/* ── Tokens ──────────────────────────────────────────────────────────────────
   Colour is reserved for data. The interface chrome is ink, rule and paper
   only, so that green and sienna always mean "gained" and "lost" and never
   just "button".                                                             */
/* Dark theme. Green and sienna are both lightened — the light-mode values go
   muddy against a dark ground and stop reading as gained and lost. */
:root.dark {
  --ground: #101512;
  --surface: #171D19;
  --surface-2: #1E2622;
  --ink: #E8EDE8;
  --ink-2: #9BA79E;
  --ink-3: #6B776F;
  --rule: #2A332D;
  --rule-2: #232B26;

  --gain: #3E9E6B;
  --gym: #6B7DC4;
  --loss: #D2705C;
  --gain-soft: rgba(62, 158, 107, 0.14);
  --cell-empty: rgba(232, 237, 232, 0.06);
  --focus: #7A9BEA;
}

:root {
  --ground: #E4E8E2;
  --surface: #FBFCFA;
  --surface-2: #F1F3EF;
  --ink: #141815;
  --ink-2: #5B645D;
  --ink-3: #8B948C;
  --rule: #CDD3CB;
  --rule-2: #DDE1DA;

  --gain: #1E6B47;
  --gym: #3A4E8F;
  --cell-empty: rgba(20, 24, 21, 0.05);
  --loss: #A63D2E;
  --gain-soft: rgba(30, 107, 71, 0.10);

  --focus: #2E4FA3;

  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --r: 3px;
  --gap: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

button, input, select { font: inherit; color: inherit; }

.wrap {
  width: 100%;
  max-width: 940px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.topbar {
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  gap: 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--ink);
}
.brand-mark {
  position: relative;
  width: 24px;
  height: 16px;
}
.brand-mark::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  border-top: 1.5px solid var(--ink);
}
.brand-mark::after {
  content: "";
  position: absolute;
  left: 3px;
  bottom: 50%;
  width: 5px;
  height: 7px;
  background: var(--gain);
  box-shadow: 10px 7px 0 0 var(--loss);
}
.brand-text {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.tabs { display: flex; gap: 2px; }
.tab {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab.on { color: var(--ink); border-bottom-color: var(--ink); }

.bottombar { display: none; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
main { padding-top: 18px; padding-bottom: 64px; }
.stack { display: flex; flex-direction: column; gap: var(--gap); }

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 18px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.section-title {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.group-title {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.caption {
  margin: 10px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-2);
}
.read { margin: 8px 0 0; color: var(--ink-2); max-width: 62ch; }

/* ── Headline: the one loud moment ───────────────────────────────────────── */
.headline-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.big-number {
  font-family: var(--mono);
  font-size: clamp(48px, 13vw, 76px);
  font-weight: 500;
  line-height: 0.95;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  margin: 6px 0 4px;
}
.test-title { margin: 4px 0 0; font-size: 20px; font-weight: 600; }

.gain-t { color: var(--gain); }
.loss-t { color: var(--loss); }

/* ── Charts ──────────────────────────────────────────────────────────────────
   Bars are HTML so their labels stay readable at any width. Only the trend
   line is drawn as vector geometry.                                          */
.chart-wrap { margin-top: 10px; }

.dbars-plot {
  position: relative;
  display: flex;
  gap: 3px;
  align-items: stretch;
}
.dbar-col { flex: 1 1 0; display: flex; flex-direction: column; min-width: 0; }
.dbar-half { flex: 1; display: flex; min-height: 0; }
.dbar-half.up { align-items: flex-end; }
.dbar-half.down { align-items: flex-start; }
.dbar {
  display: block;
  width: 100%;
  max-width: 44px;
  margin: 0 auto;
  border-radius: 1px;
}
.dbar.gain { background: var(--gain); }
.dbar.loss { background: var(--loss); }
.dbars-datum {
  position: absolute;
  left: 0; right: 0;
  border-top: 1px solid var(--ink);
  pointer-events: none;
}
.dbars-ticks { display: flex; gap: 3px; margin-top: 6px; }
.dbars-ticks span {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  overflow: hidden;
  white-space: nowrap;
}
.dbars.dense .dbars-ticks span { font-size: 9.5px; }

.drows { display: flex; flex-direction: column; }
.drow {
  display: grid;
  grid-template-columns: minmax(96px, 1.1fr) minmax(120px, 2fr) 74px;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--rule-2);
}
.drow:last-child { border-bottom: 0; }
.drow-label { display: flex; flex-direction: column; line-height: 1.25; }
.drow-sub { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }
.drow-track { position: relative; height: 20px; }
.drow-track::before {
  content: "";
  position: absolute;
  left: 50%; top: -4px; bottom: -4px;
  border-left: 1px solid var(--ink);
}
.drow-bar { position: absolute; top: 3px; bottom: 3px; border-radius: 1px; }
.drow-bar.gain { background: var(--gain); }
.drow-bar.loss { background: var(--loss); }
.drow-value {
  font-family: var(--mono);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.trend-wrap { position: relative; }
.chart.trend { width: 100%; height: auto; display: block; overflow: visible; }
.trend-line { fill: none; stroke: var(--gain); stroke-linejoin: round; stroke-linecap: round; }
.dot { fill: var(--surface); stroke: var(--gain); }
.dot.gain { fill: var(--gain); stroke: var(--gain); }
.datum-line.target { stroke: var(--ink-3); stroke-dasharray: 8 6; }
.target-zone { fill: var(--gain-soft); }
.grid-line { stroke: var(--rule-2); stroke-width: 1; }
.axis-label {
  font-family: var(--mono);
  font-size: 15px;
  fill: var(--ink-3);
}
.trend-target {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 4px;
}


@media (prefers-reduced-motion: no-preference) {
  .dbar { animation: grow 420ms cubic-bezier(.2,.7,.3,1) both; }
  .dbar-half.up .dbar { transform-origin: bottom; }
  .dbar-half.down .dbar { transform-origin: top; }
  @keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
}

/* ── Lists ───────────────────────────────────────────────────────────────── */
.round-list, .bench-list, .test-list, .hist-list { display: flex; flex-direction: column; }

.round-row {
  display: grid;
  grid-template-columns: 108px 1fr 90px 72px;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border: 0;
  border-top: 1px solid var(--rule-2);
  background: none;
  text-align: left;
  cursor: pointer;
  width: 100%;
}
.round-row:hover { background: var(--surface-2); }
.rr-date { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.rr-course { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rr-score, .rr-sg {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.rr-score { color: var(--ink-2); font-size: 13px; }

.bench-row {
  display: grid;
  grid-template-columns: 1fr 72px 92px 92px;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border: 0;
  border-top: 1px solid var(--rule-2);
  background: none;
  text-align: left;
  cursor: pointer;
}
.bench-row:hover { background: var(--surface-2); }
.br-val { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.br-target, .br-date { font-family: var(--mono); font-size: 11px; color: var(--ink-3); text-align: right; }

.test-row {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 0;
  border: 0;
  border-top: 1px solid var(--rule-2);
  background: none;
  text-align: left;
  cursor: pointer;
}
.test-row:first-child { border-top: 0; }
.test-row:hover { background: var(--surface-2); }
.tr-name { font-weight: 600; }
.tr-blurb { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; max-width: 52ch; }
.tr-right { text-align: right; flex: 0 0 auto; }
.tr-val { font-family: var(--mono); font-size: 22px; font-variant-numeric: tabular-nums; }
.tr-val.muted { color: var(--ink-3); }
.tr-target, .tr-date { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }

.hist-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid var(--rule-2);
  font-size: 13px;
}
.hr-date { flex: 0 0 auto; width: 100px; }
.hr-val { flex: 0 0 auto; width: 70px; }
.hr-meta { flex: 0 0 auto; }
.hr-note { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-row .sr-del { margin-left: auto; flex: 0 0 auto; }
.hr-date { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.hr-val { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.hr-meta, .hr-note { color: var(--ink-3); font-size: 12px; }

/* ── Forms & controls ────────────────────────────────────────────────────── */
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.field { display: flex; flex-direction: column; gap: 5px; margin-top: 10px; }
.field-grid .field { margin-top: 0; }

.input {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 9px 10px;
  width: 100%;
  min-height: 40px;
}
.input.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.big-input { font-size: 20px; }
.input:focus-visible, .btn:focus-visible, .chip:focus-visible, .tab:focus-visible,
.lie:focus-visible, .link:focus-visible, .round-row:focus-visible, .test-row:focus-visible,
.hole-pip:focus-visible, .bench-row:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.btn {
  background: var(--surface);
  border: 1px solid var(--ink);
  border-radius: var(--r);
  padding: 9px 16px;
  cursor: pointer;
  font-size: 14px;
  min-height: 40px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--ink); color: var(--surface); }
.btn.primary:hover { background: #000; }
.btn.small { padding: 6px 12px; min-height: 34px; font-size: 13px; }
.btn.wide { flex: 1; }
.btn.danger { border-color: var(--loss); color: var(--loss); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn.file { display: inline-flex; align-items: center; }

.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.row.tight { margin-top: 10px; }
.row.end { justify-content: space-between; align-items: center; }
.row.inline { margin-top: 0; gap: 16px; align-items: center; }

.link {
  background: none;
  border: 0;
  padding: 4px 0;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link:hover { color: var(--ink); }
.link.danger { color: var(--loss); }
.link.back { align-self: flex-start; }

.chip {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
  min-height: 32px;
}
.chip:hover { border-color: var(--ink-3); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.chip.wide { flex: 1; text-align: center; }
.window-switch { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Hole strip & shot entry ─────────────────────────────────────────────── */
.hole-strip {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 2px 0;
  scrollbar-width: thin;
}
.hole-pip {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid var(--rule);
  background: var(--surface);
  border-radius: var(--r);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
  border-bottom-width: 3px;
}
.hole-pip.on { border-color: var(--ink); color: var(--ink); font-weight: 600; }
.hole-pip.p-gain { border-bottom-color: var(--gain); }
.hole-pip.p-loss { border-bottom-color: var(--loss); }

.par-row { display: flex; align-items: center; gap: 6px; }

.expect-line {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-3);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule-2);
}

.shot-rows { display: flex; flex-direction: column; }
.shot-row {
  display: grid;
  grid-template-columns: 22px 1fr 104px 66px 66px 26px;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--rule-2);
}
.sr-num { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.sr-lies { display: flex; gap: 3px; flex-wrap: wrap; }
.lie {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 4px 8px;
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
  min-height: 30px;
}
.lie.on { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.lie-short { display: none; }
.lie:disabled { opacity: 0.25; cursor: not-allowed; }
.sr-dist { display: flex; align-items: center; gap: 5px; }
.sr-dist .input { min-height: 34px; padding: 5px 8px; }
.unit { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.chip.pen { padding: 3px 9px; min-height: 28px; font-size: 11px; }
.sr-sg {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.holed { font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.sr-del {
  background: none;
  border: 0;
  color: var(--ink-3);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.sr-del:hover { color: var(--loss); }
.sr-del:disabled { opacity: 0.25; cursor: not-allowed; }

.hole-summary {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
}
.hs-item { display: flex; flex-direction: column; gap: 1px; }
.hs-k {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.hs-v { font-family: var(--mono); font-size: 19px; font-variant-numeric: tabular-nums; }

.nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.nav-mid {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* ── Shot table (round detail) ───────────────────────────────────────────── */
.shots-card > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  list-style: none;
}
.shots-card > summary::-webkit-details-marker { display: none; }
.shots-hint {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
}
.shots-hint::after { content: " \2304"; }
.shots-card[open] .shots-hint::after { content: " \2303"; }
.shots-card[open] .shot-table { margin-top: 12px; }

.shot-table { display: flex; flex-direction: column; gap: 2px; }
.st-hole { border-top: 1px solid var(--rule-2); padding: 8px 0; }
.st-head {
  display: grid;
  grid-template-columns: 1fr 70px 40px 64px;
  gap: 8px;
  align-items: baseline;
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.st-h { font-weight: 600; }
.st-par { color: var(--ink-3); }
.st-sc { text-align: right; }
.st-head > span:last-child { text-align: right; }
.st-row {
  display: grid;
  grid-template-columns: 1fr 70px 52px 30px 64px;
  gap: 8px;
  padding: 3px 0 3px 12px;
  font-size: 12.5px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.st-dist, .st-cat { font-family: var(--mono); font-size: 11.5px; }
.st-cat { color: var(--ink-3); letter-spacing: 0.06em; }
.st-pen { color: var(--loss); font-family: var(--mono); font-size: 11px; }
.st-row > span:last-child { text-align: right; font-family: var(--mono); }
.st-dist, .st-sc { text-align: right; }

/* ── Practice extras ─────────────────────────────────────────────────────── */
.stat-row {
  display: flex;
  gap: 26px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
}
.stat { display: flex; flex-direction: column; }
.stat-v { font-family: var(--mono); font-size: 22px; font-variant-numeric: tabular-nums; }

.stations { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.station-row { display: flex; align-items: center; gap: 10px; }
.station-label {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
  width: 58px;
  flex: 0 0 auto;
}
.station-inputs { display: flex; gap: 6px; flex: 1; }
.station-inputs .input { min-height: 36px; padding: 6px 8px; }

.protocol { margin: 10px 0 0; padding-left: 18px; color: var(--ink-2); }
.protocol li { margin-bottom: 5px; }

.empty { text-align: left; }
.empty h2 { margin: 0; font-size: 19px; }

/* ── Toasts ──────────────────────────────────────────────────────────────── */
#toasts {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: var(--surface);
  border-radius: var(--r);
  padding: 9px 16px;
  font-size: 13px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}
.toast.warn { background: var(--loss); }
.toast.leaving { opacity: 0; transition: opacity 220ms; }

/* ── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 680px) {
  .topbar .tabs { display: none; }
  .bottombar {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--rule);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 30;
  }
  .bottombar .tab {
    flex: 1;
    padding: 12px 4px;
    border-bottom: 0;
    border-top: 2px solid transparent;
  }
  .bottombar .tab.on { border-top-color: var(--ink); border-bottom-color: transparent; }
  main { padding-bottom: 84px; }

  .card { padding: 14px; }

  .shot-row {
    grid-template-columns: 20px 1fr 58px 58px 24px;
    grid-template-areas:
      "num  lies lies lies del"
      "num  dist pen  sg   sg";
    row-gap: 7px;
    column-gap: 6px;
  }
  .sr-num { grid-area: num; align-self: start; padding-top: 6px; }
  .sr-lies { grid-area: lies; }
  .sr-dist { grid-area: dist; }
  .sr-pen { grid-area: pen; }
  .sr-sg { grid-area: sg; flex-direction: row; align-items: baseline; justify-content: flex-end; gap: 5px; }
  .sr-del { grid-area: del; justify-self: end; }

  .round-row { grid-template-columns: 1fr 74px 62px; grid-template-areas: "course score sg" "date score sg"; row-gap: 0; }
  .rr-course { grid-area: course; }
  .rr-date { grid-area: date; }
  .rr-score { grid-area: score; }
  .rr-sg { grid-area: sg; }

  .bench-row { grid-template-columns: 1fr 64px 76px; }
  .br-date { display: none; }

  .hr-note { display: none; }
  .hr-date { width: 86px; font-size: 11px; }
  .hr-val { width: 62px; }
  .hr-meta { font-size: 11px; }

  .lie-long { display: none; }
  .lie-short { display: inline; }
  .lie { padding: 4px 6px; font-size: 12.5px; flex: 1 1 0; text-align: center; }
  .sr-lies { gap: 4px; flex-wrap: nowrap; }

  .test-row { flex-direction: row; align-items: flex-start; }
  .tr-blurb { display: none; }

  .drow { grid-template-columns: minmax(78px, 1fr) minmax(90px, 1.4fr) 62px; gap: 8px; }
  .drow-value { font-size: 13.5px; }
  .dbars-plot { gap: 2px; }
  .dbars-ticks { gap: 2px; }
  .dbars.dense .dbars-ticks span { font-size: 8.5px; }

  .st-head { grid-template-columns: 1fr 56px 32px 56px; }
  .st-row { grid-template-columns: 1fr 60px 44px 24px 56px; padding-left: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ── Shot tags: club and miss direction ──────────────────────────────────── */
.sr-tags {
  grid-column: 2 / -1;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  padding: 8px 0 2px;
}
.tag-clubs, .tag-miss { display: flex; gap: 4px; flex-wrap: wrap; }
.tag {
  background: var(--surface);
  border: 1px solid var(--rule-2);
  border-radius: 999px;
  padding: 3px 9px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
  cursor: pointer;
  min-height: 26px;
}
.tag:hover { border-color: var(--ink-3); color: var(--ink-2); }
.tag.on { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.tag-miss-wrap { display: flex; align-items: center; gap: 8px; }
.tag-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.miss-pick { display: flex; align-items: center; gap: 9px; }
.miss-read {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
  max-width: 120px;
  line-height: 1.25;
}
.miss-read.set { color: var(--ink-2); }
.miss-grid {
  display: grid;
  grid-template-columns: repeat(3, 22px);
  grid-template-rows: repeat(3, 22px);
  gap: 2px;
}
.miss-cell {
  border: 1px solid var(--rule-2);
  background: var(--surface);
  border-radius: 1px;
  cursor: pointer;
  padding: 0;
}
.miss-cell.centre { border-color: var(--ink-3); }
.miss-cell:hover { background: var(--surface-2); border-color: var(--ink-3); }
.miss-cell.on { background: var(--ink); border-color: var(--ink); }
.miss-cell.centre.on { background: var(--gain); border-color: var(--gain); }

/* ── Expandable chart rows ───────────────────────────────────────────────── */
.drow.clickable {
  width: 100%;
  border-top: 0;
  border-left: 0;
  border-right: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.drow.clickable:hover { background: var(--surface-2); }
.drow.open { background: var(--surface-2); }
.drow-group { border-bottom: 1px solid var(--rule-2); }
.shot-detail {
  display: flex;
  flex-direction: column;
  padding: 4px 0 10px 10px;
  border-left: 2px solid var(--rule);
  margin: 0 0 6px 4px;
}
.sd-row {
  display: grid;
  grid-template-columns: 78px 34px 1fr 58px 58px;
  gap: 8px;
  align-items: baseline;
  padding: 5px 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--ink-2);
}
.sd-row:hover { background: var(--surface); }
.sd-date, .sd-hole, .sd-sg, .sd-club {
  font-family: var(--mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.sd-hole { color: var(--ink-3); }
.sd-club { color: var(--ink-3); text-align: right; }
.sd-sg { text-align: right; }
.sd-note {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 4px 0 2px;
}

/* ── Stats view ──────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.stat-cell { display: flex; flex-direction: column; gap: 1px; }
.stat-big {
  font-family: var(--mono);
  font-size: 24px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat-sub { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }

.kn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 12px;
  margin-top: 4px;
}
.kn-cell { display: flex; flex-direction: column; gap: 1px; }
.kn-v {
  font-family: var(--mono);
  font-size: 19px;
  font-variant-numeric: tabular-nums;
}

.split-bar {
  display: flex;
  height: 26px;
  margin-top: 8px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  overflow: hidden;
}
.split-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}
.split-seg.gain { background: var(--gain); }
.split-seg.neutral { background: var(--surface-2); border-right: 1px solid var(--rule); }
.split-seg:last-child { border-right: 0; }
.split-n {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
  white-space: nowrap;
}
.split-seg.gain .split-n { color: var(--surface); }
.split-legend {
  display: flex;
  gap: 16px;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
}
.tendency { margin-top: 14px; }

.mini-table { margin-top: 14px; display: flex; flex-direction: column; }
.mt-head, .mt-row {
  display: grid;
  grid-template-columns: 1fr 82px 76px 76px 46px;
  gap: 8px;
  align-items: baseline;
  padding: 8px 0;
  border-top: 1px solid var(--rule-2);
}
.mini-table.wide .mt-head, .mini-table.wide .mt-row {
  grid-template-columns: 1fr 82px 54px 54px 46px 34px 60px;
}
.mt-head {
  border-top: 0;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.mt-row {
  font-size: 13.5px;
  border-width: 1px;
  border-style: solid none none none;
  background: none;
  text-align: left;
  width: 100%;
  color: inherit;
}
.mt-row > span:not(:first-child) {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}
.mt-row.clickable { cursor: pointer; }
.mt-row.clickable:hover { background: var(--surface-2); }

.st-club {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  margin-left: 6px;
}

@media (max-width: 680px) {
  .sr-tags { grid-column: 1 / -1; gap: 10px; }
  .sd-row { grid-template-columns: 56px 26px 1fr 44px 46px; gap: 6px; font-size: 11.5px; }
  .sd-date, .sd-hole, .sd-sg, .sd-club { font-size: 10.5px; }
  .mt-head, .mt-row { grid-template-columns: 1fr 70px 62px 62px 40px; }
  .mini-table.wide .mt-head, .mini-table.wide .mt-row {
    grid-template-columns: 1fr 66px 44px 44px 34px 54px;
  }
  .mini-table.wide .mt-head > span:nth-child(6),
  .mini-table.wide .mt-row > span:nth-child(6) { display: none; }
  .stat-big { font-size: 21px; }
  .tabs .tab, .bottombar .tab { font-size: 10px; padding: 12px 2px; }
}

/* ── Goals ───────────────────────────────────────────────────────────────── */
.goal-list { display: flex; flex-direction: column; gap: 4px; }
.goal { padding: 12px 0; border-top: 1px solid var(--rule-2); }
.goal:first-child { border-top: 0; }

.goal-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.goal-name { font-weight: 600; line-height: 1.25; }
.goal-by {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 400;
  color: var(--ink-3);
  margin-top: 1px;
}
.goal-nums { text-align: right; flex: 0 0 auto; }
.goal-cur {
  display: block;
  font-family: var(--mono);
  font-size: 19px;
  font-variant-numeric: tabular-nums;
}
.goal-target {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
}

.goal-pct {
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  margin: 10px 0 5px;
}
.goal-pct.met, .goal-pct.on-track { color: var(--gain); }
.goal-pct.behind { color: var(--loss); }

.seg-bar {
  display: flex;
  gap: 3px;
  margin-bottom: 8px;
}
.seg {
  flex: 1 1 0;
  height: 11px;
  min-width: 0;
  border-radius: 3px;
  background: var(--cell-empty);
  position: relative;
}
.seg.on { background: var(--ink-3); }
.seg.on.met, .seg.on.on-track, .seg.on.open { background: var(--gain); }
.seg.on.behind { background: var(--loss); }
/* the segment the deadline says you should have reached by now */
.seg.pace::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: -6px;
  width: 0; height: 0;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-bottom: 4px solid var(--ink);
}

@media (prefers-reduced-motion: no-preference) {
  .seg.on { animation: segIn 260ms cubic-bezier(.2,.7,.3,1) backwards; }
  @keyframes segIn { from { opacity: 0; transform: scaleX(0.3); } to { opacity: 1; transform: scaleX(1); } }
}

.goal-foot {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
}
.goal-status {
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.goal-status.met, .goal-status.on-track { color: var(--gain); }
.goal-status.behind { color: var(--loss); }
.goal-days { margin-left: auto; }
.goal-foot .link.tiny {
  font-size: 10px;
  padding: 0;
  flex: 0 0 auto;
}
.goal-base {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  margin-top: 4px;
}

.metric-list { display: flex; flex-direction: column; }
.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 11px 0;
  border: 0;
  border-top: 1px solid var(--rule-2);
  background: none;
  text-align: left;
  cursor: pointer;
  color: inherit;
}
.metric-row:first-child { border-top: 0; }
.metric-row:hover { background: var(--surface-2); }
.mr-name { font-weight: 600; font-size: 14px; }
.mr-hint { font-size: 12px; color: var(--ink-3); margin-top: 2px; max-width: 46ch; }
.mr-cur {
  font-family: var(--mono);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  flex: 0 0 auto;
}

.settings-tab { flex: 0 0 auto; }

@media (max-width: 680px) {
  .goal-cur { font-size: 17px; }
  .goal-foot { gap: 9px; font-size: 10px; }
  .mr-hint { display: none; }
}

/* ── Distance scale chart ────────────────────────────────────────────────── */
.scale-chart { display: flex; flex-direction: column; }
.srow {
  display: grid;
  grid-template-columns: minmax(88px, 1fr) minmax(140px, 2.4fr) 66px;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--rule-2);
}
.srow-label { display: flex; flex-direction: column; line-height: 1.25; font-size: 14px; }
.srow-sub { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }

.srow-track {
  position: relative;
  height: 22px;
  border-left: 1px solid var(--rule);
}
/* the zero baseline the whole scale hangs off */
.srow-track::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  border-top: 1px solid var(--rule-2);
}
.srow-gap {
  position: absolute;
  top: 50%;
  height: 4px;
  margin-top: -2px;
  border-radius: 2px;
}
.srow-gap.good { background: var(--gain); opacity: 0.35; }
.srow-gap.bad { background: var(--loss); opacity: 0.35; }
.srow-ref {
  position: absolute;
  top: 3px; bottom: 3px;
  width: 2px;
  margin-left: -1px;
  background: var(--ink);
  z-index: 2;
}
.srow-dot {
  position: absolute;
  top: 50%;
  width: 11px; height: 11px;
  margin: -5.5px 0 0 -5.5px;
  border-radius: 50%;
  z-index: 3;
  border: 2px solid var(--surface);
}
.srow-dot.good { background: var(--gain); }
.srow-dot.bad { background: var(--loss); }
.srow-value {
  font-family: var(--mono);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.srow.axis { border-bottom: 0; padding: 2px 0 0; }
.srow.axis .srow-track { height: 14px; border-left: 0; }
.srow.axis .srow-track::after { display: none; }
.srow-tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
}
.srow-tick:first-child { transform: none; }

.scale-key {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
}
.key-item { display: inline-flex; align-items: center; gap: 5px; }
.key-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--ink-2);
}
.key-ref { width: 2px; height: 12px; background: var(--ink); }

@media (max-width: 680px) {
  .srow { grid-template-columns: minmax(64px, 1fr) minmax(110px, 2fr) 54px; gap: 8px; }
  .srow-label { font-size: 12.5px; }
  .srow-value { font-size: 13px; }
  .srow-tick { font-size: 9px; }
  .scale-key { gap: 12px; font-size: 9.5px; }
}

/* ── Distance scale chart ────────────────────────────────────────────────── */
.scale-chart { display: flex; flex-direction: column; }
.srow {
  display: grid;
  grid-template-columns: minmax(88px, 1fr) minmax(140px, 2.4fr) 66px;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--rule-2);
}
.srow-label { display: flex; flex-direction: column; line-height: 1.25; font-size: 14px; }
.srow-sub { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }

.srow-track {
  position: relative;
  height: 22px;
  border-left: 1px solid var(--rule);
}
/* the zero baseline the whole scale hangs off */
.srow-track::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  border-top: 1px solid var(--rule-2);
}
.srow-gap {
  position: absolute;
  top: 50%;
  height: 4px;
  margin-top: -2px;
  border-radius: 2px;
}
.srow-gap.good { background: var(--gain); opacity: 0.35; }
.srow-gap.bad { background: var(--loss); opacity: 0.35; }
.srow-ref {
  position: absolute;
  top: 3px; bottom: 3px;
  width: 2px;
  margin-left: -1px;
  background: var(--ink);
  z-index: 2;
}
.srow-dot {
  position: absolute;
  top: 50%;
  width: 11px; height: 11px;
  margin: -5.5px 0 0 -5.5px;
  border-radius: 50%;
  z-index: 3;
  border: 2px solid var(--surface);
}
.srow-dot.good { background: var(--gain); }
.srow-dot.bad { background: var(--loss); }
.srow-value {
  font-family: var(--mono);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.srow.axis { border-bottom: 0; padding: 2px 0 0; }
.srow.axis .srow-track { height: 14px; border-left: 0; }
.srow.axis .srow-track::after { display: none; }
.srow-tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
}
.srow-tick:first-child { transform: none; }

.scale-key {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
}
.key-item { display: inline-flex; align-items: center; gap: 5px; }
.key-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--ink-2);
}
.key-ref { width: 2px; height: 12px; background: var(--ink); }

@media (max-width: 680px) {
  .srow { grid-template-columns: minmax(64px, 1fr) minmax(110px, 2fr) 54px; gap: 8px; }
  .srow-label { font-size: 12.5px; }
  .srow-value { font-size: 13px; }
  .srow-tick { font-size: 9px; }
  .scale-key { gap: 12px; font-size: 9.5px; }
}

/* ── Activity calendar ───────────────────────────────────────────────────── */
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-month {
  font-family: var(--mono);
  font-size: 12px;
  min-width: 108px;
  text-align: center;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 6px;
}
.cal-dow {
  text-align: center;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  padding-bottom: 2px;
}
.cal-day {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--rule-2);
  border-radius: 2px;
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
}
.cal-day:hover:not(:disabled) { border-color: var(--ink-3); }
.cal-day.out { opacity: 0.32; }
.cal-day.future { opacity: 0.28; cursor: default; }
.cal-day.today { border-color: var(--ink); border-width: 2px; font-weight: 600; }

.cal-day.golf { background: var(--gain); border-color: var(--gain); color: var(--surface); }
.cal-day.gym { background: var(--gym); border-color: var(--gym); color: var(--surface); }
/* both: a hard diagonal split so the day reads as two things, not a third */
.cal-day.both {
  background: linear-gradient(135deg, var(--gain) 0 50%, var(--gym) 50% 100%);
  border-color: var(--gain);
  color: var(--surface);
}
.cal-n { position: relative; z-index: 1; }
/* small mark for days that already have a round logged */
.cal-round {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ink);
  opacity: 0.55;
}
.cal-day.golf .cal-round,
.cal-day.gym .cal-round,
.cal-day.both .cal-round { background: var(--surface); opacity: 0.9; }

.cal-key {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
}
.key-sw {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  border: 1px solid var(--rule);
  display: inline-block;
}
.key-sw.golf { background: var(--gain); border-color: var(--gain); }
.key-sw.gym { background: var(--gym); border-color: var(--gym); }
.key-sw.both { background: linear-gradient(135deg, var(--gain) 0 50%, var(--gym) 50% 100%); border-color: var(--gain); }
.key-sw.has-round {
  background: var(--surface);
  position: relative;
}
.key-sw.has-round::after {
  content: "";
  position: absolute;
  right: 1px; bottom: 1px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--ink);
  opacity: 0.55;
}

@media (max-width: 680px) {
  .cal-grid { gap: 3px; }
  .cal-day { font-size: 11px; min-height: 30px; }
  .cal-month { min-width: 92px; font-size: 11px; }
  .cal-key { gap: 10px; font-size: 9.5px; }
}

/* ── Activity heat grid ──────────────────────────────────────────────────── */
.heat-card { overflow: visible; }

.hg-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.hg-title { font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-2); }
.hg-readout {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.hg-year { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }

.hg-scroll { overflow: visible; }
.heat-grid {
  display: grid;
  grid-template-columns: 18px repeat(31, minmax(0, 1fr)) 34px;
  gap: 3px;
}

.hg-tick {
  font-family: var(--mono);
  font-size: 8.5px;
  color: var(--ink-3);
  text-align: center;
  padding-bottom: 3px;
  line-height: 1;
}
.hg-sum-head { font-size: 8px; }
.hg-row-label {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 3px;
  transition: opacity 160ms;
}
.hg-blank { background: none; }

.hg-cell {
  aspect-ratio: 1;
  min-height: 9px;
  border: 0;
  border-radius: 3px;
  padding: 0;
  cursor: pointer;
  background: var(--cell-empty);
  outline: none;
  transition: opacity 160ms;
}
.hg-cell:hover:not(:disabled) { outline: 1.5px solid var(--ink); outline-offset: -1.5px; }
.hg-cell.today { outline: 1.5px solid var(--ink-2); outline-offset: -1.5px; }
.hg-cell.on { outline: 2px solid var(--ink); outline-offset: -2px; }
.hg-cell.future { opacity: 0.3; background: none !important; border: 1px dashed var(--rule-2); cursor: default; }
.hg-cell.dim, .hg-row-label.dim, .hg-sum.dim { opacity: 0.32; }

@media (prefers-reduced-motion: no-preference) {
  .hg-cell { animation: cellIn 300ms cubic-bezier(.16,1,.3,1) backwards; }
  @keyframes cellIn { from { opacity: 0; transform: scale(0.55); } to { opacity: inherit; transform: scale(1); } }
}

.hg-sum {
  position: relative;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  cursor: help;
  transition: opacity 160ms;
}
.hg-pop {
  position: absolute;
  right: calc(100% + 7px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 8px;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms cubic-bezier(.16,1,.3,1);
  box-shadow: 0 8px 24px rgba(0,0,0,.10);
}
.hg-sum:hover .hg-pop { opacity: 1; }
.hg-pop-t, .hg-pop-n {
  font-family: var(--mono);
  font-size: 8.5px;
  color: var(--ink-3);
  white-space: nowrap;
}
.hg-pop-t { margin-bottom: 3px; }
.hg-pop-n { margin-top: 3px; }
.hg-spark { display: block; }

.key-sw.round { background: color-mix(in srgb, var(--gain) 76%, transparent); border-color: transparent; }
.key-sw.golf { background: color-mix(in srgb, var(--gain) 44%, transparent); border-color: transparent; }
.key-sw.gym { background: color-mix(in srgb, var(--gym) 46%, transparent); border-color: transparent; }
.key-sw.both {
  background: linear-gradient(135deg, color-mix(in srgb, var(--gain) 44%, transparent) 0 50%, color-mix(in srgb, var(--gym) 46%, transparent) 50% 100%);
  border-color: transparent;
}

/* ── Day editor ──────────────────────────────────────────────────────────── */
.day-editor {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
}
.de-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.de-date { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.de-btns { display: flex; gap: 8px; }
.de-btn {
  flex: 1;
  min-height: 42px;
  border-radius: 4px;
  border: 1px solid var(--rule);
  background: var(--surface);
  cursor: pointer;
  font-size: 14px;
  color: var(--ink-2);
}
.de-btn:hover:not(:disabled) { border-color: var(--ink-3); }
.de-btn.golf.on { background: var(--gain); border-color: var(--gain); color: var(--surface); }
.de-btn.gym.on { background: var(--gym); border-color: var(--gym); color: var(--surface); }
.de-btn:disabled { background: color-mix(in srgb, var(--gain) 76%, transparent); border-color: transparent; color: var(--surface); cursor: default; }

@media (max-width: 680px) {
  .heat-grid { gap: 2px; grid-template-columns: 14px repeat(31, minmax(0, 1fr)) 22px; }
  .hg-cell { border-radius: 2px; }
  .hg-readout { font-size: 9.5px; max-width: 55%; }
  .hg-tick { font-size: 7.5px; }
  .hg-row-label { font-size: 8px; }
  .hg-sum { font-size: 8px; }
  .hg-pop { right: auto; left: 0; transform: translate(-86%, -50%); }
}

/* ── Skill profile radar ─────────────────────────────────────────────────── */
.radar-wrap { margin: 4px auto 0; max-width: 460px; }
.chart.radar { width: 100%; height: auto; display: block; }

.radar-ring { fill: none; stroke: var(--rule-2); stroke-width: 1.5; }
.radar-spoke { stroke: var(--rule-2); stroke-width: 1; }
.radar-benchmark {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.5;
  stroke-dasharray: 7 5;
}
.radar-value {
  fill: color-mix(in srgb, var(--gain) 22%, transparent);
  stroke: var(--gain);
  stroke-width: 3;
  stroke-linejoin: round;
}
.radar-dot { stroke: var(--surface); stroke-width: 2.5; }
.radar-dot.over { fill: var(--gain); }
.radar-dot.under { fill: var(--loss); }

.radar-label {
  font-family: var(--sans);
  font-size: 26px;
  fill: var(--ink-2);
}
.radar-num {
  font-family: var(--mono);
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}
.radar-num.over { fill: var(--gain); }
.radar-num.under { fill: var(--loss); }
.radar-ref {
  font-family: var(--mono);
  font-size: 20px;
  letter-spacing: 0.16em;
  fill: var(--ink-3);
}

@media (max-width: 680px) {
  .radar-label { font-size: 30px; }
  .radar-num { font-size: 27px; }
  .radar-wrap { margin-top: 8px; }
}


/* ── Wide layout ─────────────────────────────────────────────────────────────
   Above 1040px the single column becomes two, with the wide charts and any
   prose-heavy card spanning both. Nothing below that width changes.          */
/* Below the wide breakpoint the deck is invisible — cards flow as one column. */
.deck { display: contents; }

@media (min-width: 1040px) {
  .wrap { max-width: 1240px; }

  /* Cards of very different heights leave voids in a fixed grid, so the deck
     flows them into balanced columns instead. Full-width cards sit outside it. */
  .deck {
    display: block;      /* overrides the `contents` default so columns apply */
    column-count: 2;
    column-gap: var(--gap);
  }
  .deck > .card {
    break-inside: avoid;
    margin-bottom: var(--gap);
    display: block;
  }

  .headline .big-number { font-size: 68px; }
  .headline-top { align-items: center; }
}

/* ── Notes ───────────────────────────────────────────────────────────────── */
.note-list { display: flex; flex-direction: column; }
.note-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px 0;
  border: 0;
  border-top: 1px solid var(--rule-2);
  background: none;
  text-align: left;
  cursor: pointer;
  color: inherit;
}
.note-row:first-child { border-top: 0; }
.note-row:hover { background: var(--surface-2); }
.nr-title { font-weight: 600; font-size: 15px; }
.nr-count, .nr-date {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
  margin-top: 2px;
}
.nr-date { flex: 0 0 auto; }

.note-title {
  font-size: 19px;
  font-weight: 600;
  border: 0;
  border-bottom: 1px solid var(--rule-2);
  border-radius: 0;
  padding: 4px 0;
  background: none;
}
.note-title:focus-visible { outline: none; border-bottom-color: var(--ink); }

.sec-hint { margin-top: 2px; }

.note-items { display: flex; flex-direction: column; }
.note-item {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  align-items: start;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--rule-2);
}
.note-item:first-child { border-top: 0; }
.ni-n {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-3);
  padding-top: 9px;
}
.note-input {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--r);
  background: none;
  padding: 7px 8px;
  font: inherit;
  font-size: 14.5px;
  line-height: 1.45;
  resize: none;
  overflow: hidden;
  color: var(--ink);
}
.note-input:hover { border-color: var(--rule-2); }
.note-input:focus-visible {
  outline: none;
  border-color: var(--ink);
  background: var(--surface);
}
.ni-tools { display: flex; gap: 2px; padding-top: 5px; }
.ni-btn {
  border: 0;
  background: none;
  color: var(--ink-3);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 6px 5px;
  border-radius: var(--r);
}
.ni-btn:hover:not(:disabled) { color: var(--ink); background: var(--surface-2); }
.ni-btn:disabled { opacity: 0.25; cursor: not-allowed; }
.ni-btn.danger:hover { color: var(--loss); }

@media (max-width: 680px) {
  .note-item { grid-template-columns: 16px 1fr; }
  .ni-tools { grid-column: 2; justify-content: flex-end; padding-top: 0; }
  .note-input { font-size: 15px; }
  .nr-count { display: none; }
}

/* ── Records ─────────────────────────────────────────────────────────────── */
.rec-fresh {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--surface);
  background: var(--gain);
  border-radius: 999px;
  padding: 3px 9px;
}
.rec-list { display: flex; flex-direction: column; }
.rec-row {
  display: grid;
  grid-template-columns: 1fr auto 96px;
  gap: 10px;
  align-items: baseline;
  padding: 9px 0;
  border-top: 1px solid var(--rule-2);
}
.rec-row:first-child { border-top: 0; }
.rec-row.fresh { background: var(--gain-soft); }
.rec-label { font-size: 14px; }
.rec-near {
  display: block;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--ink-3);
  margin-top: 1px;
}
.rec-value {
  font-family: var(--mono);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.rec-where {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Courses ─────────────────────────────────────────────────────────────── */
.course-list { display: flex; flex-direction: column; }
.course-row {
  display: grid;
  grid-template-columns: 1fr 62px 72px;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 11px 0;
  border: 0;
  border-top: 1px solid var(--rule-2);
  background: none;
  text-align: left;
  cursor: pointer;
  color: inherit;
}
.course-row:first-child { border-top: 0; }
.course-row:hover { background: var(--surface-2); }
.cr-name { font-weight: 600; font-size: 15px; }
.cr-sub { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); margin-top: 2px; }
.cr-score, .cr-sg {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.cr-score { color: var(--ink-2); font-size: 14px; }

.hole-table { display: flex; flex-direction: column; margin-top: 8px; }
.ht-head, .ht-row {
  display: grid;
  grid-template-columns: 1fr 40px 48px 34px 64px;
  gap: 8px;
  align-items: baseline;
  padding: 8px 0;
  border-top: 1px solid var(--rule-2);
}
.ht-head {
  border-top: 0;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.ht-row > span:not(.ht-n) {
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.ht-n { font-family: var(--mono); font-size: 13px; }

@media (max-width: 680px) {
  .rec-row { grid-template-columns: 1fr auto; }
  .rec-where { display: none; }
  .course-row { grid-template-columns: 1fr 52px 62px; }
  .ht-head, .ht-row { grid-template-columns: 1fr 32px 42px 28px 56px; }
}


/* ── Round river ─────────────────────────────────────────────────────────── */
.chart.river { width: 100%; height: auto; display: block; }
.river-up { fill: color-mix(in srgb, var(--gain) 30%, transparent); }
.river-down { fill: color-mix(in srgb, var(--loss) 26%, transparent); }
.river-zero { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 6 5; }
.river-line { fill: none; stroke: var(--ink); stroke-linejoin: round; stroke-linecap: round; }
.river-mark { fill: var(--surface); stroke: var(--loss); }
/* Hole cost badges — deliberately not styled like the axis, because they are
   not on the axis scale. */
.river-leader { stroke: var(--loss); stroke-width: 1.5; stroke-dasharray: 2 2; }
.river-badge { fill: var(--loss); }
.river-badge-t {
  font-family: var(--mono);
  font-size: 20px;
  fill: var(--surface);
}
.river-end.gain { fill: var(--gain); }
.river-end.loss { fill: var(--loss); }

/* ── Theme switch ────────────────────────────────────────────────────────── */
.theme-row { display: flex; gap: 8px; margin-top: 12px; }

/* ── Record moment ───────────────────────────────────────────────────────── */
.moment-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: color-mix(in srgb, var(--ground) 88%, transparent);
  backdrop-filter: blur(3px);
  overflow: hidden;
  animation: fadeIn 200ms ease both;
}
.moment-overlay.leaving { opacity: 0; transition: opacity 220ms; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.moment-box {
  position: relative;
  z-index: 2;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 26px 28px 22px;
  text-align: center;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  animation: popIn 320ms cubic-bezier(.2,.8,.3,1) both;
}
@keyframes popIn { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }

.moment-badge {
  display: inline-block;
  background: var(--gain);
  color: var(--surface);
  border-radius: 999px;
  padding: 7px 16px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.moment-item { margin-top: 18px; }
.moment-what { font-size: 20px; font-weight: 600; }
.moment-val {
  font-family: var(--mono);
  font-size: 34px;
  color: var(--gain);
  margin-top: 2px;
}
.moment-prev { font-family: var(--mono); font-size: 11px; color: var(--ink-3); margin-top: 4px; }
.moment-more { font-family: var(--mono); font-size: 11px; color: var(--ink-3); margin: 12px 0 0; }
.moment-close { margin-top: 22px; width: 100%; }

.confetti { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.flake {
  position: absolute;
  top: -20px;
  border-radius: 1px;
  animation-name: fall;
  animation-timing-function: cubic-bezier(.3,.6,.5,1);
  animation-fill-mode: both;
}
.flake.gain { background: var(--gain); }
.flake.loss { background: var(--loss); }
.flake.gym { background: var(--gym); }
.flake.ink { background: var(--ink-2); }
@keyframes fall {
  0% { transform: translate(0, -20px) rotate(0deg); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translate(var(--drift, 0), 105vh) rotate(var(--spin, 180deg)); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .moment-box, .moment-overlay { animation: none; }
}

/* ── River filter ────────────────────────────────────────────────────────── */
.band-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0 2px;
}
.band-input { width: 78px; min-height: 34px; padding: 5px 8px; }

.river-mark.gain { stroke: var(--gain); }
.river-leader.gain { stroke: var(--gain); }
.river-badge.gain { fill: var(--gain); }

.match-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
}
.match-total { font-family: var(--mono); font-size: 12px; }

.match-list { display: flex; flex-direction: column; }
.match-row {
  display: grid;
  grid-template-columns: 34px 54px 74px 1fr 66px;
  gap: 10px;
  align-items: baseline;
  padding: 8px 0;
  border-top: 1px solid var(--rule-2);
}
.match-row:first-child { border-top: 0; }
.mr-hole {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
}
.mr-par, .mr-score, .mr-worst, .mr-sg {
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.mr-par, .mr-worst { color: var(--ink-3); }
.mr-sg { text-align: right; font-size: 13px; }

@media (max-width: 680px) {
  .match-row { grid-template-columns: 26px 46px 62px 1fr 56px; gap: 6px; }
  .mr-par, .mr-score, .mr-worst { font-size: 11px; }
  .mr-worst { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ── Bar chart axis and filtering ────────────────────────────────────────── */
.dbars.axis {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
}
.dbars-axis { position: relative; }
.dbars-tick {
  position: absolute;
  right: 0;
  transform: translateY(-50%);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.dbars-grid {
  position: absolute;
  left: 0; right: 0;
  border-top: 1px solid var(--rule-2);
  pointer-events: none;
}
.dbar.muted { opacity: 0.16; }
.dbar-col.muted .dbar-val { opacity: 0; }
.dbar-val {
  font-family: var(--mono);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  padding: 2px 0;
}
.dbar-half.up { flex-direction: column; justify-content: flex-end; }
.dbar-half.down { flex-direction: column; justify-content: flex-start; }

.river-dot { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; }

@media (max-width: 680px) {
  .dbars.axis { column-gap: 6px; }
  .dbars-tick { font-size: 9.5px; }
  .dbar-val { font-size: 9px; }
}


/* ── Dropdown menu ───────────────────────────────────────────────────────── */
.menu { position: relative; display: inline-block; }
.menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 7px 12px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  min-height: 38px;
}
.menu-btn:hover { border-color: var(--ink-3); color: var(--ink); }
.menu-caret { font-size: 9px; }
.menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  min-width: 190px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 5px;
  z-index: 60;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.16);
}
.menu.right .menu-panel { right: 0; }
.menu.left .menu-panel { left: 0; }
.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  border-radius: var(--r);
  padding: 11px 12px;
  font-size: 14.5px;
  color: var(--ink);
  cursor: pointer;
  min-height: 44px;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item.current { font-weight: 600; background: var(--surface-2); }
.menu-item.danger { color: var(--loss); }
.menu-sep { height: 1px; background: var(--rule-2); margin: 5px 2px; }

/* the section menu only exists on narrow screens */
.nav-menu-wrap { display: none; }
@media (max-width: 680px) {
  .nav-menu-wrap { display: inline-block; }
  .topbar .settings-tab { display: none; }
  .nav-menu-wrap .menu-panel { min-width: 210px; }
  main { padding-bottom: 40px; }
}

/* ── Scorecard ───────────────────────────────────────────────────────────── */
.scorecard { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.sc-block { display: flex; flex-direction: column; }
.sc-row {
  display: grid;
  grid-template-columns: 44px repeat(9, 1fr) 44px;
  align-items: center;
  gap: 2px;
}
.sc-row > span { text-align: center; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.sc-lbl {
  text-align: left !important;
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.sc-tot { font-weight: 600; }
.sc-head > span { font-size: 11px; color: var(--ink-3); padding-bottom: 2px; }
.sc-par > span { font-size: 11px; color: var(--ink-3); }
.sc-score { padding-top: 3px; }
.sc-score > span { font-size: 15px; }

.sc-score em {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  font-style: normal;
  line-height: 1;
}
.sc-score em.birdie, .sc-score em.eagle {
  border: 1.5px solid var(--gain);
  border-radius: 50%;
  color: var(--gain);
}
.sc-score em.eagle { box-shadow: 0 0 0 3px var(--surface), 0 0 0 4.5px var(--gain); }
.sc-score em.bogey { border: 1.5px solid var(--loss); color: var(--loss); }
.sc-score em.double {
  border: 1.5px solid var(--loss);
  color: var(--loss);
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 4.5px var(--loss);
}

.sc-key { display: flex; gap: 12px; font-family: var(--mono); font-size: 10px; color: var(--ink-3); }
.sc-k-item { display: inline-flex; align-items: center; gap: 5px; }
.sc-k-item em { width: 12px; height: 12px; display: inline-block; }
.sc-k-item em.birdie { border: 1.5px solid var(--gain); border-radius: 50%; }
.sc-k-item em.bogey { border: 1.5px solid var(--loss); }
.sc-k-item em.double { border: 1.5px solid var(--loss); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--loss); }

.sc-total {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
}
.sc-total-v { font-family: var(--mono); font-size: 26px; font-variant-numeric: tabular-nums; }
.sc-total-p { font-family: var(--mono); font-size: 15px; }

.sd-row.static { cursor: default; grid-template-columns: 66px 1fr 54px 74px 56px; }
.sd-row.static:hover { background: none; }
.sd-fin { font-family: var(--mono); font-size: 11.5px; text-align: right; }

@media (max-width: 680px) {
  .sc-row { grid-template-columns: 30px repeat(9, 1fr) 32px; gap: 1px; }
  .sc-lbl { font-size: 8px; }
  .sc-head > span, .sc-par > span { font-size: 9.5px; }
  .sc-score > span { font-size: 13px; }
  .sc-score em { width: 21px; height: 21px; }
  .sc-key { display: none; }
  .sd-row.static { grid-template-columns: 52px 1fr 44px 46px; }
  .sd-row.static .sd-club { display: none; }
}
