:root {
  /* Obsidian Metrics design language (tokens from obsidian-design-language.css) */
  --od-obsidian: #08070A;
  --od-vellum: #141119;
  --od-gold: #F1B43E;
  --od-gold-hi: #F8D77A;
  --od-cream: #F4E9D7;
  --od-cream-dim: #C6BCA9;
  --od-muted: #8B8397;
  --od-display: "Fraunces", "Cormorant Garamond", ui-serif, Georgia, serif;
  --od-body: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --od-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --glass: rgba(8, 7, 10, 0.62);
  --glass-strong: rgba(14, 12, 17, 0.86);
  --line: rgba(241, 180, 62, 0.16);
  --text: var(--od-cream);
  --muted: var(--od-muted);
  --accent: var(--od-gold);
  --accent-ink: var(--od-obsidian);
  --radius: 12px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --credit-gap: 30px; /* keep the map attribution line visible below the dock */
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--od-obsidian);
  color: var(--text);
  font: 14px/1.4 var(--od-body);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
#view {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}
#view .cesium-viewer, #view .cesium-widget, #view canvas { width: 100%; height: 100%; }
#view .cesium-viewer-bottom { z-index: 3; }
#view .cesium-credit-lightbox-overlay { z-index: 50; }
/* Google asks for clear space between its logo and any other logo. */
#view .cesium-credit-logoContainer { margin-right: 16px; }

svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; transition: opacity 0.35s ease; }
.ui > * { pointer-events: auto; }
body.ui-hidden .ui { opacity: 0; }
body.ui-hidden .ui > * { pointer-events: none; }

.topbar {
  position: absolute;
  top: calc(12px + var(--safe-t));
  left: calc(12px + var(--safe-l));
  right: calc(12px + var(--safe-r));
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.spacer { flex: 1; pointer-events: none !important; }

.search {
  display: flex;
  align-items: center;
  gap: 6px;
  width: min(440px, 100%);
  padding: 5px 5px 5px 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
}
.search-icon { color: var(--muted); flex: none; }
.search input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font: inherit;
  font-size: 16px; /* 16px stops iOS from zooming on focus */
  padding: 6px 2px;
}
.search input::placeholder { color: var(--muted); }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--glass);
  color: var(--text);
  font: 600 13px/1 var(--od-body);
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: background 0.15s, transform 0.1s;
}
.btn:hover { background: var(--glass-strong); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { background: var(--od-gold-hi); }

.icon-btn {
  appearance: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--glass);
  color: var(--text);
  cursor: pointer;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.icon-btn:hover { background: var(--glass-strong); }

.chip {
  font: 500 11px/1 var(--od-mono);
  letter-spacing: 0.02em;
  color: var(--muted);
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* Darkens the lower frame so the OSD reads over bright city imagery,
   stopping above the attribution line so credits stay untouched. */
.ui::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--credit-gap) + var(--safe-b));
  height: min(46vh, 420px);
  background: linear-gradient(to top, rgba(6, 9, 13, 0.55), rgba(6, 9, 13, 0.25) 55%, rgba(6, 9, 13, 0));
  pointer-events: none;
}

/* Drone-style on-screen display */
.osd {
  position: absolute;
  left: calc(18px + var(--safe-l));
  bottom: calc(var(--dock-h, 132px) + var(--credit-gap) + 22px + var(--safe-b));
  max-width: min(560px, calc(100vw - 36px));
  pointer-events: none;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.55), 0 1px 2px rgba(0, 0, 0, 0.6);
}
.osd-eyebrow { font: 500 11px/1 var(--od-mono); letter-spacing: 0.18em; text-transform: uppercase; color: var(--od-gold); margin-bottom: 8px; }
.osd-place { font-family: var(--od-display); font-size: clamp(28px, 4.8vw, 48px); font-weight: 500; letter-spacing: -0.01em; line-height: 1.05; }
.osd-detail { margin-top: 4px; color: var(--od-cream-dim); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.osd-read {
  display: inline-block;
  margin-top: 8px;
  padding: 5px 9px;
  border-radius: 8px;
  background: rgba(6, 9, 13, 0.55);
  font: 500 12px/1.4 var(--od-mono);
  color: var(--accent);
  letter-spacing: 0.04em;
  text-shadow: none;
}
.osd-read:empty { display: none; }

.dock {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--credit-gap) + var(--safe-b));
  width: min(760px, calc(100vw - 24px - var(--safe-l) - var(--safe-r)));
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 10px;
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}
.dock-row { display: flex; align-items: center; gap: 10px; }
.dock-row + .dock-row { margin-top: 10px; }

.play {
  appearance: none;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.play svg { fill: currentColor; stroke: none; width: 20px; height: 20px; }
.play .i-play { display: none; }
.play.paused .i-play { display: block; }
.play.paused .i-pause { display: none; }

.seg {
  flex: 1;
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(244, 233, 215, 0.06);
  overflow-x: auto;
  scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg button {
  appearance: none;
  flex: 1 0 auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 600 13px/1 var(--od-body);
  padding: 10px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--od-cream); color: var(--od-obsidian); }
.seg button.busy { opacity: 0.6; }

.tune-toggle { display: none; }

.sliders { gap: 16px; }
.slider { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.slider span { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; font-weight: 500; }
.slider b { color: var(--text); font: 500 12px var(--od-mono); }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  margin: 0;
  touch-action: pan-y;
}
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.18); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.18); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.4); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 0; }

.hint { color: var(--muted); font-size: 12px; text-align: center; margin-top: 8px; min-height: 0; }
.hint:empty { display: none; }

.toast {
  position: fixed;
  top: calc(66px + var(--safe-t));
  left: 50%;
  transform: translate(-50%, -8px);
  background: var(--glass-strong);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 999px;
  font-weight: 500;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 40;
  max-width: calc(100vw - 32px);
  text-align: center;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.unhide {
  position: fixed;
  top: calc(12px + var(--safe-t));
  right: calc(12px + var(--safe-r));
  z-index: 30;
  display: none;
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(12, 16, 22, 0.35);
  color: rgba(255, 255, 255, 0.75);
  font: 600 12px var(--od-body);
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
}
body.ui-hidden .unhide { display: block; }

dialog {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--od-vellum);
  color: var(--text);
  padding: 0;
  width: min(440px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
.settings { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.settings h2 { margin: 0; font: 500 21px var(--od-display); }
.settings label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; }
.settings small { color: var(--muted); font-weight: 400; }
.settings select, .settings input {
  font: 400 15px var(--od-body);
  color: var(--text);
  background: var(--od-obsidian);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}
.note { margin: 0; color: var(--muted); font-size: 12px; }
.settings-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Phones */
@media (max-width: 640px) {
  :root { --credit-gap: 26px; }
  .topbar { flex-wrap: wrap; }
  .search { order: 1; width: 100%; }
  #surprise { order: 2; }
  .chip { order: 3; max-width: calc(100vw - 230px); }
  .spacer { order: 2; }
  #hideBtn, #settingsBtn { order: 4; }
  .dock { border-radius: 18px; padding: 8px; }
  .dock-row { gap: 6px; }
  .play { width: 40px; height: 40px; }
  .tune-toggle { width: 36px; height: 36px; }
  .seg button { padding: 10px 8px; font-size: 12.5px; }
  .seg .wide { display: none; }
  #view .cesium-widget-credits, #view .maplibregl-ctrl-attrib { font-size: 9.5px; line-height: 1.25; }
  .tune-toggle { display: grid; }
  .sliders { display: none; flex-direction: column; align-items: stretch; gap: 10px; }
  .dock.tune .sliders { display: flex; }
  .osd { left: calc(14px + var(--safe-l)); }
  .osd-detail { font-size: 12px; }
  .chip { display: none; }
}

/* ---------- cinema overlays (inside #view, above the map, below its credits) ---------- */
#view .cesium-viewer-bottom { z-index: 5; }
#view .maplibregl-ctrl-bottom-right, #view .maplibregl-ctrl-bottom-left { z-index: 5; }
.cine-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.cine-tint { position: absolute; inset: 0; mix-blend-mode: soft-light; }
.cine-vignette { position: absolute; inset: 0; opacity: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.9) 100%); }
.cine-bar { position: absolute; left: 0; right: 0; height: 0; background: #000; transition: height 0.3s; }
.cine-bar.top { top: 0; }
.cine-bar.bottom { bottom: 0; }
.cine-guide { display: none; position: absolute; top: 0; bottom: 0; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.55); outline: 1px solid rgba(255, 255, 255, 0.5); }
.cine-label { display: none; position: absolute; top: 2.2%; right: 2.2%; font: 550 clamp(11px, 1.5vh, 22px) var(--od-body); color: rgba(255, 255, 255, 0.9); text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7); letter-spacing: 0.02em; }

/* Capture mode: only the picture, the grade/letterbox and the attribution remain. */
body.capture .ui, body.capture .studio, body.capture .toast, body.capture .unhide { display: none !important; }
body.capture .cine-guide { display: none !important; }
/* Live preview: keep the label clear of the top bar; capture puts it top-right. */
body:not(.capture) .cine-label { top: calc(70px + var(--safe-t)); right: auto; left: calc(18px + var(--safe-l)); }

/* ---------- studio panel ---------- */
.studio {
  position: fixed;
  z-index: 20;
  top: calc(64px + var(--safe-t));
  right: calc(12px + var(--safe-r));
  bottom: calc(var(--credit-gap) + 12px + var(--safe-b));
  width: 320px;
  overflow-y: auto;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  border-radius: 18px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 4px 14px 14px;
}
.studio[hidden] { display: none; }
.studio-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: -4px; z-index: 1; margin: -4px -14px 0; padding: 12px 14px 8px; background: var(--od-vellum); border-radius: 18px 18px 0 0; }
.studio-head h2 { margin: 0; font: 500 19px var(--od-display); }
.studio-sec { border-top: 1px solid var(--line); padding: 12px 0; display: flex; flex-direction: column; gap: 10px; }
.studio-sec:first-of-type { border-top: 0; }
.sec-title { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; font-size: 13px; }
.muted { color: var(--muted); font-weight: 400; font-size: 12px; text-align: right; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 500; flex: 1; min-width: 0; }
.field select {
  font: 500 14px var(--od-body);
  color: var(--text);
  background: var(--od-obsidian);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
}
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.row.two > * { flex: 1; }
.btn.wide { width: 100%; }
.btn.file { display: inline-flex; align-items: center; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.keys { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 180px; overflow-y: auto; }
.keys li { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 6px 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.05); }
.keys li span:first-child { font-weight: 700; width: 26px; }
.keys li .mono { flex: 1; font-family: var(--od-mono); color: var(--muted); }
.mini { appearance: none; border: 1px solid var(--line); background: transparent; color: var(--text); border-radius: 6px; font: 500 11px var(--od-body); padding: 4px 7px; cursor: pointer; }
body.studio-open .dock { width: min(760px, calc(100vw - 360px)); transform: none; left: 12px; }
@media (max-width: 640px) {
  .studio { top: auto; left: 8px; right: 8px; width: auto; max-height: 58vh; bottom: calc(var(--credit-gap) + 8px + var(--safe-b)); }
  body.studio-open .dock { display: none; }
  #cinemaBtn { order: 4; }
}

[hidden] { display: none !important; }
