:root {
  --ink: #efe4c6;
  --ink-dim: #b9ab88;
  --gold: #c9a45c;
  --gold-bright: #ecd08e;
  --panel: rgba(16, 25, 35, 0.98);
  --panel-2: rgba(28, 41, 56, 0.98);
  --line: rgba(201, 164, 92, 0.55);
  --serif: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Noto Serif KR", "Nanum Myeongjo", AppleMyungjo, Batang, "Apple SD Gothic Neo", "Malgun Gothic", serif;
  --sans: -apple-system, "Segoe UI", system-ui, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  --topbar-h: 40px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d2a47; color: var(--ink); font-family: var(--sans); }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* The Korean name beside an English one (place.js placeHtml): smaller and quieter than the name it glosses. */
.alt-name { font-weight: normal; letter-spacing: 0; opacity: .72; white-space: nowrap; }
h1 .alt-name, h2 .alt-name, h3 .alt-name { font-size: .62em; }
.muted { color: var(--ink-dim); }
svg.icon { display: inline-block; flex: none; }
.emoji { display: inline-block; line-height: 1; vertical-align: middle; }
:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }

#map { position: fixed; inset: 0; width: 100%; height: 100%; cursor: grab; display: block; touch-action: none; }
#map.dragging { cursor: grabbing; }

.panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 8px 24px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,235,190,.08);
  border-radius: 6px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.icon-btn {
  display: inline-grid; place-items: center; width: 26px; height: 26px; padding: 0; cursor: pointer;
  background: rgba(0,0,0,.3); border: 1px solid rgba(201,164,92,.45); border-radius: 50%; color: var(--ink-dim);
}
.icon-btn:hover { color: var(--gold-bright); border-color: var(--gold); }

/* ---------- top bar ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); z-index: 10;
  display: flex; align-items: center; gap: 16px; padding: 0 12px;
  background: linear-gradient(180deg, #24364a, #131e2a);
  border-bottom: 1px solid var(--gold);
  box-shadow: 0 2px 10px rgba(0,0,0,.5), inset 0 -3px 0 rgba(0,0,0,.25);
  font-variant-numeric: tabular-nums;
}
.brand { font-family: var(--serif); font-weight: bold; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-bright); white-space: nowrap; display: flex; align-items: center; flex: none; }
.brand-emblem { display: inline-block; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--gold); margin-right: 6px; box-shadow: 0 0 0 2px rgba(0,0,0,.4);
  background: #0047a0 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath fill='%23cd2e3a' d='M0 24a24 24 0 0 1 48 0a12 12 0 0 1-24 0a12 12 0 0 0-24 0z'/%3E%3C/svg%3E") center / 100% 100% no-repeat; }
.yields { display: flex; align-items: center; gap: 14px; flex: none; }
.yield {
  position: relative; display: flex; align-items: center; gap: 5px; font-weight: 600; font-size: 14px; white-space: nowrap; cursor: pointer; border-radius: 4px;
  background: none; border: 1px solid transparent; padding: 1px 4px 3px; margin: 0 -5px; font-variant-numeric: tabular-nums; color: var(--yc);
}
.yield .ico { display: inline-flex; filter: drop-shadow(0 1px 1px rgba(0,0,0,.6)); }
/* The number under its name: the name costs the bar no width. */
.yv { display: flex; flex-direction: column; align-items: flex-start; }
.yl { font-size: 10px; line-height: 11px; font-weight: 500; letter-spacing: .04em; color: var(--ink-dim); }
.yn { line-height: 17px; }
/* The four yields that are parts of Gold: one bracket, named once. */
.yield-parts { display: flex; align-items: center; gap: 14px; padding: 0 9px 0 0; border: 1px solid rgba(201,164,92,.38); border-left: 2px solid var(--gold); border-radius: 0 5px 5px 0; background: rgba(0,0,0,.18); }
.yp-cap { align-self: stretch; display: flex; align-items: center; padding: 0 7px; margin-right: -4px; font-size: 10px; line-height: 11px; color: var(--gold); white-space: nowrap; background: rgba(201,164,92,.12); }
/* The caret sits over the button's bottom padding (out of the flex flow), so the bar is exactly as wide as before. */
.yield .caret { position: absolute; left: 50%; bottom: 0; margin-left: -3.5px; width: 0; height: 0; border-left: 3.5px solid transparent; border-right: 3.5px solid transparent; border-top: 3px solid var(--gold); opacity: .45; transition: transform .15s, opacity .15s; pointer-events: none; }
.yield:hover { background: rgba(201,164,92,.12); border-color: rgba(201,164,92,.35); }
.yield:hover .caret { opacity: 1; }
.yield.open { background: linear-gradient(180deg, rgba(90,74,36,.85), rgba(58,47,21,.85)); border-color: var(--gold-bright); }
.yield.open .caret { opacity: 1; transform: rotate(180deg); border-top-color: var(--gold-bright); }
.spacer { flex: 1; min-width: 0; }
.turn { font-family: var(--serif); color: var(--ink-dim); font-size: 13px; white-space: nowrap; flex: none; }
.turn b { color: var(--gold-bright); }
.tb-buttons { display: flex; gap: 6px; flex: none; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; flex: none;
  background: linear-gradient(180deg, #3a5068, #223244); border: 1px solid var(--gold); border-radius: 4px;
  padding: 4px 10px; cursor: pointer; font-family: var(--serif); font-size: 13px; color: var(--gold-bright); line-height: 18px;
  box-shadow: inset 0 1px 0 rgba(255,235,190,.15), 0 1px 2px rgba(0,0,0,.5);
}
.btn:hover { background: linear-gradient(180deg, #4a6584, #2b4057); }
.btn[aria-expanded="true"] { background: linear-gradient(180deg, #5a4a24, #3a2f15); }
.btn-icon { padding: 4px 7px; }

/* search */
.search { position: relative; display: flex; align-items: center; flex: 0 1 230px; min-width: 150px; }
.search-ic { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); color: var(--ink-dim); display: inline-flex; pointer-events: none; }
#search-input {
  width: 100%; height: 28px; padding: 0 34px 0 28px; border-radius: 14px; text-overflow: ellipsis; font: 13px var(--sans); color: var(--ink);
  background: rgba(0,0,0,.35); border: 1px solid rgba(201,164,92,.5); outline: none;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.5);
}
#search-input::placeholder { color: rgba(185,171,136,.75); }
#search-input:focus { border-color: var(--gold-bright); background: rgba(0,0,0,.5); }
#search-input::-webkit-search-cancel-button { display: none; }
.search-kbd { position: absolute; right: 7px; top: 50%; transform: translateY(-50%); pointer-events: none; }
#search-input:focus ~ .search-kbd { display: none; }
kbd {
  display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 3px; font: 11px/16px var(--sans); text-align: center;
  color: var(--gold-bright); background: rgba(255,235,190,.08); border: 1px solid rgba(201,164,92,.5); border-bottom-width: 2px;
}
.search-results { position: fixed; z-index: 40; max-height: min(420px, 70vh); overflow-y: auto; padding: 4px; }
.sr-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.sr-item.sel { background: linear-gradient(90deg, rgba(201,164,92,.28), rgba(201,164,92,.08)); }
.sr-ic { color: var(--gold); display: inline-flex; }
.sr-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sr-main b { font-family: var(--serif); color: var(--gold-bright); font-weight: normal; font-size: 14px; }
.sr-sub { color: var(--ink-dim); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-pop { color: var(--ink-dim); font-variant-numeric: tabular-nums; font-size: 12px; }
.sr-empty { padding: 10px; color: var(--ink-dim); font-size: 13px; }

/* share popover + toast */
.share-pop { position: fixed; z-index: 40; width: 250px; padding: 8px; }
.sp-title { font-family: var(--serif); color: var(--gold); font-size: 11px; letter-spacing: .18em; text-transform: uppercase; padding: 2px 6px 6px; }
.sp-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px; border-radius: 4px; cursor: pointer; background: none; border: 1px solid transparent; color: var(--ink); font-size: 13px; }
.sp-item svg { color: var(--gold-bright); }
.sp-item:hover, .sp-item:focus-visible { background: rgba(201,164,92,.15); border-color: rgba(201,164,92,.35); }
.sp-item .muted { font-size: 11px; margin-left: 4px; }
.sp-status { font-size: 12px; color: var(--ink-dim); padding: 4px 8px 0; min-height: 0; }
.sp-status:empty { display: none; }
.sp-url { width: 100%; margin-top: 6px; font: 12px var(--sans); padding: 5px; color: var(--ink); background: rgba(0,0,0,.4); border: 1px solid var(--line); border-radius: 3px; }
.toast {
  position: fixed; top: 54px; left: 50%; transform: translateX(-50%); z-index: 45; padding: 7px 14px; border-radius: 16px;
  background: rgba(16,25,35,.96); border: 1px solid var(--gold); color: var(--gold-bright); font: 13px var(--serif); letter-spacing: .04em;
  box-shadow: 0 6px 18px rgba(0,0,0,.5);
}

/* ---------- top-bar reports (ui/yieldReport.js) ---------- */
.yield-report {
  --yc: var(--gold-bright);
  position: fixed; z-index: 28; width: 450px; max-width: calc(100vw - 16px); max-height: calc(100vh - 64px); max-height: calc(100dvh - 64px);
  overflow-y: auto; overscroll-behavior: contain; padding: 0 0 12px; outline: none;
  border: 1px solid var(--gold); border-top: 3px solid var(--gold);
  box-shadow: 0 0 0 1px rgba(0,0,0,.7), inset 0 0 0 1px rgba(255,235,190,.07), 0 14px 34px rgba(0,0,0,.6);
}
.yr-head { position: relative; display: flex; align-items: center; gap: 10px; padding: 12px 14px 8px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,235,190,.07), transparent); }
.yr-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: linear-gradient(90deg, var(--yc), transparent 70%); opacity: .7; }
.yr-ic { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 50% 35%, #2a3c52, #121b26); border: 2px solid var(--gold); box-shadow: 0 0 0 1px #120d06, inset 0 0 6px rgba(0,0,0,.6); }
.yr-ic svg, .yr-ic .emoji { filter: drop-shadow(0 1px 1px rgba(0,0,0,.6)); }
.yr-titles { flex: 1; min-width: 0; }
.yr-kind { font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--gold); }
.yr-head h2 { margin: 0; font: normal 21px var(--serif); letter-spacing: .08em; text-transform: uppercase; color: var(--gold-bright); line-height: 1.15; }
.yr-close { flex: none; align-self: flex-start; }
.yr-total { padding: 10px 16px 2px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.yr-total > b { font: bold 34px/1 var(--serif); letter-spacing: .02em; text-shadow: 0 2px 3px rgba(0,0,0,.6); font-variant-numeric: tabular-nums; }
.yr-ctx { list-style: none; margin: 0; padding: 0; font-size: 12px; color: var(--ink); line-height: 1.5; flex: 1; min-width: 180px; }
.yr-ctx li::before { content: "◆"; color: var(--gold); font-size: 8px; margin-right: 6px; vertical-align: 2px; }
.yr-def { margin: 8px 16px 2px; font-size: 12px; line-height: 1.45; color: var(--ink-dim); }
.yr-src { margin: 2px 16px 0; font-size: 11px; color: var(--gold); font-style: italic; }
.yr-sec { padding: 10px 16px 0; }
.yr-sec h3 {
  margin: 4px 0 8px; font-family: var(--serif); font-weight: normal; font-size: 12px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--gold); display: flex; align-items: center; gap: 8px;
}
.yr-sec h3::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }
.yr-sec h4 { margin: 8px 0 4px; font: normal 10.5px var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-dim); }
.yr-note { margin: -4px 0 6px; font-size: 11px; color: var(--ink-dim); }
.yr-note:empty { display: none; }
.yr-bar { display: grid; grid-template-columns: 20px 1fr auto; gap: 1px 7px; align-items: center; font-size: 12px; margin-bottom: 5px; }
.yr-bar.noic { grid-template-columns: 1fr auto; }
.yr-bar.noic .yr-track { grid-column: 1 / 3; }
.yr-bic { display: inline-flex; color: var(--gold-bright); }
.yr-bl { min-width: 0; overflow-wrap: anywhere; line-height: 1.3; }
.yr-bl .muted { font-size: 11px; white-space: nowrap; }
.yr-bv { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.yr-bar.strong .yr-bl { color: var(--gold-bright); font-family: var(--serif); font-size: 13px; }
.yr-track { grid-column: 2 / 4; height: 5px; background: rgba(255,255,255,.07); border-radius: 3px; overflow: hidden; }
.yr-track i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, color-mix(in srgb, var(--yc) 70%, #000), var(--yc)); }
.yr-track i.good { background: #7fbf3f; }
.yr-track i.bad { background: #e0704f; }
.yr-more { margin: 2px 0 0 27px; padding: 2px 0; background: none; border: none; color: var(--gold-bright); font-size: 12px; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.yr-controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.yr-tabs, .yr-modes { display: inline-flex; border: 1px solid rgba(201,164,92,.5); border-radius: 4px; overflow: hidden; background: rgba(0,0,0,.25); }
.yr-tabs button, .yr-modes button { background: none; border: none; padding: 4px 10px; font-size: 12px; cursor: pointer; color: var(--ink-dim); white-space: nowrap; }
.yr-tabs button + button, .yr-modes button + button { border-left: 1px solid rgba(201,164,92,.35); }
.yr-tabs button { font-family: var(--serif); letter-spacing: .08em; text-transform: uppercase; font-size: 11.5px; }
.yr-tabs button:hover:not([disabled]), .yr-modes button:hover { color: var(--gold-bright); background: rgba(201,164,92,.12); }
.yr-tabs button[aria-selected="true"], .yr-modes button[aria-pressed="true"] { color: var(--gold-bright); background: linear-gradient(180deg, #5a4a24, #3a2f15); }
.yr-tabs button[disabled] { opacity: .4; cursor: default; }
.yr-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.yr-row {
  display: grid; grid-template-columns: 20px 1fr auto; gap: 2px 8px; align-items: center; width: 100%; text-align: left; cursor: pointer;
  padding: 5px 8px 6px; border-radius: 4px; background: rgba(0,0,0,.22); border: 1px solid rgba(201,164,92,.2); font-size: 13px;
}
.yr-row:hover, .yr-row:focus-visible { border-color: var(--gold); background: rgba(201,164,92,.12); }
.yr-row .yr-track { height: 3px; }
.yr-rk { grid-row: 1 / 3; align-self: center; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font: bold 11px var(--serif); color: #1a1408; background: radial-gradient(circle at 50% 35%, var(--gold-bright), var(--gold)); }
.yr-nm { font-family: var(--serif); color: var(--gold-bright); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.yr-nm .muted { font-family: var(--sans); font-size: 11px; }
.yr-v { font-variant-numeric: tabular-nums; font-weight: 600; }
.yr-empty { font-size: 12px; }
.yr-foot { padding: 12px 16px 0; display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.yr-foot .yr-note { margin: 0; flex: 1; min-width: 0; }
#city-panel:focus { outline: none; }

/* ---------- extension hosts (app/api.js: app.ui.dock, app.ui.addTopButton) ---------- */
/* Docks sit flush under the top bar at the screen edge; the map stays full-size underneath and app.visibleArea()
   shrinks instead. --dock-left / --dock-right on <body> hold the visible docks' widths (0px when closed). */
.app-dock {
  position: fixed; top: var(--topbar-h); bottom: 0; width: var(--dock-w, 380px); max-width: calc(100vw - 120px); z-index: 12;
  overflow-y: auto; overscroll-behavior: contain; border-radius: 0; border-top: none;
}
.app-dock-left { left: 0; border-left: none; }
.app-dock-right { right: 0; border-right: none; }
.btn-ext.active, .btn-ext[aria-pressed="true"] { background: linear-gradient(180deg, #5a4a24, #3a2f15); border-color: var(--gold-bright); }
/* Extension buttons cost top-bar room: their labels go first, then (body.tb-ext) the brand text gives way. */
@media (max-width: 1720px) { .btn-ext .lbl { display: none; } .btn-ext { padding: 4px 7px; } body.tb-ext .turn { display: none; } }
@media (max-width: 1320px) and (min-width: 701px) { body.tb-ext .brand-text { display: none; } }
/* A docked dashboard plus the minimap leave the lens dock no room on smaller desktops: drop the minimap. */
@media (max-width: 1360px) and (min-width: 701px) {
  body.dock-open #minimap-wrap { display: none; }
  body.dock-open #lens-area { left: calc(12px + var(--dock-left, 0px)); }
}

/* ---------- tooltip ---------- */
.tooltip {
  position: fixed; z-index: 20; pointer-events: none; max-width: 280px;
  background: rgba(12, 18, 26, .96); border: 1px solid var(--line); border-radius: 4px;
  padding: 6px 9px; font-size: 12px; line-height: 1.45; color: var(--ink);
}
.tooltip b { color: var(--gold-bright); font-family: var(--serif); }
.tooltip .muted { color: var(--ink-dim); }
.tooltip svg.icon { vertical-align: -2px !important; }

/* ---------- city / state panel ---------- */
#city-panel {
  position: fixed; top: 52px; right: calc(12px + var(--dock-right, 0px)); bottom: 12px; width: 370px; z-index: 12;
  overflow-y: auto; padding: 0 0 12px; overscroll-behavior: contain;
}
.sheet-grip { display: none; }
.cp-head { padding: 12px 16px 12px 20px; border-bottom: 1px solid var(--line); position: relative; background: linear-gradient(180deg, rgba(255,235,190,.05), transparent); }
.cp-head .stripe { position: absolute; left: 0; top: 0; bottom: 0; width: 6px; border-radius: 6px 0 0 0; box-shadow: inset -1px 0 0 rgba(0,0,0,.4); }
.cp-kind { font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--gold); }
.cp-name { margin: 0; font-weight: normal; font-family: var(--serif); font-size: 24px; letter-spacing: .06em; text-transform: uppercase; color: var(--gold-bright); padding-right: 34px; line-height: 1.15; }
.cp-name .cap { color: #ffe9a8; }
.cp-full { color: var(--ink-dim); font-size: 12px; margin-top: 3px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip { font: 11px var(--sans); letter-spacing: .06em; padding: 1px 7px; border-radius: 9px; border: 1px solid rgba(201,164,92,.5); background: rgba(0,0,0,.25); color: var(--gold-bright); }
button.chip { cursor: pointer; }
button.chip:hover { background: rgba(201,164,92,.2); }
.cp-pop { margin-top: 8px; font-size: 13px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.cp-pop svg { color: var(--ink-dim); }
.cp-pop b { font-size: 16px; }
.cp-pop .growth { white-space: nowrap; }
.cp-pop .growth .since { color: var(--ink-dim); font-size: 12px; }
.cp-close { position: absolute; top: 10px; right: 10px; }
.cp-section { padding: 10px 16px 4px; }
.cp-section h3 {
  margin: 4px 0 8px; font-family: var(--serif); font-weight: normal; font-size: 12px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--gold); display: flex; align-items: center; gap: 8px;
}
.cp-section h3::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }
.yield-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.yield-tile { background: rgba(0,0,0,.25); border: 1px solid rgba(201,164,92,.25); border-radius: 5px; padding: 6px 2px; text-align: center; cursor: help; }
.yield-tile .ico { display: flex; justify-content: center; filter: drop-shadow(0 1px 1px rgba(0,0,0,.6)); }
.yield-tile .val { font-weight: 700; font-size: 14px; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.yield-tile .lbl { font-size: 10px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: .06em; }
.yield-tile .rank { font-size: 10px; color: var(--gold-bright); margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ind { display: grid; grid-template-columns: 22px 1fr auto; gap: 2px 6px; align-items: center; margin-bottom: 5px; font-size: 12px; }
.ind .bar { grid-column: 2 / 4; height: 5px; background: rgba(255,255,255,.07); border-radius: 3px; overflow: hidden; }
.ind .bar i { display: block; height: 100%; border-radius: 3px; }
.ind .n { color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.lq { font-size: 10px; padding: 0 4px; border-radius: 3px; margin-left: 4px; }
.lq.hi { background: rgba(127,191,63,.25); color: #b9e486; }
.lq.lo { background: rgba(255,255,255,.06); color: var(--ink-dim); }
.stat-row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 4px 0; border-bottom: 1px dashed rgba(201,164,92,.15); }
.stat-row .sl { display: inline-flex; align-items: center; gap: 6px; }
.stat-row .sl svg, .stat-row .sl .emoji { color: var(--ink-dim); width: 14px; }
.stat-row > span:last-child { text-align: right; }
.stat-row .cmp { font-size: 11px; color: var(--ink-dim); margin-left: 6px; white-space: nowrap; }
.good { color: #9fd76a !important; } .bad { color: #f08a6a !important; }
.city-list { display: flex; flex-direction: column; gap: 3px; }
.city-row {
  display: grid; grid-template-columns: 1fr auto 12px; gap: 8px; align-items: center; width: 100%; text-align: left; cursor: pointer;
  padding: 6px 8px; border-radius: 4px; background: rgba(0,0,0,.22); border: 1px solid rgba(201,164,92,.2); font-size: 13px;
}
.city-row:hover, .city-row:focus-visible { border-color: var(--gold); background: rgba(201,164,92,.12); }
.cr-name { font-family: var(--serif); color: var(--gold-bright); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-name .muted { font-family: var(--sans); font-size: 11px; }
.cr-pop { color: var(--ink-dim); font-variant-numeric: tabular-nums; font-size: 12px; }
.cr-go { color: var(--gold); }
.cp-section p.muted { font-size: 12px; margin: 4px 0; }
.cp-foot { padding: 10px 16px 0; font-size: 11px; color: var(--ink-dim); }
.cp-foot a { color: var(--gold); cursor: pointer; }

/* ---------- lenses ---------- */
/* left: 266px keeps the area clear of the 252px-wide minimap; it never overlaps it. */
#lens-area {
  position: fixed; left: calc(266px + var(--dock-left, 0px)); right: calc(12px + var(--dock-right, 0px)); bottom: 12px; z-index: 11; pointer-events: none;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
#lens-area > * { pointer-events: auto; }
body.panel-open #lens-area { right: calc(394px + var(--dock-right, 0px)); }
#lens-area { container-type: inline-size; }
/* A narrow dock (e.g. beside the open panel) shows icons only for the quick lenses. */
@container (max-width: 560px) {
  .lens-quick .lens-btn:not(.active) span:not(.emoji), .res-toggle span { display: none; }
}
.lens-dock { display: flex; align-items: center; gap: 4px; padding: 5px; max-width: 100%; min-width: 0; }
.lens-quick { display: flex; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.lens-quick::-webkit-scrollbar { display: none; }
.lens-btn {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  background: rgba(0,0,0,.25); border: 1px solid rgba(201,164,92,.3); border-radius: 4px; padding: 5px 9px;
  cursor: pointer; font-size: 12px; white-space: nowrap; color: var(--ink);
}
.lens-btn:hover { border-color: var(--gold); }
.lens-btn.active { background: linear-gradient(180deg, #5a4a24, #3a2f15); border-color: var(--gold-bright); color: var(--gold-bright); }
.lens-more { font-family: var(--serif); color: var(--gold-bright); border-color: rgba(201,164,92,.6); background: linear-gradient(180deg, #33465c, #1d2b3a); }
.lens-more .caret { font-size: 10px; opacity: .8; }
.lens-more[aria-expanded="true"] .caret { display: inline-block; transform: rotate(180deg); }
.res-toggle { color: var(--ink-dim); margin-right: 4px; }
.res-toggle.active { color: var(--gold-bright); border-color: var(--gold-bright); }

/* The chooser: a search box, every group as a tab, the open group's lenses as chips. It stays open while lenses are
   switched, so it is kept small and the legend sits beside it. */
.lens-more:disabled { cursor: progress; opacity: .7; }
.lens-more.loading .caret { display: none; }
.lens-count { font: 600 10px var(--sans); padding: 0 5px; border-radius: 8px; background: rgba(0,0,0,.35); color: var(--ink-dim); letter-spacing: 0; }
.lens-picker { width: 580px; max-width: 100%; display: flex; flex-direction: column; overflow: hidden; }
.lc-head { display: flex; align-items: center; gap: 8px; padding: 7px 8px 7px 10px; border-bottom: 1px solid rgba(201,164,92,.3); }
.lc-find { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 0 8px; height: 28px; border-radius: 4px;
  background: rgba(0,0,0,.3); border: 1px solid rgba(201,164,92,.35); color: var(--ink-dim); }
.lc-find:focus-within { border-color: var(--gold-bright); }
.lc-search { flex: 1; min-width: 0; background: none; border: none; outline: none; color: var(--ink); font: inherit; font-size: 12.5px; }
.lc-search::placeholder { color: rgba(185,171,136,.7); }
.lc-search::-webkit-search-cancel-button { filter: invert(.7); }
.lc-total { flex: none; font-size: 10.5px; color: var(--ink-dim); white-space: nowrap; }
.lc-groups { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 7px 8px 3px; }
.lc-group { display: flex; align-items: center; gap: 5px; min-width: 0; padding: 4px 6px; cursor: pointer; font-size: 12px; border-radius: 4px;
  background: rgba(0,0,0,.22); border: 1px solid rgba(201,164,92,.22); color: var(--ink); }
.lc-group:hover { border-color: var(--gold); }
.lc-group.on { background: linear-gradient(180deg, #33465c, #1d2b3a); border-color: var(--gold-bright); color: var(--gold-bright); }
.lc-group.has-active:not(.on) { border-color: rgba(236,208,142,.7); }
.lc-gic { display: inline-flex; flex: none; color: var(--gold-bright); }
.lc-gnm { flex: 1; min-width: 0; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-group small { flex: none; font-size: 10px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
/* Tall enough for the fullest group, so the panel keeps its size from group to group. */
.lc-lenses { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 5px; padding: 6px 8px 9px; min-height: 118px; max-height: 190px; overflow-y: auto; }
.lc-chip { position: relative; display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 5px 9px 8px 6px; cursor: pointer; font-size: 12px; overflow: hidden;
  border-radius: 5px; background: rgba(0,0,0,.25); border: 1px solid rgba(201,164,92,.25); color: var(--ink); }
.lc-chip:hover, .lc-chip:focus-visible { border-color: var(--gold); background: rgba(201,164,92,.1); }
.lc-chip.active { border-color: var(--gold-bright); background: linear-gradient(180deg, rgba(90,74,36,.9), rgba(58,47,21,.9)); color: var(--gold-bright); }
.lc-ic { display: inline-grid; place-items: center; flex: none; width: 22px; height: 22px; border-radius: 50%; background: #1b2838; border: 1px solid rgba(201,164,92,.55); color: var(--gold-bright); }
.lc-nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-of { font-size: 10px; color: var(--ink-dim); white-space: nowrap; }
.lc-ramp { position: absolute; left: 5px; right: 5px; bottom: 2px; height: 3px; border-radius: 2px; }
.lc-empty { margin: 8px 4px; font-size: 12px; color: var(--ink-dim); }
/* Wide enough for both: the legend stands on the open chooser, both against the right edge. Side by side they were
   880px of panel along the bottom and hid the south coast; stacked, the wide one lies over the sea off 부산. */
@media (min-width: 1180px) {
  body:not(.panel-open):not(.listing-open):not(.dock-open) #lens-area.choosing { display: grid; grid-template-columns: 1fr auto; align-items: end; justify-items: end; }
  #lens-area.choosing .legend { grid-area: 1 / 2; }
  #lens-area.choosing .lens-picker { grid-area: 2 / 2; }
  #lens-area.choosing .lens-dock { grid-area: 3 / 1 / 4 / 3; }
  #lens-area.choosing .map-layers-pop { grid-area: 2 / 1; }
}

.legend { padding: 8px 10px 9px; width: 300px; max-width: 100%; font-size: 11px; }
.lg-head { display: flex; align-items: center; gap: 7px; margin-bottom: 3px; }
.lg-ic { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #1b2838; border: 1px solid var(--gold); color: var(--gold-bright); flex: none; }
.legend .title { font-family: var(--serif); color: var(--gold-bright); font-size: 15px; letter-spacing: .06em; flex: 1; }
.lg-close { width: 20px; height: 20px; }
.legend .desc { color: var(--ink-dim); margin-bottom: 6px; line-height: 1.4; max-height: 4.3em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.lg-scale { position: relative; cursor: crosshair; touch-action: none; padding-top: 2px; border-radius: 3px; }
.lg-hist { display: block; width: 100%; height: 38px; }
.legend .ramp { position: relative; height: 11px; border-radius: 2px; border: 1px solid rgba(0,0,0,.5); box-shadow: 0 0 0 1px rgba(201,164,92,.25); }
.band-mark { position: absolute; top: -45px; bottom: -3px; border: 1px solid var(--gold-bright); border-radius: 2px; background: rgba(255,233,168,.12); box-shadow: 0 0 6px rgba(255,214,110,.5); pointer-events: none; }
.legend .ticks { position: relative; height: 15px; margin-top: 3px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.legend .ticks span { position: absolute; top: 0; white-space: nowrap; font-size: 10.5px; }
.legend .lg-unit { display: none; margin-top: 1px; color: var(--ink-dim); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lg-meta { display: flex; flex-wrap: wrap; gap: 2px 8px; margin-top: 5px; color: var(--ink-dim); font-size: 10.5px; }
.hib { font-weight: 600; }
.lg-hint { margin-top: 4px; font-size: 10.5px; color: rgba(185,171,136,.75); font-style: italic; }
.lg-hint.on { color: var(--gold-bright); font-style: normal; }
/* A lens's caveat (lens.note), e.g. what a religion count does and does not measure. Shown everywhere, even on phones. */
.lg-note { margin: -2px 0 6px; padding: 4px 7px; border-left: 2px solid var(--gold); background: rgba(201,164,92,.08);
  color: var(--ink); font-size: 10.5px; line-height: 1.35; }
/* The colours beside the ramp: none here, beyond the scale, no value. */
.lg-keys { display: flex; flex-wrap: wrap; gap: 3px 4px; margin: 0 0 5px; }
.lg-key { display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px 2px 4px; font-size: 10.5px; color: var(--ink);
  background: rgba(0,0,0,.22); border: 1px solid rgba(201,164,92,.25); border-radius: 3px; }
button.lg-key { cursor: pointer; }
button.lg-key:hover { border-color: var(--gold); }
.lg-key.on { border-color: var(--gold-bright); color: var(--gold-bright); }
.lg-key.static { border-style: dashed; }
.lg-key i { width: 11px; height: 11px; border-radius: 2px; box-shadow: inset 0 0 0 1px rgba(201,164,92,.4); flex: none; }
.lg-keys + .lg-note { margin-top: 0; }
.lg-basis { flex-basis: 100%; }
.lg-cat small { color: var(--ink-dim); font-size: 10px; font-variant-numeric: tabular-nums; }
/* A lens whose values are on the way. */
.lg-wait { display: flex; align-items: center; gap: 8px; padding: 8px 2px 4px; color: var(--ink-dim); font-size: 11.5px; }
.lg-wait.failed { color: #f0b9a8; }
.lg-spin { width: 13px; height: 13px; border-radius: 50%; border: 2px solid rgba(201,164,92,.3); border-top-color: var(--gold-bright); animation: lg-spin .8s linear infinite; flex: none; }
@keyframes lg-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .lg-spin { animation-duration: 4s; } }
.lg-retry { margin-left: auto; cursor: pointer; padding: 2px 9px; border-radius: 3px; background: rgba(0,0,0,.3); border: 1px solid var(--gold); color: var(--gold-bright); }
/* Categorical lenses: swatches instead of the histogram; click one to show only it. */
.lg-cats { display: flex; flex-wrap: wrap; gap: 3px 4px; }
.lg-cat { display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px 2px 4px; cursor: pointer; font-size: 11px;
  background: rgba(0,0,0,.22); border: 1px solid rgba(201,164,92,.25); border-radius: 3px; }
.lg-cat i { width: 11px; height: 11px; border-radius: 2px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.45); flex: none; }
.lg-cat:hover { border-color: var(--gold); }
.lg-cats.filtered .lg-cat:not(.on) { opacity: .45; }
.lg-cat.on { border-color: var(--gold-bright); color: var(--gold-bright); }

/* Map layers menu (app.ui.addMapToggle): one dock button, a small menu of switches above the dock. */
.map-layers-btn { position: relative; }
.map-layers-btn .ml-count { min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px; background: var(--gold); color: #1a1208;
  font-size: 10px; line-height: 15px; text-align: center; }
.map-layers-pop { align-self: flex-end; width: 240px; max-width: calc(100vw - 16px); max-height: 60vh; overflow-y: auto; padding: 4px 0 6px; }
.ml-head { padding: 4px 12px 6px; font: normal 11px var(--serif); letter-spacing: .18em; text-transform: uppercase; color: var(--gold);
  border-bottom: 1px solid var(--line); margin-bottom: 3px; }
.ml-row { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 12px; min-height: 36px; cursor: pointer; text-align: left;
  background: none; border: 0; font-size: 12.5px; color: var(--ink-dim); }
.ml-row:hover, .ml-row:focus-visible { background: rgba(201,164,92,.1); }
.ml-row.on { color: var(--ink); }
.ml-ic { display: inline-grid; place-items: center; width: 18px; flex: none; }
.ml-lbl { flex: 1; }
.ml-switch { position: relative; width: 28px; height: 16px; border-radius: 8px; background: rgba(0,0,0,.4); border: 1px solid rgba(201,164,92,.4); flex: none; }
.ml-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--ink-dim); transition: left .12s; }
.ml-row.on .ml-switch { background: #5a4a24; border-color: var(--gold-bright); }
.ml-row.on .ml-switch::after { left: 14px; background: var(--gold-bright); }
/* The details toggle only matters beside a docked dashboard (advisors), where the legend is a compact strip at the
   top right of the map instead of a card over the south-east. */
.lg-more { display: none; width: 20px; height: 20px; font-size: 14px; line-height: 1; }
@media (min-width: 701px) {
  body.dock-open .lg-more { display: inline-grid; place-items: center; }
  body.dock-open #legend { position: absolute; right: 0; bottom: calc(100vh - 12px - var(--topbar-h) - 10px); transform: translateY(100%); }
  body.dock-open #legend:not(.expanded) { width: 230px; padding: 5px 8px 4px; }
  body.dock-open #legend:not(.expanded) .lg-ic { width: 20px; height: 20px; }
  body.dock-open #legend:not(.expanded) .title { font-size: 13px; }
  body.dock-open #legend:not(.expanded) :is(.desc, .lg-hist, .lg-meta, .lg-hint) { display: none; }
  body.dock-open #legend:not(.expanded) .band-mark { top: -3px; }
  body.dock-open #legend:not(.expanded) .ticks span:nth-child(2n) { display: none; }
  body.dock-open #legend:not(.expanded) .lg-unit { display: block; }
}

/* ---------- listing page (ui/listing.js) ---------- */
/* The same slot as the city panel; a full-height sheet on phones. Rows reuse the report leaderboard (.yr-row). */
.listing { position: fixed; top: 52px; right: calc(12px + var(--dock-right, 0px)); bottom: 12px; width: 370px; z-index: 13; overflow-y: auto; overscroll-behavior: contain; padding: 0 0 12px; }
.ls-head { position: sticky; top: 0; z-index: 1; padding: 12px 44px 10px 16px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #223244, #16212d); }
.ls-kind { font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--gold); }
.ls-head h2 { margin: 0; font: normal 20px var(--serif); letter-spacing: .04em; color: var(--gold-bright); line-height: 1.2; }
.ls-close { position: absolute; top: 10px; right: 10px; }
.ls-text, .ls-note, .ls-rule { margin: 8px 16px 0; font-size: 12px; line-height: 1.45; color: var(--ink); }
.ls-note { color: var(--ink-dim); font-size: 11px; }
.ls-rule { color: var(--ink-dim); }
.ls-rule summary { cursor: pointer; }
.ls-rule p { margin: 6px 0 0; }
.ls-list { margin: 10px 12px 0; padding: 0; }
.ls-row { min-height: 40px; }
.ls-group { margin: 8px 2px 2px; font-size: 11px; letter-spacing: .04em; color: var(--gold); }
.ls-row.here { border-color: var(--gold-bright); background: linear-gradient(90deg, rgba(201,164,92,.32), rgba(201,164,92,.1)); box-shadow: inset 3px 0 0 var(--gold-bright); }
.ls-row .yr-v .muted { font-weight: 400; font-size: 11px; margin-left: 4px; }
.listing-back { position: fixed; z-index: 26; top: calc(var(--topbar-h) + 12px); right: calc(394px + var(--dock-right, 0px)); }
body.listing-open #lens-area { right: calc(394px + var(--dock-right, 0px)); }
/* A category label or a rank figure that opens its listing: it keeps the look of the label and gains the marks of
   a control (a dotted underline, a pointer, a focus ring). */
.ls-open { all: unset; cursor: pointer; display: inline-block; border-radius: 4px; text-decoration: underline dotted rgba(236,208,142,.7); text-underline-offset: 3px; }
.ls-open:hover { text-decoration-style: solid; filter: brightness(1.2); }
.ls-open:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
@media (max-width: 700px) {
  .listing { top: var(--topbar-h); left: 0; right: 0; bottom: 0; width: auto; z-index: 26; border-radius: 0; border-left: none; border-right: none; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .ls-row { min-height: 44px; }
  .ls-close { width: 32px; height: 32px; }
  .listing-back { top: calc(var(--topbar-h) + 6px); left: 8px; right: auto; min-height: 36px; }
}

/* ---------- starting points (app/start.js) ---------- */
/* Wide screens: a card of rows at the top left, over the open sea west of the peninsula; a line longer than the
   card wraps (the English ones do), so every line reads whole. Narrower ones
   (and phones): one row under the top bar that scrolls sideways, so it never reaches the middle of the map. */
.start { position: fixed; z-index: 11; top: calc(var(--topbar-h) + 12px); left: 12px; max-width: min(470px, calc(100vw - 24px)); padding: 8px 8px 8px 10px;
  display: grid; grid-template-columns: 1fr auto; gap: 5px 8px; align-items: center; }
.st-title { font-family: var(--serif); font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); }
.st-close { grid-column: 2; grid-row: 1; width: 22px; height: 22px; }
.st-list { grid-column: 1 / 3; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.st-chip { display: flex; align-items: flex-start; gap: 7px; text-align: left; cursor: pointer; line-height: 1.35; padding: 5px 9px 5px 7px; border-radius: 4px;
  background: rgba(0,0,0,.25); border: 1px solid rgba(201,164,92,.28); color: var(--ink); font-size: 12.5px; }
.st-chip:hover, .st-chip:focus-visible { border-color: var(--gold); background: rgba(201,164,92,.14); color: var(--gold-bright); }
.st-ic { display: inline-flex; color: var(--gold-bright); flex: none; margin-top: 1px; }
.st-tx { min-width: 0; }
/* Once a line is picked the card folds to its title, off the city plates at the top left; the title opens it again. */
.st-reopen { display: none; align-items: center; gap: 6px; cursor: pointer; padding: 3px 4px; background: none; border: none;
  font-family: var(--serif); font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); }
.st-reopen:hover { color: var(--gold-bright); }
.st-reopen .caret { font-size: 10px; letter-spacing: 0; }
@media (min-width: 1181px) {
  .start.folded { padding: 4px 6px 4px 8px; }
  .start.folded :is(.st-title, .st-list) { display: none; }
  .start.folded .st-reopen { display: inline-flex; grid-column: 1; grid-row: 1; }
}
.help-start { margin: 14px 0 0; }
@media (max-width: 1180px) {
  .start { top: var(--topbar-h); left: 0; right: 0; max-width: none; padding: 5px 6px 5px 8px; border-radius: 0; border-left: none; border-right: none; border-top: none;
    display: flex; gap: 6px; }
  .st-title { display: none; }
  .st-list { flex: 1; flex-direction: row; gap: 5px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); padding-right: 24px; }
  .st-list::-webkit-scrollbar { display: none; }
  /* A line longer than the screen wraps, so each one can be read whole; the next is a swipe away. */
  .st-chip { flex: none; align-items: center; padding: 6px 10px 6px 8px; max-width: calc(100vw - 72px); line-height: 1.3; }
  .st-close { width: 28px; height: 28px; flex: none; }
}

/* ---------- minimap ---------- */
#minimap-wrap { position: fixed; left: calc(12px + var(--dock-left, 0px)); bottom: 12px; z-index: 11; padding: 5px; }
#minimap { display: block; cursor: pointer; border-radius: 3px; touch-action: none; }
.minimap-toggle { display: none; }

/* ---------- modals: civilopedia + help ---------- */
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.55); display: grid; place-items: center; }
.modal-card { width: min(980px, 94vw); height: min(680px, 88vh); display: grid; grid-template-columns: 210px 1fr; position: relative; overflow: hidden; }
.modal-card .close { position: absolute; top: 10px; right: 12px; z-index: 2; }
#pedia-nav { border-right: 1px solid var(--line); padding: 16px 0; background: rgba(0,0,0,.2); overflow-y: auto; }
#pedia-nav .hd { font-family: var(--serif); color: var(--gold-bright); font-size: 18px; letter-spacing: .12em; text-transform: uppercase; padding: 0 16px 12px; }
#pedia-nav button { display: block; width: 100%; text-align: left; background: none; border: none; padding: 7px 16px; cursor: pointer; font-size: 13px; color: var(--ink); }
#pedia-nav button.active, #pedia-nav button:hover { background: rgba(201,164,92,.15); color: var(--gold-bright); }
#pedia-body { padding: 20px 28px; overflow-y: auto; font-size: 14px; line-height: 1.55; }
#pedia-body h2 { font-family: var(--serif); color: var(--gold-bright); letter-spacing: .08em; margin: 0 0 12px; font-weight: normal; font-size: 24px; display: flex; align-items: center; gap: 10px; }
#pedia-body h2 svg { color: var(--gold); }
#pedia-body h3.grp { font-family: var(--serif); font-weight: normal; color: var(--gold); font-size: 13px; letter-spacing: .18em; text-transform: uppercase; margin: 22px 0 4px; display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
#pedia-body h4 { margin: 18px 0 4px; color: var(--gold); font-family: var(--serif); font-size: 15px; display: flex; align-items: center; gap: 6px; }
#pedia-body a { color: var(--gold-bright); }
#pedia-body .muted { color: var(--ink-dim); font-size: 12px; }
#pedia-body table { border-collapse: collapse; width: 100%; font-size: 12px; margin-top: 6px; }
#pedia-body td, #pedia-body th { border-bottom: 1px solid rgba(201,164,92,.2); padding: 4px 6px; text-align: left; vertical-align: top; }
#pedia-body th { color: var(--gold); font-weight: normal; font-family: var(--serif); letter-spacing: .06em; }
#pedia-body td.ic { width: 34px; vertical-align: middle; }
#pedia-body td.nm { white-space: nowrap; }
#pedia-body td.num { text-align: right; font-variant-numeric: tabular-nums; }
#pedia-body code { font-size: 11px; color: var(--ink-dim); word-break: break-all; }
.res-ic { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--gold); color: #f8f0d8; box-shadow: 0 0 0 1px #120d06; }
.lens-entry { display: grid; grid-template-columns: 40px 1fr; gap: 10px; align-items: start; }
.lens-entry h4 { margin-top: 14px !important; }
.le-ic { margin-top: 14px; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: #1b2838; border: 1px solid var(--gold); color: var(--gold-bright); }
.le-ramp { display: block; height: 6px; border-radius: 3px; margin: 6px 0 3px; max-width: 260px; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 6px; border: 1px solid rgba(0,0,0,.4); }

.help-card { width: min(720px, 94vw); max-height: 88vh; overflow-y: auto; padding: 18px 24px 16px; position: relative; }
.help-card h2 { margin: 0 0 10px; font: normal 22px var(--serif); letter-spacing: .1em; text-transform: uppercase; color: var(--gold-bright); display: flex; align-items: center; gap: 10px; }
.help-card h2 svg { color: var(--gold); }
.help-close { position: absolute; top: 12px; right: 12px; }
.help-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 4px 22px; }
.help-card h3 { margin: 10px 0 6px; font: normal 11px var(--serif); letter-spacing: .2em; text-transform: uppercase; color: var(--gold); border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.help-row { display: grid; grid-template-columns: 1fr; gap: 2px; padding: 4px 0; font-size: 13px; }
.help-row .keys { display: flex; flex-wrap: wrap; gap: 4px; }
.help-foot { margin: 14px 0 0; font-size: 12px; color: var(--ink-dim); }
.help-foot a { color: var(--gold-bright); }
.help-build { margin-top: 8px; font-size: 11px; font-variant-numeric: tabular-nums; opacity: .85; }
#pedia-body ul.changes { margin: 4px 0 10px; padding-left: 18px; font-size: 13px; line-height: 1.5; }
#pedia-body ul.changes li { margin: 3px 0; }

#loading {
  position: fixed; inset: 0; display: grid; place-items: center; z-index: 50; background: #0c2238;
  font-family: var(--serif); font-size: 22px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold-bright);
}
#loading.error { font-size: 15px; letter-spacing: 0; text-transform: none; padding: 40px; text-align: center; }

/* ---------- narrower desktops ---------- */
#topbar { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
#topbar::-webkit-scrollbar { display: none; }
/* The "Turn" label is the first thing to go when the bar is short of room (it needs about 1360px). */
@media (max-width: 1380px) { .turn { display: none; } }
@media (max-width: 1200px) {
  #topbar { gap: 12px; }
  .yields, .yield-parts { gap: 10px; }
  .yield { font-size: 13px; }
  .btn .lbl { display: none; }
  .btn { padding: 4px 7px; }
  .search { flex-basis: 180px; min-width: 130px; }
}
@media (max-width: 1000px) and (min-width: 701px) {
  .brand-text { display: none; }
  #topbar { gap: 10px; padding: 0 10px; }
  .yields, .yield-parts { gap: 8px; }
  .yield { font-size: 12.5px; gap: 4px; }
  .search { flex: 0 1 150px; min-width: 112px; }
  /* With a panel or a listing open there is no room for the dock beside the minimap: hide the minimap, give the
     dock the width (beside a listing the dock's last buttons lay under it). */
  body:is(.panel-open, .listing-open) #minimap-wrap { display: none; }
  body:is(.panel-open, .listing-open) #lens-area { left: calc(12px + var(--dock-left, 0px)); }
}
/* The yields row gives way first when the bar is short of room (topbar.js marks it .clipped). Phones scroll the
   whole bar instead. */
@media (max-width: 1000px) and (min-width: 701px) {
  .yields { flex: 0 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .yields::-webkit-scrollbar { display: none; }
  .yields.clipped { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent); }
}

/* ---------- short screens that are not narrow (a phone on its side) ---------- */
/* The chooser, the legend and the dock stand in one column that was taller than the screen: the chooser rose over
   the top bar and hid the search and the buttons. The legend keeps its name, ramp and ticks; the chooser's lenses
   scroll in what height is left; the minimap leaves the corner to the map. */
@media (max-height: 560px) and (min-width: 701px) {
  .legend :is(.desc, .lg-note, .lg-meta, .lg-hint) { display: none; }
  #lens-area.choosing .legend :is(.lg-hist, .lg-keys) { display: none; }
  .lc-lenses { min-height: 60px; max-height: calc(100vh - var(--topbar-h) - 250px); }
  .flow-legend:not([open]) { align-self: flex-end; }
  #minimap-wrap { display: none; }
  #lens-area { left: calc(12px + var(--dock-left, 0px)); }
}

/* ---------- phones ---------- */
@media (max-width: 700px) {
  /* Two rows. The first holds the controls and never scrolls: emblem, search, language, buttons. The second holds
     the six national numbers, always on screen. One scrolling row hid the numbers behind the buttons and clipped
     the last button; a strip that opens on a tap would hide them again by default. */
  :root { --topbar-h: 77px; }
  #topbar { flex-wrap: wrap; align-content: flex-start; gap: 0 6px; padding: 0 8px; overflow: hidden; }
  #topbar > * { height: 40px; }
  .brand-text, .spacer, .turn, .search-kbd { display: none; }
  .search { flex: 1 1 60px; min-width: 60px; }
  /* iOS Safari zooms the page when a focused input's text is under 16px. */
  #search-input { font-size: 16px; height: 30px; padding: 0 6px 0 26px; }
  .tb-buttons { gap: 4px; align-items: center; }
  .tb-buttons .btn { padding: 4px 6px; }
  .yields {
    order: 10; flex: 0 0 100%; min-width: 0; height: 36px !important; padding: 0 2px; border-top: 1px solid rgba(201,164,92,.25);
    overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; justify-content: space-between;
  }
  .yields::-webkit-scrollbar { display: none; }
  .yields.clipped { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent); }
  /* No icons here: the name above each number says what it is, and six icons cost a sixth of the row. */
  .yield { font-size: 11.5px; margin: 0; padding: 1px 0 3px; flex: none; }
  .yield .ico { display: none; }
  .yields { gap: 6px; }
  .yield-parts { gap: 6px; padding-right: 3px; flex: none; }
  .yp-cap { padding: 0 3px; margin-right: -2px; font-size: 9px; }
  .yl { font-size: 9px; letter-spacing: 0; }
  .yn { line-height: 15px; }

  #lens-area { left: 0; right: 0; bottom: 0; gap: 6px; align-items: stretch; z-index: 13; }
  body.panel-open #lens-area { right: 0; }
  .lens-dock { border-radius: 10px 10px 0 0; border-left: none; border-right: none; border-bottom: none; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
  .lens-quick { flex: 1; }
  .res-toggle span, .lens-more span:not(.caret) { display: none; }
  .map-layers-pop { margin: 0 8px; width: auto; align-self: stretch; }
  .ml-row { min-height: 42px; }
  .legend { width: auto; margin: 0 8px; }
  .legend .desc { display: none; }
  .lens-picker { width: auto; margin: 0; max-height: 62vh; border-left: none; border-right: none; }
  .lens-picker { border-radius: 10px 10px 0 0; }
  .lc-total { display: none; }
  .lc-search { font-size: 16px; }
  .lc-find { height: 34px; }
  .lc-groups { gap: 4px; padding: 6px 8px 2px; }
  .lc-group { flex-direction: column; gap: 2px; padding: 5px 2px 4px; font-size: 11px; }
  .lc-group small { display: none; }
  .lc-gnm { text-align: center; max-width: 100%; }
  .lc-lenses { min-height: 124px; max-height: 30vh; }
  .lc-chip { padding: 7px 10px 10px 7px; font-size: 12.5px; }
  /* Beside the open chooser the legend is one strip: its name, the ramp and the ticks. */
  #lens-area.choosing .legend :is(.lg-hist, .lg-meta, .lg-hint, .lg-note, .lg-keys, .lg-cats + .lg-meta) { display: none; }
  #lens-area.choosing .legend { padding: 5px 9px 4px; }

  #minimap-wrap { display: none; bottom: 64px; left: 8px; }
  body.minimap-on #minimap-wrap { display: block; }
  .minimap-toggle {
    display: grid; place-items: center; position: fixed; right: 8px; bottom: 60px; z-index: 11; width: 38px; height: 38px; padding: 0;
    cursor: pointer; color: var(--gold-bright); border-radius: 50%;
  }
  body.panel-open .minimap-toggle, body.panel-open #minimap-wrap { display: none; }

  #city-panel {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 55vh; height: 55dvh; z-index: 25;
    border-radius: 14px 14px 0 0; border-left: none; border-right: none; border-bottom: none;
    padding-bottom: calc(12px + env(safe-area-inset-bottom)); transition: transform .18s ease-out;
    box-shadow: 0 -8px 30px rgba(0,0,0,.55);
  }
  #city-panel.dragging-sheet { transition: none; }
  .app-dock {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; max-width: none; height: 55vh; height: 55dvh; z-index: 24;
    border-radius: 14px 14px 0 0; border: 1px solid var(--line); border-bottom: none; border-left: none; border-right: none;
    padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -8px 30px rgba(0,0,0,.55);
  }
  .sheet-grip { display: block; position: sticky; top: 0; z-index: 2; height: 18px; margin-bottom: -18px; touch-action: none; }
  .sheet-grip::before { content: ""; position: absolute; left: 50%; top: 6px; width: 44px; height: 4px; margin-left: -22px; border-radius: 2px; background: rgba(201,164,92,.6); }
  .cp-head { padding-top: 18px; touch-action: none; }
  .cp-close { top: 14px; width: 32px; height: 32px; }
  .cp-name { font-size: 21px; }
  .yield-tile .val { font-size: 13px; }

  .modal-card { grid-template-columns: 1fr; grid-template-rows: auto 1fr; width: 100vw; height: 100%; height: 100dvh; border-radius: 0; }
  /* The tabs scroll in a strip that ends before the close button, with a fade where more follow. */
  #pedia-nav { display: flex; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line); padding: 8px 20px 8px 0; margin-right: 46px; scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent); }
  #pedia-nav::-webkit-scrollbar { display: none; }
  #pedia-nav .hd { display: none; }
  .modal-card .close { background: #1c2836; top: 7px; right: 8px; }
  #pedia-nav button { width: auto; white-space: nowrap; padding: 6px 12px; }
  #pedia-body { padding: 14px 16px; }
  .help-card { padding: 16px; }
  .toast { top: calc(var(--topbar-h) + 10px); }

  .yield-report {
    left: 0 !important; right: 0; width: auto; max-width: none; z-index: 28;
    max-height: calc(100vh - var(--topbar-h) - 64px); max-height: calc(100dvh - var(--topbar-h) - 64px);
    border-radius: 0 0 12px 12px; border-left: none; border-right: none; border-top-width: 2px;
  }
  .yr-total > b { font-size: 30px; }
  .yr-row { padding: 7px 8px; }
}

/* --- language switch -------------------------------------------------------------------------------------------- */
.lang-switch { display: flex; flex: none; border: 1px solid var(--gold); border-radius: 4px; overflow: hidden; }
.lang-switch button {
  font: inherit; font-size: 12px; line-height: 1; padding: 5px 8px; border: 0; background: transparent; color: var(--ink-dim); cursor: pointer; white-space: nowrap;
}
.lang-switch button + button { border-left: 1px solid rgba(201,164,92,.5); }
.lang-switch button:hover { color: var(--ink); }
.lang-switch button[aria-pressed="true"] { background: linear-gradient(180deg, #5a4a24, #3a2f15); color: var(--gold-bright); }
.lang-switch .lg-short { display: none; }
@media (max-width: 1200px) {
  .lang-switch .lg-full { display: none; }
  .lang-switch .lg-short { display: inline; }
  .lang-switch button { padding: 5px 7px; }
}
.turn-src { margin-left: 8px; }
.cp-pop .growth { margin-left: 6px; }
.noscript { position: fixed; inset: auto 0 40% 0; text-align: center; color: var(--ink); }

/* Capitals and wide tracking are a Latin heading style. Hangul has no capitals, and tracking pulls its syllable
   blocks apart. :lang(ko) is the whole page in Korean, and in English any element marked lang="ko" because it holds a
   Korean place name. !important because some 70 rules across three stylesheets set these two properties. */
:lang(ko) { letter-spacing: 0 !important; text-transform: none !important; }
/* Hangul has no italic: a slanted syllable block is a synthesised oblique. Emphasis reads as weight instead. */
:lang(ko) { font-style: normal !important; }
:lang(ko) :is(p, li, td, span) > :is(i, em):not([class]) { font-weight: 600; }
@media (max-width: 700px) {
  .lang-switch button { padding: 6px 6px; }
}

/* ---------- phones: sheets, legends and touch targets ---------- */
@media (max-width: 700px) {
  /* A bottom sheet (city panel, listing, City View, advisors, a site card) ends where the lens dock begins, so the
     dock and the layer menu stay in reach; the lens area sits above the sheets, and a menu opened from it lies over
     the sheet. main.js keeps --lens-dock-h and --lens-area-h equal to the measured heights. */
  #city-panel, .app-dock, body .map-card { bottom: var(--lens-dock-h, 56px); }
  .listing { top: var(--topbar-h); left: 0; right: 0; width: auto; bottom: var(--lens-dock-h, 56px); border-radius: 0; }
  #lens-area { z-index: 26; }
  body.listing-open #lens-area { right: 0; }
  /* One legend at a time: with a sheet open the sheet speaks for the map, and an open migration legend takes the
     place of the lens legend (folding it brings the lens legend back). */
  body:is(.panel-open, .listing-open, .dock-open, .map-card-open) #lens-area:not(.choosing) :is(.legend, .flow-legend) { display: none; }
  #lens-area:has(.flow-legend[open]) .legend { display: none; }
  .minimap-toggle { bottom: calc(var(--lens-area-h, 56px) + 8px); }
  #minimap-wrap { bottom: calc(var(--lens-area-h, 56px) + 8px); }

  /* A thumb needs 44 px. */
  :root { --topbar-h: 89px; }
  #topbar > * { height: 44px; }
  .yields { height: 44px !important; }
  .yield { min-height: 44px; }
  #search-input { height: 44px; }
  .tb-buttons .btn, .lang-switch button { min-height: 44px; }
  .minimap-toggle { width: 44px; height: 44px; }
  #pedia-nav button { min-height: 44px; }
  .lens-btn, .icon-btn, .st-chip, .st-reopen, .cv-open, .lc-chip, .lc-group, .adv-council-btn, .cv-tabs button, .cv-ml-i { min-height: 44px; }
  .icon-btn, .cv-ml-i { min-width: 44px; }
  .lc-find, .lc-search { height: 44px; }
  body .adv-tabs button { width: 44px; height: 44px; }
  body :is(.adv-seg button, .adv-bar) { min-height: 44px; }
  .cv-ml-i { line-height: 42px; }
  /* Pills and rank figures inside a line of text keep their size; an invisible margin makes them a thumb's width. */
  button.chip, .ls-open, .lg-key { position: relative; }
  button.chip::after, .ls-open::after, .lg-key::after { content: ""; position: absolute; inset: -14px -4px; }

  /* The starting points fold to their title once the visitor opens anything else (app/start.js). */
  .start.folded { right: auto; padding: 0 4px; border-right: 1px solid var(--line); border-radius: 0 0 8px 0; }
  .start.folded .st-list, .start.folded .st-close { display: none; }
  .start.folded .st-reopen { display: inline-flex; }
}
