:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #2563eb;
  --swim: #16a34a;
  --drill: #0284c7;
  --rest: #f59e0b;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
/* A column at least the window's height: on short pages the footer (and the cookie notice) sit at the bottom. */
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.3rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.5rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.5rem; }
code { background: var(--bg); padding: 0 0.25em; border-radius: 3px; }

.top { display: flex; align-items: center; gap: 2rem; padding: 0.75rem 1.5rem; background: #0f172a; color: #fff; }
.top .brand { color: #fff; display: inline-flex; align-items: center; gap: 0.6rem; font-family: "Outfit", system-ui, sans-serif; font-weight: 600; font-size: 1.6rem; letter-spacing: -0.01em; line-height: 1; text-decoration: none; }
.top .brand:hover { text-decoration: none; }
.top .brand img { display: block; height: 38px; width: auto; }
/* The word has no descenders: lift it so the logo centres on its letters, not on the line box. */
.top .brand span { position: relative; top: -0.06em; }
.top nav a { color: #cbd5e1; margin-right: 1.25rem; }
main { width: 100%; max-width: 1200px; margin: 0 auto; padding: 1.25rem; flex: 1 0 auto; }

.card { background: var(--card); border-radius: 10px; padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; box-shadow: 0 1px 2px rgb(15 23 42 / 0.06); }
.card.narrow { max-width: 480px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.flash { background: #dbeafe; border-left: 4px solid var(--accent); padding: 0.6rem 0.9rem; border-radius: 6px; }
.title-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }

button { background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: 0.5rem 1rem; font: inherit; cursor: pointer; }
button.link { background: none; color: var(--accent); padding: 0; }
button.danger { color: #dc2626; }
input, select { font: inherit; padding: 0.35rem 0.5rem; border: 1px solid var(--line); border-radius: 6px; }
.upload { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.stack { display: grid; gap: 0.9rem; }
.stack label { display: grid; gap: 0.3rem; }
.stack label.checkbox { display: flex; align-items: center; gap: 0.5rem; }
.stack label.checkbox input { width: auto; margin: 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.75rem; }
.tile { background: var(--bg); border-radius: 8px; padding: 0.6rem 0.75rem; display: grid; gap: 0.2rem; }
.tile span { color: var(--muted); font-size: 0.8rem; }
.tile strong { font-size: 1.1rem; }

.scroll { overflow-x: auto; }
.scroll.tall { max-height: 460px; overflow-y: auto; }
.scroll.tall thead th { position: sticky; top: 0; background: var(--card); }
table.list { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
table.list th, table.list td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.list th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
table.selectable tbody tr { cursor: pointer; }
table.selectable tbody tr:hover { background: #f8fafc; }
table.selectable tbody tr.selected { background: #dbeafe; }
tr.kind-rest td { color: var(--muted); }
tr.merged td:first-child { box-shadow: inset 3px 0 0 #64748b; }
tr.all td { font-weight: 600; }
td.watch { font-weight: 700; text-align: center; color: var(--accent); }

.badge { display: inline-block; font-size: 0.75rem; padding: 0.1rem 0.45rem; border-radius: 999px; background: var(--bg); color: var(--muted); font-weight: 600; vertical-align: middle; }
.badge.swim { background: #dcfce7; color: var(--swim); }
.badge.drill { background: #e0f2fe; color: var(--drill); }
.badge.rest { background: #fef3c7; color: #b45309; }

.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 1rem; }
.charts figure, .arms figure { margin: 0; }
figcaption { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.3rem; }

/* Combined pace / heart rate / stroke rate chart (workoutChart.js). */
.workout-chart { position: relative; }
.wc-host { width: 100%; min-width: 0; }
.wc-svg { display: block; width: 100%; height: auto; font-family: inherit; user-select: none; }
.wc-svg .tabular { font-variant-numeric: tabular-nums; }
.wc-svg .halo { paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round; }
.wc-tooltip { position: absolute; pointer-events: none; background: #fff; border: 1px solid var(--line); border-radius: 6px;
  padding: 0.4rem 0.6rem; font-size: 0.8rem; line-height: 1.45; white-space: nowrap; box-shadow: 0 2px 6px rgb(15 23 42 / 0.12); z-index: 2; }
.wc-legend { display: grid; gap: 0.35rem; margin-top: 0.5rem; font-size: 0.8rem; }
.wc-legend-row { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; align-items: center; }
.wc-key { display: inline-flex; align-items: center; gap: 0.35rem; white-space: nowrap; }
.wc-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.wc-swatch.merged { border: 1.5px dashed; }
/* Comparison page: interval colour swatches and the Combined / Separate switch. */
.series-swatch { margin-right: 0.4rem; vertical-align: -1px; }
#compare-series-legend { margin: 0.25rem 0 0.5rem; font-size: 0.85rem; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented button { border: 0; background: #fff; padding: 0.3rem 0.8rem; font: inherit; font-size: 0.85rem; cursor: pointer; color: inherit; }
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button[aria-pressed="true"] { background: #0f172a; color: #fff; }
.cc-tip-row { display: flex; align-items: center; gap: 0.35rem; white-space: nowrap; }
.wc-line { width: 16px; height: 2px; border-radius: 1px; display: inline-block; }
.wc-line.dashed, .wc-line.dotted { height: 0; border-radius: 0; border-top: 2px dashed currentColor; }
.wc-line.dotted { border-top-style: dotted; }

.controls { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; margin: 0.5rem 0 0.75rem; }
.arms { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 1rem; }
.arm { height: 340px; background: linear-gradient(#f8fafc, #e0f2fe); border-radius: 8px; overflow: hidden; display: grid; }
.arm canvas { display: block; }
.arm .placeholder { place-self: center; max-width: 80%; text-align: center; }
.phasebar { position: relative; display: flex; height: 22px; border-radius: 6px; overflow: hidden; margin-top: 0.5rem; font-size: 0.72rem; color: #fff; }
.phasebar > div:not(.cursor) { display: flex; align-items: center; justify-content: center; white-space: nowrap; overflow: hidden; }
.phasebar .cursor { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1px; background: #0f172a; }
.arm-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1rem; margin-top: 0.4rem; }
.arm-controls label { display: inline-flex; align-items: center; gap: 0.3rem; }
.arm-controls .play-toggle { min-width: 5.5em; text-align: left; }
.arm-controls .ideal-swatch { display: inline-block; width: 0.9em; height: 0.9em; border-radius: 3px; background: #7c3aed; opacity: 0.55; }
.arm-controls .other-swatch { background: #db2777; }
.force-split { margin-top: 0.5rem; }
.force-split .force-row { display: flex; align-items: center; gap: 0.5rem; }
.force-split .force-name { flex: 0 0 8em; white-space: nowrap; }
.force-split .phasebar { flex: 1; margin-top: 0.3rem; height: 20px; }
.force-split .force-key { display: inline-flex; align-items: center; gap: 0.25rem; margin-right: 0.6rem; white-space: nowrap; }
.force-split .force-dot { width: 0.7em; height: 0.7em; border-radius: 2px; display: inline-block; }
.force-split .wasted .phasebar { height: 14px; margin-top: 0.15rem; font-size: 0.65rem; }
.force-split .wasted .rest { background: #e2e8f0; color: #64748b; }

.arms figure { min-width: 0; } /* lets wide tables scroll inside their own column */
.heatmaps { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 1rem; }
.arm-heat .heatmaps { grid-template-columns: 1fr; } /* one table per row under each arm */
/* Interval stroke feedback: class bars per category, plus the watch preview. */
#interval-feedback { margin: 0.5rem 0 1rem; }
#stroke [hidden] { display: none; }
/* Comparison page: class of the median stroke per interval, with its tone as a swatch. */
#compare-stroke th:first-child { text-align: left; font-weight: 600; white-space: nowrap; }
#compare-stroke td.stroke-bar { vertical-align: middle; }
/* Calibration (admins): labels on the activity page, the calibration page. */
#calibration-labels { margin: 0.5rem 0 1rem; }
.cal-labels { margin: 0.25rem 0 0.5rem; padding-left: 1.2rem; }
.cal-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.cal-ok { color: #15803d; }
.cal-drop { color: #b91c1c; }
.cal-plot { display: block; max-width: none; }
.cal-set summary { cursor: pointer; }
.cal-set summary h2 { display: inline; }
.cal-pool { margin: 0.75rem 0 0.25rem; }
.cal-set ul { padding-left: 1.2rem; }
.cal-set ul li { margin: 0.2rem 0; }
.cal-plan td { white-space: normal; }
.cal-plan td.nowrap { white-space: nowrap; font-weight: 600; }
#cal-categories td { white-space: normal; }
#cal-categories td .small { min-width: 16rem; }
.cal-axis { font-size: 11px; fill: #475569; }
#cal .swatch { display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 2px; margin-right: 0.4rem; }
pre.code { background: #0f172a; color: #e2e8f0; padding: 0.75rem 1rem; border-radius: 8px; overflow-x: auto; font-size: 0.8rem; }
/* Scale under a bar: each class name centred under its (equal-width) segment. */
.fb-scale-names { display: flex; font-size: 0.65rem; line-height: 1.15; margin-top: 1px; }
.fb-scale-names span { flex: 1 1 0; text-align: center; }
/* Table and watch faces side by side when there is room, faces below otherwise. */
.fb-layout { display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: flex-start; }
.fb-rows { display: grid; gap: 0.35rem; flex: 1 1 560px; align-content: start; }
.fb-row { display: grid; grid-template-columns: minmax(9rem, 14rem) 240px minmax(8rem, 1fr); gap: 0.75rem; align-items: center; font-size: 0.9rem; }
.fb-scale { display: grid; }
.fb-ends { display: flex; justify-content: space-between; font-size: 0.7rem; }
.fb-bar { display: block; overflow: visible; }
.watch-preview { flex: 0 0 auto; }
.watch-faces { display: flex; flex-wrap: wrap; gap: 1rem; }
.watch-face { width: 227px; height: 227px; border-radius: 50%; background: #000; color: #fff; box-sizing: border-box;
  padding: 20px 38px 14px; display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: 0 0 0 6px #334155; font-size: 11.5px; } /* px: a fixed-size watch mock-up, not scaled with the page text */
/* As on the watch: arm and strokes on top, page at the bottom, rows centred between them. */
.wf-rows { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 6px; padding: 4px 0; }
.wf-head, .wf-foot { text-align: center; color: #94a3b8; font-size: 11px; }
.wf-label { display: flex; justify-content: space-between; gap: 0.4rem; }
.wf-label span { font-weight: 600; } /* both labels alike, as on the watch */
.wf-class { color: #ffffff; }
@media (max-width: 640px) {
  .fb-row { grid-template-columns: 1fr; gap: 0.15rem; margin-bottom: 0.4rem; }
}
.recs { margin: 0; padding-left: 1.4rem; display: grid; gap: 0.6rem; }
.recs li { padding: 0.6rem 0.8rem; background: #f8fafc; border-radius: 8px; }
.recs p { margin: 0.25rem 0 0; }
.rec-head { display: flex; flex-wrap: wrap; gap: 0.3rem 0.6rem; align-items: baseline; }
.recs .badge { font-size: 0.72rem; padding: 0.05rem 0.45rem; border-radius: 999px; font-weight: 600; }
.recs .impact-high { background: #fee2e2; color: #b91c1c; }
.recs .impact-medium { background: #fef3c7; color: #b45309; }
.recs .impact-low { background: #e2e8f0; color: #475569; }
.recs .trend-improving { background: #dcfce7; color: #15803d; }
.recs .trend-worse { background: #fee2e2; color: #b91c1c; }
.recs .trend-steady, .recs .trend-none { background: #e2e8f0; color: #475569; }
/* Overview technique priorities (strokeTrend.js): text left, the share per swim on the right */
.rec-body { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 0.4rem 1.2rem; align-items: start; }
.rec-spark { display: block; width: 100%; height: auto; }
.rec-spark-cap { font-size: 0.75rem; color: var(--muted); margin: 0.3rem 0 0; }
@media (max-width: 640px) { .rec-body { grid-template-columns: 1fr; } .rec-spark-wrap { max-width: 320px; } }

/* Table and its diagram side by side; the diagram goes below the table on narrow screens. */
.technique { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 0.5rem 1rem; align-items: start; }
@media (max-width: 560px) { .technique { grid-template-columns: minmax(0, 1fr); } }
.technique .heatmap { min-width: 0; }
.technique .diagram { margin: 0; }
.technique .diagram svg { display: block; max-width: 100%; height: auto; background: #f8fafc; border-radius: 6px; }
.technique .diagram figcaption { max-width: 190px; margin-top: 0.2rem; line-height: 1.3; }
.heatmap { overflow-x: auto; }
.heatmap table { border-collapse: separate; border-spacing: 2px; font-size: 0.8rem; }
.heatmap th { text-align: left; color: var(--muted); font-weight: 600; padding: 0.2rem 0.4rem; white-space: nowrap; }
.heatmap th.label { font-weight: 400; color: var(--text); }
.heatmap td.cell { min-width: 3.2rem; text-align: center; padding: 0.3rem 0.2rem; border-radius: 4px; }
.heatmap tr.strokes td, .heatmap tr.strokes th { color: var(--muted); font-size: 0.75rem; }
/* Technique tables: all the same width (fill their column), fixed share column, a colour bar
   on each row label matching the class's zone in the diagram beside it. */
.technique-table { width: 100%; table-layout: fixed; }
.technique-table th:last-child, .technique-table td.cell { width: 4.2rem; text-align: center; }
.technique-table th { overflow: hidden; text-overflow: ellipsis; }
.technique-table th.label { border-left: 4px solid transparent; padding-left: 0.5rem; }

/* Interval comparison: add button on the activity page, stacked charts on compare.php. */
button.secondary { background: var(--bg); color: var(--text); border: 1px solid var(--line); }
.compare-add { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; align-items: center; margin: 0 0 0.75rem; }
.compare-add:empty { display: none; }
.compare-item { border-top: 1px solid var(--line); padding-top: 0.9rem; margin-top: 0.9rem; }
.compare-item:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.compare-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.3rem 1rem; margin-bottom: 0.3rem; }
.compare-head h2 { margin: 0; }
.compare-key { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 0.4rem; background: var(--text); }
.badge.pb { background: #fef3c7; color: #92400e; margin-left: 0.35rem; }
.badge.tt { background: #ede9fe; color: #5b21b6; margin-left: 0.35rem; }

/* Time trials page (timetrials.php, ttChart.js). */
.tt-group { border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 1rem; }
.tt-group:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.tt-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 1rem; }
.tt-chart { position: relative; min-width: 0; }
.tt-chart svg { display: block; width: 100%; height: auto; font-family: inherit; }
.tt-chart .dot { cursor: pointer; }
.tt-chart .dot:hover circle.mark { r: 7; }
.tt-summary { margin: 0.2rem 0 0.6rem; }

/* Activities: paging by month */
.month-pager { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; margin: 0 0 0.75rem; }
.month-pager form { margin: 0; }
.month-pager .pager-off { color: var(--muted, #94a3b8); }
.month-pager .month-total { margin-left: auto; }

/* Targets: profile table and the line on the time trials page */
.table-scroll { overflow-x: auto; }
table.targets input[type="text"] { width: 7.5em; font-variant-numeric: tabular-nums; }
table.targets td { vertical-align: middle; }
.tt-target { margin: -0.3rem 0 0.6rem; color: #9a3412; }
.badge.css { background: #ccfbf1; color: #0f766e; margin-left: 0.35rem; }
h1 .badge.css { font-size: 0.8rem; }
.css-tests td, .css-tests th { padding: 0.3rem 0.5rem; }

/* Dashboard (front page) */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(460px, 100%), 1fr)); gap: 1.25rem 2rem; margin-bottom: 1.25rem; }
.dash-panel { min-width: 0; }
.dash-headline { margin: 0.2rem 0 0.6rem; }
.dash-bars { display: grid; gap: 0.15rem; }
.dash-bar-row { display: grid; grid-template-columns: minmax(8rem, 1.1fr) 2fr 6.5rem; gap: 0.6rem; align-items: center;
  padding: 0.3rem 0.4rem; border-radius: 6px; color: var(--text); font-size: 0.9rem; }
.dash-bar-row:hover { background: #f8fafc; text-decoration: none; }
.dash-bar-row.best { background: #eff6ff; }
.dash-bar-row.best .dash-bar-label { font-weight: 600; }
.dash-bar-track { position: relative; height: 12px; }
.dash-bar-zero { position: absolute; top: -3px; bottom: -3px; width: 1px; background: var(--muted); }
.dash-bar { position: absolute; top: 0; height: 12px; border-radius: 4px; }
.dash-bar-value { font-variant-numeric: tabular-nums; font-size: 0.82rem; text-align: right; color: var(--muted); white-space: nowrap; }
.dash-svg { display: block; width: 100%; height: auto; font-family: inherit; user-select: none; }
.dash-chart { margin: 0; min-width: 0; }
.dash-chart figcaption { font-size: 0.85rem; font-weight: 600; margin-bottom: 0.2rem; }
.dash-legend { font-size: 0.78rem; color: var(--muted); margin: 0.2rem 0 0.4rem; }
.dash-key-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dash-key-dot.hollow { background: #fff; border: 2px solid; width: 9px; height: 9px; }
.dash-key-line { width: 16px; height: 2px; background: #94a3b8; display: inline-block; }
.dash-dot { cursor: default; }
.dash-month:hover path { opacity: 0.8; }
.dash-monthly-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 1rem 2rem; }
.dash-strength-table { font-size: 0.88rem; }
.dash-strength-table tr.focus td { background: #fff7ed; }
.badge.focus { background: #ffedd5; color: #9a3412; margin-left: 0.35rem; }
.dash-focus { color: #9a3412; }
.dash-strength-set + .dash-strength-set { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: 0.75rem; }
.stroke-needs { background: #fef3c7; color: #92400e; border-left: 4px solid #d97706; padding: 0.45rem 0.75rem; border-radius: 6px; margin: 0.3rem 0 0.6rem; }
/* Stroke technique trend (strokeTrend.js): fixed one-line captions so the card keeps its height while swims are analysed */
.trend-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(440px, 100%), 1fr)); gap: 0.4rem 2rem; }
.trend-status, .trend-body .dash-legend { grid-column: 1 / -1; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trend-row figcaption { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trend-latest { font-weight: 400; }
.trend-key + .trend-key { margin-left: 0.9rem; }
.trend-mark { display: inline-block; width: 9px; height: 9px; vertical-align: -1px; }
.trend-mark.left { border-radius: 50%; }
.trend-mark.right { border-radius: 2px; }
.trend-point { cursor: pointer; }
.trend-point:hover circle:not([fill="transparent"]), .trend-point:hover rect { stroke: #0f172a; }
@media (max-width: 520px) {
  .dash-bar-row { grid-template-columns: 1fr 5.5rem; }
  .dash-bar-track { grid-column: 1 / -1; grid-row: 2; }
}

/* Pace zones (activity page, profile) */
.zone-rows { display: grid; gap: 0.2rem; max-width: 900px; }
.zone-row { display: grid; grid-template-columns: 8.5rem 9.5rem 1fr 7.5rem; gap: 0.75rem; align-items: center; padding: 0.25rem 0; font-size: 0.9rem; }
.zone-track { height: 14px; position: relative; }
.zone-bar { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; }
.zone-value { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.zone-range { font-variant-numeric: tabular-nums; font-size: 0.85rem; }
table.zones td, table.zones th { white-space: nowrap; }
@media (max-width: 560px) {
  .zone-row { grid-template-columns: 1fr auto; gap: 0.15rem 0.75rem; }
  .zone-range { grid-column: 1; grid-row: 2; }
  .zone-track { grid-column: 1 / -1; grid-row: 3; }
}
.dash-zone-bars { display: grid; gap: 0.5rem; margin: 0.6rem 0 0.3rem; }
.dash-zone-row { display: grid; grid-template-columns: 10rem 1fr; gap: 0.75rem; align-items: center; }
.dash-zone-label { display: flex; flex-direction: column; line-height: 1.2; font-size: 0.9rem; }
.dash-zone-track { display: flex; gap: 2px; height: 22px; min-width: 0; }
.dash-zone-seg { flex-basis: 0; min-width: 2px; display: flex; align-items: center; justify-content: center; overflow: hidden;
  font-size: 0.75rem; font-variant-numeric: tabular-nums; color: #0f172a; white-space: nowrap; }
.dash-zone-seg:first-child { border-top-left-radius: 4px; border-bottom-left-radius: 4px; }
.dash-zone-seg:last-child { border-top-right-radius: 4px; border-bottom-right-radius: 4px; }
.dash-zone-row.target { border-top: 1px dashed var(--line); padding-top: 0.5rem; }
.dash-zone-row.target .dash-zone-seg { opacity: 0.6; }
.dash-zone-advice .dash-headline { margin-bottom: 0.1rem; }
.badge.zone { color: #0f172a; }
.dash-zone-table { font-size: 0.88rem; max-width: 40rem; margin-top: 0.4rem; }
.dash-zone-table .wc-swatch { display: inline-block; vertical-align: middle; }
@media (max-width: 520px) {
  .dash-zone-row { grid-template-columns: 1fr; gap: 0.2rem; }
  .dash-zone-label { flex-direction: row; gap: 0.5rem; align-items: baseline; }
}
.dashboard .dash-grid { margin-bottom: 0; }
.dash-pb-table { font-size: 0.9rem; }
/* Top card: fine dividers between pace improvement | personal bests (left) and strength (right). */
.dashboard .dash-grid { grid-template-columns: 1fr; gap: 0; }
.dashboard .dash-panel + .dash-panel { border-top: 1px solid var(--line); margin-top: 1.25rem; padding-top: 1.25rem; }
.dash-pb-title { border-top: 1px solid var(--line); margin-top: 1.25rem; padding-top: 1.25rem; }
@media (min-width: 1000px) {
  .dashboard .dash-grid { grid-template-columns: 1fr 1fr; }
  .dashboard .dash-panel:first-child { padding-right: 2rem; }
  .dashboard .dash-panel + .dash-panel { border-top: 0; margin-top: 0; padding-top: 0; border-left: 1px solid var(--line); padding-left: 2rem; }
}
.arms figcaption.arm-title { font-size: 1.1rem; font-weight: 700; color: var(--text, #0f172a); margin: 0 0 0.5rem; padding-bottom: 0.3rem; border-bottom: 1px solid var(--line); }
/* Latest swim summary card (front page): the whole card links to the activity. */
a.card.latest-swim { display: block; color: inherit; text-decoration: none; transition: box-shadow 0.15s, transform 0.15s; }
a.card.latest-swim:hover { box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12); }
a.card.latest-swim:focus-visible { outline: 2px solid var(--accent, #2563eb); outline-offset: 2px; }
.latest-swim h1 { margin-bottom: 0.75rem; }
.latest-open { color: var(--accent, #2563eb); font-weight: 600; white-space: nowrap; }
.latest-zones { display: grid; grid-template-columns: auto 1fr; gap: 0.75rem; align-items: center; margin-top: 0.9rem; }
.latest-marks { margin: 0.75rem 0 0; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.latest-pool { font-weight: 400; font-size: 1rem; }
.badge.ok { background: #dcfce7; color: #166534; }
.form-actions { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
#integrations h2 { margin-top: 0.25rem; }
/* Accounts: header user menu, login / register forms. */
.top .account { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.top .account form { margin: 0; }
.top .account-name { color: #e2e8f0; font-weight: 600; }
.top .account button.link { color: #93c5fd; }
.auth-card { margin-inline: auto; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0.9rem; }
.form-error { background: #fee2e2; color: #991b1b; border-left: 4px solid #dc2626; padding: 0.6rem 0.9rem; border-radius: 6px; }
.form-error p, .form-error ul { margin: 0.2rem 0; }
.inline-form { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.inline-form input { flex: 1 1 14rem; min-width: 0; }
fieldset.optional { border: 1px solid var(--line); border-radius: 8px; padding: 0.6rem 0.9rem 0.9rem; display: grid; gap: 0.7rem; margin: 0; }
fieldset.optional label { display: grid; gap: 0.3rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 640px) {
  .top { flex-wrap: wrap; gap: 0.6rem 1.25rem; }
  .top .account { margin-left: 0; }
}
/* Cards side by side when there is room (profile page): at most two columns, one below about 45rem. */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(max(min(22rem, 100%), calc((100% - 1.25rem) / 2)), 1fr)); gap: 1.25rem; align-items: start; margin-bottom: 1.25rem; }
.card-grid > .card { margin-bottom: 0; min-width: 0; }

/* Watch guide (guide.php, rendered from docs/watch-guide.md) */
.guide { max-width: 860px; margin: 0 auto; line-height: 1.55; }
.guide h1 { font-size: 1.6rem; }
.guide h2 { font-size: 1.3rem; margin: 2rem 0 0.6rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.guide h3 { font-size: 1.08rem; margin: 1.4rem 0 0.5rem; }
.guide h2, .guide h3 { scroll-margin-top: 1rem; }
.guide p, .guide ul, .guide ol { margin: 0.6rem 0; }
.guide li { margin: 0.2rem 0; }
.guide li > ul, .guide li > ol { margin: 0.2rem 0; }
.guide img { width: 250px; max-width: 100%; height: auto; vertical-align: top; margin: 0.25rem 0.4rem 0.25rem 0; border-radius: 12px; }
.guide blockquote { margin: 0.75rem 0; padding: 0.4rem 0.9rem; border-left: 4px solid var(--accent); background: var(--bg); border-radius: 6px; }
.guide blockquote p { margin: 0.3rem 0; }
.guide table.list { margin: 0.6rem 0; }
.guide table.list td, .guide table.list th { white-space: normal; vertical-align: top; }

/* Terms of use (terms.php, rendered from docs/terms.md with the .guide typography) and consent */
.accept-card { max-width: 860px; margin-inline: auto; border-left: 4px solid var(--accent); }
.accept-card .decline { margin: 0.75rem 0 0; }
.stack label.checkbox.consent { align-items: flex-start; line-height: 1.45; }
.stack label.checkbox.consent input { margin-top: 0.25em; flex: 0 0 auto; }
.terms-note { max-width: 860px; margin: 0 auto 0.6rem; }

/* Footer (helpers.php page_footer) */
.site-footer { width: 100%; max-width: 1200px; margin: 0.5rem auto 0; padding: 1rem 1.25rem 1.75rem; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 0.85rem; line-height: 1.5; }
.site-footer p { margin: 0 0 0.6rem; max-width: 62rem; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; margin: 0 0 0.6rem; }
.site-footer .footer-legal { font-size: 0.78rem; margin: 0; }
.site-footer .data-note { color: var(--text); }

/* The read-only demo account (helpers.php page_header, profile.php) */
.demo-banner { background: #e0f2fe; border-bottom: 1px solid #bae6fd; color: #0c4a6e; }
.demo-banner p { max-width: 1200px; margin: 0 auto; padding: 0.55rem 1.25rem; font-size: 0.9rem; }
fieldset.demo-readonly { border: 0; margin: 0; padding: 0; min-width: 0; }
form.inline-button { display: inline; margin: 0; }

/* Garmin attribution ("Garmin [device model]") right under an activity's title: Garmin's API brand
   guidelines want it next to the heading, above the fold, in readable text. */
.data-source { margin: -0.35rem 0 0.75rem; color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.latest-swim .data-source { margin-top: -0.6rem; }

/* Profile: Garmin Connect */
.warning { background: #fef3c7; border-left: 4px solid #d97706; padding: 0.5rem 0.8rem; border-radius: 6px; color: #78350f; }
.garmin-recent { margin: 0 0 0.75rem; padding-left: 1.2rem; color: var(--muted); }
.garmin-recent li { margin: 0.15rem 0; }

/* Cookie notice: stuck to the bottom of the window until accepted; it follows the footer in the
   page flow, so at the end of the page it sits below the footer instead of covering it. */
.cookie-notice { position: sticky; bottom: 0; z-index: 50; display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1.25rem;
  margin: 0; padding: 0.8rem max(1.25rem, calc((100% - 1200px) / 2 + 1.25rem)); background: #0f172a; color: #e2e8f0;
  font-size: 0.85rem; line-height: 1.45; box-shadow: 0 -2px 10px rgb(15 23 42 / 0.25); }
.cookie-notice p { margin: 0; flex: 1 1 26rem; }
.cookie-notice a { color: #93c5fd; }
.cookie-notice button { flex: 0 0 auto; }
@media (max-width: 600px) {
  .guide img { width: calc(50% - 0.8rem); }
}

/* ---- Landing page (src/landing.php: index.php for visitors, about.php) ---------------------- */
.landing { display: grid; gap: 1.25rem; }
.button { display: inline-flex; align-items: center; padding: 0.65rem 1.2rem; border: 1px solid transparent; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 600; }
.button:hover { text-decoration: none; background: #1d4ed8; }
.button.ghost { background: transparent; border-color: rgb(255 255 255 / 0.4); color: #fff; }
.button.ghost:hover { background: rgb(255 255 255 / 0.1); }
.hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1.5rem 2.5rem; align-items: center;
  padding: clamp(1.5rem, 4vw, 3rem); border-radius: 16px; color: #cbd5e1; overflow: hidden;
  background: radial-gradient(circle at 80% 30%, rgb(56 189 248 / 0.25), transparent 55%), linear-gradient(155deg, #0f172a 0%, #14284a 100%); }
.hero .eyebrow { margin: 0 0 0.9rem; color: #7dd3fc; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.hero h1 { margin: 0 0 1rem; color: #fff; font-family: "Outfit", system-ui, sans-serif; font-weight: 600;
  font-size: clamp(2rem, 4.4vw, 3.1rem); line-height: 1.08; letter-spacing: -0.02em; text-wrap: balance; }
.hero .lead { margin: 0 0 1.6rem; max-width: 34rem; font-size: 1.12rem; line-height: 1.55; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.hero-watches { display: flex; justify-content: center; align-items: flex-start; }
.hero-watches img { width: min(46%, 250px); height: auto; filter: drop-shadow(0 16px 28px rgb(0 0 0 / 0.5)); }
.hero-watches img + img { margin: 3.5rem 0 0 -3rem; }
.landing-section { background: var(--card); border-radius: 12px; padding: clamp(1.25rem, 3vw, 2.25rem); box-shadow: 0 1px 2px rgb(15 23 42 / 0.06); }
.landing-section > h2, .landing-cta h2 { margin: 0 0 0.4rem; font-family: "Outfit", system-ui, sans-serif; font-weight: 600;
  font-size: 1.65rem; letter-spacing: -0.01em; }
.section-lead { margin: 0 0 1.5rem; max-width: 48rem; color: var(--muted); font-size: 1.05rem; line-height: 1.5; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; margin: 1.25rem 0 0; padding: 0;
  list-style: none; counter-reset: step; }
.steps li { position: relative; padding: 1.1rem 1.1rem 1.2rem 3.7rem; border-radius: 10px; background: var(--bg); counter-increment: step; }
.steps li::before { content: counter(step); position: absolute; left: 1.05rem; top: 1rem; width: 1.9rem; height: 1.9rem; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 700; }
.steps h3, .feature h3 { margin: 0.15rem 0 0.35rem; font-size: 1.05rem; }
.steps p, .feature p { margin: 0; color: var(--muted); line-height: 1.5; }
.watch-shots { display: grid; grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr)); gap: 1.25rem; }
.watch-shots figure { display: grid; justify-items: center; align-content: start; gap: 0.5rem; margin: 0; text-align: center; }
.watch-shots img { width: 100%; max-width: 210px; height: auto; }
.watch-shots figcaption { max-width: 16rem; margin: 0; color: var(--muted); font-size: 0.92rem; line-height: 1.45; }
.watch-shots figcaption strong { display: block; margin-bottom: 0.15rem; color: var(--text); font-size: 1rem; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(16.5rem, 1fr)); gap: 1rem; }
.feature { padding: 1.1rem 1.15rem 1.25rem; border-radius: 10px; background: var(--bg); }
.feature svg { display: block; width: 40px; height: 40px; margin-bottom: 0.5rem; color: var(--accent); }
.feature p { font-size: 0.95rem; }
.landing-notes { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1.25rem; }
.landing-note { padding: 1.25rem 1.35rem; border-top: 4px solid #38bdf8; border-radius: 12px; background: var(--card);
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.06); }
.landing-note h2 { margin: 0 0 0.4rem; font-size: 1.08rem; }
.landing-note p { margin: 0; color: var(--muted); line-height: 1.5; }
.landing-cta { padding: clamp(1.5rem, 4vw, 2.75rem); border-radius: 16px; text-align: center; color: #cbd5e1;
  background: radial-gradient(circle at 20% 0%, rgb(56 189 248 / 0.2), transparent 50%), linear-gradient(155deg, #0f172a, #14284a); }
.landing-cta h2 { color: #fff; }
.landing-cta p { margin: 0 0 1.25rem; }
.landing-cta .hero-actions { justify-content: center; }
/* Header links for visitors (helpers.php page_header) */
.top .account.visitor a { color: #cbd5e1; }
.top .account.visitor a.cta { padding: 0.4rem 0.85rem; border-radius: 6px; background: var(--accent); color: #fff; font-weight: 600; }
.top .account.visitor a.cta:hover { text-decoration: none; background: #1d4ed8; }
.top .account.visitor button.cta { padding: 0.4rem 0.85rem; border-radius: 6px; background: var(--accent); color: #fff; font-weight: 600; }
.top .account.visitor button.cta:hover { background: #1d4ed8; }
/* Sign-up closed (config registration_open): Create account stays visible, disabled and marked
   "Coming soon" (helpers.php create_account_button; all of them sit on dark backgrounds). */
.button.disabled, .top .account.visitor .cta.disabled { background: rgb(255 255 255 / 0.06); border: 1px dashed rgb(255 255 255 / 0.32);
  color: #94a3b8; cursor: default; }
.button.disabled:hover { background: rgb(255 255 255 / 0.06); }
.top .account.visitor .cta.disabled { display: inline-flex; align-items: center; padding: 0.3rem 0.6rem; border-radius: 6px; font-weight: 600; }
/* Visitors' header links never break inside a label; on a narrow screen the row wraps by whole links. */
.top .account.visitor { flex-wrap: wrap; gap: 0.5rem 1rem; }
.top .account.visitor > * { white-space: nowrap; }
.soon { margin-left: 0.5rem; padding: 0.1rem 0.45rem; border-radius: 999px; background: rgb(56 189 248 / 0.18); color: #7dd3fc;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
@media (max-width: 800px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero-watches img { width: min(44%, 210px); }
}

/* ---- Phones (applied automatically on screens up to 640 px wide) ------------------------------
   Larger type (every rem size scales with the root), small print raised, tighter page margins,
   navigation that wraps by whole links with room to tap, two tiles a row, and anything wider than
   the screen scrolling inside its own card: one over-wide element made phones zoom the whole
   page out, which is what made it too small to read. */
@media (max-width: 640px) {
  :root { font-size: 18px; }
  main { padding: 0.75rem 0.6rem; }
  .card { padding: 0.95rem 0.9rem; margin-bottom: 0.9rem; border-radius: 8px; overflow-x: auto; }
  .card-grid { gap: 0.9rem; margin-bottom: 0.9rem; }
  .top { padding: 0.6rem 0.9rem; }
  .top .brand { font-size: 1.4rem; }
  .top .brand img { height: 32px; }
  .top nav { display: flex; flex-wrap: wrap; gap: 0 1.1rem; }
  .top nav a { margin-right: 0; padding: 0.3rem 0; white-space: nowrap; }
  h1 { font-size: 1.25rem; }
  .small { font-size: 0.92rem; }
  /* Small labels: at least ~14 px. */
  .badge, .recs .badge, .dash-legend, .wc-legend, .fb-ends, .fb-scale-names, .heatmap tr.strokes td,
  .heatmap tr.strokes th, .phasebar, .dash-zone-seg, .dash-chart figcaption { font-size: 0.8rem; }
  /* Chart text (drawn 1:1 at the screen width): 11 -> 12.5 px. */
  .wc-svg text, .tt-svg text { font-size: 12.5px; }
  /* Technique diagrams at the full card width (about twice their 190 px drawing). */
  .technique .diagram svg { width: 100%; }
  /* Interval feedback: bars across the full width under their labels; the two watch pages one below the other. */
  .fb-scale .fb-bar { width: 100%; height: auto; }
  .watch-preview { flex: 1 1 100%; }
  .watch-faces { justify-content: center; }
  table.list { font-size: 0.95rem; }
  table.list th { font-size: 0.85rem; }
  table.list th, table.list td { padding: 0.5rem 0.5rem; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
  .tile span { font-size: 0.85rem; }
  button { padding: 0.6rem 1rem; }
  input, select, textarea { font-size: max(1rem, 16px); } /* 16 px or more: iOS does not zoom in on focus */
  .title-row { flex-wrap: wrap; gap: 0.4rem 1rem; }
  .site-footer { padding: 0.9rem 0.9rem 1.4rem; }
  .site-footer nav a { padding: 0.2rem 0; }
  .cookie-notice { padding: 0.7rem 0.9rem; font-size: 0.8rem; }
  .hero .lead, .section-lead { font-size: 1rem; }
  .landing-section > h2, .landing-cta h2 { font-size: 1.35rem; }
  .hero-watches img + img { margin: 2.5rem 0 0 -2rem; }
}
