:root { --bg:#fff; --fg:#111; --muted:#666; --accent:#1b6ca8; --line:#ddd; }
@media (prefers-color-scheme: dark) { :root { --bg:#14181c; --fg:#eceff1; --muted:#9aa5ad; --accent:#5aaee6; --line:#2d353c; } }
* { box-sizing:border-box; }
body { margin:0; background:var(--bg); color:var(--fg); font:16px/1.5 -apple-system,Helvetica,Arial,sans-serif; }
:root { --bar-h:52px; }
body { padding-top:var(--bar-h); }
.bar { position:fixed; top:0; left:0; right:0; height:var(--bar-h); z-index:30; display:flex; align-items:center; justify-content:space-between; padding:0 8px 0 16px; background:var(--bg); border-bottom:1px solid var(--line); }
.brand { font-weight:700; color:var(--fg); text-decoration:none; }
main { max-width:720px; margin:0 auto; padding:24px 16px; }
a { color:var(--accent); }
label { display:block; margin:16px 0 6px; }
input[type=email], input[type=text] { width:100%; max-width:360px; font-size:18px; padding:10px; border:1px solid var(--line); border-radius:6px; background:var(--bg); color:var(--fg); }
button { margin-left:8px; font-size:16px; padding:10px 16px; border:0; border-radius:6px; background:var(--accent); color:#fff; cursor:pointer; }
button:disabled { opacity:.6; cursor:default; }
.card { border:1px solid var(--line); border-radius:10px; padding:4px 16px 16px; margin:20px 0; }
.card h2 { margin:12px 0 4px; font-size:20px; }
.card h3 { margin:16px 0 6px; font-size:16px; }
.muted { color:var(--muted); }
.row { display:flex; flex-wrap:wrap; gap:8px; align-items:center; margin:8px 0; }
.row input[type=text] { flex:1 1 140px; min-width:120px; max-width:260px; }
.sub { border-top:1px solid var(--line); margin-top:12px; padding-top:4px; }
.sub > div { margin:8px 0; }
label.inline { display:inline; margin:0; }
select, textarea { font-size:16px; padding:9px; border:1px solid var(--line); border-radius:6px; background:var(--bg); color:var(--fg); }
textarea { width:100%; max-width:480px; margin:8px 0; }
input[size] { width:80px; font-size:16px; padding:8px; border:1px solid var(--line); border-radius:6px; background:var(--bg); color:var(--fg); }
button.secondary { background:transparent; color:var(--accent); border:1px solid var(--accent); }
.flash { min-height:1.5em; }

/* ---- hamburger menu ---- */
.menu-button { margin:0; padding:0; width:44px; height:44px; display:flex; flex-direction:column; justify-content:center; align-items:center; gap:5px; background:transparent; border-radius:8px; }
.menu-button span { display:block; width:22px; height:2px; border-radius:1px; background:var(--fg); }
.menu { position:fixed; top:var(--bar-h); right:0; bottom:0; width:min(280px,85vw); z-index:25; overflow-y:auto; padding:8px 0 24px; background:var(--bg); border-left:1px solid var(--line); transform:translateX(100%); visibility:hidden; transition:transform .2s, visibility 0s .2s; }
.menu.open { transform:none; visibility:visible; transition:transform .2s; }
.menu a { display:block; padding:14px 20px; font-size:17px; color:var(--fg); text-decoration:none; }
.menu a:hover { background:rgba(127,127,127,.15); }
.menu a.active { color:var(--accent); font-weight:600; }
.menu-who { margin:0; padding:10px 20px 14px; font-size:14px; color:var(--muted); border-bottom:1px solid var(--line); }
.menu-backdrop { position:fixed; top:var(--bar-h); left:0; right:0; bottom:0; z-index:24; background:rgba(0,0,0,.35); opacity:0; pointer-events:none; transition:opacity .2s; }
.menu-backdrop.open { opacity:1; pointer-events:auto; }

/* ---- Today: the river cam fills the page with panels laid over it ---- */
body[data-page=today] main { max-width:none; padding:0; }
.today { position:relative; height:calc(100vh - var(--bar-h)); height:calc(100dvh - var(--bar-h)); overflow:hidden; background:#0e1a24; color:#eceff1; cursor:pointer; }
.today-cam { position:absolute; top:0; left:0; width:100%; height:100%; object-fit:cover; opacity:0; transition:opacity .6s; }
.today-cam.loaded { opacity:1; }
.today-overlay { position:absolute; left:0; right:0; padding:14px 16px; background:rgba(8,12,16,.74); cursor:default; transition:opacity .35s; }
.today-top { top:0; }
.today-bottom { bottom:0; }
.today.clear .today-overlay { opacity:0; pointer-events:none; }
.today-head { display:flex; flex-wrap:wrap; align-items:baseline; justify-content:space-between; gap:4px 12px; }
.today h1 { margin:0; font-size:20px; }
.today-age { margin:0; font-size:13px; color:#9aa5ad; }
.today-age.stale { color:#ffb454; }
.today-stats { display:flex; flex-wrap:wrap; gap:6px 28px; margin-top:10px; }
.today-stat { display:flex; flex-wrap:wrap; align-items:baseline; gap:0 4px; }
.today-val { font-size:26px; font-weight:600; font-variant-numeric:tabular-nums; }
.today-unit { font-size:14px; color:#9aa5ad; }
.today-trend { margin-left:6px; font-size:14px; }
.today-trend.rising { color:#ff8a7a; }
.today-trend.falling { color:#5fd35f; }
.today-trend.steady { color:#94a3b8; }
.today-label { flex-basis:100%; font-size:12px; text-transform:uppercase; letter-spacing:.05em; color:#9aa5ad; }
.today-note { margin:10px 0 0; font-size:14px; color:#c3ccd2; }
.today-clear-age { position:absolute; bottom:14px; left:50%; transform:translateX(-50%); margin:0; padding:4px 12px; border-radius:14px; background:rgba(8,12,16,.6); font-size:13px; white-space:nowrap; opacity:0; pointer-events:none; transition:opacity .35s; }
.today.clear .today-clear-age { opacity:1; }

/* ---- tide graph day line and scroll strip (from the old tides page) ---- */
    .tide-day-header {
      display: flex;
      align-items: center;
      justify-content: center;
      /* Total vertical space is unchanged (2 + 10 = 10 + 2); it's just been moved from
         below the line to above it, so the date sits nearer the graph and further from
         the rain/wind lines. */
      padding: 10px 0 2px;
      /* The anchor below is positioned by script (see updateTideDayHeader), so the header
         holds its height itself: 10 + 24 + 2. */
      position: relative;
      height: 36px;
    }

    /* The date/weather group stays exactly centred; the Home button hangs off its left
       edge (absolutely positioned) so it never nudges the group off-centre as the day
       text changes width. The button is hidden until the group has content. */
    .tide-day-anchor {
      position: absolute;
      top: 10px;
      left: 0;
      max-width: 100%;
    }

    .tide-day-info {
      display: flex;
      align-items: center;
      justify-content: center;
      flex-wrap: wrap;
      gap: 8px;
    }

    .tide-home-btn {
      position: absolute;
      right: 100%;
      top: 50%;
      width: 30px;
      height: 30px;
      margin-top: -15px;
      margin-right: 14px;
      padding: 0;
      border: 0;
      background: none;
      color: #94a3b8;
      cursor: pointer;
      -webkit-tap-highlight-color: transparent;
    }

    .tide-home-btn:active {
      color: #ffc107;
    }

    .tide-home-btn svg {
      display: block;
      width: 20px;
      height: 20px;
      margin: 0 auto;
    }

    .tide-day-info:empty ~ .tide-home-btn {
      display: none;
    }

    @media (min-device-width: 768px) and (max-device-width: 1024px) and (-webkit-max-device-pixel-ratio: 1) {
      .tide-day-info > span { margin: 0 4px; }
    }

    .tide-day-label {
      font-size: 16px;
      font-weight: bold;
      color: #f8fafc;
    }

    .tide-day-icon {
      width: 22px;
      height: 22px;
      display: inline-block;
      vertical-align: middle;
    }

    .tide-day-icon svg {
      width: 100%;
      height: 100%;
      display: block;
    }

    .tide-day-summary {
      font-size: 12px;
      color: #94a3b8;
    }

    .tide-day-mm {
      font-size: 11px;
      font-weight: bold;
      color: #388df8;
    }

    /* Moon phase glyph + label, after the weather on the day line. Wide screens show the
       full phase name (e.g. "Waxing Gibbous"); narrow (portrait phone) screens show a short
       label instead - "New", "Full" or the percentage lit - because the full name would wrap
       the line onto a second row and push the Home button off the left edge. */
    .tide-moon-icon {
      width: 20px;
      height: 20px;
      display: inline-block;
      vertical-align: middle;
    }

    .tide-moon-icon svg {
      width: 100%;
      height: 100%;
      display: block;
    }

    .tide-moon-name,
    .tide-moon-short {
      font-size: 12px;
      color: #94a3b8;
      white-space: nowrap;
    }

    .tide-moon-short {
      display: none;
    }

    @media (max-width: 560px), (min-width: 1100px) and (min-height: 600px) and (orientation: landscape) {
      .tide-moon-name {
        display: none;
      }
      .tide-moon-short {
        display: inline;
      }
    }

    /* ---- Tide timeline: continuous horizontal scroll, one day-width per swipe ---- */
    .tide-scroll-outer {
      width: 100%;
      overflow-x: auto;
      overflow-y: hidden;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: none;
    }

    .tide-scroll-outer svg {
      display: block;
    }

.tide-scroll-outer::-webkit-scrollbar { display: none; }
.today-bottom { padding: 0 0 8px; }
.today-bottom .today-stale { margin: 0; padding: 8px 16px 0; color: #ffb454; }
.today-trend.in { color: #5fd35f; }
.today-trend.out { color: #ff8a7a; }

/* ---- Tap the picture: show the whole photo. The normal background crops to fill the page; this second
   layer shows all of it. On a phone held upright the photo is turned a quarter turn so it still fills the
   screen (turn the phone anticlockwise to read it); held sideways it simply shows the whole photo. ---- */
.today-full { position:absolute; top:0; left:0; width:100%; height:100%; object-fit:contain; background:#0e1a24; opacity:0; pointer-events:none; transition:opacity .35s; }
.today.clear .today-full { opacity:1; }
.today.clear .today-cam { opacity:0; }
@media (orientation: portrait) {
  .today-full { top:50%; left:50%; width:calc(100vh - var(--bar-h)); width:calc(100dvh - var(--bar-h)); height:100vw; transform:translate(-50%, -50%) rotate(90deg); }
  .today.clear .today-clear-age::after { content:" \00b7  turn your phone anticlockwise"; }
}

/* ---- water clarity swatch (from the old tides page): colour from recent rain and river flow; tap to see the river ---- */
.today .water-clarity { position:absolute; top:10px; right:10px; width:48px; height:48px; margin:0; padding:10px 0 0; border:1px solid rgba(255,255,255,.25); border-radius:12px; background:#05070d; color:#000; text-align:center; white-space:nowrap; overflow:hidden; cursor:pointer; -webkit-tap-highlight-color:transparent; }
.water-clarity-pct { display:block; font-size:16px; font-weight:bold; line-height:18px; }
.water-clarity-word { display:block; font-size:9px; font-weight:bold; line-height:10px; letter-spacing:.6px; text-transform:uppercase; }
.today-top { padding-right:72px; }

/* ---- in the season: the panels stack over a fixed, shaded river cam, with the catch card at the bottom ---- */
.today-catch h2 { margin:0 0 2px; font-size:17px; }
.today-catch-grid { display:grid; grid-template-columns:repeat(3, 1fr); gap:8px; margin-top:10px; }
.today-catch-grid button { margin:0; padding:14px 4px; font-size:15px; }
.today.in-season { height:auto; min-height:calc(100vh - var(--bar-h)); min-height:calc(100dvh - var(--bar-h)); overflow:visible; display:flex; flex-direction:column; cursor:default; }
.today.in-season .today-overlay { position:relative; z-index:1; } /* in the flow, but above the fixed picture: a positioned picture paints over anything that is not itself positioned */
.today.in-season .today-catch { flex:1; }
.today.in-season .today-cam, .today.in-season .today-full { position:fixed; top:var(--bar-h); left:0; width:100%; height:calc(100vh - var(--bar-h)); height:calc(100dvh - var(--bar-h)); }
.today.in-season .today-cam, .today.in-season .today-full { z-index:0; }
.today.in-season .today-clear-age { position:fixed; z-index:2; }
@media (orientation: portrait) {
  .today.in-season .today-full { top:calc(50% + var(--bar-h) / 2); left:50%; width:calc(100vh - var(--bar-h)); width:calc(100dvh - var(--bar-h)); height:100vw; }
}