* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    background: #0c0d10;
    color: #d8dae0;
    font-family: "Segoe UI", system-ui, sans-serif;
    overflow: hidden;
}

#layout { display: flex; height: 100%; }

#sidebar {
    width: 360px;
    min-width: 360px;
    background: #121318;
    border-right: 1px solid #23252c;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#map-wrap { flex: 1; position: relative; }
#map { width: 100%; height: 100%; display: block; cursor: grab; }
#map:active { cursor: grabbing; }

#loading {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: #0c0d10; color: #8a8fa0;
    font-size: 14px; letter-spacing: 0.08em;
    z-index: 10;
}

/* ---- Panel chrome ---- */
.panel-head {
    padding: 14px 16px 12px;
    border-bottom: 1px solid #23252c;
    background: #15161c;
}
.city-name {
    font-size: 19px; font-weight: 700; letter-spacing: 0.12em;
    text-transform: uppercase;
}
.city-era { font-size: 11px; color: #7a7f90; margin-top: 2px; }

#intel-search {
    width: 100%; margin-top: 10px;
    background: #0d0e12; border: 1px solid #2a2d36; border-radius: 4px;
    color: #d8dae0; padding: 7px 10px; font-size: 12px;
}
#intel-search:focus { outline: none; border-color: #4a5065; }

.panel-body { flex: 1; overflow-y: auto; }
.panel-body::-webkit-scrollbar { width: 8px; }
.panel-body::-webkit-scrollbar-thumb { background: #2a2d36; border-radius: 4px; }

/* ---- Roster ---- */
details.faction { border-bottom: 1px solid #1c1e24; }
details.faction summary {
    display: flex; align-items: center; gap: 8px;
    padding: 11px 16px; cursor: pointer; list-style: none;
    user-select: none;
}
details.faction summary::-webkit-details-marker { display: none; }
details.faction summary:hover { filter: brightness(1.35); }
.f-name { font-weight: 600; font-size: 13px; flex: 1; }
.f-type { font-size: 10px; color: #7a7f90; text-transform: uppercase; letter-spacing: 0.06em; }
.f-meta { padding: 0 16px 8px 34px; font-size: 11px; color: #7a7f90; }

.swatch {
    width: 10px; height: 10px; border-radius: 2px; display: inline-block;
    flex-shrink: 0; border: 1px solid rgba(255,255,255,0.15);
}
.swatch.big { width: 22px; height: 22px; border-radius: 4px; margin-right: 6px; }
.swatch.big.pickable { position: relative; cursor: pointer; overflow: hidden; }
.swatch.big.pickable:hover { box-shadow: 0 0 0 2px #6f7688; }
.swatch.big.pickable input[type="color"] {
    position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%;
    padding: 0; border: none; cursor: pointer;
}

.set-list { list-style: none; }
.set-item {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 16px 7px 26px; cursor: pointer; font-size: 12px;
}
.set-item:hover { background: #1a1c24; }
.s-name { flex: 1; }
.s-abbr { color: #9298aa; font-size: 10px; font-weight: 600; }
.s-regions { color: #5d6272; font-size: 9px; letter-spacing: 0.04em; }

/* ---- Intel card ---- */
.card-head { border-left: 4px solid; }
#intel-back {
    background: none; border: none; color: #8a8fa0; font-size: 11px;
    cursor: pointer; padding: 0 0 6px;
}
#intel-back:hover { color: #d8dae0; }
.card-title { font-size: 17px; font-weight: 700; }
.card-sub { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
    font-size: 10px; padding: 3px 9px; border-radius: 10px; line-height: 1.5;
    border: 1px solid #3a3e4c; background: #1c1e26; letter-spacing: 0.05em;
}
/* Incident type is a sentence, not a chip — give it room. */
.card-type {
    margin-top: 7px; font-size: 11px; line-height: 1.5; color: #9aa3b2;
    border-left: 2px solid #3a4a68; padding-left: 9px;
}

/* Two columns so a long value wraps in its own column instead of crushing
   the label against it. */
.meta-row {
    display: grid; grid-template-columns: 88px 1fr; gap: 14px;
    padding: 9px 16px; border-bottom: 1px solid #1a1c22; font-size: 12px;
    align-items: start;
}
.m-label {
    color: #7a7f90; font-size: 10px; letter-spacing: 0.07em;
    text-transform: uppercase; padding-top: 2px;
}
.m-value { line-height: 1.5; overflow-wrap: anywhere; }

.card-section { padding: 12px 16px; border-bottom: 1px solid #1a1c22; }
.card-section h3 {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
    color: #7a7f90; margin-bottom: 8px;
}
.card-section p { font-size: 12px; line-height: 1.55; color: #b8bcc8; }

.chapter {
    padding: 8px 10px; margin-bottom: 6px; border-radius: 4px;
    background: #17181f; cursor: pointer; border: 1px solid #23252c;
}
.chapter:hover { border-color: #3a3e4c; }
.ch-region {
    font-size: 11px; font-weight: 600;
    display: flex; justify-content: space-between; gap: 8px; align-items: baseline;
}
.ch-pop { font-size: 10px; font-weight: 400; color: #8a8fa0; white-space: nowrap; }
.ch-artic { font-size: 11px; color: #8a8fa0; margin-top: 3px; line-height: 1.4; }

.palette { display: flex; margin-bottom: 8px; }

.relation { padding: 7px 0; font-size: 12px; }
.rel-kind {
    font-size: 9px; font-weight: 700; letter-spacing: 0.08em;
    padding: 1px 6px; border-radius: 3px; margin-right: 6px;
    background: #33202a; color: #e08098;
}
.relation-internal .rel-kind { background: #2a2a20; color: #d0c880; }
.rel-note { font-size: 11px; color: #8a8fa0; margin-top: 3px; }

.term { font-size: 12px; padding: 4px 0; color: #b8bcc8; line-height: 1.5; }

.muted { color: #6a6f80; font-size: 11px; }

/* ---- Save status pill ---- */
.save-status {
    position: absolute; z-index: 26; right: 12px; bottom: 12px;
    background: #16171d; border: 1px solid #2e313c; border-radius: 14px;
    color: #9aa3b2; padding: 5px 12px; font-size: 11px; font-weight: 600;
    letter-spacing: 0.04em; pointer-events: none; opacity: 0;
    transition: opacity 0.4s ease;
}
.save-status.saved { color: #7fd6a0; border-color: #2f5a42; }
.save-status.saving { color: #d6c77f; border-color: #5a5330; }
.save-status.error { color: #e88; border-color: #6a3030; }

/* ---- Shared-server bar ---- */
.share-bar {
    display: flex; align-items: center; gap: 8px; justify-content: space-between;
    padding: 7px 10px; font-size: 10px; color: #8a90a0;
    background: #14151b; border-top: 1px solid #23252c;
}
.share-bar.editing { color: #7fd6a0; }
.share-bar button {
    background: #1c1e26; border: 1px solid #2e313c; border-radius: 3px;
    color: #9aa3b2; font-size: 9px; letter-spacing: 0.08em; padding: 4px 9px;
    cursor: pointer; font-family: inherit; flex-shrink: 0;
}
.share-bar button:hover { background: #232631; color: #d8dae0; }

/* ---- Sidebar footer ---- */
.panel-foot {
    display: flex; gap: 6px; padding: 8px 10px;
    border-top: 1px solid #23252c; background: #15161c;
}
.panel-foot button {
    flex: 1; background: #1c1e26; border: 1px solid #2e313c; border-radius: 4px;
    color: #9aa3b2; font-size: 10px; padding: 6px 4px; cursor: pointer;
    letter-spacing: 0.04em; font-family: inherit;
}
.panel-foot button:hover { background: #232631; color: #d8dae0; }
.panel-foot button.danger:hover { background: #3a2027; color: #f0c0c8; border-color: #5c2f3a; }

/* ---- Color picker (per-set palette options) ---- */
.color-options { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.color-opt {
    width: 26px; height: 26px; border-radius: 5px; cursor: pointer;
    border: 2px solid transparent; box-shadow: 0 0 0 1px rgba(255,255,255,0.15) inset;
}
.color-opt:hover { border-color: #6f7688; }
.color-opt.active { border-color: #fff; }

/* ---- Map layer toggles ---- */
.layer-list { list-style: none; }
.layer-item {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 16px 6px 20px; cursor: pointer; font-size: 12px; user-select: none;
}
.layer-item:hover { background: #1a1c24; }
.layer-item.off { opacity: 0.42; }
.layer-box {
    width: 13px; height: 13px; border-radius: 3px; border: 1px solid #4a5065;
    background: #0d0e12; font-size: 9px; line-height: 12px; text-align: center;
    color: #7fd6a0; flex-shrink: 0;
}
.layer-item.off .layer-box { border-color: #2e313c; }

/* ---- Cross-street search hit ---- */
.cross-hit {
    margin: 10px 12px; padding: 10px 12px; border-radius: 5px;
    background: #17222e; border: 1px solid #2f4a63; cursor: pointer;
}
.cross-hit:hover { background: #1d2b3a; border-color: #43678a; }
.cross-label {
    font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: #6f93b5;
}
.cross-name { font-size: 13px; font-weight: 600; margin-top: 3px; color: #dbe6f2; }
.cross-sub { font-size: 10px; color: #7d8da0; margin-top: 2px; }

/* ---- Directory sections ---- */
.dir-head {
    padding: 14px 16px 6px; font-size: 9px; letter-spacing: 0.16em;
    text-transform: uppercase; color: #5d6272; border-top: 1px solid #23252c;
    margin-top: 6px;
}
details.dir summary { background: #14151b; }
.dir-title { flex: 1; font-weight: 600; font-size: 12px; color: #c6cbd6; }
.dir-icon { width: 14px; text-align: center; font-size: 11px; flex-shrink: 0; }
.dir-empty { padding: 8px 16px 10px 26px; font-size: 11px; color: #5d6272; font-style: italic; }
.dir-add { padding: 4px 16px 10px 26px; }
.dir-add button {
    background: #1c1e26; border: 1px dashed #3a3e4c; border-radius: 4px;
    color: #8a90a0; font-size: 10px; padding: 5px 10px; cursor: pointer;
    letter-spacing: 0.06em; font-family: inherit;
}
.dir-add button:hover { background: #232631; color: #d8dae0; border-color: #4a5065; }
.del-btn {
    background: #2a1c20; border: 1px solid #4a2c34; border-radius: 3px;
    color: #d09098; font-size: 9px; letter-spacing: 0.1em; padding: 3px 9px;
    cursor: pointer; font-family: inherit;
}
.del-btn:hover { background: #3a2027; color: #f0c0c8; }
.fld select {
    display: block; width: 100%; margin-top: 5px;
    background: #0d0e12; border: 1px solid #2a2d36; border-radius: 4px;
    color: #d8dae0; padding: 7px 9px; font-size: 12px; font-family: inherit;
}
.fld input[type="color"] { height: 32px; padding: 2px; cursor: pointer; }

/* ---- Party editor rows ---- */
.party-edit {
    border: 1px solid #2a2d36; border-left: 3px solid #4a5065; border-radius: 4px;
    background: #14151b; padding: 8px; margin-bottom: 7px;
    display: flex; flex-direction: column; gap: 6px; position: relative;
}
.pe-head { display: flex; gap: 6px; align-items: center; }
.pe-two { display: flex; gap: 6px; }
.pe-two .pe-age { width: 70px; flex: none; }
.party-edit input, .party-edit select {
    width: 100%; background: #0d0e12; border: 1px solid #2a2d36; border-radius: 4px;
    color: #d8dae0; padding: 6px 8px; font-size: 11px; font-family: inherit;
}
.party-edit input:focus, .party-edit select:focus { outline: none; border-color: #4a5065; }
.pe-head .pe-role { flex: 1; font-weight: 600; }
.pe-del { position: static; width: 20px; height: 20px; flex-shrink: 0; }

/* ---- Person: mugshot & media ---- */
.person-head { display: flex; gap: 12px; align-items: center; margin-top: 4px; }
.mugshot {
    width: 62px; height: 62px; border-radius: 5px; flex-shrink: 0; overflow: hidden;
    background: #0d0e12; border: 1px solid #2e313c;
    display: flex; align-items: center; justify-content: center;
}
.mugshot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mug-empty { font-size: 8px; letter-spacing: 0.1em; color: #4d525e; }
.row-mug {
    width: 18px; height: 18px; border-radius: 3px; object-fit: cover;
    flex-shrink: 0; border: 1px solid rgba(255,255,255,0.15);
}
.photo-actions { display: flex; gap: 6px; margin-top: 9px; }
.photo-actions button {
    background: #1c1e26; border: 1px solid #2e313c; border-radius: 4px;
    color: #9aa3b2; font-size: 9px; letter-spacing: 0.08em; padding: 5px 10px;
    cursor: pointer; font-family: inherit;
}
.photo-actions button:hover { background: #232631; color: #d8dae0; }
.media-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.media-tile {
    position: relative; width: 68px; height: 68px; border-radius: 4px;
    overflow: hidden; border: 1px solid #2e313c; background: #0d0e12;
}
.media-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-tile.link {
    width: auto; max-width: 100%; height: auto; padding: 7px 26px 7px 9px;
    display: flex; align-items: center;
}
.media-tile.link a { color: #8fb3d9; font-size: 11px; text-decoration: none; word-break: break-all; }
.media-tile.link a:hover { text-decoration: underline; }
.media-x {
    position: absolute; top: 2px; right: 2px; width: 17px; height: 17px;
    border-radius: 3px; border: none; background: rgba(0,0,0,0.62);
    color: #f0c0c8; font-size: 13px; line-height: 15px; cursor: pointer; padding: 0;
}
.media-x:hover { background: #7a2030; }

/* ---- Incident reports ---- */
.loc-link { cursor: pointer; color: #9fc2e6; }
.loc-link:hover { color: #cfe3f7; text-decoration: underline; }
.loc-go {
    display: block; margin-top: 3px; font-size: 10px; color: #6f93b5;
    letter-spacing: 0.06em; text-decoration: none;
}
.loc-note {
    padding: 8px 16px; font-size: 11px; color: #8a8fa0; line-height: 1.5;
    background: #14151b; border-bottom: 1px solid #1a1c22; font-style: italic;
}
.rpt-list { list-style: none; }
.rpt-list li {
    font-size: 12px; color: #b8bcc8; line-height: 1.5; padding: 3px 0 3px 14px;
    position: relative;
}
.rpt-list li::before { content: '▸'; position: absolute; left: 0; color: #5d6272; }
.rpt-party {
    border-left: 3px solid #4a2c34; background: #17181f; border-radius: 4px;
    padding: 8px 10px; margin-bottom: 6px;
}
.rp-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.rp-role {
    font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase;
    padding: 2px 7px; border-radius: 3px; font-weight: 700;
}
.rpt-party.suspect .rp-role { background: rgba(176,74,74,0.28); color: #f0b0b0; }
.rpt-party.victim .rp-role { background: rgba(74,122,176,0.28); color: #b4d2f0; }
.rp-side {
    font-size: 9px; color: #aeb5c2; display: flex; align-items: center; gap: 5px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.rp-name { font-size: 12px; font-weight: 600; margin-top: 3px; }
.rp-set { font-size: 11px; color: #8a8fa0; margin-top: 2px; }
.rp-set[data-setlink] { cursor: pointer; color: #8fb3d9; }
.rp-set[data-setlink]:hover { text-decoration: underline; }
.rp-injury { font-size: 11px; color: #d09098; margin-top: 3px; }
#rpt-edit {
    background: #1c1e26; border: 1px solid #2e313c; border-radius: 3px;
    color: #9aa3b2; font-size: 9px; letter-spacing: 0.1em; padding: 3px 9px;
    cursor: pointer; font-family: inherit;
}
#rpt-edit:hover { background: #232631; color: #d8dae0; }

/* ---- Dossier edit form ---- */
.card-head-row { display: flex; justify-content: space-between; align-items: center; }
#intel-edit {
    background: #1c1e26; border: 1px solid #2e313c; border-radius: 3px;
    color: #9aa3b2; font-size: 9px; letter-spacing: 0.1em; padding: 3px 9px;
    cursor: pointer; font-family: inherit;
}
#intel-edit:hover { background: #232631; color: #d8dae0; }
.edited-dot { color: #7fd6a0; margin-left: 6px; font-size: 20px; line-height: 0; }

.fld {
    display: block; font-size: 10px; text-transform: uppercase;
    letter-spacing: 0.08em; color: #7a7f90; margin-bottom: 12px;
}
.fld-hint { text-transform: none; letter-spacing: 0; color: #5d6272; font-size: 9px; }
.fld input {
    display: block; width: 100%; margin-top: 5px;
    background: #0d0e12; border: 1px solid #2a2d36; border-radius: 4px;
    color: #d8dae0; padding: 7px 9px; font-size: 12px; font-family: inherit;
    text-transform: none; letter-spacing: 0;
}
.fld input:focus { outline: none; border-color: #4a5065; }

.panel-body textarea {
    width: 100%; background: #0d0e12; border: 1px solid #2a2d36; border-radius: 4px;
    color: #b8bcc8; padding: 8px 9px; font-size: 12px; line-height: 1.5;
    font-family: inherit; resize: vertical;
}
.panel-body textarea:focus { outline: none; border-color: #4a5065; }

.color-inputs { display: flex; gap: 6px; margin-bottom: 8px; }
.color-inputs input[type="color"] {
    width: 44px; height: 30px; padding: 0; border: 1px solid #2e313c;
    border-radius: 4px; background: none; cursor: pointer;
}

.edit-actions { display: flex; gap: 8px; }
.edit-actions button {
    flex: 1; border-radius: 4px; padding: 9px 6px; cursor: pointer;
    font-size: 10px; letter-spacing: 0.08em; font-family: inherit;
    border: 1px solid #2e313c; background: #1c1e26; color: #9aa3b2;
}
.edit-actions .primary { background: #22402f; border-color: #2f5a42; color: #a8e6c0; }
.edit-actions .primary:hover { background: #2a5039; }
.edit-actions .danger:hover { background: #3a2027; color: #f0c0c8; border-color: #5c2f3a; }

/* ---- Editor: context menu & swap hint ---- */
.ctx-menu {
    position: absolute; z-index: 30; min-width: 200px;
    background: #16171d; border: 1px solid #2e313c; border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    padding: 4px; font-size: 12px;
}
.ctx-item {
    padding: 8px 12px; border-radius: 4px; cursor: pointer;
    color: #d8dae0; display: flex; flex-direction: column; gap: 2px;
}
.ctx-item:hover { background: #232631; }
.ctx-item.disabled { color: #5a5f6e; cursor: default; }
.ctx-item.disabled:hover { background: none; }
.ctx-sub { font-size: 10px; color: #8a8fa0; }

.editor-hint {
    position: absolute; z-index: 25; top: 12px; left: 50%;
    transform: translateX(-50%);
    background: #16171d; border: 1px solid #3a4a68; border-radius: 6px;
    color: #cdd6e8; padding: 8px 16px; font-size: 12px; font-weight: 600;
    letter-spacing: 0.04em; box-shadow: 0 6px 18px rgba(0,0,0,0.45);
    pointer-events: none; white-space: nowrap;
}

.contested-note {
    margin: 10px 16px 0; padding: 8px 10px; border-radius: 4px;
    background: #2a1c20; border: 1px solid #4a2c34;
    font-size: 11px; color: #e0a0b0;
}
