/* Run Coach. Calm, quiet surfaces; colour only where it means something: the effort of a run,
   the phase of a plan, how well a run went. System fonts, so nothing to download. */

:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --sunk: #ecebe6;
  --text: #17181a;
  --muted: #5d6066;
  --faint: #8a8d93;
  --border: #e3e2dc;
  --line: #ecebe6;
  --accent: #3b4fd4;
  --accent-soft: #e7eafc;
  --ink: #17181a;
  --ink-text: #ffffff;
  --warn: #9a5b00;
  --warn-soft: #fbf0dc;
  --danger: #b4321f;

  /* Effort colours: easy · long · tempo · speed · race · rest */
  --k-easy: #2f9a6d;
  --k-long: #3a7bd5;
  --k-tempo: #d98a1c;
  --k-speed: #e0533d;
  --k-race: #7a4fd0;
  --k-rest: #a2a5ab;

  /* Plan phases */
  --ph-base: #cfe6d9;
  --ph-build: #cfe0f6;
  --ph-peak: #f7e0b8;
  --ph-taper: #e3d9f5;
  --ph-race: #f6d0c8;
  --ph-ink: #2a2c30;

  --good: #2f9a6d;
  --fair: #d98a1c;
  --poor: #e0533d;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(20 20 30 / .04), 0 8px 24px -16px rgb(20 20 30 / .18);
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Inter, Roboto, system-ui, sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Inter, Roboto, system-ui, sans-serif;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111214; --surface: #1a1b1e; --sunk: #222327; --text: #eceef1; --muted: #a2a6ad; --faint: #7d8189;
    --border: #2a2c31; --line: #24262a; --accent: #8c9bff; --accent-soft: #23284a; --ink: #eceef1; --ink-text: #111214;
    --warn: #f0b860; --warn-soft: #33281a; --danger: #ff8a75;
    --k-easy: #4cc592; --k-long: #6aa3f0; --k-tempo: #f0aa45; --k-speed: #ff7a63; --k-race: #a586f0; --k-rest: #6d7078;
    --ph-base: #1f3a2d; --ph-build: #1f3048; --ph-peak: #45351a; --ph-taper: #33294a; --ph-race: #4a2620; --ph-ink: #e6e8eb;
    --good: #4cc592; --fair: #f0aa45; --poor: #ff7a63;
    --shadow: 0 1px 0 rgb(255 255 255 / .03) inset, 0 10px 30px -18px rgb(0 0 0 / .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111214; --surface: #1a1b1e; --sunk: #222327; --text: #eceef1; --muted: #a2a6ad; --faint: #7d8189;
  --border: #2a2c31; --line: #24262a; --accent: #8c9bff; --accent-soft: #23284a; --ink: #eceef1; --ink-text: #111214;
  --warn: #f0b860; --warn-soft: #33281a; --danger: #ff8a75;
  --k-easy: #4cc592; --k-long: #6aa3f0; --k-tempo: #f0aa45; --k-speed: #ff7a63; --k-race: #a586f0; --k-rest: #6d7078;
  --ph-base: #1f3a2d; --ph-build: #1f3048; --ph-peak: #45351a; --ph-taper: #33294a; --ph-race: #4a2620; --ph-ink: #e6e8eb;
  --good: #4cc592; --fair: #f0aa45; --poor: #ff7a63;
  --shadow: 0 1px 0 rgb(255 255 255 / .03) inset, 0 10px 30px -18px rgb(0 0 0 / .7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px) env(safe-area-inset-left);
}
main, .top { max-width: 640px; margin: 0 auto; padding: 0 16px; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.015em; line-height: 1.15; margin: 0; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 600; }
p { margin: .4rem 0; }
a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.grow { flex: 1; }
[hidden] { display: none !important; }
.kicker { font-size: .75rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 1.25rem 0 .5rem; }
#view > .kicker:first-child { margin-top: .25rem; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- buttons ---------- */

button, .button {
  font: inherit; font-weight: 600; font-size: .95rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: .55rem 1.1rem; min-height: 44px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  transition: background-color .15s, border-color .15s, transform .1s, opacity .15s;
}
button:active, .button:active { transform: scale(.98); }
button:disabled { opacity: .4; cursor: default; transform: none; }
button svg, .button svg { width: 18px; height: 18px; flex: none; }
.primary { background: var(--ink); border-color: var(--ink); color: var(--ink-text); }
.primary:hover:not(:disabled) { opacity: .9; }
.ghost { background: transparent; }
.ghost:hover:not(:disabled) { background: color-mix(in srgb, var(--text) 6%, transparent); }
.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: transparent; }
button.danger.primary, .dialog-actions .danger:not(.ghost) { background: var(--danger); color: #fff; border-color: var(--danger); }
button.small, .button.small { min-height: 36px; padding: .35rem .85rem; font-size: .85rem; }
.icon, button.icon, .button.icon { min-width: 44px; padding: 0; border-color: transparent; background: transparent; color: var(--muted); }
.icon:hover:not(:disabled) { color: var(--text); background: color-mix(in srgb, var(--text) 6%, transparent); }
.icon svg { width: 22px; height: 22px; }
.link { border: 0; background: none; padding: 0; min-height: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; border-radius: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- shell ---------- */

.sample-bar {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; padding: 8px 16px;
  background: var(--ink); color: var(--ink-text); font-size: .82rem; text-align: center;
}
.sample-bar .link { color: inherit; font-weight: 600; }
.sample-actions { display: inline-flex; gap: 16px; }

.top { display: flex; align-items: center; gap: 8px; height: 56px; }
.top #back { margin-left: -12px; }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 700; letter-spacing: -.01em; }
.mark { width: 26px; height: 26px; color: var(--text); }
.mark .dot { fill: var(--k-speed); }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  padding: 6px max(8px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px);
  border-top: 1px solid var(--border);
}
.nav a {
  flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; min-height: 52px; color: var(--faint); text-decoration: none; font-size: .7rem; font-weight: 600; border-radius: 12px;
}
.nav a svg { width: 24px; height: 24px; }
.nav a.on { color: var(--text); }
.nav a.on svg { color: var(--accent); }

.error { margin: 8px 0; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn); font-size: .9rem; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  display: flex; gap: 16px; align-items: center; max-width: min(92vw, 480px);
  padding: 12px 18px; border-radius: 14px; background: var(--ink); color: var(--ink-text);
  font-size: .9rem; box-shadow: 0 12px 30px -10px rgb(0 0 0 / .35); animation: rise .2s ease-out;
}
.toast .link { color: inherit; font-weight: 700; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

.skeleton div { height: 88px; margin: 12px 0; border-radius: var(--radius); background: var(--sunk); animation: pulse 1.2s ease-in-out infinite alternate; }
.skeleton div:first-child { height: 280px; }
@keyframes pulse { to { opacity: .5; } }

/* ---------- cards, chips, pills ---------- */

.card {
  display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin: 12px 0; box-shadow: var(--shadow); text-decoration: none;
}
.card.spread { display: flex; }
.card h2 { margin-bottom: .25rem; }
.card h3 { margin: 1.1rem 0 .1rem; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 999px;
  font-size: .78rem; font-weight: 650; color: var(--c, var(--k-easy)); background: color-mix(in srgb, var(--c, var(--k-easy)) 13%, transparent);
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--k-easy)); }
.k-easy { --c: var(--k-easy); } .k-long { --c: var(--k-long); } .k-tempo { --c: var(--k-tempo); }
.k-speed { --c: var(--k-speed); } .k-race { --c: var(--k-race); } .k-rest { --c: var(--k-rest); }

.pill { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; font-weight: 650; color: var(--muted); }
.pill svg { width: 15px; height: 15px; }
.pill.s-completed, .pill.s-partial { color: var(--good); }
.pill.s-partial { color: var(--fair); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.dot.k-rest { background: transparent; box-shadow: inset 0 0 0 1.5px var(--k-rest); }
.dot.skipped { background: transparent; box-shadow: inset 0 0 0 1.5px var(--c); opacity: .6; }

.notice {
  display: flex; align-items: center; gap: 8px; margin: 8px 0 0; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--text); text-decoration: none; font-size: .9rem;
}
.notice svg { width: 18px; height: 18px; margin-left: auto; flex: none; color: var(--accent); }

.warn { margin: .5rem 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn); font-size: .88rem; }

.empty { text-align: center; padding: 64px 12px; }
.empty h2 { font-size: 1.4rem; margin-bottom: .4rem; }
.empty p { max-width: 34ch; margin: 0 auto 1.2rem; }

/* ---------- today ---------- */

.hero {
  position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--border);
  border-radius: 22px; padding: 20px; margin: 0 0 12px; box-shadow: var(--shadow);
}
.hero::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--c, var(--k-easy)); }
.hero.is-skipped { opacity: .7; }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hero-title { font-size: 2rem; margin: 12px 0 4px; }
.hero-title a { text-decoration: none; }
.hero-meta, .row-meta { display: flex; flex-wrap: wrap; gap: 0 8px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hero-meta { font-size: 1rem; margin: 0 0 12px; }
.hero-meta span + span::before, .row-meta span + span::before { content: "·"; margin-right: 8px; color: var(--faint); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.hero-actions .primary { flex: 1 1 auto; }
.coach-note { margin: 14px 0 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--sunk); color: var(--muted); font-size: .92rem; }
.actual { display: flex; align-items: center; gap: 12px; margin: 4px 0 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--sunk); font-size: .92rem; }
.countdown { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; margin: 20px 4px; font-size: .9rem; font-weight: 600; }
.week-glance { padding: 14px 16px; }
.week-glance .muted { font-variant-numeric: tabular-nums; font-size: .9rem; }

/* Steps: a small timeline of the session. */
.steps { list-style: none; margin: 8px 0 0; padding: 0; }
.step {
  display: grid; grid-template-columns: 5.2rem 1fr auto; gap: 2px 12px; align-items: baseline;
  padding: 10px 0 10px 14px; border-bottom: 1px solid var(--line); position: relative;
}
.step:last-child { border-bottom: 0; }
.step::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--k-rest); opacity: .5; }
.step.st-work::before { background: var(--c, var(--k-speed)); opacity: 1; }
.step-label { font-weight: 650; font-size: .9rem; }
.step-what { font-size: .92rem; }
.step-what small { display: block; color: var(--muted); font-size: .8rem; }
.step-pace { font-variant-numeric: tabular-nums; font-weight: 650; font-size: .92rem; text-align: right; white-space: nowrap; }

.meter { height: 8px; border-radius: 99px; background: var(--sunk); overflow: hidden; margin-top: 10px; position: relative; }
.meter > span { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: var(--accent); }
.meter.stacked > span.planned { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.meter .target { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--text); border-radius: 2px; }
.meter.stacked { overflow: visible; }

/* ---------- lists ---------- */

.row-wrap { display: flex; align-items: center; gap: 4px; }
.row-wrap .row { flex: 1; min-width: 0; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; margin: 8px 0; border-radius: 14px; border: 1px solid var(--border);
  background: var(--surface); text-decoration: none; color: inherit; font-weight: 400; font-size: 1rem; min-height: 0;
}
button.row { border-radius: 14px; justify-content: flex-start; }
a.row:hover, button.row:hover { border-color: color-mix(in srgb, var(--text) 18%, var(--border)); }
.row .bar { width: 4px; align-self: stretch; border-radius: 4px; background: var(--c, var(--k-easy)); flex: none; }
.row.is-skipped { opacity: .55; }
.row.is-skipped .row-title { text-decoration: line-through; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { font-size: .85rem; }
.row-tag { margin-top: 4px; }
.row.is-past, .race-row.is-past { opacity: .6; }

/* ---------- week ---------- */

.week-head { display: flex; align-items: center; gap: 4px; margin: 4px -8px 8px; }
.week-title { flex: 1; text-align: center; }
.week-title h1 { font-size: 1.5rem; }
.week-title p { margin: 2px 0 0; font-size: .88rem; }
.phase-tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: .75rem; font-weight: 650; color: var(--ph-ink); background: var(--sunk); }
.phase-tag.ph-base { background: var(--ph-base); } .phase-tag.ph-build { background: var(--ph-build); } .phase-tag.ph-peak { background: var(--ph-peak); }
.phase-tag.ph-taper { background: var(--ph-taper); } .phase-tag.ph-race { background: var(--ph-race); }
.phase-tag.cut { background: transparent; box-shadow: inset 0 0 0 1px var(--border); color: var(--muted); }
.phase-tag.now { background: var(--accent); color: var(--ink-text); }

.strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 8px 0; }
.day {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 10px; min-height: 0;
  border-radius: 14px; border: 1px solid var(--border); background: var(--surface); font-weight: 400;
}
.day > span:first-child { font-size: .72rem; color: var(--muted); font-weight: 600; }
.day b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.day .dots { display: flex; gap: 3px; height: 8px; }
.day.is-past { opacity: .65; }
.day.is-today { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.volume .meter { height: 10px; }
.volume p:last-child { margin-bottom: 0; }

.day-block { margin: 18px 0 0; scroll-margin-top: 16px; }
.day-block h3 { font-size: .9rem; display: flex; gap: 8px; }
.day-block h3 .muted { font-weight: 500; }
.day-block.is-today h3::after { content: "Today"; font-size: .72rem; font-weight: 700; color: var(--accent); align-self: center; }
.rest-line { margin: 6px 0 0; padding: 10px 14px; border-radius: 14px; border: 1px dashed var(--border); font-size: .9rem; }

/* ---------- plan ---------- */

.plan-head h1 { margin-top: 2px; }
.plan-head p { margin: 2px 0; }
.plan-head .kicker { margin-top: 8px; }
.plan-head .kicker a { color: var(--accent); text-transform: none; letter-spacing: 0; }
.approve { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); background: var(--accent-soft); }
.approve > div:first-child { flex: 1 1 240px; }
.approve-actions { display: flex; gap: 8px; align-items: center; }

.phase-band { display: flex; gap: 3px; margin: 16px 0 8px; border-radius: 10px; overflow: hidden; }
.phase-band span { min-width: 0; padding: 6px 8px; font-size: .75rem; color: var(--ph-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phase-band b { font-weight: 700; }
.ph-base { background: var(--ph-base); } .ph-build { background: var(--ph-build); } .ph-peak { background: var(--ph-peak); }
.ph-taper { background: var(--ph-taper); } .ph-race { background: var(--ph-race); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 4px 0 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.weeks { display: flex; flex-direction: column; gap: 4px; }
.week-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 0; border-radius: 12px;
  text-decoration: none; background: var(--surface); border: 1px solid transparent; position: relative;
}
.week-row:hover { border-color: var(--border); }
.week-row.is-past { opacity: .7; }
.week-row.is-now { border-color: var(--ink); }
.wk-num {
  width: 40px; align-self: stretch; display: grid; place-items: center; flex: none;
  font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ph-ink); border-radius: 12px 0 0 12px; margin: -10px 0;
}
.week-row.ph-base, .week-row.ph-build, .week-row.ph-peak, .week-row.ph-taper, .week-row.ph-race { background: var(--surface); }
.week-row.ph-base .wk-num { background: var(--ph-base); } .week-row.ph-build .wk-num { background: var(--ph-build); }
.week-row.ph-peak .wk-num { background: var(--ph-peak); } .week-row.ph-taper .wk-num { background: var(--ph-taper); }
.week-row.ph-race .wk-num { background: var(--ph-race); }
.wk-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.wk-line { display: flex; gap: 8px; align-items: center; font-size: .85rem; font-weight: 600; }
.wk-bar { position: relative; height: 6px; border-radius: 6px; }
.wk-bar span { position: absolute; inset: 0 auto 0 0; border-radius: 6px; }
.wk-bar .target { background: var(--sunk); }
.wk-bar .ran { background: var(--accent); }
.wk-dots { display: flex; gap: 4px; }
.wk-dots .dot { width: 6px; height: 6px; }
.wk-dist { font-variant-numeric: tabular-nums; font-weight: 650; font-size: .9rem; min-width: 4.2rem; text-align: right; }

/* ---------- workout detail ---------- */

.detail h1 { margin: 12px 0 2px; font-size: 1.9rem; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 16px 0; }
@media (min-width: 480px) { .stats { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); } }
.stats div { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; }
.stats dt { font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
h2.section { margin: 24px 0 4px; display: flex; align-items: baseline; gap: 8px; }
.detail .steps { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 16px 4px 14px; }
.actual-card .spread { justify-content: flex-start; gap: 16px; }
.actual-card .kicker { margin: 0 0 2px; }
.sync-line { margin-top: 12px; }

.reps { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .9rem; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.reps th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.reps td { padding: 8px 12px; border-bottom: 1px solid var(--line); }
.reps tr:last-child td { border-bottom: 0; }
.reps .res { font-size: .8rem; font-weight: 650; }
.reps .r-hit .res { color: var(--good); } .reps .r-beat .res { color: var(--k-long); } .reps .r-missed .res { color: var(--poor); }
.reps .is-outlier { opacity: .55; }
.detail .kicker { margin-top: 14px; }

/* Compliance ring: a conic gradient filled to --v. */
.score {
  --size: 44px; --tone: var(--good);
  width: var(--size); height: var(--size); flex: none; border-radius: 50%; display: inline-grid; place-items: center;
  background: conic-gradient(var(--tone) calc(var(--v) * 1%), var(--sunk) 0);
}
.score span {
  width: calc(var(--size) - 8px); height: calc(var(--size) - 8px); border-radius: 50%; background: var(--surface);
  display: grid; place-items: center; font-weight: 750; font-size: .82rem; font-variant-numeric: tabular-nums;
}
.score.sm { --size: 36px; } .score.sm span { font-size: .72rem; width: calc(var(--size) - 6px); height: calc(var(--size) - 6px); }
.score.lg { --size: 60px; } .score.lg span { font-size: 1.05rem; width: calc(var(--size) - 10px); height: calc(var(--size) - 10px); }
.actual .score span { background: var(--sunk); }
.actual .score { background: conic-gradient(var(--tone) calc(var(--v) * 1%), color-mix(in srgb, var(--text) 10%, transparent) 0); }
.t-good { --tone: var(--good); } .t-fair { --tone: var(--fair); } .t-poor { --tone: var(--poor); }

/* ---------- activities ---------- */

.page-head { margin: 4px 0 8px; }
.page-head .card { margin-top: 12px; }
.act-week h3 { margin: 22px 0 4px; font-size: .85rem; }
.act-week h3 span { font-weight: 500; }
.row.act { align-items: center; }

/* ---------- setup & forms ---------- */

.form h2 { margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 0 0 12px; min-width: 0; }
.field > span { font-size: .8rem; font-weight: 650; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
input, select, textarea {
  font: inherit; font-size: 1rem; color: var(--text); background: var(--bg); width: 100%;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .75rem; min-height: 44px;
}
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--accent); }
fieldset { border: 0; padding: 0; margin: 12px 0 0; min-width: 0; }
.form-actions, .dialog-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 16px; flex-wrap: wrap; }

.seg { display: flex; padding: 3px; gap: 3px; border-radius: 12px; background: var(--sunk); }
.seg label { flex: 1; position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 8px 6px; border-radius: 9px; font-size: .88rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.seg.days span { padding: 8px 0; font-size: .8rem; }

.avail { display: flex; flex-direction: column; gap: 6px; }
.avail-row { display: grid; grid-template-columns: 5.5rem 1fr auto; gap: 12px; align-items: center; }
.toggle { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.mins { display: flex; align-items: center; gap: 6px; }
.mins input { width: 4.75rem; flex: none; min-height: 38px; padding: .35rem .6rem; }
.long { display: flex; align-items: center; gap: 6px; color: var(--muted); }

.prio { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-weight: 750; font-size: .85rem; flex: none; background: var(--sunk); }
.prio.p-a { background: var(--k-race); color: #fff; }
.prio.p-b { background: color-mix(in srgb, var(--k-race) 25%, transparent); color: var(--text); }

.conn { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.conn:first-of-type { border-top: 0; }
.conn p { margin: 0; }
.conn-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--k-rest); }
.conn-dot.on { background: var(--good); }

/* ---------- dialogs ---------- */

dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 48px); overflow: auto;
  border: 1px solid var(--border); border-radius: 22px; padding: 22px 20px 18px; background: var(--surface); color: var(--text);
  box-shadow: 0 30px 80px -20px rgb(0 0 0 / .45);
}
dialog::backdrop { background: rgb(10 10 15 / .45); backdrop-filter: blur(2px); }
dialog h2 { font-size: 1.3rem; margin: 0 40px 6px 0; }
.dlg-close { position: absolute; top: 10px; right: 10px; }
@media (max-width: 560px) {
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 22px 22px 0 0; max-height: 92dvh; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
}

.choices { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.choice {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 12px; cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice:has(input:disabled) { opacity: .55; cursor: default; }
.choice small { font-size: .8rem; text-align: right; }

.wiz-steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 40px 18px 0; counter-reset: s; }
.wiz-steps li { flex: 1; font-size: .72rem; font-weight: 650; color: var(--faint); padding-top: 8px; border-top: 3px solid var(--sunk); }
.wiz-steps li.on { color: var(--text); border-color: var(--accent); }
.wiz-steps li.done { color: var(--muted); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.wizard:has(input[name="raceId"][value="new"]:not(:checked)) .new-race { display: none; }

@media (min-width: 720px) {
  body { padding-bottom: calc(var(--nav-h) + 40px); }
  .hero-title { font-size: 2.3rem; }
  .nav { left: 50%; right: auto; transform: translateX(-50%); bottom: 16px; border: 1px solid var(--border); border-radius: 20px; padding: 6px; width: 520px; box-shadow: var(--shadow); }
  .toast { bottom: calc(var(--nav-h) + 40px); }
}
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ---------- slice 2: sync status, notes, connections ---------- */

.quiet-link { display: inline-flex; align-items: center; gap: 2px; font-size: .82rem; font-weight: 600; color: var(--muted); text-decoration: none; }
.quiet-link svg { width: 14px; height: 14px; }
.quiet-link:hover { color: var(--text); }

.sync-lines { margin: 20px 4px 0; font-size: .8rem; color: var(--muted); }
.sync-lines p { margin: 2px 0; display: flex; align-items: center; gap: 8px; }
.card .sync-lines { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line); }
.sync-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--good); flex: none; }
.sync-dot.busy { background: var(--accent); animation: pulse .8s ease-in-out infinite alternate; }
.sync-issue { color: var(--warn); }
.sync-issue::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); flex: none; }

.note { margin: .4rem 0; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--sunk); color: var(--muted); font-size: .86rem; }
.warn.cap { font-weight: 600; }
.plan-notes { margin-top: 8px; }
.plan-notes .kicker { margin: 12px 0 4px; }

.key-row { display: flex; gap: 8px; align-items: flex-end; margin: 4px 0 0; }
.key-hint { margin: 4px 0 6px; }
.key-row .field { flex: 1; margin: 0; }
.key-row button { flex: none; }
.form-actions.start { justify-content: flex-start; }

.blocked { margin: 10px 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn); font-size: .9rem; }
.blocked p { margin: .3rem 0; }
.blocked ul { margin: .3rem 0; padding-left: 1.1rem; }

.choice-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left;
  padding: 12px 14px; border-radius: 12px; font-weight: 400; min-height: 0;
}
.choice-btn strong { font-weight: 650; }
.choice-btn small { font-size: .82rem; }
.choice-btn:hover { border-color: var(--accent); }
.choice-btn.danger-soft strong { color: var(--danger); }
