/* ============================================================
   MBES Survey Planner — styles.css
   Original app styles + auth overlay styles
   ============================================================ */

/* ── Google Fonts are loaded via <link> in index.html ───────── */

/* ── App CSS variables & reset ─────────────────────────────── */
/* ── Design tokens ──────────────────────────────────────────────
   Andromeida brand palette (andromeida.com): deep navy #15257b /
   #00153b, bright blue #0099ff, brand teal #157988, neutral greys.
   Light is the default; <html data-theme="dark"> flips the app.
   The bathymetry colour ramps live in app.js and are deliberately
   left alone — they encode depth, not branding.
   ──────────────────────────────────────────────────────────── */
:root {
  /* surfaces */
  --bg:        #f7f8fa;
  --surface:   rgba(255, 255, 255, 0.94);
  --surface2:  #ffffff;
  /* tile surface: how solid the card body is (100% = opaque), and an
     optional frosted blur behind it. Try values live with ?tune in the URL. */
  --tile-pct:      30%;
  --tile-backdrop: blur(1px);
  /* dashboard panels float over the busy map, so they stay mostly solid */
  --card-pct:      14%;
  --card-backdrop: blur(4px) brightness(1.12) saturate(.8);
  /* glass: the colour translucent tiles/cards are mixed from; line: their outline */
  --glass:     var(--surface2);
  --line:      var(--border2);
  /* dashboard glass sits on a thin light floor, and dims/softens what shows
     through, so dark text stays readable over deep-blue sea */
  --glass-floor: rgba(247, 248, 250, 0.5);
  --glass-flat:  rgba(236, 244, 248, 0.78);   /* card look without backdrop-filter (masked scroller) */
  --border:    #d6d9e3;
  --border2:   #e9ebf1;
  /* ink */
  --fg:        #00153b;
  --fg2:       #5b6478;
  /* brand */
  --accent:    #15257b;
  --accent-fg: #ffffff;
  --accent2:   #0e5e6a;
  /* state */
  --danger:    #b7341a;
  --danger-fg: #ffffff;
  --warn:      #8a5d05;
  --measured:  #c46f12;   /* keep in sync with PAL_SRC in app.js */
  /* canvases */
  --map-bg:    #e6ebf1;
  --map-dot:   rgba(20, 40, 80, .13);
  --map-edge:  rgba(15, 30, 60, .16);
  --map-shade: rgba(15, 30, 60, .16);
  --plot-bg:   #08233a;
  --scrim:     rgba(0, 21, 59, 0.45);
  /* elevation */
  --shadow:    0 1px 2px rgba(0, 21, 59, .05), 0 6px 16px rgba(0, 21, 59, .07);
  --shadow-lg: 0 2px 6px rgba(0, 21, 59, .07), 0 18px 44px rgba(0, 21, 59, .14);
  /* geometry — the site settles on 8px */
  --r-sm: 6px;
  --r:    8px;
  --r-lg: 12px;
  /* type */
  --font:  'Geist', 'Inter', system-ui, -apple-system, sans-serif;
  --mono:  'Geist Mono', 'JetBrains Mono', ui-monospace, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #1c1e21;
    --surface:   rgba(255, 255, 255, 0.06);
    --surface2:  #26292d;
    /* tile surface: how solid the card body is (100% = opaque), and an
       optional frosted blur behind it. Try values live with ?tune in the URL. */
    --tile-pct:      30%;
    --tile-backdrop: blur(1px);
    /* dashboard panels float over the busy map, so they stay mostly solid */
    --card-pct:      14%;
    --card-backdrop: blur(4px) brightness(.55) saturate(.8);
    /* surfaces float as whitish glass with white outlines */
    --glass:     rgba(255, 255, 255, 0.5);
    /* dashboard glass sits on a thin charcoal floor so light icons keep
       their contrast over bright parts of the map */
    --glass-floor: rgba(24, 26, 29, 0.45);
    --glass-flat:  rgba(50, 57, 61, 0.84);
    --line:      rgba(255, 255, 255, 0.85);
    --border:    #3a3e44;
    --border2:   #2e3136;
    --fg:        #eef0f3;
    --fg2:       #a9aeb7;
    --accent:    #ffffff;
    --accent-fg: #1c1e21;
    /* selection colour (ticks, "selected", chosen-tile border): the light
       theme's teal #0e5e6a, brightened to read on charcoal */
    --accent2:   #3fc4ad;
    --danger:    #ee6a4a;
    --danger-fg: #2a0b03;
    --warn:      #e8b04a;
    --measured:  #f0a04b;
    --map-bg:    #202226;
    --map-dot:   rgba(255, 255, 255, .08);
    --map-edge:  rgba(255, 255, 255, .22);
    --map-shade: rgba(0, 0, 0, .45);
    --scrim:     rgba(12, 13, 15, 0.66);
    --shadow:    0 1px 2px rgba(0, 0, 0, .30), 0 6px 18px rgba(0, 0, 0, .34);
    --shadow-lg: 0 2px 8px rgba(0, 0, 0, .38), 0 20px 48px rgba(0, 0, 0, .50);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg:        #1c1e21;
  --surface:   rgba(255, 255, 255, 0.06);
  --surface2:  #26292d;
  /* tile surface: how solid the card body is (100% = opaque), and an
     optional frosted blur behind it. Try values live with ?tune in the URL. */
  --tile-pct:      30%;
  --tile-backdrop: blur(1px);
  /* dashboard panels float over the busy map, so they stay mostly solid */
  --card-pct:      14%;
  --card-backdrop: blur(4px) brightness(.55) saturate(.8);
  /* surfaces float as whitish glass with white outlines */
  --glass:     rgba(255, 255, 255, 0.5);
  /* dashboard glass sits on a thin charcoal floor so light icons keep
     their contrast over bright parts of the map */
  --glass-floor: rgba(24, 26, 29, 0.45);
  --glass-flat:  rgba(50, 57, 61, 0.84);
  --line:      rgba(255, 255, 255, 0.85);
  --border:    #3a3e44;
  --border2:   #2e3136;
  --fg:        #eef0f3;
  --fg2:       #a9aeb7;
  --accent:    #ffffff;
  --accent-fg: #1c1e21;
  /* selection colour: the light theme's teal, brightened for charcoal */
  --accent2:   #3fc4ad;
  --danger:    #ee6a4a;
  --danger-fg: #2a0b03;
  --warn:      #e8b04a;
  --measured:  #f0a04b;
  --map-bg:    #202226;
  --map-dot:   rgba(255, 255, 255, .08);
  --map-edge:  rgba(255, 255, 255, .22);
  --map-shade: rgba(0, 0, 0, .45);
  --scrim:     rgba(12, 13, 15, 0.66);
  --shadow:    0 1px 2px rgba(0, 0, 0, .30), 0 6px 18px rgba(0, 0, 0, .34);
  --shadow-lg: 0 2px 8px rgba(0, 0, 0, .38), 0 20px 48px rgba(0, 0, 0, .50);
  color-scheme: dark;
}

[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--fg);
  font: 13px/1.35 var(--font);
  display: flex; flex-direction: column; overflow: hidden;
}

/* ── Authenticated app wrapper ────────────────────────────────
   Required because #map-wrap is now nested inside #app-root.
   This preserves the original flex layout after login.
*/
#app-root {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}

button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ── Map canvas layer stack ─────────────────────────────────── */
#map-wrap { --left-offset: 352px; position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: none;
  /* outside the data: a calm tone with a faint dot grid (app.js pans and scales it with the map) */
  background-color: var(--map-bg);
  background-image: radial-gradient(circle, var(--map-dot) 1px, transparent 1.4px);
  background-size: 24px 24px; }
#map-wrap canvas.layer { position: absolute; inset: 0; display: block; }
#cv-base { z-index: 1; }
#cv-cov  { z-index: 2; pointer-events: none; opacity: 0.9; }
#cv-ui   { z-index: 3; cursor: crosshair; }
#cv-ui.dragging { cursor: grabbing; }

/* ── Overlay columns ────────────────────────────────────────── */
.col { position: absolute; z-index: 10; top: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.col > * { pointer-events: auto; }

/* ── Left tool rail + expanding panel ───────────────────────── */
#leftdock {
  position: absolute; z-index: 10; left: 10px; top: 10px; bottom: 10px;
  display: flex; gap: 8px; align-items: flex-start;
  pointer-events: none; max-width: calc(100% - 20px);
}
#leftdock > * { pointer-events: auto; }
#toolrail {
  flex: none; display: flex; flex-direction: column; gap: 6px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); backdrop-filter: blur(10px); box-shadow: var(--shadow);
}
.rail-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  border: 0; border-radius: var(--r-sm); background: transparent;
  color: var(--fg2); cursor: pointer;
  transition: background-color .13s ease, color .13s ease;
}
.rail-btn:hover { background: var(--border2); color: var(--fg); }
.rail-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); }
.rail-btn svg { width: 19px; height: 19px; display: block; }
#toolpanels {
  flex: none; width: var(--tp-w, 272px); max-height: 100%; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
}
#right { right: 10px; width: min(540px, 46vw); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 11px 13px; backdrop-filter: blur(10px); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; flex: none; }
.card > * { flex: none; }
h2, h3 { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--fg2); }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ctrl { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.ctrl label { font-size: 10px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: var(--fg2); }
input[type=number] {
  width: 100%; padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface2); color: var(--fg); font: 12px var(--mono); font-variant-numeric: tabular-nums;
}
input[type=number]:focus { border-color: var(--accent); }
.btn { flex: 1; padding: 6px 8px; border: 0; border-radius: var(--r-sm); cursor: pointer; font: 500 12px var(--font); background: var(--border); color: var(--fg); }
.btn { transition: background-color .13s ease, border-color .13s ease, color .13s ease; }
.btn:hover { background: color-mix(in srgb, var(--border) 62%, var(--fg) 14%); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 86%, var(--fg)); }
.btn.danger:hover  { background: color-mix(in srgb, var(--danger) 86%, var(--fg)); }
.btn:disabled, .btn[disabled] { opacity: .42; cursor: not-allowed; }
.btn:disabled:hover { background: var(--border); }
.btn.primary { background: var(--accent); color: var(--accent-fg); }
.btn.danger { background: var(--danger); color: var(--danger-fg); }
.hint { margin: 0; font-size: 11px; color: var(--fg2); }
.hint b { color: var(--accent); font-weight: 600; }

/* ── Segmented controls & checkboxes ────────────────────────── */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg button { font: 500 11px var(--font); color: var(--fg2); background: transparent; border: 0; padding: 5px 9px; cursor: pointer; transition: background-color .13s ease, color .13s ease; }
.seg button:hover:not([aria-pressed="true"]) { background: var(--border2); color: var(--fg); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); }
.check { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--fg2); cursor: pointer; }
.check input { accent-color: var(--accent); margin: 0; }

/* ── Legend ─────────────────────────────────────────────────── */
.sw { width: 13px; height: 9px; border-radius: 2px; flex: none; border: 1px solid rgba(0,0,0,.15); }
#cbar { height: 8px; border-radius: 999px; }
.cbar-lab { display: flex; justify-content: space-between; font: 10px var(--mono); color: var(--fg2); }

/* ── Readout card ───────────────────────────────────────────── */
#readout .depth { font: 600 30px/1 var(--font); }
#readout .depth small { font-size: 13px; font-weight: 500; color: var(--fg2); margin-left: 4px; }
#readout .where { font-size: 11px; color: var(--fg2); }
#readout .srcline { display: flex; align-items: center; gap: 7px; font-size: 12px; }
#readout .coastline { font-size: 12px; color: var(--fg2); }
#readout .coastline b { font-size: 15px; color: var(--fg); }

/* ── Side-view panels ───────────────────────────────────────── */
#sv-panel { gap: 5px; }
#sv-panel canvas { display: block; width: 100%; border-radius: 5px; background: var(--plot-bg); }
#sv-cross { height: clamp(140px, 24vh, 230px); }
#sv-prof  { height: clamp(110px, 19vh, 180px); cursor: ew-resize; touch-action: none; }
.lab { font: 11px var(--mono); color: var(--fg2); font-variant-numeric: tabular-nums; min-height: 15px; }
#coastcard { gap: 5px; }
#coastcard canvas { display: block; width: 100%; border-radius: 5px; background: var(--plot-bg); }
#sv-coast { height: 150px; }

/* ── 3D panel ───────────────────────────────────────────────── */
#v3d { position: absolute; z-index: 12; left: var(--left-offset); right: calc(min(540px, 46vw) + 20px); bottom: 10px; height: 46%; min-height: 230px; padding: 8px 10px; gap: 6px; }
#v3d.big { top: 10px; height: auto; }
#v3d .head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#v3d .head h3 { margin-right: auto; }
#v3d .mini { display: flex; align-items: center; gap: 4px; font-size: 10px; color: var(--fg2); text-transform: uppercase; letter-spacing: .04em; }
#v3d .mini input { width: 64px; padding: 3px 5px; }
#v3d .head { gap: 6px; }
#v3d .seg button { padding: 4px 8px; }
#v3d .btn.sm { flex: none; padding: 4px 9px; font-size: 11px; }
#cv-3d { flex: 1 1 0 !important; min-height: 0; width: 100%; display: block; border-radius: 5px; background: var(--plot-bg); cursor: grab; touch-action: none; }
#cv-3d:active { cursor: grabbing; }

/* ── Stats bar ──────────────────────────────────────────────── */
#stats { flex: none; display: flex; flex-wrap: wrap; background: var(--surface2); border-top: 1px solid var(--border); }
.stat { flex: 1 1 108px; padding: 6px 12px; border-right: 1px solid var(--border); min-width: 0; }
.stat:last-child { border-right: 0; }
.stat-label { font-size: 9px; letter-spacing: .06em; text-transform: uppercase; color: var(--fg2); white-space: nowrap; }
.stat-val { font: 500 13px var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-val.warn { color: var(--warn); }
.stat-val.danger { color: var(--danger); }

/* ── Loading overlay ────────────────────────────────────────── */
#loading { position: absolute; inset: 0; z-index: 70; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: var(--bg); color: var(--fg2); text-align: center; padding: 24px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* ── Region data drawer ─────────────────────────────────────── */
#drawer { position: absolute; inset: 0; z-index: 25; display: flex; align-items: center; justify-content: center; background: var(--scrim); padding: 16px; }
.drawer-card { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); width: min(860px, 100%); max-height: 100%; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 16px; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.drawer-head .btn { flex: none; }
.drawer-card section { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.drawer-card h3 { font-size: 13px; color: var(--fg); letter-spacing: .02em; text-transform: none; }
.drawer-card p { margin: 0; font-size: 12.5px; color: var(--fg2); max-width: 80ch; }
.drawer-card a { color: var(--accent); }
.tablewrap { overflow-x: auto; border-top: 1px solid var(--border); }
table { border-collapse: collapse; width: 100%; min-width: 440px; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 9px; text-align: right; border-bottom: 1px solid var(--border); vertical-align: top; }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
th { font-weight: 500; color: var(--fg2); font-size: 11px; white-space: nowrap; }
td .v { display: block; font-weight: 600; font-size: 14px; }
td .r { display: block; color: var(--fg2); font-size: 11px; white-space: nowrap; }
td.na .v { color: var(--fg2); font-weight: 500; }
td.pct { background: color-mix(in srgb, var(--measured) calc(var(--p) * 0.42%), transparent); }
td.rowname { font-weight: 500; white-space: nowrap; }
.foot { font-size: 12px; }
ul.notes { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--fg2); display: flex; flex-direction: column; gap: 4px; }

/* ── Responsive breakpoints ─────────────────────────────────── */
@media (max-width: 900px) { #right { width: 330px; } #v3d, #legend-dock { right: 350px; } }
@media (max-width: 640px) { #toolpanels { --tp-w: 196px; } #right { width: 260px; } #v3d, #legend-dock { right: 280px; } }

/* ── Setup screen ───────────────────────────────────────────── */
.btn.sm { flex: none; padding: 4px 9px; font-size: 11px; }
#setup { position: absolute; inset: 0; z-index: 60; background: var(--bg); overflow-y: auto; display: flex; justify-content: center; align-items: flex-start; padding: 28px 16px; }
.setup-card { width: min(880px, 100%); display: flex; flex-direction: column; gap: 18px; }
.setup-card h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.setup-card .sub { margin: 4px 0 0; color: var(--fg2); font-size: 13px; }
.setup-card section { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.setup-card label.lbl { font-size: 11px; color: var(--fg2); text-transform: uppercase; letter-spacing: .05em; display: block; margin-bottom: 3px; }
.setup-card input[type=text] { width: 100%; }
.drop { display: block; border: 1.5px dashed var(--border); border-radius: 8px; padding: 16px; text-align: center; cursor: pointer; color: var(--fg2); }
.drop b { color: var(--fg); }
.drop.over, .drop:hover { border-color: var(--accent); }
.drop span { font-size: 12px; }
.files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.files li.ok::before { content: "✓ "; color: var(--accent2); }
.files li.bad::before { content: "✕ "; color: var(--danger); }
.files li.bad { color: var(--danger); }
.params { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 640px) { .params { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.params input { width: 100%; }
.setup-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.err { color: var(--danger); font-size: 12.5px; margin: 0; min-height: 16px; }
select.sel { width: 100%; padding: 5px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface2); color: var(--fg); font: 12px var(--font); }

/* ── Mission panel ──────────────────────────────────────────── */
#mission .seg { display: flex; } #mission .seg button { flex: 1; }
#ms-body { display: flex; flex-direction: column; gap: 8px; }
/* Mission summary: header fixed, body scrolls vertically only. Headline
   tiles, then folding sections; patterns are a list, not a wide table. */
#ms-summary {
  position: absolute; z-index: 11; left: var(--left-offset); top: 10px;
  width: 320px; max-height: min(60%, 520px); overflow: hidden;
}
#ms-summary:not(.collapsed) { padding-right: 8px; }
#ms-summary .card-head { padding-right: 8px; }
#ms-sbody {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 10px; padding-right: 6px;
  scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--fg) 22%, transparent) transparent;
}
#ms-sbody::-webkit-scrollbar { width: 6px; }
#ms-sbody::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--fg) 22%, transparent); border-radius: 99px; }
#ms-sbody.more { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
                         mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent); }
#ms-res { display: flex; flex-direction: column; gap: 10px; font-size: 11.5px; min-width: 0; }
#ms-cmp { display: flex; flex-direction: column; gap: 6px; }
#ms-cmp:empty { display: none; }

#ms-res .tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#ms-res .ms-tile { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 7px 9px; min-width: 0; }
#ms-res .tl { font-size: 9.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--fg2); }
#ms-res .tv { font: 600 14px var(--mono); color: var(--accent2); overflow-wrap: anywhere; }
#ms-res .ts { font: 10px var(--mono); color: var(--fg2); overflow-wrap: anywhere; }

/* folding sections */
.ms-sec { border-top: 1px solid var(--border); padding-top: 8px; }
.ms-sec > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
  font: 600 10px var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--fg2);
}
.ms-sec > summary::-webkit-details-marker { display: none; }
.ms-sec > summary::after {
  content: ""; width: 7px; height: 7px; margin-right: 3px; border: solid currentColor; border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg) translateY(-2px); transition: transform .18s ease;
}
.ms-sec[open] > summary::after { transform: rotate(-135deg) translateY(-1px); }
.ms-sec > summary:hover { color: var(--fg); }
.ms-sec > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.ms-rows { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, auto); gap: 3px 10px; margin-top: 7px; align-items: baseline; }
#ms-res .k { color: var(--fg2); min-width: 0; }
#ms-res .v { font: 11.5px var(--mono); text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; min-width: 0; }
#ms-res .big .k { color: var(--fg); font-weight: 600; } #ms-res .big .v { font-size: 13px; color: var(--accent2); }
#ms-res .ms-rows:has(.ms-pat) { display: flex; flex-direction: column; gap: 5px; }

/* compare patterns: one tappable row each */
.ms-pat {
  display: flex; flex-direction: column; gap: 2px; width: 100%; min-width: 0; text-align: left;
  padding: 7px 10px; border-radius: 10px; cursor: pointer; font: inherit; color: var(--fg);
  border: 1px solid var(--border); background: color-mix(in srgb, var(--surface2) 55%, transparent);
  transition: border-color .13s ease, background-color .13s ease;
}
.ms-pat:hover { border-color: color-mix(in srgb, var(--accent2) 55%, var(--border)); }
.ms-pat.pick { border-color: var(--accent2); background: color-mix(in srgb, var(--accent2) 12%, transparent); }
.ms-pat:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mp-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.mp-name { font: 600 12px var(--font); }
.mp-cov { font: 600 12px var(--mono); color: var(--accent2); }
.mp-sub { font: 10.5px var(--mono); color: var(--fg2); overflow-wrap: anywhere; }

.ms-warn {
  color: var(--warn); font-size: 11px; line-height: 1.4; padding: 7px 9px; border-radius: 9px;
  background: color-mix(in srgb, var(--warn) 10%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
}
@media (max-width: 640px) { #ms-summary { width: 260px; } }

/* ════════════════════════════════════════════════════════════
   AUTH OVERLAY  (login / register / verify screens)
   ════════════════════════════════════════════════════════════ */
#auth-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  overflow-y: auto;
}
/* Auto margins centre the form when it fits and let it start at the top (and
   scroll) when it does not. Plain flex centring would clip the top of a tall
   form such as Create account, where the logo sits. */
.auth-screen { margin: auto; width: 100%; max-width: 420px; }
.auth-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 2rem 2.25rem;
  width: 100%; max-width: 420px;
  display: flex; flex-direction: column; gap: 0;
}
.auth-box h1 {
  font-size: 1.25rem; font-weight: 600; margin: 0 0 1.5rem;
  color: var(--accent); letter-spacing: -.01em; text-transform: none;
  text-align: center;
}
.auth-box .auth-label {
  font-size: 10px; font-weight: 500; letter-spacing: .05em;
  text-transform: uppercase; color: var(--fg2);
  display: block; margin-bottom: 4px; margin-top: 12px;
}
/* no gap above the first field under the heading; every other label keeps its gap */
.auth-box > .auth-error + .auth-label, .auth-box > .auth-error + .auth-row .auth-label { margin-top: 0; }
.auth-box .auth-row { display: flex; gap: 10px; }
.auth-box .auth-row > div { flex: 1; }
.auth-input {
  width: 100%; box-sizing: border-box;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  color: var(--fg); padding: 7px 10px; font: 13px var(--font);
  margin-bottom: 0;
}
.auth-input:focus { outline: none; border-color: var(--accent); }
.auth-btn {
  width: 100%; padding: 9px; border: 0; border-radius: 7px;
  background: var(--accent); color: var(--accent-fg);
  font: 600 13px var(--font);
  cursor: pointer; margin-top: 18px;
}
.auth-btn { transition: background-color .13s ease; }
.auth-btn:hover { background: color-mix(in srgb, var(--accent) 86%, var(--fg)); }
.auth-btn.secondary:hover { background: color-mix(in srgb, var(--border) 62%, var(--fg) 14%); }
.auth-btn:disabled { opacity: .45; cursor: not-allowed; }
.auth-btn.secondary {
  background: var(--border); color: var(--fg); margin-top: 8px;
}
.auth-error {
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  border: 1px solid var(--danger); border-radius: 6px;
  color: var(--danger); font-size: 12px; padding: 8px 10px;
  margin-top: 12px; margin-bottom: 0;
  display: none;
}
.auth-error.visible { display: block; }
.auth-info {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid var(--accent); border-radius: 8px;
  color: var(--fg); font-size: 13px; padding: 14px 16px;
  line-height: 1.6; text-align: center; margin-top: 8px;
}
.auth-footer {
  margin-top: 16px; text-align: center;
  font-size: 12px; color: var(--fg2);
}
.auth-link {
  color: var(--accent); cursor: pointer; background: none; border: none;
  font-size: 12px; padding: 0; text-decoration: underline;
  font-family: inherit;
}
/* Forgot / reset password. [hidden] must win over display rules such as
   .auth-footer's flex on phones. */
#auth-overlay { --auth-ok: #1d7a43; }
:root[data-theme="dark"] #auth-overlay { --auth-ok: #5cc98a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #auth-overlay { --auth-ok: #5cc98a; } }
#auth-overlay [hidden] { display: none !important; }
.auth-box h1:focus { outline: none; }
.auth-forgot { display: flex; justify-content: flex-end; margin-top: 6px; }
.auth-hint {
  margin: 6px 0 0; font-size: 12px; line-height: 1.45; color: var(--fg2);
}
#forgot-hint { margin: 0 0 12px; }
#forgot-error { margin: 0 0 12px; }
.auth-note { text-align: left; overflow-wrap: anywhere; }
.auth-note:empty { display: none; }
#forgot-off { margin: 0 0 12px; }
#forgot-status { margin-top: 14px; }
.auth-ok {
  background: color-mix(in srgb, var(--auth-ok) 14%, transparent);
  border: 1px solid var(--auth-ok); border-radius: 6px;
  color: var(--fg); font-size: 12px; line-height: 1.5; padding: 8px 10px;
  margin: 0 0 12px;
}
.auth-ok:empty { display: none; }
.auth-req {
  margin-top: 6px; font-size: 12px; line-height: 1.45; color: var(--fg2); text-align: left;
}

/* ── Top bar (every screen after sign-in) ───────────────────── */
#topbar {
  flex: none; display: flex; align-items: center; gap: 14px;
  padding: 0 14px; height: 46px;
  background: var(--surface2); border-bottom: 1px solid var(--border);
  position: relative; z-index: 80;   /* above #setup (60) so Sign out is always reachable */
}
.tb-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-app {
  font: 600 13px var(--font); color: var(--fg);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tb-mid { flex: 1; min-width: 0; text-align: center; }
#tb-region {
  font: 11.5px var(--mono); color: var(--fg2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: inline-block; max-width: 100%;
}
.tb-actions { display: flex; align-items: center; gap: 8px; flex: none; margin-left: auto; }
.tb-actions #user-email {
  font-size: 11.5px; color: var(--fg2);
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#btn-setup, #logout-btn {
  background: var(--border); color: var(--fg); border: 0;
  border-radius: var(--r-sm); padding: 5px 10px; font: 500 11.5px var(--font);
  cursor: pointer; transition: background-color .13s ease;
}
#btn-setup:hover, #logout-btn:hover { background: color-mix(in srgb, var(--border) 60%, var(--fg) 16%); }

@media (max-width: 860px) {
  .tb-brand .brand-rule, .tb-brand .tb-app { display: none; }
  .tb-mid { display: none; }
  .tb-actions #user-email { max-width: 120px; }
}

/* ── Data-usage consent modal ─────────────────────────────── */
#terms-modal {
  position: fixed; inset: 0; z-index: 9000; backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  background: var(--scrim); padding: 16px;
}
#terms-modal[hidden] { display: none; }
.terms-card {
  width: min(620px, 100%); max-height: 88vh; display: flex; flex-direction: column;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 22px 24px; box-shadow: var(--shadow-lg);
  font: 400 13px var(--font); color: var(--fg);
}
.terms-card h2 { margin: 0 0 12px; font-size: 18px; font-weight: 600; }
.terms-body {
  overflow-y: auto; padding-right: 6px; line-height: 1.5; color: var(--fg2);
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding-top: 10px; padding-bottom: 10px;
}
.terms-body h3 { margin: 14px 0 4px; font-size: 13px; font-weight: 600; color: var(--fg); }
.terms-body p { margin: 0 0 8px; }
.terms-body ul { margin: 0 0 8px; padding-left: 18px; }
.terms-body li { margin-bottom: 3px; }
.terms-version { font-size: 11px; opacity: .7; margin-top: 12px; }
.terms-check {
  display: flex; gap: 9px; align-items: flex-start;
  margin: 14px 0 4px; line-height: 1.45; cursor: pointer;
}
.terms-check input { margin-top: 2px; flex: none; }
.terms-actions { display: flex; gap: 10px; margin-top: 12px; }
.terms-actions .btn { padding: 9px 12px; font-size: 13px; }
.terms-actions .btn:disabled { opacity: .45; cursor: not-allowed; }
#terms-err { margin: 8px 0 0; }



/* ── Brand lockup ───────────────────────────────────────────── */
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
/* Logo: navy-to-teal wordmark on transparent. The navy would disappear on the
   dark theme, so there it is shown as a white silhouette. */
.auth-logo  { display: block; width: auto; height: 30px; margin: 0 auto 1.25rem; }
.setup-logo { display: block; width: auto; height: 22px; flex: none; }
.tb-logo    { display: block; width: auto; height: 17px; flex: none; }
:root[data-theme="dark"] .auth-logo,
:root[data-theme="dark"] .setup-logo,
:root[data-theme="dark"] .tb-logo { filter: brightness(0) invert(1); }
.brand-rule { flex: none; width: 20px; height: 1px; background: var(--border); }
.brand-sub {
  font: 500 10.5px/1 var(--font);
  letter-spacing: .1em; text-transform: uppercase; color: var(--fg2); white-space: nowrap;
}
.setup-card .brand { margin-bottom: 10px; }

/* ── Theme switch: a sun / moon slider, as tall as its neighbours ── */
#theme-btn {
  position: relative; flex: none; width: 52px; height: 26px; padding: 0; margin: 0;
  border: 0; border-radius: 999px; cursor: pointer; background: var(--border);
  transition: background-color .2s ease;
}
#theme-btn:hover { background: color-mix(in srgb, var(--border) 60%, var(--fg) 16%); }
#theme-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#theme-btn .ts-knob {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface2); box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .22s cubic-bezier(.3, .7, .4, 1);
}
#theme-btn svg {
  position: absolute; top: 6px; width: 14px; height: 14px; pointer-events: none;
  color: var(--fg2); transition: color .2s ease;
}
#theme-btn .ts-sun { left: 6px; color: #d48a06; }
#theme-btn .ts-moon { right: 6px; }
#theme-btn[aria-checked="true"] .ts-knob { transform: translateX(26px); background: #ffffff; }
#theme-btn[aria-checked="true"] .ts-sun { color: var(--fg2); }
#theme-btn[aria-checked="true"] .ts-moon { color: #1c1e21; }


/* ── Survey-data tiles ──────────────────────────────────────────
   Upload tile first, then the sample regions. Card style follows
   selected.site: big outer radius, the image inset by a small gutter with a
   matching inner radius, a label row with an arrow, then a bold title.
   The region detail appears over the image on hover; devices without hover
   get it permanently, otherwise it would be unreachable there. */
.tile-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 880px) { .tile-grid { grid-template-columns: repeat(2, 1fr); } }


.tile {
  --tile-r: 20px; --tile-gap: 6px;
  position: relative; display: flex; flex-direction: column; min-width: 0;
  padding: var(--tile-gap); margin: 0;
  background: color-mix(in srgb, var(--glass) var(--tile-pct), transparent);
  -webkit-backdrop-filter: var(--tile-backdrop); backdrop-filter: var(--tile-backdrop);
  color: inherit; font: inherit; text-align: left;
  border: 1px solid var(--line); border-radius: var(--tile-r);
  box-shadow: var(--shadow); cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.tile:hover:not(:disabled) { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* the inset image: inner radius = outer radius - gutter, so the curves nest */
.tile-thumb {
  position: relative; display: grid; place-items: center;
  aspect-ratio: 1 / 1; overflow: hidden;
  border-radius: calc(var(--tile-r) - var(--tile-gap));
  background: var(--bg);
}
.tile-thumb img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block;
  transition: transform .45s cubic-bezier(.2, .7, .2, 1);
}
.tile:hover .tile-thumb img { transform: scale(1.06); }

.tile-body { display: flex; flex-direction: column; gap: 7px; padding: 11px 8px 7px; }
.tile-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font: 500 11px/1 var(--font); color: var(--fg2);
}
.tile-arrow { font-size: 13px; line-height: 1; transition: transform .2s ease, color .2s ease; }
.tile:hover .tile-arrow { transform: translate(2px, -2px); color: var(--accent); }
.tile-upload:hover .tile-arrow { transform: translateY(-2px); }
.tile-name {
  font: 700 17px/1.15 var(--font); letter-spacing: -.025em; color: var(--fg);
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* Detail over the image on hover — a gradient from the bottom, text left */
.tile-info {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  justify-content: flex-end; align-items: flex-start; gap: 3px;
  padding: 12px; text-align: left;
  font: 500 11.5px/1.35 var(--font); color: #fff;
  background: linear-gradient(to top, rgba(0, 12, 34, .88) 0%, rgba(0, 12, 34, .55) 45%, rgba(0, 12, 34, 0) 75%);
  opacity: 0; transition: opacity .2s ease;
}
.tile-bounds { font: 10.5px var(--mono); opacity: .85; font-variant-numeric: tabular-nums; }
.tile:hover .tile-info, .tile:focus-visible .tile-info { opacity: 1; }

/* Selected sample */
.tile.loaded { border-color: var(--accent2); box-shadow: 0 0 0 1px var(--accent2), var(--shadow); }
.tile.loaded .tile-name::after { content: "\00a0\2713"; color: var(--accent2); }
.tile.loaded .tile-meta > span:first-child::after { content: " \00b7  selected"; color: var(--accent2); }
.tile.loading { opacity: .6; cursor: progress; }
.tile:disabled, .tile.unavailable { opacity: .5; cursor: not-allowed; }
.tile.unavailable .tile-thumb::after {
  content: "Not added yet"; position: absolute; inset: auto 0 10px 0;
  font: 500 11px var(--font); color: #fff; text-align: center;
}

/* Upload tile: a dashed well inside the same card frame */
.tile-upload .tile-thumb {
  background: color-mix(in srgb, var(--accent) 5%, var(--bg));
  outline: 1.5px dashed color-mix(in srgb, var(--fg2) 45%, transparent);
  outline-offset: -8px;
}
.tile-plus {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface2); box-shadow: var(--shadow);
  font: 300 30px/1 var(--font); color: var(--fg);
  transition: transform .2s ease, background-color .2s ease, color .2s ease;
}
.tile-upload:hover .tile-plus { transform: scale(1.08); background: var(--accent); color: var(--accent-fg); }
.tile-upload .tile-info {
  justify-content: center; align-items: center; text-align: center;
  background: color-mix(in srgb, #00153b 90%, transparent);
  font-size: 11px; gap: 2px;
}
.tile-info b { font-family: var(--mono); font-weight: 600; font-size: 10.5px; }
.tile-info-sub { margin-top: 6px; opacity: .8; font-size: 10px; }
.tile-upload.dragover { border-color: var(--accent); }
.tile-upload.dragover .tile-thumb { outline-color: var(--accent); }
.tile-summary {
  display: none; padding: 14px; text-align: center;
  font: 10.5px/1.55 var(--mono); color: var(--fg2); word-break: break-all; white-space: pre-line;
}
.tile-upload.has-files .tile-plus { display: none; }
.tile-upload.has-files .tile-summary { display: block; }
.tile-upload.has-files { border-color: var(--accent2); box-shadow: 0 0 0 1px var(--accent2), var(--shadow); }

/* No hover (touch): keep the sample detail visible as the bottom gradient,
   and show the upload formats as a strip so the + stays visible */
@media (hover: none) {
  .tile-info { opacity: 1; }
  /* one compact line of extensions under the +, not the full list */
  .tile-upload .tile-info {
    inset: auto 0 0 0; padding: 22px 8px 9px; font-size: 10px;
    flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 2px 6px;
    background: linear-gradient(to top, rgba(0, 12, 34, .9), rgba(0, 12, 34, 0));
  }
  .tile-upload .fmt { font-size: 0; }
  .tile-upload .fmt b { font-size: 10px; }
  .tile-upload .tile-info-sub { flex-basis: 100%; margin-top: 2px; text-align: center; }
}

/* Clear button on the upload tile (rule 6). It sits in a wrapper beside the
   tile, so the lift moves to the wrapper; otherwise hovering the × would
   un-hover the tile and make it jump. */
.tile-wrap { position: relative; display: flex; min-width: 0; transition: transform .2s ease; }
.tile-wrap > .tile { flex: 1; }
.tile-wrap > .tile:hover:not(:disabled) { transform: none; }
.tile-wrap:hover { transform: translateY(-3px); }
.tile-clear {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  width: 26px; height: 26px; border-radius: 50%; border: 0; padding: 0;
  display: grid; place-items: center; cursor: pointer;
  background: var(--surface2); color: var(--fg); box-shadow: var(--shadow);
  font: 400 17px/1 var(--font); transition: background-color .15s ease, color .15s ease;
}
.tile-clear[hidden] { display: none; }
.tile-clear:hover { background: var(--danger); color: var(--danger-fg); }
.tile-summary { text-align: left; }


/* ── Alert strip at the top of a setup pane ─────────────────── */
.setup-alert {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--warn); border-radius: var(--r);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  font-size: 12.5px; color: var(--fg); line-height: 1.45;
}
.setup-alert[hidden] { display: none; }
.setup-alert-icon {
  flex: none; width: 18px; height: 18px; border-radius: 50%; margin-top: 1px;
  display: grid; place-items: center;
  background: var(--warn); color: var(--bg); font: 700 12px var(--font);
}
.setup-alert-x {
  flex: none; margin-left: auto; border: 0; background: transparent; cursor: pointer;
  color: var(--fg2); font: 400 17px/1 var(--font); padding: 0 2px;
}
.setup-alert-x:hover { color: var(--fg); }


/* ── Collapsible card header ────────────────────────────────── */
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; flex-wrap: nowrap;
}
.card-head > :first-child {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-min {
  flex: none; width: 22px; height: 22px; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: transparent; color: var(--fg2);
  font: 600 14px/1 var(--font); cursor: pointer; padding: 0;
  transition: background-color .13s ease, color .13s ease, border-color .13s ease;
}
.card-min:hover { background: var(--border2); color: var(--fg); border-color: var(--accent); }
/* Collapsed: only the header survives */
.card.collapsed > :not(.card-head) { display: none !important; }


/* ── Setup tabs ─────────────────────────────────────────────── */
.setup-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); }
.setup-tab {
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  padding: 9px 14px; margin-bottom: -1px;
  font: 500 13px var(--font); color: var(--fg2); cursor: pointer; white-space: nowrap;
  transition: color .13s ease, border-color .13s ease;
}
.setup-tab:hover { color: var(--fg); }
.setup-tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.setup-pane { display: flex; flex-direction: column; gap: 18px; }
.setup-pane[hidden] { display: none; }
.setup-foot { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--border); padding-top: 14px; }
.setup-foot .setup-actions { margin: 0; }
/* Round → "Next" button (Survey data step): glass with a teal ring, centred
   just above the footer line. It sits in the footer box but is drawn above
   it, so the footer keeps its own layout. */
.setup-foot { position: relative; }
/* room for it: padding on whatever comes just before the footer, so the
   footer keeps its own margins (on phones it is pinned to the bottom) */
.setup-card > :has(+ .setup-foot > .setup-next:not([hidden])) { padding-bottom: 88px; }
.setup-next {
  position: absolute; left: 50%; bottom: calc(100% + 12px); transform: translateX(-50%);
  width: 56px; height: 56px; padding: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  color: var(--accent2); background: var(--glass);
  border: 1.5px solid var(--accent2);
  box-shadow: 0 4px 18px color-mix(in srgb, var(--accent2) 28%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4);
  transition: transform .15s, box-shadow .15s, opacity .15s;
}
.setup-next[hidden] { display: none; }
.setup-next svg { width: 24px; height: 24px; transition: transform .15s; }
.setup-next:not(:disabled):hover { box-shadow: 0 6px 24px color-mix(in srgb, var(--accent2) 40%, transparent); }
.setup-next:not(:disabled):hover svg { transform: translateX(2px); }
.setup-next:not(:disabled):active { transform: translateX(-50%) scale(.95); }
.setup-next:focus-visible { outline: 2px solid var(--accent2); outline-offset: 3px; }
.setup-next:disabled { opacity: .38; cursor: default; box-shadow: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .setup-next { background: rgba(255, 255, 255, .07); } }
:root[data-theme="dark"] .setup-next { background: rgba(255, 255, 255, .07); }
@media (prefers-reduced-motion: reduce) { .setup-next, .setup-next svg { transition: none; } }
/* Desktop (everything except the phone layout of mobile-setup.css, where the
   footer itself is pinned and the button floats above it): the button stays
   at the bottom of the window while the tiles scroll under it, and rests just
   above the footer line at the end of the page. Pure CSS: the footer box is
   dissolved (display: contents) so the button becomes an in-flow child of the
   card and can be position: sticky against the scrolling #setup; the footer
   line moves onto the error line, which is now the first footer row. */
@media not ((max-width: 640px) or ((pointer: coarse) and (orientation: portrait) and (max-width: 1100px)) or ((pointer: coarse) and (orientation: landscape) and (max-height: 500px)) or ((max-width: 950px) and (orientation: landscape) and (max-height: 500px))) {
  .setup-card > .setup-foot { display: contents; }
  .setup-foot > .err { border-top: 1px solid var(--border); padding-top: 14px; }
  .setup-foot > .setup-actions { margin-top: -10px; }        /* card gap 18 → footer gap 8 */
  .setup-foot > .setup-next {
    position: sticky; bottom: 0; z-index: 5;               /* + #setup padding (28 px) from the window edge */
    left: auto; transform: none; align-self: center;
    margin: 0 0 -6px;                                           /* 12 px above the footer line, as before */
  }
  .setup-foot > .setup-next:not(:disabled):active { transform: scale(.95); }
}
/* .btn is flex:1 for the dashboard toolbar; here buttons size to content */
.setup-foot .setup-actions .btn { flex: 0 0 auto; padding: 9px 20px; font-size: 13px; }

/* ── Echosounder cards ──────────────────────────────────────────
   Same tile design as the Survey data step (see .tile): product photo in
   the inset frame, label row, bold name. The pencil floats on the photo. */
.sonar-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 880px) { .sonar-grid { grid-template-columns: repeat(2, 1fr); } }

/* product shots are on white, so the frame is white in both themes */
.sonar-card .tile-thumb.photo { background: #fff; }
.sonar-card[aria-pressed="true"] { border-color: var(--accent2); box-shadow: 0 0 0 1px var(--accent2), var(--shadow); }
.sonar-card[aria-pressed="true"] .tile-name::after { content: "\00a0\2713"; color: var(--accent2); }
.sonar-card[aria-pressed="true"] .tile-meta > span:first-child::after { content: " \00b7  selected"; color: var(--accent2); }
.sonar-edit {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  width: 30px; height: 30px; border-radius: 50%; border: 0; padding: 0;
  display: grid; place-items: center; cursor: pointer;
  background: var(--surface2); color: var(--fg); box-shadow: var(--shadow);
  transition: background-color .15s ease, color .15s ease, transform .15s ease;
}
.sonar-edit:hover { background: var(--accent); color: var(--accent-fg); transform: scale(1.08); }
.sonar-edit svg { width: 14px; height: 14px; display: block; }
.tile-specs { font: 10.5px var(--mono); opacity: .9; }


/* ── Wireframe-sea background (sign-in and setup screens) ──────────
   A still image rendered once offline, in the style of elektrokid.be:
   no script, no WebGL, nothing running. The browser downloads only the
   image for the active theme (~65 KB light, ~105 KB dark). Its top edge
   is exactly --bg, so it melts into the page colour above the horizon.
   If --bg ever changes, re-render the images to match. */
#auth-overlay, #setup {
  background: var(--bg) url("../assets/bg/waves-light.webp") center bottom / cover no-repeat;
}
:root[data-theme="dark"] #auth-overlay,
:root[data-theme="dark"] #setup { background-image: url("../assets/bg/waves-dark.webp"); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #auth-overlay,
  :root:not([data-theme="light"]) #setup { background-image: url("../assets/bg/waves-dark.webp"); }
}

/* ── Tile steps sit straight on the background ─────────────────
   The section wrapping the tiles on Survey data and Echosounder has no
   fill, border or padding, so the tiles float on the sea. Parameters
   keeps its cards: form fields need a solid surface behind them. */
.setup-pane[data-tab="data"] > section,
.setup-pane[data-tab="sonar"] > section {
  background: transparent; border-color: transparent; box-shadow: none; padding: 0;
}

/* Region name: a slim pill beside Open dashboard */
.setup-foot .setup-actions { gap: 10px; }
.region-field {
  display: flex; align-items: center; gap: 8px; flex: 0 1 300px; min-width: 0;
  height: 38px; padding: 0 14px; cursor: text;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 999px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.region-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.region-field > span {
  flex: none; font: 600 10.5px var(--font); letter-spacing: .06em;
  text-transform: uppercase; color: var(--fg2);
}
.setup-card .region-field input {
  flex: 1; min-width: 0; width: auto; height: 100%; padding: 0;
  border: 0; outline: 0; background: transparent;
  font: 13px var(--font); color: var(--fg);
}
.setup-card .region-field input::placeholder { color: var(--fg2); opacity: .7; }
@media (max-width: 520px) { .region-field { flex-basis: 100%; } }

/* Phones: two tiles per row rather than one huge tile per screen, and no
   email in the top bar, where it ran into the logo. */
@media (max-width: 520px) {
  .tile-grid, .sonar-grid { gap: 10px; }
  .tile { --tile-r: 16px; --tile-gap: 5px; }
  .tile-name { font-size: 14.5px; }
  .tb-actions #user-email { display: none; }
}

/* ── Echosounder editor ─────────────────────────────────────────
   Normal: model cards in a 4-column grid. Editing: only the card being
   edited stays, in the first column, and the editor fills the rest. The
   move itself is animated in app.js (sonarLayout). */
.sonar-editor {
  display: none; flex-direction: column; gap: 14px; min-width: 0;
  padding: 16px 18px 14px;
  background: color-mix(in srgb, var(--glass) var(--tile-pct), transparent);
  -webkit-backdrop-filter: var(--tile-backdrop); backdrop-filter: var(--tile-backdrop);
  border: 1px solid var(--line);
  border-radius: 20px; box-shadow: var(--shadow);
}
.sonar-grid.editing { grid-template-columns: minmax(190px, 1fr) minmax(0, 3fr); align-items: start; }
.sonar-grid.editing > .sonar-card:not(.active) { display: none; }
.sonar-grid.editing > .sonar-editor { display: flex; }
.sonar-grid.editing > .sonar-card.active { cursor: default; }
.sonar-grid.editing > .sonar-card.active:hover { transform: none; }
.sonar-grid.editing > .sonar-card.active .sonar-edit { display: none; }

.se-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.se-title { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.se-kind { font: 500 11px var(--font); color: var(--fg2); }
.setup-card .se-name {
  width: 100%; padding: 2px 0; border: 0; border-bottom: 1px dashed var(--border);
  background: transparent; color: var(--fg); outline: 0;
  font: 700 19px/1.2 var(--font); letter-spacing: -.02em;
}
.setup-card .se-name:focus { border-bottom-color: var(--accent); }
.setup-card .se-name[readonly] { border-bottom-color: transparent; }
.se-close {
  flex: none; width: 30px; height: 30px; border-radius: 50%; border: 0; padding: 0;
  display: grid; place-items: center; cursor: pointer;
  background: var(--bg); color: var(--fg); font: 400 18px/1 var(--font);
  transition: background-color .15s ease, color .15s ease;
}
.se-close:hover { background: var(--border); }
.se-params { gap: 12px 14px; }
.se-foot { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--border2); padding-top: 12px; }
.se-foot #se-done { margin-left: auto; padding: 7px 18px; }
.se-foot [hidden] { display: none; }

@media (max-width: 720px) {
  .sonar-grid.editing { grid-template-columns: 1fr; }
  .sonar-grid.editing > .sonar-card.active { max-width: 240px; }
}

/* Generic thumbnail for custom models (inline SVG). It is a picture, like
   the photo on the built-in model, so it keeps the light-theme colours in
   both themes instead of inverting. */
.tile-thumb.generic {
  --sg-bg: #f7f8fa; --sg-ink: #00153b; --sg-ink2: #5b6478; --sg-accent: #0e5e6a;
  background: linear-gradient(180deg, color-mix(in srgb, var(--sg-accent) 4%, var(--sg-bg)) 0%,
                                       color-mix(in srgb, var(--sg-accent) 14%, var(--sg-bg)) 100%);
}
.sonar-generic { position: absolute; inset: 8%; width: 84%; height: 84%; color: var(--sg-accent);
  transition: transform .45s cubic-bezier(.2, .7, .2, 1); }
.tile:hover .sonar-generic { transform: scale(1.06); }
.sonar-generic .sg-rays line { stroke: var(--sg-accent); stroke-opacity: .45; stroke-width: 1.6; }
.sonar-generic .sg-bed { fill: none; stroke: var(--sg-ink2); stroke-width: 2.5; stroke-dasharray: 2 6; stroke-linecap: round; }
.sonar-generic .sg-cable { fill: none; stroke: var(--sg-ink); stroke-width: 5; stroke-linecap: round; opacity: .85; }
.sonar-generic .sg-body { fill: var(--sg-ink); }
.sonar-generic .sg-plate { fill: color-mix(in srgb, var(--sg-ink) 72%, var(--sg-bg)); }
.sonar-generic .sg-led { fill: var(--sg-accent); }

/* ── Optional settings beside Open dashboard ───────────────────── */
.setup-foot .setup-actions { flex-wrap: wrap; align-items: center; }
.opt-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: 1 1 auto; min-width: 0; }
.opt-chip {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 999px;
  font: 500 12.5px var(--font); color: var(--fg); cursor: pointer; white-space: nowrap;
  transition: border-color .15s ease;
}
.opt-chip:hover { border-color: var(--accent); }
.opt-chip input[type=checkbox] { margin: 0; accent-color: var(--accent); }
.opt-chip em { font-style: normal; font-size: 11px; color: var(--fg2); }
.opt-chip.on { border-color: var(--accent2); }
.setup-foot #btn-open { margin-left: auto; }
@media (max-width: 720px) { .setup-foot #btn-open { margin-left: 0; } }

/* ── ⓘ info buttons and their popover ──────────────────────────
   Instructions that used to sit on screen live behind these. One shared
   popover (built in app.js) shows the text: hover with a mouse, tap on
   touch, focus with the keyboard. */
.info {
  position: relative; display: inline-block; flex: none;
  width: 16px; height: 16px; margin: 0 0 0 5px; padding: 0; border-radius: 50%;
  /* A button lines up by the text inside it, which is centred in the
     circle; with the surrounding font inherited, baseline alignment puts the
     circle on the middle of the letters beside it. */
  overflow: hidden; vertical-align: baseline;
  border: 1px solid color-mix(in srgb, var(--fg2) 55%, transparent);
  background: transparent; color: var(--fg2); cursor: help;
  font: inherit;                                           /* buttons ignore the text size around them unless told */
  text-indent: -9999px; white-space: nowrap;               /* the letter is hidden; the glyph below is drawn */
  letter-spacing: 0; text-transform: none;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
/* A drawn info glyph (dot + stem with feet) instead of the font's "i",
   which is only a thin bar at this size. Painted with currentColor, so it
   follows hover and both themes. */
.info::before {
  content: ""; position: absolute; inset: 19%;          /* sized from the circle itself, so it scales with every ⓘ size */
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='3.3' r='2'/%3E%3Cpath d='M5 6.3h4.6v6h1.6V14.4H4.7v-2.1h1.8V8.4H5z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='3.3' r='2'/%3E%3Cpath d='M5 6.3h4.6v6h1.6V14.4H4.7v-2.1h1.8V8.4H5z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.info:hover, .info[aria-expanded="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.info:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.info .info-text { display: none; }
.setup-card h1 .info { width: 19px; height: 19px; margin-left: 7px; }
.opt-bar > .info { width: 20px; height: 20px; margin-left: 2px; }

.info-pop {
  position: fixed; z-index: 100001; left: 0; top: 0;
  max-width: min(300px, calc(100vw - 16px)); padding: 10px 12px;
  border-radius: 10px; background: var(--fg); color: var(--bg);
  box-shadow: var(--shadow-lg);
  font: 400 12px/1.5 var(--font); letter-spacing: 0; text-transform: none; text-align: left;
  animation: info-in .14s ease-out;
}
.info-pop[hidden] { display: none; }
.info-pop b { font-weight: 700; }
/* the little pointer, aimed at the ⓘ */
.info-pop::before {
  content: ""; position: absolute; left: var(--arrow-x, 50%); width: 10px; height: 10px;
  background: inherit; transform: translateX(-50%) rotate(45deg); border-radius: 2px;
}
.info-pop[data-side="below"]::before { top: -4px; }
.info-pop[data-side="above"]::before { bottom: -4px; }
@keyframes info-in { from { opacity: 0; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .info-pop { animation: none; } }
/* Measured nudges where baseline alignment can't apply or the font differs:
   the 3D labels are flex rows (vertical-align is ignored there), and the
   Region data headings are larger mixed-case text. */
#v3d .mini .info { top: -4px; }
.drawer-card h3 .info { top: 1.5px; }


/* ═══════════════════════════════════════════════════════════════
   DASHBOARD IN THE SURVEY-PLANNER STYLE
   Same visual language as the setup tiles: 20px nested corners, hairline
   borders, bold titles, rounded fields, pill switches, round icon buttons.
   Layout, widths and behaviour are unchanged. Panels sit over the map, so
   their surface uses --card-pct / --card-backdrop (tune with ?tune).
   ═══════════════════════════════════════════════════════════════ */
.card {
  border-radius: 20px; padding: 14px 16px; gap: 10px;
  background: linear-gradient(color-mix(in srgb, var(--glass) var(--card-pct), transparent), color-mix(in srgb, var(--glass) var(--card-pct), transparent)), var(--glass-floor);
  -webkit-backdrop-filter: var(--card-backdrop); backdrop-filter: var(--card-backdrop);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
/* card titles: the planner's bold title; sub-headings: its small label */
.card h2, #v3d .head h3 {
  font: 700 15px/1.2 var(--font); letter-spacing: -.02em; text-transform: none; color: var(--fg);
}
.card h3 { font: 500 11.5px/1.3 var(--font); letter-spacing: 0; text-transform: none; color: var(--fg2); }
.card-head { gap: 10px; }

/* buttons, fields, switches */
.btn { border-radius: 10px; padding: 7px 10px; }
.btn.sm { border-radius: 8px; }
input[type=number], select.sel {
  height: 32px; padding: 0 10px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface2); color: var(--fg);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input[type=number]:focus, select.sel:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
#v3d .mini input { height: 28px; padding: 0 8px; }
.seg {
  border: 0; border-radius: 999px; padding: 3px; gap: 2px; overflow: visible;
  background: color-mix(in srgb, var(--fg) 7%, transparent);
}
.seg button { border-radius: 999px; padding: 5px 11px; }
.seg button + button { border-left: 0; }
.seg button[aria-pressed="true"] { box-shadow: var(--shadow); }

/* left icon rail: same nested-corner card */
#toolrail {
  border-radius: 20px; padding: 6px; border: 1px solid var(--line);
  background: linear-gradient(color-mix(in srgb, var(--glass) var(--card-pct), transparent), color-mix(in srgb, var(--glass) var(--card-pct), transparent)), var(--glass-floor);
  -webkit-backdrop-filter: var(--card-backdrop); backdrop-filter: var(--card-backdrop);
}
.rail-btn { border-radius: 14px; }

/* round collapse buttons, like the planner's x and pencil */
.card-min {
  width: 26px; height: 26px; border-radius: 50%; border: 0;
  background: var(--bg); color: var(--fg); font-size: 15px;
}
.card-min:hover { background: var(--accent); color: var(--accent-fg); border-color: transparent; }

/* charts nest inside the card's curve (20px card, ~16px gutter) */
#sv-panel canvas, #coastcard canvas, #cv-3d { border-radius: 12px; }

/* Region data & notes */
.drawer-card { border-radius: 20px; padding: 20px 22px; border-color: var(--line); }
/* glass like the cards over the map, with a denser tint (the floor twice)
   and a stronger blur, since it holds a lot of small text; the scrim behind
   is lighter so the map still shows round it */
#drawer { background: color-mix(in srgb, var(--scrim) 55%, transparent); }
.drawer-card {
  background:
    linear-gradient(color-mix(in srgb, var(--glass) 20%, transparent), color-mix(in srgb, var(--glass) 20%, transparent)),
    linear-gradient(var(--glass-floor), var(--glass-floor)), var(--glass-floor);
  -webkit-backdrop-filter: var(--card-backdrop) blur(14px); backdrop-filter: var(--card-backdrop) blur(14px);
}
.drawer-card h3 { font: 700 14px/1.3 var(--font); letter-spacing: -.01em; }
/* a thin rounded scroll bar that stays clear of the 20px corners, instead
   of the browser's wide grey bar with arrows running into them */
.drawer-card::-webkit-scrollbar { width: 12px; }
.drawer-card::-webkit-scrollbar-button { display: none; height: 0; }
.drawer-card::-webkit-scrollbar-track { background: transparent; margin: 20px 0; }
.drawer-card::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--fg) 24%, transparent); border-radius: 99px;
  border: 4px solid transparent; background-clip: padding-box;
}
.drawer-card::-webkit-scrollbar-thumb:hover { background-color: color-mix(in srgb, var(--fg) 38%, transparent); }
@supports not selector(::-webkit-scrollbar) {
  .drawer-card { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--fg) 24%, transparent) transparent; }
}
.drawer-head h2 { font: 700 17px/1.2 var(--font); letter-spacing: -.02em; text-transform: none; color: var(--fg); }
/* measured: the bold 15px card titles need the ⓘ 2px lower to centre on their capitals */
.card h2 .info, #v3d .head h3 .info { top: 2px; }

/* ═══════════════════════════════════════════════════════════════
   MAP LAYERS: one-row icon toolbar + legend strip on the map
   The toolbar sits at the top of the right column; the legend it
   drives is docked bottom-centre of the free map area, moves above the
   3D panel when that is open, and hides while the 3D panel is enlarged.
   ═══════════════════════════════════════════════════════════════ */
#layers.layers-bar {
  flex-direction: row; align-items: center; align-self: flex-end;
  gap: 2px; padding: 5px; border-radius: 18px;
}
.ib-group { display: flex; gap: 2px; }
.ib-sep { width: 1px; height: 20px; margin: 0 5px; background: var(--border); flex: none; }
.ib {
  position: relative; flex: none; width: 34px; height: 34px; padding: 0; margin: 0;
  display: inline-grid; place-items: center; border: 0; border-radius: 13px;
  background: transparent; color: var(--fg2); cursor: pointer;
  transition: background-color .13s ease, color .13s ease;
}
.ib svg { width: 18px; height: 18px; display: block; }
.ib:hover:not(:disabled) { background: color-mix(in srgb, var(--fg) 8%, transparent); color: var(--fg); }
/* base layer (one of two): solid; on/off overlays: a soft tint */
.ib[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); box-shadow: var(--shadow); }
.ib[aria-pressed="true"]:hover { background: color-mix(in srgb, var(--accent) 86%, var(--fg)); color: var(--accent-fg); }
.ib-toggle:has(input:checked), #btn-heatlegend[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); box-shadow: none;
}
.ib-toggle:has(input:checked):hover, #btn-heatlegend[aria-pressed="true"]:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 26%, transparent); color: var(--accent);
}
.ib:disabled, #btn-heatlegend:disabled { opacity: .35; cursor: not-allowed; background: transparent; color: var(--fg2); }
.ib-toggle input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.ib:focus-visible, .ib-toggle:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

#legend-dock {
  position: absolute; z-index: 11; bottom: 10px;
  /* placeLegend() (app.js) sets left/width on desktop; this is the fallback */
  left: 76px; right: calc(min(540px, 46vw) + 20px);
  display: flex; justify-content: center; pointer-events: none;
  transition: left .2s ease, width .2s ease;
}
#v3d:not([hidden]) ~ #legend-dock { bottom: calc(max(46%, 230px) + 20px); }
#v3d.big:not([hidden]) ~ #legend-dock { display: none; }
.legend-strip {
  pointer-events: auto; width: min(500px, 100%);
  display: flex; flex-direction: column; gap: 8px; padding: 9px 13px;
  border-radius: 16px; border: 1px solid var(--line); box-shadow: var(--shadow);
  background: linear-gradient(color-mix(in srgb, var(--glass) var(--card-pct), transparent), color-mix(in srgb, var(--glass) var(--card-pct), transparent)), var(--glass-floor);
  -webkit-backdrop-filter: var(--card-backdrop); backdrop-filter: var(--card-backdrop);
  font-size: 10.5px; color: var(--fg2);
}
.ls-base, .ls-heat { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ls-label { flex: none; font: 600 11px var(--font); color: var(--fg); }
.ls-depth { flex: 1; min-width: 0; padding-bottom: 12px; }
.dbar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; }
.dbar i { flex: 1; }
.dticks { position: relative; height: 0; }
.dticks span { position: absolute; top: 3px; transform: translateX(-50%); font: 9.5px/1 var(--mono); white-space: nowrap; }
.dticks span:first-child { transform: none; }
.dticks span:last-child { transform: translateX(-100%); }
.ls-chip { display: inline-flex; align-items: center; gap: 5px; flex: none; white-space: nowrap; }
.ls-chip i, .key i { width: 12px; height: 8px; border-radius: 3px; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.ls-base .ls-chip + .ls-chip { margin-left: 2px; }
/* route heat row: only once there is a route, and while the toolbar's flame is on */
.ls-heat { display: none; padding-top: 8px; border-top: 1px solid var(--border); }
#legend-dock.has-route.heat-on .ls-heat { display: flex; }
.ls-heat .seg.sm button { padding: 3px 9px; font-size: 10.5px; }
.ls-bar { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ls-bar .cbar-lab { font-size: 9.5px; }
.key { display: flex; align-items: center; gap: 7px; }
.key + .key { margin-top: 5px; }
@media (max-width: 640px) { .legend-strip { padding: 8px 10px; } .ls-label { display: none; } }

/* rail: divider before the right-hand panel switches (Side views) */
.rail-sep { height: 1px; margin: 2px 8px; background: var(--border); flex: none; }
/* round close button on panels opened from the rail */
.card-x {
  width: 26px; height: 26px; border-radius: 50%; border: 0; padding: 0; flex: none;
  display: inline-grid; place-items: center; cursor: pointer;
  background: var(--bg); color: var(--fg); font: 17px/1 var(--font);
  transition: background-color .13s ease, color .13s ease;
}
.card-x:hover { background: var(--accent); color: var(--accent-fg); }
.card-x:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ═══════════════════════════════════════════════════════════════
   SURVEY CONTROLS (compact): icon fields, a player-style transport
   strip with the waypoint count, a waypoint sub-card, an icon tool row
   ═══════════════════════════════════════════════════════════════ */
/* value strip (from option B): label over value; the value is the input */
.sc-vals {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; padding: 3px;
  border-radius: 14px; background: color-mix(in srgb, var(--fg) 6%, transparent);
}
.sv {
  display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0;
  padding: 6px 2px 5px; border-radius: 11px; cursor: text;
  transition: background-color .13s ease, box-shadow .13s ease;
}
.sv:hover { background: color-mix(in srgb, var(--fg) 6%, transparent); }
.sv:focus-within { background: var(--surface2); box-shadow: inset 0 0 0 1.5px var(--accent); }
.sv .k { font: 500 9.5px var(--font); letter-spacing: .02em; color: var(--fg2); white-space: nowrap; }
.sv .v { display: flex; align-items: baseline; justify-content: center; gap: 1px; max-width: 100%; }
.sv small { font: 10px var(--mono); color: var(--fg2); }
#panel .sv input[type=number] {
  width: 3.6ch; min-width: 1ch; height: auto; padding: 0; border: 0; border-radius: 0; text-align: center;
  background: transparent; box-shadow: none; outline: none;
  font: 600 14px var(--mono); color: var(--fg); -moz-appearance: textfield;
}
@supports (field-sizing: content) { #panel .sv input[type=number] { field-sizing: content; width: auto; max-width: 6ch; } }
#panel .sv input::-webkit-inner-spin-button, #panel .sv input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }


/* actions (from option A): a wide Simulate, then icon buttons */
.sc-actions { display: flex; gap: 6px; align-items: center; }
.sc-play {
  flex: 1; height: 36px; border: 0; border-radius: 11px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--accent); color: var(--accent-fg); font: 600 12.5px var(--font);
  transition: background-color .13s ease;
}
.sc-play:hover { background: color-mix(in srgb, var(--accent) 86%, var(--fg)); }
.sc-play svg { width: 14px; height: 14px; }
.sc-play .i-stop, .sc-play[aria-pressed="true"] .i-play { display: none; }
.sc-play[aria-pressed="true"] .i-stop { display: block; }
.sc-play[aria-pressed="true"] { background: var(--danger); color: var(--danger-fg); }
.ibtn.solid { width: 36px; height: 36px; border-radius: 11px; background: color-mix(in srgb, var(--fg) 7%, transparent); color: var(--fg); }
.ibtn.solid:hover { background: color-mix(in srgb, var(--fg) 13%, transparent); }
.ibtn.danger { color: var(--danger); }
.ibtn.danger:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.sc-play:focus-visible, 
/* waypoint card: its own card under Survey controls; goes when that panel closes */
#panel[hidden] + #wp-card { display: none; }
#wp-card { padding: 12px 12px 10px 16px; gap: 6px; }
#wp-card h2 { font-size: 13.5px; }
#wp-list { max-height: 150px; overflow-y: auto; padding-right: 6px; font: 10.5px/1.4 var(--mono); color: var(--fg2); }
.wp-row { display: grid; grid-template-columns: 34px 1fr; column-gap: 6px; row-gap: 1px; align-items: baseline; padding: 5px 0; }
.wp-row .ll { color: var(--fg); white-space: nowrap; }
.wp-meta { grid-column: 2; display: flex; justify-content: space-between; gap: 8px; font-size: 10px; }
.wp-meta em { font-style: normal; color: var(--fg); }
.wp-row + .wp-row, .wp-gap + .wp-row { border-top: 1px solid var(--border); }
.wp-row b { color: var(--fg); font-weight: 600; }
.wp-sum { font: 500 11px var(--font); color: var(--fg); padding: 2px 0 4px; }
.wp-gap { text-align: center; padding: 2px 0; }

.sc-tools { display: flex; align-items: center; gap: 2px; margin: 0 -4px -4px; }
.sc-tools .grow { flex: 1; }
.ibtn {
  width: 34px; height: 32px; border-radius: 10px; border: 0; padding: 0; flex: none;
  display: grid; place-items: center; cursor: pointer; background: transparent; color: var(--fg2);
  transition: background-color .13s ease, color .13s ease;
}
.ibtn svg { width: 16px; height: 16px; }
.ibtn:hover { background: color-mix(in srgb, var(--fg) 8%, transparent); color: var(--fg); }
.ibtn[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }


/* ═══════════════════════════════════════════════════════════════
   YOUR RECENT DATA (setup page)
   Same tile as the samples. Every set shows one generic picture
   (assets/thumbs/recent-data.webp); until that file exists, a dotted
   chart-paper fallback with a grid icon is drawn instead.
   ═══════════════════════════════════════════════════════════════ */
.recent-thumb {
  background-color: var(--map-bg);
  background-image: radial-gradient(circle, var(--map-dot) 1px, transparent 1.4px);
  background-size: 14px 14px;
}
.recent-thumb::before {
  content: ""; width: 34%; aspect-ratio: 1; opacity: .55; background: var(--fg2);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6l6-2 6 2 6-2v14l-6 2-6-2-6 2z'/%3E%3Cpath d='M9 4v14M15 6v14'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6l6-2 6 2 6-2v14l-6 2-6-2-6 2z'/%3E%3Cpath d='M9 4v14M15 6v14'/%3E%3C/svg%3E") center / contain no-repeat;
}
.recent-thumb img + .recent-badge { z-index: 1; }
.recent-badge {
  position: absolute; top: 9px; left: 9px; z-index: 1;
  padding: 3px 8px; border-radius: 999px;
  font: 600 10px/1.3 var(--font); letter-spacing: .01em; color: #fff;
  background: rgba(0, 12, 34, .62); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.recent-progress {
  position: absolute; inset: 0; z-index: 2; display: grid; place-items: center;
  font: 600 12px var(--mono); color: #fff; background: rgba(0, 12, 34, .55);
}
.recent-progress[hidden] { display: none; }
.tile-recent.loading { opacity: 1; }     /* the progress overlay already says it is busy */
.recent-file { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-recent .tile-name { overflow-wrap: anywhere; }

/* who a tile belongs to: a small tag pinned to the tile's own bottom-right
   corner (not the text block), so it lines up across a row whatever the name */
.tile-tag {
  position: absolute; right: 14px; bottom: 13px;
  font: 500 10px/1 var(--font); letter-spacing: .02em; color: var(--fg2);
  padding: 3px 7px; border-radius: 999px; border: 1px solid var(--border);
}
.tile-recent .tile-tag { color: var(--accent2); border-color: color-mix(in srgb, var(--accent2) 45%, transparent); }
.tile-sample .tile-name, .tile-recent .tile-name { padding-right: 52px; }

/* ═══════════════════════════════════════════════════════════════
   NOTIFICATIONS — top centre, below the top bar (mbesNotify in app.js)
   ═══════════════════════════════════════════════════════════════ */
#toasts {
  position: fixed; z-index: 9000; top: 56px; left: 50%; transform: translateX(-50%);
  width: min(520px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 10px 10px 12px; border-radius: 14px;
  background: color-mix(in srgb, var(--surface2) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  font: 500 12.5px/1.45 var(--font); color: var(--fg);
  animation: toast-in .22s cubic-bezier(.2, .7, .2, 1);
}
.toast.out { animation: toast-out .2s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-6px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { .toast, .toast.out { animation-duration: .01s; } }
.toast-ic {
  flex: none; width: 20px; height: 20px; margin-top: 0; border-radius: 50%;
  display: grid; place-items: center; font: 700 12px/1 var(--font);
  background: color-mix(in srgb, var(--fg) 10%, transparent); color: var(--fg2);
}
.toast-tx { flex: 1; min-width: 0; padding-top: 1px; overflow-wrap: anywhere; }
.toast-tx b { color: var(--accent2); font-weight: 600; }
.toast-x {
  flex: none; width: 24px; height: 24px; margin: -2px -2px 0 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--fg2); font: 16px/1 var(--font); cursor: pointer;
}
.toast-x:hover { background: color-mix(in srgb, var(--fg) 10%, transparent); color: var(--fg); }
.toast-x:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.toast-warn  { border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); }
.toast-warn .toast-ic  { background: var(--warn); color: #fff; }
.toast-error { border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }
.toast-error .toast-ic { background: var(--danger); color: var(--danger-fg); }
.toast-ok .toast-ic    { background: var(--accent2); color: #fff; }
/* dashboard messages wait while the setup screen covers it */
body:has(#setup:not([hidden])) .toast[data-scope="dash"] { display: none; }


/* ═══════════════════════════════════════════════════════════════
   NEAT SCROLLING in the left tool panels (2 panels, short screens,
   browser zoom): vertical only, a thin bar, and a soft fade at the edge
   that has more. Rows wrap rather than push the column sideways.
   ═══════════════════════════════════════════════════════════════ */
#toolpanels {
  overflow-x: hidden; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--fg) 22%, transparent) transparent;
  padding-bottom: 2px;
}
#toolpanels::-webkit-scrollbar { width: 6px; }
#toolpanels::-webkit-scrollbar-track { background: transparent; }
#toolpanels::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--fg) 22%, transparent); border-radius: 99px; }
#toolpanels.scrolls { padding-right: 8px; }
/* Card shadows and glass in the column. A scroll container clips what is
   drawn outside it, so the cards' shadows were cut off at the column's
   rectangle: shadow filled the square corners round each card's curve and
   stopped in a straight line along the edges, a rectangular tint behind the
   cards (and one big rectangle behind two). The column is therefore only a
   scroll container while it has more than fits (.scrolls, set by app.js);
   otherwise nothing is clipped. While it scrolls it reaches out to the rail
   (left), past the cards (right) and to the map edges (top, bottom), with
   the same padding inside, so the cards stay where they were and their
   shadows fit inside the clip. */
#toolpanels:not(.scrolls) { overflow: visible; }
#toolpanels.scrolls {
  width: calc(var(--tp-w, 272px) + 22px); max-height: calc(100% + 20px);
  margin: -10px -14px -10px -8px; padding: 10px 22px 10px 8px;
}
/* The fade below is a mask, and in Chrome a masked element is a backdrop
   root: the cards' backdrop-filter then sees nothing behind them (no blur,
   no darkening), so a dark card turned pale and the map showed through
   sharp. While the column scrolls the cards get a denser tint that gives
   the same colour without the filter. */
#toolpanels.scrolls > .card { background: var(--glass-flat); }
#toolpanels.fade-b { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 26px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 26px), transparent); }
#toolpanels.fade-t { -webkit-mask-image: linear-gradient(to top, #000 calc(100% - 26px), transparent); mask-image: linear-gradient(to top, #000 calc(100% - 26px), transparent); }
#toolpanels.fade-t.fade-b { -webkit-mask-image: linear-gradient(to bottom, transparent, #000 26px, #000 calc(100% - 26px), transparent); mask-image: linear-gradient(to bottom, transparent, #000 26px, #000 calc(100% - 26px), transparent); }
#toolpanels > .card { min-width: 0; }
#toolpanels .row { flex-wrap: wrap; }
/* the action and tool rows stay on one line: their icons give a little instead */
.sc-actions, .sc-tools { flex-wrap: nowrap; min-width: 0; }
.sc-tools .ibtn, .sc-actions .ibtn { flex-shrink: 1; min-width: 28px; }
.sc-tools .grow { min-width: 0; }
.sc-play { min-width: 0; }
#toolpanels .ctrl { min-width: 0; }
.sc-vals { grid-template-columns: repeat(auto-fit, minmax(52px, 1fr)); }
#mission select.sel, #mission input { max-width: 100%; min-width: 0; }

/* the legend strip keeps a readable width; with Side views closed it may
   use the empty right-hand side too */
.legend-strip { min-width: min(300px, calc(100vw - 32px)); }
body:has(#sv-panel[hidden]) #legend-dock { right: 10px; }

/* ═══════════════════════════════════════════════════════════════
   MOVABLE PANELS: Mission summary and the 3D patch view are dragged by
   their title bar; double-click the title bar to put the panel back.
   ═══════════════════════════════════════════════════════════════ */
.drag-handle { cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none; }
.drag-handle button, .drag-handle input, .drag-handle select, .drag-handle label, .drag-handle .seg { cursor: auto; }
.drag-handle button { cursor: pointer; }
.card.moved { right: auto !important; bottom: auto !important; z-index: 13; }
.card.dragging { cursor: grabbing; box-shadow: var(--shadow-lg); transition: none; }
.card.dragging .drag-handle { cursor: grabbing; }
/* a moved 3D panel no longer pushes the legend strip up */
#v3d.moved:not([hidden]) ~ #legend-dock { bottom: 10px; }

/* ── Simulation progress: top-edge bar + chip + filling Simulate button ── */
#sim-edge {
  position: absolute; z-index: 15; left: 0; right: 0; top: 0; height: 3px; pointer-events: none;
  background: color-mix(in srgb, var(--fg) 10%, transparent);
}
#sim-edge i {
  display: block; height: 100%; width: 0; background: var(--accent2);
  box-shadow: 0 0 8px var(--accent2), 0 0 2px var(--accent2); transition: width .12s linear;
}
#sim-chip {
  position: absolute; z-index: 14; right: 10px; top: 66px;
  display: flex; flex-direction: column; gap: 0; padding: 5px 5px 5px 12px; border-radius: 18px; cursor: default;
  background: color-mix(in srgb, var(--surface2) 94%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  animation: toast-in .2s cubic-bezier(.2, .7, .2, 1);
}
#sim-chip[hidden] { display: none; }
.sc-row { display: flex; align-items: center; gap: 8px; }
.sc-pct { font: 600 12.5px var(--mono); color: var(--fg); font-variant-numeric: tabular-nums; min-width: 3.2ch; }
.sc-left { font: 500 11.5px var(--font); color: var(--fg2); white-space: nowrap; }
.sc-stop {
  width: 26px; height: 26px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; flex: none;
  display: grid; place-items: center; color: var(--danger); background: color-mix(in srgb, var(--danger) 13%, transparent);
}
.sc-stop svg { width: 10px; height: 10px; }
.sc-stop:hover { background: color-mix(in srgb, var(--danger) 24%, transparent); }
.sc-more { display: none; flex-direction: column; gap: 3px; padding: 7px 7px 4px 0; font: 11px/1.45 var(--mono); color: var(--fg2); font-variant-numeric: tabular-nums; }
.sc-dist { color: var(--fg); font-weight: 600; }
/* Mouse: hover only. Keyboard: focus-visible (mouse clicks don't latch it). Touch: tap toggles .open. */
@media (hover: hover) { #sim-chip:hover .sc-more { display: flex; } }
#sim-chip:has(:focus-visible) .sc-more, #sim-chip.open .sc-more { display: flex; }
.sc-finish {
  align-self: flex-end; margin-top: 3px; height: 26px; padding: 0 11px; border-radius: 99px; cursor: pointer;
  border: 1px solid var(--border); background: transparent; color: var(--fg); font: 600 11.5px var(--font);
}
.sc-finish:hover { border-color: var(--accent2); }
.sc-stop:focus-visible, .sc-finish:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* the Simulate button fills up while running and shows the % on it */
.sc-play { position: relative; overflow: hidden; }
.sc-play > :not(.sim-fill) { position: relative; }
.sim-fill { position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--p, 0) * 100%); pointer-events: none; transition: width .12s linear; }
.sim-pct { display: none; font: 600 12px var(--mono); font-variant-numeric: tabular-nums; }
.sc-play.running, .sc-play.running:hover {
  justify-content: space-between; padding: 0 12px;
  background: color-mix(in srgb, var(--danger) 15%, var(--surface2)); color: var(--danger);
}
.sc-play.running .sim-fill { background: color-mix(in srgb, var(--danger) 24%, transparent); }
.sc-play.running .sim-pct { display: inline; }
.sc-play.running #sim-label { margin-right: auto; margin-left: 7px; }
.sc-play.running .i-stop { display: block; }

/* Recent data: downloaded or not.
   Not downloaded yet: a round ↓ in the middle of the (normal) picture.
   Downloaded (kept for this session, opens instantly): the label-row arrow
   becomes a teal ⚡. Hidden while a download is in progress. */
.tile-recent:not(.is-cached):not(.loading) .tile-thumb::after {
  content: "\2193"; position: absolute; z-index: 1; inset: 0; margin: auto;
  width: 44px; height: 44px; border-radius: 50%; pointer-events: none;
  display: grid; place-items: center; text-align: center;
  font: 600 20px/44px var(--font); color: #fff;
  background: rgba(0, 12, 34, .55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
  transition: transform .2s ease, background-color .2s ease;
}
.tile-recent:not(.is-cached):hover .tile-thumb::after { transform: scale(1.08); background: rgba(0, 12, 34, .72); }
.tile-recent.is-cached .tile-arrow { font-size: 0; }
.tile-recent.is-cached .tile-arrow::after { content: "\26A1"; font-size: 13px; color: var(--accent2); }
@media (prefers-reduced-motion: reduce) { .tile-recent .tile-thumb::after { transition: none; } }

/* Show / hide password: an eye button inside the field's right edge */
.pw-wrap { position: relative; }
.pw-wrap .auth-input { padding-right: 42px; }
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px; cursor: pointer;
  display: grid; place-items: center; background: transparent; color: var(--fg2);
  transition: background-color .13s ease, color .13s ease;
}
.pw-toggle:hover { background: color-mix(in srgb, var(--fg) 8%, transparent); color: var(--fg); }
.pw-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pw-toggle svg { width: 18px; height: 18px; }
.pw-toggle .pw-hide, .pw-toggle[aria-pressed="true"] .pw-show { display: none; }
.pw-toggle[aria-pressed="true"] .pw-hide { display: block; }
.pw-wrap .auth-input::-ms-reveal { display: none; }   /* no second eye from Edge */


/* ═══════════════════════════════════════════════════════════════
   3D PATCH VIEW, desktop/tablet layout (phones: mobile-map.css).
   It runs from the left dock to the map's right edge (the Map layers
   toolbar is at the top, out of its way) and stops at the right-hand
   column only while Side views is open. --v3d-left (placeLegend/place3d
   in app.js) moves its left edge over the map when the minimum width
   does not fit. The canvas takes all the height the header leaves.
   ═══════════════════════════════════════════════════════════════ */
@media (min-width: 641px) {
  html:not(.mmap-on) #v3d {
    left: var(--v3d-left, var(--left-offset)); right: 10px;
    height: auto; min-height: clamp(300px, 46%, 460px); max-height: calc(100% - 20px);
    min-width: 340px; max-width: 820px;
    padding: 8px 10px 6px; gap: 6px; container-type: inline-size;
  }
  html:not(.mmap-on) body:has(#sv-panel:not([hidden])) #v3d { right: calc(min(540px, 46vw) + 20px); }
  /* enlarged: the whole map area below the Map layers toolbar
     (--v3d-big-top from place3d); the progress chip moves to its corner */
  html:not(.mmap-on) #v3d.big { top: var(--v3d-big-top, 66px); height: auto; min-height: 0; max-height: none; max-width: none; }
  html:not(.mmap-on) body:has(#v3d.big:not([hidden])) #sim-chip { top: auto; bottom: 20px; right: 20px; }
  html:not(.mmap-on) #v3d #cv-3d { min-height: 220px; }
  html:not(.mmap-on) #v3d .head { flex-wrap: wrap; row-gap: 5px; column-gap: 6px; }
  html:not(.mmap-on) #v3d .head h3 { white-space: nowrap; }
  html:not(.mmap-on) #v3d .mini { white-space: nowrap; }
  html:not(.mmap-on) #v3d .mini input { width: 60px; }
  /* the caption is one line; the full text is in its tooltip */
  html:not(.mmap-on) #lab-3d { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 0; font-size: 10.5px; line-height: 15px; }
}
@media (min-width: 641px) and (max-width: 900px) {
  html:not(.mmap-on) body:has(#sv-panel:not([hidden])) #v3d { right: 350px; }
}
/* narrower panels: drop the small (i) buttons next to Span/Vert, tighter controls */
@container (max-width: 620px) {
  html:not(.mmap-on) #v3d .mini .info { display: none; }
  html:not(.mmap-on) #v3d .mini input { width: 54px; }
  html:not(.mmap-on) #v3d .seg button { padding: 4px 7px; }
}
/* too narrow for one row: title + enlarge/close on top, the controls below */
@container (max-width: 600px) {
  html:not(.mmap-on) #v3d .head h3 { order: -2; flex: 1 0 calc(100% - 80px); margin-right: 0; }
  html:not(.mmap-on) #v3d .head #btn-3d-big, html:not(.mmap-on) #v3d .head #btn-3d-close { order: -1; }
}
@container (max-width: 400px) {
  html:not(.mmap-on) #v3d .mini { letter-spacing: 0; }
  html:not(.mmap-on) #v3d .mini input { width: 44px; }
}

/* Legend chip (desktop/tablet): the strip folds into it while the 3D panel
   sits at the bottom of the map; a click opens the strip above it. */
.lg-chip { display: none; }
#legend-dock.lg-compact { right: auto; flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: 6px; transition: none; }
#legend-dock.lg-compact.lg-open { z-index: 16; }
#legend-dock.lg-compact:not(.lg-open) .legend-strip { display: none; }
#legend-dock.lg-compact .legend-strip { width: 100%; }
#legend-dock.lg-compact .lg-chip {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px;
  border-radius: 99px; border: 1px solid var(--line); box-shadow: var(--shadow); cursor: pointer;
  font: 600 11.5px var(--font); color: var(--fg);
  background: linear-gradient(color-mix(in srgb, var(--glass) var(--card-pct), transparent), color-mix(in srgb, var(--glass) var(--card-pct), transparent)), var(--glass-floor);
  -webkit-backdrop-filter: var(--card-backdrop); backdrop-filter: var(--card-backdrop);
}
#legend-dock.lg-compact .lg-chip:hover { border-color: var(--accent); }
#legend-dock.lg-compact .lg-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#legend-dock.lg-open .lg-chip { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.lg-chip-bar { width: 34px; height: 7px; border-radius: 9px; flex: none; background: linear-gradient(90deg, #e2f3f8, #97d0e4, #3f95c5, #1f5791, #102b51); }
.mmap-on .lg-chip { display: none !important; }

/* Stats bar: Step / footprint is the longest value; give its cell a little
   more room and a tighter mono face so it is not cut off on tablets */
.stat:has(#st-along) { flex-basis: 124px; }
#st-along { font-size: 12px; letter-spacing: -.02em; }
