:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f1ed;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --swim: #0072B2;
  --bike: #E69F00;
  --run: #CC79A7;
  --atl: #8d8a82;
  --swim-z1: #6bb9f7; --swim-z2: #4e9cd8; --swim-z3: #3081bb; --swim-z4: #08669e; --swim-z5: #004b82;
  --bike-z1: #e3a434; --bike-z2: #c58700; --bike-z3: #a86c00; --bike-z4: #8c5100; --bike-z5: #703700;
  --power-z1: #b58cff; --power-z2: #9a5ffd; --power-z3: #7d3be6; --power-z4: #6128bf; --power-z5: #461a92;
  --run-z1: #e295bf; --run-z2: #c47aa3; --run-z3: #a75f87; --run-z4: #8a456d; --run-z5: #6e2c53;
  --other: #898781;
  --violet: #4a3aa7;
  --magenta: #e87ba4;
  --yellow: #eda100;
  --good: #0ca30c;
  --warn: #fab219;
  --serious: #ec835a;
  --crit: #d03b3b;
  --fresh: #2a78d6;  /* form's "fresh" zone: good, but a different good from optimal training */
  --good-text: #006300;
  --warn-text: #8f5c00;  /* status colors readable as text */
  --hr: #e0313f;     /* workout streams, Strava's scheme: heart rate red, power purple */
  --power: #8a3ffc;
  --crit-text: #b42f2f;
  --band: rgba(11, 11, 11, 0.035);
  --focus: #2a78d6;
  --shadow: 0 8px 28px rgba(11, 11, 11, 0.12);
  --z1: #a6a7da; --z2: #8d8cce; --z3: #7572c2; --z4: #5e57b5; --z5: #4a3aa7;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #242423;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --swim: #006eae;
    --bike: #c47f00;
    --run: #c976a4;
    --atl: #a9a69c;
    --swim-z1: #005991; --swim-z2: #2474ae; --swim-z3: #4390cb; --swim-z4: #60ace9; --swim-z5: #7cc9ff;
    --bike-z1: #7f4500; --bike-z2: #9b6000; --bike-z3: #b87a1d; --bike-z4: #d59640; --bike-z5: #f4b35e;
    --power-z1: #4a2193; --power-z2: #6532c4; --power-z3: #8452ec; --power-z4: #a47cff; --power-z5: #c4a8ff;
    --run-z1: #7e3a61; --run-z2: #9a537b; --run-z3: #b76e96; --run-z4: #d589b2; --run-z5: #f3a5cf;
    --violet: #9085e9;
    --magenta: #d55181;
    --yellow: #c98500;
    --good-text: #0ca30c;
    --warn-text: #fab219;
    --hr: #ff5a63;
    --power: #b07cff;
    --crit-text: #f07070;
    --band: rgba(255, 255, 255, 0.04);
    --focus: #3987e5;
    --fresh: #3987e5;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
    --z1: #514d79; --z2: #6e67ad; --z3: #9085e9; --z4: #aba5f1; --z5: #c5c2f7;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #242423;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --swim: #006eae;
  --bike: #c47f00;
  --run: #c976a4;
  --atl: #a9a69c;
  --swim-z1: #005991; --swim-z2: #2474ae; --swim-z3: #4390cb; --swim-z4: #60ace9; --swim-z5: #7cc9ff;
  --bike-z1: #7f4500; --bike-z2: #9b6000; --bike-z3: #b87a1d; --bike-z4: #d59640; --bike-z5: #f4b35e;
  --power-z1: #4a2193; --power-z2: #6532c4; --power-z3: #8452ec; --power-z4: #a47cff; --power-z5: #c4a8ff;
  --run-z1: #7e3a61; --run-z2: #9a537b; --run-z3: #b76e96; --run-z4: #d589b2; --run-z5: #f3a5cf;
  --violet: #9085e9;
  --magenta: #d55181;
  --yellow: #c98500;
  --good-text: #0ca30c;
  --warn-text: #fab219;
  --hr: #ff5a63;
  --power: #b07cff;
  --crit-text: #f07070;
  --band: rgba(255, 255, 255, 0.04);
  --focus: #3987e5;
  --fresh: #3987e5;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  --z1: #514d79; --z2: #6e67ad; --z3: #9085e9; --z4: #aba5f1; --z5: #c5c2f7;
}

* { box-sizing: border-box; }
html { background: var(--page); }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  padding: 10px 24px;
  background: color-mix(in oklab, var(--page) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 650; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand-mark { width: 20px; height: 20px; border-radius: 5px; background: url("favicon.svg") center / cover; }
.signout { font-size: 12px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.signout:hover { color: var(--ink); }
/* Phones: tabs get their own row (they were squeezed to nothing), and the theme toggle goes (the system
   setting applies), so brand, Sync now and Sign out fit on the first row. */
@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; gap: 6px 12px; padding: 8px 16px; }
  .topbar::after { content: ""; order: 9; flex-basis: 100%; height: 0; }  /* line break: tabs start row 2 */
  .topbar .tabs { order: 10; flex: 1 1 0; min-width: 0; }
  .topbar .theme-toggle { display: none; }
  .topbar .theme-cycle { display: inline-grid; order: 11; }  /* right end of the tabs row */
  /* Solid, not frosted: iOS Safari colors the strip above the page from the top bar, and can't from a
     see-through one (it showed white in dark mode). */
  .topbar { background: var(--page); backdrop-filter: none; }
}
.theme-cycle { display: none; place-items: center; width: 30px; height: 28px; padding: 0; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); color: var(--ink-2); cursor: pointer; }
.theme-cycle svg { width: 16px; height: 16px; }
.theme-cycle:hover { color: var(--ink); border-color: var(--axis); }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  text-decoration: none; color: var(--ink-2); padding: 6px 10px; border-radius: 8px; white-space: nowrap;
}
.tabs a:hover { background: var(--surface-2); color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.topbar .spacer { flex: 1; }
.sync { color: var(--muted); font-size: 12px; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.sync .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.sync .dot.stale { background: var(--warn); }
.sync { cursor: default; }
.sync-btn { font: inherit; font-size: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--ink-2); border-radius: 8px; padding: 4px 10px; cursor: pointer; white-space: nowrap; }
.sync-btn:hover:not(:disabled) { color: var(--ink); border-color: var(--axis); }
.sync-btn:disabled { opacity: .6; cursor: progress; }
@media (max-width: 1100px) { .sync { display: none; } .brand .pill { display: none; } }
.banner { border-radius: 10px; padding: 10px 14px; margin: 0 0 12px; font-size: 13px; color: var(--ink); border: 1px solid var(--border); }
.banner ul { margin: 6px 0 0; padding-left: 18px; color: var(--ink-2); }
.banner.warn { background: color-mix(in oklab, var(--warn) 14%, var(--surface)); border-color: color-mix(in oklab, var(--warn) 45%, transparent); }
.banner.crit { background: color-mix(in oklab, var(--crit) 10%, var(--surface)); border-color: color-mix(in oklab, var(--crit) 40%, transparent); }
.theme-toggle { flex: none; display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.theme-toggle button { background: none; border: 0; padding: 4px 8px; font-size: 12px; color: var(--ink-2); cursor: pointer; }
.theme-toggle button[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); font-weight: 600; }

/* ---------- layout ---------- */
main { max-width: 1320px; margin: 0 auto; padding: 20px 24px 64px; }
.page-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 4px 0 16px; }
.page-head h1 { font-size: 22px; letter-spacing: -0.015em; margin: 0; font-weight: 650; }
.page-head .sub { color: var(--ink-2); }
.concept-note {
  margin: 0 0 18px; padding: 10px 14px; border-radius: 10px;
  background: var(--surface-2); color: var(--ink-2); font-size: 13px;
}
.concept-note b { color: var(--ink); }
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }
@media (max-width: 1000px) {
  .span-3, .span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; }
}
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px 18px; min-width: 0;
}
.card-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { font-size: 14px; font-weight: 650; margin: 0; }
.card-head .meta { color: var(--muted); font-size: 12px; }
.card-head .right { margin-left: auto; }

/* ---------- legend ---------- */
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key-line { width: 14px; height: 2px; border-radius: 2px; display: inline-block; }
.key-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.key-sq { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 700px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.tile .label { color: var(--ink-2); font-size: 12px; }
.tile .value { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; margin-top: 2px; }
.tile .value small { font-size: 13px; font-weight: 500; color: var(--ink-2); margin-left: 2px; }
.tile .delta { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.tile .spark { height: 28px; margin-top: 6px; }

/* ---------- status pill ---------- */
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.ico { width: 14px; height: 14px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 10px; font-weight: 800; color: #fff; flex: none; line-height: 1; }
.ico.good { background: var(--good); }
.ico.warn { background: var(--warn); color: #0b0b0b; }
.ico.serious { background: var(--serious); color: #0b0b0b; }
.ico.crit { background: var(--crit); }
.ico.neutral { background: var(--muted); }
.ico.fresh { background: var(--fresh); }

/* ---------- activity chips ---------- */
.chip {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 4px 7px; border-radius: 7px; border: 1px solid transparent;
  background: var(--surface-2); font-size: 12px; line-height: 1.3; text-align: left; cursor: pointer; min-width: 0;
}
.chip:hover { border-color: var(--axis); }
.chip .sw { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.chip .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chip .num { margin-left: auto; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip.planned { background: transparent; border: 1px dashed var(--axis); color: var(--ink-2); cursor: default; }
.chip.planned.optional { opacity: 0.75; }
.chip.race { background: color-mix(in oklab, var(--violet) 14%, var(--surface)); border-color: color-mix(in oklab, var(--violet) 40%, transparent); font-weight: 600; }
.sw.swim { background: var(--swim); } .sw.bike { background: var(--bike); } .sw.run { background: var(--run); }
.sw.other, .sw.rest, .sw.tbd { background: var(--other); } .sw.race { background: var(--violet); }

/* ---------- link-out buttons ---------- */
.links { display: flex; gap: 6px; flex-wrap: wrap; }
.link-out {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; text-decoration: none;
  padding: 3px 8px; border-radius: 6px; border: 1px solid var(--border); color: var(--ink-2); background: var(--surface);
  white-space: nowrap;
}
.link-out:hover { color: var(--ink); border-color: var(--axis); }
.link-out[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }
.link-out .arr { font-size: 10px; }

/* ---------- tables ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
table.data td { padding: 6px 8px; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
table.data td.r, table.data th.r { text-align: right; }
details.tv { margin-top: 10px; font-size: 12px; color: var(--ink-2); }
details.tv summary { cursor: pointer; color: var(--muted); }
details.tv[open] summary { margin-bottom: 6px; }
.tv-scroll { max-height: 260px; overflow: auto; }

/* ---------- charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart text { font: 11px system-ui, -apple-system, "Segoe UI", sans-serif; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart text.lbl { fill: var(--ink-2); font-size: 11.5px; }
.chart text.lbl-strong { fill: var(--ink); font-weight: 600; font-size: 11.5px; }
.chart text.halo { paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.tip {
  position: fixed; z-index: 50; pointer-events: none; opacity: 0; transition: opacity .08s;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); padding: 8px 10px; font-size: 12px; min-width: 120px; max-width: 280px;
}
.tip.on { opacity: 1; }
.tip .t-h { font-weight: 600; margin-bottom: 4px; }
.tip .t-r { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tip .t-r b { margin-left: auto; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; padding-left: 10px; }

/* ---------- drawer ---------- */
.drawer-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.18); opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 30; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); z-index: 31;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow);
  transform: translateX(100%); transition: transform .18s ease; padding: 20px; overflow-y: auto;
}
.drawer-open .drawer { transform: none; }
.drawer-open .drawer-scrim { opacity: 1; pointer-events: auto; }
.drawer .close { position: absolute; top: 14px; right: 14px; border: 0; background: var(--surface-2); border-radius: 8px; width: 30px; height: 30px; cursor: pointer; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 14px 0; }
.kv div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.kv .k { font-size: 11.5px; color: var(--ink-2); }
.kv .v { font-size: 17px; font-weight: 600; }

.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.small { font-size: 12px; }
.pill { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.seg-control { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg-control button { border: 0; background: var(--surface); padding: 5px 10px; font-size: 12px; cursor: pointer; color: var(--ink-2); }
.seg-control button[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filters .lab { font-size: 12px; color: var(--muted); }
.info-i { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--axis); color: var(--muted); font-size: 10px; font-weight: 700; cursor: help; vertical-align: middle; flex: none; }
.info-i:hover, .info-i:focus-visible { color: var(--ink); border-color: var(--ink-2); }

/* Phones: data tables must fit the screen; last in the file so it beats the table rules above (an overflowing table makes iOS widen and zoom out the page). */
@media (max-width: 700px) {
  table.data { font-size: 12px; }
  table.data th, table.data td { padding: 6px 4px; }
  table.data th { white-space: normal; }
}

/* ---- the "how it felt" journal ---- */
.felt-wrap { margin: 0 0 12px; }
.felt { font-size: 13px; color: var(--ink-2); padding: 8px 0; border-top: 1px solid var(--border); display: grid; gap: 4px; }
.felt:first-of-type { border-top: 0; padding-top: 2px; }
.felt b { color: var(--ink); font-weight: 600; }
.felt-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.felt-note { color: var(--ink); }
.felt-hard { font-size: 11px; padding: 1px 6px; border-radius: 6px; background: color-mix(in oklab, var(--warn) 18%, transparent); color: var(--ink); margin-left: 4px; }
.syms { display: flex; flex-wrap: wrap; gap: 4px; }
.sym { font-size: 11.5px; padding: 1px 7px; border-radius: 999px; border: 1px solid color-mix(in oklab, var(--c) 70%, transparent); background: color-mix(in oklab, var(--c) 16%, transparent); color: var(--ink); }

.felt-mark { display: inline-flex; align-items: center; justify-content: center; width: 12px; height: 12px; border-radius: 50%; background: color-mix(in oklab, var(--c) 30%, transparent); border: 2px solid var(--c); margin-left: 5px; vertical-align: -1px; cursor: default; font-size: 9px; line-height: 1; }
.felt-mark b { font-weight: 800; }
.felt-grid { display: grid; gap: 3px 2px; align-items: center; font-size: 12px; overflow-x: auto; }
.felt-grid .fg-d { text-align: center; font-size: 10px; color: var(--muted); line-height: 1.15; }
.felt-grid .fg-d.now { color: var(--ink); font-weight: 600; }
.felt-grid .fg-l { color: var(--ink-2); padding-right: 8px; white-space: nowrap; }
.felt-grid .fg-c { display: flex; align-items: center; justify-content: center; gap: 2px; min-height: 18px; }
.felt-grid .fg-last { color: var(--muted); font-size: 11px; padding-left: 8px; white-space: nowrap; }
.fg-dot { width: 10px; height: 10px; border-radius: 50%; }
.fg-eff { font-size: 9.5px; color: var(--muted); }
.fg-sev { width: 14px; height: 14px; border-radius: 4px; font-size: 9px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2); }
.fg-na { width: 6px; height: 6px; border-radius: 50%; border: 1px solid var(--border); }
.felt-notes.clip li.more { display: none; }
.felt-notes { margin: 12px 0 0; padding-left: 0; list-style: none; font-size: 12.5px; display: grid; gap: 4px; color: var(--ink); }
/* phones: drop the "last value" column (every row's last cell is .fg-last, so rows stay aligned) */
@media (max-width: 640px) { .felt-grid .fg-last { display: none; } .felt-grid { grid-template-columns: minmax(64px, max-content) repeat(14, minmax(0, 1fr)) !important; gap: 3px 1px; } .felt-grid .fg-l { padding-right: 4px; } .felt-grid .fg-eff { display: none; } }
.felt-mark b { color: var(--ink); }
