:root {
  --bg: rgba(12, 18, 27, 0.86);
  --bg-solid: #0f1722;
  --line: rgba(255, 255, 255, 0.09);
  --text: #e7edf4;
  --muted: #95a3b4;
  --accent: #fde725;
  --accent-2: #35b779;
  --accent-3: #6ea8ff;
  --panel-w: 410px;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.38), 0 2px 8px rgba(0, 0, 0, 0.25);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b111a; color: var(--text); font: 14px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-3); }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

#globe { position: fixed; inset: 0; }
.cesium-viewer-bottom { display: none !important; }
.credits .cesium-widget-credits { display: block; position: static; }

/* ---------------------------------------------------------------- loader */
.loader { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: radial-gradient(1200px 700px at 60% 40%, #16263a 0%, #0a0f17 70%); transition: opacity .8s ease; }
.loader.is-done { opacity: 0; pointer-events: none; }
.loader-card { text-align: center; }
.loader-orb { width: 86px; height: 86px; margin: 0 auto 18px; border-radius: 50%; background: conic-gradient(from 0deg, #440154, #31688e, #35b779, #fde725, #440154); animation: spin 2.4s linear infinite; mask: radial-gradient(circle, transparent 52%, #000 54%); -webkit-mask: radial-gradient(circle, transparent 52%, #000 54%); }
.loader-title { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.loader-text { color: var(--muted); margin-top: 4px; font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- panel */
.panel { position: fixed; z-index: 10; top: 14px; left: 14px; bottom: 14px; width: var(--panel-w); display: flex; flex-direction: column; background: var(--bg); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); transition: transform .45s cubic-bezier(.2,.8,.2,1), opacity .3s; }
.panel.is-collapsed { transform: translateX(calc(-100% - 20px)); opacity: 0; pointer-events: none; }
.panel-toggle { position: fixed; z-index: 11; top: 26px; left: calc(var(--panel-w) + 22px); width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow); transition: left .45s cubic-bezier(.2,.8,.2,1); }
.panel-toggle svg, .nav-btn svg, .tool-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
body.panel-collapsed .panel-toggle { left: 14px; }
body.panel-collapsed .panel-toggle svg { transform: rotate(180deg); }

.panel-head { padding: 16px 18px 0; border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 12px; align-items: center; }
.logo { width: 34px; height: 34px; flex: none; }
.eyebrow { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.brand-title { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.tabs { display: flex; gap: 4px; margin-top: 12px; }
.tabs button { flex: 1; background: none; border: 0; padding: 9px 6px 11px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; font-weight: 600; font-size: 13px; }
.tabs button:hover { color: var(--text); }
.tabs button.is-active { color: var(--text); border-bottom-color: var(--accent); }

.tab-body { position: relative; flex: 1; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
.tab-body::-webkit-scrollbar { width: 8px; }
.tab-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 8px; }

/* story */
.story { padding: 4px 0 0; }
.chapter { padding: 22px 22px 26px; margin: 0 8px; border-radius: 12px; opacity: .38; transition: opacity .45s ease, background .45s ease; }
.chapter.is-active { opacity: 1; background: rgba(255,255,255,.025); }
.chapter + .chapter { margin-top: 18vh; }
.story-end { height: 55vh; }
.kicker { font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--accent-2); }
.chapter h1 { font-size: 32px; line-height: 1.12; letter-spacing: -0.02em; margin: 8px 0 14px; background: linear-gradient(90deg, #fff 0%, #fde725 55%, #35b779 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.chapter h2 { font-size: 22px; line-height: 1.2; letter-spacing: -0.015em; margin: 6px 0 12px; }
.chapter p { margin: 0 0 11px; color: #d4dce6; }
.chapter .lead { font-size: 15.5px; color: var(--text); }
.chapter .note { color: var(--muted); font-size: 12.5px; }
.chapter .hint { color: #b9c7d6; font-size: 12.5px; background: rgba(110,168,255,.08); border: 1px solid rgba(110,168,255,.18); padding: 7px 10px; border-radius: 8px; }
.chapter b { color: #fff; }
a.place { color: #ffe76a; text-decoration: none; border-bottom: 1px dotted rgba(255,231,106,.6); cursor: pointer; white-space: nowrap; }
a.place::before { content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 4px 1px 1px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 2px rgba(255,231,106,.25); }
a.place:hover { color: #fff; border-bottom-color: #fff; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0 14px; }
.kpi { background: rgba(255,255,255,.045); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.kpi b { display: block; font-size: 24px; line-height: 1.1; color: var(--accent); letter-spacing: -0.02em; }
.kpi span { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.35; }
.kpi em { font-style: normal; color: #c2ccd8; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: rgba(255,255,255,.06); padding: 8px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; }
.btn:hover { background: rgba(255,255,255,.12); }
.btn.primary { background: linear-gradient(90deg, #35b779, #9bd93c); color: #0b111a; border: 0; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 5px 11px; font-size: 12px; }

/* story nav */
.story-nav { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.nav-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255,255,255,.05); cursor: pointer; display: grid; place-items: center; flex: none; }
.nav-btn:hover:not(:disabled) { background: rgba(255,255,255,.14); }
.nav-btn:disabled { opacity: .3; cursor: default; }
.dots { flex: 1; display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.dot { width: 8px; height: 8px; padding: 0; border-radius: 50%; border: 0; background: rgba(255,255,255,.22); cursor: pointer; transition: all .25s; }
.dot:hover { background: rgba(255,255,255,.5); }
.dot.is-active { width: 22px; border-radius: 4px; background: var(--accent); }

/* charts */
.chart { margin: 14px 0 6px; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-svg text { fill: #aebbc9; font-size: 10.5px; font-family: var(--font); }
.chart-svg .label { fill: #d5dde7; font-size: 11px; }
.chart-svg .value { fill: #c7d1dc; font-size: 10.5px; font-variant-numeric: tabular-nums; }
.chart-svg .tick { fill: #8c9aab; font-size: 10px; }
.chart-svg .axis { stroke: rgba(255,255,255,.25); stroke-width: 1; }
.chart-svg .ref { stroke: rgba(255,231,106,.55); stroke-dasharray: 3 3; }
.chart-svg .marker { stroke: #fff; stroke-width: 1.5; }
.chart-svg .marker-label { fill: #fff; font-weight: 600; }
.chart-svg .whisker { stroke: rgba(255,255,255,.45); stroke-width: 1.2; }
.chart-svg .median { stroke: #fff; stroke-width: 2; }
.chart-svg .mean { stroke: #ff9bd2; stroke-width: 1.5; }
.chart-svg .hit { fill: transparent; cursor: pointer; }
.chart-svg .row:hover .hit { fill: rgba(255,255,255,.06); }
.chart-svg .row { transition: opacity .25s; }
.chart-svg .row.is-dim { opacity: .32; }
.chart-svg .row.is-active .label { fill: #fff; font-weight: 700; }
.chart-svg .focus { stroke: #fff; stroke-width: 2; }
.chart-caption { color: var(--muted); font-size: 11.5px; margin-top: 6px; }
.legend-inline { font-size: 11.5px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.legend-inline .sw { display: inline-block; width: 14px; height: 8px; border-radius: 2px; margin-right: 3px; vertical-align: middle; }
.legend-inline .sw.box { background: linear-gradient(90deg, #31688e, #35b779); }
.legend-inline .sw.med { width: 2px; height: 11px; background: #fff; }
.legend-inline .sw.mean { width: auto; height: auto; color: #ff9bd2; font-weight: 700; }
.legend-inline .sw.ref { width: 14px; height: 0; border-top: 2px dashed rgba(255,231,106,.7); border-radius: 0; }

/* explore */
.explore, .about { padding: 6px 18px 24px; }
.ex-block { padding: 14px 0; border-bottom: 1px solid var(--line); }
.ex-block:last-child { border-bottom: 0; }
.ex-block h3 { margin: 0 0 10px; font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.radio-list { display: grid; gap: 4px; }
.radio { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.radio:hover { background: rgba(255,255,255,.05); }
.radio:has(input:checked) { background: rgba(253,231,37,.08); border-color: rgba(253,231,37,.35); }
.radio input, .check input { accent-color: #fde725; }
.check { display: flex; gap: 8px; align-items: center; margin: 8px 0 2px; cursor: pointer; }
.seg { display: flex; background: rgba(255,255,255,.05); border-radius: 10px; padding: 3px; gap: 3px; margin-bottom: 10px; }
.seg button { flex: 1; border: 0; background: none; padding: 6px 8px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 12.5px; }
.seg button.is-active { background: rgba(255,255,255,.12); color: var(--text); }
.slider { display: block; margin: 8px 0 12px; }
.slider span { display: flex; justify-content: space-between; font-size: 12.5px; color: #c9d3de; }
.slider input { width: 100%; accent-color: #fde725; }
.field { display: grid; gap: 4px; font-size: 12.5px; color: #c9d3de; margin: 8px 0; }
select { width: 100%; background: rgba(255,255,255,.06); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; }
select option { background: #121c28; }
.prose p, .prose li { color: #cfd8e3; font-size: 13px; }
.prose h3 { margin-top: 6px; }
.src-list { padding-left: 0; list-style: none; }
.src-list li { padding: 5px 0; border-bottom: 1px dashed var(--line); }
.src-list a { font-weight: 700; margin-right: 4px; }
.note { color: var(--muted); font-size: 12px; }

/* ---------------------------------------------------------------- toolbar */
.toolbar { position: fixed; z-index: 12; top: 14px; right: 14px; display: flex; gap: 8px; align-items: flex-start; }
.search { position: relative; }
.search input { width: 300px; height: 40px; padding: 0 14px 0 38px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: var(--shadow); outline: none; transition: width .3s, border-color .2s; }
.search input:focus { border-color: rgba(253,231,37,.5); width: 340px; }
.search-ico { position: absolute; z-index: 1; left: 13px; top: 11px; width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.search-results { position: absolute; top: 46px; left: 0; right: 0; background: var(--bg-solid); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; max-height: 60vh; overflow-y: auto; }
.result { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 14px; cursor: pointer; border-bottom: 1px solid var(--line); }
.result b { display: block; font-weight: 600; }
.result span { font-size: 11.5px; color: var(--muted); }
.result:hover, .result.is-active { background: rgba(255,255,255,.07); }
.tool-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: var(--shadow); cursor: pointer; display: grid; place-items: center; }
.tool-btn:hover { background: rgba(30,42,58,.95); }
.tool-btn.text { font-weight: 800; font-size: 12.5px; letter-spacing: .02em; }
.basemap-menu { position: absolute; top: 48px; right: 0; width: 270px; background: var(--bg-solid); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; }
.basemap-option { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; border: 0; background: none; padding: 8px; border-radius: 10px; cursor: pointer; }
.basemap-option:hover { background: rgba(255,255,255,.06); }
.basemap-option.is-active { background: rgba(253,231,37,.1); }
.basemap-option .sw { width: 30px; height: 30px; border-radius: 8px; flex: none; border: 1px solid rgba(255,255,255,.2); }
.basemap-option b { display: block; font-size: 13px; }
.basemap-option em { font-style: normal; font-size: 11.5px; color: var(--muted); }

/* ---------------------------------------------------------------- cards: info + legend */
.card { position: fixed; z-index: 9; background: var(--bg); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.legend { right: 14px; bottom: 30px; width: 292px; padding: 12px 14px 10px; max-height: 46vh; overflow-y: auto; }
.legend-title { font-weight: 700; font-size: 13.5px; }
.legend-sub { color: var(--muted); font-size: 11.5px; line-height: 1.35; margin: 2px 0 9px; }
.legend .grad { height: 12px; border-radius: 6px; }
.legend .grad-ticks { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.sw-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 2px 0; }
.sw-row em { margin-left: auto; font-style: normal; color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.sw-row .sw, .sw-grid .sw { width: 14px; height: 14px; border-radius: 4px; flex: none; border: 1px solid rgba(255,255,255,.18); }
.sw-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
.legend details.more { margin-top: 4px; }
.legend details.more summary { cursor: pointer; color: var(--muted); font-size: 11.5px; padding: 3px 0; }
.legend details.more summary:hover { color: var(--text); }
.sw-btn { border: 0; background: none; text-align: left; cursor: pointer; border-radius: 6px; padding: 1px 3px; font-size: 12px; line-height: 1.3; }
.sw-btn:hover { background: rgba(255,255,255,.07); }
.sw-btn.is-dim { opacity: .4; }
.sw-btn.is-active { background: rgba(255,255,255,.1); font-weight: 700; }
.legend-focus { margin-top: 8px; font-size: 12px; display: flex; align-items: center; gap: 6px; background: rgba(253,231,37,.09); border-radius: 8px; padding: 4px 8px; }
.legend-focus button { margin-left: auto; border: 0; background: none; cursor: pointer; color: var(--muted); }
.legend-foot { margin-top: 9px; padding-top: 7px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }

.info { right: 14px; top: 66px; width: 330px; max-height: calc(100vh - 66px - 28px - var(--legend-h, 0px)); min-height: 120px; overflow-y: auto; padding: 14px 16px 12px; animation: pop .25s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.info h3 { margin: 2px 26px 2px 0; font-size: 18px; letter-spacing: -0.01em; line-height: 1.2; }
.info-kicker { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--accent-2); font-weight: 700; }
.info-close { position: absolute; top: 10px; right: 10px; width: 26px; height: 26px; border: 0; border-radius: 50%; background: rgba(255,255,255,.08); cursor: pointer; }
.info-close:hover { background: rgba(255,255,255,.18); }
.info-sec { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.info-sec-title { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.info-sec-title b { text-transform: none; letter-spacing: 0; color: var(--text); font-size: 12.5px; }
.big-metric { font-size: 13px; margin-bottom: 6px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.big-metric b { font-size: 24px; letter-spacing: -0.02em; }
.big-metric .dot { width: 12px; height: 12px; border-radius: 50%; align-self: center; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12.5px; padding: 3px 0; }
.kv > span:first-child { color: var(--muted); }
.kv-bar { display: flex; align-items: center; gap: 8px; }
.mini-bar { display: inline-block; width: 80px; height: 7px; background: rgba(255,255,255,.1); border-radius: 4px; overflow: hidden; }
.mini-bar i { display: block; height: 100%; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12.5px; }
.chip::before { content: ""; width: 11px; height: 11px; border-radius: 3px; background: var(--c); border: 1px solid rgba(255,255,255,.25); }
.muted { color: var(--muted); font-weight: 400; }
.info-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; font-size: 12px; }
.info .strip { margin-top: 6px; }

.tooltip { position: fixed; z-index: 20; top: 0; left: 0; pointer-events: none; background: rgba(10,15,22,.92); border: 1px solid var(--line); border-radius: 9px; padding: 6px 10px; font-size: 12.5px; line-height: 1.35; box-shadow: 0 6px 20px rgba(0,0,0,.35); max-width: 280px; }

.credits { position: fixed; z-index: 8; left: calc(var(--panel-w) + 28px); right: 320px; bottom: 6px; font-size: 10px; color: rgba(255,255,255,.72); text-shadow: 0 1px 2px rgba(0,0,0,.8); pointer-events: auto; line-height: 1.3; }
.credits a { color: rgba(255,255,255,.85); }
.credits .cesium-credit-textContainer { display: inline; }
/* Cesium's default "Cesium ion" logo: no ion services are used (Ion.defaultAccessToken = ""), so it is hidden.
   !important because Cesium sets display:inline on the element itself. */
.credits .cesium-credit-logoContainer { display: none !important; }
.credits .cesium-credit-expand-link { color: #ffe76a; cursor: pointer; text-decoration: underline; }
body.panel-collapsed .credits { left: 56px; }
body.basemap-dark .credits { color: rgba(255,255,255,.8); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  :root { --panel-w: 100vw; }
  .panel { top: auto; left: 0; right: 0; bottom: 0; width: 100%; height: 48vh; border-radius: 16px 16px 0 0; }
  .panel.is-collapsed { transform: translateY(calc(100% - 0px)); }
  .panel-toggle { display: none; }
  .chapter + .chapter { margin-top: 10vh; }
  .toolbar { left: 10px; right: 10px; top: 10px; }
  .search { flex: 1; }
  .search input, .search input:focus { width: 100%; }
  .legend { top: 60px; bottom: auto; right: 10px; width: 220px; max-height: 30vh; font-size: 12px; }
  .info { top: auto; bottom: calc(48vh + 10px); right: 10px; left: 10px; width: auto; max-height: 34vh; }
  .credits { left: 10px; right: 10px; bottom: calc(48vh + 2px); }
  .chapter h1 { font-size: 26px; }
  .brand { display: none; }
  .panel-head { padding: 4px 12px 0; }
  .tabs { margin-top: 0; }
  .tabs button { padding: 8px 4px 9px; font-size: 12.5px; }
  .legend { width: 190px; padding: 8px 10px; }
  .legend .legend-sub, .legend .legend-foot { display: none; }
  .legend .legend-title { font-size: 12px; margin-bottom: 6px; }
  .credits { font-size: 9px; }
  .kpi b { font-size: 20px; }
}

/* ---- embedded in another page (src/app/embed.js, docs/EMBED.md) ---------------------------------------------------- */
.embed-hint { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 40; padding: 10px 16px; border-radius: 10px; background: rgba(8,14,22,.84); color: #fff; font-size: 14px; font-weight: 600; pointer-events: none; opacity: 0; transition: opacity .25s; }
.embed-hint.is-on { opacity: 1; }

/* ---- finer than 10 m: field parcels, lens, imagery ---------------------------------------------------------------- */
.small { font-size: 11.5px; line-height: 1.45; }
p.small { margin: 6px 0 8px; }
.wrap { text-align: right; overflow-wrap: anywhere; font-weight: 600; }
.jump-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.chip-btn { border: 1px solid var(--line); background: rgba(255,255,255,.05); color: var(--text); padding: 4px 9px; border-radius: 999px; font-size: 11.5px; cursor: pointer; }
.chip-btn:hover { background: rgba(253,231,37,.14); border-color: rgba(253,231,37,.4); }
.lens-btns { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.lens-out:empty { display: none; }
.lens-out { margin-top: 8px; }
.lens-out .chart-svg { margin: 6px 0 4px; }
.legend-fields { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.legend-fields.is-main { margin-top: 2px; padding-top: 0; border-top: 0; }
.fields-src li { padding: 3px 0; font-size: 12px; }
.note.warn { color: #ffcf6e; margin: 4px 0 6px; }
