@font-face {
  font-family: "Archivo";
  src: url("/fonts/archivo-var-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/plex-mono-400-latin.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/plex-mono-600-latin.woff2") format("woff2");
  font-weight: 500 600;
  font-display: swap;
}
/* Layout: one continuous scene from deep space to rooftops. Desktop: control sheet left, sun clock docked
   along the bottom, altitude ladder and globe buttons on the right. Phone: sheet becomes a bottom drawer,
   the clock sits above it, buttons go top-right and the ladder is dropped.
   Deliberately single-theme: the scene starts in space and the panels float over a changing sky. */
:root {
  color-scheme: dark;
  --space: #05070d;
  --sheet: rgba(11, 15, 27, 0.88);
  --raised: rgba(255, 255, 255, 0.05);
  --ink: #eef0f6;
  --muted: #9aa3ba;
  --rule: #2a3550;
  --accent: #f6a34a;
  --accent-ink: #1a1206;
  --sun: #ffd27a;
  /* bar colour, validated with the dataviz ramp checks against the space background:
     sequential = one orange hue, dark (few people) to light (many);
     diverging = blue arm and red arm, three equal steps each, grey midpoint for "no change" */
  --s0: #7a3410; --s1: #b04e17; --s2: #e0702a; --s3: #f59a55; --s4: #fbc08e; --s5: #fde3c8;
  --d0: #9cc4f5; --d1: #4f93e6; --d2: #2c5f9e; --d3: #4a4c52; --d4: #a5452e; --d5: #e0623f; --d6: #f7a487;
  --f-display: "Archivo", "Arial Narrow", sans-serif;
  --f-body: "Archivo", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --side: 340px;
  --rail: 132px;
  --sheet-h: 0px;
}
html, body { height: 100%; margin: 0; }
[hidden] { display: none !important; }
body { background: var(--space); color: var(--ink); font-family: var(--f-body); overflow: hidden; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#stage { position: fixed; inset: 0; }
#stage canvas { display: block; touch-action: none; }
#stage canvas:focus-visible { outline: none; }

/* loader */
#loader { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: var(--space); transition: opacity .6s; }
#loader.gone { opacity: 0; pointer-events: none; }
.ld { text-align: center; }
.ld h1 { font: 800 34px/1 var(--f-display); margin: 0 0 10px; letter-spacing: -.02em; }
.ld p { margin: 0; font: 400 13px var(--f-mono); color: var(--muted); }
.ld .bar { width: 220px; height: 3px; background: var(--rule); border-radius: 2px; margin: 18px auto 0; overflow: hidden; }
.ld .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }

/* sheet */
.sheet {
  position: fixed; z-index: 3;
  top: calc(env(safe-area-inset-top, 0px) + 16px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  left: max(16px, env(safe-area-inset-left, 0px));
  width: var(--side);
  display: flex; flex-direction: column;
  background: var(--sheet); backdrop-filter: blur(12px);
  border: 1px solid var(--rule); border-radius: 10px;
}
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 18px 12px; border-bottom: 1px solid var(--rule); }
.sheet-body { overflow-y: auto; overflow-x: hidden; padding: 14px 18px 18px; display: flex; flex-direction: column; gap: 18px; overscroll-behavior: contain; }
.sheet-body > * { min-width: 0; }
.back { font: 500 12px/1 var(--f-mono); color: var(--muted); text-decoration: none; letter-spacing: .04em; }
.back:hover { color: var(--accent); }
.eyebrow { font: 500 11px/1.2 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0; }
h1 { font: 800 30px/0.95 var(--f-display); letter-spacing: -.02em; margin: 6px 0 0; text-wrap: balance; }
.lede { margin: 0; font-size: 14px; line-height: 1.45; color: var(--muted); }
.note { margin: 0; font-size: 13px; line-height: 1.45; color: var(--muted); }
.group { display: flex; flex-direction: column; gap: 10px; }
.icon-btn { display: none; min-height: 40px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--rule); background: var(--raised); font-weight: 600; font-size: 13px; }
.actions { display: grid; grid-template-columns: 1.3fr 1fr; gap: 8px; }
.btn { min-height: 44px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--rule); background: var(--raised); font-weight: 600; font-size: 14px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }

/* scale card */
.scale { padding: 14px; border-radius: 10px; background: var(--raised); border: 1px solid var(--rule); display: grid; gap: 6px; }
.scale .alt { font: 800 30px/1 var(--f-display); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.scale .alt small { font: 500 13px var(--f-mono); color: var(--muted); letter-spacing: 0; margin-left: 6px; }
.scale h2 { margin: 2px 0 0; font: 600 15px/1.25 var(--f-display); }

/* layers + legend */
.layers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.layer { display: grid; gap: 6px; text-align: left; padding: 8px 9px; border-radius: 8px; border: 1px solid var(--rule); background: var(--raised); }
.layer[aria-checked="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); box-shadow: inset 0 0 0 1px var(--accent); }
.layer .sw { height: 6px; border-radius: 3px; }
.layer b { font: 600 13px/1.1 var(--f-body); }
.ramp { height: 10px; border-radius: 3px; }
.ticks { position: relative; height: 14px; font: 400 11px var(--f-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.ticks span.first { transform: none; }
.ticks span.last { transform: translateX(-100%); }
.yr-row { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; }
.mini-play { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--rule); background: var(--raised); display: grid; place-items: center; }
.mini-play svg { width: 15px; height: 15px; }
.yr-val { font: 800 20px/1 var(--f-display); font-variant-numeric: tabular-nums; min-width: 3ch; text-align: right; }
.seg { display: flex; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.seg button { flex: 1; min-height: 38px; font-weight: 600; font-size: 13px; background: transparent; border: 0; padding: 0 6px; }
.seg button + button { border-left: 1px solid var(--rule); }
.seg button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }
.row { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; }
.row output { font: 400 12px var(--f-mono); color: var(--muted); }
input[type="range"] { width: 100%; accent-color: var(--accent); min-height: 30px; margin: 0; }
.switches { display: flex; flex-wrap: wrap; gap: 8px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px 0 8px; border: 1px solid var(--rule); border-radius: 20px; background: var(--raised); font-size: 13px; font-weight: 600; cursor: pointer; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch i { width: 30px; height: 18px; border-radius: 9px; background: var(--rule); position: relative; flex: none; transition: background .15s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--ink); transition: transform .15s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(12px); background: var(--accent-ink); }
.switch:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
details > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; min-height: 32px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: "+"; font: 400 16px var(--f-mono); color: var(--muted); }
details[open] > summary::after { content: "−"; }
.places { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 2px; }
.places button { width: 100%; min-height: 38px; display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; text-align: left; background: none; border: 0; padding: 0 8px; margin: 0 -8px; border-radius: 6px; font-size: 14px; }
.places button:hover { background: rgba(246, 163, 74, 0.14); }
.places span:last-child { font: 400 12px var(--f-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.top { width: 100%; border-collapse: collapse; font-size: 13px; }
.top th { text-align: right; font: 500 10.5px var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 0 6px; border-bottom: 1px solid var(--rule); }
.top th:first-child, .top td:first-child { text-align: left; }
.top td { text-align: right; padding: 0; border-bottom: 1px solid color-mix(in srgb, var(--rule) 50%, transparent); font: 400 12px var(--f-mono); font-variant-numeric: tabular-nums; color: var(--ink); }
.top td button { background: none; border: 0; padding: 0; min-height: 34px; text-align: left; font: 600 13px var(--f-body); }
.top td button:hover { color: var(--accent); }
.keys { margin: 6px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; }
.keys dt { font: 500 12px var(--f-mono); color: var(--ink); white-space: nowrap; }
.keys dd { margin: 0; color: var(--muted); }
kbd { font: 500 11px var(--f-mono); border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; background: var(--raised); }
.foot { font-size: 11.5px; color: var(--muted); line-height: 1.45; margin: 0; }
.foot a { color: inherit; }

/* sun clock dock */
.dock {
  position: fixed; z-index: 2;
  left: calc(max(16px, env(safe-area-inset-left, 0px)) + var(--side) + 16px);
  right: calc(max(16px, env(safe-area-inset-right, 0px)) + var(--rail) + 16px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  max-width: 820px; margin-inline: auto;
  display: grid; grid-template-columns: 52px 1fr; gap: 14px; align-items: center;
  padding: 10px 16px 8px 10px; border-radius: 12px;
  background: var(--sheet); backdrop-filter: blur(12px); border: 1px solid var(--rule);
}
.play { width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--sun); color: var(--accent-ink); display: grid; place-items: center; }
.play svg { width: 20px; height: 20px; }
.dk-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.clock { font: 800 26px/1 var(--f-display); font-variant-numeric: tabular-nums; }
.clock small { font: 500 12px var(--f-mono); color: var(--muted); margin-left: 4px; }
.dk-date { font: 600 14px var(--f-body); }
.dk-sun { font: 400 12px var(--f-mono); color: var(--muted); }
.dk-sun b { color: var(--sun); font-weight: 500; }
.chip { min-height: 30px; padding: 0 10px; border-radius: 15px; border: 1px solid var(--rule); background: var(--raised); font: 600 12px var(--f-body); }
.chip:hover { border-color: var(--sun); }
.chip[aria-pressed="true"] { border-color: var(--sun); color: var(--sun); }
.dk-top .chip:first-of-type { margin-left: auto; }
.dk-sliders { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; }
.dk-sliders label { display: grid; gap: 0; font: 500 10.5px var(--f-mono); color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.dk-sliders input { accent-color: var(--sun); }
.dk-foot { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font: 400 12px var(--f-mono); color: var(--muted); }
.dk-foot span { margin-right: auto; }

/* right rail: altitude ladder + buttons */
.rail { position: fixed; z-index: 2; right: max(16px, env(safe-area-inset-right, 0px)); top: calc(env(safe-area-inset-top, 0px) + 16px); bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); width: var(--rail); display: flex; flex-direction: column; align-items: flex-end; gap: 12px; pointer-events: none; }
.rail > * { pointer-events: auto; }
.ladder { position: relative; flex: 1; width: 100%; min-height: 200px; max-height: 560px; background: var(--sheet); backdrop-filter: blur(10px); border: 1px solid var(--rule); border-radius: 10px; }
.ladder::before { content: ""; position: absolute; right: 8px; top: 8px; bottom: 8px; width: 2px; background: linear-gradient(var(--rule), color-mix(in srgb, var(--accent) 50%, var(--rule))); border-radius: 1px; }
.rung { position: absolute; right: 0; transform: translateY(-50%); display: flex; align-items: center; gap: 6px; background: none; border: 0; padding: 3px 0; text-align: right; color: var(--muted); }
.rung span { font: 500 10.5px/1.15 var(--f-body); text-shadow: 0 0 4px var(--space), 0 0 8px var(--space); max-width: 104px; }
.rung span small { display: block; font: 400 10px var(--f-mono); opacity: .8; }
.rung i { width: 10px; height: 2px; background: var(--muted); margin-right: 4px; flex: none; }
.rung:hover { color: var(--accent); }
.rung:hover i { background: var(--accent); }
.rung.pow span { font: 500 10px var(--f-mono); opacity: .55; }
.rung.pow i { width: 6px; margin-right: 6px; }
.marker { position: absolute; right: 0; transform: translateY(-50%); display: flex; align-items: center; gap: 6px; pointer-events: none; }
.marker b { font: 600 12px var(--f-mono); background: var(--accent); color: var(--accent-ink); padding: 3px 7px; border-radius: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.marker i { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--space); margin-right: 2px; }
.mapctl { display: flex; flex-direction: column; gap: 8px; }
.mapctl button { width: 46px; height: 46px; border-radius: 10px; border: 1px solid var(--rule); background: var(--sheet); backdrop-filter: blur(10px); display: grid; place-items: center; font: 500 22px/1 var(--f-mono); }
.mapctl button:hover { border-color: var(--accent); }
.mapctl button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.mapctl svg { width: 20px; height: 20px; }
#compass svg { transition: none; }

/* tour caption */
#caption { position: fixed; z-index: 4; top: calc(env(safe-area-inset-top, 0px) + 16px); left: calc(max(16px, env(safe-area-inset-left, 0px)) + var(--side) + 16px); right: calc(max(16px, env(safe-area-inset-right, 0px)) + var(--rail) + 16px); max-width: 560px; margin-inline: auto; padding: 14px 16px 12px; border-radius: 12px; background: var(--sheet); backdrop-filter: blur(12px); border: 1px solid var(--accent); }
#caption h2 { margin: 2px 0 6px; font: 800 22px/1.05 var(--f-display); letter-spacing: -.01em; }
#caption p { margin: 0; font-size: 14px; line-height: 1.45; }
.cap-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.cap-dots { display: flex; gap: 5px; margin-right: auto; }
.cap-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--rule); }
.cap-dots i.on { background: var(--accent); }

/* labels and tooltip */
#labels { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.lbl { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 5px; white-space: nowrap; pointer-events: auto; cursor: pointer; background: none; border: 0; padding: 4px 2px; color: var(--ink); font: 600 12px/1 var(--f-body); text-shadow: 0 0 3px var(--space), 0 0 6px var(--space), 0 1px 2px var(--space); will-change: transform; }
.lbl::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 1.5px var(--space); flex: none; }
.lbl small { font: 400 10.5px/1 var(--f-mono); color: var(--muted); }
.lbl.big { font-size: 14px; font-family: var(--f-display); }
.lbl.bld { font: 600 11.5px/1 var(--f-body); }
.lbl.bld::before { width: 2px; height: 14px; border-radius: 1px; background: var(--accent); }
.lbl:hover { color: var(--accent); }
#tip { position: fixed; z-index: 5; pointer-events: none; background: var(--sheet); border: 1px solid var(--rule); border-radius: 8px; padding: 9px 11px; font-size: 13px; line-height: 1.45; max-width: 270px; backdrop-filter: blur(8px); }
#tip strong { display: block; font: 600 17px var(--f-display); color: var(--accent); font-variant-numeric: tabular-nums; }
#tip .m { font: 400 12px var(--f-mono); color: var(--muted); }

@media (max-width: 1100px) { :root { --rail: 52px; } .ladder { display: none; } .rail { justify-content: center; } }
/* phone: sheet becomes a bottom drawer, clock above it, buttons top-right */
@media (max-width: 760px) {
  .sheet { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 52%; border-radius: 14px 14px 0 0; border-bottom: 0; padding-bottom: env(safe-area-inset-bottom, 0px); padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
  .sheet-head { padding: 12px 16px 10px; align-items: center; }
  .sheet.collapsed .sheet-body { display: none; }
  .sheet.collapsed .sheet-head { border-bottom: 0; }
  .icon-btn { display: inline-block; }
  h1 { font-size: 22px; }
  .lede, .back { display: none; }
  .sheet-body { padding: 12px 16px 16px; gap: 14px; }
  .dock { left: max(10px, env(safe-area-inset-left, 0px)); right: max(10px, env(safe-area-inset-right, 0px)); bottom: calc(var(--sheet-h) + 10px); grid-template-columns: 44px 1fr; gap: 10px; padding: 8px 12px 6px 8px; }
  .play { width: 44px; height: 44px; }
  .clock { font-size: 21px; }
  .dk-sun, .dk-foot span { display: none; }
  .dk-sliders { grid-template-columns: 1fr 1fr; gap: 10px; }
  .rail { top: calc(env(safe-area-inset-top, 0px) + 12px); bottom: auto; right: max(10px, env(safe-area-inset-right, 0px)); }
  .mapctl button { width: 44px; height: 44px; }
  #caption { left: 10px; right: 66px; top: calc(env(safe-area-inset-top, 0px) + 10px); padding: 10px 12px; }
  #caption h2 { font-size: 18px; }
  #caption p { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { .switch i, .switch i::after, #loader { transition: none; } }
