:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel2: #fafafa;
  --line: #e3e4e6;            /* light hairline: table rows, quiet rules */
  --border: #101418;          /* structural rules are ink */
  --text: #101418;
  --muted: #4c545c;
  --faint: #646b71;           /* 5.9:1 on white: readable at 10.5px bold */
  --accent: #c8102e;          /* signal red — the one loud thing */
  --accent-dim: #c8102e14;
  --focus: #c8102e;
  --steel: #35708e;           /* quiet steel for virtual-fleet marks */
  --good: #1a7a4a;
  --bad: #c8102e;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.55 "Archivo", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: #97001c; text-decoration: underline; }
h1, h2, h3 { font-weight: 700; }

/* ---- header: program masthead ------------------------------------------- */
header.site {
  display: flex; align-items: baseline; gap: 16px;
  padding: 14px 22px;
  background: var(--bg);
  border-bottom: 2px solid var(--border);
}
header.site .logo {
  font-size: 15px; font-weight: 800;
  letter-spacing: .1em; text-transform: uppercase;
  display: flex; align-items: center; gap: 9px;
}
header.site .logo a { display: flex; align-items: center; gap: 9px; }
header.site .logo a:hover { text-decoration: none; }
header.site .logo svg { display: block; width: 30px; height: 24px; }
header.site { align-items: center; }
header.site .sub { color: var(--muted); font-size: 12.5px; }
header.site .right {
  margin-left: auto; color: var(--muted);
  font-size: 12.5px; text-align: right; white-space: nowrap;
}


.wrap { max-width: 1080px; margin: 0 auto; padding: 26px 22px 70px; }

/* ---- home hero: the pitch beside the live chart ----------------------------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 28px; align-items: center; padding: 34px 0 30px;
}
.hero h1 {
  margin: 0 0 12px; font-size: 34px; line-height: 1.08;
  font-weight: 800; text-transform: uppercase; letter-spacing: .005em;
  text-wrap: balance;
}
.hero .lead { margin: 0; color: var(--muted); font-size: 15px; max-width: 58ch; }
.hero .lead b, .hero .lead i { color: var(--text); }
.hero-cta { display: flex; align-items: center; gap: 16px; margin-top: 18px; flex-wrap: wrap; }
.hero-cta a { display: inline-block; }
#cta_note { margin-top: 8px; min-height: 18px; }
.hero-chart #home_map { height: 340px; margin: 0; }
#home_map_cap { margin-top: 6px; }
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 18px; padding-top: 24px; }
  .hero-chart #home_map { height: 260px; }
}

/* ---- documents (how it works) ------------------------------------------------ */
.doc-title {
  margin: 28px 0 10px; font-size: 30px; line-height: 1.1; font-weight: 800;
  text-transform: uppercase; letter-spacing: .005em; text-wrap: balance;
}
.doc > .lead { margin: 0 0 14px; color: var(--muted); font-size: 15px; max-width: 62ch; }
.doc-toc { margin: 0 0 22px; color: var(--muted); }
.doc .card p { max-width: 66ch; margin: 0 0 10px; }
.doc .card p:last-child { margin-bottom: 0; }

/* ---- home race board ------------------------------------------------------ */
#home_map {
  height: 360px; border: 1px solid var(--border);
  background: #eef1f3; margin-bottom: 14px;
}
.race-item {
  padding: 11px 14px; margin-bottom: 10px;
  background: var(--bg); border: 1px solid var(--border);
}
.race-item-head { margin-bottom: 4px; }
table.podium { margin-top: 4px; }
table.podium td { padding: 3px 8px; border-bottom: none; font-size: 13px; }

/* ---- cards ---------------------------------------------------------------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card h2 {
  margin: -18px -20px 14px;
  padding: 9px 20px;
  font-size: 11.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 800;
  border-bottom: 1px solid var(--border);
}
.card h3 {
  margin: 16px 0 6px;
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  font-weight: 700; color: var(--muted);
}
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---- tables ---------------------------------------------------------------- */
table.list { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.list th {
  text-align: left; color: var(--faint); font-weight: 700;
  font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.list td {
  padding: 7px 10px; border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
table.list tr:hover td { background: #10141806; }

/* ---- forms ----------------------------------------------------------------- */
input, textarea, select {
  background: var(--bg); color: var(--text);
  border: 1px solid #8a9096; border-radius: 0;   /* 3.2:1 boundary on white */
  padding: 7px 10px; font: inherit; width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--border);
  box-shadow: 0 0 0 3px #c8102e40;
}
:is(a, button, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px;
}
.skip {
  position: absolute; left: 8px; top: -60px; z-index: 2000;
  background: var(--text); color: #fff; padding: 8px 12px;
  font-size: 13px; font-weight: 700;
}
.skip:focus { top: 8px; color: #fff; text-decoration: none; }
/* a link that looks like the primary button (CTAs that navigate, not submit) */
a.btn {
  display: inline-block; background: var(--accent); color: #fff;
  border: 1.5px solid var(--accent); padding: 8px 16px;
  font-size: 12.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
}
a.btn:hover { background: #a30d25; border-color: #a30d25; color: #fff; text-decoration: none; }
textarea { font-family: var(--mono); font-size: 12px; }
label {
  display: block; margin: 10px 0 4px;
  font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase;
  font-weight: 700; color: var(--muted);
}
button {
  background: var(--accent); color: #ffffff;
  border: 1.5px solid var(--accent); border-radius: 0;
  padding: 8px 16px; font: inherit; font-size: 12.5px;
  font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  cursor: pointer;
}
button:hover { background: #a30d25; border-color: #a30d25; }
button.ghost {
  background: transparent; color: var(--text);
  border: 1.5px solid var(--border);
}
button.ghost:hover { background: var(--text); color: #ffffff; }
button.warn { background: var(--bad); border-color: var(--bad); }
button:disabled { opacity: .4; cursor: default; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.row.actions { margin-top: 10px; flex-wrap: wrap; }
.row.actions > * { flex: 0 1 auto; }
form { margin: 0; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* the fix row carries three buttons in a narrow column — let them size to their
   own label and wrap, so "Copy lon" never breaks across two lines */
.row.fix-actions { flex-wrap: wrap; }
.row.fix-actions > button { flex: 0 1 auto; padding: 8px 12px; white-space: nowrap; }
.msg { margin-top: 8px; font-size: 13px; min-height: 18px; }
.msg.ok { color: var(--good); }
.msg.err { color: var(--bad); }

/* ---- badges ----------------------------------------------------------------- */
.badge {
  display: inline-block; padding: 1px 7px; border-radius: 0;
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; vertical-align: 1px;
  border: 1px solid currentColor;
}
.badge.virtual { color: var(--steel); }
.badge.real { color: var(--accent); }
.badge.fin { color: var(--good); }

/* ---- race page layout -------------------------------------------------------- */
.race-grid {
  display: grid; grid-template-columns: 1fr 400px;
  gap: 0; height: calc(100vh - 53px);
}
#map { height: 100%; background: #eef1f3; }
#map.chart-mode { background: #c7d9e3; }   /* ENC water tint while tiles load */
.side {
  overflow-y: auto; border-left: 2px solid var(--border);
  padding: 14px 16px 40px; background: var(--bg);
}
.side .card { background: var(--panel); padding: 14px 16px; }
.side .card h2 { margin: -14px -16px 12px; padding: 8px 16px; }
@media (max-width: 900px) {
  .race-grid { grid-template-columns: 1fr; height: auto; }
  #map { height: 52vh; }
  .side { border-left: 0; }
}
/* the chart lock (narrow layouts only): a text button in the zoom bar's style */
.chart-lock a {
  width: auto; padding: 0 9px; font: 600 12px/30px var(--sans, system-ui, sans-serif);
  letter-spacing: .02em; white-space: nowrap;
}
.chart-lock a[aria-pressed="true"] { background: var(--accent); color: #fff; }
.lb-scroll { max-height: 46vh; overflow-y: auto; }
.lb-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.lb-filters button {
  background: transparent; color: var(--muted);
  border: 1px solid #8a9096; border-radius: 0;
  padding: 3px 9px; font-size: 11px; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase;
}
.lb-filters button:hover { background: transparent; color: var(--text); border-color: var(--border); }
.lb-filters button.on { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }

/* ---- map furniture ------------------------------------------------------------ */
.leaflet-container { font: inherit; }
.boat-label {
  background: #ffffffee; border: 1px solid var(--border); color: var(--text);
  border-radius: 0; padding: 0 6px; font-size: 11px;
  font-family: var(--mono); white-space: nowrap; box-shadow: none;
}
.boat-label::before { display: none; }
#minimap {
  position: absolute; left: 10px; bottom: 10px; z-index: 900;
  width: 190px; height: 130px; background: #eef1f3;
  border: 2px solid var(--border); box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
  cursor: pointer;
}
@media (max-width: 900px) { #minimap { width: 140px; height: 95px; } }
.map-legend {
  background: #ffffffee; border: 1px solid var(--border); color: var(--text);
  padding: 4px 9px; font-family: var(--mono); font-size: 11px; white-space: nowrap;
}
.wind-canvas { pointer-events: none; }
.wind-ctl { width: 230px; line-height: 1.5; }
.wind-ctl .wind-slider { display: block; width: 100%; margin: 2px 0 1px; }
.wind-ctl .wind-read { min-height: 16px; }
.wind-ctl .wind-scale { height: 7px; margin-top: 3px; border: 1px solid var(--border); }
.wind-ctl .wind-ticks { display: flex; justify-content: space-between; font-size: 9.5px; color: var(--muted); }
@media (max-width: 900px) { .wind-ctl { width: 200px; } .wind-ctl .wind-read { display: none; } }

/* ---- real vs virtual: diverging gap bars ------------------------------------------ */
.cmp-head { margin: 0 0 10px; }
.cmp-row {
  display: grid; grid-template-columns: 84px 1fr 56px;
  align-items: center; gap: 8px; margin: 3px 0;
}
.cmp-lab {
  font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase;
  font-weight: 700; color: var(--muted);
}
.cmp-track { position: relative; height: 14px; background: #f4f4f2; border: 1px solid var(--line); }
.cmp-track::before {
  content: ''; position: absolute; left: 50%; top: -3px; bottom: -3px;
  border-left: 1px solid var(--border);
}
.cmp-seg { position: absolute; top: 2px; bottom: 2px; background: var(--accent); }
.cmp-seg.v { background: var(--steel); }
.cmp-val { font-family: var(--mono); font-size: 12px; text-align: right; }
.cmp-axis {
  display: flex; justify-content: space-between;
  font-size: 10.5px; color: var(--faint); margin: 2px 0 4px;
}
table.cmp-table td, table.cmp-table th { padding: 4px 8px; }
table.cmp-table td:not(:first-child), table.cmp-table th:not(:first-child) { text-align: right; }

/* ---- data text ------------------------------------------------------------------ */
code, pre {
  font-family: var(--mono);
  background: #f4f4f2; border: 1px solid var(--line);
  border-radius: 0; padding: 1px 6px; font-size: 12.5px;
}
pre { padding: 10px 12px; overflow-x: auto; }
.clock { font-family: var(--mono); font-size: 12.5px; color: var(--text); }
.steplist { margin: 6px 0 0 0; padding-left: 20px; }
.steplist li { margin-bottom: 5px; }

/* ---- race page: header card, facts, collapsible compare ---------------------- */
.race-title {
  font-family: var(--display); font-weight: 800; font-size: 22px;
  line-height: 1.12; letter-spacing: -.005em; text-wrap: balance;
}
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; }
dl.facts dt {
  color: var(--faint); font-size: 10.5px; letter-spacing: .08em;
  text-transform: uppercase; font-weight: 700; padding-top: 2px;
}
dl.facts dd { margin: 0; }
details.card > summary {
  list-style: none; cursor: pointer;
  margin: -14px -16px 12px; padding: 8px 16px;
  font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase;
  font-weight: 800; border-bottom: 1px solid var(--border);
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: '+'; float: right; font-family: var(--mono); }
details.card[open] > summary::after { content: '−'; }
details.card:not([open]) > summary { margin-bottom: -14px; border-bottom: 0; }

/* ---- footer: attribution, the not-for-navigation line, what we keep ---------- */
.site-foot {
  border-top: 1px solid var(--border); margin-top: 40px; padding-top: 14px;
  font-size: 12px; line-height: 1.5; color: var(--muted); max-width: 72ch;
}
.site-foot p { margin: 0 0 8px; }
.site-foot b { color: var(--text); }
.side .site-foot { margin-top: 24px; max-width: none; }

/* ---- small screens (last, so these win over the rules above) --------------- */
@media (max-width: 600px) {
  header.site { flex-wrap: wrap; gap: 4px 14px; padding: 10px 14px; }
  header.site .sub { flex-basis: 100%; order: 3; font-size: 12px; }
  .wrap { padding: 16px 14px 50px; }
  .card { padding: 14px; }
  .card h2 { margin: -14px -14px 12px; padding: 8px 14px; }
  .hero { padding: 22px 0 18px; }
  .hero h1 { font-size: 26px; }
  .row { flex-direction: column; gap: 4px; }
  .row.actions { flex-direction: row; gap: 10px; }
  button { padding: 10px 16px; }          /* a thumb-sized target */
  .lb-scroll { max-height: none; }         /* one scroll: the page's */
  table.list { font-size: 13px; }
  table.list th, table.list td { padding: 7px 6px; }
}

/* keyboard-reachable leaderboard rows */
#lb tbody tr[tabindex]:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
