/* Workout Coach: design tokens, shell and components. Instrument panel direction.
   Dark is the default. Light follows prefers-color-scheme, and can be forced with
   <html data-theme="light"> or <html data-theme="dark">. System fonts only. */

:root {
  /* Surfaces and text */
  --bg: #0b0e12;
  --surface: #141a21;
  --surface-2: #1e2630;
  --border: #26303b;
  --border-strong: #5a6672;
  --text: #e8ecf0;
  --text-2: #c9d1d9;
  --muted: #8c97a3;
  --curve-ref: #5a6672; /* power curve reference series */

  /* Signal colours: data, target (primary action), coach */
  --data: #5fd4f4;
  --target: #d8ff5e;
  --fatigue: #f5c84b;
  --coach: #a99bea;
  --coach-bg: #17141f;
  --accent: var(--target);
  --on-target: #0b0e12;

  /* Semantic */
  --ok: #6fdb9a;
  --warn: #f5c84b;
  --warn-bg: #2a2410;
  --error: #ff7a72;
  --error-bg: #2e1514;

  /* Sport (categorical) and Focus/zones (one ordinal ramp) */
  --run: #db6a2d;
  --ride: #6b8cf0;
  --pump: #d95f9a;
  --zone-1: #2b6b7c; --zone-2: #3a8499; --zone-3: #4c9fb7; --zone-4: #66b9d0; --zone-5: #8acfe3; --zone-6: #b8e6f3; --zone-7: #e8f8fc;
  --focus: var(--zone-3);

  --r-tag: 4px; --r-ctl: 6px; --r-card: 6px; --r-sheet: 12px;
  --tap: 2.75rem;
  --motion: 120ms ease-out;
  --s1: 0.25rem; --s2: 0.5rem; --s3: 0.75rem; --s4: 1rem; --s5: 1.5rem; --s6: 2rem;
  --header-h: 3.25rem;
  --nav-w: 14rem;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
  font-family: var(--font);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) { color-scheme: light; --bg: #f2f4f7; --surface: #ffffff; --surface-2: #e6eaef; --border: #cbd2da; --border-strong: #7a8591; --text: #14181d; --text-2: #3a424b; --muted: #4f5964; --curve-ref: #7a8591; --data: #0b6e8a; --target: #1d5fa8; --fatigue: #8a5a00; --coach: #5a3fb5; --coach-bg: #f0ecfa; --on-target: #ffffff; --ok: #14633a; --warn: #8a5a00; --warn-bg: #fff4d6; --error: #b3261e; --error-bg: #fbe4e2; --run: #a8420c; --ride: #2f4fb8; --pump: #a8245f; --zone-1: #6fbbd3; --zone-2: #4ca3c0; --zone-3: #2f8aaa; --zone-4: #1a7394; --zone-5: #0e5c7a; --zone-6: #084663; --zone-7: #032e42; --focus: var(--zone-4); }
}
:root[data-theme="light"] { color-scheme: light; --bg: #f2f4f7; --surface: #ffffff; --surface-2: #e6eaef; --border: #cbd2da; --border-strong: #7a8591; --text: #14181d; --text-2: #3a424b; --muted: #4f5964; --curve-ref: #7a8591; --data: #0b6e8a; --target: #1d5fa8; --fatigue: #8a5a00; --coach: #5a3fb5; --coach-bg: #f0ecfa; --on-target: #ffffff; --ok: #14633a; --warn: #8a5a00; --warn-bg: #fff4d6; --error: #b3261e; --error-bg: #fbe4e2; --run: #a8420c; --ride: #2f4fb8; --pump: #a8245f; --zone-1: #6fbbd3; --zone-2: #4ca3c0; --zone-3: #2f8aaa; --zone-4: #1a7394; --zone-5: #0e5c7a; --zone-6: #084663; --zone-7: #032e42; --focus: var(--zone-4); }

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

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  padding-bottom: calc(3.5rem + env(safe-area-inset-bottom));
}

a { color: var(--data); }
:focus-visible { outline: 2px solid var(--target); outline-offset: 2px; }
h1 { font-size: 1.5rem; margin: 0 0 0.75rem; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.label { font: 0.6875rem/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

/* Shell: slim top bar, tab bar at the bottom on phones, side nav from 64rem. */
.app-header {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 1rem;
  min-height: var(--header-h);
  padding: 0 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.app-header a { color: inherit; text-decoration: none; }
.app-header .brand { font: 700 0.8125rem var(--mono); letter-spacing: 0.12em; text-transform: uppercase; }
.app-header .account { margin-left: auto; display: flex; align-items: center; gap: 1rem; font-size: 0.875rem; }
.app-header form { margin: 0; }

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 5;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--bg); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  font: 0.6875rem var(--mono); letter-spacing: 0.08em; text-transform: uppercase; text-align: center;
}
.tabbar .tab { position: relative; display: flex; flex-direction: column; gap: 2px; align-items: center; justify-content: center; min-height: 3.5rem; color: var(--muted); text-decoration: none; }
.tabbar a.active { color: var(--target); }
.nav-icon { flex: none; }
.nav-leaves { display: none; }
.badge { position: absolute; top: 0.35rem; left: calc(50% + 4px); min-width: 1.125rem; height: 1.125rem; padding: 0 4px; border-radius: 999px; background: var(--coach); color: var(--bg); font: 700 0.6875rem/1.125rem var(--mono); letter-spacing: 0; text-align: center; }

.app-main { max-width: 48rem; margin: 0 auto; padding: 1.25rem 1rem; }

@media (min-width: 64rem) {
  body { padding-bottom: 0; padding-left: var(--nav-w); }
  .tabbar { inset: var(--header-h) auto 0 0; width: var(--nav-w); grid-template-columns: 1fr; align-content: start; border-top: 0; border-right: 1px solid var(--border); padding: 1rem 0.75rem; text-align: left; }
  .tabbar .tab { flex-direction: row; gap: 0.75rem; justify-content: flex-start; min-height: var(--tap); padding: 0 0.75rem; border-radius: var(--r-ctl); }
  .tabbar .tab.active { background: var(--surface); }
  .badge { position: static; margin-left: auto; }
  .nav-leaves { display: grid; list-style: none; margin: 0.25rem 0 0.5rem; padding: 0 0 0 2.5rem; text-transform: none; letter-spacing: 0; font: 0.875rem var(--font); }
  .nav-leaves a { display: flex; align-items: center; min-height: 2.25rem; color: var(--muted); text-decoration: none; }
  .nav-leaves a.active { color: var(--target); font-weight: 600; }
  .sub-nav { display: none; }
  .app-header { margin-left: calc(var(--nav-w) * -1); padding-left: calc(var(--nav-w) + 1rem); }
}

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 0.875rem 1rem; }
.card dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; margin: 0; }
.card dt { color: var(--muted); }
.card dd { margin: 0; }

.muted { color: var(--muted); }
.error { color: var(--error); }

#blazor-error-ui {
  display: none; position: fixed; inset: auto 0 0 0; z-index: 10;
  padding: 0.75rem 1rem; background: var(--warn-bg); color: var(--warn);
  box-shadow: 0 -1px 2px rgb(0 0 0 / 0.3);
}
#blazor-error-ui .dismiss { cursor: pointer; float: right; }

/* Coach-authored content: dashed violet, always labelled. A proposal is visibly not a decision. */
.coach { background: var(--coach-bg); border: 1px dashed var(--coach); border-radius: var(--r-card); padding: 0.75rem 1rem; }
.coach > .label { display: block; color: var(--coach); margin-bottom: 0.25rem; }

/* Chips: text always, colour is secondary. */
.chip { display: inline-block; padding: 3px 8px; border: 1px solid currentColor; border-radius: var(--r-tag); font: 700 0.6875rem var(--mono); letter-spacing: 0.08em; text-transform: uppercase; }
.chip--run { color: var(--run); } .chip--ride { color: var(--ride); } .chip--pump { color: var(--pump); } .chip--focus { color: var(--focus); }
.chip--proposed { color: var(--coach); border-style: dashed; }
.chip--accepted { color: var(--ok); }
.chip--declined { color: var(--muted); }
.chip--expired { color: var(--muted); border-style: dashed; }
/* Low confidence (Stress or Focus estimated without power or HR): quieter and dotted; the words still say it. */
.chip--low { color: var(--muted); border-style: dotted; text-transform: none; letter-spacing: 0; font-family: inherit; font-weight: 400; }

/* Metric tile and skeleton */
.tile { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: var(--s2) var(--s3); }
.tile__value { font: 1.5rem var(--mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
/* Tiles always sit in a row: an equal grid (--cols, default 3), stretched to one height, with no outside margins, so
   flow rules such as .card + .card can never shift one tile against another. Use the StatTile component. */
.tile-row { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); gap: var(--s2); align-items: stretch; margin: 0; }
.tile-row > * { margin: 0; }
.skeleton { background: var(--surface-2); border-radius: 3px; min-height: 0.75rem; }

.notice { padding: 0.75rem; border-radius: var(--r-ctl); font-size: 0.875rem; }
.notice--warn { background: var(--warn-bg); color: var(--warn); }
.notice--error { background: var(--error-bg); color: var(--error); }
.notice--ok { background: var(--surface-2); color: var(--ok); }
.notice p { margin: var(--s2) 0; }

/* Connections: one card a provider; the buttons wrap on a narrow screen */
.connection { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s3); margin: var(--s4) 0; }
.connection input[type="file"] { max-width: 100%; }
.connection h2, .connection p { margin: 0; }
.connection .actions { display: flex; flex-wrap: wrap; gap: var(--s2); }

/* Forms and buttons */
.form { display: grid; gap: 0.5rem; max-width: 24rem; }
.form label { font-weight: 600; }
.form label.checkbox { font-weight: normal; display: flex; gap: 0.5rem; align-items: center; }
input, select, textarea { background: var(--bg); color: var(--text); font: inherit; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="time"], input:not([type]) {
  min-height: var(--tap); padding: 0 0.75rem;
  border: 1px solid var(--border-strong); border-radius: var(--r-ctl);
}
select { min-height: var(--tap); padding: 0 0.5rem; border: 1px solid var(--border-strong); border-radius: var(--r-ctl); }

button { font: inherit; cursor: pointer; min-height: var(--tap); padding: 0 1rem; border-radius: var(--r-ctl); border: 1px solid var(--border-strong); background: transparent; color: var(--text); transition: opacity var(--motion); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: var(--target); color: var(--on-target); border-color: transparent; font-weight: 700; }
button.danger { background: transparent; color: var(--error); border-color: var(--error); }
button.link { background: none; border: none; padding: 0; min-height: 0; color: inherit; text-decoration: underline; }

.status { padding: 0.5rem 0.75rem; border-radius: var(--r-ctl); }
.status.success { background: var(--surface-2); color: var(--ok); }
.status.error { background: var(--error-bg); color: var(--error); }
.validation-message, .validation-errors { color: var(--error); }

/* More: links to the pages that are not tabs. */
.more-list { list-style: none; margin: 1rem 0; padding: 0; display: grid; gap: 0.5rem; }
.more-list a { display: flex; justify-content: space-between; align-items: center; min-height: 3.25rem; padding: 0 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); color: var(--text); text-decoration: none; }
.more-list a::after { content: "›"; color: var(--muted); }

/* Account management */
.manage { display: grid; grid-template-columns: 10rem 1fr; gap: 1.5rem; }
.manage-nav { display: flex; flex-direction: column; gap: 0.5rem; }
.manage-nav a.active { font-weight: 700; color: var(--accent); }
table.card { width: 100%; border-collapse: collapse; }
table.card td { padding: 0.5rem; border-bottom: 1px solid var(--border); }

/* History */
.filters { display: flex; flex-wrap: wrap; gap: 1rem; align-items: end; margin-bottom: 1rem; }
.filters label { display: grid; gap: 0.25rem; font-weight: 600; }
.filters select, .filters input { padding: 0.4rem 0.6rem; border: 1px solid var(--border-strong); border-radius: var(--r-ctl); font: inherit; }
.dev-tools { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-bottom: 1rem; }
table.activities th { text-align: left; padding: 0.5rem; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); }
table.activities td { white-space: nowrap; }
.app-main:has(table.activities) { max-width: 64rem; }
/* The coach's note under an Activity: wraps, and stays in view when the table scrolls sideways on a phone. */
table.activities tr.feedback-row td { white-space: normal; padding-top: 0; }
.feedback-note { position: sticky; left: 0; max-width: 36rem; display: flex; flex-direction: column; gap: var(--s1); }

/* Trend: fitness and fatigue, form. Series colours are the design tokens (--data, --fatigue), validated in both themes. */
.trend-chart, .trend-tiles { --fitness: var(--data); --form: var(--text); --stress-bar: var(--surface-2); }
.trend-tiles .tile-day { margin: var(--s2) 0 0; }
.trend-chart { margin: 0 0 1rem; padding: 0.75rem; }
.trend-chart figcaption { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; font-weight: 600; margin-bottom: 0.25rem; }
.trend-chart figcaption .muted { font-weight: 400; }
.trend-chart .legend { display: flex; gap: 1rem; font-weight: 400; color: var(--muted); }
.trend-chart .swatch { display: inline-block; width: 0.9rem; height: 0.2rem; border-radius: 1px; margin-right: 0.35rem; vertical-align: middle; }
.trend-chart .swatch.fitness { background: var(--fitness); }
.trend-chart .swatch.fatigue { background: var(--fatigue); }
.trend-chart .swatch.stress { background: var(--stress-bar); height: 0.6rem; }
.trend-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.trend-chart .grid { stroke: var(--border); stroke-width: 1; }
.trend-chart .zero { stroke: var(--muted); stroke-width: 1; }
.trend-chart .axis, .trend-chart .end-label { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.trend-chart .end-label { fill: var(--text); }
.trend-chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend-chart .line.fitness { stroke: var(--fitness); }
.trend-chart .line.fatigue { stroke: var(--fatigue); }
.trend-chart .line.form { stroke: var(--form); }
.trend-chart .stress-bar { fill: var(--stress-bar); }
.trend-chart .crosshair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.trend-chart .hit { fill: transparent; }
.app-main:has(.trend-chart) { max-width: 64rem; }

/* Weight: weighings as dots with a surface ring, the trend as a line (reuses the Trend chart styles). */
.trend-chart { --weighing: var(--muted); }
.trend-chart .weighing { fill: var(--weighing); stroke: var(--surface); stroke-width: 2; }
.trend-chart .swatch.weighing { background: var(--weighing); width: 0.6rem; height: 0.6rem; border-radius: 50%; }
.app-main:has(.trend-chart) table.activities { margin-top: 1rem; }

/* Workout: the profile as filled steps, then the steps in words. Reads on a phone: one column, large text. */
.workout-chart { --step: var(--data); margin: 0 0 1rem; padding: 0.75rem; }
.workout-chart figcaption { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; font-weight: 600; margin-bottom: 0.25rem; }
.workout-chart figcaption .muted { font-weight: 400; }
.workout-chart svg { display: block; width: 100%; height: auto; }
.workout-chart .step { fill: var(--step); fill-opacity: 0.85; stroke: var(--surface); stroke-width: 1; }
.workout-chart .threshold { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; }
.workout-chart .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.workout-steps { padding: 0.75rem 0.75rem 0.75rem 2.25rem; font-size: 1.1rem; line-height: 1.6; }
.workout-steps li + li { margin-top: 0.4rem; }

/* Activity: the facts, time in power zones as bars, and the power and heart-rate distributions. */
.activity-facts { margin: 0 0 1rem; }
.zone-bars { margin: 0 0 1rem; }
.zone-bars h2, .distribution figcaption { font-size: 1rem; font-weight: 600; margin: 0 0 0.5rem; }
.zone-row { display: grid; grid-template-columns: minmax(8rem, 12rem) 1fr 5rem; align-items: center; gap: 0.5rem; padding: 0.15rem 0; }
.zone-track { background: var(--surface-2); border-radius: 3px; height: 0.9rem; overflow: hidden; }
.zone-fill { display: block; height: 100%; }
.zone-time { text-align: right; font-variant-numeric: tabular-nums; }
.zone-1 { background: var(--zone-1); } .zone-2 { background: var(--zone-2); } .zone-3 { background: var(--zone-3); } .zone-4 { background: var(--zone-4); }
.zone-5 { background: var(--zone-5); } .zone-6 { background: var(--zone-6); } .zone-7 { background: var(--zone-7); }
.distribution { margin: 0 0 1rem; padding: 0.75rem; }
.distribution svg { display: block; width: 100%; height: auto; }
.distribution .bar { fill: var(--data); fill-opacity: 0.85; }
.distribution .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
@media (max-width: 40rem) { .zone-row { grid-template-columns: 1fr 4rem; } .zone-name { grid-column: 1 / -1; } .zone-track { grid-column: 1; } }

/* Library: one card per Workout, the name a link. */
.library { list-style: none; margin: 1rem 0; padding: 0; display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); }
.library li { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.75rem; }
.library a { font-weight: 600; font-size: 1.05rem; }

/* Importing a .zwo on the library page. */
.import { margin: 1rem 0; padding: 0.75rem; }
.import summary { cursor: pointer; font-weight: 600; }
.import label { display: block; margin: 0.5rem 0; }

/* Plan: the active Plan, the form to start another, and the history. */
.plan-active { padding: 0.75rem 1rem; margin: 1rem 0; }
.plan-active h2 { margin-top: 0; }
.plan-form { display: grid; gap: 0.75rem; max-width: 28rem; }
.plan-form label { display: flex; flex-direction: column; gap: 0.25rem; }
.plan-form label.inline { flex-direction: row; align-items: center; gap: 0.5rem; }
.plan-history { list-style: none; padding: 0; display: grid; gap: 0.5rem; }
.plan-history li { display: flex; flex-direction: column; padding: 0.5rem 0.75rem; }

/* Schedule: availability, class types, class slots, what is coming up. */
.schedule-form { display: grid; gap: 0.75rem; max-width: 28rem; margin: 0.75rem 0 1.5rem; }
.schedule-form label { display: flex; flex-direction: column; gap: 0.25rem; }
.schedule-form label.inline { flex-direction: row; align-items: center; gap: 0.5rem; }
.schedule-form fieldset { border: 1px solid var(--border); border-radius: 0.5rem; display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; }
.schedule-list { list-style: none; padding: 0; margin: 0.5rem 0 1rem; display: grid; gap: 0.5rem; }
.schedule-list li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem; }
.schedule-list .actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.week-tabs { display: flex; gap: 0.5rem; margin: 0.75rem 0; }
.week-tabs .tab { padding: 0.4rem 0.9rem; border: 1px solid var(--border); border-radius: var(--r-ctl); background: transparent; cursor: pointer; }
.week-tabs .tab.active { font-weight: 600; border-color: var(--muted); }
.week-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0.75rem; margin: 1rem 0; }
.week-day { padding: 0.5rem 0.75rem; margin: 0; }
.week-day h2 { font-size: 1rem; margin: 0 0 0.25rem; }
.week-day p { margin: 0; }
.planned { display: flex; flex-direction: column; gap: 0.1rem; padding: 0.25rem 0 0.25rem 0.5rem; border-left: 3px solid var(--border); margin-top: 0.4rem; }
.app-main:has(.week-grid) { max-width: 64rem; }
.planned .choices { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.planned .choices button { padding: 0.2rem 0.5rem; font-size: 0.85rem; }
.planned.status-completed { border-left-color: var(--ok); }
.planned.status-replaced { border-left-color: var(--data); }
.planned.status-needsreview { border-left-color: var(--warn); }
.planned.status-missed, .planned.status-skipped { border-left-color: var(--muted); opacity: 0.8; }
.adaptation { padding: 0.75rem 1rem; margin: 1rem 0; }
.adaptation h2 { margin-top: 0; }
.adaptation-compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; }
.adaptation-compare h3 { margin: 0.25rem 0; font-size: 0.95rem; color: var(--muted); }
.adaptation-compare p { margin: 0.2rem 0; }
.inbox-list { list-style: none; padding: 0; display: grid; gap: 0.5rem; }
.inbox-list li { display: flex; flex-direction: column; gap: 0.2rem; padding: 0.5rem 0.75rem; }
.inbox-list li.inbox-unread { border-left: 4px solid var(--muted); }

/* Spacing: one scale (--s1..--s6) and a vertical rhythm. Later rules here win over page rules above. */
h1 { margin: 0 0 var(--s4); }
h2 { font-size: 1.125rem; margin: var(--s5) 0 var(--s2); }
h3 { font-size: 1rem; margin: var(--s4) 0 var(--s2); }
p { margin: 0 0 var(--s3); }
ul, ol { margin: 0 0 var(--s4); }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.app-main > :last-child { margin-bottom: 0; }
.card + .card, .card + h2 { margin-top: var(--s4); }
.card + h2 { margin-top: var(--s5); }

/* Forms: a label stays close to its field, groups are spaced apart.
   .form can hold fields directly (Manage pages) or inside an EditForm (Login). */
.form, .form form { display: grid; gap: var(--s1); }
.form label { margin-top: var(--s3); }
.form label:first-child { margin-top: 0; }
.form input:not([type="checkbox"]):not([type="hidden"]) { width: 100%; }
.form label.checkbox { min-height: var(--tap); margin-top: var(--s2); }
.form button { margin-top: var(--s4); }
.form button.link { margin-top: var(--s2); min-height: var(--tap); justify-self: start; }
.form .validation-message, .form .error { font-size: 0.875rem; }
.app-main > .card.form { margin: var(--s5) auto 0; padding: var(--s5); }
.status { margin-bottom: var(--s3); }

.plan-form, .schedule-form { gap: var(--s4); }
.plan-form label, .schedule-form label { gap: var(--s1); }
.plan-form label.inline, .schedule-form label.inline { min-height: var(--tap); }
.plan-form button, .schedule-form button { justify-self: start; }
.schedule-form fieldset { padding: var(--s3) var(--s4); }
.filters { gap: var(--s3) var(--s4); margin-bottom: var(--s5); }

/* Button rows: a paragraph that holds buttons lays them out with a gap. */
p:has(> button), .actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }

/* Cards and list rows */
.plan-active, .adaptation, .import { padding: var(--s4); margin: var(--s4) 0; }
.adaptation-compare { gap: var(--s5); margin-bottom: var(--s4); }
.week-day { padding: var(--s3); }
.planned { padding: var(--s2) 0 var(--s2) var(--s3); margin-top: var(--s3); gap: var(--s1); }
.inbox-list, .plan-history, .schedule-list { gap: var(--s3); }
.inbox-list li, .plan-history li, .schedule-list li { padding: var(--s3) var(--s4); gap: var(--s1); }
.library { gap: var(--s4); }
.library li { padding: var(--s4); gap: var(--s2); }
.import summary { display: flex; align-items: center; min-height: var(--tap); }
.week-tabs { gap: var(--s2); margin: var(--s3) 0 var(--s4); }
.week-tabs .tab { min-height: var(--tap); }
.trend-tiles { margin: var(--s4) 0 var(--s5); }
.trend-chart, .workout-chart { padding: var(--s4); margin-bottom: var(--s5); }

/* Tables */
table.activities th, table.card th { padding: var(--s3) var(--s2); }
table.activities td, table.card td { padding: var(--s3) var(--s2); }

/* Account management: stack on phones. */
.manage { gap: var(--s5); }
.manage-nav a { display: inline-block; padding: var(--s2) 0; }
@media (max-width: 40rem) {
  .manage { grid-template-columns: 1fr; gap: var(--s4); }
  .manage-nav { flex-direction: row; flex-wrap: wrap; gap: var(--s1) var(--s4); }
}

/* Coach chat: bubbles, a send box, 44 px touch targets. */
.chat-log { list-style: none; padding: 0; margin: var(--s4) 0; display: grid; gap: var(--s3); }
.chat-bubble { display: flex; flex-direction: column; gap: var(--s1); max-width: 85%; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-athlete { justify-self: end; background: var(--surface-2); }
.chat-coach { justify-self: start; background: var(--coach-bg); border-color: var(--coach); }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: var(--s2); align-items: end; }
.chat-form textarea { min-height: var(--tap); padding: var(--s2) var(--s3); border: 1px solid var(--border-strong); border-radius: var(--r-ctl); resize: vertical; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Segmented: sub-pages of a tab on phones, and the Coach filter. */
.segmented { display: flex; gap: 2px; padding: 2px; margin: 0 0 var(--s4); background: var(--surface-2); border-radius: var(--r-ctl); overflow-x: auto; }
.segmented a { flex: 1 0 auto; display: flex; align-items: center; justify-content: center; min-height: var(--tap); padding: 0 var(--s3); border-radius: var(--r-ctl); color: var(--text-2); text-decoration: none; font-size: 0.875rem; white-space: nowrap; }
.segmented a.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 0 0 1px var(--border-strong); }

/* Coach stream: proposals and notes, newest first. */
.stream { list-style: none; padding: 0; margin: var(--s4) 0; display: grid; gap: var(--s3); }
.stream h2 { margin: var(--s1) 0; font-size: 1.05rem; }
.stream-decided { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); padding: var(--s2) var(--s4); }
.unread-dot { display: inline-block; width: 0.5rem; height: 0.5rem; margin-right: var(--s1); border-radius: 50%; background: var(--coach); }
.coach .new { color: var(--coach); margin-right: var(--s2); }

/* A hard session is labelled, not coloured: red is for errors. */
.chip--hard { color: var(--fatigue); align-self: flex-start; }
/* ===== P10.4 Today, P10.5 Best efforts, Welcome restyle (keep this block together) ===== */
a.button { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 1rem; border-radius: var(--r-ctl); border: 1px solid var(--border-strong); color: var(--text); text-decoration: none; }
a.button.primary { background: var(--target); color: var(--on-target); border-color: transparent; font-weight: 700; }

.app-main:has(> .today) { max-width: 72rem; }
.today { display: grid; gap: var(--s4); }
.today-col { display: flex; flex-direction: column; gap: var(--s4); min-width: 0; }
.today-col > .card + .card { margin-top: 0; }
.today-card h2 { font-size: 1.125rem; margin: var(--s2) 0; }
.today-card .label { display: block; }
.today-skeleton { width: 100%; }
.today-card .notice--error { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
@media (min-width: 64rem) { .today { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }

.today-session + .today-session { margin-top: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--border); }
.today-session-card:has(.today-session--rest) { border-style: dashed; }
.today-session--muted { color: var(--muted); }
.today-session--muted h2 { color: var(--text-2); }
.today-compare { display: grid; grid-template-columns: max-content 1fr; gap: var(--s1) var(--s4); margin: var(--s3) 0; }
.today-compare dt { color: var(--muted); }
.today-compare dd { margin: 0; }
.today-session .coach { margin-top: var(--s3); }

.today-needs { list-style: none; margin: var(--s2) 0 0; padding: 0; }
.today-needs li { min-height: var(--tap); display: flex; align-items: center; border-top: 1px solid var(--border); }
.today-needs li:first-child { border-top: 0; }

.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.coach.today-card button.link { margin-right: var(--s3); }

.today-card-head { text-decoration: none; }
.today-card .tile-row { margin-top: var(--s2); }
.sparkline { width: 100%; height: 2rem; overflow: visible; }
.sparkline polyline { fill: none; stroke: var(--data); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.sparkline circle { fill: var(--data); stroke: var(--surface); stroke-width: 2; }
.today-reading { margin: var(--s3) 0 0; color: var(--text-2); }

.today-week-link { display: flex; justify-content: space-between; align-items: baseline; color: inherit; text-decoration: none; }
.week-strip { list-style: none; margin: var(--s3) 0 0; padding: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--s1); text-align: center; }
.week-strip__day { display: flex; flex-direction: column; align-items: center; gap: var(--s1); padding: var(--s2) 0; border-radius: var(--r-ctl); }
.week-strip__day.is-today { background: var(--surface-2); }
.week-strip__mark { width: 0.75rem; height: 0.75rem; border-radius: 50%; border: 2px solid var(--border-strong); }
.week-strip__day--done .week-strip__mark { background: var(--ok); border-color: var(--ok); }
.week-strip__day--partly .week-strip__mark { background: linear-gradient(90deg, var(--ok) 50%, transparent 50%); border-color: var(--ok); }
.week-strip__day--missed .week-strip__mark { border-style: dashed; border-color: var(--muted); }
.week-strip__day--rest .week-strip__mark { border-color: var(--border); }
.week-strip__text { font-size: 0.6875rem; color: var(--muted); }
@media (max-width: 40rem) { .week-strip__text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); } }

.today-sheet { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.today-sheet label { flex-basis: 100%; }
.today-sheet input { min-height: var(--tap); width: 7rem; }

/* Segmented: buttons (or read-only steps) side by side in one frame. */
/* Bordered variant for toggles and step headers; navigation uses the plain base. Drop one when the design picks. */
.segmented.segmented--toggle { display: inline-flex; list-style: none; margin: 0 0 var(--s4); padding: 2px; gap: 2px; border: 1px solid var(--border-strong); border-radius: var(--r-ctl); }
.segmented > button, .segmented > li > a { min-height: calc(var(--tap) - 6px); border: 0; border-radius: calc(var(--r-ctl) - 2px); padding: 0 var(--s4); display: flex; align-items: center; color: var(--text-2); text-decoration: none; }
.segmented > button { white-space: nowrap; }
.segmented > button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); font-weight: 700; }
.segmented--steps { counter-reset: step; }
.segmented--steps > li > a::before { counter-increment: step; content: counter(step) ". "; color: var(--muted); white-space: pre; }

.load-bar { width: 100%; height: 0.5rem; accent-color: var(--data); }
.suggestion-card { margin: var(--s3) 0; }
.suggestion-card .tile__value { font-size: 2rem; }
.suggestion-card__head { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }

.power-curve { margin: 0 0 var(--s5); --recent: var(--data); --longer: var(--curve-ref); }
.power-curve figcaption { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s2); }
.power-curve__legend { font-size: 0.8125rem; color: var(--text-2); display: inline-flex; align-items: center; gap: var(--s2); }
.power-curve .key { display: inline-block; width: 1rem; height: 2px; }
.power-curve .key--recent { background: var(--recent); }
.power-curve .key--longer { background: var(--longer); }
.power-curve svg { width: 100%; height: auto; display: block; }
.power-curve .grid { stroke: var(--border); stroke-width: 1; }
.power-curve .axis { fill: var(--muted); font: 11px var(--mono); }
.power-curve .direct-label { fill: var(--text-2); font: 11px var(--mono); }
.power-curve .curve { fill: none; stroke-width: 2; stroke-linejoin: round; }
.power-curve .curve--recent { stroke: var(--recent); }
.power-curve .curve--longer { stroke: var(--longer); stroke-dasharray: 5 3; }
.power-curve .dot { stroke: var(--surface); stroke-width: 2; }
.power-curve .dot--recent { fill: var(--recent); }
.power-curve .dot--longer { fill: var(--longer); }
.power-curve-skeleton { height: 18rem; margin-bottom: var(--s5); }
table.best-efforts th { text-align: left; }
table.best-efforts th[scope="row"] { font-weight: 400; color: var(--text-2); }
/* ===== end P10.4/P10.5 block ===== */
