/*
 * Nauti Cloud. Brand: navy #0a4765, sea blue #257ea9, helm orange #f08a24, cream #f3f0e8.
 * One design system for every page (CLOUD_UX_REVIEW.md §5): tokens first, then base,
 * layout, components, and last the few page-specific pieces.
 */

/* ---- Tokens */
:root {
  color-scheme: dark;
  /* Surfaces */
  --bg: #061820;
  --bg-2: #08212c;
  --panel: #0d2a38;
  --panel-2: #113546;
  --line: #1b4457;
  --line-2: #24586f;
  /* Text */
  --ink: #f3f0e8;
  --ink-2: #d6e2e7;
  --muted: #93b3c2;
  /* Brand */
  --navy: #0a4765;
  --blue: #257ea9;
  --blue-2: #5cb8e4;
  --blue-3: #8fd0f0;
  --orange: #f08a24;
  --orange-2: #ffa54d;
  --on-orange: #1b1004;
  /* Status */
  --ok: #43c463;
  --warn: #f0c27a;
  --error: #ff9b8a;
  --only-you: #c9a7ff;
  /* Data colours (graphs, leg types): shared with the share images */
  --beat: #4fb0de;
  --reach: #9fd36b;
  --run: #f08a24;
  /* Spacing: a 4 px scale */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s7: 32px;
  --s8: 48px;
  /* Type */
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-xs: 0.72rem;
  --fs-sm: 0.86rem;
  --fs-md: 1rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.6rem;
  --fs-2xl: clamp(1.7rem, 1.2rem + 1.6vw, 2.4rem);
  /* Shape */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.18);
  --wrap: 1120px;
  --gutter: 32px;
}
@media (min-width: 1600px) { :root { --wrap: 1280px; } }
@media (max-width: 900px) { :root { --gutter: 24px; } }
@media (max-width: 600px) { :root { --gutter: 16px; } }

/* ---- Base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
main { flex: 1 0 auto; }
a { color: var(--blue-2); text-underline-offset: 3px; }
a:hover { color: var(--blue-3); }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { line-height: 1.15; margin: 0; font-weight: 700; letter-spacing: -0.015em; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
small { font-size: 0.7em; }
button { font: inherit; }
.hidden { display: none !important; }
[id] { scroll-margin-top: 84px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.skip { position: absolute; left: var(--s3); top: -60px; z-index: 1000; background: var(--orange); color: var(--on-orange); padding: var(--s2) var(--s3); border-radius: var(--r-sm); font-weight: 600; }
.skip:focus { top: var(--s3); }

/* Small caps label: every stat, tile, table head and instrument uses this one style. */
.label, .stats dt, .tiles dt, .instruments b, .facts span, .data-table th, .race-table th, .leg-facts dt {
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.eyebrow { margin: 0 0 var(--s2); color: var(--orange-2); font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.lede { color: var(--muted); margin: var(--s3) 0 0; font-size: 1.08rem; max-width: 46rem; }

/* ---- Layout */
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }
.content { padding-top: var(--s7); padding-bottom: var(--s8); }
.hero + .content { padding-top: var(--s7); }

/* Header: logo, then Voyages · My voyages · Account (or Sign in). Legal links are in the footer. */
.top {
  position: sticky;
  top: 0;
  z-index: 900;
  background: rgba(10, 71, 101, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 -2px 0 var(--orange);
}
.top .wrap { display: flex; justify-content: space-between; align-items: center; min-height: 64px; gap: var(--s4); }
.brand { display: flex; align-items: center; gap: var(--s3); color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); }
.brand img { width: 40px; height: 40px; border-radius: 50%; }
.brand-name { font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em; white-space: nowrap; }
.brand-name small { color: #bcd9e6; font-weight: 500; font-size: 0.8rem; letter-spacing: 0; margin-left: var(--s1); }
.top nav { display: flex; gap: var(--s1); }
.top nav a { color: var(--ink); text-decoration: none; font-weight: 500; padding: var(--s2) 14px; border-radius: 999px; opacity: 0.85; white-space: nowrap; }
.top nav a:hover { opacity: 1; background: rgba(255, 255, 255, 0.08); color: var(--ink); }
.top nav a[aria-current="page"] { opacity: 1; background: rgba(255, 255, 255, 0.12); }

/* Tall title band: home, profile and legal pages only. */
.hero {
  background:
    radial-gradient(1200px 300px at 80% -40%, rgba(37, 126, 169, 0.45), transparent 70%),
    linear-gradient(180deg, #0b3349 0%, var(--bg) 100%);
  padding: 56px 0 40px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.hero h1 { font-size: clamp(2rem, 1.3rem + 2.4vw, 3rem); }

/* Footer */
.foot { border-top: 1px solid var(--line); background: var(--bg-2); color: var(--muted); font-size: var(--fs-sm); }
.foot .wrap { display: flex; justify-content: space-between; align-items: center; gap: var(--s3) var(--s6); flex-wrap: wrap; padding-top: 22px; padding-bottom: 22px; }
.foot p { margin: 0; }
.foot-small { margin-top: var(--s1) !important; font-size: 0.78rem; opacity: 0.85; max-width: 40rem; }
.foot nav { display: flex; flex-wrap: wrap; gap: var(--s5); }
.foot nav a { color: var(--muted); }
.foot nav a:hover { color: var(--ink); }

/* ---- Components */

/* Page header: back link, kicker, title, actions. Every page that isn't a landing page. */
.back { display: inline-block; color: var(--muted); text-decoration: none; font-size: 0.9rem; margin-bottom: var(--s3); }
.back:hover { color: var(--ink); }
.page-head, .head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s4) var(--s6); flex-wrap: wrap; }
.head-text { min-width: 0; }
.page-head h1, .head h1 { overflow-wrap: anywhere; }
.kicker { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s2); margin: 0 0 var(--s2); color: var(--muted); font-size: 0.95rem; }
.kicker a { color: var(--ink-2); }
.page-head .lede { margin-top: var(--s2); }
.page-head + * { margin-top: var(--s6); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: 9px var(--s4);
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.btn:hover { color: var(--ink); border-color: var(--blue); background: var(--panel-2); }
.btn.primary { background: var(--orange); border-color: var(--orange); color: var(--on-orange); }
.btn.primary:hover { background: var(--orange-2); color: var(--on-orange); }
.btn.quiet { background: transparent; }
.linkish { background: none; border: 0; padding: 0; color: var(--blue-2); cursor: pointer; text-align: left; text-decoration: underline; text-underline-offset: 3px; font: inherit; }
.linkish:hover { color: var(--blue-3); }

/* Badges: voyage type, visibility, owner-only */
.badge { display: inline-flex; align-items: center; gap: var(--s1); padding: 2px var(--s2); border-radius: 999px; font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; line-height: 1.5; white-space: nowrap; border: 1px solid transparent; }
.badge.type-race { background: var(--orange); color: var(--on-orange); }
.badge.type-passage { background: var(--beat); color: #0a2433; }
.badge.type-daysail { background: var(--reach); color: #0a2433; }
.badge.vis-private { border-color: var(--line-2); color: var(--ink-2); }
.badge.vis-link { border-color: var(--blue); color: var(--blue-3); }
.badge.vis-public { border-color: rgba(67, 196, 99, 0.6); color: #8de0a2; }
.badge.only { border-color: rgba(201, 167, 255, 0.55); color: var(--only-you); letter-spacing: 0.04em; }
.badge.only::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--only-you); }

/* Panels and sections */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s5); }
.section { margin: var(--s8) 0 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2) var(--s3); flex-wrap: wrap; margin-bottom: 14px; }
.section-head h2 { font-size: var(--fs-lg); }
.section-head p { margin: 0; color: var(--muted); font-size: var(--fs-sm); }
.section h3, .fold > summary h3 { font-size: 0.95rem; margin: 0 0 var(--s2); color: var(--ink-2); }
.section-status { margin: 0; padding: var(--s4) var(--s5); color: var(--muted); background: var(--panel); border: 1px dashed var(--line-2); border-radius: var(--r); }
.section-status.error { color: var(--warn); border-style: solid; border-color: rgba(240, 194, 122, 0.35); }
.block { margin: var(--s4) 0 0; }

/* Folded detail: a native disclosure with a one-line summary. */
.fold { margin: var(--s4) 0 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.fold > summary { display: flex; align-items: baseline; gap: var(--s2) var(--s3); flex-wrap: wrap; padding: 14px var(--s4); cursor: pointer; list-style: none; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before { content: "▸"; color: var(--blue-2); flex: none; transition: transform 0.15s; }
.fold[open] > summary::before { transform: rotate(90deg); }
.fold > summary h2, .fold > summary h3 { margin: 0; display: inline; }
.fold > summary h2 { font-size: var(--fs-lg); }
.fold-sum { color: var(--muted); font-size: var(--fs-sm); }
.fold > .fold-body { padding: 0 var(--s4) var(--s4); }
.fold .data-table, .fold .race-table { border-radius: var(--r-sm); }
.section-fold { margin-top: 0; background: transparent; border: 0; }
.section-fold > summary { padding: 0 0 14px; }
.section-fold > .fold-body { padding: 0; }

/* In-page jump links under the replay */
.jump { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin: var(--s6) 0 0; font-size: 0.9rem; }
.jump span { color: var(--muted); margin-right: var(--s1); }
.jump a { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--ink); text-decoration: none; background: var(--panel); }
.jump a:hover { border-color: var(--blue); }

/* Headline strip and tile grids. Dividers are cell shadows, so a short last row is plain panel. */
.stats, .tiles {
  display: grid;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  margin: 0;
}
.stats { grid-template-columns: repeat(4, 1fr); margin-top: var(--s6); }
.tiles { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.stats-note { margin: var(--s2) 0 0; color: var(--muted); font-size: 0.9rem; }
.stats-note a { color: var(--ink-2); }
.stats > div, .tiles > div { padding: 14px var(--s5); box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line); min-width: 0; }
.stats dd, .tiles dd { margin: var(--s1) 0 0; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stats dd { font-size: var(--fs-xl); }
.tiles dd { font-size: 1.4rem; }
.tiles dt { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s2); align-items: center; }
.stats small, .tiles small, .facts small, .instruments small { color: var(--muted); font-weight: 500; margin-left: 3px; }
.tiles .note { display: block; color: var(--muted); font-size: 0.8rem; font-weight: 500; letter-spacing: 0; margin-top: 2px; }
.tiles .only-you { background: rgba(201, 167, 255, 0.05); }

/* Tables */
.data-table, .race-table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; font-variant-numeric: tabular-nums; font-size: 0.92rem; }
.data-table th, .race-table th { text-align: left; padding: 10px var(--s3); border-bottom: 1px solid var(--line); }
.data-table td, .race-table td { padding: 9px var(--s3); border-bottom: 1px solid var(--line); }
.data-table tr:last-child td, .race-table tr:last-child td { border-bottom: 0; }
.race-table td:not(:first-child), .race-table th:not(:first-child) { text-align: right; }
.race-table small { color: var(--muted); margin-left: 6px; }
.table-scroll { overflow-x: auto; position: relative; }

/* Notices: the not-for-navigation line, form errors, drafts */
.warn, .notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: var(--s7) 0 0;
  padding: var(--s3) var(--s4);
  border-radius: var(--r-sm);
  font-size: 0.9rem;
}
.warn { color: var(--warn); background: rgba(240, 194, 122, 0.07); border: 1px solid rgba(240, 194, 122, 0.22); }
.warn::before { content: "⚠"; flex: none; }
.form-error { margin: 0 0 14px; padding: 10px var(--s3); border-radius: var(--r-sm); background: rgba(240, 194, 122, 0.12); color: var(--warn); border: 1px solid rgba(240, 194, 122, 0.35); }
.form-note { color: var(--muted); font-size: 0.9rem; margin: 14px 0 0; }
.saved { color: var(--ok); font-size: 0.88rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.live-panel { margin: 0 0 var(--s5); }
.live-panel p { margin: var(--s2) 0 0; overflow-wrap: anywhere; }
.owner-bar p.saved { flex-basis: 100%; margin: 0; }

/* Forms */
input[type="text"], input[type="password"], input[type="email"], input:not([type]), select {
  background: var(--bg-2);
  color: var(--ink);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: 10px var(--s3);
  font: inherit;
}
input::placeholder { color: #7f9dab; }
input:focus-visible, select:focus-visible { outline: 2px solid var(--blue-2); outline-offset: 1px; }
input[type="checkbox"] { accent-color: var(--orange); width: 18px; height: 18px; margin: 0; }
.row { display: flex; gap: var(--s2); flex-wrap: wrap; }
.row input { flex: 1 1 200px; min-width: 0; }
.lock button, .report button {
  background: var(--orange);
  color: var(--on-orange);
  font-weight: 650;
  border: 0;
  border-radius: var(--r-sm);
  padding: 10px 18px;
  cursor: pointer;
}
.lock button:hover, .report button:hover { background: var(--orange-2); }
.panel-form { max-width: 460px; }
.panel-form label { display: block; color: var(--ink-2); margin-bottom: var(--s2); font-weight: 600; }
.panel-form input[type="email"], .panel-form input#code { width: 100%; margin-bottom: var(--s4); }
.panel-form .check { display: flex; gap: var(--s2); align-items: center; font-weight: 500; margin: 0 0 var(--s4); }
.panel-form input#code { font-size: 1.4rem; letter-spacing: 0.3em; max-width: 12rem; font-variant-numeric: tabular-nums; }
.inline-form { display: inline-block; margin: 0 var(--s2) var(--s2) 0; }

/* Empty states */
.empty-state { text-align: center; margin-top: var(--s6); padding: 64px var(--s6); border: 1px dashed var(--line-2); border-radius: var(--r); color: var(--muted); }
.empty-state svg { color: var(--blue-2); }
.empty-state h2, .empty-state h3 { color: var(--ink); font-size: 1.3rem; margin: var(--s3) 0 6px; }
.empty-state p { margin: 0 auto; max-width: 30rem; }

/* Loading */
.spinner { display: inline-block; width: 16px; height: 16px; margin-right: 10px; vertical-align: -3px; border: 2px solid var(--line-2); border-top-color: var(--orange); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Meter (storage) */
.meter { display: block; width: 100%; max-width: 320px; height: 8px; margin: var(--s2) 0 0; border: 0; border-radius: 999px; overflow: hidden; background: var(--panel-2); accent-color: var(--blue-2); appearance: none; }
.meter::-webkit-progress-bar { background: var(--panel-2); border-radius: 999px; }
.meter::-webkit-progress-value { background: var(--blue-2); border-radius: 999px; }
.meter::-moz-progress-bar { background: var(--blue-2); border-radius: 999px; }

/* ---- Voyage cards (gallery, profile) */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--s6); }
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  color: inherit;
  text-decoration: none;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.card:hover { color: inherit; border-color: var(--line-2); transform: translateY(-3px); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), 0 16px 32px rgba(0, 0, 0, 0.3); }
.card:hover h2, .card:hover h3 { color: var(--orange-2); }
.card .badge { position: absolute; top: var(--s3); left: var(--s3); }
.sketch { aspect-ratio: 16 / 9; background: #0b3346; border-bottom: 1px solid var(--line); overflow: hidden; }
.sketch img { display: block; width: 100%; height: 100%; object-fit: cover; }
.card .body { padding: 18px var(--s5) var(--s5); display: flex; flex-direction: column; flex: 1; }
.card h2, .card h3 { font-size: 1.15rem; font-weight: 650; transition: color 0.15s; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.card .sub { margin: 6px 0 0; color: var(--muted); font-size: 0.9rem; }
.facts { list-style: none; margin: auto 0 0; padding: 14px 0 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.card .sub + .facts { margin-top: var(--s4); }
.facts li { font-size: 1.05rem; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.facts span { display: block; margin-bottom: 2px; }
.pager { display: flex; justify-content: space-between; align-items: center; margin: var(--s7) 0 0; color: var(--muted); }
.pager .btn + .btn { margin-left: auto; }

/* ---- Voyage page */
.owner-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); margin: 0 0 var(--s4); padding: 10px 14px; background: rgba(201, 167, 255, 0.06); border: 1px solid rgba(201, 167, 255, 0.28); border-radius: var(--r-sm); color: var(--ink-2); font-size: 0.9rem; }
.owner-bar .owner-note { flex: 1 1 18rem; }
.owner-bar ul { display: flex; flex-wrap: wrap; gap: var(--s2); list-style: none; margin: 0; padding: 0; }
.owner-bar a.btn { padding: 6px 14px; }

/* Map + replay: one panel */
.player { margin: var(--s5) 0 0; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--panel); box-shadow: var(--shadow); }
.map { height: min(58vh, 560px); min-height: 320px; background: #aad3df; position: relative; }
.map.tall { height: min(66vh, 640px); }
.map-msg { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: var(--s6); text-align: center; color: var(--muted); background: var(--panel-2); }
.leaflet-container { font-family: var(--font); }
.leaflet-control-attribution { font-size: 11px; }
.boat-arrow { filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.55)); }
.replay { display: flex; align-items: center; gap: var(--s4); padding: var(--s3) var(--s4); border-top: 1px solid var(--line); }
.replay button { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--orange); color: var(--on-orange); font-size: 1rem; cursor: pointer; box-shadow: 0 2px 8px rgba(240, 138, 36, 0.35); }
.replay button:hover { background: var(--orange-2); }
.replay button:disabled { opacity: 0.4; cursor: default; box-shadow: none; }
#scrub { flex: 1; min-width: 0; accent-color: var(--orange); height: 28px; }
.clock { flex: none; display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; font-variant-numeric: tabular-nums; min-width: 5.5em; }
.clock strong { font-size: 1.05rem; font-weight: 650; }
.clock span { color: var(--muted); font-size: 0.78rem; }
.speed { flex: none; background: var(--panel-2); color: var(--ink); border: 1px solid var(--line-2); border-radius: 999px; padding: 7px 10px; font: inherit; font-size: 0.85rem; }

/* Instruments at the replay position: cells wrap rather than run off the panel. */
.instruments { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin: var(--s4) 0 0; }
.instruments:empty { display: none; }
/* Seven to ten instruments: two even rows of five rather than a row and a straggler. */
@media (min-width: 901px) { .instruments:has(> div:nth-child(7)) { grid-template-columns: repeat(5, 1fr); } }
.instruments div { padding: var(--s3) var(--s4); box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line); min-width: 0; }
.instruments b { display: block; }
.instruments abbr { text-decoration: none; cursor: help; }
.instruments span { display: block; font-size: 1.4rem; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; margin-top: 2px; }

/* Graphs */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
.chart { position: relative; margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px var(--s4) 10px; }
.chart header { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2); margin-bottom: var(--s2); }
.chart header b { font-size: 0.9rem; }
.chart header b small { color: var(--muted); font-weight: 500; font-size: 0.85em; }
.chart header span { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chart svg { display: block; width: 100%; height: 120px; cursor: crosshair; border-radius: 4px; }
.chart .axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; margin-top: 6px; }
.chart .tip { position: absolute; top: 40px; transform: translateX(-50%); background: var(--ink); color: #0a2433; font-size: 0.78rem; font-weight: 650; padding: 3px var(--s2); border-radius: 6px; pointer-events: none; white-space: nowrap; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4); }
.engine-band { grid-column: 1 / -1; }
.engine-band svg { height: 26px; }
.band-key { display: inline-flex; gap: 6px; align-items: center; }
.band-key i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 6px; }
.leg-beat, .band-key i.band-beat, .band-key i.mark-tack { background: var(--beat); }
.leg-reach, .band-key i.band-reach, .band-key i.mark-gybe { background: var(--reach); }
.leg-run, .band-key i.band-run { background: var(--run); }

/* Race */
.race-takeaways { margin: 0 0 var(--s4); padding: var(--s4) var(--s5); background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--blue-2); border-radius: var(--r); }
.race-takeaways h3 { margin: 0 0 var(--s2); }
.race-takeaways ul { margin: 0; padding-left: 1.1em; display: grid; gap: var(--s2); }
.race-takeaways li { line-height: 1.45; }
.race-takeaways .badge.only { margin-left: 4px; vertical-align: 1px; }
.race-tables { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); margin: var(--s4) 0 0; }
.race-hint, .race-notes { color: var(--muted); font-size: 0.82rem; margin: var(--s2) 0 0; }
.race-notes:empty { display: none; }
.leg-type { display: block; width: max-content; margin-top: 3px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; color: #0a2433; }
.leg-open { background: var(--panel-2); color: var(--ink); border: 1px solid var(--line-2); border-radius: 6px; width: 30px; height: 30px; font-size: 0.9rem; cursor: pointer; }
.leg-open:hover, .leg-open[aria-expanded="true"] { border-color: var(--blue-2); }
.race-table tr.leg-detail td { text-align: left; white-space: normal; background: var(--panel-2); padding: var(--s3); }
.leg-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--s3) 18px; margin: 0; }
.leg-facts dd { margin: 2px 0 0; font-weight: 700; font-size: 1rem; }
.leg-facts p { margin: 2px 0 0; color: var(--muted); font-size: 0.78rem; line-height: 1.35; }
.leg-facts .only-you dt::after { content: " · Only you"; color: var(--only-you); text-transform: none; letter-spacing: 0; }

/* Passage bars */
.bars { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s3) 14px; display: grid; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 7.5em 1fr 5.5em; align-items: center; gap: 10px; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.bar-label { color: var(--ink-2); }
.bar-value { text-align: right; }
.bar-track { position: relative; height: 12px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.bar-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--beat); border-radius: 3px; }
.bar-track.diverging::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--line-2); }
.bar-track.diverging .bar-fill { left: 50%; background: var(--reach); }
.bar-row.neg .bar-track.diverging .bar-fill { left: auto; right: 50%; background: var(--run); }

/* Map labels */
.leaflet-tooltip.mark-label { background: #0a2433; color: var(--ink); border: 0; font-weight: 700; font-size: 12px; box-shadow: none; }
.leaflet-tooltip.mark-label::before { display: none; }
.leaflet-tooltip.line-label { background: #ffffff; color: #0a2433; border: 2px solid #0a2433; box-shadow: none; padding: 3px 7px; line-height: 1.3; }
.leaflet-tooltip.line-label strong { display: block; font-weight: 800; font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }
.leaflet-tooltip.line-label small { display: flex; gap: var(--s2); align-items: center; font-size: 11px; font-weight: 600; }
.leaflet-tooltip.line-label small i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; border: 2px solid #0a2433; margin-right: -4px; }
.leaflet-tooltip.line-label i.end-pin { background: var(--orange); }
.leaflet-tooltip.line-label i.end-boat { background: var(--ink); }
.leaflet-tooltip.line-label::before { display: none; }
#map.labels-off .leaflet-tooltip.mark-label, #map.labels-off .leaflet-tooltip.line-label { visibility: hidden; }
.move-dot { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5)); cursor: pointer; }
.move-bubble { border-radius: 50%; background: var(--beat); border: 2px solid #0a2433; color: #0a2433; font: 700 0.72rem/1 system-ui, sans-serif; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); cursor: zoom-in; }
.move-bubble.gybes { background: var(--reach); }
.move-bubble span { display: flex; width: 100%; height: 100%; align-items: center; justify-content: center; }

/* Share menu */
.share { position: relative; }
.share-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 1000; min-width: 230px; padding: var(--s2); background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--r-sm); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45); display: flex; flex-direction: column; }
.share-menu a, .share-menu button { display: block; text-align: left; padding: 9px var(--s3); border-radius: var(--r-sm); color: var(--ink); text-decoration: none; background: none; border: 0; font: inherit; font-size: 0.95rem; cursor: pointer; }
.share-menu a:hover, .share-menu button:hover, .share-menu a:focus-visible, .share-menu button:focus-visible { background: rgba(255, 255, 255, 0.08); color: var(--ink); }
.share-sep { margin: 6px var(--s3) 2px; padding-top: var(--s2); border-top: 1px solid var(--line); color: var(--muted); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }

/* Report this page */
.report { margin: var(--s5) 0 0; color: var(--muted); font-size: 0.88rem; }
.report summary { cursor: pointer; display: inline-block; text-decoration: underline; text-underline-offset: 3px; }
.report summary:hover { color: var(--ink); }
.report form { margin: var(--s3) 0 0; padding: var(--s4); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm); max-width: 560px; }
.report label { display: block; color: var(--ink-2); margin-bottom: var(--s2); }

/* Live */
.status { display: inline-flex; align-items: center; gap: 10px; margin: 0; padding: var(--s2) 14px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--ink-2); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.status::before { content: ""; flex: none; width: 10px; height: 10px; border-radius: 50%; background: #6b7f88; }
.status.fresh::before { background: var(--ok); box-shadow: 0 0 0 4px rgba(67, 196, 99, 0.2); animation: pulse 2s ease-in-out infinite; }
.status.stale { color: var(--warn); border-color: rgba(240, 194, 122, 0.35); }
.status.stale::before { background: var(--warn); }
.status.ended::before { background: #b85c5c; }
.status .spinner { margin-right: 0; }
.status:has(.spinner)::before { display: none; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(67, 196, 99, 0.05); } }
#livebody.pending { display: none; }
.lock { max-width: 440px; margin: 40px auto var(--s2); padding: var(--s7); text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.lock svg { color: var(--orange-2); }
.lock h2 { font-size: 1.2rem; margin: 10px 0 6px; }
.lock p { color: var(--muted); margin: 0 0 18px; }
.lock .pwerr { color: var(--warn); margin: var(--s3) 0 0; font-size: 0.9rem; }
.lock .pwerr:empty { display: none; }

/* ---- Signed-in pages */
.my-voyages th[scope="row"] { text-transform: none; letter-spacing: 0; font-size: 0.95rem; font-weight: 600; color: var(--ink); }
.my-voyages th[scope="row"] .badge { margin-left: var(--s2); vertical-align: 2px; }
.my-voyages td, .my-voyages th { vertical-align: top; }
.race-table.my-voyages td:last-child { text-align: left; }
.my-voyages td:nth-child(2) { white-space: nowrap; }
.share-form { display: flex; flex-wrap: wrap; gap: var(--s2) 14px; align-items: center; }
.share-form .check { display: inline-flex; gap: 6px; align-items: center; color: var(--ink-2); white-space: nowrap; }
.share-form .form-error { margin: 0; flex-basis: 100%; }
.account-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.account-grid .panel h2 { font-size: 1.05rem; margin: 0 0 10px; }
.account-grid .panel p { margin: 0 0 10px; }
.account-grid .panel p:last-child { margin-bottom: 0; }
.account-grid .wide { grid-column: 1 / -1; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px var(--s4); margin: 0 0 10px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s3); align-items: center; padding: 6px 0; }

/* ---- Home, prose, 404 */
.intro {
  background:
    radial-gradient(1000px 400px at 85% -10%, rgba(37, 126, 169, 0.45), transparent 70%),
    linear-gradient(180deg, #0b3349 0%, var(--bg) 100%);
  padding: 64px 0 var(--s2);
}
.intro-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: var(--s8); align-items: center; }
.intro h1 { font-size: clamp(2.2rem, 1.4rem + 2.8vw, 3.6rem); letter-spacing: -0.025em; }
.intro .lede { font-size: 1.15rem; }
.cta { display: flex; gap: var(--s3); flex-wrap: wrap; margin: 28px 0 0; }
.cta .btn { padding: var(--s3) 22px; font-size: 1rem; }
.intro-photo img { display: block; width: 100%; height: auto; aspect-ratio: 800 / 446; object-fit: cover; border-radius: 18px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45); border: 1px solid rgba(255, 255, 255, 0.08); }
.features { list-style: none; margin: 56px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s5); }
.features li { padding: var(--s5) 22px; background: rgba(13, 42, 56, 0.7); border: 1px solid var(--line); border-radius: var(--r); }
.features h2 { font-size: 1.05rem; color: var(--orange-2); margin-bottom: 6px; }
.features p { margin: 0; color: var(--ink-2); font-size: 0.95rem; }
.voyages .section-head { margin-bottom: var(--s5); }
.voyages .section-head h2 { font-size: var(--fs-xl); }
.prose section { max-width: 44rem; padding: 0 0 var(--s6); margin: 0 0 var(--s6); border-bottom: 1px solid var(--line); }
.prose section:last-child { border-bottom: 0; }
.prose h2 { font-size: 1.15rem; margin: 0 0 var(--s2); }
.prose p { line-height: 1.7; margin: 0; color: var(--ink-2); }
.prose p + p { margin-top: var(--s3); }
.prose ul { margin: 0 0 var(--s3); padding-left: 1.2em; color: var(--ink-2); line-height: 1.7; }
.prose li { margin-bottom: 6px; }
.prose .callout { padding: var(--s5) 22px; border: 1px solid rgba(240, 194, 122, 0.35); background: rgba(240, 194, 122, 0.07); border-radius: var(--r); }
.prose .callout h2 { color: var(--warn); }
.draft-note { max-width: 44rem; margin: 0 0 28px; padding: var(--s3) var(--s4); border-radius: var(--r-sm); background: rgba(240, 138, 36, 0.12); border: 1px solid rgba(240, 138, 36, 0.45); color: var(--ink); }
.notfound { text-align: center; padding-top: 96px !important; }
.notfound .eyebrow { font-size: 1rem; }
.notfound-art { color: var(--blue-2); margin-bottom: var(--s4); }
.notfound .lede { margin: 14px auto 28px; }

/* ---- Motion */
@media (prefers-reduced-motion: reduce) {
  .status.fresh::before { animation: none; }
  .card, .card:hover { transform: none; transition: none; }
  .spinner { animation-duration: 3s; }
  .fold > summary::before { transition: none; }
}

/* ---- Narrow screens */
@media (max-width: 900px) {
  .intro { padding-top: 40px; }
  .intro-grid { grid-template-columns: 1fr; gap: 28px; }
  .features { grid-template-columns: 1fr; gap: var(--s3); margin-top: var(--s7); }
  .race-tables { grid-template-columns: 1fr; }
  .chart-grid { grid-template-columns: 1fr; }
  .account-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  /* My voyages: one block per voyage. */
  .race-table.my-voyages, .my-voyages tbody, .my-voyages tr, .my-voyages th, .my-voyages td { display: block; }
  .my-voyages thead { display: none; }
  .my-voyages tr { padding: var(--s3); border-bottom: 1px solid var(--line); }
  .race-table.my-voyages td, .race-table.my-voyages th { padding: 2px 0; border: 0; text-align: left; white-space: normal; }
  .my-voyages td:nth-child(2), .my-voyages td:nth-child(3), .my-voyages td:nth-child(4) { display: inline; color: var(--muted); }
  .my-voyages td:nth-child(3)::before, .my-voyages td:nth-child(4)::before { content: " · "; }
  .my-voyages td:last-child { margin-top: 10px; }
  .share-form select { width: 100%; }
}
@media (max-width: 600px) {
  .top .wrap { min-height: 56px; }
  .brand { gap: var(--s2); }
  .brand img { width: 34px; height: 34px; }
  .brand-name { font-size: 1.05rem; }
  .brand-name small { display: none; }
  .top nav { gap: 0; }
  .top nav a { padding: 6px var(--s2); font-size: 0.92rem; }
  /* "Voyages" stays on phones too (CL-12). */
  .hero { padding: var(--s7) 0 var(--s6); }
  .content { padding-top: var(--s6); padding-bottom: 40px; }
  .hero + .content { padding-top: var(--s5); }
  .intro { padding-top: 28px; }
  .intro-grid { gap: var(--s5); }
  .cta { flex-direction: column; }
  .features li { padding: 14px var(--s4); }
  .grid { grid-template-columns: 1fr; gap: var(--s4); }
  .page-head, .head { align-items: flex-start; }
  .actions { width: 100%; }
  .actions .btn, .actions .share { flex: 1; }
  .actions .share .btn { width: 100%; }
  .stats { grid-template-columns: 1fr 1fr; margin-top: var(--s5); }
  .stats > div, .tiles > div { padding: var(--s3) var(--s4); }
  .stats dd { font-size: 1.35rem; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .tiles dd { font-size: 1.2rem; }
  .section { margin-top: 40px; }
  .map { height: 340px; min-height: 0; }
  .map.tall { height: 420px; }
  .replay { gap: var(--s3); padding: 10px var(--s3); }
  .speed { padding: 6px; }
  .instruments { grid-template-columns: repeat(3, 1fr); }
  .instruments div { padding: 10px var(--s3); }
  .instruments span { font-size: 1.2rem; }
  .chart svg { height: 84px; }
  .foot .wrap { flex-direction: column; text-align: center; }
  .foot nav { justify-content: center; gap: var(--s3) 18px; }
  .lock { padding: var(--s6) var(--s5); margin-top: var(--s6); }
  .notfound { padding-top: 56px !important; }
  /* The menu was anchored to the Share button's right edge and ran off the left of the screen (CL-01):
     on a phone it is a sheet along the bottom, above the map's zoom buttons. */
  .share-menu { position: fixed; left: 16px; right: 16px; bottom: 16px; top: auto; min-width: 0; max-height: calc(100vh - 32px); overflow-y: auto; z-index: 2000; }
  .share-menu a, .share-menu button { padding: 12px var(--s3); }
  /* The replay slider gets its own full-width row (CL-02). */
  .replay { flex-wrap: wrap; }
  #scrub { order: 5; flex: 1 1 100%; height: 36px; }
  .clock { margin-left: auto; }
  /* Legs on one line each: smaller type, no wrapping, units in the header. */
  .race-table { font-size: 0.8rem; }
  .race-table th, .race-table td { padding: var(--s2) 6px; white-space: nowrap; }
  .race-table th:first-child, .race-table td:first-child { padding-left: 10px; }
  .leg-open { width: 44px; height: 44px; }
  .race-table .linkish { display: inline-block; min-height: 44px; padding: 10px 0; }
  .leg-facts { grid-template-columns: 1fr 1fr; gap: 10px var(--s3); }
  .leg-facts dd { font-size: 0.9rem; }
  .race-laps small { display: block; margin: 0; }
  /* In a table head the "Only you" badge is just its dot (the words stay for screen readers). */
  .race-table th .badge.only { font-size: 0; padding: 4px; gap: 0; vertical-align: 1px; }
  .owner-bar .badge { font-size: 0.66rem; }
  .fold > summary { padding: var(--s3); }
  .fold > .fold-body { padding: 0 var(--s3) var(--s3); }
  .section-fold > summary, .section-fold > .fold-body { padding-left: 0; padding-right: 0; }
}
@media (max-width: 380px) {
  /* The narrowest phones: the legs table still on one line each. */
  .race-table { font-size: 0.74rem; }
  .race-table th, .race-table td { padding: 7px var(--s1); }
  .race-table th:first-child, .race-table td:first-child { padding-left: var(--s2); }
}
@media (max-width: 420px) {
  /* Logo only; the name stays for screen readers. */
  .brand-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}

/* Back to the whole track (CL-03). */
.map-fit { width: 34px; height: 34px; border: 2px solid rgba(0, 0, 0, 0.2); border-radius: 4px; background: #fff; color: #0a2c3d; font-size: 1.15rem; line-height: 1; cursor: pointer; background-clip: padding-box; }
.map-fit:hover { background: #f4f4f4; }
.map-hint { position: absolute; left: 50%; top: 8px; transform: translateX(-50%); z-index: 800; margin: 0; padding: 4px 10px; border-radius: 999px; background: rgba(6, 26, 36, 0.72); color: #fff; font-size: 0.8rem; pointer-events: none; white-space: nowrap; }
.move-key { background: rgba(255, 255, 255, 0.92); color: #0a2433; border-radius: 6px; padding: 4px 8px; font-size: 0.78rem; line-height: 1.7; max-width: calc(100vw - 80px); }
.move-key .mk { display: inline-grid; place-items: center; width: 16px; height: 16px; margin: 0 3px 0 6px; border-radius: 50%; border: 1.5px solid #0a2433; font-style: normal; font-size: 9px; font-weight: 700; vertical-align: -3px; }
.move-key .mk:first-child { margin-left: 0; }
.move-key .tack { background: #4fb0de; }
.move-key .gybe { background: #9fd36b; }
.move-key .many { background: #4fb0de; width: 18px; height: 18px; }

/* ---- UX flow fixes, 11 Nov 2026 (CF-*) */
/* Live follow: whose boat, and since when (CF-01). */
.live-since { margin: var(--s2) 0 0; color: var(--muted); font-size: 0.95rem; }
.live-since a { color: var(--ink-2); }
/* My voyages: the live link with Copy, WhatsApp and Email (CF-03). */
.live-panel .live-link { font-size: 1.05rem; }
.live-actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-top: var(--s3); }
.live-actions .btn { min-height: 44px; }
.live-actions .saved:empty { display: none; }
/* Share on a private voyage: one question, then Share by link (CF-02). */
.share-private { position: relative; }
.share-private > summary { list-style: none; }
.share-private > summary::-webkit-details-marker { display: none; }
.share-ask { width: 300px; padding: var(--s4); gap: var(--s2); }
.share-ask p { margin: 0; color: var(--ink-2); font-size: 0.92rem; }
.share-ask p strong { color: var(--ink); }
.share-menu.share-ask .btn.primary { display: flex; justify-content: center; width: 100%; margin-top: var(--s2); padding: 11px var(--s4); border-radius: 999px; text-align: center; background: var(--orange); border: 1px solid var(--orange); color: var(--on-orange); font-weight: 650; }
.share-menu.share-ask .btn.primary:hover { background: var(--orange-2); }
/* My voyages: a plain heading, with the help behind a small link (CF-09). */
.sharing-head { margin: var(--s5) 0 var(--s3); }
.sharing-head h2 { font-size: var(--fs-lg); margin: 0; }
.sharing-head .form-note { margin-top: var(--s1); }
.help > summary { display: inline-block; margin-top: var(--s2); color: var(--blue-2); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-size: 0.9rem; }
.help > summary::-webkit-details-marker { display: none; }
.help .form-note { margin-top: var(--s2); max-width: 70ch; }
/* A 44 px row for each share switch, and a bigger box (CF-10). */
.share-form .check { min-height: 44px; padding: 0 var(--s2) 0 0; cursor: pointer; }
.share-form .check input[type="checkbox"] { width: 22px; height: 22px; }
/* Account: Free and Nauti Cloud side by side (CF-04). */
.plans { margin: var(--s2) 0 var(--s3); font-size: 0.88rem; }
.plans th[scope="row"] { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--ink-2); font-size: 0.88rem; }
.plans td { white-space: nowrap; }
.account-grid .panel .plan-how { color: var(--ink); font-weight: 600; margin: 0 0 var(--s5); }
/* Home: sign in for owners, and the plans in one line (CF-12, CF-04). */
.cta-signin { margin: var(--s4) 0 0; color: var(--ink-2); }
.cta-signin a { font-weight: 600; }
.plans-note { margin: var(--s4) 0 0; color: var(--muted); font-size: 0.92rem; }
.empty-cta { justify-content: center; margin-top: var(--s5); }
@media (max-width: 600px) {
  .share-private { flex: 1; }
  .share-private > summary.btn { width: 100%; }
  .share-ask { width: auto; }
  .empty-cta { flex-direction: column; }
}
