:root {
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --text: #f2f2f0;
  --muted: #9a9ca3;
  --dim: #5c5f66;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; color: var(--text); }
body { font: 18px/1.35 var(--mono); overflow: hidden; -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none; touch-action: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

/* ---------- map ---------- */
#stage { position: fixed; inset: 0; overflow: hidden; background: #000; }
#flow { position: absolute; inset: 0; width: 100%; height: 100%; }
#coast { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#coast[hidden] { display: none; }
/* the open ocean fades into the frame edges */
.vignette { position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(90deg, #000 0, rgba(0,0,0,0) 9%),
    linear-gradient(0deg, #000 0, rgba(0,0,0,0) 10%),
    linear-gradient(180deg, #000 0, rgba(0,0,0,0) 4%); }
#labels { position: absolute; inset: 0; pointer-events: none; }
#winds { position: absolute; inset: 0; pointer-events: none; }
.wind-marker { position: absolute; width: 0; height: 0; }
.wind-marker[hidden], .wind-marker span[hidden] { display: none; }
.wind-marker svg { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); overflow: visible; filter: drop-shadow(0 0 2px #000); }
/* wind arrows stand out from the streaks: solid white on a dark casing */
.wind-marker .arrow line { stroke: #fff; stroke-width: 3; stroke-linecap: round; }
.wind-marker .arrow path { fill: #fff; stroke: #fff; stroke-width: 1; stroke-linejoin: round; }
.wind-marker .casing line { stroke: #000; stroke-width: 7; stroke-linecap: round; }
.wind-marker .casing path { fill: #000; stroke: #000; stroke-width: 4; stroke-linejoin: round; }
.wind-marker span { position: absolute; left: 10px; top: 12px; font: 500 13px/1 var(--mono); color: #fff; white-space: nowrap; text-shadow: 0 0 3px #000, 0 0 3px #000, 0 0 8px #000; }
.place { position: absolute; display: flex; align-items: center; gap: 0.55em; white-space: nowrap;
  font: 500 17px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: #e8e8e8;
  text-shadow: 0 0 4px #000, 0 0 8px #000; transform: translate(-0.3em, -50%); }
.place::before { content: ""; width: 0.42em; height: 0.42em; border-radius: 50%; background: #fff; flex: none; }
.place.left { flex-direction: row-reverse; transform: translate(calc(-100% + 0.3em), -50%); }
/* town name hung below its dot, its right end --dx past the dot (TOWN_DOWN_OVERHANG_EM in app.js); the dot stays on the place */
.place.left.down { display: block; transform: translate(calc(-100% + var(--dx, 0.3em)), 0.45em); }
.place.left.down::before { position: absolute; right: calc(var(--dx, 0.3em) - 0.21em); top: calc(-0.45em - 0.21em); }
.place.small { font-size: 15px; }
.place[hidden] { display: none; }
.place.marina { font-size: 14px; font-weight: 400; letter-spacing: 0.05em; color: #d7dde5; gap: 0.5em; }
.place.marina.nolabel { font-size: 0; gap: 0; transform: translate(-3.5px, -50%); }
.place.marina.up { transform: translate(-0.3em, -135%); }
.place.marina.down { transform: translate(-0.3em, 35%); }
.place.marina.left.up { transform: translate(calc(-100% + 0.3em), -135%); }
.place.marina.left.down { transform: translate(calc(-100% + 0.3em), 35%); }
.place.marina::before { width: 7px; height: 7px; background: transparent; border: 1.5px solid #fff; box-sizing: border-box; }
/* marina name left of its ring and lowered: text top 0.1em below the pin, right end 0.5em left of it; the ring stays centred on the pin */
.place.marina.left.lower { display: block; transform: translate(calc(-100% - 0.5em), 0.1em); }
.place.marina.left.lower::before { position: absolute; right: calc(-0.5em - 3.5px); top: calc(-0.1em - 3.5px); }
.loading { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: var(--muted); font-size: 18px; letter-spacing: 0.08em; text-transform: uppercase; }
.loading[hidden] { display: none; }

/* ---------- title block ---------- */
.titleblock { transform-origin: right top; text-shadow: 0 0 6px #000, 0 0 12px #000; position: fixed; z-index: 5; right: 5vw; top: 50%; transform: translateY(-50%); width: min(34vw, 470px); }
.when { display: flex; flex-direction: row-reverse; align-items: baseline; justify-content: space-between; /* date right-justified, NOW at the left */ font-size: clamp(18px, 1.45vw, 26px); letter-spacing: 0.06em; margin-bottom: 0.5em; }
.now-btn { font: 500 14px/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: #f2c14e; padding: 8px 12px 8px 2px; }
.now-btn[hidden] { display: none; }
/* time control: one slim pill; play/pause sits in its left end, the whole pill is the touch target */
.player { display: flex; align-items: center; height: 48px; border-radius: 24px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); padding-right: 20px; }
.play { width: 48px; height: 48px; flex: none; display: grid; place-items: center; border-radius: 24px; touch-action: manipulation; }
.play svg { width: 16px; height: 16px; fill: #f2f2f0; }
.play:active { background: rgba(255,255,255,.1); }
.bar { position: relative; flex: 1; height: 48px; cursor: pointer; touch-action: none; }
.bar-track { position: absolute; left: 0; right: 0; top: 50%; height: 4px; margin-top: -2px; border-radius: 2px; background: rgba(255,255,255,.16); }
.bar-fill { position: absolute; left: 0; top: 50%; height: 4px; margin-top: -2px; border-radius: 2px; background: #f2f2f0; }
.bar-ticks span { position: absolute; top: 50%; height: 12px; margin: -6px 0 0 -0.5px; width: 1px; background: rgba(255,255,255,.35); }
.bar-ticks span.minor { height: 6px; margin-top: -3px; background: rgba(255,255,255,.2); }
.bar-now { position: absolute; top: 50%; width: 2px; height: 16px; margin: -8px 0 0 -1px; border-radius: 1px; background: #f2c14e; }
.bar-knob { position: absolute; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px rgba(255,255,255,.12), 0 1px 4px rgba(0,0,0,.6); }
.bar-labels { position: relative; height: 1.4em; font-size: 15px; color: var(--muted); letter-spacing: 0.06em; margin: 6px 20px 0 48px; text-transform: uppercase; }
.bar-labels span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.cap { font-size: 15px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 1.6em 0 0.5em; }
.ramp { height: 6px; border-radius: 3px; }
.ramp-ticks { position: relative; height: 1.4em; font-size: 16px; margin-top: 0.35em; }
.ramp-ticks span { position: absolute; transform: translateX(-50%); }
.ramp-ticks span:first-child { transform: none; }
.ramp-ticks span:last-child { transform: translateX(-100%); }
.readout { display: grid; grid-template-columns: auto 1fr; gap: 0.35em 1.2em; margin: 2em 0 0; font-size: 18px; }
.readout dt { color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.readout dd { margin: 0; text-align: right; white-space: nowrap; }
.g-head { gap: 0.8em; display: flex; justify-content: space-between; align-items: baseline; margin-top: 1.6em; }
.g-head .cap { margin: 0 0 0.4em; white-space: nowrap; }
.graph { background: rgba(0,0,0,.72); border-radius: 4px; display: block; width: 100%; height: clamp(130px, 16vh, 210px); overflow: visible; font-family: var(--mono); }
.graph .grid { stroke: rgba(255,255,255,.09); stroke-width: 1; }
.graph .msl { stroke: rgba(255,255,255,.28); stroke-width: 1; stroke-dasharray: 3 4; }
.graph .axis { fill: var(--muted); font-size: 14px; }
.graph .curve { fill: none; stroke: #7cc4f0; stroke-width: 2.5; }
.graph .area { fill: rgba(124,196,240,.14); }
.graph .hl { fill: #fff; }
.graph .hl-label { fill: #e8e8e8; font-size: 14px; }
.wind-graph { height: clamp(110px, 13vh, 170px); }
.graph .wind { fill: none; stroke: #e8e8e8; stroke-width: 2.2; }
.graph .gust { fill: none; stroke: rgba(232,232,232,.55); stroke-width: 1.4; stroke-dasharray: 4 3; }
.graph .arrow { fill: #cfd3da; }
.graph .rain { fill: #5aa8e8; }
.graph .rain-zero { fill: rgba(90,168,232,.18); }
.graph .lbl { fill: #e8e8e8; font-size: 14px; }
.graph .now { stroke: rgba(255,255,255,.5); stroke-width: 1; stroke-dasharray: 2 3; }
.graph .sel { stroke: #f2c14e; stroke-width: 2; }
.graph .sel-dot { fill: #f2c14e; stroke: #000; stroke-width: 2; }
.graph .sel-label { fill: #f2c14e; font-size: 15px; font-weight: 500; }

/* ---------- corners ---------- */
.speed-legend { position: fixed; z-index: 5; left: 24px; bottom: 22px; width: min(22vw, 320px); text-shadow: 0 0 6px #000, 0 0 12px #000; }
.speed-legend .cap { margin-top: 0; }
.status { position: fixed; z-index: 5; left: 18px; top: 14px; text-shadow: 0 0 4px #000; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--dim); letter-spacing: 0.06em; text-transform: uppercase; }
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.status.ok .dot { background: #5bd38b; }
.status.warn .dot { background: #f0b33c; }
.status.warn .text { color: #c9a35a; }
.status.bad .dot { background: #f05a4f; }
.status.bad .text { color: #d0756e; }

/* ---------- folding left navigation ---------- */
.nav-toggle { position: fixed; z-index: 30; left: 8px; top: 6px; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 22px; touch-action: manipulation; }
.nav-toggle svg { width: 20px; height: 20px; fill: #f2f2f0; filter: drop-shadow(0 0 3px #000); }
.nav-toggle:active { background: rgba(255,255,255,.1); }
.nav-panel { position: fixed; z-index: 25; left: 0; top: 0; bottom: 0; width: 260px; padding: 64px 0 24px; background: rgba(12,13,16,.97); border-right: 1px solid rgba(255,255,255,.1);
  display: flex; flex-direction: column; transform: translateX(-100%); transition: transform .22s ease; visibility: hidden; }
.nav[data-open="true"] .nav-panel { transform: none; visibility: visible; }
.nav-scrim { position: fixed; z-index: 24; inset: 0; background: rgba(0,0,0,.45); display: none; }
.nav[data-open="true"] .nav-scrim { display: block; }
.nav-item { text-align: left; padding: 15px 28px; font: 500 18px/1.2 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: #d7dde5; border-left: 3px solid transparent; }
.nav-item:active { background: rgba(255,255,255,.06); }
.nav-item[aria-current="page"] { color: #f2c14e; border-left-color: #f2c14e; }
.nav-item.nav-sub { padding: 10px 28px 12px 52px; font-size: 16px; letter-spacing: 0.08em; }
/* the status line sits to the right of the menu button */
.status { left: 62px; top: 20px; }

/* ---------- icons ---------- */
.ic { width: 1.35em; height: 1.35em; flex: none; vertical-align: -0.3em; margin-right: 0.5em; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.ic .i-sun { stroke: #f2c14e; }
.ic .i-cloud { stroke: #cfd3da; fill: #000; }
.ic .i-drop { stroke: #5aa8e8; stroke-width: 1.9; }
.ic.wind { stroke-width: 2; }
.ic.w-light { stroke: #9a9ca3; } .ic.w-fresh { stroke: #7cc4f0; } .ic.w-strong { stroke: #f2c14e; } .ic.w-gale { stroke: #f05a4f; }
.nav-item { display: flex; align-items: center; }
.nav-ic { width: 22px; height: 22px; margin-right: 14px; stroke-width: 1.5; }
.nav-item.nav-sub .nav-ic { width: 18px; height: 18px; }
/* the start view choice sits at the foot of the menu */
.start-on { margin-top: auto; padding: 18px 24px 4px; border-top: 1px solid rgba(255,255,255,.1); }
.start-on .cap { margin: 0 0 10px; }
.start-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.start-choice { font: 500 14px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: #d7dde5; padding: 10px 12px; border-radius: 18px; border: 1px solid rgba(255,255,255,.2); touch-action: manipulation; }
.start-choice[aria-pressed="true"] { color: #f2c14e; border-color: #f2c14e; }
.wind-strip { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin: 4px 0 10px; text-align: center; }
.ws-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.ws-cell .ic { margin: 0; width: 26px; height: 26px; }
.ws-time { color: var(--muted); font-size: 14px; }
.ws-kt { font-size: 16px; }
.ws-gust { color: var(--muted); font-size: 13px; min-height: 1.1em; }
.wind-key { display: flex; flex-wrap: wrap; gap: 0.4em 1.6em; margin: 0 auto 1em; color: var(--muted); font-size: 15px; }
.wind-key span { display: inline-flex; align-items: center; }
.d-cond, .d-wind, .h-sky, .h-wind { display: inline-flex; align-items: center; white-space: nowrap; }

/* ---------- views ---------- */
/* data-kind: live, map (Map and Coastline) or page */
body[data-kind="map"] .titleblock { display: none; }
body[data-kind="page"] .titleblock,
body[data-kind="page"] .speed-legend { display: none; }
.page { position: fixed; z-index: 10; inset: 0; overflow-y: auto; background: #000; padding: 72px max(4vw, 20px) 64px; display: none; touch-action: pan-y; -webkit-overflow-scrolling: touch; user-select: text; -webkit-user-select: text; }
body[data-kind="page"] .page { display: block; }
.page > * { max-width: 1100px; margin-left: auto; margin-right: auto; }
.page-head h1 { font: 500 26px/1.2 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; margin: 0 0 0.3em; }
.page-head h1 { display: flex; align-items: center; }
.title-ic { width: 30px; height: 30px; margin-right: 14px; stroke-width: 1.5; }
.page-sub { margin: 0 0 1.6em; color: var(--muted); font-size: 16px; }
.section-cap { margin: 1.6em auto 0.6em; font-weight: 400; }
.dim { color: var(--muted); }
.d-src { color: var(--dim); font-size: 14px; letter-spacing: 0.04em; }
.days { border-top: 1px solid rgba(255,255,255,.1); }
.day { border-bottom: 1px solid rgba(255,255,255,.1); }
.day-row { width: 100%; display: grid; grid-template-columns: 9em 1fr 7em 9em 13em 7em 1.2em; gap: 0.8em; align-items: center; text-align: left; padding: 16px 4px; }
.day-row:active { background: rgba(255,255,255,.05); }
.d-name { font-weight: 500; letter-spacing: 0.04em; }
.d-temp, .d-rain, .d-wind { white-space: nowrap; }
.d-fold::after { content: "▸"; color: var(--muted); }
.day.open .d-fold::after { content: "▾"; }
.hourly { padding: 0 4px 18px; }
.hourly .cap { margin: 0.2em 0 0.6em; }
.hour-grid { display: grid; grid-template-columns: 6em 4em 10em 9em 14em; justify-content: start; gap: 0.35em 1.4em; font-size: 16px; }
.hour-grid .hh { color: var(--muted); font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; }
.cards { display: grid; gap: 22px; }
.card-head { display: flex; flex-wrap: wrap; gap: 0.4em 1.4em; align-items: baseline; margin-bottom: 8px; }
.hl-list { display: flex; flex-wrap: wrap; gap: 0.3em 1.2em; }
.hl-item { white-space: nowrap; }
.page-graph.tide-graph { height: 200px; }
.page-graph.wind-graph { height: 170px; }
.page-graph.rain-graph { height: 120px; }
.rain-days { height: 220px; margin-bottom: 26px; }
.measured { display: grid; grid-template-columns: auto auto 1fr; gap: 0.35em 1.4em; }
.m-name { color: var(--muted); }

/* ---------- portrait screens (not phones): the reel's own layout ---------- */
@media (max-aspect-ratio: 1/1) and (min-width: 761px) {
  .titleblock { right: 4vw; top: 42%; transform: none; width: 44vw; }
  .when { font-size: clamp(12px, 3.1vw, 24px); white-space: nowrap; }
  .player { height: 44px; padding-right: 14px; }
  .play, .bar { height: 44px; }
  .play { width: 44px; }
  .bar-labels { margin: 4px 14px 0 44px; }
  .now-btn { font-size: 11px; }
  .cap, .bar-labels { font-size: clamp(9px, 2.4vw, 15px); }
  .cap { margin-top: 1.2em; }
  .ramp-ticks { font-size: clamp(11px, 2.8vw, 16px); }
  .readout { font-size: clamp(11px, 2.8vw, 18px); grid-template-columns: auto auto; gap: 0.3em 0.8em; margin-top: 1.4em; }
  .readout dd, .readout dt { white-space: nowrap; }
  .readout dt { letter-spacing: 0.02em; }
  .titleblock { width: 45vw; right: 3vw; }
  .readout { font-size: clamp(9px, 2.3vw, 18px); }
  .tide-graph { height: clamp(80px, 13vh, 200px); }
  .wind-graph { height: clamp(70px, 10vh, 160px); }
  .graph .axis, .graph .hl-label, .graph .lbl { font-size: 9px; }
  .g-head { margin-top: 0.8em; }
  .titleblock { transform-origin: right top; }
  .place { font-size: clamp(10px, 2.7vw, 17px); }
  .place.small { font-size: clamp(9px, 2.4vw, 15px); }
  .place.marina { font-size: clamp(8px, 2.1vw, 14px); }
    .status { font-size: 10px; }
  .speed-legend { left: 12px; bottom: 12px; width: 40vw; }
}

/* ---------- phones: map on top, the title block's data underneath ----------
   Must match PHONE_QUERY in app.js. The page scrolls; the map keeps its own
   pan and pinch. Map overlays keep the sizes each phone shape had before. */
@media (max-width: 760px), (pointer: coarse) and (max-height: 500px) {
  :root { --phone-map-h: min(72svh, 135vw); }
  html, body { height: auto; }
  body { overflow-x: hidden; overflow-y: auto; touch-action: pan-y; }
  #stage { position: relative; height: var(--phone-map-h); touch-action: none; }
  .titleblock { position: static; transform: none; width: auto; padding: 18px 16px 32px; }
  .status { position: absolute; }
  .speed-legend { position: absolute; bottom: auto; top: calc(var(--phone-map-h) - 22px); transform: translateY(-100%); }
  /* full width under the map: tall enough that the axis labels do not crowd */
  .tide-graph { height: 190px; }
  .wind-graph { height: 160px; }
}
/* upright phones: the overlay sizes the portrait layout gave them */
@media (max-width: 760px) {
  .status { font-size: 10px; }
  .speed-legend { left: 12px; top: calc(var(--phone-map-h) - 12px); width: 40vw; }
  .speed-legend .cap { font-size: clamp(9px, 2.4vw, 15px); }
  .speed-legend .ramp-ticks { font-size: clamp(11px, 2.8vw, 16px); }
  .place { font-size: clamp(10px, 2.7vw, 17px); }
  .place.small { font-size: clamp(9px, 2.4vw, 15px); }
  .place.marina { font-size: clamp(8px, 2.1vw, 14px); }
}
/* phone held sideways: a strip of the data shows below the map so there is somewhere to scroll from */
@media (pointer: coarse) and (max-height: 500px) {
  :root { --phone-map-h: 82svh; }
}

/* pages on phones: the day row stacks into two lines */
@media (max-width: 760px) {
  .page { padding: 64px 16px 48px; }
  .day-row { grid-template-columns: 1fr auto 1.2em; grid-template-areas: "name temp fold" "cond rain fold" "wind src fold"; gap: 0.25em 0.8em; }
  .day-row .d-name { grid-area: name; } .day-row .d-temp { grid-area: temp; text-align: right; }
  .day-row .d-cond { grid-area: cond; color: var(--muted); } .day-row .d-rain { grid-area: rain; text-align: right; }
  .day-row .d-wind { grid-area: wind; } .day-row .d-src { grid-area: src; text-align: right; }
  .day-row .d-fold { grid-area: fold; align-self: center; }
  /* one hour = time, temp, sky, rain on a line, the wind under them */
  .hour-grid { grid-template-columns: 4.2em 2.8em 1fr auto; gap: 0.1em 0.7em; font-size: 15px; }
  .hour-grid .hh { display: none; }
  .hour-grid > :nth-child(5n+4) { text-align: right; }
  .hour-grid > :nth-child(5n+5) { grid-column: 2 / -1; color: var(--muted); margin-bottom: 0.45em; }
  .measured { grid-template-columns: 1fr auto; } .measured .dim { grid-column: 1 / -1; margin-top: -0.3em; font-size: 14px; }
  .page-graph.tide-graph { height: 190px; }
}
/* Map view on a phone: the whole screen is map */
@media (max-width: 760px), (pointer: coarse) and (max-height: 500px) {
  body[data-kind="map"] { --phone-map-h: 100svh; }
  body[data-kind="map"] #stage { height: 100svh; }
}
