/* ═══════════════════════════════════════════════════════════════
   SWAPA Tidebook PWA — Maritime Dark UI v3.0
   Design system ported from design-preview-v3.html
   Architecture: reset → tokens → base → layout → components →
                 states → utilities → responsive
   ═══════════════════════════════════════════════════════════════ */

/* ── Google Fonts ────────────────────────────────────────────────
   Inter: clean geometric sans, replaces Space Grotesk + DM Mono
   font-variant-numeric: tabular-nums used for all data displays
   ─────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

/* ════════════════════════════════════════════════════════════════
   LAYER 1 · RESET
   ════════════════════════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
html {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  font-size: 16px;
}
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  line-height: 1.4;
}
button {
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  line-height: 1;
}
a      { text-decoration: none; color: inherit; }
svg    { display: block; flex-shrink: 0; }
img    { display: block; }
input  { font-family: inherit; }

/* ════════════════════════════════════════════════════════════════
   LAYER 2 · DESIGN TOKENS  (ported from mock-up :root verbatim,
   then mapped to real app --color-* names for full compatibility)
   ════════════════════════════════════════════════════════════════ */
:root {
  /* ── Mock-up tokens (source of truth) ──────────────────────── */
  --bg:           #0a1628;
  --bg-section:   #0d2137;
  --bg-elevated:  #1a3a5c;
  --glass-bg:     rgba(13, 33, 55, 0.75);
  --glass-border: rgba(41, 204, 245, 0.12);
  --accent:       #29ccf5;
  --accent-dim:   rgba(41, 204, 245, 0.12);
  --accent-mid:   rgba(41, 204, 245, 0.22);
  --accent-glow:  rgba(41, 204, 245, 0.35);
  --text-1:       rgba(255,255,255,0.90);
  --text-2:       rgba(255,255,255,0.50);
  --text-3:       rgba(255,255,255,0.25);
  --success:      #26d07c;
  --warning:      #f0c040;
  --danger:       #ef5350;
  --r-card:       16px;
  --r-pill:       999px;

  /* ── Compatibility aliases (real app --color-* names) ───────── */
  --color-bg:           var(--bg);
  --color-surface:      var(--bg-section);
  --color-surface-mid:  var(--bg-elevated);
  --color-surface-hi:   #1e4060;
  --color-border:       var(--glass-border);
  --color-border-hi:    rgba(41, 204, 245, 0.22);
  --color-accent:       var(--accent);
  --color-accent-dim:   var(--accent-dim);
  --color-accent-mid:   var(--accent-mid);
  --color-accent-glow:  var(--accent-glow);
  --color-accent-chip:  var(--accent-dim);
  --color-gold:         #f0c040;
  --color-gold-dim:     rgba(240, 192, 64, 0.16);
  --color-success:      var(--success);
  --color-danger:       var(--danger);
  --color-text-1:       var(--text-1);
  --color-text-2:       var(--text-2);
  --color-text-3:       var(--text-3);

  /* ── Layout constants ─────────────────────────────────────────── */
  --header-h:     60px;
  --toolbar-h:    68px;
  --safe-top:     env(safe-area-inset-top,    0px);
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
  --safe-left:    env(safe-area-inset-left,   0px);
  --safe-right:   env(safe-area-inset-right,  0px);
  --drawer-w:     min(320px, 88vw);

  /* ── Border radii ─────────────────────────────────────────────── */
  --r-xs:   6px;
  --r-sm:   10px;
  --r-md:   14px;
  --r-lg:   22px;
  --r-xl:   32px;
  --r-full: 9999px;

  /* ── Spacing scale ────────────────────────────────────────────── */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;

  /* ── Motion ───────────────────────────────────────────────────── */
  --dur-fast:    120ms;
  --dur-normal:  240ms;
  --dur-slow:    400ms;
  --ease-out:    cubic-bezier(0.0, 0.0, 0.2, 1);
  --ease-in:     cubic-bezier(0.4, 0.0, 1.0, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);

  /* ── Font sizes ───────────────────────────────────────────────── */
  --fs-xs:   0.625rem;   /* 10px */
  --fs-sm:   0.75rem;    /* 12px */
  --fs-base: 0.875rem;   /* 14px */
  --fs-md:   1rem;       /* 16px */
  --fs-lg:   1.125rem;   /* 18px */
}

/* ════════════════════════════════════════════════════════════════
   LAYER 3 · BASE
   ════════════════════════════════════════════════════════════════ */
body {
  background: var(--bg);
  color: var(--text-1);
}

/* Subtle nautical grid on the main body */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(41,204,245,0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(41,204,245,0.022) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 0;
}

.hidden { display: none !important; }

*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* Scrollbars */
::-webkit-scrollbar              { width: 4px; }
::-webkit-scrollbar-track        { background: transparent; }
::-webkit-scrollbar-thumb        { background: rgba(41, 204, 245, 0.18); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover  { background: rgba(41, 204, 245, 0.30); }

/* ════════════════════════════════════════════════════════════════
   LAYER 4 · LAYOUT (app shell)
   ════════════════════════════════════════════════════════════════ */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  position: relative;
  overflow: hidden;
  z-index: 1;
}

/* ════════════════════════════════════════════════════════════════
   LAYER 5 · COMPONENTS
   ════════════════════════════════════════════════════════════════ */

/* ─── Header ──────────────────────────────────────────────────── */
#appHeader {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: 0 var(--sp-4);
  padding-top: var(--safe-top);
  height: calc(var(--header-h) + var(--safe-top));
  background: linear-gradient(180deg, rgba(10,22,40,0.98) 0%, rgba(10,22,40,0.93) 100%);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: relative;
  z-index: 20;
  transition:
    transform var(--dur-normal) var(--ease-in),
    opacity  var(--dur-normal) var(--ease-in);
}
#appHeader.ui-hide {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

.header-left  { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.header-right { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }

.logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--bg-elevated) 0%, var(--bg-section) 100%);
  border: 1px solid var(--glass-border);
}

.header-titles {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  overflow: hidden;
}
.header-org {
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  line-height: 1;
}
.header-name {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-1);
  margin-top: 1px;
}

.clock {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  margin-right: 6px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--r-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  transition:
    background var(--dur-fast),
    color      var(--dur-fast),
    transform  var(--dur-fast) var(--ease-spring);
}
.icon-btn svg { width: 16px; height: 16px; stroke-width: 1.6; }
.icon-btn:hover,
.icon-btn:focus-visible {
  background: var(--accent-dim);
  color: var(--accent);
}
.icon-btn:active {
  background: var(--accent-mid);
  transform: scale(0.92);
}
.icon-btn.active      { color: var(--color-gold); }
.icon-btn.wake-active { color: var(--success); }

/* ─── Viewer ──────────────────────────────────────────────────── */
#viewerMain {
  flex: 1;
  min-height: 0;  /* prevent flex item from overriding the bottom toolbar position */
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg);
}

/* Ambient glow */
#viewerMain::after {
  content: '';
  position: absolute;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(41,204,245,0.04) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.page-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  z-index: 1;
}
.page-container.grabbing { cursor: grabbing; }

/* ─── Book Stage ──────────────────────────────────────────────── */
#bookStage {
  position: relative;
  display: flex;
  align-items: stretch;
  width: 100%;
  height: calc(100% - 16px);
  perspective: 2800px;
  perspective-origin: 50% 50%;
  overflow: hidden;
  border-radius: var(--r-card);
  border: 1px solid rgba(41,204,245,0.08);
}

.page-slot {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  min-width: 0;
  background: #0c1e35;
}

.page-slot-right {
  border-left: 1px solid rgba(41,204,245,0.06);
}

.page-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  border-radius: 2px;
  -webkit-user-drag: none;
  touch-action: none;
  user-select: none;
  pointer-events: none;
}

.page-slot .page-img {
  box-shadow:
    0 10px 50px rgba(0, 0, 0, 0.80),
    0 0 0 1px rgba(255, 255, 255, 0.04);
}

.book-spine {
  width: 10px;
  flex-shrink: 0;
  align-self: stretch;
  background: linear-gradient(
    to right,
    #000 0%, #04101e 25%, #0a1e35 50%, #04101e 75%, #000 100%
  );
  box-shadow: 0 0 22px rgba(0,0,0,1), inset 0 0 6px rgba(255,255,255,0.02);
  z-index: 3;
}

#bookStage.single .book-spine,
#bookStage.single #slotRight { display: none; }
#bookStage.single #slotLeft  { flex: 1; }
#bookStage.spread .book-spine { display: block; }

#bookStage.spread #slotLeft::after,
#bookStage.spread #slotRight::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  width: 36px;
  pointer-events: none;
  z-index: 1;
}
#bookStage.spread #slotLeft::after {
  right: 0;
  background: linear-gradient(to right, transparent, rgba(0,0,0,0.38));
}
#bookStage.spread #slotRight::before {
  left: 0;
  background: linear-gradient(to left, transparent, rgba(0,0,0,0.30));
}

/* ─── 3D Page Flipper ─────────────────────────────────────────── */
.page-flipper {
  position: absolute;
  top: 0;
  height: 100%;
  transform-style: preserve-3d;
  z-index: 10;
  display: none;
  pointer-events: none;
  will-change: transform;
}
.page-flipper.active { display: block; }

.flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.flip-back { transform: rotateY(180deg); }
.flip-face .page-img {
  box-shadow:
    0 10px 50px rgba(0,0,0,0.80),
    0 0 0 1px rgba(255,255,255,0.04);
}

.flip-shadow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  background: linear-gradient(
    to right,
    rgba(0,0,0,0.65) 0%,
    rgba(0,0,0,0.20) 30%,
    transparent 60%
  );
}
.page-flipper.flipping .flip-shadow {
  animation: fold-shadow var(--flip-dur, 0.65s) ease forwards;
}
@keyframes fold-shadow {
  0%   { opacity: 0; }
  38%  { opacity: 1; }
  62%  { opacity: 1; }
  100% { opacity: 0; }
}
.page-flipper.flipping::before {
  content: '';
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: rgba(0,0,0,0.28);
  z-index: 6;
  animation: page-lift-shadow var(--flip-dur, 0.65s) ease forwards;
  pointer-events: none;
}
@keyframes page-lift-shadow {
  0%   { opacity: 1; }
  50%  { opacity: 0.55; }
  100% { opacity: 0; }
}

/* ─── Page loader ─────────────────────────────────────────────── */
.page-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 5;
}
.page-loader.visible { opacity: 1; }
.spinner {
  width: 30px;
  height: 30px;
  border: 2px solid rgba(41, 204, 245, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Progress bar ────────────────────────────────────────────── */
#progressBar {
  position: absolute;
  top: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    var(--accent) 0%,
    rgba(41,204,245,0.4) 100%
  );
  border-radius: 0 1px 1px 0;
  transition: width 0.38s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  z-index: 1;
}
/* The glowing dot at the tip */
#progressBar::after {
  content: '';
  position: absolute;
  right: 0; top: -2px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* ─── Page indicator ──────────────────────────────────────────── */
.page-mini-btn {
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-pill);
  padding: 4px 14px;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 400;
  cursor: pointer;
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  font-variant-numeric: tabular-nums;
  transition: border-color var(--dur-fast), color var(--dur-fast);
}
.page-mini-btn:hover { border-color: var(--glass-border); }
.page-mini-btn:active { border-color: rgba(41,204,245,0.3); }
.page-mini-btn #pageIndicator {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-1);
  line-height: 1;
}
.page-mini-btn .page-sep  { color: var(--text-3); margin: 0 2px; }
.page-mini-btn #pageTotal { color: var(--text-2); }

/* ─── Swipe hint ──────────────────────────────────────────────── */
.swipe-hint {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-full);
  padding: 7px 20px;
  font-size: var(--fs-sm);
  color: var(--text-2);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s;
  white-space: nowrap;
  z-index: 6;
}
.swipe-hint.visible { opacity: 1; }
.swipe-icon { width: 14px; height: 14px; }

/* ─── Zoom controls ───────────────────────────────────────────── */
.zoom-controls {
  position: absolute;
  bottom: 20px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-card);
  padding: 4px;
  z-index: 10;
  overflow: hidden;
}
.zoom-btn {
  width: 34px;
  height: 30px;
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
}
.zoom-btn:hover,
.zoom-btn:active {
  background: var(--accent-dim);
  color: var(--accent);
}
.zoom-pct {
  font-size: 9px;
  font-weight: 500;
  color: var(--text-2);
  border-top: 1px solid var(--glass-border);
  border-bottom: 1px solid var(--glass-border);
  border-radius: 0;
  font-variant-numeric: tabular-nums;
}

/* ─── Tide countdown overlay ──────────────────────────────────── */
.tide-countdown {
  position: absolute;
  top: 12px;
  left: 12px;
  right: auto;
  width: max-content;
  max-width: calc(100% - 24px);
  z-index: 8;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-card);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.tide-cd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
  cursor: grab;
}
.tide-cd-header:active { cursor: grabbing; }
.tide-cd-location {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.tide-cd-close {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: none;
  color: var(--text-2);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.tide-cd-close:hover {
  color: var(--text-1);
  background: rgba(255,255,255,0.12);
}

.tide-cd-body {
  display: flex;
  gap: 14px;
  align-items: center;
  white-space: nowrap;
}
.tide-cd-group  { display: flex; flex-direction: column; gap: 2px; }
.tide-cd-label  { font-size: 9px; color: var(--text-2); font-weight: 400; letter-spacing: 0.05em; text-transform: uppercase; }
.tide-cd-now,
.tide-cd-value  { font-size: 16px; font-weight: 300; color: var(--text-1); font-variant-numeric: tabular-nums; line-height: 1; }
.tide-cd-now.accent,
.tide-cd-value.accent { color: var(--accent); }
.tide-cd-value.tide-cd-ht { font-size: 13px; color: var(--text-2); }
.tide-cd-time-inline { font-size: 9px; font-weight: 400; color: var(--text-2); }
.tide-cd-sep    { width: 1px; height: 32px; background: var(--glass-border); align-self: center; }
.tide-cd-time   { font-size: 0.86rem; font-weight: 400; color: var(--text-1); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.tide-cd-ht     { font-size: 0.7rem; color: var(--text-2); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.tide-cd-countdown { font-size: 0.88rem; font-weight: 400; color: var(--accent); flex-shrink: 0; font-variant-numeric: tabular-nums; }

/* Legacy layout helpers kept for JS-built markup */
.tide-cd-now-row  { display: flex; align-items: baseline; gap: 6px; margin-bottom: 4px; }
.tide-cd-next-row { display: flex; align-items: baseline; gap: 5px; flex-wrap: nowrap; white-space: nowrap; }

/* ─── Bottom Toolbar ──────────────────────────────────────────── */
.bottom-toolbar {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-bottom);
  padding-left:   var(--safe-left);
  padding-right:  var(--safe-right);
  background: rgba(8, 20, 40, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--glass-border);
  position: relative;
  z-index: 20;
  transition:
    transform var(--dur-normal) var(--ease-in),
    opacity  var(--dur-normal) var(--ease-in);
}
.bottom-toolbar.ui-hide {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

/* Row 1: icon buttons */
.toolbar-buttons {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: var(--toolbar-h);
  flex-shrink: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  padding-top: 12px;
}
.toolbar-buttons::-webkit-scrollbar { display: none; }

/* Row 2: progress bar + page indicator */
.toolbar-status {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px 0 0;
  border-top: 1px solid rgba(255,255,255,0.04);
}

/* Regular toolbar buttons */
.toolbar-btn {
  flex: 1 0 40px;
  height: calc(var(--toolbar-h) - 12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 9px 10px 7px;
  color: var(--text-2);
  border-radius: var(--r-pill);
  transition:
    color      var(--dur-fast),
    background var(--dur-fast),
    transform  var(--dur-fast) var(--ease-spring);
  min-width: 0;
  position: relative;
  border: none;
  background: none;
}
.toolbar-btn:active {
  background: var(--accent-dim);
  color: var(--accent);
  transform: scale(0.94);
}
.toolbar-btn.t-active { color: var(--accent); }
/* Active underline glow — mock-up style */
.toolbar-btn.t-active::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 2px;
  border-radius: 1px;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
}

.toolbar-icon { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 1.6; }
.toolbar-label {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.03em;
  white-space: nowrap;
  line-height: 1;
  color: inherit;
}

/* Center FAB: Today button */
#todayBtn {
  flex: 0 0 56px;
  margin-top: -24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #29ccf5, #1ab5ef);
  color: #0a1628;
  border: 3px solid var(--bg);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0;
  transition:
    transform    var(--dur-fast) var(--ease-spring),
    box-shadow   var(--dur-fast),
    background   var(--dur-fast);
  z-index: 5;
  box-shadow: 0 4px 20px rgba(41, 204, 245, 0.40), 0 2px 8px rgba(0,0,0,0.50);
}
#todayBtn:active {
  transform: scale(0.88);
  box-shadow: 0 2px 8px rgba(41, 204, 245, 0.22), 0 1px 4px rgba(0,0,0,0.5);
  background: linear-gradient(135deg, #1ab5ef, #0288d1);
}
#todayBtn.t-active {
  background: linear-gradient(135deg, #29ccf5, #1ab5ef);
  color: #0a1628;
}
#todayBtn::after        { display: none; }
#todayBtn .toolbar-icon { width: 20px; height: 20px; color: inherit; }
#todayBtn .toolbar-label {
  font-size: 9px;
  font-weight: 600;
  color: inherit;
  letter-spacing: 0.03em;
}

/* Nav prev/next arrow buttons */
.nav-btn { flex: 0.55; }
.nav-btn .toolbar-icon {
  width: 20px;
  height: 20px;
  color: var(--text-2);
  stroke-width: 2;
}
.nav-btn:active { background: none; transform: none; }
.nav-btn:active .toolbar-icon { color: var(--text-1); }
.nav-btn:disabled { opacity: 0.15; pointer-events: none; }

/* ─── Shared drawer/overlay backdrop ──────────────────────────── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6,14,26,0.60);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-normal);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.drawer-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

/* ─── Drawers ─────────────────────────────────────────────────── */
.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--drawer-w);
  background: linear-gradient(180deg, #0c1e35 0%, var(--bg) 100%);
  border-right: 1px solid var(--glass-border);
  z-index: 110;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform var(--dur-normal) var(--ease-out);
  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
  overflow: hidden;
  will-change: transform;
}
.drawer.open { transform: translateX(0); }

.drawer-right {
  left: auto;
  right: 0;
  border-right: none;
  border-left: 1px solid var(--glass-border);
  transform: translateX(100%);
  padding-left: 0;
  padding-right: var(--safe-right);
}
.drawer-right.open { transform: translateX(0); }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 56px 20px 16px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--glass-border);
}
.drawer-header h2 {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-1);
}

.close-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  font-size: 14px;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.close-btn:hover,
.close-btn:active {
  background: rgba(255,255,255,0.12);
  color: var(--text-1);
}

/* TOC / bookmarks list */
.drawer-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: var(--sp-2) 0;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.drawer-list li a,
.drawer-list li button {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  padding: 11px 20px;
  text-align: left;
  font-size: 13px;
  font-weight: 300;
  line-height: 1.4;
  color: var(--text-1);
  transition: background var(--dur-fast), color var(--dur-fast);
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.drawer-list li a:hover,
.drawer-list li button:hover,
.drawer-list li a:active,
.drawer-list li button:active {
  background: rgba(41,204,245,0.05);
  color: var(--accent);
}
.drawer-list li.current > a,
.drawer-list li.current > button {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 500;
}

/* TOC category dividers */
.toc-category {
  padding: 14px 20px 6px;
  font-size: 9px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Page number chip */
.item-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 20px;
  font-size: 10px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  width: 24px;
  flex-shrink: 0;
  text-align: right;
}
.drawer-list li.current .item-page { color: var(--accent); }

.item-delete {
  width: 26px;
  height: 26px;
  border-radius: var(--r-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 0.72rem;
  flex-shrink: 0;
  margin-left: auto;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.item-delete:hover,
.item-delete:active {
  background: rgba(239,83,80,0.14);
  color: var(--danger);
}

.drawer-empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--text-2);
  font-size: var(--fs-base);
  font-weight: 300;
  line-height: 1.7;
}
.inline-icon {
  display: inline;
  vertical-align: middle;
  width: 14px;
  height: 14px;
}

/* ─── Search Sheet ────────────────────────────────────────────── */
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 72%;
  background: linear-gradient(180deg, var(--bg-section) 0%, var(--bg) 100%);
  border-top: 1px solid var(--glass-border);
  border-radius: 20px 20px 0 0;
  z-index: 110;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform var(--dur-normal) var(--ease-out);
  padding-bottom: var(--safe-bottom);
  overflow: hidden;
  will-change: transform;
}
.sheet.open { transform: translateY(0); }

.sheet-handle {
  width: 36px;
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  margin: 12px auto 0;
  flex-shrink: 0;
}
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  flex-shrink: 0;
}
.sheet-header h2 {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-1);
}

.search-field-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 16px 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-pill);
  padding: 10px 14px;
  flex-shrink: 0;
}
.search-field-icon {
  width: 16px;
  height: 16px;
  color: var(--text-2);
  stroke-width: 1.8;
  flex-shrink: 0;
}
#searchInput {
  flex: 1;
  width: 100%;
  background: none;
  border: none;
  outline: none;
  color: var(--text-1);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 300;
  -webkit-user-select: text;
  user-select: text;
}
#searchInput::placeholder { color: var(--text-3); }

/* Legacy wrapper for icon-in-field layout */
.search-field-wrap .search-field-icon { pointer-events: none; }

.clear-search-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
  color: var(--text-2);
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-fast);
  flex-shrink: 0;
}
.clear-search-btn:hover { background: rgba(255,255,255,0.14); }

.search-results-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: 0 0 16px;
  border-top: 1px solid rgba(255,255,255,0.03);
}
.search-results-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background 0.15s;
}
.search-results-list li:hover { background: rgba(41,204,245,0.05); }
.item-page.sr-page { font-size: 10px; font-weight: 500; color: var(--accent); width: 24px; flex-shrink: 0; text-align: right; }
.sr-body  { flex: 1; }
.sr-title { font-size: 13px; font-weight: 400; color: var(--text-1); }
.search-snippet {
  font-size: 11px;
  font-weight: 300;
  color: var(--text-2);
  margin-top: 2px;
  line-height: 1.45;
}
.search-snippet mark {
  background: none;
  color: var(--accent);
  font-weight: 500;
}

/* ─── Modals ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(6,14,26,0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 20px;
  padding-bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 16px));
  animation: fade-in var(--dur-fast) ease;
}
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.modal-card {
  background: linear-gradient(180deg, #0f2540 0%, #0a1a30 100%);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  width: 100%;
  overflow: hidden;
  animation: modal-rise var(--dur-normal) var(--ease-spring);
}
@keyframes modal-rise {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-card h3 {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-1);
}
.modal-hint {
  font-size: 11px;
  color: var(--text-2);
  font-weight: 300;
  padding: 10px 20px;
}

/* Modal actions */
.modal-actions { display: flex; gap: var(--sp-2); }
.modal-btn {
  flex: 1;
  padding: 12px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  transition: opacity var(--dur-fast), background var(--dur-fast);
  letter-spacing: 0.02em;
  cursor: pointer;
}
.modal-secondary {
  background: none;
  border: 1px solid var(--glass-border);
  color: var(--text-2);
}
.modal-secondary:hover { border-color: rgba(41,204,245,0.3); color: var(--text-1); }
.modal-primary {
  background: linear-gradient(135deg, #29ccf5, #1ab5ef);
  border: none;
  color: #0a1628;
  font-weight: 600;
}
.modal-primary:hover { opacity: 0.90; }

/* ─── Page Jump Modal ─────────────────────────────────────────── */
#pageJumpInput {
  display: block;
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 12px 16px;
  font-family: 'Inter', sans-serif;
  font-size: 22px;
  font-weight: 300;
  text-align: center;
  color: var(--text-1);
  outline: none;
  font-variant-numeric: tabular-nums;
  margin-bottom: 16px;
  -webkit-user-select: text;
  user-select: text;
  transition: border-color var(--dur-fast);
}
#pageJumpInput:focus { border-color: rgba(41,204,245,0.4); }
#pageJumpInput.shake { animation: shake 0.3s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60%  { transform: translateX(-6px); }
  40%, 80%  { transform: translateX( 6px); }
}

/* Jump modal card layout (uses .modal-card + .today-card) */
.today-card { max-width: 360px; }
.today-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--glass-border);
}
.today-header h3 {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-1);
}
.today-date {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 3px;
  font-weight: 300;
}

/* Location grid */
.today-loc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 16px;  /* 16px top gives clear space above divider line */
}
.today-loc-btn {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.15s, border-color 0.15s;
  text-align: left;
  font-family: inherit;
}
.today-loc-btn:hover,
.today-loc-btn:active {
  background: var(--accent-dim);
  border-color: rgba(41,204,245,0.30);
}
.today-loc-btn.preferred {
  border-color: rgba(41,204,245,0.35);
  background: var(--accent-dim);
}
.today-loc-btn.preferred .today-loc-name { color: var(--accent); }
.today-loc-btn svg { width: 16px; height: 16px; stroke-width: 1.6; color: var(--accent); flex-shrink: 0; }
.today-loc-name { font-size: 12px; font-weight: 500; color: var(--text-1); }
.today-loc-sub  { font-size: 10px; color: var(--text-2); }

.today-tide-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px 20px;
  border-top: 1px solid var(--glass-border);
}
.modal-toggle-label { font-size: 12px; color: var(--text-2); font-weight: 300; }
.tide-box-toggle {
  background: var(--accent-dim);
  border: 1px solid rgba(41,204,245,0.3);
  border-radius: var(--r-pill);
  padding: 4px 14px;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.tide-box-toggle.off {
  background: rgba(255,255,255,0.04);
  border-color: var(--glass-border);
  color: var(--text-2);
}

/* Jump modal actions wrapper */
.jump-actions { display: flex; gap: 8px; padding: 0 20px 20px; }
.btn-secondary {
  flex: 1;
  padding: 12px;
  border-radius: var(--r-pill);
  background: none;
  border: 1px solid var(--glass-border);
  color: var(--text-2);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-secondary:hover { border-color: rgba(41,204,245,0.3); color: var(--text-1); }
.btn-primary {
  flex: 1;
  padding: 12px;
  border-radius: var(--r-pill);
  background: linear-gradient(135deg, #29ccf5, #1ab5ef);
  border: none;
  color: #0a1628;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* ─── Update Toast ────────────────────────────────────────────── */
.update-toast {
  position: fixed;
  top: calc(var(--header-h) + var(--safe-top) + 10px);
  left: 16px;
  right: 16px;
  z-index: 90;
  background: linear-gradient(135deg, rgba(41,204,245,0.15), rgba(41,182,246,0.10));
  border: 1px solid rgba(41,204,245,0.30);
  border-radius: var(--r-card);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-1);
  animation: toast-drop 0.3s var(--ease-out) both;
}
@keyframes toast-drop {
  from { transform: translateY(-16px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}
.update-toast-icon { width: 16px; height: 16px; flex-shrink: 0; color: var(--accent); stroke-width: 2; }
.update-toast span { flex: 1; font-weight: 400; }
.toast-text { flex: 1; font-size: 12px; color: var(--text-1); font-weight: 400; }
.update-refresh-btn {
  background: var(--accent);
  border: none;
  border-radius: var(--r-pill);
  padding: 5px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: #0a1628;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity var(--dur-fast);
}
.update-refresh-btn:hover { opacity: 0.88; }
.update-dismiss-btn {
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ─── Install Banner ──────────────────────────────────────────── */
.install-banner {
  position: fixed;
  bottom: calc(var(--toolbar-h) + var(--safe-bottom) + 14px);
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 13px 14px;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-card);
  z-index: 80;
  animation: banner-rise 0.38s var(--ease-out) both;
}
@keyframes banner-rise {
  from { transform: translateY(22px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.install-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--r-sm);
  flex-shrink: 0;
  border: 1px solid var(--glass-border);
}
.install-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.install-text strong { font-size: var(--fs-base); color: var(--text-1); line-height: 1.2; font-weight: 500; }
.install-text span   { font-size: 0.7rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.install-btn {
  flex-shrink: 0;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--dur-fast), background var(--dur-fast);
}
.install-btn-primary {
  padding: 8px 16px;
  background: linear-gradient(135deg, #29ccf5, #1ab5ef);
  color: #0a1628;
  font-size: var(--fs-base);
  border: none;
}
.install-btn-primary:hover { opacity: 0.88; }
.install-btn-dismiss {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.06);
  color: var(--text-2);
  font-size: 0.72rem;
  border: none;
}
.install-btn-dismiss:hover { background: rgba(255,255,255,0.12); }

/* ─── Version toast ───────────────────────────────────────────── */
.version-toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 1.2rem);
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  background: var(--glass-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
  color: var(--text-1);
  font-size: var(--fs-sm);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  padding: 0.5rem 1.4rem;
  border-radius: var(--r-full);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s ease;
  z-index: 9999;
}
.version-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ════════════════════════════════════════════════════════════════
   LIVE DASHBOARD PANELS
   ════════════════════════════════════════════════════════════════ */

/* ─── Shared dashboard overlay ────────────────────────────────── */
.dashboard-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: dashFadeIn 0.22s var(--ease-smooth);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
@keyframes dashFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.dashboard-overlay[hidden] { display: none; }

.dashboard-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 52px 20px 14px;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(10,22,40,0.95);
  flex-shrink: 0;
  min-height: 54px;
}
/* When no safe-area top, collapse the large padding */
@supports (padding-top: env(safe-area-inset-top)) {
  .dashboard-header {
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
  }
}

.dashboard-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-1);
  flex: 1;
}
.dashboard-title-icon {
  width: 18px;
  height: 18px;
  stroke-width: 1.6;
  color: var(--accent);
  flex-shrink: 0;
}
.dashboard-meta {
  font-size: 10px;
  color: var(--text-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.dashboard-refresh-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid var(--glass-border);
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.dashboard-refresh-btn svg { width: 14px; height: 14px; stroke-width: 2; }
.dashboard-refresh-btn:hover { background: var(--accent-mid); }
.dashboard-refresh-btn.spinning svg { animation: spin 0.8s linear infinite; }

/* Close button (× icon inside header) */
.dashboard-close-icon-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 50%;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.dashboard-close-icon-btn:hover,
.dashboard-close-icon-btn:focus-visible {
  background: rgba(255,255,255,0.14);
  color: var(--text-1);
  outline: none;
}

.dashboard-footer {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  padding-bottom: env(safe-area-inset-bottom, 4px);
  border-top: 1px solid var(--glass-border);
  background: rgba(10,22,40,0.95);
}
.dashboard-close-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-pill);
  padding: 12px 20px;
  color: var(--text-2);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.dashboard-close-btn:hover { border-color: rgba(41,204,245,0.3); color: var(--text-1); }
.dashboard-close-btn svg { width: 16px; height: 16px; stroke-width: 2; }

/* ─── Live Tides dashboard grid ────────────────────────────────── */
.dashboard-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr;  /* single-column default; wider breakpoints override below */
  gap: 12px;
  align-content: start;
}
.dashboard-grid::-webkit-scrollbar { width: 4px; }
.dashboard-grid::-webkit-scrollbar-thumb { background: rgba(41,204,245,0.15); border-radius: 2px; }

/* Dash cards — styled like mock-up .tide-card */
.dash-card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-card);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  transition: border-color 0.2s;
  min-height: 0;
  overflow: clip;
}
.dash-card:hover { border-color: rgba(41,204,245,0.25); }

/* Status stripe on left edge */
.dash-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: var(--r-card) 0 0 var(--r-card);
  background: var(--accent);
  opacity: 0.5;
}
.dash-card.rising::before  { background: var(--success); opacity: 0.9; }
.dash-card.falling::before { background: var(--danger);  opacity: 0.9; }
.dash-card.loading::before { background: var(--text-2);  opacity: 0.3; }
.dash-card.error::before   { background: var(--danger);  opacity: 0.35; }

.dash-card-row { display: flex; align-items: center; gap: 0.65rem; }
.dash-arrow {
  font-size: 1.7rem;
  line-height: 1;
  font-weight: 900;
  flex-shrink: 0;
  width: 1.7rem;
  text-align: center;
}
.dash-arrow.rising,  .dash-arrow.flood  { color: var(--success); }
.dash-arrow.falling, .dash-arrow.ebb   { color: var(--danger); }
.dash-arrow.slack { color: var(--text-2); font-size: 1.2rem; }

.dash-card-location {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-event { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; justify-content: center; }

.tide-card-now,
.dash-event-now {
  font-size: 26px;
  font-weight: 300;
  color: var(--text-1);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tide-card-now small { font-size: 13px; color: var(--text-2); margin-left: 2px; }

.dash-event-next {
  display: flex;
  align-items: center;
  gap: 6px;
}
.dash-event-label { font-size: 9px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; flex-shrink: 0; }
.dash-event-time  {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-1);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.dash-event-ht    { font-size: 11px; color: var(--text-2); margin-left: auto; font-variant-numeric: tabular-nums; }

/* Tide event row badges */
.tide-event-row { display: flex; align-items: center; gap: 6px; }
.tide-event-badge {
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: var(--r-pill);
}
.tide-event-badge.hi { background: var(--accent-dim); color: var(--accent); }
.tide-event-badge.lo { background: rgba(255,255,255,0.07); color: var(--text-2); }
.tide-event-time { font-size: 11px; color: var(--text-1); font-variant-numeric: tabular-nums; }

.tide-card-events { display: flex; flex-direction: column; gap: 4px; }

.dash-countdown { text-align: right; flex-shrink: 0; min-width: 3.8rem; }
.dash-countdown-label { font-size: 9px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }
.dash-countdown-val {
  font-size: 16px;
  font-weight: 300;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
}
.dash-countdown-val.accent { color: var(--accent); }

/* Tide arc / wave */
.tide-arc-wrap { display: flex; justify-content: center; }
.tide-wave {
  height: 36px;
  overflow: hidden;
  border-radius: 8px;
}

@media (max-width: 539px) {
  /* grid-template-columns already 1fr by default — no override needed */
  .dashboard-grid {
    padding: 12px;
    gap: 10px;
  }

  /* ── Tide cards: scale down large current-height number ── */
  .tide-card-now,
  .dash-event-now {
    font-size: 19px;
  }
  /* Tide arrow — slightly smaller to match */
  .dash-arrow {
    font-size: 1.4rem;
    width: 1.4rem;
  }

  /* ── Weather cards: scale down wind-speed display ── */
  .wx-primary {
    font-size: 17px;
  }
  .wx-trend {
    font-size: 1.1rem;
  }
  /* Ensure station name and wind block share the row comfortably */
  .wx-top {
    gap: 8px;
  }
}
@media (min-width: 540px) {
  .dashboard-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.65rem;
    padding: 0.7rem;
  }
  .dash-card { padding: 16px; border-radius: var(--r-card); }
  .dash-event-time { font-size: 12px; }
  .dash-event-ht   { font-size: 12px; }
  .dash-countdown-val { font-size: 18px; }
  .dash-countdown { min-width: 4.2rem; }
}
/* ── Landscape phone: explicit 3-column grid + smaller type ── */
@media (orientation: landscape) and (max-height: 500px) {
  /* 3 explicit columns — never more, never fewer */
  .dashboard-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 6px;
  }
  /* Cards: auto height so content is never clipped */
  .dash-card { padding: 10px 12px; height: auto; }
  .tide-card-now,
  .dash-event-now { font-size: 20px; }
  .dash-arrow { font-size: 1.3rem; width: 1.3rem; }
  .dash-countdown-val { font-size: 16px; }
  .wx-primary { font-size: 17px; }
  /* Compact footer so it always fits in the short landscape viewport */
  .dashboard-footer {
    padding-top: 6px;
    padding-bottom: env(safe-area-inset-bottom, 4px);
    flex-shrink: 0;  /* belt-and-suspenders: never let footer collapse */
  }
}

/* ── Portrait: reflow tide cards into a two-row grid layout ────── */
/* col 1 (auto) = arrow glyph / location prefix                     */
/* col 2 (1fr)  = current height / station name                     */
/* col 3 (auto) = countdown / next event                            */
@media (orientation: portrait) {
  .dash-card-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    column-gap: 8px;
    row-gap: 8px;
    align-items: center;
  }

  /* Dissolve .dash-event so its 3 children join the parent grid */
  .dash-event { display: contents; }

  /* ── Row 1 (top): station name | next event ── */
  .dash-card-location {
    grid-column: 1 / span 2;
    grid-row: 1;
    font-size: 11px;
  }

  .dash-event-next {
    grid-column: 3;
    grid-row: 1;
    justify-content: flex-end;
  }

  /* ── Row 2 (bottom): arrow | current height | countdown ── */
  .dash-arrow     { grid-column: 1; grid-row: 2; width: auto; }
  .dash-event-now { grid-column: 2; grid-row: 2; }
  .dash-countdown { grid-column: 3; grid-row: 2; min-width: 0; }

  /* "In" micro-label not needed — the value is self-explanatory */
  .dash-countdown-label { display: none; }

  /* Scale countdown to balance the current-height prominence */
  .dash-countdown-val { font-size: 20px; text-align: right; }

  /* Remove auto left margin — flex-end handles alignment */
  .dash-event-ht { margin-left: 0; }

  /* Card: auto height, no clipping, content centered — background clips to border-radius natively */
  .dash-card { height: auto; overflow: visible; justify-content: center; }
}

/* ─── Expected Arrivals Panel ─────────────────────────────────── */

/* Port tabs */
.arrivals-port-tabs {
  flex-shrink: 0;
  display: flex;
  gap: 6px;
  padding: 12px 16px 8px;
  background: transparent;
  border-bottom: 1px solid var(--glass-border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.arrivals-port-tabs::-webkit-scrollbar { display: none; }

.arrivals-port-tab {
  padding: 6px 16px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--glass-border);
  background: none;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  flex-shrink: 0;
  font-family: inherit;
}
.arrivals-port-tab:hover { color: var(--text-1); border-color: rgba(41,204,245,0.25); }
.arrivals-port-tab[aria-selected="true"] {
  background: var(--accent-dim);
  border-color: rgba(41,204,245,0.35);
  color: var(--accent);
}

.arrivals-port-tab .arrivals-port-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 16px;
  background: rgba(255,255,255,0.08);
  border-radius: var(--r-pill);
  font-size: 9px;
  font-weight: 600;
  padding: 0 5px;
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  vertical-align: middle;
}
.arrivals-port-tab[aria-selected="true"] .arrivals-port-count {
  background: var(--accent-mid);
  color: var(--accent);
}

/* Arrivals scroll list */
.arrivals-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}
.arrivals-list::-webkit-scrollbar { width: 4px; }
.arrivals-list::-webkit-scrollbar-thumb { background: rgba(41,204,245,0.15); border-radius: 2px; }

/* Individual arrival cards — compact grid layout matching v2.2 */
.arrival-row {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-card);
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-rows: auto auto;
  column-gap: 10px;
  row-gap: 2px;
  align-items: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
  overflow: hidden;
}
.arrival-row:hover { border-color: rgba(41,204,245,0.25); background: rgba(13,33,55,0.85); }
.arrival-row:active { background: rgba(41,204,245,0.06); }
.arrival-row.is-hidden-preview { opacity: 0.5; border-style: dashed; }

/* Top row: icon + name/type + badge */
.arrival-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.arrival-vessel-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent);
}
.arrival-vessel-icon svg { width: 18px; height: 18px; stroke-width: 1.5; }
.arrival-info { flex: 1; min-width: 0; }
.arrival-name {
  grid-column: 1; grid-row: 1;
  font-size: 14px; font-weight: 600; color: var(--text-1);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.arrival-type {
  grid-column: 1; grid-row: 2;
  font-size: 9px; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.arrival-badge {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  flex-shrink: 0;
  align-self: flex-start;
}
.arrival-badge.expected { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(41,204,245,0.2); }
.arrival-badge.arrived  { background: rgba(38,208,124,0.12); color: var(--success); border: 1px solid rgba(38,208,124,0.2); }
.arrival-badge.delayed  { background: rgba(240,192,64,0.12); color: var(--warning); border: 1px solid rgba(240,192,64,0.2); }

/* ETA column — stacked vertically, right-aligned */
.arrival-eta {
  grid-column: 2; grid-row: 1 / span 2;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
}
.arrival-meta-item { display: flex; flex-direction: column; gap: 2px; }
.arrival-meta-label { font-size: 9px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; }
.arrival-meta-value { font-size: 12px; color: var(--text-1); font-variant-numeric: tabular-nums; }

/* Original compact ETA spans (JS renders these inside .arrival-eta) */
.arrival-eta-date {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.arrival-eta-time {
  font-size: 11px;
  font-weight: 400;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.arrival-eta-relative { font-size: 9px; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* Dismiss / restore button */
.arrival-dismiss {
  grid-column: 3; grid-row: 1 / span 2;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--text-2);
  opacity: 0.45;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  align-self: center;
  transition: opacity 0.12s, background-color 0.12s, color 0.12s;
}
.arrival-dismiss svg { width: 0.95rem; height: 0.95rem; }
.arrival-dismiss:hover,
.arrival-dismiss:focus-visible {
  opacity: 1;
  background: rgba(0,0,0,0.06);
  color: var(--text-1);
  outline: none;
}

/* Hidden footer */
.arrivals-hidden-footer {
  padding: 10px 16px 4px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: var(--text-2);
  font-weight: 300;
}
.arrivals-hidden-link {
  color: var(--accent);
  font-size: 11px;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  transition: color 0.12s;
}
.arrivals-hidden-link:hover,
.arrivals-hidden-link:focus-visible { color: var(--text-1); outline: none; }

/* Empty state */
.arrivals-empty { padding: 2rem 1rem; text-align: center; color: var(--text-2); font-size: var(--fs-base); font-weight: 300; }
.arrivals-empty .arrivals-empty-icon { display: block; width: 2.4rem; height: 2.4rem; margin: 0 auto 0.6rem; opacity: 0.25; }

/* Stale data banner */
.arrivals-stale-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 0 0 8px;
  background: rgba(240,192,64,0.08);
  border: 1px solid rgba(240,192,64,0.20);
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 400;
  color: var(--warning);
}
.arrivals-stale-banner svg { width: 0.95rem; height: 0.95rem; flex-shrink: 0; }

/* ── Bottom view-tab bar (Expected / Recently Arrived) ─────────── */
.arrivals-view-tabs {
  flex-shrink: 0;
  display: flex;
  border-top: 1px solid var(--glass-border);
  background: rgba(10,22,40,0.95);
  padding-bottom: env(safe-area-inset-bottom, 4px);
}
.arrivals-view-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px 8px;
  background: none;
  border: none;
  color: var(--text-2);
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s;
  position: relative;
}
.arrivals-view-tab svg { width: 20px; height: 20px; stroke-width: 1.6; }
.arrivals-view-tab.active { color: var(--accent); }
.arrivals-view-tab.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 25%;
  right: 25%;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  border-radius: 0 0 2px 2px;
}
.arrivals-view-tab:hover:not(.active) { color: var(--text-1); }

/* ─── Pull-to-refresh ─────────────────────────────────────────── */
.pull-refresh-wrap {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.pull-refresh-wrap > * { flex: 1; min-height: 0; }
.pull-refresh-indicator {
  position: absolute;
  top: -40px;
  left: 50%;
  margin-left: -18px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  z-index: 5;
  pointer-events: none;
  opacity: 0;
}
.pull-refresh-indicator svg { width: 18px; height: 18px; }
.pull-refresh-indicator.refreshing svg { animation: spin 0.8s linear infinite; }

/* ─── Live Weather ────────────────────────────────────────────── */
.weather-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Weather cam one-time tip banner ─────────────────────────── */
.wx-cam-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(41, 204, 245, 0.08);
  border: 1px solid rgba(41, 204, 245, 0.22);
  border-radius: var(--r-card);
  padding: 10px 14px;
  margin-bottom: 10px;
  max-height: 80px;
  overflow: hidden;
  transition: opacity 0.25s, max-height 0.25s, padding 0.25s, margin-bottom 0.25s;
}
.wx-cam-banner-icon {
  color: var(--accent);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.wx-cam-banner-text {
  flex: 1;
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.4;
}
.wx-cam-banner-close {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 11px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.wx-cam-banner-close:hover { background: rgba(255,255,255,0.08); color: var(--text-1); }

/* Weather cards — styled like mock-up .weather-card */
.wx-card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-card);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  align-self: start;
  transition: border-color 0.2s;
}
.wx-card:hover { border-color: rgba(41,204,245,0.25); }
.wx-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: var(--r-card) 0 0 var(--r-card);
  background: var(--accent);
  opacity: 0.5;
}
.wx-card.wx-card-nodata { opacity: 0.55; border-style: dashed; }
.wx-card.wx-card-nodata::before { background: var(--text-2); opacity: 0.4; }

/* Weather top row */
.wx-top { display: flex; align-items: center; gap: 12px; }
.wx-station { flex: 1; }
.wx-name { font-size: 13px; font-weight: 500; color: var(--text-1); line-height: 1.2; }
.wx-age {
  font-size: 9px;
  font-weight: 400;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.wx-wind-big { text-align: right; }
.wx-primary {
  font-size: 26px;
  font-weight: 300;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.wx-primary small { font-size: 12px; color: var(--text-2); }
.wx-gust { font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.wx-gust:empty { display: none; }
.wx-wave { font-size: 11px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wx-wave:empty { display: none; }
.wx-trend { display: inline-block; font-size: 1.4rem; font-weight: 700; line-height: 1; vertical-align: -3px; margin-left: 0.12rem; color: inherit; }

/* Weather details row */
.wx-details {
  display: flex;
  border-top: 1px solid var(--glass-border);
  padding-top: 10px;
}
.wx-detail-item { flex: 1; display: flex; flex-direction: column; gap: 2px; align-items: center; }
.wx-detail-item:not(:last-child) { border-right: 1px solid var(--glass-border); }
.wd-label { font-size: 9px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; }
.wd-value { font-size: 12px; color: var(--text-1); font-variant-numeric: tabular-nums; }
.wd-value.accent { color: var(--accent); }

/* Wind speed color classes */
.wx-card.wx-speed-calm     .wx-primary, .wx-card.wx-speed-calm     .wx-trend { color: var(--success); }
.wx-card.wx-speed-moderate .wx-primary, .wx-card.wx-speed-moderate .wx-trend { color: var(--warning); }
.wx-card.wx-speed-strong   .wx-primary, .wx-card.wx-speed-strong   .wx-trend { color: var(--danger); }

@media (min-width: 620px) {
  .weather-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.65rem;
    padding: 16px;
    align-content: start;
    align-items: start;
  }
  .arrivals-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 10px;
    padding: 16px;
    align-content: start;
  }
}

/* ─── Vessel Detail Sheet ─────────────────────────────────────── */
.vessel-detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(6,14,26,0.70);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  animation: fade-in var(--dur-fast) ease;
}
.vessel-detail-sheet {
  width: 100%;
  background: linear-gradient(180deg, #0f2540 0%, var(--bg) 100%);
  border-top: 1px solid var(--glass-border);
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  overflow: hidden;
  transform: translateY(100%);
  transition: transform var(--dur-normal) var(--ease-out);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  will-change: transform;
}
.vessel-detail-overlay.open .vessel-detail-sheet { transform: translateY(0); }
.vessel-detail-handle {
  width: 36px;
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  margin: 12px auto 0;
  flex-shrink: 0;
}
.vessel-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}
.vessel-detail-name {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-1);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vessel-detail-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: none;
  color: var(--text-2);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.vessel-detail-close:hover { background: rgba(255,255,255,0.12); color: var(--text-1); }

.vessel-detail-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(41,204,245,0.20);
  margin: 0 20px 12px;
  align-self: flex-start;
}
.vessel-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--glass-border);
  border-top: 1px solid var(--glass-border);
  border-bottom: 1px solid var(--glass-border);
  flex: 1;
  overflow-y: auto;
}
.vessel-detail-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  background: var(--bg);
}
.vessel-detail-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
}
.vessel-detail-value {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  word-break: break-word;
  line-height: 1.3;
}
.vessel-detail-actions { padding: 0.25rem 1rem 0.5rem; }
.vessel-detail-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--accent-dim);
  border: 1px solid rgba(41,204,245,0.25);
  border-radius: 12px;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.vessel-detail-link:hover,
.vessel-detail-link:focus-visible {
  background: var(--accent-mid);
  color: var(--text-1);
  outline: none;
}

/* Wider screens: centered modal */
@media (min-width: 600px) {
  .vessel-detail-overlay {
    align-items: center;
    justify-content: center;
    padding: 1rem;
  }
  .vessel-detail-sheet {
    width: min(520px, 100%);
    max-height: 80vh;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    transform: translateY(16px) scale(0.97);
  }
  .vessel-detail-overlay.open .vessel-detail-sheet {
    transform: translateY(0) scale(1);
  }
}

/* ════════════════════════════════════════════════════════════════
   LAYER 6 · STATES

   6a · Night mode — red instrument lighting
   ════════════════════════════════════════════════════════════════ */
body.night-mode {
  --color-bg:           #0c0000;
  --color-surface:      #160000;
  --color-surface-mid:  #1e0000;
  --color-surface-hi:   #280000;
  --color-border:       rgba(180, 0, 0, 0.18);
  --color-border-hi:    rgba(220, 0, 0, 0.30);
  --color-accent:       #c0392b;
  --color-accent-dim:   rgba(192, 57, 43, 0.16);
  --color-accent-mid:   rgba(192, 57, 43, 0.22);
  --color-accent-glow:  rgba(192, 57, 43, 0.32);
  --color-accent-chip:  rgba(192, 57, 43, 0.16);
  --color-text-1:       #cc8080;
  --color-text-2:       #7a3030;
  --color-text-3:       #3d1515;
  /* Override mock-up tokens too */
  --bg:           #0c0000;
  --bg-section:   #160000;
  --bg-elevated:  #280000;
  --glass-bg:     rgba(22, 0, 0, 0.75);
  --glass-border: rgba(180, 0, 0, 0.18);
  --accent:       #c0392b;
  --accent-dim:   rgba(192, 57, 43, 0.16);
  --accent-mid:   rgba(192, 57, 43, 0.22);
  --accent-glow:  rgba(192, 57, 43, 0.32);
  --text-1:       #cc8080;
  --text-2:       #7a3030;
  --text-3:       #3d1515;
}
body.night-mode .page-img {
  filter: brightness(0.36) sepia(1) saturate(5) hue-rotate(300deg);
}
body.night-mode #appHeader {
  background: linear-gradient(180deg, rgba(28,0,0,0.98) 0%, rgba(22,0,0,0.93) 100%);
  border-bottom-color: rgba(192,57,43,0.30);
}
body.night-mode .bottom-toolbar {
  background: rgba(12,0,0,0.92);
  border-top-color: rgba(192,57,43,0.25);
}
body.night-mode #viewerMain {
  background: radial-gradient(ellipse 110% 65% at 50% 52%, #220000 0%, #050000 72%);
}
body.night-mode body::before {
  background-image:
    linear-gradient(rgba(192,57,43,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(192,57,43,0.015) 1px, transparent 1px);
}
body.night-mode .book-spine {
  background: linear-gradient(to right, #000 0%, #100000 50%, #000 100%);
}
body.night-mode #nightModeBtn { color: #c0392b; }
body.night-mode #progressBar {
  background: linear-gradient(90deg, #c0392b, #e05c5c);
}
body.night-mode #progressBar::after { background: #c0392b; }
body.night-mode #todayBtn {
  background: linear-gradient(135deg, #c0392b 0%, #922b21 100%);
  box-shadow: 0 4px 20px rgba(192,57,43,0.40), 0 2px 8px rgba(0,0,0,0.50);
  color: #fff;
  border-color: #0c0000;
}
body.night-mode #todayBtn:active {
  background: linear-gradient(135deg, #a93226 0%, #7b241c 100%);
}
body.night-mode .drawer-header {
  background: rgba(22,0,0,0.95);
  border-bottom-color: rgba(192,57,43,0.25);
}
body.night-mode .tide-countdown {
  background: rgba(18,0,0,0.88);
  border-color: rgba(192,57,43,0.25);
}
body.night-mode .dash-card { background: rgba(22,0,0,0.75); }
body.night-mode .wx-card   { background: rgba(22,0,0,0.75); }
body.night-mode .arrival-row { background: rgba(22,0,0,0.75); }
body.night-mode .dash-arrow.rising,  body.night-mode .dash-arrow.flood  { color: #b45309; }
body.night-mode .dash-arrow.falling, body.night-mode .dash-arrow.ebb   { color: #991b1b; }
body.night-mode .dash-event-ht { color: #9a3412; }
body.night-mode .arrival-eta-time { color: #9a3412; }
body.night-mode .arrival-dismiss:hover,
body.night-mode .arrival-dismiss:focus-visible { background: rgba(180,0,0,0.16); }
body.night-mode .arrivals-hidden-link { color: #fca5a5; }
body.night-mode .arrivals-port-tab[aria-selected="true"] {
  background: rgba(127,29,29,0.4);
  border-color: rgba(127,29,29,0.6);
  color: #fee2e2;
}
body.night-mode .wx-card::before { background: #b91c1c; }
body.night-mode .pull-refresh-indicator { background: rgba(22,0,0,0.85); color: #fca5a5; }
body.night-mode .vessel-detail-overlay { background: rgba(12,0,0,0.80); }
body.night-mode .vessel-detail-sheet   { border-color: rgba(180,30,30,0.30); }
body.night-mode .vessel-detail-badge   { background: rgba(180,30,30,0.15); border-color: rgba(180,30,30,0.3); color: #fca5a5; }
body.night-mode .vessel-detail-link    { background: rgba(180,30,30,0.12); border-color: rgba(180,30,30,0.30); color: #fca5a5; }
body.night-mode .vessel-detail-link:hover { background: rgba(180,30,30,0.25); color: #fff; }
body.night-mode .arrivals-view-tabs    { background: rgba(12,0,0,0.95); border-top-color: rgba(192,57,43,0.25); }
body.night-mode .arrivals-view-tab.active { color: #fca5a5; }
body.night-mode .arrivals-view-tab.active::after { background: #fca5a5; box-shadow: 0 0 8px rgba(192,57,43,0.35); }
body.night-mode .dashboard-header { background: rgba(22,0,0,0.95); border-bottom-color: rgba(192,57,43,0.30); }
body.night-mode .dashboard-footer { background: rgba(12,0,0,0.95); border-top-color: rgba(192,57,43,0.18); }

/* 6b · Fullscreen mode */
body.fs-mode #appHeader,
body.fs-mode .bottom-toolbar {
  position: fixed;
  left: 0; right: 0;
  z-index: 50;
  transition:
    transform var(--dur-normal) var(--ease-in),
    opacity  var(--dur-normal) var(--ease-in);
}
body.fs-mode #appHeader      { top: 0; }
body.fs-mode .bottom-toolbar { bottom: 0; }
body.fs-mode #viewerMain { position: fixed; inset: 0; z-index: 1; }
body.fs-mode.ui-hide #appHeader      { transform: translateY(-100%); opacity: 0; pointer-events: none; }
body.fs-mode.ui-hide .bottom-toolbar { transform: translateY(100%);  opacity: 0; pointer-events: none; }

/* ════════════════════════════════════════════════════════════════
   LAYER 7 · UTILITIES
   ════════════════════════════════════════════════════════════════ */
.hidden { display: none !important; }

/* ════════════════════════════════════════════════════════════════
   LAYER 8 · RESPONSIVE
   ════════════════════════════════════════════════════════════════ */
@media (orientation: landscape) and (max-height: 480px) {
  :root { --header-h: 44px; --toolbar-h: 52px; }
  .header-name { font-size: 0.85rem; }
  .toolbar-label { display: none; }
  .toolbar-icon { width: 18px; height: 18px; }
  #todayBtn { width: 46px; height: 46px; margin-top: -18px; }
  #todayBtn .toolbar-label { display: none; }
}
@media (orientation: landscape) and (max-height: 500px) {
  body.mob-ls #appHeader,
  body.mob-ls .bottom-toolbar { position: fixed; left: 0; right: 0; z-index: 50; }
  body.mob-ls #appHeader      { top: 0; }
  body.mob-ls .bottom-toolbar { bottom: 0; }
  body.mob-ls #viewerMain     { position: fixed; inset: 0; z-index: 1; }
  body.mob-ls:not(.mob-ls-show) #appHeader      { transform: translateY(-100%); opacity: 0; pointer-events: none; }
  body.mob-ls:not(.mob-ls-show) .bottom-toolbar { transform: translateY(100%);  opacity: 0; pointer-events: none; }
  body.mob-ls.mob-ls-show #appHeader,
  body.mob-ls.mob-ls-show .bottom-toolbar { transform: translateY(0); opacity: 1; pointer-events: auto; }
}
@media (max-width: 375px) {
  .header-org { display: none; }
  .clock      { display: none; }
  .toolbar-label { font-size: 8px; }
}

/* ─── Tide Graph ──────────────────────────────────────────────── */

/* Dash cards are tappable on tide stations */
.dash-card.tappable {
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast);
}
.dash-card.tappable:hover {
  background: rgba(41,204,245,0.08);
  border-color: rgba(41,204,245,0.22);
}
.dash-card.tappable:active { transform: scale(0.985); }

/* Overlay reuses vessel-detail-overlay structure; sheet overrides height */
.tide-graph-sheet {
  max-height: 90vh;
}

/* Graph SVG wrapper */
.tg-wrap {
  padding: 4px 12px 8px;
  overflow: hidden;
  flex-shrink: 0;
}
.tg-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

/* SVG text classes (styled via CSS so the SVG stays clean) */
.tg-axis-label {
  font-size: 8px;
  fill: rgba(255,255,255,0.38);
  font-family: 'Inter', -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
}
.tg-day-label {
  font-size: 8.5px;
  fill: rgba(255,255,255,0.32);
  font-family: 'Inter', -apple-system, sans-serif;
  letter-spacing: 0.03em;
}
.tg-now-label {
  font-size: 7.5px;
  font-weight: 600;
  fill: rgba(41,204,245,0.9);
  font-family: 'Inter', -apple-system, sans-serif;
  letter-spacing: 0.06em;
}
.tg-event-label {
  font-size: 8.5px;
  font-weight: 500;
  font-family: 'Inter', -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
}
.tg-event-label.tg-high { fill: rgba(41,204,245,0.95); }
.tg-event-label.tg-low  { fill: rgba(255,255,255,0.55); }
.tg-event-time {
  font-size: 7.5px;
  fill: rgba(255,255,255,0.38);
  font-family: 'Inter', -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
}

/* Loading state inside graph wrap */
.tg-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 28px 0;
  justify-content: center;
  color: var(--text-2);
  font-size: 0.85rem;
}
.tg-loading .spinner {
  width: 20px;
  height: 20px;
  border-width: 2px;
}
.tg-empty {
  text-align: center;
  color: var(--text-2);
  font-size: 0.85rem;
  padding: 28px 16px;
  line-height: 1.5;
}

/* Current-conditions row below graph */
.tg-info-row {
  display: flex;
  gap: 20px;
  padding: 0 20px 16px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.tg-info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tg-info-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  font-weight: 400;
}
.tg-info-val {
  font-size: 15px;
  font-weight: 300;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
}
.tg-info-val.accent { color: var(--accent); }

/* Night mode adjustments */
body.night-mode .tide-graph-overlay { background: rgba(12,0,0,0.80); }

/* ─── Weather Cam Overlay ─────────────────────────────────────── */
/* Reuses vessel-detail-overlay / sheet structure; iframe fills body */

.wx-cam-sheet {
  height: 88vh;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

/* Header bar (reuses tg-header style) */
.wx-cam-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}
.wx-cam-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wx-cam-ext-link {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  padding: 4px 10px;
  border: 1px solid rgba(41,204,245,0.25);
  border-radius: var(--r-pill);
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
  text-decoration: none;
}
.wx-cam-ext-link:hover { background: rgba(41,204,245,0.08); }
.wx-cam-close {
  width: 28px; height: 28px; border-radius: 50%;
  font-size: 13px; color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}
.wx-cam-close:hover { background: rgba(255,255,255,0.06); color: var(--text-1); }

/* iframe wrapper */
.wx-cam-frame-wrap {
  flex: 1;
  overflow: hidden;
  background: var(--bg);
  position: relative;
}
.wx-cam-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: var(--bg);
  display: block;
}

/* No-cam message */
.wx-cam-nocam {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-2);
  font-size: 13px;
  padding: 2rem;
  text-align: center;
  line-height: 1.5;
}
.wx-cam-nocam strong { color: var(--text-1); }

body.night-mode .wx-cam-overlay { background: rgba(12,0,0,0.80); }

/* ════════════════════════════════════════════════════════════════
   PRINT
   ════════════════════════════════════════════════════════════════ */
@media print {
  #appHeader, .bottom-toolbar, .zoom-controls,
  .drawer, .drawer-overlay, .sheet, .modal-overlay { display: none !important; }
  #viewerMain, #pageImage { position: static !important; width: 100% !important; height: auto !important; }
}
