/* Layout: full-bleed map with an editorial story card on first visit, then a tabbed
   panel (Problem / Explore / Learn / Act). "Noche y boya amarilla" palette: cool
   white, night-blue ink and sea blue. Buoy yellow (--threat) is reserved for what
   threatens the coast: the anchorages, emissions drift and industry. Yellow is a
   fill colour only, always opaque; text in that role uses --threat-text (night blue
   in light mode), so no ochre or khaki tones appear. */
:root {
  --bg: #f5f6f8;
  --paper: #ffffff;
  --panel: rgba(255, 255, 255, 0.92);
  --raise: #eceff3;
  --sand: #eef0f2;
  --line: rgba(10, 31, 51, 0.12);
  --ink: #0a1f33;
  --muted: #5a6878;
  --threat: #f2b705;
  --threat-soft: #fff4c7;
  --threat-ink: #0a1f33;
  --threat-text: #0a1f33;
  --night: #0a1f33;
  --focus: #0a1f33;
  --sea: #2b6cb0;
  --sea-bright: #3d85d1;
  --sea-soft: #e1ecf8;
  --water: #cfe0ee;
  --green: #5f9e50;
  --green-soft: #e3f0de;
  --live: #2f8a4e;
  --shadow: 0 12px 40px rgba(10, 31, 51, 0.14);
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-data: "JetBrains Mono", ui-monospace, "Cascadia Mono", monospace;
  --radius: 18px;
  --panel-w: 384px;
  --peek: 200px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #071422; --paper: #0c1d30; --panel: rgba(12, 29, 48, 0.92); --raise: #132a42; --sand: #1a2a3a;
    --line: rgba(190, 215, 235, 0.14); --ink: #eef3f7; --muted: #9db0c2;
    --threat: #ffc933; --threat-soft: rgba(255, 201, 51, 0.15); --threat-ink: #1a1400; --threat-text: #ffc933; --night: #1c3a5c; --focus: #ffc933;
    --sea: #6aa8ea; --sea-bright: #6aa8ea; --sea-soft: rgba(106, 168, 234, 0.16); --water: #0b2238;
    --green: #8cc47d; --green-soft: rgba(140, 196, 125, 0.16); --live: #5fd08a;
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.45); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #071422; --paper: #0c1d30; --panel: rgba(12, 29, 48, 0.92); --raise: #132a42; --sand: #1a2a3a;
  --line: rgba(190, 215, 235, 0.14); --ink: #eef3f7; --muted: #9db0c2;
  --threat: #ffc933; --threat-soft: rgba(255, 201, 51, 0.15); --threat-ink: #1a1400; --threat-text: #ffc933; --night: #1c3a5c; --focus: #ffc933;
  --sea: #6aa8ea; --sea-bright: #6aa8ea; --sea-soft: rgba(106, 168, 234, 0.16); --water: #0b2238;
  --green: #8cc47d; --green-soft: rgba(140, 196, 125, 0.16); --live: #5fd08a;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45); color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font-body); overflow: hidden; -webkit-font-smoothing: antialiased; }
#map { position: fixed; inset: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--sea); font-weight: 600; }
/* Focus and state indicators use --focus (night blue in light mode, yellow in dark)
   so they keep 3:1 against the page; the yellow ring inside is the brand touch. */
:focus-visible { outline: 2.5px solid var(--focus); outline-offset: 2px; box-shadow: 0 0 0 2px var(--threat); }
.glass { background: var(--panel); backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3); border: 1px solid var(--line); box-shadow: var(--shadow); }

/* ---------- top bar ---------- */
.topbar { position: fixed; z-index: 6; top: calc(12px + env(safe-area-inset-top, 0px)); left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 12px; border-radius: var(--radius); width: var(--panel-w); max-width: 100%; }
.brand .txt { flex: 1; min-width: 0; }
/* The whole title box opens "Por qué Atalayas": a transparent button covers it. */
.brand { position: relative; transition: background 0.2s, box-shadow 0.2s; }
.brand:hover { background: var(--paper); }
.brand-hit { position: absolute; inset: 0; border: 0; background: transparent; border-radius: inherit; cursor: pointer; }
.brand-hit:focus-visible { outline: 2.5px solid var(--focus); outline-offset: 2px; box-shadow: 0 0 0 2px var(--threat); }
.brand .q { display: inline-grid; place-items: center; width: 18px; height: 18px; margin-left: 7px; border-radius: 50%; background: var(--sea-soft); color: var(--sea); font: 700 11.5px/1 var(--font-body); vertical-align: 4px; }
.brand h1 { margin: 0; font: 800 23px/1 var(--font-display); letter-spacing: -0.02em; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.25; }
.live { display: inline-flex; align-items: center; gap: 7px; flex: none; font: 500 11px/1 var(--font-data); letter-spacing: 0.06em; text-transform: uppercase; color: var(--live); padding: 6px 9px; border-radius: 999px; background: color-mix(in srgb, var(--live) 12%, transparent); }
.live i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 70%, transparent); } 70% { box-shadow: 0 0 0 9px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.tools { display: flex; gap: 8px; align-items: center; }
.tool { height: 42px; min-width: 42px; padding: 0 13px; border-radius: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; font-size: 14px; }
.tool:hover { background: var(--paper); }
.tool .code { font: 500 12px/1 var(--font-data); letter-spacing: 0.06em; }
.menu { position: relative; }
.menu ul { position: absolute; right: 0; top: 48px; margin: 0; padding: 6px; list-style: none; border-radius: 14px; min-width: 180px; background: var(--paper); }
.menu li button { width: 100%; display: flex; justify-content: space-between; gap: 16px; padding: 9px 10px; border: 0; background: none; border-radius: 9px; text-align: left; }
.menu li button:hover, .menu li button[aria-current="true"] { background: var(--raise); }
.menu li button[aria-current="true"] { color: var(--threat-text); font-weight: 600; }
.menu .code { color: var(--muted); }

/* ---------- side panel / bottom sheet ---------- */
.panel { position: fixed; z-index: 4; left: max(12px, env(safe-area-inset-left, 0px)); top: calc(98px + env(safe-area-inset-top, 0px)); bottom: calc(12px + env(safe-area-inset-bottom, 0px)); width: var(--panel-w); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; }
.sheet-handle { display: none; }
.tabs { display: flex; gap: 4px; padding: 10px 10px 0; border-bottom: 1px solid var(--line); flex: none; }
.tab { flex: 1 1 auto; white-space: nowrap; border: 0; background: none; padding: 10px 4px 12px; font-weight: 600; font-size: 13.5px; color: var(--muted); border-bottom: 2.5px solid transparent; margin-bottom: -1px; }
.tab[aria-selected="true"] { color: var(--ink); border-color: var(--focus); }
.tab[data-tab="act"] { color: var(--ink); font-weight: 700; box-shadow: inset 0 -3px 0 var(--threat); }
.tab[data-tab="act"][aria-selected="true"] { box-shadow: none; }
.panel-body { overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 18px; flex: 1; overscroll-behavior: contain; }
.panel-body > * { flex-shrink: 0; }
.eyebrow { margin: 0 0 8px; font: 500 11px/1 var(--font-data); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.lead { margin: 0; font-size: 14px; color: var(--muted); }
.small { font-size: 12px; }
.now-zones { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.nz { border: 1px solid var(--line); background: var(--paper); border-radius: 14px; padding: 12px; text-align: left; display: flex; flex-direction: column; gap: 4px; }
.nz b { font: 800 34px/1 var(--font-display); color: var(--threat-text); font-variant-numeric: tabular-nums; }
.nz span { font-size: 13px; color: var(--muted); line-height: 1.3; }
.nz strong { font: 700 15px/1.2 var(--font-display); }
.vcard { width: 100%; border: 1px solid var(--line); background: var(--paper); border-radius: 14px; padding: 12px; text-align: left; display: grid; grid-template-columns: 74px 1fr; gap: 12px; align-items: center; }
.vcard:hover { border-color: color-mix(in srgb, var(--sea) 50%, transparent); }
.vcard .sil { width: 74px; height: 26px; }
.vcard .t { font-weight: 600; font-size: 14.5px; line-height: 1.3; }
.vcard .s { font-size: 13px; color: var(--muted); line-height: 1.35; }
.vcard > div { min-width: 0; }
.tag { display: inline-block; font: 600 10.5px/1 var(--font-data); letter-spacing: 0.05em; text-transform: uppercase; padding: 4px 7px; border-radius: 999px; margin-bottom: 5px; }
.tag.anch { background: var(--threat-soft); color: var(--threat-text); }
.tag.move { background: var(--sea-soft); color: var(--sea); }
.cards { display: flex; flex-direction: column; gap: 8px; }
.hint { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--muted); background: var(--raise); padding: 10px 12px; border-radius: 12px; }
.hint svg { flex: none; color: var(--sea); }
.lgroup { display: flex; flex-direction: column; gap: 6px; }
/* Explore cards: the whole card is a show/hide button. Shown = coloured edge, filled
   eye and its legend underneath; hidden = plain card with an outlined "Mostrar". */
.layer { width: 100%; text-align: left; display: grid; grid-template-columns: 38px 1fr auto; gap: 12px; align-items: center; padding: 11px; border-radius: 14px; background: var(--paper); border: 1.5px solid var(--line); transition: border-color 0.2s, box-shadow 0.2s; }
.layer:hover { border-color: color-mix(in srgb, var(--sea) 45%, var(--line)); }
.layer .ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--raise); color: var(--muted); transition: background 0.2s, color 0.2s; }
.layer h4 { margin: 0; font-size: 14.5px; font-weight: 600; }
.layer p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.layer > div { min-width: 0; }
.layer .eye { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 6px 9px; border-radius: 999px; border: 1.5px solid var(--line); color: var(--muted); white-space: nowrap; }
.layer[aria-pressed="true"] { border-color: var(--sea); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sea) 14%, transparent); }
.layer[aria-pressed="true"] .ico { background: var(--sea-soft); color: var(--sea); }
.layer[aria-pressed="true"] .eye { background: var(--sea); border-color: var(--sea); color: #fff; }
.layer-wrap { display: flex; flex-direction: column; gap: 0; }
.layer-more { margin: -6px 0 0; padding: 14px 12px 10px; border: 1.5px solid var(--sea); border-top: 0; border-radius: 0 0 14px 14px; background: color-mix(in srgb, var(--sea-soft) 45%, var(--paper)); display: flex; flex-direction: column; gap: 8px; }
.layer-wrap:has(.layer-more) .layer { border-radius: 14px 14px 0 0; }
.src { font-size: 11px; color: var(--muted); }
/* Legend rows (in the Explore cards and the floating map legend) */
.lg { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; }
.lg li { display: grid; grid-template-columns: 26px 1fr; gap: 8px; align-items: center; line-height: 1.3; }
.lg svg { display: block; }
.legend { position: fixed; z-index: 3; right: max(12px, env(safe-area-inset-right, 0px)); top: calc(70px + env(safe-area-inset-top, 0px)); width: 250px; max-height: calc(100vh - 220px); overflow-y: auto; border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.legend h5 { margin: 0 0 4px; font: 600 11px/1 var(--font-data); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.legend header { display: flex; justify-content: space-between; align-items: center; }
.legend header b { font: 600 16px/1 var(--font-display); }
.legend .x { width: 30px; height: 30px; border-radius: 8px; }
/* Map / Satellite switch */
.impact { display: grid; grid-template-columns: 44px 1fr; gap: 12px; padding: 14px; border-radius: 14px; background: var(--paper); border: 1px solid var(--line); }
.impact .ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--threat-soft); color: var(--threat-text); }
.impact.sea .ico { background: var(--sea-soft); color: var(--sea); }
.impact cite a { font-weight: 500; }
.impact.coast .ico { background: var(--green-soft); color: var(--green); }
.impact h4 { margin: 0 0 3px; font: 700 16px/1.2 var(--font-display); }
.impact p { margin: 0; font-size: 14px; line-height: 1.45; }
.impact cite { display: block; margin-top: 6px; font-style: normal; font-size: 11.5px; color: var(--muted); }
details.gl { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; }
details.gl summary { cursor: pointer; padding: 12px 0; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 8px; }
details.gl summary::-webkit-details-marker { display: none; }
details.gl summary::after { content: "?"; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--sea-soft); color: var(--sea); font: 700 13px/1 var(--font-display); flex: none; }
details.gl[open] summary::after { content: "–"; }
details.gl p { margin: 0 0 12px; font-size: 14px; color: var(--muted); }
.verify { font: 500 10.5px/1.3 var(--font-data); color: var(--threat-text); text-transform: uppercase; letter-spacing: 0.05em; }
.back { align-self: flex-start; border: 0; background: var(--raise); border-radius: 10px; padding: 8px 12px; display: inline-flex; gap: 6px; align-items: center; font-weight: 600; }
.vd-hero { background: linear-gradient(180deg, var(--sea-soft), transparent); border-radius: 16px; padding: 18px 14px 10px; }
.vd-hero svg { width: 100%; height: auto; display: block; }
.vd h2 { margin: 6px 0 2px; font: 800 26px/1.05 var(--font-display); letter-spacing: -0.015em; text-wrap: balance; }
.facts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.facts li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; font-size: 15px; line-height: 1.4; }
.facts li svg { margin-top: 2px; color: var(--sea); }
details.tech { border-top: 1px solid var(--line); padding-top: 10px; }
details.tech summary { cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 600; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 10px 0 0; font-size: 13px; }
.kv dt { font: 500 10.5px/1 var(--font-data); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.kv dd { margin: 3px 0 0; font-family: var(--font-data); }

/* ---------- story ---------- */
.story { position: fixed; z-index: 7; left: max(16px, env(safe-area-inset-left, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); width: min(460px, calc(100% - 32px)); border-radius: 22px; background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 22px 22px 18px; display: flex; flex-direction: column; gap: 12px; }
.story .dots { display: flex; gap: 6px; }
.story .dots i { height: 4px; flex: 1; border-radius: 2px; background: var(--line); transition: background 0.3s; }
.story .dots i.on { background: var(--threat); }
.story .kicker { font: 500 11px/1 var(--font-data); letter-spacing: 0.1em; text-transform: uppercase; color: var(--threat-text); }
.story h2 { margin: 0; font: 800 clamp(24px, 4.2vw, 32px)/1.05 var(--font-display); letter-spacing: -0.02em; text-wrap: balance; }
.story h2 em { font-style: normal; color: var(--threat-text); }
.story p { margin: 0; font-size: 15.5px; line-height: 1.55; max-width: 60ch; }
.story .nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 4px; flex-wrap: wrap; }
.story .nav > div { display: flex; gap: 8px; margin-left: auto; }
.btn { border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.btn.primary { background: var(--threat); color: var(--threat-ink); }
.btn.ghost { background: var(--raise); }
.btn.link { background: none; padding: 11px 4px; color: var(--muted); }
.mini-impacts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mini-impacts div { background: var(--raise); border-radius: 12px; padding: 10px; font-size: 13px; line-height: 1.35; }
.mini-impacts b { display: flex; align-items: center; gap: 6px; font: 700 14px/1.2 var(--font-display); margin-bottom: 4px; color: var(--threat-text); }
.count { display: flex; align-items: baseline; gap: 10px; }
.count b { font: 800 64px/0.9 var(--font-display); color: var(--threat-text); font-variant-numeric: tabular-nums; }
.count span { font-size: 15px; color: var(--muted); }
.scale { display: flex; flex-direction: column; gap: 6px; }
.scale-row { display: grid; grid-template-columns: 1fr; gap: 3px; font-size: 12.5px; color: var(--muted); }
.scale-row svg { width: 100%; height: auto; }

/* ---------- floating map buttons, popups ---------- */
.fab { position: fixed; z-index: 3; right: max(12px, env(safe-area-inset-right, 0px)); bottom: calc(44px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; padding: 4px; border-radius: 16px; gap: 2px; }
.fab button { width: 64px; min-height: 54px; border: 0; background: none; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 6px 2px; color: var(--ink); }
.fab button span { font-size: 11px; font-weight: 600; line-height: 1.1; text-align: center; }
.fab button:hover { background: var(--raise); }
.fab button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.fab button + button { position: relative; }
.fab button + button::before { content: ""; position: absolute; top: -1px; left: 14px; right: 14px; height: 1px; background: var(--line); }
.maplibregl-popup-content { background: var(--paper); color: var(--ink); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); font: 14px/1.4 var(--font-body); }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--paper); }
.maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--paper); }
.maplibregl-popup-close-button { font-size: 18px; padding: 2px 8px; color: var(--muted); }
.probe b { font-family: var(--font-display); }
.info { display: flex; flex-direction: column; gap: 3px; padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px solid var(--line); }
.info b { font: 600 15.5px/1.25 var(--font-display); }
.info .muted { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.info ul { margin: 4px 0 0; padding: 0; list-style: none; font-size: 12.5px; }
.info li { display: flex; justify-content: space-between; gap: 12px; }
.info li span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }
.info .tag { align-self: flex-start; margin: 0; }
.tag.prot { background: var(--green-soft); color: #2e6b3a; text-transform: none; letter-spacing: 0; font-size: 11.5px; font-family: var(--font-body); }
.tag.ind { background: var(--threat-soft); color: var(--threat-text); text-transform: none; letter-spacing: 0; font-size: 11.5px; font-family: var(--font-body); }
.probe ul { margin: 6px 0 0; padding: 0; list-style: none; }
.probe li { display: flex; justify-content: space-between; gap: 18px; }
.probe li span:last-child { font-weight: 700; color: var(--threat-text); font-variant-numeric: tabular-nums; }
.maplibregl-ctrl-attrib { font-size: 11px; }

/* ---------- about ---------- */
.about { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(8, 24, 32, 0.45); padding: calc(16px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.about article { width: min(640px, 100%); max-height: 100%; overflow-y: auto; border-radius: 22px; background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.about header { display: flex; justify-content: space-between; gap: 16px; }
.about h2 { margin: 0; font: 800 30px/1.05 var(--font-display); letter-spacing: -0.02em; }
.about p { margin: 0; max-width: 62ch; font-size: 15.5px; line-height: 1.6; }
.about .src { font-size: 12px; color: var(--muted); }
.about .draft { font: 500 11px/1.3 var(--font-data); color: var(--threat-text); }
.x { border: 0; background: var(--raise); width: 38px; height: 38px; border-radius: 10px; flex: none; }
.motto { margin: -6px 0 0; font: italic 500 16px/1.35 var(--font-display); color: var(--sea); }
.def { margin: 0; padding: 14px 16px; border-left: 3px solid var(--threat); background: var(--raise); border-radius: 0 12px 12px 0; display: flex; flex-direction: column; gap: 6px; }
.def .w { font: 600 22px/1 var(--font-display); }
.def .w small { font: 400 13px/1 var(--font-body); color: var(--muted); margin-left: 6px; }
.def ol { margin: 0; padding-left: 20px; font-size: 14.5px; line-height: 1.5; }
.def .fig { font: italic 500 17px/1.35 var(--font-display); color: var(--threat-text); }
.def cite { font-style: normal; font-size: 11.5px; color: var(--muted); }
figure.photo { margin: 0; border-radius: 14px; overflow: hidden; background: var(--raise); }
figure.photo img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; }
figure.photo figcaption { padding: 7px 10px; font-size: 11.5px; color: var(--muted); }
.photos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
/* Cover: first screen on a first visit */
.cover { position: fixed; inset: 0; z-index: 5; display: flex; align-items: flex-end; background: #0a1f33 url("img/guadalquiton.jpg") center / cover no-repeat; }
.cover::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(11,42,74,0.55) 0%, rgba(11,42,74,0.1) 18%, rgba(11,42,74,0.72) 40%, rgba(11,42,74,0.96) 100%); }
.cover-in { position: relative; width: min(680px, 100%); padding: 0 max(24px, env(safe-area-inset-left, 0px)) calc(32px + env(safe-area-inset-bottom, 0px)); color: #fffdf9; display: flex; flex-direction: column; gap: 14px; }
.cover .kicker { font: 500 12px/1.3 var(--font-data); letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.85; }
.cover h2 { margin: 0; font: 700 clamp(32px, 7vw, 54px)/1.03 var(--font-display); letter-spacing: -0.02em; text-wrap: balance; }
.cover p { margin: 0; font-size: 16.5px; line-height: 1.5; max-width: 56ch; opacity: 0.95; }
.cover .pill { align-self: flex-start; padding: 8px 14px; border-radius: 999px; background: var(--threat); color: var(--threat-ink); font-weight: 600; font-size: 14.5px; }
.cover .btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.cover .btn.primary { background: var(--threat); color: var(--threat-ink); }
.cover .btn.ghost { background: rgba(255,253,249,0.14); color: #fffdf9; border: 1px solid rgba(255,253,249,0.35); }
.cover .btn.link { color: #fffdf9; opacity: 0.85; text-decoration: underline; padding-left: 0; }
.cover .credit { font-size: 11px; opacity: 0.7; }
.cover .credit a { color: inherit; font-weight: 400; }
body.on-cover .panel, body.on-cover .fab, body.on-cover .story, body.on-cover .legend { display: none; }
body.on-cover .brand { visibility: hidden; }
/* Action bar under the tabs: countdown, appeal and share, always in reach */
.actbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--night); border-bottom: 1px solid var(--line); flex: none; }
.actbar span { flex: 1; font-size: 13px; font-weight: 600; color: #ffffff; }
.actbar .btn.ghost { background: rgba(255, 255, 255, 0.14); color: #ffffff; }
.actbar .btn { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.actbar[hidden] { display: none; }
/* Home distance and appeal generator */
.home { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: 14px; background: var(--sea-soft); }
.home b { font: 600 16px/1.3 var(--font-display); }
.home p { margin: 0; font-size: 13px; color: var(--muted); }
.home .res { font-size: 15px; color: var(--ink); }
.gen { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 16px; border: 1.5px solid var(--ink); background: var(--paper); }
.gen h3 { margin: 0; font: 700 19px/1.2 var(--font-display); }
.gen p { margin: 0; font-size: 13.5px; color: var(--muted); }
.gen label { display: flex; flex-direction: column; gap: 5px; font-size: 14.5px; font-weight: 600; }
.gen input, .gen select, .gen textarea { min-height: 46px; font: 16px/1.4 var(--font-body); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }
.gen textarea { min-height: 80px; resize: vertical; }
.gen .row { display: flex; gap: 8px; align-items: flex-end; }
.gen .row label { flex: 1; }
.gen .err { color: var(--threat-text); font-size: 13px; font-weight: 600; }
.gen .ok { color: var(--live); font-size: 13.5px; font-weight: 600; }
.gen-out { white-space: pre-wrap; font: 13px/1.55 Georgia, "Times New Roman", serif; padding: 14px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); max-height: 340px; overflow-y: auto; }
/* Economy block */
.econ { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 16px; background: var(--sand); }
.econ h3 { margin: 0; font: 700 19px/1.2 var(--font-display); }
.econ p { margin: 0; font-size: 14px; line-height: 1.5; }
.econ .ctx { font-size: 13px; color: var(--muted); }
.econ-figs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.econ-figs .fig { background: var(--paper); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.econ-figs b { font: 700 26px/1 var(--font-display); color: var(--ink); }
.econ-figs span { font-size: 12.5px; line-height: 1.35; }
.econ-figs cite { font-style: normal; font-size: 10.5px; color: var(--muted); }
/* Act tab */
.act-intro { margin: 0; font: 600 17px/1.4 var(--font-display); }
.astep { display: flex; flex-direction: column; gap: 10px; padding-left: 0; }
.astep h3 { margin: 0; display: flex; align-items: center; gap: 10px; font: 700 20px/1.2 var(--font-display); }
.astep h3 i { font-style: normal; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--paper); font: 700 16px/1 var(--font-display); flex: none; }
.astep > p { margin: 0; font-size: 15px; line-height: 1.5; }
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--raise); flex-wrap: wrap; }
.seg button { flex: 1 1 auto; min-height: 44px; border: 0; background: none; border-radius: 10px; font-weight: 600; font-size: 14.5px; color: var(--muted); padding: 8px 10px; }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,0.12); }
.how { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; font-size: 15.5px; line-height: 1.5; }
.act-links { display: flex; flex-direction: column; gap: 8px; }
.act-links .btn { justify-content: space-between; min-height: 44px; text-decoration: none; }
.astep .note { margin: 0; font-size: 14px; color: var(--muted); }
.term { border: 0; background: none; padding: 0; font: inherit; color: var(--sea); font-weight: 600; text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }
.term::after { content: " ?"; font-size: 0.8em; }
.term-box { padding: 10px 12px; border-radius: 12px; background: var(--sea-soft); font-size: 14.5px; line-height: 1.5; }
/* Copy button in the corner of a text box */
.copy-wrap { position: relative; }
.copy-wrap .gen-out { padding-right: 52px; }
.copy-btn { position: absolute; top: 8px; right: 18px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-width: 32px; height: 32px; padding: 0 8px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); font-weight: 600; font-size: 12px; transition: background 0.2s, color 0.2s; }
.copy-btn span { display: none; }
.copy-btn:hover, .copy-btn:focus-visible { background: var(--raise); color: var(--ink); }
.copy-btn.done { background: var(--live); color: #fff; }
.copy-btn.done span { display: inline; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#genPrint { align-self: stretch; justify-content: center; min-height: 48px; font-size: 15.5px; }
/* Help tour: a dimmed screen with a spotlight on one part of the interface */
.tour { position: fixed; inset: 0; z-index: 20; }
.tour-hole { position: fixed; border-radius: 14px; box-shadow: 0 0 0 9999px rgba(8, 24, 40, 0.62); outline: 2px solid #fffdf9; transition: all 0.3s ease; pointer-events: none; }
.tour-card { position: fixed; width: min(330px, calc(100vw - 32px)); background: var(--paper); color: var(--ink); border-radius: 16px; box-shadow: var(--shadow); padding: 16px 16px 12px; display: flex; flex-direction: column; gap: 8px; transition: top 0.3s ease, left 0.3s ease; }
.tour-card .step { font: 500 11px/1 var(--font-data); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.tour-card h3 { margin: 0; font: 700 19px/1.2 var(--font-display); }
.tour-card p { margin: 0; font-size: 14.5px; line-height: 1.5; }
.tour-card .nav { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.tour-card .nav .btn { min-height: 42px; }
.tour-card .nav .skip { margin-right: auto; }
@media (prefers-reduced-motion: reduce) { .tour-hole, .tour-card { transition: none; } }
/* Problem tab: summary grid and foldable blocks */
.prob-hero figure.photo img { aspect-ratio: 16 / 8; }
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kpi { position: relative; overflow: hidden; text-align: left; border: 0; border-radius: 16px; padding: 14px 12px 12px; background: var(--night); color: #ffffff; display: flex; flex-direction: column; gap: 6px; min-height: 132px; cursor: pointer; animation: kpi-in 0.5s ease both; animation-delay: calc(var(--i) * 90ms); transition: transform 0.15s; }
.kpi:nth-child(1), .kpi:nth-child(4) { background: var(--threat); color: var(--threat-ink); }
.kpi:hover { transform: translateY(-2px); }
.kpi:active { transform: scale(0.98); }
.kpi-ico { position: absolute; top: 10px; right: 10px; opacity: 0.55; }
.kpi b { font: 700 44px/0.95 var(--font-display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 5px; }
.kpi b small { font: 600 15px/1 var(--font-body); letter-spacing: 0; opacity: 0.9; }
.kpi > span:last-child { font-size: 13px; line-height: 1.3; opacity: 0.95; }
.kpi-tap { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
@keyframes kpi-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .kpi { animation: none; } }
.quick .eyebrow { margin-bottom: 8px; }
.paccs { display: flex; flex-direction: column; gap: 8px; }
.pacc { border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
.pacc > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: 40px 1fr 20px; gap: 12px; align-items: center; padding: 12px; min-height: 64px; }
.pacc > summary::-webkit-details-marker { display: none; }
.pacc > summary::after { content: ""; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); justify-self: center; transition: transform 0.2s; }
.pacc[open] > summary::after { transform: rotate(-135deg); }
.pacc-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--raise); color: var(--ink); }
.pacc-t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pacc-t b { font: 600 16px/1.25 var(--font-display); }
.pacc-t span { font-size: 13px; color: var(--muted); line-height: 1.35; }
.pacc-body { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.pacc-body > p { margin: 0; font-size: 14px; line-height: 1.5; }
.pacc-body .econ { padding: 0; background: none; }
/* Problem tab */
.prob-hero { display: flex; flex-direction: column; gap: 8px; }
.prob-hero h2 { margin: 0; font: 700 27px/1.08 var(--font-display); letter-spacing: -0.015em; text-wrap: balance; }
.prob-hero .kicker { font: 500 11px/1 var(--font-data); letter-spacing: 0.1em; text-transform: uppercase; color: var(--threat-text); }
.prob-hero p { margin: 0; font-size: 15px; line-height: 1.55; }
.prob-block h3 { margin: 0 0 4px; font: 600 17px/1.2 var(--font-display); }
.prob-block p { margin: 0; font-size: 14px; line-height: 1.5; }
.mini { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: start; padding: 10px 0; border-top: 1px solid var(--line); }
.mini .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--threat-soft); color: var(--threat-text); }
.mini b { display: block; font-size: 14.5px; }
.mini span { font-size: 13.5px; line-height: 1.45; color: var(--muted); }
.want { padding: 16px; border-radius: 16px; background: var(--ink); color: var(--paper); display: flex; flex-direction: column; gap: 8px; }
.want h3 { margin: 0; font: 500 11px/1 var(--font-data); letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.75; }
.want p { margin: 0; font: 700 20px/1.2 var(--font-display); }
.want ul { margin: 4px 0 0; padding-left: 18px; font-size: 13.5px; line-height: 1.45; opacity: 0.92; }
.cta-row { display: flex; flex-wrap: wrap; gap: 8px; }
/* Act tab */
.act-count { display: flex; align-items: baseline; gap: 10px; padding: 14px; border-radius: 14px; background: var(--threat-soft); }
.act-count b { font: 700 46px/0.9 var(--font-display); color: var(--threat-text); font-variant-numeric: tabular-nums; }
.act-count span { font-size: 14px; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; display: flex; flex-direction: column; gap: 10px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; gap: 10px; font-size: 14px; line-height: 1.45; }
.steps li::before { content: counter(s); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--paper); font: 600 14px/1 var(--font-display); }
.steps b { display: block; font-size: 14.5px; }
.caveat { font-size: 12.5px; line-height: 1.45; padding: 10px 12px; border-radius: 12px; border: 1.5px dashed var(--threat); color: var(--ink); }
.model { border: 1px solid var(--line); border-radius: 14px; background: var(--paper); overflow: hidden; }
.model-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; background: var(--raise); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.model-bar span { font: 500 11px/1.2 var(--font-data); letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.model-cols { display: grid; grid-template-columns: 1fr; }
.model-cols > div { padding: 12px 14px; font-size: 13px; line-height: 1.55; white-space: pre-wrap; }
.model-cols > div + div { border-top: 1px solid var(--line); background: color-mix(in srgb, var(--raise) 50%, var(--paper)); color: var(--muted); }
.model-cols h6 { margin: 0 0 6px; font: 600 11px/1 var(--font-data); letter-spacing: 0.06em; text-transform: uppercase; color: var(--sea); white-space: normal; }
.btn.small { padding: 7px 11px; font-size: 13px; border-radius: 10px; }

/* ---------- phone ---------- */
@media (max-width: 860px) {
  :root { --panel-w: 100%; }
  .brand { width: auto; flex: 1; min-width: 0; padding: 8px 10px; gap: 10px; }
  .brand h1 { font-size: 19px; white-space: nowrap; }
  .tool .label { display: none; }
  .brand p { font-size: 11.5px; line-height: 1.2; margin-top: 2px; }
  .brand svg { width: 28px; height: 28px; }
  .live { padding: 7px; }
  .live span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .tool { padding: 0 10px; }
  .panel { left: 0; right: 0; top: auto; bottom: 0; width: auto; height: min(80vh, 700px); border-radius: 22px 22px 0 0; border-bottom: 0; padding-bottom: env(safe-area-inset-bottom, 0px); transform: translateY(calc(100% - var(--peek) - env(safe-area-inset-bottom, 0px))); transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1); }
  .panel[data-sheet="full"] { transform: translateY(0); }
  .panel.dragging { transition: none; }
  .sheet-handle { display: grid; place-items: center; height: 22px; flex: none; border: 0; background: none; width: 100%; touch-action: none; }
  .sheet-handle::before { content: ""; width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
  .tabs { padding-top: 0; gap: 0; }
  .tab { font-size: 12.5px; padding: 10px 2px 12px; }
  .panel-body { padding: 14px max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px)); }
  .fab { bottom: calc(var(--peek) + 40px + env(safe-area-inset-bottom, 0px)); }
  .fab button { width: 58px; min-height: 50px; }
  .legend { left: max(12px, env(safe-area-inset-left, 0px)); width: auto; max-height: 42vh; }
  .photos { grid-template-columns: 1fr; }
  .story { left: 0; right: 0; width: auto; bottom: 0; border-radius: 22px 22px 0 0; padding: 18px max(18px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px)); max-height: 60vh; overflow-y: auto; gap: 10px; }
  .story p { font-size: 15px; }
  .count b { font-size: 52px; }
  .maplibregl-ctrl-bottom-right { bottom: calc(var(--peek) + env(safe-area-inset-bottom, 0px)); }
  .about { place-items: end stretch; padding: calc(40px + env(safe-area-inset-top, 0px)) 0 0; }
  .about article { border-radius: 22px 22px 0 0; padding: 22px max(18px, env(safe-area-inset-right, 0px)) calc(22px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px)); }
}
body.in-story .panel, body.in-story .fab { display: none; }
@media (prefers-reduced-motion: reduce) { .live i { animation: none; } .panel { transition: none; } }
