:root {
  --bg: #08121f;
  --surface: #0f1d2e;
  --surface-2: #142639;
  --ink: #e8eef5;
  --ink-2: #a9b8c9;
  --ink-3: #6f8196;
  --rule: #1f3349;
  --accent: #33d1c1;
  --accent-ink: #5fe3d5;
  --gold: #ffc857;
  --logo-blue: #3ca3f2;
  --poor: #f07167;
  --fair: #ffc857;
  --good: #7bd88f;
  --great: #33d1c1;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --topbar-h: 64px;
  --panel-w: 400px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef3f7;
    --surface: #ffffff;
    --surface-2: #f3f7fa;
    --ink: #0b1a2a;
    --ink-2: #3f5266;
    --ink-3: #6b7d90;
    --rule: #d9e2ea;
    --accent: #0f9d8f;
    --accent-ink: #0a7d72;
    --gold: #b7791f;
    --logo-blue: #1877c9;
    --poor: #c2413a;
    --fair: #b7791f;
    --good: #2f8f46;
    --great: #0f9d8f;
    --shadow: 0 6px 18px rgba(15, 30, 50, 0.12);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Instrument Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, .byteon-num { font-family: "Bricolage Grotesque", "Helvetica Neue", Arial, sans-serif; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 22px; line-height: 1.2; font-weight: 700; text-wrap: balance; }
h2 { font-size: 17px; font-weight: 600; }
p { margin: 0 0 10px; }
.lbl, .eyebrow, .muted.mono, .buoys th {
  font-family: "JetBrains Mono", Menlo, monospace; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
}
.muted { color: var(--ink-3); font-size: 13px; }
.fine { color: var(--ink-3); font-size: 12.5px; margin: 10px 0 0; }

/* ---------- top bar ---------- */
.topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: 18px;
  padding: 0 16px 0 18px; background: var(--surface); border-bottom: 1px solid var(--rule);
  position: relative; z-index: 1000;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-logo { height: 52px; width: auto; aspect-ratio: 818 / 353; display: block; }
.tagline { margin: 0; color: var(--ink-3); font-size: 13.5px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.byteon { display: flex; align-items: center; gap: 8px; }
.byteon svg { width: 76px; height: 46px; }
.g-track, .g-fill { fill: none; stroke-width: 11; stroke-linecap: round; }
.g-track { stroke: var(--rule); }
.g-fill { stroke: var(--ink-3); transition: stroke-dasharray 0.8s ease, stroke 0.3s; }
.byteon-read { display: grid; line-height: 1.05; }
.byteon-read .lbl { color: var(--ink-3); font-size: 10px; }
.byteon-num { font-size: 26px; font-weight: 700; }
.byteon-label { font-size: 12px; color: var(--ink-2); }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 1fr var(--panel-w); height: calc(100vh - var(--topbar-h)); height: calc(100dvh - var(--topbar-h)); }
.map-wrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: #0b2239; }
.panel { overflow-y: auto; padding: 14px; display: grid; gap: 12px; align-content: start; border-left: 1px solid var(--rule); background: var(--bg); }

@media (max-width: 900px) {
  :root { --topbar-h: 56px; }
  .tagline { display: none; }
  .brand-logo { height: 46px; }
  .layout { display: block; height: auto; }
  .map-wrap { height: 62vh; height: 62dvh; }
  .panel { border-left: 0; padding: 12px 16px 24px; }
}

/* ---------- map overlays ---------- */
.map-ui { position: absolute; top: 12px; left: 12px; right: 12px; z-index: 500; display: flex; flex-wrap: wrap; gap: 8px; pointer-events: none; }
.map-ui > * { pointer-events: auto; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 3px; box-shadow: var(--shadow); }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; cursor: pointer; font-size: 13.5px; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.seg button:hover { color: var(--ink); }
.seg button[aria-selected="true"], .seg button[aria-pressed="true"] { background: var(--accent); color: #04201d; }
.seg.small { box-shadow: none; background: var(--surface-2); flex-wrap: wrap; }
.seg.small button { padding: 4px 10px; font-size: 12.5px; }
.toggles { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 6px 12px; box-shadow: var(--shadow); font-size: 13px; color: var(--ink-2); }
.toggles label { display: inline-flex; gap: 5px; align-items: center; cursor: pointer; }
.toggles input { accent-color: var(--accent); margin: 0; }

.readout {
  position: absolute; right: 58px; bottom: 28px; z-index: 500; background: var(--surface); border: 1px solid var(--rule);
  border-radius: 10px; padding: 8px 12px; font-family: "JetBrains Mono", Menlo, monospace; font-size: 12px; color: var(--ink-2);
  box-shadow: var(--shadow); white-space: nowrap; pointer-events: none;
}
.readout b { color: var(--ink); font-weight: 500; }
.legend {
  position: absolute; left: 12px; bottom: 28px; z-index: 500; background: var(--surface); border: 1px solid var(--rule);
  border-radius: 10px; padding: 8px 12px 6px; box-shadow: var(--shadow); width: min(300px, calc(100% - 24px));
}
.legend .lbl { color: var(--ink-3); display: flex; justify-content: space-between; }
.legend .bar { height: 10px; border-radius: 3px; margin: 5px 0 3px; }
.legend .ticks { display: flex; justify-content: space-between; font-family: "JetBrains Mono", Menlo, monospace; font-size: 11px; color: var(--ink-2); }
.layers-menu { position: relative; }
.layers-menu summary {
  list-style: none; cursor: pointer; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px;
  padding: 7px 12px; box-shadow: var(--shadow); font-size: 13px; font-weight: 500; color: var(--ink-2); user-select: none;
}
.layers-menu summary::-webkit-details-marker { display: none; }
.layers-menu summary::after { content: " ▾"; color: var(--ink-3); }
.layers-menu[open] summary { color: var(--ink); border-color: var(--accent); }
.layer-list {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 10; min-width: 250px; background: var(--surface);
  border: 1px solid var(--rule); border-radius: 10px; box-shadow: var(--shadow); padding: 6px;
}
.layer-list label { display: grid; grid-template-columns: 16px 12px 1fr auto; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 7px; cursor: pointer; font-size: 13px; color: var(--ink); }
.layer-list label:hover { background: var(--surface-2); }
.layer-list input { accent-color: var(--accent); margin: 0; }
.layer-list .sw { width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.4); }
.layer-list .sw.zone { border-radius: 2px; }
.layer-list .ct { color: var(--ink-3); font-family: "JetBrains Mono", monospace; font-size: 11px; }
/* Only the key landmarks are labelled when zoomed out; everything else labels at zoom 11+. */
.spot-label.minor { display: none; }
.show-minor-labels .spot-label.minor { display: block; }

.loading {
  position: absolute; inset: 0; z-index: 600; display: grid; place-items: center; background: rgba(8, 18, 31, 0.55);
  color: #e8eef5; font-size: 15px; pointer-events: none; transition: opacity 0.4s;
}
.loading.done { opacity: 0; }
@media (max-width: 1100px) {
  .readout { display: none; }
}
@media (max-width: 900px) {
  .legend { bottom: 22px; }
  .map-ui { top: 8px; left: 8px; right: 8px; gap: 6px; }
  .seg button { padding: 5px 9px; font-size: 12.5px; }
  .toggles { padding: 5px 10px; font-size: 12px; gap: 3px 10px; }
}

/* Leaflet theming */
.leaflet-container { font-family: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.leaflet-popup-content { margin: 12px 14px; font-size: 13.5px; line-height: 1.45; }
.leaflet-popup-content h3 { margin: 0 0 4px; font-size: 15px; font-family: "Bricolage Grotesque", sans-serif; }
.leaflet-container a.leaflet-popup-close-button { color: var(--ink-3); }
.leaflet-control-attribution { font-size: 10px; }
.spot-label {
  background: rgba(8, 18, 31, 0.78); color: #e8eef5; border: 0; box-shadow: none; border-radius: 4px;
  font-family: "JetBrains Mono", Menlo, monospace; font-size: 10.5px; padding: 1px 5px;
}
.spot-label::before { display: none; }
.iso-label { background: transparent; border: 0; box-shadow: none; color: #fff; font: 500 10px "JetBrains Mono", monospace; text-shadow: 0 0 3px #000; padding: 0; }
.iso-label::before { display: none; }
.mx-note { color: var(--fair); }
.hot-pin {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font: 700 13px "Instrument Sans", sans-serif;
  color: #1b1200; background: var(--gold); border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
.hot-pin.top { background: #ff6b5b; color: #fff; width: 32px; height: 32px; font-size: 14px; }

/* ---------- panel cards ---------- */
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: 14px; padding: 16px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.eyebrow { color: var(--accent-ink); margin: 0 0 8px; display: flex; align-items: center; gap: 7px; }
.eyebrow .muted { text-transform: none; letter-spacing: 0; font-family: "Instrument Sans", sans-serif; font-size: 12px; margin-left: auto; }
.ai-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.briefing h1 { margin-bottom: 8px; }
.briefing #b-summary { color: var(--ink-2); }
.species-list { display: grid; gap: 8px; margin: 12px 0; }
.sp {
  display: grid; gap: 2px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--rule);
  cursor: pointer; text-align: left; width: 100%;
}
.sp:hover { border-color: var(--accent); }
.sp-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sp-name { font-weight: 600; }
.pill { font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 99px; border: 1px solid currentColor; }
.pill.Poor { color: var(--poor); } .pill.Fair { color: var(--fair); } .pill.Good { color: var(--good); } .pill.Great { color: var(--great); }
.sp-where { font-size: 13.5px; }
.sp-why { font-size: 12.5px; color: var(--ink-3); }
.boating { font-size: 13.5px; color: var(--ink-2); border-top: 1px solid var(--rule); padding-top: 10px; margin: 0; }
.skeleton { color: var(--ink-3); }

.port-pick { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-3); margin-bottom: 10px; }
.port-pick select {
  flex: 1; font: inherit; font-size: 13.5px; color: var(--ink); background: var(--surface-2); border: 1px solid var(--rule);
  border-radius: 8px; padding: 6px 8px;
}
.hotspots { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.hotspots li button {
  width: 100%; display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; text-align: left;
  background: var(--surface-2); border: 1px solid var(--rule); border-radius: 10px; padding: 8px 10px; cursor: pointer;
}
.hotspots li button:hover { border-color: var(--accent); }
.hotspots .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--gold); color: #1b1200; font-weight: 700; font-size: 12.5px; }
.hotspots .w { font-size: 13.5px; line-height: 1.3; }
.hotspots .d { display: block; font-size: 12px; color: var(--ink-3); font-family: "JetBrains Mono", monospace; }
.hotspots .s { font-family: "Bricolage Grotesque", sans-serif; font-weight: 700; font-size: 18px; }
.hotspots .empty { color: var(--ink-3); font-size: 13.5px; padding: 6px 2px; }

.reports { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.reports li button {
  width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; text-align: left;
  background: var(--surface-2); border: 1px solid var(--rule); border-radius: 10px; padding: 8px 10px; cursor: pointer;
}
.reports li button:hover { border-color: var(--accent); }
.reports .rsp { font-weight: 600; font-size: 14px; }
.reports .when { font-size: 12px; color: var(--ink-3); text-align: right; }
.reports .where { grid-column: 1 / -1; font-size: 13px; color: var(--ink-2); }
.reports .note { grid-column: 1 / -1; font-size: 12.5px; color: var(--ink-3); }
.report-pin {
  min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px; display: grid; place-items: center;
  font: 700 12px "Instrument Sans", sans-serif; color: #04201d; background: var(--accent); border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45); white-space: nowrap;
}

.table-wrap { overflow-x: auto; }
.buoys { width: 100%; border-collapse: collapse; font-size: 13px; }
.buoys th { text-align: left; color: var(--ink-3); font-weight: 400; padding: 0 6px 6px 0; }
.buoys td { padding: 6px 6px 6px 0; border-top: 1px solid var(--rule); white-space: nowrap; }
.buoys td:first-child { white-space: normal; }
.buoys .id { display: block; color: var(--ink-3); font-size: 11px; font-family: "JetBrains Mono", monospace; }
.buoys tr { cursor: pointer; }
.buoys tr:hover td { background: var(--surface-2); }
.swatch { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: 0; }

.zone-label { font-size: 12.5px; color: var(--ink-3); margin: 8px 0; }
.advisory { background: color-mix(in srgb, var(--poor) 16%, transparent); color: var(--ink); border-left: 3px solid var(--poor); padding: 6px 10px; border-radius: 6px; font-size: 13px; margin-bottom: 8px; }
.forecast { margin: 0; display: grid; gap: 8px; }
.forecast dt { font-weight: 600; font-size: 13px; }
.forecast dd { margin: 0; font-size: 13px; color: var(--ink-2); }

.moon-card { display: flex; gap: 14px; align-items: center; }
.moon { width: 44px; height: 44px; flex: none; }
.moon-card p { margin: 2px 0 0; }

.about p { font-size: 13.5px; color: var(--ink-2); }
.about h2 { margin-bottom: 8px; }
.foot { color: var(--ink-3); font-size: 12.5px; padding: 4px 4px 10px; }
.foot p { margin: 0 0 6px; }
