/* 02 Strata — the layers workbench. Dark GIS chrome around a light map. */
:root {
  --ui-font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display-font: 'Inter', system-ui, sans-serif;
  --bg: #17181b;
  --panel: #1f2125;
  --panel-2: #2a2d33;
  --panel-3: #33373e;
  --line: #2a2d33;
  --line-2: #3a3e46;
  --text: #e6e7ea;
  --muted: #9aa0a8;
  --accent: #ff2d9b;
  --accent-soft: rgba(255, 45, 155, 0.16);
  --hover: #ff8f1f;
  --primary: #2f6fe4;
  --primary-text: #fff;
  --danger: #ff6b5e;
  --warn-bg: #3a2f14;
  --radius: 5px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  --header-h: 46px;
}
body { background: var(--bg); color: var(--text); font-size: 12.5px; }
h1, h2, h3 { font-family: var(--display-font); font-weight: 600; letter-spacing: -0.01em; }
code { background: rgba(255, 255, 255, 0.08); color: #cfd3da; }
kbd { border-color: var(--line-2); color: var(--muted); background: #15161a; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #3a3e46; border-radius: 5px; border: 2px solid var(--panel); }
::-webkit-scrollbar-track { background: transparent; }

/* ---- base.css overrides for dark chrome ---- */
.btn { background: var(--panel-2); border-color: var(--line-2); color: var(--text); padding: 4px 9px; border-radius: var(--radius); }
.btn:hover:not(:disabled) { background: var(--panel-3); border-color: #4a4f58; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #3f7ff0; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { background: var(--panel-2); color: var(--text); }
.btn.on { background: #1e3a6e; border-color: #2f6fe4; color: #cfe0ff; }
.btn.tool.armed { background: #5a2a0a; border-color: #c2410c; color: #ffd9c2; }
.seg { background: var(--panel-2); border-color: var(--line-2); }
.seg-btn { color: var(--muted); padding: 4px 9px; }
.seg-btn.on { background: #e6e7ea; color: #17181b; }
.toggle { background: var(--panel-2); border-color: var(--line-2); color: var(--muted); }
.toggle.on { background: var(--panel-3); border-color: #4a4f58; color: var(--text); }
input[type="text"], input[type="search"], input[type="number"], select, input:not([type]) { background: #15161a; border-color: var(--line-2); color: var(--text); border-radius: 4px; }
input:focus, select:focus { outline: 1px solid var(--primary); outline-offset: 0; }
input[type="range"] { accent-color: #8fb4ff; }
.switch .track { background: #3a3e46; }
.switch input:checked + .track { background: var(--primary); }
.chip { background: var(--panel-3); color: #c3c7ce; }
.chip.gm { background: #4a1d1a; color: #ffb4ad; }
.lock-badge { background: #4a3812; color: #ffd27a; }
.gm-badge { background: #4a1d1a; color: #ffb4ad; }
.warning { background: var(--warn-bg); color: #f3d38b; }
button.link, .btn.link { color: #8fb4ff; }
.list-head .search { background: #15161a; border-color: var(--line-2); }
.list-head .search input { color: var(--text); }
.element-list .item:hover, .element-list .item.hovered { background: rgba(255, 143, 31, 0.16); box-shadow: inset 3px 0 0 var(--hover); }
.element-list .item.selected, .element-list .item.selected.hovered { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.element-list .group { color: #7d838c; }
.element-list .lock-ic { color: #ffd27a; }
.ctx-menu, .popover { background: #24272c; border-color: var(--line-2); box-shadow: var(--shadow); }
.ctx-item:hover:not(:disabled) { background: var(--panel-3); }
.ctx-title { color: var(--muted); }
table.props tr { border-top-color: var(--line); }
table.props th { color: var(--muted); }
.el-deps { border-top-color: var(--line); }
.el-head h2 { font-size: 17px; }
.var-group { background: transparent; border-color: var(--line-2); }
.var-row { border-top-color: var(--line); }
.impact { background: var(--panel-3); color: var(--muted); }
.impact.hot { background: var(--accent-soft); color: var(--accent); }
.crumb { color: var(--muted); }
.crumb:hover:not(:disabled) { background: var(--panel-2); color: var(--text); }
.crumb.current { color: var(--text); }
.crumb-scale { color: #7d838c; }
.progress-wrap { top: var(--header-h); }
.progress { background: rgba(31, 33, 37, 0.96); border-bottom: 1px solid var(--line-2); height: 20px; }
.progress-bar { background: var(--primary); opacity: 0.8; }
.progress-label { color: var(--text); font-size: 11px; }
.toast { background: #24272c; border-color: var(--line-2); color: var(--text); }
.toast.warn { border-left-color: var(--hover); }
.floor-select select { padding: 3px 6px; }

/* ---- app frame ---- */
.app { display: flex; flex-direction: column; height: 100vh; }
.hdr { display: grid; grid-template-columns: minmax(0, 1.5fr) auto minmax(0, 1fr); align-items: center; height: var(--header-h); padding: 0 10px; background: var(--panel); border-bottom: 1px solid var(--line-2); gap: 12px; }
.hdr-left, .hdr-right, .hdr-center { display: flex; align-items: center; gap: 8px; min-width: 0; }
/* breadcrumb clips from the left so the current crumb always stays visible */
.crumb-wrap { min-width: 0; overflow: hidden; direction: rtl; }
.hdr .breadcrumb { display: inline-flex; direction: ltr; white-space: nowrap; }
.hdr .crumb:not(.current) .crumb-scale { display: none; }
.hdr-left .btn, .brand { flex: none; }
.hdr-right { justify-content: flex-end; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; letter-spacing: 0.02em; padding-right: 10px; border-right: 1px solid var(--line-2); }
.brand .mark { width: 16px; height: 16px; display: inline-grid; grid-template-rows: repeat(3, 1fr); gap: 2px; }
.brand .mark i { display: block; border-radius: 1px; background: #8fb4ff; }
.brand .mark i:nth-child(2) { background: var(--accent); width: 70%; }
.brand .mark i:nth-child(3) { background: #7fb07a; width: 45%; }
.hdr .breadcrumb { flex-wrap: nowrap; overflow: hidden; }
.hdr .crumb { padding: 2px 6px; }
.hdr .crumb-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.hdr .crumb:not(.current) .crumb-label { max-width: 100px; }
.hdr .row { gap: 2px; }
.divider { width: 1px; height: 22px; background: var(--line-2); }

.work { display: grid; grid-template-columns: 280px 1fr 320px; flex: 1; min-height: 0; }
.col { background: var(--panel); min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.col.left { border-right: 1px solid var(--line-2); grid-column: 1; grid-row: 1; }
.col.right { border-left: 1px solid var(--line-2); grid-column: 3; grid-row: 1; }
.col-scroll { overflow: auto; flex: 1; min-height: 0; }
.sec { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); }
.sec-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sec-head h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.sec-head .mini { display: flex; gap: 4px; align-items: center; }
.mini-btn { border: none; background: none; color: var(--muted); padding: 2px 5px; border-radius: 3px; cursor: pointer; font-size: 11px; display: inline-flex; align-items: center; gap: 4px; }
.mini-btn:hover { background: var(--panel-2); color: var(--text); }
.mini-btn.on { color: #cfe0ff; background: #1e3a6e; }

/* ---- layers panel ---- */
.layer-row { display: grid; grid-template-columns: 22px 1fr 72px 34px; align-items: center; gap: 6px; padding: 3px 0; border-radius: 4px; }
.layer-row:hover { background: rgba(255, 255, 255, 0.03); }
.layer-row.off { color: var(--muted); }
.layer-row.off .layer-name { text-decoration: line-through; text-decoration-color: rgba(255,255,255,0.25); }
.layer-row.solo { background: rgba(47, 111, 228, 0.16); box-shadow: inset 2px 0 0 var(--primary); }
.layer-row.na { opacity: 0.4; }
.eye { border: none; background: none; color: var(--text); width: 22px; height: 22px; display: inline-grid; place-items: center; border-radius: 4px; cursor: pointer; padding: 0; }
.eye:hover { background: var(--panel-3); }
.layer-row.off .eye { color: var(--muted); }
.layer-name { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.layer-row input[type="range"] { width: 72px; min-width: 0; height: 14px; }
.layer-pct { font-size: 10.5px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.solo-note { margin: 8px 0 0; font-size: 10.5px; color: #7d838c; }
.density { display: grid; grid-template-columns: 1fr 72px 34px; align-items: center; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line-2); font-size: 12px; color: var(--muted); }
.density input[type="range"] { width: 72px; min-width: 0; }

/* ---- legend ---- */
.legend-group { margin-top: 6px; }
.legend-group:first-child { margin-top: 0; }
.legend-title { font-size: 10.5px; color: #7d838c; text-transform: uppercase; letter-spacing: 0.06em; margin: 6px 0 2px; }
.legend-row { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 8px; padding: 2px 4px; border-radius: 4px; cursor: pointer; }
.legend-row:hover { background: rgba(255, 255, 255, 0.04); }
.legend-row.active { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.legend-row.zero { opacity: 0.45; }
.legend-row .cnt { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.legend-svg.mapsvg { background: none; cursor: inherit; width: 26px; height: 22px; display: block; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 9px; border-radius: 999px; background: var(--accent-soft); border: 1px solid rgba(255, 45, 155, 0.5); color: #ffd1e9; font-size: 11.5px; }
.filter-chip button { border: none; background: rgba(255,255,255,0.1); color: inherit; border-radius: 999px; width: 18px; height: 18px; display: grid; place-items: center; cursor: pointer; padding: 0; }
.filter-chip button:hover { background: rgba(255,255,255,0.25); }

/* ---- map pane ---- */
.center { position: relative; min-width: 0; background: #101114; grid-column: 2; grid-row: 1; }
.center .mapsvg-container { position: absolute; inset: 0; }
.center .mapsvg { box-shadow: inset 0 0 0 1px rgba(0,0,0,0.5); }
.center.tool-battle .mapsvg { cursor: cell; }
.map-tools { position: absolute; left: 10px; top: 10px; display: flex; gap: 6px; align-items: center; z-index: 5; }
.map-tools .btn { background: rgba(31, 33, 37, 0.92); backdrop-filter: blur(4px); box-shadow: 0 2px 8px rgba(0,0,0,0.35); }
.map-tools .btn kbd { margin-left: 2px; border-color: rgba(255,255,255,0.18); }
.map-tools .floor-select { background: rgba(31, 33, 37, 0.92); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 2px 6px; color: var(--text); }
.map-chips { position: absolute; right: 10px; top: 10px; display: flex; gap: 6px; z-index: 5; }
.status { position: absolute; left: 10px; bottom: 8px; display: flex; gap: 10px; align-items: center; font-size: 11px; color: #cfd3da; background: rgba(31, 33, 37, 0.9); padding: 3px 8px; border-radius: 4px; pointer-events: none; font-variant-numeric: tabular-nums; z-index: 5; }
.status b { color: #fff; font-weight: 600; }
.status .dot { width: 6px; height: 6px; border-radius: 50%; background: #7fb07a; }
.status .dot.busy { background: var(--hover); }
.tool-hint { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); background: rgba(90, 42, 10, 0.95); color: #ffd9c2; border: 1px solid #c2410c; padding: 5px 12px; border-radius: 999px; font-size: 12px; z-index: 5; pointer-events: none; }
.tile-tip { position: absolute; z-index: 6; pointer-events: none; background: rgba(31, 33, 37, 0.96); color: var(--text); border: 1px solid var(--line-2); border-radius: 6px; padding: 6px 9px; font-size: 11.5px; box-shadow: var(--shadow); min-width: 150px; max-width: 240px; }
.tile-tip .tt-title { font-weight: 600; font-size: 12px; display: flex; justify-content: space-between; gap: 8px; }
.tile-tip .tt-title span:last-child { color: #8fb4ff; font-weight: 500; }
.tile-tip .tt-k { color: var(--muted); margin-top: 1px; }
.tile-tip ul { margin: 4px 0 0; padding: 0 0 0 14px; }
.tile-tip li { line-height: 1.35; }
.tile-tip .tt-hint { margin-top: 5px; color: #7d838c; font-size: 10.5px; }

/* map skin: symbol mode flat fills, tile grid readable, strong selection */
.center .mapsvg { --sel: #d5006c; --hov: #ff8f1f; --preview: #1273d8; }
.center .mapsvg .tile-line { stroke-opacity: 0.7; stroke-dasharray: none; stroke-width: 0.8px; }
.center .mapsvg[data-lod="0"] .tile-line { stroke-opacity: 0.25; }
.center .mapsvg .tile-hl { fill-opacity: 0.16; stroke-width: 2px; }
.center .mapsvg .preview-mask { fill-opacity: 0.22; }
.center .mapsvg .preview-frame { stroke-width: 2.5px; stroke-dasharray: none; }
.center .mapsvg .preview-body { fill-opacity: 0.02; }
.mapsvg .hl-sel .hl-glow.area { stroke-width: 14px; stroke-opacity: 0.32; }
.mapsvg .hl-sel .hl-glow.line { stroke-width: 16px; }
.mapsvg .hl-sel .hl-shape.area, .mapsvg .hl-sel .hl-shape.line { stroke-width: 3px; stroke-dasharray: 9 6; animation: ants 0.8s linear infinite; }
.mapsvg .hl-sel .hl-shape:not(.area):not(.line) { stroke-dasharray: 4 3; animation: ants 0.8s linear infinite; }
.mapsvg .hl-sel .hl-ring { stroke-width: 3; stroke-dasharray: 6 4; animation: ants 0.8s linear infinite; filter: drop-shadow(0 0 1.5px #fff); }
.mapsvg .hl-sel .hl-ring-outer { fill-opacity: 0.28; }
@keyframes ants { to { stroke-dashoffset: -15; } }
.mapsvg .hl-hov .hl-ring { stroke-width: 2.5; filter: drop-shadow(0 0 1.5px #fff); }
.mapsvg .hl-hov .hl-shape.area { stroke-width: 2.5px; }
.mapsvg .dim-veil { fill-opacity: 0.45; }

/* ---- right column: card + tabs ---- */
.card-slot { border-bottom: 1px solid var(--line-2); background: #1b1d21; }
.card { padding: 10px 12px 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-head h3 { font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-head h3 > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.card-head .kind { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: #8fb4ff; font-weight: 600; }
.card-head .kind.battle { color: #ffb289; }
.thumb-wrap { position: relative; border: 1px solid var(--line-2); border-radius: 4px; overflow: hidden; background: #f4f2ec; }
.thumb { height: 280px; }
.thumb.wide { height: 200px; }
.thumb.battle { height: 240px; }
.thumb .mapsvg { cursor: default; box-shadow: none; }
.thumb.reanchor .mapsvg { cursor: grab; }
.thumb .mapsvg .lbl.tier-1, .thumb .mapsvg .lbl.tier-2, .thumb .mapsvg .lbl.tier-3 { display: none; }
.thumb .mapsvg .lbl-settlement { font-size: calc(var(--upp) * 10); }
.thumb .mapsvg .preview-label, .thumb .mapsvg .preview-sublabel { font-size: calc(var(--upp) * 10.5); }
.thumb .mapsvg .preview-mask { fill-opacity: 0.35; }
.thumb-badge { position: absolute; left: 6px; top: 6px; background: rgba(31, 33, 37, 0.9); color: #fff; font-size: 10.5px; padding: 2px 7px; border-radius: 999px; pointer-events: none; }
.thumb-badge.right { left: auto; right: 6px; }
.thumb-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(23, 24, 27, 0.55); color: #fff; font-size: 12px; pointer-events: none; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 10px 0; font-size: 12px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.card-actions .btn.primary { flex: 1; justify-content: center; }
.card-actions select { padding: 3px 6px; }
.nudge { display: grid; grid-template-columns: repeat(3, 22px); grid-template-rows: repeat(2, 22px); gap: 2px; }
.nudge .btn { padding: 0; width: 22px; height: 22px; justify-content: center; }
.nudge .n-up { grid-column: 2; grid-row: 1; } .nudge .n-left { grid-column: 1; grid-row: 2; } .nudge .n-down { grid-column: 2; grid-row: 2; } .nudge .n-right { grid-column: 3; grid-row: 2; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; background: var(--panel-2); }
.stepper button { border: none; background: none; color: var(--text); width: 22px; height: 24px; cursor: pointer; }
.stepper button:hover { background: var(--panel-3); }
.stepper span { min-width: 30px; text-align: center; font-variant-numeric: tabular-nums; font-size: 12px; }
.stepper label { font-size: 10.5px; color: var(--muted); padding: 0 6px; border-right: 1px solid var(--line-2); height: 24px; display: inline-flex; align-items: center; }
.card-hint { color: #7d838c; font-size: 11px; margin: 8px 0 0; line-height: 1.4; }
.card.empty { color: var(--muted); font-size: 12px; display: flex; gap: 8px; align-items: center; }
.card.empty .icon { color: #8fb4ff; }

.tabs { display: flex; border-bottom: 1px solid var(--line-2); background: var(--panel); padding: 0 6px; }
.tab { flex: 1; border: none; background: none; color: var(--muted); padding: 9px 6px 8px; font-weight: 500; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 6px; align-items: center; justify-content: center; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.tab .cnt { font-size: 10px; background: var(--panel-3); padding: 0 5px; border-radius: 999px; color: var(--muted); }
.tab-body { padding: 10px 12px 14px; }
.tab-body[hidden] { display: none; }
.tab-body .element-list { max-height: none; }
.tab-body .el-nav .btn.primary { justify-content: center; }
.tab-body .map-info h2 { font-size: 16px; }
.tab-body .var-group summary { padding: 6px 8px; }

/* ---- about ---- */
.about-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 1200; display: grid; place-items: center; }
.about-backdrop[hidden] { display: none; }
.about { width: 640px; max-height: 84vh; overflow: auto; background: #24272c; border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); padding: 20px 24px 22px; }
.about h2 { font-size: 18px; margin-bottom: 4px; }
.about .lead { color: var(--muted); margin: 0 0 14px; }
.about h4 { margin: 14px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: #8fb4ff; }
.about p, .about li { font-size: 12.5px; line-height: 1.5; margin: 0; }
.about ul { margin: 0; padding-left: 18px; }
.about .keys { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 18px; margin-top: 4px; }
.about .keys div { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; padding: 3px 0; border-bottom: 1px dashed var(--line-2); }
.about .keys kbd { margin: 0; }
.about-close { float: right; }

/* ---- world list ---- */
.list-screen { flex: 1; overflow: auto; }
.world-list { grid-template-columns: 1fr 340px; max-width: 1180px; padding: 28px 32px; gap: 28px; }
.world-create { order: 2; background: #1b1d21; border-color: var(--line-2); border-radius: 8px; position: sticky; top: 0; }
.world-create h3 { font-size: 14px; }
.world-create label { color: var(--muted); }
.world-create label.file-btn { flex-direction: row; align-items: center; color: var(--text); }
.world-cards { order: 1; align-self: start; display: flex; flex-direction: column; gap: 0; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; background: #1b1d21; }
.world-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 16px; border: none; border-top: 1px solid var(--line); border-radius: 0; padding: 12px 16px; background: transparent; }
.world-card:first-child { border-top: none; }
.world-card:hover { background: rgba(255, 255, 255, 0.025); }
.world-card-head { grid-column: 1; justify-content: flex-start; }
.world-card-head h3 { font-size: 15px; font-weight: 600; }
.world-card p { grid-column: 1; margin: 0; }
.world-card .actions { grid-column: 2; grid-row: 1 / span 2; }
.list-intro { max-width: 1180px; margin: 0 auto; padding: 28px 32px 0; }
.list-intro h2 { font-size: 20px; }
.list-intro p { color: var(--muted); margin: 4px 0 0; }
.list-intro + .list-body .world-list { padding-top: 14px; }
