/* Garmin Training Hub: the category standard (Whoop / Apple Fitness bar).
   Graphite ground, raised rounded flat cards, a readiness ring that makes the day's call,
   metric tiles in two columns, condensed figures, one violet accent for chrome only.
   Every colour comes from a token below; CSP forbids inline style attributes. */

@font-face { font-family: "Barlow Semi Condensed"; src: url("/fonts/barlow-semi-condensed-600.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Barlow Semi Condensed"; src: url("/fonts/barlow-semi-condensed-700.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Barlow Semi Condensed"; src: url("/fonts/barlow-semi-condensed-800.woff2") format("woff2"); font-weight: 800; font-style: normal; font-display: swap; }

:root {
  /* Graphite ramp: the only neutrals */
  --g0: #0e0f11; --g1: #141518; --g2: #1b1d21; --g3: #24272c; --g4: #2a2d32; --g5: #3a3e45;
  --g6: #6c7179; --g7: #8b9098; --g8: #a3a8af; --g9: #c9cdd2; --g10: #eef0f2;
  --ink: var(--g10); --soft: var(--g9); --muted: var(--g8); --line: var(--g4);
  /* Cards: the raised surface */
  --card: #1a1c20; --card-press: var(--g3);
  /* Accent: active tab, primary actions, focus, links. Never a data colour. */
  --accent: #8b7dff; --accent-fill: #6b5cf0; --accent-ink: #ffffff;
  /* States: meaning only, tint exceptions */
  --good: #46c98a; --fair: #f2b43c; --poor: #ff6b5e; --info: #7cc4ff;
  --fair-ground: #2a2312; --fair-line: #5a4718; --fair-ink: #ffe1a8;
  --poor-ground: #2e1715; --poor-line: #6b3328; --poor-ink: #ffd9d4;
  /* Data series, movement rings, heart-rate zones */
  --distance: #4f9dff; --calories: #f2b43c; --recovery: #7cc4ff; --effort: #ff8f7a;
  --move-steps: #ff5c8a; --move-intensity: #2ad4e6; --move-floors: #4f9dff;
  --z1: #9aa3ad; --z2: #4f9dff; --z3: #ffd23f; --z4: #ff8a3d; --z5: #ff4f5e;
  /* Type */
  --text: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;
  --figures: "Barlow Semi Condensed", var(--text);
  /* Shape */
  --r-card: 20px; --r-tile: 18px; --r-control: 12px; --r-pill: 999px;

  font-family: var(--text);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--g0);
  accent-color: var(--accent);
  caret-color: var(--accent);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { scrollbar-color: var(--g5) var(--g0); }
::selection { background: var(--accent-fill); color: var(--accent-ink); }
body { margin: 0; min-height: 100vh; background: var(--g0); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) 0 calc(78px + env(safe-area-inset-bottom)); }
main { width: min(760px, 100%); margin: auto; padding: 18px 16px 22px; }
h1 { margin: 0 0 14px; font-size: 2rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; overflow-wrap: anywhere; }
h2 { margin: 0 0 .9rem; font-size: 1.05rem; font-weight: 700; }
h3 { font-size: .92rem; }
a { color: var(--accent); text-underline-offset: 3px; }
.muted { color: var(--muted); }
.error { color: var(--poor); }
.icon { width: 20px; height: 20px; flex-shrink: 0; vertical-align: middle; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:focus:not(:focus-visible), a:focus:not(:focus-visible) { outline: none; }
a, button, [role="button"] { touch-action: manipulation; -webkit-touch-callout: none; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--soft); font-size: .78rem; line-height: 1.5; }
details summary { cursor: pointer; font-weight: 700; }
.center { text-align: center; margin-top: 28vh; }

/* Tone text (state colours only tint exceptions; records read as good) */
.t-good, .t-record { color: var(--good); } .t-fair { color: var(--fair); } .t-poor { color: var(--poor); }
.t-info { color: var(--info); } .t-muted { color: var(--muted); } .t-soft { color: var(--soft); }
.t-record { font-weight: 700; }

/* ---------- Controls ---------- */
button, input, select { font: inherit; }
button { border: 0; border-radius: var(--r-control); padding: 12px 16px; font-weight: 700; cursor: pointer; color: var(--ink); background: var(--card);
  transition: background-color 120ms ease-out, transform 120ms ease-out; user-select: none; }
button:disabled { opacity: .6; cursor: wait; }
button:active:not(:disabled) { transform: scale(.98); }
/* Primary action: the default button that is not one of the named families below */
button:not(.secondary):not(.chip):not(.r-row):not(.tile):not(.move):not(.link-button):not(.ring-button):not(.hero-morning):not(.danger):not(.dashboard-card):not(.card-button):not(.match):not(.segmented button):not(nav button):not(.more-menu button):not(.hero-dot):not(.pr-prev) { background: var(--accent-fill); color: var(--accent-ink); }
button.secondary { background: var(--card); color: var(--ink); }
@media (hover: hover) { button.secondary:hover:not(:disabled) { background: var(--card-press); } }
.page-stack .card button.secondary, .panel button.secondary, dialog button.secondary { background: var(--card-press); }
@media (hover: hover) { .page-stack .card button.secondary:hover:not(:disabled), .panel button.secondary:hover:not(:disabled) { background: var(--g5); } }
button.danger { background: var(--poor-ground); color: var(--poor-ink); box-shadow: inset 0 0 0 1px var(--poor-line); }
button.small { padding: 8px 12px; font-size: .84rem; }
.link-button { padding: 4px 0; background: none; color: var(--accent); font-size: .84rem; font-weight: 600; white-space: nowrap; }
.icon-button { width: 44px; height: 44px; padding: 0; display: inline-grid; place-items: center; }
.home-button, .account-button { width: 42px; height: 42px; flex: 0 0 42px; padding: 0; display: grid; place-items: center; border-radius: var(--r-pill); }
.copy-button { white-space: nowrap; padding: 10px 12px; }
.overflow-button { min-width: 44px; padding: 8px 12px; display: grid; place-items: center; }
.button-spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--g5); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; }
#sync-page.is-busy .icon { animation: spin .9s linear infinite; }

label { font-size: .84rem; color: var(--muted); }
input, select { width: 100%; margin: .35rem 0 .8rem; padding: 14px; border-radius: var(--r-control); border: 1px solid var(--card); background: var(--card); color: var(--ink); }
input[type="date"] { min-width: 0; max-width: 100%; color-scheme: dark; }
.panel input, .panel select, .page-stack .card input, .page-stack .card select, dialog input, dialog select { background: var(--card-press); border-color: var(--g5); }
#workout-json { width: 100%; max-width: 100%; margin: 10px 0; padding: 12px; resize: vertical; border: 1px solid var(--g5); border-radius: var(--r-control); background: var(--card-press); color: var(--ink); font: 16px ui-monospace, monospace; }

.date-field { position: relative; display: block; min-width: 0; }
.date-field-text { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: .35rem 0 .8rem; padding: 14px; border-radius: var(--r-control); background: var(--card); color: var(--ink); font-size: 1rem; }
.date-field-text .icon { width: 18px; height: 18px; color: var(--muted); flex: none; }
.date-field input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; opacity: 0; cursor: pointer; }
.date-field:focus-within .date-field-text { outline: 2px solid var(--accent); outline-offset: 1px; }
.page-stack .card .date-field-text { background: var(--card-press); }

.chip { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 12px; border-radius: var(--r-pill); background: var(--card); color: var(--soft); font-size: .84rem; font-weight: 600; white-space: nowrap; }
.chip.active { background: var(--ink); color: var(--g0); }
.chip .icon { width: 16px; height: 16px; flex: 0 0 16px; }
.chip-row, .record-pick { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.segmented { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; padding: 3px; border-radius: var(--r-control); background: var(--card); }
.segmented button { padding: 9px 6px; border-radius: 9px; background: none; color: var(--soft); font-size: .84rem; white-space: nowrap; }
.segmented button.active { background: var(--card-press); color: var(--ink); }
.pill { display: inline-block; padding: 4px 10px; border-radius: var(--r-pill); background: var(--card-press); color: var(--soft); font-size: .78rem; font-weight: 600; }
.pill.warning { background: var(--fair-ground); color: var(--fair); }
.notice { padding: 12px 14px; border: 1px solid var(--fair-line); border-radius: var(--r-control); background: var(--fair-ground); color: var(--fair-ink); }
.notice .secondary { display: block; margin: 8px 0 4px; }
.approval { display: flex; align-items: flex-start; gap: 10px; margin: 14px 0; color: var(--fair-ink); }
.approval input { width: auto; margin-top: 3px; }

/* ---------- Page header, control strip ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.page-header > * { min-width: 0; }
.page-title { display: flex; align-items: flex-start; gap: 10px; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.section-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 12px; }
.section-heading h2, .section-heading p { margin: 0; }

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; min-width: 0; }
.filters > * { min-width: 0; }
.filters > button, .filters #sync-state, .filters .sport-chips { grid-column: 1 / -1; }
.filters.compact { display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 4px 0 6px; margin: 0 0 4px; }
.filter-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: stretch; }
.filter-row input, .filter-row button { height: 44px; margin: 0; }
.filter-row .date-field-text { height: 44px; margin: 0; padding: 0 14px; }
.sport-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.sport-chips::-webkit-scrollbar { display: none; }
.sport-chips .chip { flex: none; padding: 7px 12px; }
.sport-chips .chip span { overflow: hidden; text-overflow: ellipsis; }
.sync-line { margin: 0; min-width: 0; font-size: .84rem; color: var(--muted); }
.sync-line:empty { display: none; }
.sync-line.error, .sync-freshness.missing { color: var(--poor); font-weight: 600; }
.sync-freshness { margin: 0; color: var(--muted); font-size: .84rem; }
.sync-line-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* ---------- Cards ---------- */
.card, .panel, .hero { margin: 0 0 12px; padding: 16px; border: 0; border-radius: var(--r-card); background: var(--card); overflow-wrap: anywhere; }
.card > h2:first-child, .panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 0 0 6px; font-size: 1.05rem; font-weight: 700; }
.panel-status { font-size: .84rem; font-weight: 600; color: var(--muted); }
.panel-off .panel-status { color: var(--fair); }
.panel-head .link-button { padding: 0; font-size: .84rem; }
.sheet-note { margin: 8px 0 0; font-size: .84rem; color: var(--soft); }
.panel h3, .card h3 { margin: 16px 0 6px; font-size: .84rem; font-weight: 600; color: var(--muted); }

/* Rows inside a card: label left, figure right, "vs base" and the result word under it */
.r-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; align-items: start; width: 100%; margin: 0; padding: 11px 0;
  border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; color: inherit; font: inherit; font-weight: 400; text-align: left; }
.r-row:last-of-type { border-bottom: 0; }
button.r-row { cursor: pointer; }
@media (hover: hover) { button.r-row:hover:not(:disabled) { background: var(--card-press); } }
button.r-row:active:not(:disabled) { background: var(--card-press); transform: none; }
button.r-row:focus-visible { outline-offset: -2px; }
.r-label { min-width: 0; padding-top: 3px; font-weight: 600; }
.r-label small { display: block; margin-top: 2px; font-size: .78rem; font-weight: 400; color: var(--muted); }
.r-fig { display: flex; flex-direction: column; align-items: flex-end; min-width: 0; text-align: right; }
.r-today { font-family: var(--figures); font-size: 1.6rem; font-weight: 800; line-height: 1; white-space: nowrap; }
.r-today small { font-family: var(--text); font-size: .78rem; font-weight: 600; color: var(--muted); }
.r-today .live { vertical-align: baseline; }
.r-hero .r-today { font-size: 2.3rem; }
.r-meta { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; font-size: .84rem; line-height: 1.2; color: var(--muted); white-space: nowrap; }
.r-base i { font-style: normal; color: var(--g7); }
.mark { font-weight: 600; }
.mark.t-muted { color: var(--muted); }
.r-scale { grid-column: 1 / -1; display: block; margin-top: 2px; }
.r-splits { grid-column: 1 / -1; margin-top: 8px; font-size: .84rem; line-height: 1.4; color: var(--muted); }
.r-splits b { color: var(--soft); font-weight: 600; }

/* ---------- Daily hero ---------- */
.hero { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; align-items: center; padding: 18px 16px; }
.hero-text h2 { margin: 0 0 6px; font-size: 1.3rem; font-weight: 800; line-height: 1.15; letter-spacing: -.01em; text-wrap: balance; }
.hero-text p { margin: 0; font-size: .92rem; color: var(--soft); }
.hero-text .hero-reason { margin-top: 8px; font-weight: 600; }
.hero-text .hero-ready { margin-top: 8px; font-size: .84rem; }
.hero-text .hero-next { margin-top: 8px; font-size: .84rem; color: var(--ink); }
.hero-text .hero-morning { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: .84rem; }
.hero-text .hero-foot { margin-top: 8px; font-size: .78rem; color: var(--muted); }
.hero-ready b, .hero-foot b, .tile-sub b { white-space: nowrap; }
.dot-state { width: 8px; height: 8px; flex: none; border-radius: 50%; background: currentColor; }
.ring-button { display: block; margin: 0; padding: 0; border-radius: 50%; background: none; }

/* Rings */
.ring { display: block; flex: none; }
.ring-track { stroke: var(--g4); }
.ring-good .ring-fill { stroke: var(--good); } .ring-fair .ring-fill { stroke: var(--fair); } .ring-poor .ring-fill { stroke: var(--poor); }
.ring-muted .ring-fill { stroke: var(--g6); } .ring-session .ring-fill { stroke: var(--info); }
.ring-move-steps .ring-fill { stroke: var(--move-steps); } .ring-move-intensity .ring-fill { stroke: var(--move-intensity); } .ring-move-floors .ring-fill { stroke: var(--move-floors); }
.ring-score { font-family: var(--figures); font-size: 40px; font-weight: 800; fill: var(--ink); }
.ring-caption { font-size: 10px; font-weight: 700; letter-spacing: .12em; fill: var(--muted); }
.ring-pct { font-family: var(--figures); font-size: 17px; font-weight: 800; fill: var(--ink); }
.hero .ring-fill { animation: ring-draw 1100ms cubic-bezier(.16, 1, .3, 1) both; }
@keyframes ring-draw { from { stroke-dasharray: 0 999; } }

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0 0 12px; }
.tile { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; margin: 0; padding: 14px 14px 13px; border-radius: var(--r-tile);
  background: var(--card); color: inherit; font: inherit; font-weight: 400; text-align: left; }
button.tile { cursor: pointer; }
@media (hover: hover) { button.tile:hover:not(:disabled) { background: var(--card-press); } }
button.tile:active:not(:disabled) { background: var(--card-press); }
.tile-label { font-size: .84rem; font-weight: 600; color: var(--muted); }
.tile-value { font-family: var(--figures); font-size: 2rem; font-weight: 800; line-height: 1.05; }
.tile-value small { font-family: var(--text); font-size: .78rem; font-weight: 600; color: var(--muted); }
.tile-meta { font-size: .84rem; color: var(--soft); }
.tile-sub { margin-top: 2px; font-size: .78rem; line-height: 1.35; color: var(--muted); }
.tile-sub b { color: var(--soft); font-weight: 600; }

/* Garmin-style zone bar */
.zscale { width: 100%; margin-top: 8px; }
.zscale svg { display: block; width: 100%; height: 12px; overflow: visible; }
.zs-seg { opacity: .9; }
.zs-good { fill: var(--good); } .zs-fair { fill: var(--fair); } .zs-poor { fill: var(--poor); } .zs-info { fill: var(--z2); }
.zs-marker { fill: var(--ink); stroke: var(--g0); stroke-width: .6; vector-effect: non-scaling-stroke; }
.scale-ticks { position: relative; height: 14px; margin-top: 3px; font-size: .78rem; color: var(--muted); }
.tick { position: absolute; top: 0; white-space: nowrap; transform: translateX(-50%); }
.tick-start { transform: none; } .tick-end { transform: translateX(-100%); }
.tile .zscale { margin-top: 6px; }

/* Movement rings */
.moves { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 6px; }
.move { display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 0; padding: 6px 0; border-radius: 14px; background: none; color: inherit; font: inherit; font-weight: 400; }
button.move { cursor: pointer; }
.move .ring { margin-bottom: 6px; }
.move-value { font-family: var(--figures); font-size: 1.3rem; font-weight: 800; }
.move-label { font-size: .84rem; font-weight: 600; }
.move-goal { font-size: .78rem; color: var(--muted); text-align: center; }

/* Heart-rate zone bars */
.zbars { display: grid; gap: 10px; margin-top: 6px; }
.zbar { display: grid; grid-template-columns: 4.6rem minmax(0, 1fr) 5.4rem; gap: 10px; align-items: center; }
.zbar-name { font-size: .84rem; font-weight: 600; color: var(--soft); }
.zbar-track { display: block; width: 100%; height: 10px; }
.zbar-bg { fill: var(--g4); }
.zbar-fill.z1 { fill: var(--z1); } .zbar-fill.z2 { fill: var(--z2); } .zbar-fill.z3 { fill: var(--z3); } .zbar-fill.z4 { fill: var(--z4); } .zbar-fill.z5 { fill: var(--z5); }
.zbar-value { text-align: right; font-family: var(--figures); font-size: 1rem; font-weight: 700; white-space: nowrap; }
.zbar-value small { font-family: var(--text); font-size: .78rem; font-weight: 600; color: var(--muted); }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; }
.chart text { fill: var(--muted); font-size: 9px; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-note { margin: 6px 0 0; font-size: .78rem; }
.chart-host { margin-bottom: 12px; }
.panel .ichart { max-width: 560px; }
.bar { rx: 2px; transform-origin: bottom; transform-box: fill-box; animation: bar-grow .8s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes bar-grow { from { transform: scaleY(0); } }
.ibar { opacity: .6; transition: opacity .15s; }
.ibar.active { opacity: 1; }
.cursor { stroke: var(--ink); stroke-opacity: .7; stroke-width: 1; }
.scrub-host { touch-action: pan-y; user-select: none; }
.readout { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; min-height: 2.6em; margin: 14px 0 6px; font-size: .84rem; color: var(--muted); }
.readout strong { color: var(--ink); font-size: .92rem; }
.readout-item b { color: var(--ink); font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: .84rem; }
.dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; }
svg.dot { border-radius: 0; margin-right: 5px; }
.dot-distance { background: var(--distance); } .dot-calories { background: var(--calories); }

/* ---------- Tables, facts ---------- */
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .84rem; }
th, td { padding: 9px 6px; text-align: left; border-bottom: 1px solid var(--line); }
th { font-size: .78rem; font-weight: 600; color: var(--muted); }
.table-scroll { max-width: 100%; max-height: min(60vh, 28rem); overflow: auto; isolation: isolate; border-radius: var(--r-control); }
.table-scroll th, .table-scroll td { white-space: nowrap; background: var(--card); }
.table-scroll thead th { position: sticky; top: 0; z-index: 2; background: var(--card-press); }
.table-scroll tr > :first-child { position: sticky; left: 0; z-index: 1; border-right: 1px solid var(--line); }
.table-scroll thead tr > :first-child { z-index: 3; }
.facts { margin: 12px 0; }
.facts > div { padding: 10px 0; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--muted); text-transform: capitalize; }
.facts dd { margin: 5px 0 0; overflow-wrap: anywhere; }
.facts .facts { padding-left: 12px; border-left: 1px solid var(--line); }

/* ---------- Dashboard ---------- */
.dashboard-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.dashboard-header h1 { margin-bottom: .25rem; }
.dashboard-header p { margin: 0; }
.dashboard-header .pill { margin-top: 8px; white-space: nowrap; }
.dashboard-notice { margin-bottom: 18px; }
.dashboard-metrics { margin-bottom: 24px; }
.grid, .dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; min-width: 0; }
.grid > * { min-width: 0; }
.grid > .card { margin: 0; }
.dashboard-card { display: block; min-height: 120px; margin: 0; padding: 16px; border-radius: var(--r-tile); background: var(--card); color: var(--ink); text-align: left; font-weight: 400; }
@media (hover: hover) { .dashboard-card:hover:not(:disabled) { background: var(--card-press); } }
.dashboard-card strong { display: block; margin-bottom: 8px; font-size: 1.05rem; color: var(--ink); }
.dashboard-card span { display: block; color: var(--muted); font-size: .84rem; line-height: 1.4; font-weight: 500; }
.dashboard-card > .icon, .dashboard-card > .motion-art { margin-bottom: 8px; color: var(--soft); }
.metric { position: relative; min-height: 172px; padding: 18px 18px 82px; }
.metric strong { display: block; font-family: var(--figures); font-size: 1.6rem; font-weight: 800; }
.metric .metric-label { display: block; margin-top: 7px; line-height: 1.45; }
.metric span { color: var(--muted); font-size: .84rem; }
.metric--text strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: clamp(.88rem, 3.4vw, 1.12rem); line-height: 1.5; overflow-wrap: normal; }
.metric .metric-status { display: flex; align-items: center; gap: 5px; margin-top: 10px; font-size: .78rem; }
.metric-status .icon { width: 15px; height: 15px; }
.metric .positive { color: var(--good); } .metric .caution { color: var(--fair); } .metric .neutral { color: var(--muted); }
.metric-icon { position: absolute; right: 12px; bottom: 10px; width: 64px; height: 64px; pointer-events: none; color: var(--soft); }
.metric.tone-positive .metric-icon { color: var(--good); } .metric.tone-caution .metric-icon { color: var(--fair); }
.metric-action { position: absolute; left: 16px; bottom: 16px; z-index: 1; width: 38px; height: 38px; padding: 9px; border-radius: 50%; }
.card-button { width: 100%; text-align: left; font: inherit; font-weight: 400; color: inherit; cursor: pointer; }
.metric.card-button { display: block; }
@media (hover: hover) { .card-button:hover:not(:disabled) { background: var(--card-press); } }

/* Animated metric art (dashboard): runs only while visible, never under reduced motion */
.motion-art { display: block; width: 64px; height: 64px; }
.motion-art > .icon { display: block; width: 40px; height: 40px; margin: 12px; }
.route-track, .score-track, .hrv-baseline, .motion-ground, .motion-terrain, .clock-ticks, .training-lines { opacity: .22; }
.route-draw { stroke-dasharray: 100; }
.score-fill { stroke-width: 4; }
.battery-fill { transform-origin: 12px 32px; }
.runner-shirt { stroke-width: 7; }
.runner-arm { stroke-width: 4; transform-origin: 33px 22px; }
.runner-leg { stroke-width: 5; transform-origin: 29px 35px; }
.runner-arm-back, .runner-leg-back { opacity: .45; }
.runner-body { transform-origin: 32px 34px; }
.clock-hand, .bike-crank { transform-origin: 32px 32px; }
.route-target { transform-origin: 51px 51px; }
.motion-art .runner-body { animation: runner-bounce 700ms ease-in-out infinite; }
.motion-art .runner-arm-front { animation: runner-arm-front 700ms ease-in-out infinite; }
.motion-art .runner-arm-back { animation: runner-arm-back 700ms ease-in-out infinite; }
.motion-art .runner-leg-front { animation: runner-leg-front 700ms ease-in-out infinite; }
.motion-art .runner-leg-back { animation: runner-leg-back 700ms ease-in-out infinite; }
.art-walker .runner-body, .art-walker .runner-arm, .art-walker .runner-leg { animation-duration: 1400ms; }
.motion-art .route-draw { animation: route-draw 2800ms cubic-bezier(.4, 0, .2, 1) both; }
.motion-art .route-target { animation: target-arrive 2800ms ease-out both; }
.motion-art .battery-fill { animation: battery-charge 1200ms cubic-bezier(.2, .7, .2, 1) both; }
.motion-art .score-fill { animation: score-charge 1200ms cubic-bezier(.2, .7, .2, 1) both; }
.motion-art .wave-draw { stroke-dasharray: 100; animation: route-draw 1800ms ease-out both; }
.motion-art .clock-hand { animation: clock-turn 2400ms cubic-bezier(.4, 0, .2, 1) both; }
.motion-art .bike-crank { animation: pedal-turn 1200ms linear infinite; transform-origin: 39px 43px; }
.training-writing { stroke-dasharray: 100; animation: training-write 3200ms ease-in-out infinite; }
.training-pen { animation: training-pen 3200ms ease-in-out infinite; }
.art-heart > .icon { animation: heart-beat 1800ms ease-in-out 2; }
.art-moon > .icon, .art-flame > .icon { animation: icon-breathe 2400ms ease-in-out 2; }
.art-steps > .icon { animation: footsteps 1400ms ease-in-out 3; }
.motion-art, .motion-art * { animation-play-state: paused !important; }
.motion-visible .motion-art, .motion-visible .motion-art * { animation-play-state: running !important; }
#app:not(.motion-enabled) .motion-art, #app:not(.motion-enabled) .motion-art * { animation: none !important; }
@keyframes runner-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
@keyframes runner-arm-front { 0%, 100% { transform: rotate(-18deg); } 50% { transform: rotate(-88deg); } }
@keyframes runner-arm-back { 0%, 100% { transform: rotate(15deg); } 50% { transform: rotate(88deg); } }
@keyframes runner-leg-front { 0%, 100% { transform: rotate(-20deg); } 50% { transform: rotate(-95deg); } }
@keyframes runner-leg-back { 0%, 100% { transform: rotate(5deg); } 50% { transform: rotate(90deg); } }
@keyframes route-draw { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
@keyframes target-arrive { 0%, 65% { opacity: 0; transform: translateY(-8px) scale(.65); } 85% { opacity: 1; transform: translateY(1px) scale(1.08); } 100% { opacity: 1; transform: none; } }
@keyframes battery-charge { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes score-charge { from { stroke-dasharray: 0 100; } }
@keyframes clock-turn { from { transform: rotate(-120deg); } to { transform: rotate(0); } }
@keyframes pedal-turn { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes training-write { 0% { stroke-dashoffset: 100; } 72%, 100% { stroke-dashoffset: 0; } }
@keyframes training-pen {
  0% { opacity: 0; transform: translate(-18px, -22px); } 5% { opacity: 1; }
  24% { transform: translate(4px, -22px); } 28% { transform: translate(-18px, -12px); }
  49% { transform: translate(4px, -12px); } 53% { transform: translate(-18px, -2px); }
  72% { opacity: 1; transform: translate(0, -2px); } 82%, 100% { opacity: 0; transform: translate(3px, 1px); }
}
@keyframes heart-beat { 0%, 40%, 100% { transform: scale(1); } 15% { transform: scale(1.1); } 25% { transform: scale(1); } 32% { transform: scale(1.06); } }
@keyframes icon-breathe { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-2px) scale(1.05); } }
@keyframes footsteps { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }

/* ---------- Account ---------- */
.identity { display: flex; flex-direction: column; gap: 4px; margin: 12px 0 4px; }
.identity strong { font-size: 1.3rem; font-weight: 800; color: var(--ink); }
.identity span, .identity .account-weight { color: var(--soft); font-weight: 600; }
.account-status { display: flex; align-items: center; gap: 8px; margin: -6px 0 12px; color: var(--muted); font-size: .84rem; }
.mini-loader { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.vma-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.vma-row strong { font-family: var(--figures); font-size: 1.6rem; font-weight: 800; }
.vma-row strong small { font-family: var(--text); font-size: .78rem; font-weight: 600; color: var(--muted); }
.vma-form { display: grid; gap: 10px; max-width: 420px; }
.vma-form input { margin: 6px 0 0; }
.inline-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.inline-form label { min-width: 0; }
.inline-form [data-action-status] { grid-column: 1 / -1; margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 10px; }
.acct-section.fade-in { animation: acct-fade .45s ease-out; }
@keyframes acct-fade { from { opacity: 0; transform: translateY(6px); } }
.live { display: inline-block; max-width: 100%; overflow: hidden; vertical-align: bottom; }
.roll-track { display: block; }
.roll-cell { display: block; white-space: nowrap; }
.roll-track.rolling { animation: roll-up .6s cubic-bezier(.2, .8, .2, 1); }
@keyframes roll-up { from { transform: translateY(0); } to { transform: translateY(-50%); } }
.effort-list { display: flex; flex-direction: column; gap: 10px; margin: 0 0 12px; padding: 0; list-style: none; }
.effort-list li { display: flex; align-items: center; gap: 12px; }
.effort-list li > div { display: flex; flex-direction: column; }
.effort-list strong { font-family: var(--figures); font-size: 1.3rem; font-weight: 800; }
.rank { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--card-press); color: var(--soft); font-size: .84rem; font-weight: 700; }
.tile-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tile-row > div { display: flex; flex-direction: column; gap: 4px; }
.tile-row strong { font-family: var(--figures); font-size: 1.3rem; font-weight: 800; }

/* ---------- Compare ---------- */
.compare-side label { display: block; margin: 8px 0; }
.compare-tag { font-size: .84rem; font-weight: 700; }
.tag-a { color: var(--distance); } .tag-b { color: var(--recovery); }
.match-list { display: flex; flex-direction: column; gap: 6px; max-height: 360px; margin: 10px 0; overflow-y: auto; }
.match { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; margin: 0; padding: 10px 12px; border-radius: var(--r-control);
  background: var(--card-press); color: inherit; font-weight: 400; text-align: left; }
.match.active { box-shadow: inset 0 0 0 2px var(--accent); }
.match-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.match-main strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .92rem; }
.match-main .muted { font-size: .78rem; }
.match-score { display: flex; flex: 0 0 auto; flex-direction: column; align-items: flex-end; font-weight: 700; color: var(--ink); }
.match-score small { font-size: .78rem; font-weight: 400; color: var(--muted); }
.compare-delta { margin: 6px 0; font-family: var(--figures); font-size: 2.3rem; font-weight: 800; line-height: 1.15; }
.compare-delta small { font-family: var(--text); font-size: .92rem; font-weight: 500; color: var(--muted); }
.compare-delta.muted { color: var(--muted); }
.delta-faster { color: var(--good); } .delta-slower { color: var(--effort); }
.run-type-edit summary { cursor: pointer; color: var(--muted); }
.run-type-edit label { display: block; margin-top: 8px; }
#compare-go { width: 100%; margin: 4px 0 8px; }
#compare-run { margin-bottom: 12px; }

/* ---------- Training (workouts) ---------- */
.program-day-header, .program-item, .program-actions { display: flex; align-items: center; gap: 10px; }
.program-day-header, .program-item { justify-content: space-between; }
.program-day-header h3 { margin: 0; }
.program-item { padding: 12px 0; border-top: 1px solid var(--line); }
.program-actions { flex-wrap: wrap; justify-content: flex-end; }

/* ---------- Nutrition and fueling ---------- */
.nutrition-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 0; border-top: 1px solid var(--line); }
.nutrition-row:first-child { border-top: 0; }
.nutrition-row > div:first-child { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.nutrition-row span, .nutrition-row small { color: var(--muted); overflow-wrap: anywhere; }
.nutrition-row.is-hidden { opacity: .58; }
.nutrition-actions { display: flex; flex-shrink: 0; gap: 6px; }
.default-foods { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.default-foods label { display: flex; align-items: center; gap: 8px; }
.default-foods input { width: auto; margin: 0; }
.fuel-targets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.fuel-targets p { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 12px; border-radius: var(--r-control); background: var(--card-press); }
.fuel-targets span { color: var(--muted); font-size: .78rem; }
.fuel-comparison { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 4px 0 14px; }
.fuel-comparison > div { padding: 13px; border-radius: 14px; background: var(--card-press); }
.fuel-comparison h3 { margin: 0 0 10px; }
.food-hints { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.food-hint { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 11px; border-radius: var(--r-control); background: var(--card-press); }
.food-hint span, .food-hint small { color: var(--muted); overflow-wrap: anywhere; }
.food-pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; }
.food-pagination span { min-width: 78px; text-align: center; color: var(--muted); font-size: .84rem; }
.food-pagination button:disabled { cursor: default; }

/* ---------- Navigation, overlays, loading ---------- */
nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 8px max(8px, calc((100vw - 760px) / 2)) calc(8px + env(safe-area-inset-bottom)); background: var(--g1); border-top: 1px solid var(--line); }
nav button { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 48px; padding: 9px 2px; background: none; color: var(--muted); }
@media (hover: hover) { nav button:hover { color: var(--ink); } }
nav button.active { color: var(--accent); }
nav button .icon { width: 24px; height: 24px; }
.nav-date { display: grid; place-items: center; width: 25px; height: 25px; border: 1.7px solid currentColor; border-radius: 6px; font-size: .78rem; line-height: 1; }
.more-menu { position: fixed; right: max(12px, env(safe-area-inset-right)); bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 20;
  display: flex; flex-direction: column; gap: 2px; padding: 6px; border-radius: var(--r-tile); background: var(--card-press); }
.more-menu button { display: flex; align-items: center; justify-content: flex-start; gap: 10px; min-width: 180px; background: none; color: var(--ink); font-weight: 600; }
@media (hover: hover) { .more-menu button:hover { background: var(--g5); } }
dialog { width: min(420px, calc(100% - 32px)); padding: 18px; border: 0; border-radius: var(--r-card); background: var(--card); color: var(--ink); overscroll-behavior: contain; }
dialog::backdrop { background: #000000b3; }
dialog.fullscreen { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; border-radius: 0; background: var(--g0); overflow-y: auto;
  padding: max(18px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); }
html:has(dialog[open]), body:has(dialog[open]) { overflow: hidden; }
.detail-body { max-width: 760px; margin: 0 auto; }
.detail-body .dialog-header { margin-bottom: 14px; }
.dialog-header, .dialog-actions { display: flex; align-items: center; gap: 10px; }
.dialog-header { justify-content: space-between; }
.dialog-header h2 { margin: 0; }
.dialog-actions { flex-direction: column; align-items: stretch; margin-top: 20px; }
.dialog-actions button { width: 100%; }
#account-detail { width: min(92vw, 480px); }
.auto-sync { position: fixed; top: calc(env(safe-area-inset-top) + 10px); left: 50%; z-index: 50; transform: translateX(-50%); max-width: calc(100vw - 32px);
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: var(--r-pill); background: var(--card-press); color: var(--ink); font-size: .84rem; }
.page-loading { display: grid; place-items: center; min-height: 180px; text-align: center; }
.page-loading p { margin-bottom: 0; color: var(--muted); }
.spinner { width: 28px; height: 28px; margin: auto; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.reveal-pending { opacity: 0; transform: translateY(6px); }
.card, .panel, .tile, .dashboard-card { transition: opacity 180ms ease-out, transform 180ms ease-out, background-color 120ms ease-out; }

/* ---------- Responsive and motion preferences ---------- */
@media (min-width: 600px) { .grid { grid-template-columns: repeat(4, 1fr); } .dashboard-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } main { padding-top: 32px; } }
@media (max-width: 420px) {
  .dashboard-header { flex-direction: column; } .dashboard-header .pill { margin-top: 0; }
  .filters, .inline-form, .form-grid { grid-template-columns: 1fr; } .inline-form [data-action-status] { grid-column: auto; }
  .nutrition-row { align-items: flex-start; flex-direction: column; } .nutrition-actions { width: 100%; } .nutrition-actions button { flex: 1; }
  .default-foods, .food-hints { grid-template-columns: 1fr; }
}
@media (max-width: 360px) { .hero { grid-template-columns: 1fr; justify-items: start; } .tile-value { font-size: 1.6rem; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .reveal-pending { opacity: 1; transform: none; }
}

/* ---------- Review round (whole app) ---------- */
/* Labelled tab bar */
nav button { flex-direction: column; gap: 3px; min-height: 52px; padding: 6px 2px; }
.nav-label { font-size: .68rem; font-weight: 600; line-height: 1; }
body { padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
.more-menu { right: max(12px, calc((100vw - 760px) / 2 + 8px)); bottom: calc(80px + env(safe-area-inset-bottom)); }
/* Header never wraps: long titles clamp to two lines */
.page-header { flex-wrap: nowrap; align-items: flex-start; }
.page-title { min-width: 0; flex: 1; }
.page-title h1 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.header-actions { flex: none; }
.compare-run-button { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.activity-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 12px; }
.grid { margin-bottom: 12px; }
/* Compare option rows scroll instead of wrapping one chip alone */
.chip-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -16px; margin-right: -16px; padding: 0 16px; }
.chip-row::-webkit-scrollbar { display: none; }
.chip-row .chip { flex: none; }
/* Charts keep a readable, fixed label size: the plot stops growing on wide screens */
.ichart, .chart-host { max-width: 520px; }
.chart text { font-size: 10px; }
/* Absent data (future day, unsynced day or week) is a flat dash, never a zero bar */
.bar-missing { fill: var(--g5); }
/* Morning call after the session is a button into readiness history */
.hero-text .hero-morning { display: flex; align-items: center; gap: 6px; width: auto; margin-top: 8px; padding: 0; background: none; color: var(--soft); font-size: .84rem; font-weight: 400; text-align: left; }
.hero-morning b { color: var(--ink); font-family: var(--figures); font-size: 1rem; }
.num-table td { font-variant-numeric: tabular-nums; }
.num-table td:not(:first-child), .num-table th:not(:first-child) { text-align: right; }
/* The control strip sits on the ground, not in a card */
.card.filters.compact { background: none; border-radius: 0; padding: 4px 0 8px; margin: 0 0 6px; }
/* Scrolling chip rows fade at the edge so a cut chip reads as "more this way" */
.chip-row { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); }
/* Capped charts sit centred in their card */
.ichart { margin-inline: auto; }
.back-button { flex: none; margin-top: 2px; }
.back-button .icon { transform: scaleX(-1); }
.page-title { display: flex; align-items: flex-start; gap: 10px; }

/* ---------- Nutrition pantry and calculator ---------- */
fieldset { margin: 0 0 14px; padding: 0; border: 0; min-width: 0; }
legend { margin-bottom: 6px; padding: 0; font-size: .84rem; color: var(--muted); }
.choice-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.choice-chips .chip { padding: 8px 14px; }
.panel .choice-chips .chip, dialog .choice-chips .chip { background: var(--card-press); }
.panel .choice-chips .chip.active, dialog .choice-chips .chip.active { background: var(--ink); color: var(--g0); }
.fav-mark { display: inline-flex; margin-right: 6px; vertical-align: -3px; color: var(--fair); }
.fav-mark .icon { width: 16px; height: 16px; fill: currentColor; stroke: currentColor; }
.chip .icon { width: 15px; height: 15px; }
.food-row.is-hidden { opacity: .6; }
.hidden-foods summary { color: var(--soft); font-weight: 600; }
.hidden-foods .r-row:first-of-type { margin-top: 8px; }
.food-editor { display: grid; gap: 4px; max-width: 520px; }
.food-editor > button { margin-top: 6px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 4px 0 12px; color: var(--ink); font-size: .92rem; font-weight: 600; }
.switch-row small { display: block; margin-top: 2px; color: var(--muted); font-size: .78rem; font-weight: 400; }
.switch { appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 48px; height: 28px; margin: 0; padding: 0; border: 0; border-radius: var(--r-pill); background: var(--g5); cursor: pointer; transition: background-color 150ms ease-out; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); transition: transform 150ms ease-out; }
.switch:checked { background: var(--good); }
.switch:checked::after { transform: translateX(20px); }
.more-nutrients { margin: 4px 0 8px; }
.more-nutrients summary { margin-bottom: 10px; color: var(--soft); font-size: .92rem; }
.add-tabs { margin-bottom: 12px; }
.library-row { align-items: center; }
.calc-form { display: grid; gap: 2px; }
.calc-form input { margin: 6px 0 0; }
.is-hidden-field { display: none; }
#other-distance { margin-top: 10px; }
.rate-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.rate-row input { margin: 0; }
.solver-result { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; padding: 14px; border-radius: var(--r-tile); background: var(--card-press); }
.solver-figure { font-family: var(--figures); font-size: 2.3rem; font-weight: 800; line-height: 1; }
.solver-figure small { font-family: var(--text); font-size: .92rem; font-weight: 600; color: var(--muted); }
.section-title-plain { margin: 22px 0 10px; font-size: 1.3rem; font-weight: 800; }
.fuel-note { margin: 0 0 12px; color: var(--soft); font-size: .92rem; }
.timeline-row .minute { display: inline-block; min-width: 3.4rem; margin-right: 6px; font-family: var(--figures); font-weight: 700; color: var(--muted); }

/* Hero: ring and the key facts on top, advice and the morning call underneath at full width */
.hero { display: block; }
.hero-top { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; align-items: center; }
.hero-notes { display: grid; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.hero-notes p, .hero-notes .hero-morning { margin: 0; }
.hero-tip { display: flex; align-items: flex-start; gap: 10px; font-size: .92rem; color: var(--ink); }
.hero-tip-icon { display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--card-press); color: var(--fair); }
.hero-tip-icon .icon { width: 16px; height: 16px; }
.hero-notes .hero-reason { display: flex; align-items: center; gap: 10px; font-size: .84rem; font-weight: 600; }
.hero-notes .hero-reason .dot-state { margin: 0 9px; }
.hero-notes .hero-morning { display: flex; align-items: center; gap: 10px; width: 100%; padding: 0; background: none; color: var(--soft); font-size: .84rem; font-weight: 400; text-align: left; }
.hero-notes .hero-morning .dot-state { margin: 0 9px; }
.hero-notes .hero-foot { padding-left: 36px; font-size: .78rem; color: var(--muted); }
@media (max-width: 360px) { .hero-top { grid-template-columns: 1fr; justify-items: start; } }

/* ---------- Personal records ---------- */
.pr-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.pr-badge { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; font-weight: 700; color: var(--good); }
.pr-badge .icon { width: 14px; height: 14px; }
.pr-badge.pr-past { font-weight: 600; color: var(--muted); }
.ring-cup { stroke: var(--good); transform-box: fill-box; transform-origin: center; }
.hero-record .ring-cup { animation: cup-pop 700ms 400ms cubic-bezier(.34, 1.56, .64, 1) both; }
@keyframes cup-pop { from { opacity: 0; scale: .4; } to { opacity: 1; scale: 1; } }
.hero-text .hero-figure { font-family: var(--figures); font-size: 2rem; font-weight: 800; color: var(--good); line-height: 1.1; }
.hero-figure small { font-family: var(--text); font-size: .84rem; font-weight: 600; color: var(--muted); }
.hero-tip-icon.hero-tip-good { color: var(--good); }
.record-panel .panel-title { display: inline-flex; align-items: center; gap: 8px; }
.record-panel .panel-title .icon { width: 18px; height: 18px; color: var(--good); }

/* Swipeable hero cards */
.hero-slider { margin: 0 0 12px; }
.hero-track { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none; }
.hero-track::-webkit-scrollbar { display: none; }
.hero-track > .hero { flex: 0 0 100%; margin: 0; scroll-snap-align: start; scroll-snap-stop: always; }
.hero-dots { display: flex; justify-content: center; gap: 4px; margin-top: 6px; }
.hero-dot { width: 24px; height: 24px; margin: 0; padding: 0; border-radius: 50%; background: none; position: relative; }
.hero-dot::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--g6); transition: background 200ms; }
.hero-dot.active::after { background: var(--ink); }

/* One-time record celebration */
.confetti { position: fixed; inset: 0; z-index: 50; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: -12px; width: 7px; height: 12px; border-radius: 2px; opacity: 0; animation: confetti-fall linear both; }
@keyframes confetti-fall {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--drift), 105vh) rotate(var(--spin)); }
}

/* ---------- Workout builder ---------- */
.workout-builder { display: grid; gap: 12px; margin: 6px 0 14px; }
.workout-builder > fieldset { margin: 0; }
.builder-meta { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 10px; }
.builder-meta input, .builder-meta .date-field-text { margin: 6px 0 0; background: var(--card-press); }
.builder-summary { padding: 12px 14px; border-radius: var(--r-tile); background: var(--card-press); }
.builder-summary p { margin: 8px 0 0; font-size: .92rem; }
.builder-summary b { font-family: var(--figures); font-size: 1.05rem; }
.workout-timeline { display: block; width: 100%; height: 28px; }
.tl-work { fill: var(--z4); } .tl-rest { fill: var(--z2); } .tl-easy { fill: var(--g6); } .tl-ready { fill: var(--info); }
.builder-block, .builder-repeat { display: grid; gap: 10px; padding: 12px 14px; border-radius: var(--r-tile); background: var(--card-press); }
.builder-repeat { background: none; box-shadow: inset 0 0 0 1px var(--g5); }
.builder-repeat .builder-block { background: var(--card-press); }
.builder-block-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 700; }
.builder-block-head .choice-chips .chip { padding: 5px 12px; background: var(--g5); }
.builder-block-head .choice-chips .chip.active { background: var(--ink); }
.builder-amount { display: flex; align-items: center; gap: 8px; }
.builder-amount input { width: 5.2rem; margin: 0; padding: 10px; text-align: center; font-family: var(--figures); font-size: 1.3rem; font-weight: 800; background: var(--card); }
.builder-amount .unit { min-width: 2rem; color: var(--muted); font-weight: 600; }
.builder-amount .icon-button { width: 40px; height: 40px; font-size: 1.3rem; background: var(--g5); }
.block-work .builder-block-head > span { color: var(--z4); }
.pace-range { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.pace-range input { width: 5.2rem; margin: 0; padding: 10px; text-align: center; font-family: var(--figures); font-size: 1.15rem; font-weight: 800; background: var(--card); }
.builder-block .sheet-note { margin: 0; font-size: .8rem; color: var(--muted); }
#builder-review { width: 100%; }
.builder-meta { grid-template-columns: minmax(0, 1fr) auto; }
.builder-meta .date-field-text { white-space: nowrap; gap: 10px; }
.builder-kinds { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.builder-kinds .chip { border-radius: 9px; padding: 9px 4px; background: none; color: var(--soft); }
.builder-kinds .chip.active { background: var(--card-press); color: var(--ink); }
.workout-summary { padding: 12px 14px; border-radius: var(--r-tile); background: var(--card-press); }
.workout-summary-title { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; margin: 0 0 8px; }
.workout-summary-title span { color: var(--muted); font-size: .84rem; }
.workout-summary ol { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.workout-summary li { font-size: .92rem; }

/* ---------- Embedded in the StrideSense Android app ---------- */
/* The native app draws its own tab bar below the WebView, so the PWA nav,
   the More menu and the space reserved for them are removed. */
body.embedded { padding-bottom: 16px; }
body.embedded #nav, body.embedded .more-menu, body.embedded nav [data-view="more"] { display: none !important; }
.hero-notes .hero-also { padding-left: 36px; font-size: .84rem; color: var(--soft); }
.hero-share { display: flex; justify-content: flex-end; }
.share-record { display: inline-flex; align-items: center; gap: 6px; }
.share-record .icon { width: 16px; height: 16px; }
.record-panel .panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* Previous bests under a record */
.pr-history { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.record-panel .pr-history { margin: 0 0 8px; padding-top: 0; border-top: 0; }
.pr-history-head { margin: 0 0 4px; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.pr-history ol { margin: 0; padding: 0; list-style: none; }
.pr-prev { display: grid; grid-template-columns: 5.5em minmax(0, 1fr) auto; align-items: baseline; gap: 10px; width: 100%; margin: 0; padding: 8px 0; border-radius: 0; background: none; color: var(--ink); font-weight: 400; text-align: left; }
.pr-prev:disabled { opacity: 1; cursor: default; }
.pr-prev-time { font-family: var(--figures); font-size: 1.25rem; font-weight: 700; }
.pr-prev-date { font-size: .84rem; color: var(--muted); }
.pr-prev-diff { font-family: var(--figures); font-size: 1.05rem; font-weight: 700; color: var(--soft); }
.pr-history-note, .pr-history-empty { margin: 6px 0 0; font-size: .78rem; color: var(--muted); }

/* Share sheet */
.share-send { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-bottom: 16px; }
.share-preview-box { display: grid; place-items: center; width: min(100%, 300px); aspect-ratio: 1080 / 1350; margin: 0 auto; border-radius: var(--r-card); background: var(--card); overflow: hidden; }
.share-preview { display: block; width: 100%; height: 100%; }
.share-wait { margin: 0; font-size: .84rem; color: var(--muted); }
/* In the app, the native tab bar covers the bottom of the screen. */
body.embedded dialog.fullscreen { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.share-send .icon { width: 18px; height: 18px; }
.share-preview[hidden], .share-wait[hidden] { display: none; }

/* Step-list builder */
.builder-steps { display: grid; gap: 10px; }
.builder-repeat { gap: 10px; }
.builder-repeat .builder-repeat { margin-left: 4px; box-shadow: inset 3px 0 0 var(--z4), inset 0 0 0 1px var(--g5); }
.builder-block .choice-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.builder-block .choice-chips .chip { padding: 5px 11px; background: var(--g5); }
.builder-block .choice-chips .chip.active { background: var(--ink); color: var(--g0); }
.builder-block-head { flex-wrap: wrap; }
.node-actions { display: inline-flex; gap: 4px; margin-left: auto; }
.node-actions .icon-button { width: 32px; height: 32px; padding: 0; font-size: .95rem; background: var(--g5); }
.bstep-interval { box-shadow: inset 3px 0 0 var(--z4); }
.bstep-recovery { box-shadow: inset 3px 0 0 var(--z2); }
.bstep-ready { padding: 8px 14px; box-shadow: inset 3px 0 0 var(--info); }
.bstep-ready .builder-block-head > span { color: var(--info); }
.builder-add { display: flex; flex-wrap: wrap; gap: 6px; }
.builder-add .icon { width: 14px; height: 14px; vertical-align: -2px; }
.tl-lap { opacity: .45; }

/* Workout type and suggestion */
.builder-types { display: flex; flex-wrap: wrap; gap: 6px; }
.builder-types .chip { padding: 7px 12px; }
.builder-call { margin: 0; font-size: .9rem; color: var(--soft); }
.builder-call b { color: var(--ink); }
.builder-why { padding: 10px 14px; border-radius: var(--r-tile); background: var(--card-press); }
.builder-why summary { font-weight: 700; cursor: pointer; }
.builder-why ul { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 6px; font-size: .88rem; color: var(--soft); }
.bstep-easyrun { box-shadow: inset 3px 0 0 var(--g6); }

/* "Your day" card */
.ring-score-small { font-size: 30px; }
.day-rows { gap: 0; }
.day-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label figure" "label usual"; column-gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.day-row:last-of-type { border-bottom: 0; }
.day-label { grid-area: label; font-weight: 600; font-size: .92rem; }
.day-label small { display: block; margin-top: 2px; font-size: .78rem; font-weight: 400; color: var(--muted); }
.day-figure { grid-area: figure; text-align: right; font-family: var(--figures); font-size: 1.35rem; line-height: 1.1; }
.day-figure small { font-family: var(--text); font-size: .78rem; color: var(--muted); }
.day-usual { grid-area: usual; text-align: right; font-size: .8rem; color: var(--muted); white-space: nowrap; }
.hero-day .hero-foot { padding-left: 0; }

/* ‹ date › stepper */
.date-stepper { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 6px; align-items: stretch; min-width: 0; }
.date-stepper .date-step { width: 44px; height: 44px; padding: 0; margin: 0; font-size: 1.4rem; line-height: 1; align-self: center; }
.date-stepper .date-field-text { height: 44px; margin: 0; padding: 0 12px; }
.program-range { margin: 4px 0 12px; }
.program-range .date-field-text { background: var(--card); font-family: var(--figures); font-weight: 700; }
.filters > .stepper-field { grid-column: 1 / -1; display: grid; gap: 6px; }
.stepper-label { font-size: .84rem; font-weight: 600; color: var(--soft); }

/* Garmin training-effect label on activities */
.effect-tag { display: inline-block; margin-top: 3px; font-size: .76rem; font-weight: 600; color: var(--soft); }
.r-label .effect-tag { display: block; }

/* History sync card */
.history-card p { margin: 6px 0; }
.history-bar { height: 8px; margin: 10px 0; border-radius: 4px; background: var(--g4); overflow: hidden; }
.history-bar span { display: block; height: 100%; width: 0; border-radius: 4px; background: var(--info); transition: width 400ms; }
.history-card button { width: 100%; margin-top: 8px; }
