/* Tokens. Charts read these too (js/charts.js), so light and dark stay in step. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --text-1: #0b0b0b;
  --text-2: #52514e;
  --text-3: #898781;
  --border: rgba(11, 11, 11, 0.1);
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --danger: #d03b3b;
  --warning-bg: #fff6e0;
  --warning-ink: #6b4a00;
  --tooltip-bg: #ffffff;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-prev: #c3c2b7;
  --series-other: #9ec5f4;
  --zone-1: #86b6ef;
  --zone-2: #719fd8;
  --zone-3: #5c89c1;
  --zone-4: #4874ab;
  --zone-5: #345f95;
  --zone-6: #214a80;
  --zone-7: #0d366b;
  --sport-running: #2a78d6;
  --sport-paddling: #0e9a9f;
  --sport-biking: #d9860b;
  --sport-strength: #8457d6;
  --sport-other: #a3a199;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #262624;
    --text-1: #ffffff;
    --text-2: #c3c2b7;
    --text-3: #898781;
    --border: rgba(255, 255, 255, 0.1);
    --grid: #2c2c2a;
    --baseline: #383835;
    --accent: #3987e5;
    --warning-bg: #3a2e10;
    --warning-ink: #f5d68a;
    --tooltip-bg: #262624;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-prev: #5d5c58;
    --series-other: #184f95;
    --zone-1: #184f95;
    --zone-2: #3867a6;
    --zone-3: #557fb8;
    --zone-4: #7297c9;
    --zone-5: #90b0d9;
    --zone-6: #aec9ea;
    --zone-7: #cde2fb;
  --sport-running: #3987e5;
  --sport-paddling: #19b3b8;
  --sport-biking: #e99a2a;
  --sport-strength: #9b74e8;
  --sport-other: #6f6e69;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #262624;
  --text-1: #ffffff;
  --text-2: #c3c2b7;
  --text-3: #898781;
  --border: rgba(255, 255, 255, 0.1);
  --grid: #2c2c2a;
  --baseline: #383835;
  --accent: #3987e5;
  --warning-bg: #3a2e10;
  --warning-ink: #f5d68a;
  --tooltip-bg: #262624;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-prev: #5d5c58;
  --series-other: #184f95;
  --zone-1: #184f95;
  --zone-2: #3867a6;
  --zone-3: #557fb8;
  --zone-4: #7297c9;
  --zone-5: #90b0d9;
  --zone-6: #aec9ea;
  --zone-7: #cde2fb;
  --sport-running: #3987e5;
  --sport-paddling: #19b3b8;
  --sport-biking: #e99a2a;
  --sport-strength: #9b74e8;
  --sport-other: #6f6e69;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-1);
  font: 16px/1.5 var(--font);
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.05rem; font-weight: 650; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 0.95rem; font-weight: 600; }
a { color: var(--accent); }
code { font-size: 0.9em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }
[hidden] { display: none !important; }

main { max-width: 1180px; margin: 0 auto; padding: 0 16px 48px; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1180px; margin: 0 auto; padding: 14px 16px;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.updated { color: var(--text-3); font-size: 0.8rem; text-align: right; }

/* Buttons */
.btn {
  font: inherit; font-size: 0.9rem; font-weight: 550;
  border-radius: 8px; padding: 8px 14px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-1);
  min-height: 40px;
}
.btn:hover { background: var(--surface-2); }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-quiet { background: transparent; }
.btn-danger { color: var(--danger); background: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Segmented controls */
.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border-radius: 10px;
}
.segmented button {
  font: inherit; font-size: 0.9rem; font-weight: 550; color: var(--text-2);
  border: 0; background: transparent; border-radius: 7px; padding: 7px 14px; cursor: pointer;
  min-height: 36px; white-space: nowrap;
}
.segmented button[aria-checked="true"] {
  background: var(--surface); color: var(--text-1);
  box-shadow: 0 0 0 1px var(--border), 0 1px 2px rgba(0, 0, 0, 0.06);
}
.segmented.small button { font-size: 0.8rem; padding: 4px 10px; min-height: 30px; }
.sport-toggle button { font-size: 1rem; padding: 8px 20px; }

/* Controls */
.controls {
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin: 4px 0 16px;
}
.range { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.custom-range { display: flex; gap: 10px; flex-wrap: wrap; }
.custom-range label { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--text-2); }
input {
  font: inherit; font-size: 0.95rem; color: var(--text-1); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; min-height: 38px;
}

/* Notices */
.notice {
  background: var(--warning-bg); color: var(--warning-ink);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px;
}
.notice button { margin-left: 8px; }

/* Summary */
.summary {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 16px;
}
.summary h2 { color: var(--text-2); font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.summary-text { font-size: 1.2rem; line-height: 1.55; margin: 0; max-width: 70ch; text-wrap: pretty; }
.notes { margin: 12px 0 0; padding-left: 1.1em; color: var(--text-2); font-size: 0.875rem; }
.notes:empty { display: none; }
.notes li + li { margin-top: 4px; }

/* Cards and charts */
.grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) {
  .grid { grid-template-columns: 1fr 1fr; }
}
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 16px 12px; min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; min-height: 34px; }
.chart { position: relative; height: 240px; margin-top: 8px; }
@media (min-width: 900px) { .chart { height: 260px; } }
.empty {
  position: absolute; inset: 0; margin: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 24px; color: var(--text-2); font-size: 0.9rem; background: var(--surface);
}
.footnote { color: var(--text-3); font-size: 0.8rem; margin: 8px 2px 0; }

/* Legends */
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: 0.8rem; color: var(--text-2); }
.legend:empty { display: none; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.swatch.line { height: 3px; width: 14px; border-radius: 2px; }
/* Planned load: the chart's hatched bars, in miniature */
.swatch.hatch {
  background: repeating-linear-gradient(135deg, color-mix(in oklab, var(--series-1) 75%, transparent) 0 1.5px, transparent 1.5px 3.5px);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--series-1) 55%, transparent);
}

/* Info tips: hover on desktop, tap (focus) on touch */
.tip { position: relative; }
.info {
  width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); font: 600 0.75rem/1 var(--font); cursor: help; padding: 0;
}
button.legend-item { font: inherit; color: inherit; background: none; border: 0; padding: 2px 0; cursor: help; text-decoration: underline dotted var(--text-3); text-underline-offset: 3px; }
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus::after {
  content: attr(data-tip);
  position: absolute; z-index: 10; top: calc(100% + 6px); left: 0;
  width: max-content; max-width: min(300px, 80vw);
  background: var(--tooltip-bg); color: var(--text-1); border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  border-radius: 8px; padding: 8px 10px; font: 400 0.8rem/1.4 var(--font); text-align: left;
  text-decoration: none; white-space: normal;
}
.info[data-tip]:hover::after, .info[data-tip]:focus::after { left: auto; right: 0; }

/* Export */
.export {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; margin-top: 24px;
}
.export p { color: var(--text-2); margin: 6px 0 14px; font-size: 0.925rem; }
.export-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.export-buttons .btn { min-height: 48px; font-size: 1rem; }
@media (max-width: 520px) { .export-buttons { grid-template-columns: 1fr; } }
.preview { margin-top: 16px; }
.preview summary { cursor: pointer; color: var(--text-2); font-size: 0.9rem; }
.preview pre {
  background: var(--surface-2); border-radius: 8px; padding: 14px; margin: 10px 0 0;
  max-height: 420px; overflow: auto; font-size: 0.78rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word;
}

/* Onboarding and settings */
.onboarding { max-width: 620px; margin: 24px auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.onboarding .lede { color: var(--text-2); }
.steps { padding-left: 1.2em; }
.steps li + li { margin-top: 6px; }
.creds-form { display: grid; gap: 12px; margin: 16px 0; }
.creds-form label { display: grid; gap: 4px; font-size: 0.875rem; font-weight: 550; color: var(--text-2); }
.privacy, .hint { font-size: 0.875rem; color: var(--text-2); }
.settings { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text-1); padding: 4px 20px; width: min(440px, calc(100vw - 32px)); }
.settings::backdrop { background: rgba(0, 0, 0, 0.4); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spacer { flex: 1; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  background: var(--text-1); color: var(--page); padding: 10px 16px; border-radius: 10px;
  font-size: 0.9rem; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2); max-width: calc(100vw - 32px);
}

/* Phones: everything stacks, summary first */
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  .controls { flex-direction: column; align-items: stretch; }
  .controls .segmented { display: flex; }
  .controls .segmented button { flex: 1; padding-left: 6px; padding-right: 6px; }
  .range { flex-direction: column; align-items: stretch; }
  .summary { padding: 16px; }
  .summary-text { font-size: 1.075rem; }
  .export { padding: 16px; }
}

/* ---------- Visual layer ---------- */

:root {
  --radius: 16px;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 6px 20px rgba(11, 11, 11, 0.05);
  --state-risk: #d03b3b;
  --state-productive: #0ca30c;
  --state-neutral: #898781;
  --state-fresh: #2a78d6;
  --state-transition: #fab219;
}

body {
  background:
    radial-gradient(900px 360px at 15% -120px, color-mix(in oklab, var(--accent) 12%, transparent), transparent 70%),
    var(--page);
  background-repeat: no-repeat;
}

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 30px; height: 30px; flex: none; }
.brand h1 { font-size: 1.1rem; letter-spacing: -0.01em; }
.topbar { padding-top: 18px; padding-bottom: 16px; }

/* Icon buttons */
.btn-icon { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.btn-icon svg { width: 18px; height: 18px; flex: none; }
@media (max-width: 640px) {
  .topbar-actions .btn-icon span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .topbar-actions .btn-icon { padding: 8px 10px; }
}

/* Sport toggle with icons */
.sport-toggle button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.sport-toggle svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.sport-toggle button[aria-checked="true"] { color: var(--accent); }
.sport-toggle button[aria-checked="true"] svg { color: var(--accent); }

/* Cards */
.summary, .card, .export, .onboarding { border-radius: var(--radius); box-shadow: var(--shadow); }
.card { padding: 18px 18px 14px; }
.card h3 { font-size: 1rem; }
.takeaway { margin: 2px 0 0; color: var(--text-2); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.takeaway:empty { display: none; }
.takeaway strong { color: var(--text-1); font-weight: 650; }
.grid { gap: 18px; }

/* Summary */
.summary { padding: 24px 26px; }
.summary-text { font-size: 1.25rem; letter-spacing: -0.005em; }

.tiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px;
  margin-top: 20px;
}
.tile {
  background: var(--surface-2); border-radius: 12px; padding: 12px 14px; min-width: 0;
}
.tile-label { font-size: 0.8rem; color: var(--text-2); }
.tile-value { font-size: 1.6rem; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; margin-top: 2px; white-space: nowrap; }
.tile-value small { font-size: 0.9rem; font-weight: 550; color: var(--text-2); margin-left: 2px; letter-spacing: 0; }
.tile-delta { font-size: 0.8rem; color: var(--text-2); margin-top: 2px; display: flex; align-items: center; gap: 4px; }
.tile-delta .arrow { font-size: 0.7rem; color: var(--text-1); }

/* Form gauge */
.form-gauge { margin-top: 20px; }
.gauge-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.gauge-label { font-size: 0.8rem; color: var(--text-2); }
.gauge-value { font-size: 0.95rem; font-weight: 600; }
.gauge-value .state { font-weight: 500; color: var(--text-2); }
.gauge-track { position: relative; height: 10px; border-radius: 999px; }
.gauge-marker {
  position: absolute; top: 50%; width: 18px; height: 18px; border-radius: 50%;
  background: var(--text-1); border: 3px solid var(--surface);
  transform: translate(-50%, -50%); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.gauge-scale { position: relative; height: 34px; margin-top: 6px; font-size: 0.72rem; color: var(--text-3); }
.gauge-scale span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; text-align: center; line-height: 1.3; }
.gauge-scale .band-name { top: 0; color: var(--text-2); }
.gauge-scale .tick { top: 17px; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .gauge-scale .band-name { display: none; }
  .gauge-scale .tick { top: 0; }
  .gauge-scale { height: 18px; }
}

/* Export */
.export {
  background: color-mix(in oklab, var(--accent) 7%, var(--surface));
  border-color: color-mix(in oklab, var(--accent) 22%, transparent);
  padding: 24px 26px;
}
.export-head { display: flex; gap: 14px; align-items: flex-start; }
.export-head p { margin-top: 4px; }
.export-icon {
  width: 40px; height: 40px; padding: 8px; flex: none; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink);
}
.export-buttons .btn { border-radius: 10px; }
.preview pre { background: var(--surface); border: 1px solid var(--border); }
@media (max-width: 640px) {
  .summary, .export { padding: 18px; }
  .summary-text { font-size: 1.1rem; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .tile:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .tile-value { font-size: 1.35rem; }
}

/* Summary lines: label on the left, sentence on the right; stacked on phones */
.summary-text { font-weight: 550; }
.summary-lines { display: grid; gap: 8px; margin: 14px 0 0; max-width: 72ch; }
.summary-lines div { display: grid; grid-template-columns: 92px 1fr; gap: 12px; align-items: baseline; }
.summary-lines dt {
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3);
}
.summary-lines dd { margin: 0; font-size: 1.02rem; line-height: 1.5; color: var(--text-2); }
.summary-lines strong { color: var(--text-1); font-weight: 650; }
@media (max-width: 640px) {
  .summary-lines { gap: 12px; }
  .summary-lines div { grid-template-columns: 1fr; gap: 2px; }
}

/* Compare switch */
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text-2); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  position: relative; width: 36px; height: 20px; border-radius: 999px; flex: none;
  background: var(--baseline); transition: background 0.15s;
}
.switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform 0.15s;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Line charts are dragged sideways; let the page still scroll vertically */
.chart canvas { touch-action: pan-y; }

/* ---------- Plan ---------- */

.plan {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 24px; margin-top: 24px;
}
.plan-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 20px; }
.plan-intro { flex: 1 1 380px; min-width: 0; }
.plan-lede { margin: 6px 0 0; color: var(--text-2); font-size: 0.925rem; max-width: 72ch; text-wrap: pretty; }
.plan-lede strong { color: var(--text-1); font-weight: 650; }
.plan-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.plan-note { margin: 12px 0 0; color: var(--text-3); font-size: 0.8rem; max-width: 90ch; }
.plan-note:empty { display: none; }

/* The More menu */
.menu { position: relative; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 15; min-width: 190px;
  display: grid; padding: 6px; border-radius: 10px;
  background: var(--tooltip-bg); border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
}
.menu-list button, .menu-list a {
  font: inherit; font-size: 0.9rem; text-align: left; color: var(--text-1); text-decoration: none;
  background: none; border: 0; border-radius: 6px; padding: 9px 10px; cursor: pointer;
}
.menu-list button:hover, .menu-list button:focus-visible, .menu-list a:hover, .menu-list a:focus-visible { background: var(--surface-2); }
.menu-list .danger { color: var(--danger); }

/* Races */
.races-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; }
.races-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); margin-right: 2px; }
.races-none { color: var(--text-2); font-size: 0.875rem; }
.race-pill {
  font: inherit; font-size: 0.85rem; color: var(--text-2); cursor: pointer; text-align: left;
  background: var(--surface-2); border: 0; border-radius: 999px; padding: 6px 12px; min-height: 34px;
}
.race-pill strong { color: var(--text-1); }
.race-pill:hover { background: color-mix(in oklab, var(--accent) 12%, var(--surface-2)); }

/* Weeks: this week and next open, later ones a single line until opened */
.plan-weeks { display: grid; gap: 12px; margin-top: 16px; align-items: start; }
@media (min-width: 900px) { .plan-weeks { grid-template-columns: 1fr 1fr; } }
.plan-week { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; min-width: 0; }
.plan-week.current { border-color: color-mix(in oklab, var(--accent) 40%, transparent); }
.week-head {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center;
  padding: 10px 12px 10px 34px; background: var(--surface-2); cursor: pointer; list-style: none; position: relative;
}
.week-head::-webkit-details-marker { display: none; }
.week-head::before {
  content: ""; position: absolute; left: 14px; top: 16px; width: 7px; height: 7px;
  border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: rotate(-45deg); transition: transform 0.15s;
}
.plan-week[open] > .week-head::before { transform: rotate(45deg); top: 13px; }
.week-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-width: 0; }
.week-title strong { font-size: 0.95rem; }
.week-sub { color: var(--text-2); font-size: 0.8rem; }
.week-totals {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px 8px;
  color: var(--text-2); font-size: 0.82rem; font-variant-numeric: tabular-nums;
}
.week-note { grid-column: 1 / -1; display: block; font-size: 0.82rem; color: var(--warning-ink); }
.tag, .flag {
  display: inline-block; font-size: 0.72rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 7px; border-radius: 999px; line-height: 1.4; color: var(--text-1);
}
.tag.build { background: color-mix(in oklab, var(--state-productive) 18%, transparent); }
.tag.maintain, .tag.phase { background: color-mix(in oklab, var(--state-neutral) 22%, transparent); }
.tag.recover { background: color-mix(in oklab, var(--state-fresh) 18%, transparent); }
.tag.mismatch, .flag { background: var(--warning-bg); color: var(--warning-ink); }
.week-tools {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-top: 1px solid var(--border);
}
.phase-label { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-2); }
select {
  font: inherit; font-size: 0.85rem; color: var(--text-1); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; min-height: 34px;
}
.phase { font-size: 0.8rem; min-height: 30px; padding: 3px 6px; }
.btn-small { min-height: 30px; padding: 3px 9px; font-size: 0.8rem; white-space: nowrap; }

/* Days */
.days { list-style: none; margin: 0; padding: 0; }
.day {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 8px; align-items: center;
  padding: 5px 8px 5px 12px; border-top: 1px solid var(--border); min-height: 44px;
}
.day.today { background: color-mix(in oklab, var(--accent) 6%, transparent); }
.day.today .dow { color: var(--accent); }
.day-label { font-size: 0.82rem; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.day-label .dow { font-weight: 600; color: var(--text-1); }
.day.past .day-label { color: var(--text-3); }
.day.past .day-label .dow { color: var(--text-2); }
.day-items { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.day-actions { display: flex; gap: 6px; justify-self: end; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  font: inherit; font-size: 0.85rem; text-align: left; color: var(--text-1); cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 5px 9px; min-height: 32px;
}
.chip-text { overflow: hidden; text-overflow: ellipsis; }
.chip-icon { display: inline-flex; flex: none; }
.chip-icon svg { width: 16px; height: 16px; fill: currentColor; }
.chip:hover { background: var(--surface-2); }
.chip.key { border-color: color-mix(in oklab, var(--accent) 55%, transparent); background: color-mix(in oklab, var(--accent) 8%, var(--surface)); font-weight: 600; }
.chip.rest { color: var(--text-2); border-style: dashed; }
.chip .tick { color: var(--state-productive); font-weight: 700; }
.chip.missed .chip-text { color: var(--text-2); }
.missed-mark { font-size: 0.72rem; color: var(--text-3); border: 1px solid var(--border); border-radius: 999px; padding: 0 6px; }
.race-badge {
  font: inherit; font-size: 0.8rem; font-weight: 650; cursor: pointer;
  background: var(--text-1); color: var(--page); border: 0; border-radius: 8px; padding: 5px 9px; min-height: 32px;
}
.add-day, .day-btn {
  height: 32px; border-radius: 8px; cursor: pointer;
  font: 500 0.8rem/1 var(--font); color: var(--text-2); background: transparent; border: 1px dashed var(--border);
}
.add-day { width: 32px; font-size: 1.1rem; }
.day-btn { padding: 0 9px; }
.add-day:hover, .day-btn:hover { color: var(--accent); border-color: var(--accent); }
.more-weeks { margin-top: 12px; width: 100%; }

/* Plan dialogs */
.plan-dialog { max-height: calc(100dvh - 24px); overflow: auto; }
.plan-dialog h2 { margin-top: 12px; }
.field { display: grid; gap: 6px; }
.field-label { font-size: 0.875rem; font-weight: 550; color: var(--text-2); }
.field .segmented { display: flex; }
.field .segmented button { flex: 1; }
.interval-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; }
.creds-form label.inline { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.creds-form label.inline input { width: 110px; }
.creds-form label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text-1); }
.creds-form label.check input { min-height: 0; width: 18px; height: 18px; accent-color: var(--accent); }
textarea {
  font: inherit; font-size: 0.95rem; color: var(--text-1); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; resize: vertical;
}
.estimate { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.estimate:empty { display: none; }
.form-error { margin: 0; color: var(--danger); font-size: 0.875rem; }
.plan-dialog .dialog-actions { padding-bottom: 14px; }

@media (max-width: 640px) {
  .plan { padding: 18px 14px; }
  .plan-actions { width: 100%; }
  .plan-actions > .btn { flex: 1; }
  .day { grid-template-columns: 46px 1fr auto; padding-left: 10px; gap: 6px; }
  .day-label { font-size: 0.78rem; }
  .week-head { grid-template-columns: 1fr; }
  .week-totals { justify-content: flex-start; }
}

/* Sport toggle and view switch. On phones the sports show as icons, with the
   selected one's name. */
.controls-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.sport-toggle button { padding: 8px 16px; }
@media (max-width: 640px) {
  .controls-row { flex-direction: column; align-items: stretch; }
  .controls-row .segmented { display: flex; }
  .sport-toggle button { flex: 1 1 auto; padding: 8px 10px; }
  .sport-toggle button .label { display: none; }
  .sport-toggle button[data-sport="all"] .label, .sport-toggle button[aria-checked="true"] .label { display: inline; }
}
.view-toggle button { min-width: 92px; }

/* Undo in the toast */
.toast { display: flex; align-items: center; gap: 14px; }
.toast-undo {
  font: inherit; font-weight: 650; color: inherit; background: none; border: 0; padding: 4px 2px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}

/* Workout dialog */
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.optional { font-weight: 400; color: var(--text-3); }
.settings .field { margin: 4px 0 8px; }
