/* Pointbreak UI. Text-bearing surfaces use opaque near-black so the ocean can
   stay visually dominant without compromising the 8:1 project contrast floor. */
:root {
  color-scheme: dark;
  --ink: #f4f7f8;
  --secondary: #c8d2d7;
  --accent: #79dcff;
  --panel: #0d1418;
  --panel-raised: #141e23;
  --line: #34454e;
  --focus: #a8eaff;
  --radius: 10px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; overflow: hidden; background: #06090c; }
button, summary { font: inherit; }
button { color: inherit; }

#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

#nogl {
  display: none; position: fixed; inset: 40%;
  color: var(--ink); font: 500 16px/1.5 system-ui, sans-serif; text-align: center;
}

.appbar {
  position: fixed;
  z-index: 20;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  min-height: 56px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 44px;
  align-items: center;
  gap: 18px;
  padding: 5px 6px 5px 14px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
}

/* overflow hidden: a squeezed brand must clip, never paint over the menus */
.brand { min-width: 0; display: flex; align-items: baseline; gap: 10px; overflow: hidden; }
.brand-name { font-size: 16px; line-height: 1; font-weight: 760; letter-spacing: -0.025em; }
.brand-place { color: var(--secondary); font-size: 13px; font-weight: 550; white-space: nowrap; }

.top-status {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.status-divider { width: 1px; height: 14px; background: var(--line); }

.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
}
.icon-button svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.drawer-backdrop {
  position: fixed;
  z-index: 29;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgba(2, 7, 10, 0.56);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease-in;
}

.control-drawer {
  position: fixed;
  z-index: 30;
  top: 0;
  right: 0;
  width: min(410px, 100vw);
  height: 100%;
  color: var(--ink);
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 48px rgba(0, 0, 0, 0.34);
  transform: translateX(102%);
  transition: transform 220ms ease-in;
  visibility: hidden;
}

body.menu-open .drawer-backdrop { opacity: 1; pointer-events: auto; transition-timing-function: ease-out; }
body.menu-open .control-drawer { transform: translateX(0); visibility: visible; transition-timing-function: ease-out; }

.drawer-header {
  min-height: 78px;
  padding: max(16px, env(safe-area-inset-top)) 14px 12px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}
.eyebrow { margin-bottom: 4px; color: var(--accent); font-size: 12px; line-height: 1.2; font-weight: 750; letter-spacing: 0.09em; text-transform: uppercase; }
.drawer-header h1 { font-size: 21px; line-height: 1.1; letter-spacing: -0.025em; text-wrap: balance; }

.drawer-scroll {
  height: calc(100% - 78px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 22px max(28px, env(safe-area-inset-bottom));
}

.control-section { padding: 22px 0; border-bottom: 1px solid var(--line); }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 13px; }
.section-heading h2 { font-size: 16px; line-height: 1.2; }
.section-heading span { color: var(--secondary); font-size: 12px; font-weight: 550; }

.site-controls, .camera-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.camera-controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.site-controls button, .camera-controls button, .toggle-controls button, .mode-controls button {
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: transparent;
  font-size: 13px;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}
.site-controls button[aria-pressed="true"], .camera-controls button[aria-pressed="true"] {
  color: #061116;
  background: var(--accent);
  border-color: var(--accent);
}

.toggle-controls { margin-top: 14px; display: grid; gap: 7px; }
.toggle-controls button, .mode-controls button { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.control-state { color: var(--accent); font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: 0.05em; }

.mode-controls { display: grid; gap: 7px; margin-bottom: 18px; }
.mode-controls button { min-height: 44px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: transparent; font-size: 13px; font-weight: 650; text-align: left; cursor: pointer; }
.toggle-controls + .mode-controls { margin-top: 7px; margin-bottom: 0; }
.range-controls { display: grid; gap: 18px; }
.range-control { display: grid; gap: 9px; }
.section-position-control { margin-top: 18px; }
.section-position-control[hidden] { display: none; }
.range-label { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 3px 16px; min-width: 0; font-size: 13px; font-weight: 650; }
.range-label > span { flex: 1 1 6rem; min-width: 0; }
.range-label output { flex: 0 0 auto; margin-left: auto; color: var(--accent); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.range-control input[type="range"] {
  width: 100%;
  height: 24px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Month-of-year picker. A select rather than the drawer's usual cycle button:
   twelve items is eleven clicks too many, and a month is a value the reader
   already has an ordered mental model of. Contrast verified against the 8:1
   floor — ink on panel-raised is 15.73:1, secondary on panel 12.08:1. */
/* margin-bottom matches .range-controls' own 18px gap: without it the source
   note butts against the "Wave size" label and reads as captioning the slider
   rather than the select above it. */
.select-control { display: grid; gap: 9px; margin: 18px 0; }
.select-control select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-raised);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}
.select-control select:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.select-note { color: var(--secondary); font-size: 12px; line-height: 1.4; }

.readout { border-bottom: 1px solid var(--line); }
.readout summary {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.readout summary::-webkit-details-marker { display: none; }
.readout summary::after { content: "+"; color: var(--accent); font-size: 20px; font-weight: 500; }
.readout[open] summary::after { content: "−"; }

#hud {
  padding: 0 0 18px;
  display: grid;
  grid-template-columns: minmax(76px, auto) minmax(0, 1fr);
  gap: 5px 12px;
  font-size: 12px;
  line-height: 1.45;
}
#hud .k { color: var(--secondary); font-weight: 550; }
#hud .v { color: var(--accent); font-weight: 550; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.key-deck { padding: 22px 0 0; }
.key-group-label { margin-bottom: 7px; color: var(--secondary); font-size: 12px; font-weight: 650; }
.break-keys { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.command-keys { margin-top: 9px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.break-keys button, .command-keys button {
  min-width: 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 6px;
  color: var(--ink);
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.command-keys button { justify-content: flex-start; padding-inline: 10px; }
.break-keys button[aria-pressed="true"], .command-keys button[aria-pressed="true"] {
  color: #061116;
  background: var(--accent);
  border-color: var(--accent);
}
kbd {
  min-width: 25px;
  padding: 4px 6px;
  color: inherit;
  background: #233139;
  border: 1px solid #62727a;
  border-radius: 4px;
  box-shadow: 0 2px 0 #05090b;
  font: 750 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: center;
}
.break-keys button[aria-pressed="true"] kbd, .command-keys button[aria-pressed="true"] kbd {
  background: #dff7ff;
  border-color: #133744;
  box-shadow: 0 2px 0 #2e788f;
}
.space-key kbd { min-width: 52px; }

.ui-reveal {
  display: none;
  position: fixed;
  z-index: 40;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  min-height: 44px;
  padding: 0 14px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

button:focus-visible, summary:focus-visible, input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

@media (hover: hover) and (pointer: fine) {
  .icon-button:hover, .site-controls button:hover, .camera-controls button:hover, .toggle-controls button:hover, .mode-controls button:hover,
  .break-keys button:hover, .command-keys button:hover, .ui-reveal:hover { background: #1c2a31; }
  .site-controls button[aria-pressed="true"]:hover, .camera-controls button[aria-pressed="true"]:hover,
  .break-keys button[aria-pressed="true"]:hover, .command-keys button[aria-pressed="true"]:hover { background: var(--accent); }
}

body.hidepanel .appbar,
body.hidepanel .control-drawer,
body.hidepanel .drawer-backdrop { display: none; }
body.hidepanel .ui-reveal { display: block; }
body.controls-disabled .ui-reveal { display: none; }

/* Cross-section analysis panel (C toggles). */
.section-panel {
  position: fixed; left: 14px; bottom: 14px;
  width: min(560px, calc(100vw - 28px)); height: 210px;
  background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 4px 6px 2px;
}
.section-panel canvas { display: block; width: 100%; height: 100%; touch-action: none; }

@media (max-width: 700px) {
  .appbar {
    top: max(8px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    min-height: 52px;
    /* Phones: the brand keeps its natural width and the MENUS become the
       shrinkable column — the reverse of the desktop split. Bar-item labels
       ellipsize under pressure instead of letting columns collide. */
    grid-template-columns: auto minmax(0, 1fr) 44px;
    gap: 10px;
    padding-left: 12px;
  }
  .brand-place { display: none; }
  .top-status { justify-content: flex-end; font-size: 12px; min-width: 0; }
  .spot-menu { overflow: hidden; }
  .spot-menu .fisheye-menubar { min-width: 0; font-size: 12px; }
  .spot-menu .fisheye-menubar-item {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 8px 7px;
  }
  .top-paused { font-size: 10px; letter-spacing: 0.02em; }
  .control-drawer { width: min(390px, 100vw); }
  .drawer-scroll { padding-left: 18px; padding-right: 18px; }
  .section-panel { left: 8px; bottom: max(8px, env(safe-area-inset-bottom)); width: calc(100vw - 16px); height: min(190px, 32vh); }
}

@media (max-width: 390px) {
  .camera-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .drawer-backdrop, .control-drawer { transition-duration: 1ms; }
}

/* ── Appbar spot menu (vendored fisheye-menu) ─────────────────────
   Contrast, computed on solid pairs (8:1 project floor):
   accent #79dcff on panel #0d1418        11.94:1  [bar item, active mark]
   ink #f4f7f8 on panel #0d1418           17.26:1  [menu items]
   panel #0d1418 on accent #79dcff        11.94:1  [item hover]
   accent #79dcff on #1c2a31               9.47:1  [bar item hover]
   secondary #c8d2d7 on panel #0d1418     12.08:1  [paused badge] */
:root {
  --fisheye-bar-bg: transparent;
  --fisheye-bar-border: transparent;
  --fisheye-bar-text: var(--accent);
  --fisheye-bar-hover-bg: #1c2a31;
  --fisheye-bar-hover-text: var(--accent);
  --fisheye-panel-bg: var(--panel);
  --fisheye-panel-border: var(--line);
  --fisheye-panel-shadow: rgba(0, 0, 0, 0.45);
  --fisheye-item-text: var(--ink);
  --fisheye-item-hover-bg: var(--accent);
  --fisheye-item-hover-text: var(--panel);
  --fisheye-item-trigger-bg: #1c2a31;
  --fisheye-separator-color: var(--line);
  --fisheye-focus-ring: var(--focus);
  --fisheye-swatch-border: transparent;
}

.spot-menu { min-width: 0; }
.spot-menu .fisheye-menubar {
  background: transparent;
  border-bottom: 0;
  height: auto;
  font-size: 13px;
  font-weight: 650;
}
.spot-menu .fisheye-menubar-item {
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
}
/* Dropdown affordance; decorative, exempt from the text floor. */
.spot-menu .fisheye-menubar-item::after { content: " \25BE"; font-size: 11px; }

.top-paused {
  color: var(--secondary);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.spot-menu .fisheye-menubar { gap: 4px; }
