:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #14212e;
  --muted: #5f6f7f;
  --line: #dde3ea;
  --navy: #0d2a44;
  --navy-2: #173e61;
  --sea: #2b7fb8;
  --sea-soft: rgba(43, 127, 184, 0.16);
  --night: rgba(13, 42, 68, 0.07);
  --hi: #1d6fa5;
  --lo: #b5651d;
  --alert: #fff3d6;
  --alert-ink: #7a4b00;
  --moon-lit: #f4e9c1;
  --moon-dark: #2a3848;
  --moon-rim: #8494a5;
  --radius: 14px;
  --icon-sun: #f5b83d;
  --icon-moon: #e6d9a8;
  --icon-cloud: #b4c2d0;
  --icon-cloud-dark: #8193a6;
  --icon-rain: #3f93dc;
  --icon-snow: #9cc9ee;
  --wind: #2f8f6f;
  --gust: rgba(47, 143, 111, 0.18);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1520;
    --card: #122030;
    --ink: #e6edf3;
    --muted: #93a4b5;
    --line: #22354a;
    --sea: #5cb0e6;
    --sea-soft: rgba(92, 176, 230, 0.18);
    --night: rgba(0, 0, 0, 0.25);
    --hi: #6cc0f5;
    --lo: #f0a45c;
    --alert: #3a2c0c;
    --alert-ink: #ffd88a;
    --moon-dark: #0b1520;
    --icon-cloud: #cdd7e1;
    --icon-cloud-dark: #8797a8;
    --wind: #5fd0a8;
    --gust: rgba(95, 208, 168, 0.18);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

a { color: var(--sea); }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }

/* header */
.site-header {
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  color: #fff;
  padding: 22px 0 18px;
}
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.brand h1 { margin: 0; font-size: 1.7rem; letter-spacing: -0.01em; }
.brand .sub { margin: 2px 0 0; opacity: 0.75; }
.now { display: flex; flex-wrap: wrap; gap: 10px; }
.now-item {
  display: flex; flex-direction: column;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px; padding: 8px 14px; min-width: 150px;
}
.now-big { font-size: 1.25rem; font-weight: 600; }
.now-sub { font-size: 0.82rem; opacity: 0.8; }
.now-src { font-size: 0.68rem; opacity: 0.6; margin-top: 1px; }

/* day nav */
.day-nav {
  position: sticky; top: 0; z-index: 5;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.day-nav .wrap { display: flex; gap: 4px; overflow-x: auto; padding-top: 6px; padding-bottom: 6px; }
.day-nav a {
  flex: 1 0 auto; min-width: 72px;
  display: flex; flex-direction: column; align-items: center;
  padding: 4px 8px; border-radius: 8px;
  text-decoration: none; color: var(--ink); font-size: 0.85rem;
}
.day-nav a:hover { background: var(--sea-soft); }
.nav-icon { height: 28px; display: flex; align-items: center; }
.wx-icon { flex: none; vertical-align: middle; }
.now-big .wx-icon, .now-big .arrow { vertical-align: -4px; }
.now-big small { font-size: 0.8rem; font-weight: 500; opacity: 0.85; }
.now-sub b { font-weight: 700; }
.chip .wx-icon { margin: -2px 0; }
.nav-temp { font-weight: 600; }
.nav-temp small { font-weight: 400; color: var(--muted); margin-left: 4px; }

/* alerts */
#alerts { margin-top: 16px; }
.alert {
  background: var(--alert); color: var(--alert-ink);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; font-weight: 600;
}
.alert summary { cursor: pointer; }
.alert-until { font-weight: 400; opacity: 0.85; }
.alert p { font-weight: 400; margin: 8px 0 0; }
.alert.sev-severe, .alert.sev-extreme { background: #ffe1dc; color: #8a1c0c; }
.alert.stale { background: var(--card); color: var(--muted); border: 1px dashed var(--line); font-weight: 400; }
@media (prefers-color-scheme: dark) {
  .alert.sev-severe, .alert.sev-extreme { background: #4a1810; color: #ffc2b5; }
}
.synopsis {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 14px; margin: 12px 0 0;
}
.synopsis summary { cursor: pointer; font-weight: 600; }
.synopsis p { margin: 8px 0 0; color: var(--muted); }

/* day cards */
.days { display: flex; flex-direction: column; gap: 18px; margin: 18px 0; }
.loading { color: var(--muted); text-align: center; padding: 40px; }
.day {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  scroll-margin-top: 80px;
  overflow: hidden;
}
.day-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.day-head h2 { margin: 0; font-size: 1.3rem; }
.day-date { color: var(--muted); font-size: 0.9rem; }
.day-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--sea-soft); border-radius: 999px;
  padding: 3px 10px; font-size: 0.85rem;
}
.moon-chip svg { width: 16px; height: 16px; }

.panels { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.panel { padding: 14px 18px 16px; border-right: 1px solid var(--line); }
.panel:last-child { border-right: 0; }
.panel h3 {
  margin: 0 0 10px; font-size: 0.75rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted);
}
.muted { color: var(--muted); }

@media (max-width: 1050px) {
  .panels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel:nth-child(2) { border-right: 0; }
  .panel:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 640px) {
  .panels { grid-template-columns: 1fr; }
  .panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .panel:last-child { border-bottom: 0; }
  .brand h1 { font-size: 1.4rem; }
  .now-item { min-width: 0; flex: 1 1 40%; padding: 7px 10px; }
  .now-big { font-size: 1.05rem; }
}

/* tides */
.tide-chart { width: 100%; height: 110px; display: block; }
.tide-chart .night { fill: var(--night); }
.tide-area { fill: var(--sea-soft); }
.tide-line { fill: none; stroke: var(--sea); stroke-width: 2; vector-effect: non-scaling-stroke; }
.tide-dot.hi { fill: var(--hi); }
.tide-dot.lo { fill: var(--lo); }
.tide-label { font-size: 10px; fill: var(--ink); text-anchor: middle; font-weight: 600; }
.tick { stroke: var(--line); }
.now-line { stroke: #d33; stroke-width: 1.5; stroke-dasharray: 3 2; vector-effect: non-scaling-stroke; }
.tide-list { list-style: none; margin: 10px 0 0; padding: 0; }
.tide-list li {
  display: grid; grid-template-columns: 3.2em 1fr auto 5.6em; gap: 6px; align-items: center;
  padding: 3px 0; border-bottom: 1px dashed var(--line);
}
.tide-list li:last-child { border-bottom: 0; }
.tide-list .tide-type { font-weight: 700; }
.tide-list .hi .tide-type { color: var(--hi); }
.tide-list .lo .tide-type { color: var(--lo); }
.tide-list .tide-ht { color: var(--muted); font-variant-numeric: tabular-nums; }
.tide-list .tide-time { font-variant-numeric: tabular-nums; }
.tide-list .past { opacity: 0.45; }
.tide-size { font-size: 0.72rem; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.size-bar { display: block; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.size-bar i { display: block; height: 100%; }
.hi .size-bar i { background: var(--hi); }
.lo .size-bar i { background: var(--lo); }
.tide-day { font-size: 0.88rem; margin-bottom: 8px; padding-left: 8px; border-left: 3px solid var(--line); }
.tide-day .muted { font-size: 0.8rem; }
.tide-day.spring { border-left-color: var(--sea); }
.tide-day.neap { border-left-color: var(--muted); }
.tide-context { font-size: 0.78rem; color: var(--muted); margin: 10px 0 0; }
.tide-context .fine { display: block; margin-top: 3px; font-style: italic; }

/* marine */
.marine-period + .marine-period { margin-top: 10px; }
.marine-label { font-weight: 700; font-size: 0.85rem; }
.marine-period p { margin: 2px 0 0; font-size: 0.9rem; }
.marine-period strong { color: var(--sea); font-weight: 600; }

/* weather */
.wx-period + .wx-period { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.wx-head { display: flex; gap: 10px; align-items: center; }
.wx-name { font-weight: 700; }
.wx-temp { font-size: 1.1rem; margin-left: 4px; }
.wx-temp.hi { color: var(--lo); }
.wx-temp.lo { color: var(--hi); }
.wx-short { color: var(--muted); font-size: 0.88rem; }
.wx-meta { font-size: 0.85rem; margin-top: 4px; }
.wx-detail { font-size: 0.85rem; color: var(--muted); margin: 4px 0 0; }

/* sun & moon */
.sm-row { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; font-size: 0.92rem; }
.sm-row.muted { font-size: 0.84rem; }
.moon-block { display: flex; gap: 12px; align-items: center; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.moon-block .muted { font-size: 0.84rem; }
.moon-name { font-weight: 700; }
.badge {
  background: var(--sea); color: #fff; border-radius: 999px;
  font-size: 0.7rem; padding: 1px 7px; vertical-align: middle; font-weight: 600;
}

/* footer */
.site-footer { color: var(--muted); font-size: 0.82rem; padding-bottom: 30px; }
.site-footer .fine { font-style: italic; }

/* shared sub-headings inside panels */
.sub-h { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.fine { font-size: 0.72rem; color: var(--muted); font-style: italic; }

/* wind chart */
.wind { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px dashed var(--line); }
.wind-chart { width: 100%; height: 92px; display: block; }
.wind-chart .grid { stroke: var(--line); stroke-dasharray: 2 3; vector-effect: non-scaling-stroke; }
.wind-chart .grid-label { font-size: 8px; fill: var(--muted); }
.gust-area { fill: var(--gust); }
.wind-line { fill: none; stroke: var(--wind); stroke-width: 2; vector-effect: non-scaling-stroke; }
.wind-arrow { fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.wind-sum { font-size: 0.84rem; margin-top: 4px; }

/* currents */
.currents { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.cur-station + .cur-station { margin-top: 8px; }
.cur-name { font-weight: 600; font-size: 0.84rem; }
.cur-list { list-style: none; margin: 3px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.cur-list li { font-size: 0.78rem; background: var(--sea-soft); border-radius: 6px; padding: 1px 6px; font-variant-numeric: tabular-nums; }
.cur-list li.slack { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.cur-list li.past { opacity: 0.45; }
.cur-t { font-weight: 600; margin-right: 4px; }
.currents .fine { margin: 6px 0 0; }

/* sea state (broken out of the marine forecast text) */
.sea-state { display: flex; gap: 12px; align-items: stretch; margin: 6px 0; padding: 8px 10px; background: var(--sea-soft); border-radius: 10px; }
.seas { display: flex; flex-direction: column; justify-content: center; min-width: 4.2em; }
.seas-num { font-size: 1.25rem; font-weight: 700; color: var(--sea); line-height: 1.1; white-space: nowrap; }
.seas-lbl { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.waves { list-style: none; margin: 0; padding: 0 0 0 12px; border-left: 1px solid var(--line); display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.waves li { display: flex; align-items: center; gap: 5px; white-space: nowrap; font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.waves .arrow { color: var(--sea); }
.w-dir { font-weight: 700; min-width: 1.6em; }
.w-ht { font-weight: 600; }
.w-per { color: var(--muted); }
.w-kind { color: var(--muted); font-size: 0.72rem; font-style: italic; }

/* data source map */
.sources { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 0 0 18px; scroll-margin-top: 80px; }
.sources h2 { margin: 0 0 12px; font-size: 1.2rem; }
.source-map { height: 440px; border-radius: 10px; z-index: 0; }
.pin span, .pin-dot {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  color: #fff; font-weight: 700; font-size: 12px;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
.pin-dot { flex: none; width: 22px; height: 22px; font-size: 11px; box-shadow: none; border-color: var(--card); }
.pin-dot.zone { background: repeating-linear-gradient(45deg, rgba(232, 89, 12, 0.55) 0 2px, transparent 2px 6px); border: 2px solid #e8590c; border-radius: 4px; }
.source-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px 18px; font-size: 0.88rem; }
.source-list li { display: flex; gap: 10px; align-items: flex-start; }
.source-list .muted { font-size: 0.8rem; }
@media (max-width: 640px) { .source-map { height: 340px; } }

.cur-key { font-size: 0.74rem; color: var(--muted); margin-top: 1px; }
.cur-key .arrow, .cur-list .arrow { vertical-align: -1px; }

/* footer: currents explainer */
.currents-explained { margin: 14px 0; scroll-margin-top: 80px; }
.currents-explained h3 { font-size: 0.85rem; margin: 0 0 6px; color: var(--ink); }
.currents-explained table { border-collapse: collapse; font-size: 0.8rem; }
.currents-explained th, .currents-explained td { text-align: left; padding: 4px 14px 4px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.currents-explained thead th { font-weight: 600; color: var(--muted); }
.currents-explained tbody th { color: var(--ink); font-weight: 600; }
.currents-explained p { max-width: 70ch; margin: 6px 0 0; }
@media (max-width: 640px) { .currents-explained table { display: block; overflow-x: auto; } }
