/**
 * Minimal redesign. Loaded last.
 *
 * The legend keeps its layout and shape (04-legend.css); only its look
 * (surface, tabs, buttons) follows this skin.
 *
 * Quiet chrome over the map: no full-width bars or hairline boxes. Every
 * control floats as a soft, rounded, translucent surface with one shadow;
 * corners are generous; text is lighter and smaller except the numbers that
 * matter. One accent (a clear blue) for "on". Every control keeps its id and
 * its function (tools/ui_regress.py).
 *
 * Layout fixes from the per-control regression on a phone:
 *  - the legend's tabs lay over the sidebar's close button: the open
 *    sidebar is above the legend;
 *  - the field debug panel opened above the top of the screen: it is
 *    held inside the viewport and scrolls;
 *  - the camera view panel lay under it: they stack apart.
 */
:root {
  --ink-950: oklch(14% 0.006 260);
  --ink-900: oklch(18% 0.006 260);
  --ink-850: oklch(21% 0.006 260);
  --ink-800: oklch(26% 0.006 260);
  --ink-750: oklch(30% 0.006 260);
  --ink-700: oklch(36% 0.006 260);
  --ink-600: oklch(46% 0.005 260);
  --ink-500: oklch(64% 0.004 260);
  --ink-300: oklch(84% 0.003 260);
  --ink-100: oklch(97% 0.002 260);

  --surface: oklch(17% 0.006 260 / 0.72);
  --surface-solid: oklch(18% 0.006 260 / 0.94);
  --surface-hover: oklch(97% 0 0 / 0.07);
  --surface-press: oklch(97% 0 0 / 0.12);
  --edge: inset 0 0 0 0.5px oklch(97% 0 0 / 0.10);
  --hairline: oklch(97% 0 0 / 0.06);
  --hairline-strong: oklch(97% 0 0 / 0.12);
  --scrim-strong: var(--surface);

  --accent-live:      oklch(72% 0.15 250);
  --accent-live-dim:  oklch(72% 0.15 250 / 0.18);
  --accent-live-line: oklch(72% 0.15 250 / 0.55);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --shadow-raised: 0 4px 16px oklch(0% 0 0 / 0.28);
  --shadow-float:  0 8px 32px oklch(0% 0 0 / 0.34);

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-bold: 600;
  --weight-black: 650;

  --blur: blur(20px) saturate(1.5);
}

/* ── Surfaces: translucent, borderless, one shadow ─────────────────── */
.playbackBar,
.legendPanel,
.sidebarPanel,
.pbMenu,
.pbSubmenu,
.fdPanel,
.pwaInstallBanner,
.camClientPicker {
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--edge), var(--shadow-float);
}
.pbMenu, .pbSubmenu { border-radius: var(--radius-md); padding: 6px; }
.aboutModalContent {
  border: none;
  border-radius: 22px;
  box-shadow: var(--edge), var(--shadow-float);
}

/* ── Top: no bar. Brand and buttons float on their own ─────────────── */
#topbar {
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom: none;
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }
#topbar .brandRow {
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--edge), var(--shadow-raised);
  border-radius: var(--radius-pill);
  padding: 6px 14px 6px 12px;
}
.brand { font-weight: var(--weight-bold); letter-spacing: -0.01em; }
.status, #statusText { font-weight: var(--weight-medium); letter-spacing: 0.02em; }

/* ── Round buttons ──────────────────────────────────────────────────── */
.menuBtn,
.pbMenuBtn,
.shareBtn,
.autoCameraBtn,
#camCenterBtn,
#map3dToggle,
#followHeadingBtn,
#fpvBtn,
#firstPersonBtn,
#camReplayBtn,
.legendToggleBtn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--edge), var(--shadow-raised);
  color: var(--ink-100);
  transition: background var(--ease-standard), transform var(--ease-standard);
}
.pbMenuBtn {
  width: auto;
  border-radius: var(--radius-pill);
  padding: 0 16px;
  font-weight: var(--weight-medium);
}
.menuBtn:hover, .pbMenuBtn:hover, .shareBtn:hover,
#camCenterBtn:hover, #map3dToggle:hover, #followHeadingBtn:hover,
#fpvBtn:hover, #firstPersonBtn:hover, .legendToggleBtn:hover {
  background: var(--surface-solid);
}
.menuBtn:active, .pbMenuBtn:active, #camCenterBtn:active, #map3dToggle:active,
#followHeadingBtn:active, #fpvBtn:active, #firstPersonBtn:active, .legendToggleBtn:active {
  transform: scale(0.94);
}
.legendToggleBtn.active,
#fpvBtn.active,
#firstPersonBtn.active,
#followHeadingBtn.active,
#map3dToggle[aria-pressed="true"],
.autoCameraBtn.active {
  background: var(--accent-live);
  color: oklch(14% 0.02 250);
}

/* ── Legend: same layout, this skin's look ────────────────────────── */
.legendTab {
  border-radius: var(--radius-pill);
  font-weight: var(--weight-medium);
  letter-spacing: 0.01em;
}
.legendTab.active { background: var(--surface-press); }
.legendCollapseBtn { border-radius: 50%; }
.legendCollapseBtn:hover { background: var(--surface-hover); }
.legendHeader { border-bottom-color: var(--hairline); }
.legendUnit, .legendCatLabel { color: var(--ink-500); font-weight: var(--weight-regular); }

/* ── Sidebar: above the legend while open (its close button was under
   the legend's tabs) ─────────────────────────────────────────────────── */
.sidebarPanel { z-index: calc(var(--z-panel-toggle) + 1); }
.sidebarHeader { border-bottom: none; }
.sidebarTitle { font-weight: var(--weight-bold); letter-spacing: -0.01em; }
.sidebarClose { border-radius: 50%; }
.sidebarClose:hover { background: var(--surface-hover); }
.tabBar { gap: 4px; border-bottom: none; }
.tab { border-radius: var(--radius-pill); }
.tab.active { background: var(--surface-press); }
.sidebarPanel .item { border-radius: var(--radius-md); border: none; }
.sidebarPanel .item:hover { background: var(--surface-hover); }

/* ── Playback bar ───────────────────────────────────────────────────── */
.playbackBar {
  padding: 10px 16px 8px;
  border-radius: 22px;
}
.playbackBar #pbPlay {
  border-radius: var(--radius-pill);
  border: none;
  font-weight: var(--weight-bold);
  box-shadow: none;
}
.playbackBar #pbScrub { accent-color: var(--accent-live); }
.pbSpeed, #pbSpeed {
  border: none;
  border-radius: var(--radius-pill);
  background: var(--surface-hover);
}
.pbPageBtn { border: none; border-radius: 50%; background: transparent; }
.pbPageBtn:hover { background: var(--surface-hover); }
#pbNow { font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; }
#pbLeft, #pbRight { color: var(--ink-500); font-variant-numeric: tabular-nums; }

/* ── Menus ──────────────────────────────────────────────────────────── */
.pbMenuItem, .pbSubmenuItem {
  border-radius: var(--radius-sm);
  border: none;
}
.pbMenuItem:hover, .pbSubmenuItem:hover { background: var(--surface-hover); }
.pbSubmenuItem.active { background: var(--accent-live-dim); }
.pbMenuDivider { background: var(--hairline); margin: 4px 8px; }

/* ── Footer: one quiet line ─────────────────────────────────────────── */
#appFooter {
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-top: none;
  color: var(--ink-500);
  text-shadow: 0 1px 2px oklch(0% 0 0 / 0.6);
}
#appFooter a { color: var(--ink-300); }

/* ── Debug and camera panels: inside the screen, apart ─────────────── */
.fdPanel { border-radius: var(--radius-md); }
#fieldDebugPanel {
  top: 70px;
  bottom: auto;
  max-height: calc(100vh - 150px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
#cameraViewPanel {
  top: auto;
  bottom: 140px;
  left: 14px;
  right: auto;
}

/* ── Phones ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #fieldDebugPanel { right: 12px; left: auto; max-height: calc(100vh - 240px); }
  #cameraViewPanel { left: 12px; right: 12px; width: auto; bottom: 150px; }
}

/* Footer: a quiet solid strip, not text laid over the map. */
#appFooter {
  background: var(--ink-950);
  border-top: 1px solid var(--hairline);
  text-shadow: none;
  font-size: 11px;
  line-height: 15px;
}

/* Playback row: the slider gives way, so nothing runs off the bar
   (the Turbo toggle was cut off at the right edge on a phone). */
.pbRow1 { min-width: 0; }
.pbRow1 input[type="range"] { min-width: 0; }
@media (max-width: 768px) {
  .pbRow1 { gap: 8px; }
  .pbSpeed { gap: 4px; }
}

/* ── Layout rework ─────────────────────────────────────────────────────
   Fewer, smaller things on the map. */

/* Top: brand + status in one pill; the round buttons smaller. */
#topbar { height: 52px; gap: 8px; padding: 0 10px; }
.menuBtn, .shareBtn, .autoCameraBtn { width: 36px; height: 36px; }
.pbMenuBtn { height: 36px; padding: 0 14px; font-size: 14px; }
#topbar .brandRow { padding: 5px 12px 5px 10px; gap: 6px; }
#topbar .brand { font-size: 15px; }
#topbar .status {
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--edge);
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  font-size: 11px;
}

/* Map controls: one stack of small squircles down the right edge. */
.legendToggleBtn, #camCenterBtn, #map3dToggle, #followHeadingBtn, #fpvBtn, #firstPersonBtn {
  width: 38px; height: 38px;
  border-radius: 13px;
}
#map3dToggle { font-size: 12px; font-weight: var(--weight-bold); }

/* Playback: one slim card; times row quieter. */
.playbackBar { padding: 8px 12px 6px; gap: 4px; border-radius: 20px; }
.playbackBar #pbPlay { height: 32px; padding: 0 14px; font-size: 14px; }
.pbSpeed select, #pbSpeed { height: 30px; font-size: 13px; }
.pbToggleLabel, .pbSpeed { font-size: 12px; }
.pbRow2 { font-size: 11px; opacity: 0.85; }

/* Footer: smaller, tighter. */
#appFooter { font-size: 10px; line-height: 13px; padding-top: 4px; padding-bottom: 4px; }
#appFooter, #appFooter * { font-size: 10px !important; line-height: 13px !important; }
#appFooter .footerContent { gap: 0 8px; }
#appFooter { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* ── Less clunk ─────────────────────────────────────────────────────── */
/* Status reads as part of the brand row, not a second pill. */
#topbar .status { background: none; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; padding: 0 4px; }
/* Play: a filled soft chip, no outline ring. */
.playbackBar #pbPlay {
  background: var(--accent-live-dim);
  color: var(--accent-live);
  border: none !important;
  outline: none;
  box-shadow: none !important;
  height: 30px;
  min-width: 64px;
  padding: 0 12px;
  font-size: 13px;
}
.playbackBar #pbPlay:active { transform: scale(0.96); }
/* Thin track, small thumb. */
.playbackBar #pbScrub { height: 22px; }
/* Speed and Turbo: plain text controls, no chip backgrounds. */
.pbSpeed, #pbSpeed, .pbSpeed select { background: transparent; }
.pbToggleLabel { color: var(--ink-500); }
/* Times row: smaller and closer. */
.pbRow2 { margin-top: -2px; font-size: 11px; }
#pbNow { font-size: 12px; }
#pbLeft, #pbRight { font-size: 11px; }
/* Map buttons: lighter. */
.legendToggleBtn, #camCenterBtn, #map3dToggle, #followHeadingBtn, #fpvBtn, #firstPersonBtn {
  width: 36px; height: 36px; border-radius: 12px;
}
/* The open legend card lies over the map buttons, not under them. */
#camCenterBtn, #map3dToggle, #followHeadingBtn, #fpvBtn, #firstPersonBtn { z-index: calc(var(--z-panel-toggle) - 1); }
