:root {
  color-scheme: light dark;
  --ink: #0f2a3d;
  --ink-2: #4a6273;
  --ink-3: #7d909d;
  --paper: #eef2f4;
  --card: #ffffff;
  --line: #d3dce2;
  --swim: #11798a;
  --bike: #5a47a8;
  --run: #c04a26;
  --hyrox: #9e2e64;
  --strength: #56606a;
  --race: #0f2a3d;
  --ok: #2f7d4f;
  --warn: #b07015;
  --bad: #b23a3a;
  --p-base: #9fc3d1;
  --p-build: #4f93ad;
  --p-peak: #1f5f7a;
  --p-taper: #e0a94a;
  --p-race: #c04a26;
  --p-recovery: #cdd7dd;
  --p-maintain: #b9cbd4;
  --display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --text: "Barlow", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e4edf2; --ink-2: #a7b9c5; --ink-3: #7a8d99;
    --paper: #0d1820; --card: #14232e; --line: #26394a;
    --swim: #3fb4c5; --bike: #9a88e6; --run: #ef8462; --hyrox: #e070a5; --strength: #a2adb7; --race: #e4edf2;
    --p-base: #2a5566; --p-build: #3e7f99; --p-peak: #7cc2dd; --p-recovery: #24343f; --p-maintain: #2b4250;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--text); }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--bike); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

button, .btn {
  font: 500 14px/1 var(--text); color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 6px; padding: 9px 12px; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .btn:hover { border-color: var(--ink-3); }
button.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); padding: 11px 18px; }
button.ghost, .btn.ghost { background: transparent; }
button.tiny { padding: 4px 8px; font-size: 12px; }
input, select, textarea {
  font: 15px/1.4 var(--text); color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; width: 100%;
}
textarea { font-size: 13px; }
label { display: block; font-size: 13px; color: var(--ink-2); }
label > input, label > select { margin-top: 4px; }

.bib { font-family: var(--display); font-weight: 700; letter-spacing: -0.01em; }

/* top */
.top { display: flex; align-items: center; gap: 24px; padding: 14px clamp(16px, 3vw, 36px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.wordmark { font-size: 28px; text-decoration: none; line-height: 1; }
.top nav { display: flex; gap: 18px; }
.top nav a { text-decoration: none; color: var(--ink-2); font-weight: 500; }
.top nav a[aria-current] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sync { font-size: 13px; color: var(--ink-2); }
.sync.error { color: var(--bad); }

main { padding: 20px clamp(16px, 3vw, 36px) 64px; max-width: 1480px; margin: 0 auto; }
main.narrow { max-width: 760px; }

/* season strip: the memorable element */
.season { margin-bottom: 22px; }
.season-head { display: flex; align-items: flex-end; gap: 28px; flex-wrap: wrap; margin-bottom: 10px; }
.countdown { display: flex; align-items: baseline; gap: 10px; }
.countdown .big { font: 700 clamp(64px, 9vw, 112px)/0.8 var(--display); letter-spacing: -0.03em; }
.countdown span:last-child { font: 600 20px/1 var(--display); color: var(--ink-2); }
.race-name { display: flex; flex-direction: column; }
.race-name strong { font: 600 22px/1.1 var(--display); }
.race-name span { color: var(--ink-2); font-size: 14px; }
.phase-now { margin-left: auto; font: 700 26px/1 var(--display); padding: 6px 12px; border-radius: 4px; background: var(--card); border: 1px solid var(--line); }
.strip { list-style: none; display: flex; gap: 3px; margin: 0; padding: 0; height: 26px; }
.strip li { flex: 1; border-radius: 2px; position: relative; }
.strip li a { position: absolute; inset: 0; }
.strip li.now { outline: 2px solid var(--ink); outline-offset: 2px; }
.strip-legend { display: flex; gap: 14px; margin-top: 8px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.strip-legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; background: var(--c); }
.phase-base { --c: var(--p-base); } .phase-build { --c: var(--p-build); } .phase-peak { --c: var(--p-peak); }
.phase-taper { --c: var(--p-taper); } .phase-race { --c: var(--p-race); } .phase-recovery { --c: var(--p-recovery); }
.phase-maintain { --c: var(--p-maintain); }
.strip li { background: var(--c); }
.phase-now { border-left: 8px solid var(--c); }
.season-empty { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.season-empty p { margin: 0; max-width: 60ch; }

/* readout */
.readout { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.readout > div { padding: 12px 14px; border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.readout > div:first-child { border-left: 0; padding-left: 0; }
.readout .lbl { font-size: 13px; color: var(--ink-2); }
.readout .val { font: 600 26px/1.1 var(--display); }
.readout .sub { font-size: 12px; color: var(--ink-3); }

.adapt { margin-bottom: 18px; }
.adapt p { margin: 0; font-size: 14px; color: var(--ink-2); padding-left: 12px; border-left: 3px solid var(--p-taper); }
.adapt p + p { margin-top: 4px; }

.weekbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.weekbar h2 { font: 600 24px/1 var(--display); margin: 0 6px; }
.weekbar .right { margin-left: auto; }

/* week */
.week { list-style: none; margin: 0 0 32px; padding: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.day { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px; min-height: 200px; display: flex; flex-direction: column; gap: 6px; }
.day.today { border: 2px solid var(--ink); padding: 9px; }
.day.past { opacity: .78; }
.day.rest { background: transparent; border-style: dashed; }
.day-head { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: end; margin-bottom: 4px; }
.day-head .num { font: 700 44px/0.85 var(--display); grid-row: span 2; letter-spacing: -0.02em; }
.day-head .dname { font-size: 13px; color: var(--ink-2); }
.day-head form, .day-head .rest-tag { justify-self: start; }
.rest-tag { font: 600 15px/1 var(--display); color: var(--ink-2); }
.rest-note { font-size: 13px; color: var(--ink-3); margin: 0; }

.sess { border-left: 4px solid var(--c); padding: 6px 8px; background: color-mix(in srgb, var(--c) 9%, transparent); border-radius: 0; }
.sess header { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
.sess .t { font-weight: 600; font-size: 14px; line-height: 1.2; }
.sess .m { font: 600 15px/1 var(--display); white-space: nowrap; }
.sess.adapted .t::after { content: " ↓"; color: var(--warn); }
.sess details { font-size: 13px; color: var(--ink-2); }
.sess summary { cursor: pointer; font-size: 12px; color: var(--ink-3); }
.sess details p { margin: 4px 0; }
.wod { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.wod-text { white-space: pre-wrap; font: 12px/1.4 var(--text); margin: 6px 0 0; color: var(--ink-2); }
.s-swim { --c: var(--swim); } .s-bike { --c: var(--bike); } .s-run { --c: var(--run); }
.s-hyrox { --c: var(--hyrox); } .s-strength { --c: var(--strength); } .s-race { --c: var(--race); } .s-other { --c: var(--ink-3); }

.done { display: grid; grid-template-columns: 1fr auto; gap: 2px 6px; font-size: 13px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; position: relative; }
.done::before { content: "✓"; position: absolute; left: -1px; top: -1px; }
.done .t { font-weight: 600; padding-left: 10px; color: var(--c); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.done .m { color: var(--ink-2); grid-column: 1; padding-left: 10px; }
.done .rpe { grid-column: 2; grid-row: 1 / span 2; align-self: center; }

.rpe { font: 600 13px/1 var(--display); padding: 4px 6px; border-radius: 4px; background: var(--paper); text-decoration: none; white-space: nowrap; }
.rpe.none { color: var(--warn); }
.r1, .r2, .r3 { --rc: var(--ok); } .r4, .r5, .r6 { --rc: var(--swim); } .r7, .r8 { --rc: var(--warn); } .r9, .r10 { --rc: var(--bad); }
.rpe[class*=" r"] { color: var(--rc); }

/* rating */
.rate h2 { font: 600 26px/1.1 var(--display); margin: 0; }
.rate h3 { font: 600 18px/1.2 var(--display); margin: 22px 0 8px; }
.hint { font-size: 13px; color: var(--ink-2); margin: 4px 0 12px; }
.rate ul { list-style: none; margin: 0; padding: 0; }
.rate-row { display: grid; grid-template-columns: minmax(180px, 1.3fr) 130px auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.who { display: flex; flex-direction: column; }
.who span { font-size: 13px; color: var(--ink-2); }
.scale { display: flex; gap: 4px; }
.scale button { width: 38px; justify-content: center; font: 600 16px/1 var(--display); padding: 9px 0; color: var(--rc); }
.scale button:hover { background: var(--rc); color: var(--card); border-color: var(--rc); }
.recent li { display: flex; gap: 10px; font-size: 14px; padding: 4px 0; border-left: 3px solid var(--c); padding-left: 8px; margin-bottom: 4px; }
.recent li span:nth-child(2) { flex: 1; }
.empty { color: var(--ink-2); }

/* settings */
.saved { background: var(--card); border-left: 4px solid var(--ok); padding: 10px 14px; }
.settings fieldset { border: 0; border-top: 1px solid var(--line); padding: 18px 0 8px; margin: 0; }
.settings legend { font: 600 22px/1 var(--display); padding: 0 8px 0 0; }
.settings .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 12px 0 4px; }
.race-types { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 6px; margin-top: 10px; }
.race-opt { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; color: var(--ink); font-size: 15px; cursor: pointer; }
.race-opt input { width: auto; margin: 0; }
.race-opt:has(input:checked) { border-color: var(--ink); box-shadow: inset 4px 0 0 var(--ink); }
.days { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.days .lbl { font-size: 13px; color: var(--ink-2); margin-right: 6px; }
.chip { cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 1px; }
.chip span { display: inline-block; min-width: 44px; text-align: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font: 600 16px/1 var(--display); color: var(--ink); background: var(--card); }
.chip input:checked + span { background: var(--hyrox); color: #fff; border-color: var(--hyrox); }
.chip input:focus-visible + span { outline: 2px solid var(--bike); outline-offset: 2px; }
.settings > button { margin-top: 20px; }

/* login */
main.login { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; margin: 0; max-width: none; }
.login-card { width: min(340px, 90vw); display: flex; flex-direction: column; gap: 10px; }
.login-card h1 { font-size: 64px; margin: 0 0 10px; line-height: .9; }
.err { color: var(--bad); margin: 0; font-size: 14px; }

@media (max-width: 1100px) {
  .week { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .readout { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .readout > div:nth-child(4) { border-left: 0; padding-left: 0; }
}
@media (max-width: 680px) {
  .week { grid-template-columns: 1fr; }
  .day { min-height: 0; }
  .readout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .readout > div { border-left: 0; padding-left: 0; }
  .rate-row { grid-template-columns: 1fr; }
  .scale button { width: auto; flex: 1; }
  .phase-now { margin-left: 0; }
  .top-actions { margin-left: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
