/* Themes (athlete profile setting): lowkey = the original muted dark,
   dark = dark with stronger contrast, daylight = light and clear. */
:root, html[data-theme="lowkey"] {
  --bg: #0b1017;
  --bg2: #101722;
  --card: #151d2a;
  --card2: #1a2434;
  --line: rgba(141,151,166,0.18);
  --text: #ece7dc;
  --muted: #8d97a6;
  --accent: #ffa14e;
  --accent2: #ff8a3d;
  --green: #1fc78c;
  --blue: #3987e5;
  --red: #e05a5a;
  --purple: #a78bfa;
  --btn-ink: #14100b;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
html[data-theme="dark"] {
  --bg: #04070c;
  --bg2: #0e1622;
  --card: #16202f;
  --card2: #202c3f;
  --line: rgba(176,188,204,0.32);
  --text: #ffffff;
  --muted: #b0bccc;
  --accent: #ffb066;
  --accent2: #ff9026;
  --green: #24e3a3;
  --blue: #55a2ff;
  --red: #ff6d6d;
  --purple: #c0a8ff;
  --btn-ink: #100b06;
}
html[data-theme="daylight"] {
  --bg: #f2f4f7;
  --bg2: #ffffff;
  --card: #ffffff;
  --card2: #e9edf3;
  --line: rgba(24,34,49,0.16);
  --text: #18202c;
  --muted: #59636f;
  --accent: #d95f0e;
  --accent2: #e97010;
  --green: #0b8f64;
  --blue: #2160c4;
  --red: #c33a3a;
  --purple: #6d4fd0;
  --btn-ink: #ffffff;
}
html[data-theme="pastel"] {
  --bg: #f6f1ec;
  --bg2: #fdfaf6;
  --card: #ffffff;
  --card2: #f0e7f0;
  --line: rgba(96,82,116,0.16);
  --text: #4b4257;
  --muted: #93889f;
  --accent: #e2917a;
  --accent2: #eca57f;
  --green: #7cc0a4;
  --blue: #8fa8d9;
  --red: #dd8f96;
  --purple: #b49bd9;
  --btn-ink: #43302a;
}
html[data-theme="daylight"] .badge, html[data-theme="pastel"] .badge {
  color: #b45309; border-color: rgba(180,83,9,0.5); }
html[data-theme="daylight"] .hint, html[data-theme="pastel"] .hint {
  color: var(--accent); border-color: rgba(217,95,14,0.45); }
html[data-theme="daylight"] .wk .num, html[data-theme="daylight"] .key .dn,
html[data-theme="pastel"] .wk .num, html[data-theme="pastel"] .key .dn { color: var(--accent); }
html[data-theme="daylight"] .key .t { color: #7c3a06; }
html[data-theme="pastel"] .key .t { color: #8a4a35; }
html[data-theme="daylight"] .key .what, html[data-theme="pastel"] .key .what {
  background: linear-gradient(90deg, rgba(233,112,16,0.10), rgba(233,112,16,0.02) 70%);
  border: 1px solid rgba(217,95,14,0.25);
}
html[data-theme="daylight"] .stat.good .val, html[data-theme="pastel"] .stat.good .val {
  color: var(--green); }
* { margin: 0; padding: 0; box-sizing: border-box; }
/* An app, not a page: no pinch/double-tap zoom (index.html viewport + the
   gesture handlers in app.js) and no rubber-band that drags the top bar. */
html { -webkit-text-size-adjust: 100%; height: 100%; touch-action: manipulation;
  overscroll-behavior: none; }
/* No stray text selection: taps/drags on cards kept selecting text on both
   desktop and mobile. Texts worth copying get an explicit ⧉ button instead;
   form fields stay selectable. */
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea { -webkit-user-select: text; user-select: text; }
.copy-btn {
  background: none; border: 0; padding: 0 3px; cursor: pointer;
  color: var(--muted); font: inherit; font-size: 13px; font-style: normal;
  line-height: 1; vertical-align: baseline;
}
.copy-btn:hover { color: var(--accent); }
/* App shell: fixed-height column, #scroll is the only scroller and the tab
   bar sits in normal flow below it — iOS Safari can no longer float a
   position:fixed bar mid-page while its URL bar collapses. */
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  height: 100dvh; display: flex; flex-direction: column; overflow: hidden;
  overscroll-behavior: none;
}
#scroll {
  flex: 1; min-height: 0; overflow-y: auto;
  -webkit-overflow-scrolling: touch; overscroll-behavior-y: none;
  padding-bottom: 20px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--red); min-height: 1.2em; }
button {
  font: inherit; border: 0; border-radius: 10px; cursor: pointer;
  background: var(--accent2); color: var(--btn-ink); font-weight: 600;
  padding: 10px 16px;
}
button.ghost {
  background: transparent; color: var(--muted);
  border: 1px solid var(--line); font-weight: 500;
}
button.small { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  width: 100%;
  font-size: 16px;   /* iOS zooms into any field under 16px on focus */
}
input:focus, textarea:focus { outline: 1px solid var(--accent2); }
/* every on/off checkbox renders as a slider switch */
input[type="checkbox"] {
  -webkit-appearance: none; appearance: none; flex: none; cursor: pointer;
  position: relative; width: 40px !important; height: 24px; padding: 0; margin: 0;
  border-radius: 999px; border: 1px solid var(--line); background: var(--card2);
  transition: background .18s, border-color .18s;
}
input[type="checkbox"]::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--muted); transition: transform .18s, background .18s;
}
input[type="checkbox"]:checked { background: var(--accent2); border-color: var(--accent2); }
input[type="checkbox"]:checked::before { transform: translateX(16px); background: var(--btn-ink); }
input[type="checkbox"]:disabled { opacity: .45; cursor: default; }
input[type="checkbox"]:focus { outline: none; }
input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
/* iOS Safari gives date/time inputs an intrinsic min width and centred
   native chrome — they overflow narrow cards. Flatten them to the text-field
   look and let them shrink to their container. */
input[type="date"], input[type="time"], input[type="datetime-local"] {
  -webkit-appearance: none; appearance: none;
  display: block; min-width: 0; max-width: 100%; min-height: 44px;
}
input[type="date"]::-webkit-date-and-time-value,
input[type="time"]::-webkit-date-and-time-value,
input[type="datetime-local"]::-webkit-date-and-time-value { text-align: left; }
.form-grid > div { min-width: 0; }
/* native pickers (icon + popup) follow the theme's light/dark */
:root, html[data-theme="lowkey"], html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="daylight"], html[data-theme="pastel"] { color-scheme: light; }

/* top bar */
#topbar {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 10px;
  position: sticky; top: 0; background: linear-gradient(var(--bg) 75%, transparent);
  z-index: 5;
}
.brand-wrap { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.brand { font-weight: 700; font-size: 20px; letter-spacing: 0.02em;
  display: flex; align-items: center; gap: 7px; }
/* active block title: small tag tucked under the wordmark */
.block-tag {
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted); margin: 2px 0 0 29px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.block-tag:empty { display: none; }
.brand b { font-weight: inherit; }
.brand.big { justify-content: center; }
.brand-ico { width: 22px; height: 22px; border-radius: 5px; }
.login-logo { width: 72px; height: 72px; border-radius: 16px; margin: 0 auto 4px; }
.brand span { color: var(--accent); }
.brand.big { font-size: 34px; text-align: center; margin-bottom: 4px; }

.topbar-actions { display: flex; gap: 14px; align-items: flex-start; }
#admin-btn, #profile-btn {
  font-size: 20px; text-decoration: none; color: var(--muted); line-height: 1;
}
#admin-btn:hover, #profile-btn:hover { color: var(--accent); }

/* bottom tabs: normal flow at the bottom of the flex column */
#tabs {
  flex: none; z-index: 10;
  display: flex; background: var(--bg2);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
#tabs a {
  flex: 1; text-align: center; padding: 8px 0 9px;
  color: var(--muted); text-decoration: none; font-size: 11px;
}
#tabs a .ico { display: block; font-size: 19px; line-height: 1.25; }
#tabs a.active { color: var(--accent); }

/* desktop: bottom tab bar becomes a left sidebar, content gets room */
@media (min-width: 1000px) {
  body { flex-direction: row; }
  #scroll { padding-bottom: 24px; order: 2; }
  #tabs {
    order: 1; width: 196px; height: 100%;
    flex-direction: column; justify-content: flex-start; gap: 4px;
    padding: 74px 12px 12px; border-top: 0;
    border-right: 1px solid var(--line);
  }
  #tabs a {
    flex: none; display: flex; align-items: center; gap: 12px;
    text-align: left; font-size: 14px; padding: 10px 14px;
    border-radius: 10px;
  }
  #tabs a .ico { display: inline; font-size: 18px; line-height: 1; }
  #tabs a:hover { color: var(--text); background: var(--card2); }
  #tabs a.active { background: rgba(255,138,61,0.14); }
  #topbar { z-index: 20; }
  #view { max-width: 1080px; margin: 0; padding-left: 22px; }
  #view:has(.board) { max-width: 1080px; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
}

/* login overlay */
#login {
  position: fixed; inset: 0; background: var(--bg); z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
#login form { width: min(320px, 86vw); display: grid; gap: 12px; text-align: center; }

/* main view */
#view { padding: 4px 14px 20px; max-width: 720px; margin: 0 auto; }

/* week board: stacked on mobile, side-by-side on desktop */
@media (min-width: 900px) {
  #view:has(.board) { max-width: 1160px; }
  .board { display: grid; grid-template-columns: 3fr 2fr; gap: 0 28px; align-items: start; }
  .board .side { position: sticky; top: 58px; }
  .board .side .act { margin-left: 0; }
}
h2 { font-size: 17px; margin: 18px 2px 10px; }
/* section headings over a card (session, step test, protocol): the reset
   above leaves them touching the cards around them */
h3 { margin: 20px 2px 10px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 14px; margin-bottom: 10px;
}

/* week media buttons */
.media-row {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin: 8px 0 4px;
}
.btn-link {
  display: inline-block; text-decoration: none;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 11px; font-size: 13px; color: var(--muted);
  background: var(--bg2);
}
.btn-link:hover { color: var(--text); border-color: var(--accent2); }

/* week header */
.week-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 6px 2px 4px; }
.week-head .wkno { font-size: 30px; font-weight: 700; }
.week-head .wkno b { color: var(--accent); }
.week-nav { display: flex; gap: 8px; margin-left: auto; }
.week-head { position: relative; }
.day-pop { position: absolute; right: 0; top: 100%; z-index: 20; width: min(340px, 92vw);
  display: flex; flex-direction: column; gap: 10px; margin-top: 6px;
  box-shadow: 0 10px 32px rgba(0,0,0,.45); }
.day-pop .chips { display: flex; gap: 6px; flex-wrap: wrap; }
.day-pop .chips:empty { display: none; }
.badge {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  color: #ffc989; border: 1px solid rgba(255,176,87,0.45);
  border-radius: 999px; padding: 2px 10px;
}
.phase-tag { font-size: 12px; letter-spacing: 0.12em; color: var(--muted); text-transform: uppercase; }

/* planned sessions */
.sess { position: relative; transition: outline 0.15s; outline: 2px solid transparent; }
.sess.key { background: linear-gradient(90deg, rgba(255,138,61,0.13), var(--card) 60%); border-color: rgba(255,154,69,0.3); }
.sess.rest { opacity: 0.6; }
.sess.droppable { outline: 2px dashed var(--accent); }
.sess .row1 { display: flex; gap: 10px; align-items: baseline; }
.sess .day {
  width: 40px; flex: none; font-weight: 600; font-size: 13px;
  color: var(--muted);
  display: flex; flex-direction: column; align-items: center;
  line-height: 1.25;
}
/* wallpaper-like hierarchy: day name slightly dominant, date a notch
   smaller and dimmer, tightly stacked */
.sess .day .muted { font-size: 11.5px; font-weight: 500; opacity: 0.75; }
.sess.key .day { color: var(--accent); }
.sess .title { font-weight: 600; }
.sess .detail { color: var(--muted); font-size: 13px; margin-left: 54px; }
.sess .status { margin-left: auto; font-size: 12px; }
.status.done { color: var(--green); }
.status.planned { color: var(--muted); }
.status.skipped { color: var(--red); }

/* activities */
.act {
  display: flex; gap: 10px; align-items: center;
  background: var(--card2); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; margin: 8px 0 0 54px;
  font-size: 14px; cursor: grab;
}
.act.unassigned { margin-left: 0; }
.act.selected { outline: 2px solid var(--accent); }
.act .typ { font-size: 17px; }
.act .meta { color: var(--muted); font-size: 12px; }
.act .grow { flex: 1; min-width: 0; }
.act .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act .note-txt { font-size: 12px; color: var(--accent); font-style: italic;
  white-space: normal; }
.note-more { color: var(--muted); cursor: pointer; text-decoration: underline;
  font-style: normal; }
.act .act-tools {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  align-self: flex-start;
}
.act .act-tools:empty { display: none; }

/* session note editor */
.note-modal textarea { width: 100%; resize: vertical; font: inherit; font-size: 16px; }
.note-auto {
  white-space: pre-wrap; font-size: 12px; color: var(--muted);
  background: var(--bg2); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; margin: 4px 0 8px;
}
.note-sync { font-size: 12px; color: var(--muted); }
.note-sync a { color: inherit; }
.sync-synced { color: var(--green); }
.sync-error { color: var(--red); }
.act .bp { opacity: 0.45; }
.act .bp.bp-on { opacity: 1; border-color: rgba(255,154,69,0.6); color: var(--accent); }
.act .bp.bp-auto { font-size: 15px; padding: 4px 6px; }
.hint {
  font-size: 13px; color: var(--accent); text-align: center;
  padding: 8px; border: 1px dashed rgba(255,154,69,0.4); border-radius: 10px;
  margin-bottom: 8px;
}

/* plan table */
table.weeks { width: 100%; border-collapse: collapse; font-size: 14px; }
table.weeks th, table.weeks td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--line); }
table.weeks th { color: var(--muted); font-weight: 500; font-size: 12px; }
table.weeks tr.cur {
  background: rgba(255,138,61,0.16);
  outline: 2px solid var(--accent2); outline-offset: -2px;
  border-radius: 8px;
}
table.weeks tr.cur td { font-weight: 700; border-bottom-color: transparent; }
table.weeks tr.down td { color: var(--muted); font-style: italic; }
table.weeks tr.phase-row td {
  font-weight: 700; padding-top: 14px; color: var(--accent);
  font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase;
}
table.weeks td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.weeks tr[onclick] { cursor: pointer; }

/* collapsible profile action sections (reveal on demand) */
details.sec { margin: 18px 2px 10px; }
details.sec > summary {
  font-size: 17px; font-weight: 600; margin-bottom: 10px; cursor: pointer;
  list-style: none; display: flex; align-items: center; gap: 8px; color: var(--text);
}
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary::before {
  content: "\203A"; color: var(--muted); font-size: 18px; line-height: 1;
  transition: transform 0.15s;
}
details.sec[open] > summary::before { transform: rotate(90deg); }
details.sec.danger > summary { color: var(--red); }

/* full date inside a hero stat value — bold but fits one line */
.stat .val .fulldate { font-size: 15px; font-weight: 600; white-space: nowrap; }

/* link-styled button (forgot password, back, etc.) */
.linklike {
  background: none; border: none; color: var(--accent); cursor: pointer;
  font-size: 13px; padding: 6px; text-decoration: underline; width: auto;
}

/* layout editor modal (panel show/hide + reorder) */
.modal-ov {
  position: fixed; inset: 0; z-index: 50; display: flex;
  align-items: center; justify-content: center; padding: 16px;
  background: rgba(0,0,0,0.55);
}
.modal {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; width: 100%; max-width: 420px; max-height: 82vh; overflow: auto;
}
.lay-list { display: flex; flex-direction: column; gap: 4px; }
/* a long panel list scrolls on its own; title, hint and Cancel/Save stay put
   (dvh: the height the phone's toolbars actually leave) */
.modal.lay-modal {
  display: flex; flex-direction: column; overflow: hidden;
  max-height: 82vh; max-height: 82dvh;
}
.lay-modal .lay-list {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.lay-modal > :not(.lay-list) { flex: none; }
.lay-row {
  display: flex; align-items: center; gap: 6px; font-size: 14px;
  padding: 6px 4px; border-bottom: 1px solid var(--line);
}
.lay-row button { width: auto; padding: 4px 10px; }

/* trends: chips + dual-handle date slider */
.chip-row { display: flex; gap: 10px; margin: 10px 0 2px; flex-wrap: wrap; }
.chip-group {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 14px;
  padding: 6px 10px; background: rgba(21,29,42,0.5);
}
.cg-lbl {
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); margin-right: 2px;
}
.chip {
  border: 1px solid var(--line); background: var(--bg2); color: var(--muted);
  border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer;
}
.chip.active { color: var(--accent); border-color: rgba(255,154,69,0.5); }

.dslider { position: relative; height: 30px; margin: 14px 2px 2px; }
.dslider .track {
  position: absolute; top: 13px; left: 0; right: 0; height: 4px;
  background: var(--line); border-radius: 2px;
}
.dslider .fill {
  position: absolute; top: 13px; height: 4px;
  background: var(--accent2); border-radius: 2px;
}
.dslider input[type="range"] {
  position: absolute; inset: 0; width: 100%; height: 30px; margin: 0;
  -webkit-appearance: none; appearance: none;
  background: none; border: 0; padding: 0; pointer-events: none;
}
.dslider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; pointer-events: auto;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--bg);
  cursor: grab; box-shadow: 0 0 8px rgba(255,154,69,0.4);
}
.dslider input[type="range"]::-moz-range-thumb {
  pointer-events: auto; width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--bg); cursor: grab;
}
.ds-labels {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; color: var(--muted); margin: 0 2px 10px;
  font-variant-numeric: tabular-nums;
}
.ds-l b { color: var(--text); font-size: 14px; }
.ds-l small { display: block; font-size: 11px; color: var(--muted); }
.ds-l.right { text-align: right; }
canvas.chart {
  width: 100%; height: auto; display: block; border-radius: 10px;
  touch-action: pan-y;   /* finger-drag inspects, vertical scroll still works */
}
/* dense charts scroll horizontally past the config threshold (canvas widened
   in JS); short ranges stay 100% and don't scroll */
.chart-scroll {
  overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(141,151,166,0.4) transparent;
  padding-bottom: 2px;
}
/* wraps a .chart-scroll so the y-axis can be pinned in the right gutter while
   the plot scrolls underneath (canvas overlay added in JS on scroll only) */
.chart-wrap { position: relative; }
.chart-axis-y {
  position: absolute; top: 0; right: 0; height: 100%;
  pointer-events: none; z-index: 2;
  background: linear-gradient(to right, transparent, var(--bg) 55%);
}
.chart-scroll canvas.chart { touch-action: pan-x pan-y; }
.chart-scroll::-webkit-scrollbar { height: 8px; }
.chart-scroll::-webkit-scrollbar-track { background: transparent; }
.chart-scroll::-webkit-scrollbar-thumb {
  background: rgba(141,151,166,0.35); border-radius: 4px;
}
.chart-scroll:hover::-webkit-scrollbar-thumb { background: rgba(141,151,166,0.55); }
.seg.seg-small { max-width: 320px; margin-bottom: 10px; }
.seg.seg-small button { font-size: 13px; padding: 6px 10px; }

/* today: budget bar in the hero card */
.budget-bar { position: relative; margin: 16px 3px 6px; }
.bb-track {
  display: flex; height: 14px; border-radius: 7px; overflow: hidden;
  background: rgba(141,151,166,0.15);
}
.bb-track i { display: block; height: 100%; }
/* consumed: a glass tube threaded OVER the track — visible walls, an air
   gap to the bar inside, and a solid leading edge. Zones stay readable. */
.bb-eaten {
  position: absolute; top: -6px; bottom: -6px; left: -3px;
  background: rgba(255,255,255,0.14);
  border: 1.5px solid rgba(236,231,220,0.55);
  border-right: 3px solid var(--text);
  border-radius: 12px 0 0 12px;
  box-shadow: 2px 0 10px rgba(236,231,220,0.3),
              inset 0 0 6px rgba(255,255,255,0.12);
}
.bb-target {
  position: absolute; top: -6px; bottom: -6px; width: 0;
  border-left: 2px dashed var(--text); opacity: 0.85;
}
/* kcal-account compensation overlay: green deposit (banked surplus) /
   red withdrawal (covered overshoot), up to the target marker */
.bb-comp {
  position: absolute; top: -1px; bottom: -1px; border-radius: 4px; opacity: 0.5;
}
.bb-comp.dep { background: var(--green); }
.bb-comp.wd { background: var(--red); }
/* backfill due: eating past the mark leaves earlier days' gaps uncovered;
   the band up to the target is today's surplus owed to those days */
.bb-backfill {
  position: absolute; top: -6px; bottom: -6px; width: 0;
  border-left: 2px dashed var(--green);
}
.bb-bf-band {
  position: absolute; top: 2px; bottom: 2px; opacity: 0.35;
  background: repeating-linear-gradient(135deg, var(--green) 0 3px, transparent 3px 6px);
}
.bb-legend .bb-bf { color: var(--green); }
.bb-legend {
  display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px;
  font-size: 11px; color: var(--muted);
}
.bb-legend i {
  display: inline-block; width: 8px; height: 8px; border-radius: 2px;
  margin-right: 4px;
}
.bb-legend .bb-t { color: var(--text); }

/* today ledger */
.ledger .lrow {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.ledger .lrow:last-child { border-bottom: 0; }
.ledger .lrow.total { border-top: 2px solid var(--line); font-weight: 700; }
.ledger .lrow b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin: 10px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat .lbl { font-size: 11px; letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; }
.stat .val { font-size: 22px; font-weight: 700; margin-top: 2px; }
.stat .val small { font-size: 13px; font-weight: 500; color: var(--muted); }
.stat .sub { font-size: 12px; color: var(--muted); }
.fc-hero { grid-template-columns: 1fr 1fr; }
.fc-hero .stat:first-child { grid-column: 1 / -1; }
.fc-hero .stat .sub + .sub { margin-top: 2px; }
.stat.good .val { color: var(--green); }
.stat.warn .val { color: var(--red); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 6px 2px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

/* profile */
.form-grid { display: grid; gap: 10px; }
.form-grid label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two > * { min-width: 0; }   /* let fields shrink instead of overflowing */
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; background: transparent; color: var(--muted); border-radius: 0; font-weight: 500; }
.seg button.on { background: var(--accent2); color: var(--btn-ink); font-weight: 600; }

/* forecast horizon slider: full-width track, value label tight below */
.hz-wrap { margin: 4px 0 12px; }
.hz-wrap .cg-lbl { display: block; margin-bottom: 2px; }
.hz-wrap input[type="range"] {
  /* undo the global input box model (padding/border/background made the
     track inset ~5% and added a text-height gap below) */
  display: block; width: 100%; height: 22px;
  margin: 0; padding: 0; border: 0; background: none; border-radius: 0;
  accent-color: var(--accent2);
}
.hz-val {
  font-size: 12px; color: var(--muted); text-align: right;
  margin: 0 0 0; line-height: 1.2; font-variant-numeric: tabular-nums;
}

/* milestones: one full-width tile per row so titles never truncate */
.ms-strip {
  display: grid; grid-template-columns: 1fr;
  gap: 10px; margin-bottom: 12px;
}
.ms-tile {
  background: var(--card); border: 1px solid var(--line);
  border-left: 4px solid var(--ms); border-radius: 12px; padding: 10px 12px;
}
.ms-head { display: flex; align-items: baseline; gap: 6px; }
.ms-head b { flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-tools { display: flex; gap: 2px; }
.ms-btn {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  font-size: 13px; padding: 2px 5px; border-radius: 6px;
}
.ms-btn:hover { color: var(--text); background: var(--card2); }
.ms-btn:disabled { opacity: 0.25; cursor: default; }
/* edit / reorder mode: a drag handle and a big edit button per tile */
/* drag handles (milestones, layout editor): a lined box to grab */
.ms-drag, .drag-handle { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card2); color: var(--muted); font-size: 16px; line-height: 1; margin-right: 8px; }
.ms-drag:hover, .drag-handle:hover { color: var(--text); }
.ms-edit { background: var(--card2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; font-size: 18px; min-width: 44px; min-height: 40px; cursor: pointer;
  margin: -4px 0; }
.ms-edit:hover { color: var(--accent); border-color: var(--accent); }
.ms-strip.editing .ms-head { align-items: center; }
.ms-tile.shifting, .lay-row.shifting { transition: transform .15s ease; }
.ms-tile.dragging, .lay-row.dragging { position: relative; z-index: 5; cursor: grabbing;
  box-shadow: 0 10px 28px rgba(0,0,0,.45); background: var(--card); }
.ms-main { font-size: 19px; font-weight: 700; margin-top: 4px; color: var(--ms); }
.ms-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.ms-bar {
  height: 6px; border-radius: 3px; background: rgba(141,151,166,0.2);
  margin-top: 8px; overflow: hidden;
}
.ms-bar i { display: block; height: 100%; background: var(--ms); border-radius: 3px; }
.ms-pct { font-size: 11px; color: var(--muted); margin-top: 3px; text-align: right; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent;
  padding: 0; cursor: pointer;
}
.swatch.on { border-color: var(--text); }

/* portrait-only on phones: manifest handles installed/Android; in-browser
   iOS gets a full-screen hint instead of a broken landscape layout */
/* Phones stay portrait: in landscape the app is turned back against the
   phone's rotation (body[data-rot], set by syncRotation in app.js). */
body[data-rot] { position: fixed; top: 0; left: 0; width: 100dvh; height: 100vw;
  transform-origin: 0 0; }
body[data-rot="-90"] { transform: translateY(100dvh) rotate(-90deg); }
body[data-rot="90"] { transform: translateX(100vw) rotate(90deg); }

/* expanded chart */
.chart-x { background: none; border: 0; padding: 0 4px; margin-left: 6px; cursor: pointer;
  color: var(--muted); font-size: 16px; line-height: 1; vertical-align: middle; float: right; }
.chart-x:hover { color: var(--accent); }
/* ⤢ on the chart itself: a slim strip right above the plot's top-right
   corner (margin, so the plot and its pinned axis keep their geometry) */
.chart-wrap.has-x { margin-top: 26px; }
.chart-wrap > .chart-x { position: absolute; top: -25px; right: 0; z-index: 3; float: none;
  margin: 0; padding: 2px 6px; border-radius: 6px; }
#chart-modal { position: fixed; inset: 0; z-index: 150; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; }
#chart-modal.hidden { display: none; }
#cm-box { position: absolute; inset: 24px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 16px 14px; display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 12px 48px rgba(0,0,0,.5); }
.cm-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cm-head b { font-size: 16px; }
#cm-close { background: none; border: 0; color: var(--muted); font-size: 26px; line-height: 1;
  padding: 0 4px; cursor: pointer; }
#cm-body { flex: 1; min-height: 0; overflow: hidden; }
#cm-body canvas.chart { width: 100%; display: block; }
#cm-legend:empty { display: none; }
#chart-modal.phone #cm-box { inset: 0; border-radius: 0; border: 0;
  padding: calc(8px + env(safe-area-inset-top, 0px)) calc(12px + env(safe-area-inset-right, 0px))
           calc(8px + env(safe-area-inset-bottom, 0px)) calc(12px + env(safe-area-inset-left, 0px)); }
/* upright phone: the box is laid sideways (landscape) — turn the phone to read */
#chart-modal.phone #cm-box[data-rot="90"] { inset: auto; top: 0; left: 0;
  width: 100dvh; height: 100vw; transform-origin: 0 0;
  transform: translateX(100vw) rotate(90deg); }

/* toast */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(74px + var(--safe-b)); z-index: 50;
  background: var(--card2); border: 1px solid var(--line);
  padding: 10px 18px; border-radius: 999px; font-size: 14px;
}

/* Strava brand button (their guidelines: #FC5200, white text) */
.strava-btn { background: #fc5200; color: #fff; border: none; font-weight: 600; }
.title-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.title-chips .chip { width: auto; text-align: left; }
.act .sync-warn { font-size: 12px; color: var(--red); margin-top: 2px; }

/* session photos */
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.thumb {
  position: relative; width: 64px; height: 64px; padding: 0; border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; background: var(--bg2); cursor: pointer;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumbs.mini .thumb { width: 40px; height: 40px; border-radius: 6px; }
.thumbs .more { font-size: 12px; color: var(--muted); }
.thumb .pb {
  position: absolute; right: 2px; bottom: 2px; font-style: normal; font-size: 10px;
  background: rgba(0,0,0,0.6); color: #fff; border-radius: 6px; padding: 0 4px;
}
.thumb .pb-error { background: var(--red); }
.add-photo { width: 64px; height: 64px; padding: 0; }
.photo-modal img { width: 100%; border-radius: 10px; display: block; }
.photo-modal { max-width: 560px; }
/* portrait framing for sharing (cropPhoto): photo under a fixed frame */
.crop-ov {
  position: fixed; inset: 0; z-index: 60; background: #000;
  display: flex; flex-direction: column; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 12px
           calc(10px + env(safe-area-inset-bottom, 0px));
}
.crop-seg { flex: none; align-self: center; width: 100%; max-width: 360px; }
.crop-stage { flex: 1; min-height: 0; position: relative; overflow: hidden;
  touch-action: none; cursor: grab; }
.crop-stage img { position: absolute; z-index: 0; left: 0; top: 0; transform-origin: 0 0;
  max-width: none; user-select: none; -webkit-user-select: none; pointer-events: none; }
.crop-frame { position: absolute; z-index: 1; pointer-events: none; border: 1px solid rgba(255,255,255,.8);
  box-shadow: 0 0 0 100vmax rgba(0,0,0,.6); }
.crop-btns { flex: none; display: flex; gap: 8px; }
.crop-btns button { flex: 1; }
.photo-modal img { max-height: 62vh; object-fit: contain; background: #000; }

/* summary card options */
.stat-list { display: flex; flex-direction: column; gap: 2px; }
.stat-list label {
  display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text);
  padding: 6px 4px; border-bottom: 1px solid var(--line);
}
.stat-list label.off { opacity: 0.45; }

.stat-list span { flex: 1; }
.stat-list b small { font-weight: 400; color: var(--muted); }
.card-opts .chk { display: flex; gap: 8px; align-items: center; font-size: 14px; margin-top: 10px; color: var(--text); }

/* week recap */
.rc-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.rc-ph { position: relative; padding: 0; border: 2px solid transparent; border-radius: 10px;
  overflow: hidden; background: var(--bg2); cursor: pointer; aspect-ratio: 1; }
.rc-ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rc-ph.on { border-color: var(--accent); }
.rc-ph b { position: absolute; top: 4px; left: 4px; background: var(--accent); color: #111;
  border-radius: 999px; min-width: 22px; height: 22px; font-size: 13px; line-height: 22px; text-align: center; }
.rc-ph span { position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; padding: 2px 4px;
  background: rgba(0,0,0,.55); color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-stats { display: flex; flex-direction: column; gap: 2px; }
.rc-stats label { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text);
  padding: 6px 4px; border-bottom: 1px solid var(--line); }
.rc-stats label.off { opacity: .45; }

.rc-stats span { flex: 1; }
.rc-stats b small { font-weight: 400; color: var(--muted); }
#rc-caption { width: 100%; font: inherit; resize: vertical; }
.rc-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; }
.rc-asset { padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: #000; flex: none; scroll-snap-align: start; cursor: pointer; }
.rc-asset img { display: block; height: 100%; width: 100%; object-fit: cover; }
.rc-asset.feed { width: 176px; height: 220px; }
.rc-asset.story { width: 124px; height: 220px; }
.rc-ph em { position: absolute; top: 4px; right: 4px; font-style: normal; font-size: 14px;
  background: rgba(0,0,0,.55); border-radius: 999px; padding: 1px 5px; }
#rc-tags { width: 100%; font: inherit; resize: vertical; }
.ig-btn { background: linear-gradient(90deg, #f58529, #dd2a7b 50%, #8134af); color: #fff; border: none; font-weight: 600; }
.chk { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--text); }

#rc-headline { width: 100%; font: inherit; resize: vertical; }

/* photo upload progress */
.upload-bar {
  position: fixed; left: 12px; right: 12px; top: calc(env(safe-area-inset-top, 0px) + 10px);
  z-index: 60; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; box-shadow: 0 6px 24px rgba(0,0,0,.45); max-width: 480px; margin: 0 auto;
}
.upload-bar .ub-txt { font-size: 14px; margin-bottom: 8px; }
.upload-bar .ub-track { height: 6px; border-radius: 3px; background: var(--bg2); overflow: hidden; }
.upload-bar .ub-track i { display: block; height: 100%; width: 0; background: var(--accent);
  transition: width .2s; }

/* inputs: lactate */
.lac-match { font-size: 13px; min-height: 18px; }
.lac-row { display: flex; gap: 12px; align-items: center; padding: 10px 12px; margin-bottom: 8px; }
.lac-row .grow { flex: 1; min-width: 0; }
.ms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.lay-row input { min-width: 0; }
.lac-val { font-size: 24px; font-weight: 700; color: var(--accent); white-space: nowrap; min-width: 64px; }
.lac-val small { font-size: 12px; font-weight: 500; color: var(--muted); }
.lac-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.lac-chip { font-size: 12px; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px;
  color: var(--text); background: var(--bg2); }
.lac-chips .sched-btn { font-size: 12px; padding: 1px 8px; }
/* chips of different heights (the ⏰ button, a wrapped forecast) share a
   row: each stretches to the row and centres its text */
.lac-chips > * { display: inline-flex; align-items: center; }
.wx-chip { white-space: normal; border-radius: 10px; }

/* current paces */
.stats.paces { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stats.paces .val { font-size: 20px; white-space: nowrap; }
.stats.paces .val small { font-size: 11px; }
@media (max-width: 420px) { .stats.paces { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* a phone held sideways keeps the portrait app (body[data-rot]), but media
   queries see the wide landscape viewport: keep the two-per-row layout */
body[data-rot] .stats.paces { grid-template-columns: repeat(2, minmax(0, 1fr)); }
body[data-rot] .board { display: block; }
body[data-rot] .board .side { position: static; }
.pz-cal { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }

/* planned session parts + plan versions */
.steps { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 4px; font-size: 12px; }
.steps span { border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; color: var(--muted); }
.kind-chip { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; vertical-align: middle;
  border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; color: var(--muted); font-weight: 600; }
.kind-chip.k-threshold, .kind-chip.k-interval, .kind-chip.k-vo2, .kind-chip.k-race { color: var(--red); }
.kind-chip.k-long, .kind-chip.k-distance { color: var(--accent); }
.kind-chip.k-easy { color: var(--green); }
.kind-chip.k-strength { color: var(--purple); }
.kind-chip.k-test { color: var(--blue); border-color: var(--blue); }
.vc-card { display: flex; flex-direction: column; gap: 8px; }
.vc-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.vc-hist summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.vc-commit { border-top: 1px solid var(--line); padding: 8px 0; }
.vc-ch { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.vc-ch .muted { font-size: 12px; }
.vc-op { font-size: 13px; padding: 6px 8px; border-radius: 6px; margin-top: 6px;
  border-left: 3px solid var(--line); }
.vc-oh { display: flex; gap: 8px; align-items: baseline; }
.vc-tag { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: 1px 6px; border-radius: 4px; color: var(--btn-ink); flex: none; }
.vc-add { background: rgba(31,199,140,.10); border-left-color: var(--green); }
.vc-add .vc-tag { background: var(--green); }
.vc-remove { background: rgba(224,90,90,.10); border-left-color: var(--red); }
.vc-remove .vc-tag { background: var(--red); }
.vc-change { background: rgba(255,161,78,.10); border-left-color: var(--accent); }
.vc-change .vc-tag { background: var(--accent); }
.vc-f { font-size: 12px; margin-top: 3px; word-break: break-word; line-height: 1.45; }
.vc-lbl { color: var(--muted); margin-right: 6px; }
.vc-f del { color: var(--red); text-decoration: line-through; text-decoration-thickness: 2px; }
.vc-f ins { color: var(--green); text-decoration: none; font-weight: 600; }
.vc-arrow { color: var(--muted); }
.vc-strike { text-decoration: line-through; text-decoration-color: var(--red); }
.vc-group { margin-top: 8px; }
.vc-gh { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.vc-pill { font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 8px; white-space: nowrap; border: none; }
table.weeks tr.vc-row-add td { background: rgba(31,199,140,.10); }
table.weeks tr.vc-row-change td { background: rgba(255,161,78,.08); }
table.weeks tr.vc-row-remove td { background: rgba(224,90,90,.10); color: var(--muted); text-decoration: line-through; }
table.weeks tr.vc-row-remove td:last-child { text-decoration: none; }
.mini-badge { font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-style: normal; }
.plan-mode { margin: 4px 0 10px; }
.draft-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 6px 10px; margin-bottom: 8px; border-radius: 8px; font-size: 13px;
  background: rgba(255,161,78,.12); border: 1px dashed var(--accent); }
.draft-bar a { color: var(--accent); text-decoration: none; }
.sess.vc-add { box-shadow: inset 3px 0 var(--green); }
.sess.vc-change { box-shadow: inset 3px 0 var(--accent); }
.sess.vc-removed { opacity: .65; box-shadow: inset 3px 0 var(--red); }
.sess.vc-removed .title { text-decoration: line-through; text-decoration-color: var(--red); }
.vc-sess-ch { margin: 4px 0 0 54px; }
.board.draft { grid-template-columns: 1fr; }

/* Garmin MCP tool switches */
.gm-groups.off { opacity: .5; }
.gm-group { border-top: 1px solid var(--line); padding: 6px 0; }
.gm-gh { display: flex; align-items: center; gap: 8px; }
.gm-gh .gm-name { flex: 1; text-decoration: none; text-align: left; color: var(--text); font-weight: 600; font-size: 14px; }
.gm-tools { display: none; flex-direction: column; gap: 6px; padding: 6px 0 2px 18px; }
.gm-group.open .gm-tools { display: flex; }
.gm-tool { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--text); }
.gm-tool span { min-width: 0; word-break: break-word; }
.gm-w { font-style: normal; font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; }

.panel-empty { display: none !important; }

/* inputs menu + sub-views */
.back-link { display: inline-block; margin: 2px 0 6px; color: var(--muted); text-decoration: none; font-size: 14px; }
.inp-menu { display: flex; flex-direction: column; gap: 10px; }
.inp-tile { display: flex; align-items: center; gap: 14px; padding: 16px; text-decoration: none; color: inherit; }
.inp-tile .grow { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.inp-tile small { font-size: 13px; }
.inp-ico { font-size: 26px; width: 34px; text-align: center; }
.inp-chev { color: var(--muted); font-size: 22px; }
.row-toggle { display: flex; gap: 10px; align-items: center; font-size: 14px; color: var(--muted); }
.row-toggle input { width: auto; }
.chip-warn { display: inline-block; padding: 4px 10px; border-radius: 12px; font-size: 13px;
  background: rgba(240,197,61,0.15); color: #f0c53d; margin: 0 0 8px; }

/* bottom sheets (Borg ladder, machine pick/edit) */
.sheet-ov { align-items: flex-end; padding: 0; }
.sheet { max-width: 520px; border-radius: 16px 16px 0 0; max-height: 88vh;
  padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.borg-list { display: flex; flex-direction: column; gap: 4px; }
.borg-row, .pick-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: transparent; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
  color: inherit; font-weight: normal; }
.borg-row.on { border-color: var(--accent); background: rgba(255,161,78,0.08); }
.borg-row .grow { display: flex; flex-direction: column; flex: 1; }
.borg-row small { font-size: 12px; }
.borg-n { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 30px;
  border-radius: 8px; color: #fff; font-weight: 700; font-size: 15px; }
.borg-btn { display: flex; align-items: center; gap: 8px; width: 100%; justify-content: flex-start;
  font-weight: normal; min-height: 42px; text-align: left; }
.borg-btn .borg-n { min-width: 26px; height: 26px; font-size: 13px; }

/* weight training */
.str-card { padding: 12px 14px; margin-bottom: 8px; }
.str-mrow { display: flex; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line);
  color: inherit; text-decoration: none; font-size: 14px; }
.str-mrow .grow { flex: 1; }
.str-garmin { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 8px; font-size: 13px; }
.str-garmin .grow { flex: 1; }
.str-head { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 4px 0; }
.str-name { font-size: 24px; font-weight: 700; text-align: center; }
.wheels { display: flex; gap: 14px; justify-content: center; margin: 14px 0; }
.wheel-box { flex: 1; max-width: 170px; position: relative; }
.wheel { height: 220px; overflow-y: scroll; scroll-snap-type: y mandatory; scrollbar-width: none;
  border: 1px solid var(--line); border-radius: 14px; background: var(--card);
  -webkit-mask-image: linear-gradient(transparent, #000 30%, #000 70%, transparent);
  mask-image: linear-gradient(transparent, #000 30%, #000 70%, transparent); }
.wheel::-webkit-scrollbar { display: none; }
.wheel-box::after { content: ""; position: absolute; left: 6px; right: 6px; top: 88px; height: 44px;
  border-top: 2px solid var(--accent); border-bottom: 2px solid var(--accent); border-radius: 6px;
  pointer-events: none; }
.wheel-pad { height: 88px; }
.wheel-item { height: 44px; line-height: 44px; text-align: center; font-size: 22px;
  scroll-snap-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.wheel-item.on { color: var(--text, #fff); font-size: 28px; font-weight: 700; }
.wheel-lbl { text-align: center; color: var(--muted); font-size: 13px; margin-top: 4px; }
/* time of day: two narrower wheels, a colon between them */
.time-wheels { margin: 6px 0 10px; gap: 22px; }
.time-wheels .wheel-box { max-width: 120px; }
.time-wheels .wheel-box + .wheel-box::before { content: ":"; position: absolute; left: -15px; top: 92px;
  font-size: 26px; font-weight: 700; color: var(--muted); }
.time-btn { font-variant-numeric: tabular-nums; }
.str-commit { width: 100%; font-size: 20px; padding: 16px; border-radius: 14px; }
.str-set { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--line);
  font-size: 15px; }
.str-set b { flex: 1; }
.str-set button { width: auto; }
.str-last .str-set b { font-weight: 500; }
.str-pv { width: 100%; border-collapse: collapse; font-size: 13px; margin: 6px 0; }
.str-pv td { padding: 5px 4px; border-bottom: 1px solid var(--line); }

/* QR scanner */
.scan-ov { position: fixed; inset: 0; z-index: 60; background: #000; }
.scan-ov video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; left: 50%; top: 45%; width: 62vmin; height: 62vmin;
  transform: translate(-50%, -50%); border: 3px solid var(--accent); border-radius: 18px;
  box-shadow: 0 0 0 100vmax rgba(0,0,0,0.35); }
.scan-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 10px; align-items: center;
  justify-content: space-between; padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: rgba(0,0,0,0.6); color: #fff; font-size: 14px; }
.scan-bar button { width: auto; }
.str-sub { text-align: center; font-size: 13px; margin-top: -4px; }
.str-sub a { color: var(--accent); }
.str-settings { text-align: center; font-size: 14px; margin: 6px 0 2px; }
.pick-row[disabled] { opacity: 0.55; }
.ex-list { max-height: 50vh; overflow-y: auto; margin-top: 8px; }
.pick-row.on { border-color: var(--accent); }
/* top-anchored sheet for search pickers (stays clear of the iOS keyboard) */
.top-ov { align-items: flex-start; padding: calc(10px + env(safe-area-inset-top)) 10px 0; }
.top-sheet { max-width: 520px; border-radius: 16px; display: flex; flex-direction: column;
  max-height: calc(100% - 20px); }
/* the list takes what is left between the search field and the keyboard */
.top-sheet .ex-list { flex: 1 1 auto; min-height: 0; max-height: none; }

/* tap feedback */
button, .inp-tile, .pick-row, .borg-row, a.str-mrow, a.back-link, #tabs a {
  transition: transform 90ms ease, filter 90ms ease, background-color 200ms;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:active:not(:disabled), button.tapped, .inp-tile.tapped, .pick-row.tapped,
.borg-row.tapped, a.str-mrow.tapped, a.back-link.tapped, #tabs a.tapped {
  transform: scale(0.96); filter: brightness(1.18); }
button:disabled { opacity: 0.6; cursor: default; }
.str-commit.saved { background: var(--ok, #1fc78c); animation: saved-pop 0.35s ease; }
@keyframes saved-pop { 0% { transform: scale(0.94); } 60% { transform: scale(1.03); } 100% { transform: none; } }

/* busy: photo being read */
.spin { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: -2px;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
input.pulse { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

/* taken-at with seconds */
.tk-row { display: flex; gap: 8px; align-items: center; }
.tk-row .tk-date { flex: 1.2; min-width: 0; }
.tk-row .tk-time { flex: 1; min-width: 0; font-variant-numeric: tabular-nums; letter-spacing: 0.5px; }

/* lactate step-test review */
.lt-chart { padding: 10px 8px 8px; }
.lt-compare { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); margin-top: 6px; }
.lt-compare select { width: auto; padding: 4px 8px; }
.lt-marks .stat.lt1 { border-top: 3px solid #1fc78c; }
.lt-marks .stat.lt2 { border-top: 3px solid #f07a3d; }
.lt-marks .stat.obla { border-top: 3px solid #e05a5a; }
.lt-zones { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; }
.lt-zone { display: flex; justify-content: space-between; padding: 6px 10px; border-radius: 8px; font-size: 14px; }
.lt-z-easy { background: rgba(57,135,229,0.14); }
.lt-z-steady { background: rgba(31,199,140,0.14); }
.lt-z-threshold { background: rgba(240,122,61,0.16); }
.lt-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.lt-table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 4px 6px; }
.lt-table td { padding: 6px; border-top: 1px solid var(--line); }
.lt-table .lt-up { color: #f07a3d; font-weight: 600; }
.lt-cond { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; font-size: 14px; }
.lt-cond div { display: flex; justify-content: space-between; gap: 12px; }
.lt-cond div span:last-child { text-align: right; }
.lt-proto summary { cursor: pointer; font-weight: 600; }

/* Inputs › Sessions browser */
.ss-parsed { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 2px 0; }
.ss-chip { font-size: 12px; padding: 3px 8px; border-radius: 10px; background: rgba(141,151,166,0.15); }
.ss-chip.ss-cond { background: rgba(255,161,78,0.15); color: var(--accent); }
.ss-chip.ss-bad { background: rgba(224,90,90,0.15); color: #e05a5a; }
.ss-op { font-size: 12px; font-weight: 700; color: var(--muted); align-self: center; text-transform: uppercase; }
.ss-filters .chip-group { flex-wrap: wrap; }
.ss-row { display: flex; gap: 12px; align-items: center; padding: 12px; margin-bottom: 8px;
  text-decoration: none; color: inherit; }
.ss-row .typ { font-size: 22px; width: 28px; text-align: center; }
.ss-row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ss-row .nm { font-weight: 600; }
.ss-row .meta { font-size: 13px; color: var(--muted); }
.ss-row .snip { font-size: 13px; color: var(--muted); font-style: italic; }
.ss-row mark { background: rgba(255,161,78,0.35); color: inherit; border-radius: 3px; padding: 0 1px; }
.act.focus-flash { animation: focus-flash 2s ease; }
@keyframes focus-flash { 0%, 60% { box-shadow: 0 0 0 2px var(--accent); background: rgba(255,161,78,0.12); }
  100% { box-shadow: none; } }
.lt-z-above-lt1 { background: rgba(31,199,140,0.14); }

/* session view */
.sv-head { display: flex; gap: 12px; align-items: center; margin: 4px 0 10px; }
.sv-ico { font-size: 30px; }
.sv-actions { display: flex; gap: 8px; margin-bottom: 12px; }
.sv-actions button { flex: 1; }
.sv-map { width: 100%; border-radius: 14px; display: block; margin-bottom: 12px; background: #14171c;
  aspect-ratio: 800 / 460; object-fit: cover; }
.sv-stats .stat .val { font-size: 22px; }
.sv-zones { padding: 12px; }
.sv-zbar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; margin-bottom: 8px; }
.sv-zbar i { display: block; height: 100%; }
.sv-zleg { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--muted); }
.lt-table tr.sv-rep td { background: rgba(255,161,78,0.10); }

/* Day: training load */
.load-card { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.load-top { display: flex; justify-content: space-between; align-items: flex-start; }
.load-big { font-size: 34px; font-weight: 700; line-height: 1.1; }
.load-status { padding: 4px 10px; border-radius: 12px; font-size: 13px; background: rgba(141,151,166,0.18); }
.load-status.ok { background: rgba(31,199,140,0.18); color: #1fc78c; }
.load-status.hi, .load-status.vhi { background: rgba(240,122,61,0.18); color: #f07a3d; }
.load-status.lo { background: rgba(57,135,229,0.18); color: #3987e5; }
.load-bar, .lf-bar { position: relative; height: 10px; border-radius: 5px; background: rgba(141,151,166,0.15); }
.load-bar .band, .lf-bar .band { position: absolute; top: 0; bottom: 0; background: rgba(31,199,140,0.35); border-radius: 5px; }
.load-bar .mark { position: absolute; top: -4px; width: 4px; height: 18px; margin-left: -2px; border-radius: 2px;
  background: var(--accent); }
.load-focus { display: flex; flex-direction: column; gap: 6px; }
.lf-row { display: grid; grid-template-columns: 96px 1fr 44px; gap: 8px; align-items: center; font-size: 13px; }
.lf-row b { text-align: right; }
.lf-bar .fill { position: absolute; top: 2px; bottom: 2px; left: 0; background: var(--accent); border-radius: 4px; opacity: 0.85; }

/* Forecast: why the ETA changed */
.why-row { padding: 6px 0 6px 10px; margin-top: 8px; font-size: 14px;
  border-left: 3px solid var(--why, var(--muted)); }
.why-row .sub { color: var(--muted); margin-top: 2px; }
.why-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.why-pill { font-size: 12px; padding: 1px 8px; border-radius: 10px; color: var(--why);
  border: 1px solid color-mix(in srgb, var(--why) 55%, transparent);
  background: color-mix(in srgb, var(--why) 14%, transparent); }
.why-weight { --why: #4ea3ff; }
.why-race { --why: #b57cff; }
.why-day { --why: var(--muted); }
.why-plan { --why: var(--accent); }
.why-model { --why: #8a9aa8; }
.why-was { opacity: .75; }
.why-good { color: var(--green); }
.why-bad { color: var(--red); }
.why-more { margin-top: 10px; width: 100%; }
.borg-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.gm-fv { font-style: normal; font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--green); }
.wiz-dots { display: flex; gap: 5px; }
.wiz-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.wiz-dots i.done { background: var(--muted); }
.wiz-dots i.on { background: var(--accent2); }
.block-goal { margin-top: 10px; }

/* Plan: the plan's own description under its name */
.plan-desc { font-size: 13px; margin: -4px 2px 10px; white-space: pre-wrap; }
.chart-note { font-size: 12px; margin: -4px 2px 6px; }

/* strength: muscle map (front/back figure, SVG from the backend) */
.mm-card { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.mm-card .muscle-map { width: 100%; max-width: 340px; height: auto; }
.mm-top { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.mm-top span { font-size: 12px; border: 1px solid var(--accent); color: var(--accent);
  border-radius: 999px; padding: 1px 9px; }
.str-with-mm { display: flex; gap: 12px; align-items: flex-start; }
.str-with-mm .grow { flex: 1; min-width: 0; }
.mm-mini { flex: 0 0 92px; }
.mm-mini .muscle-map { width: 92px; height: auto; display: block; }

/* strength: machine muscle override, stale Garmin write */
.mus-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.warn-txt { color: var(--accent); }
.str-mrow .ghost.small[data-medit] { margin-left: 6px; padding: 2px 8px; }

/* lactate protocols: stop-rule notes, plan sessions, the stage editor */
.lp-warn { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--accent);
  border-color: rgba(255,161,78,.45); }
.lp-plan { display: flex; flex-direction: column; padding: 4px 12px; }
.lp-plan a { display: flex; gap: 10px; align-items: baseline; padding: 9px 0; color: inherit;
  text-decoration: none; font-size: 14px; border-top: 1px solid var(--line); }
.lp-plan a:first-child { border-top: 0; }
.lp-plan .grow { flex: 1; min-width: 0; }
#lp-form { gap: 16px; }
#lp-form label { margin-bottom: 8px; }
#lp-stages { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
#lp-stages .lp-head { margin-bottom: -2px; }
.lp-st { display: grid; grid-template-columns: 18px 1fr 1fr 1fr 1.4fr 32px; gap: 5px; align-items: center; }
.lp-st input { min-width: 0; padding: 7px 6px; font-size: 15px; }
.lp-head span { font-size: 11px; color: var(--muted); padding-left: 2px; }
.lp-st .lp-n { color: var(--muted); font-size: 12px; text-align: right; }
.lp-st button { padding: 4px 0; }
a.proto-chip { color: inherit; text-decoration: none; }

/* Profile › Location: the stored position */
.loc-last { display: flex; flex-direction: column; gap: 6px; }
.loc-map { width: 100%; aspect-ratio: 2 / 1; border-radius: 10px; background: var(--line); object-fit: cover; }
.loc-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }

/* search field with its own clear ✕ (iOS's native one is hidden) */
.search-box { position: relative; }
.search-box input { padding-right: 40px; }
.search-box input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.search-box .search-x {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); font-size: 16px; line-height: 1;
}
.search-box .search-x.hidden { display: none; }

/* session title: clear ✕ and favourite ☆ inside the field */
.title-box { position: relative; }
.title-box input { padding-right: 76px; }
.title-box button {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); font-size: 16px; line-height: 1;
}
.title-box .title-x { right: 38px; }
.title-box .title-fav { right: 4px; font-size: 19px; }
.title-box .title-fav.on { color: var(--accent); }

/* Trends race-time boxes; a race time's pace under it */
.stats.race-heroes { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
/* a panel's switched-off feature (Day: "turn on") */
.cfg-card { position: relative; margin-top: 10px; }
.race-pace { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.stat .sub.why-good { color: var(--green); }
.stat .sub.why-bad { color: var(--red); }

/* lactate: the photo read's state, and where the saved time comes from */
.ocr-box { font-size: 13.5px; border-radius: 10px; padding: 10px 12px; line-height: 1.45;
  border: 1px solid var(--line); background: var(--card2); }
.ocr-box.busy { border-color: var(--accent); }
.ocr-box.ok { border-color: var(--green); }
.ocr-box.warn { border-color: #f0c53d; }
.ocr-box.err { border-color: var(--red); }
.ocr-box .muted { font-size: 12.5px; margin-top: 2px; }
.ocr-box button { margin-top: 8px; }
.lac-src { margin: 4px 0 8px; }
.lac-when { font-size: 13.5px; margin-top: 6px; }
.lac-src-line { font-size: 12px; margin-top: 2px; }

/* lactate camera mode */
.lac-mode { margin-bottom: 2px; }
.lac-snap { font-size: 18px; padding: 16px; width: 100%; }
.lac-shot { display: grid; grid-template-columns: 96px 1fr; gap: 10px; align-items: start; margin-top: 10px; }
.lac-shot img { width: 96px; border-radius: 8px; border: 1px solid var(--line); }
.lac-big { font-size: 22px; font-variant-numeric: tabular-nums; }
.lac-cam-ov .lac-frame { width: 56vmin; height: 66vmin; top: 42%; border-radius: 14px; }
.lac-cam-hint { position: absolute; left: 0; right: 0; top: calc(env(safe-area-inset-top, 0px) + 18px);
  text-align: center; color: #fff; font-size: 15px; text-shadow: 0 1px 4px #000; }
.lac-cam-bar { position: absolute; left: 0; right: 0; bottom: 0; display: grid;
  grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  padding: 18px 20px calc(env(safe-area-inset-bottom, 0px) + 22px); background: rgba(0,0,0,.45); }
.lac-cam-bar button.ghost { width: auto; justify-self: start; }
.lac-shutter { width: 74px; height: 74px; border-radius: 50%; border: 5px solid #fff;
  background: rgba(255,255,255,.25); padding: 0; cursor: pointer; }
.lac-shutter:active { background: #fff; }

/* "New version available · Update now · Later" (app.js updateBanner) */
#update-banner {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(74px + var(--safe-b)); z-index: 60;
  display: flex; align-items: center; gap: 12px; white-space: nowrap;
  background: var(--card2); border: 1px solid var(--line);
  padding: 8px 10px 8px 16px; border-radius: 999px; font-size: 14px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .35);
}
#update-banner button { width: auto; margin: 0; padding: 6px 12px; font-size: 14px; }

/* Admin › Ideas (the development backlog, app.js renderDevBox) */
.dev-card { padding: 12px; }
.dev-add { display: flex; gap: 8px; }
.dev-add textarea { flex: 1; margin: 0; resize: none; overflow: hidden; display: block;
  line-height: 1.35; min-height: 0; }
.dev-add { align-items: flex-end; }
.dev-fold > summary { cursor: pointer; list-style: none; }
.dev-fold > summary::-webkit-details-marker { display: none; }
.dev-fold > summary h2 { display: inline-block; }
.dev-fold > summary h2::before { content: "▸ "; color: var(--muted); }
.dev-fold[open] > summary h2::before { content: "▾ "; }
.dev-add button { width: auto; margin: 0; }
.dev-list { list-style: none; margin: 10px 0 0; padding: 0; }
.dev-list > li { padding: 8px 0; border-top: 1px solid var(--line); }
.dev-line { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.dev-time { color: var(--muted); }
.dev-rm { margin-left: auto; width: auto; padding: 2px 8px; font-size: 15px; color: var(--muted); }
.dev-text { margin-top: 2px; white-space: pre-wrap; word-break: break-word; cursor: text; }
.dev-edit { width: 100%; margin: 0; font: inherit; }
.dev-note { margin-top: 3px; font-size: 13px; color: var(--muted); white-space: pre-wrap;
            border-left: 2px solid var(--line); padding-left: 8px; }
.dev-chip { font-size: 11px; padding: 1px 7px; border-radius: 999px;
            border: 1px solid var(--c); color: var(--c); }
.dev-more, .dev-hist, .dev-set { margin-top: 8px; }
.dev-more summary, .dev-hist summary, .dev-set summary { cursor: pointer; }
.dev-pre { white-space: pre-wrap; font-size: 13px; margin: 6px 0; }
/* markdown from Claude (mdHtml): plan, line notes, summary */
.md { white-space: normal; line-height: 1.45; overflow-wrap: anywhere; }
.md p { margin: 0 0 6px; }
.md ul, .md ol { margin: 2px 0 6px; padding-left: 18px; }
.md li { margin: 2px 0; }
.md li > ul, .md li > ol { margin: 2px 0; }
.md .md-h { font-weight: 700; color: var(--text); margin: 10px 0 4px; }
.md .md-h1, .md .md-h2 { font-size: 15px; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md b { color: var(--text); }
.md code { font-size: 12px; padding: 0 4px; border-radius: 4px; background: rgba(141,151,166,.15); }
.md pre { white-space: pre-wrap; font-size: 12px; padding: 6px 8px; border-radius: 6px;
  background: rgba(141,151,166,.1); margin: 4px 0 6px; }
.dev-live { font-size: 11px; margin-top: 8px; }
.dev-set { padding: 6px 0; border-top: 1px solid var(--line); }
.dev-set-body { padding: 4px 0 4px 12px; }
.dev-commits { margin: 6px 0; padding-left: 18px; font-size: 12px; }

/* Motion: quick, and never in the way — the new content is there at once,
   these only ease it in. Overlays: the backdrop fades, the box slides up (a
   sheet from the bottom edge); closing (dismiss() in app.js) runs it
   backwards, a save lifts the box away instead. Views slide in from the side
   they come from (data-enter, set on navigation). */
@keyframes ov-in { from { background-color: rgba(0,0,0,0); } }
@keyframes ov-out { to { background-color: rgba(0,0,0,0); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(40px) scale(.94); } }
@keyframes modal-out { to { opacity: 0; transform: translateY(28px) scale(.95); } }
@keyframes modal-commit { to { opacity: 0; transform: translateY(-40px) scale(.94); } }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
@keyframes sheet-commit { to { opacity: 0; transform: translateY(-16px); } }
.modal-ov { animation: ov-in .28s ease-out; }
.modal-ov > .modal { animation: modal-in .3s cubic-bezier(.2, .9, .3, 1); }
.modal-ov.sheet-ov > .modal { animation-name: sheet-in; }
.modal-ov.shown > .modal { animation: none; }
.modal-ov.closing { animation: ov-out .22s ease-in forwards; pointer-events: none; }
.modal-ov.closing > .modal { animation: modal-out .2s ease-in forwards; }
.modal-ov.sheet-ov.closing > .modal { animation-name: sheet-out; }
.modal-ov.closing.commit > .modal { animation: modal-commit .24s ease-in forwards; }
.modal-ov.sheet-ov.closing.commit > .modal { animation-name: sheet-commit; }
/* the expanded chart: its box may be turned (phone), so it only fades */
#chart-modal:not(.hidden) { animation: ov-in .22s ease-out; }
#chart-modal:not(.hidden) #cm-box { animation: view-fade .2s ease-out; }

@keyframes view-fwd { from { opacity: 0; transform: translateX(72px); } }
@keyframes view-back { from { opacity: 0; transform: translateX(-72px); } }
@keyframes view-fade { from { opacity: 0; } }
#view[data-enter] { overflow-x: clip; }
#view[data-enter="fwd"] > * { animation: view-fwd .3s cubic-bezier(.2, .9, .3, 1); }
#view[data-enter="back"] > * { animation: view-back .3s cubic-bezier(.2, .9, .3, 1); }
#view[data-enter="fade"] > * { animation: view-fade .24s ease-out; }

/* Reduce Motion (iOS: Accessibility › Motion): nothing moves, it
   cross-fades instead — Apple's own substitute for slides. Profile ›
   Animations: "on" (html[data-motion=on]) slides anyway, "off" drops it all. */
@media (prefers-reduced-motion: reduce) {
  html:not([data-motion="on"]) .modal-ov > .modal,
  html:not([data-motion="on"]) .modal-ov.sheet-ov > .modal { animation-name: view-fade; }
  html:not([data-motion="on"]) .modal-ov.closing > .modal,
  html:not([data-motion="on"]) .modal-ov.sheet-ov.closing > .modal,
  html:not([data-motion="on"]) .modal-ov.closing.commit > .modal,
  html:not([data-motion="on"]) .modal-ov.sheet-ov.closing.commit > .modal { animation-name: fade-out; }
  html:not([data-motion="on"]) #view[data-enter="fwd"] > *,
  html:not([data-motion="on"]) #view[data-enter="back"] > * { animation-name: view-fade; }
}
html[data-motion="off"] .modal-ov, html[data-motion="off"] .modal-ov > .modal,
html[data-motion="off"] #chart-modal, html[data-motion="off"] #cm-box,
html[data-motion="off"] #view > * { animation: none !important; }
@keyframes fade-out { to { opacity: 0; } }

/* Admin › API tokens: name · scope · status, a tap shows the rest */
.tok-table .tok-row { cursor: pointer; }
.tok-table td { overflow-wrap: anywhere; }
.tok-st { font-size: 12px; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.tok-st.ok { color: var(--ok, #1fc78c); background: rgba(31,199,140,.12); }
.tok-st.temp { color: var(--accent); background: rgba(255,161,78,.12); }
.tok-st.bad { color: #e05a5a; background: rgba(224,90,90,.12); }
.tok-st span { color: inherit; }
.tok-info { display: grid; gap: 3px; font-size: 13px; padding: 4px 0 6px; overflow-wrap: anywhere; }
.tok-info button { justify-self: start; margin-top: 4px; }

/* Admin: Athletes / API tokens folds with their "+" button, token groups */
.admin-sec > summary .sec-add { margin: 0 0 0 auto; width: auto; font-size: 13px; font-weight: 500; }
.tok-group { margin: 6px 0; }
.tok-group > summary { cursor: pointer; list-style: none; font-weight: 600; font-size: 15px; padding: 6px 2px; }
.tok-group > summary::-webkit-details-marker { display: none; }
.tok-group > summary::before { content: "▸ "; color: var(--muted); }
.tok-group[open] > summary::before { content: "▾ "; }

/* a slow refresh behind a cached view (swrLoad) */
#refresh-pill {
  position: fixed; top: calc(env(safe-area-inset-top, 0px) + 8px); left: 50%; z-index: 60;
  transform: translate(-50%, -12px); opacity: 0; pointer-events: none;
  background: var(--card); color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 12px; font-size: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .18); transition: opacity .2s, transform .2s;
}
#refresh-pill.on { opacity: 1; transform: translate(-50%, 0); }

/* live lactate test */
.ll-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ll-head .seg button { white-space: nowrap; }
.ll-advice { text-align: center; padding: 14px 12px; border: 1px solid var(--line); }
.ll-advice .ll-lbl { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.ll-advice .ll-now { font-size: 30px; font-weight: 700; color: var(--accent); margin: 2px 0; }
.ll-advice .ll-then { font-size: 14px; color: var(--muted); }
.ll-facts { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin-top: 10px; font-size: 14px; }
.ll-facts .ll-near { color: var(--red); }
.ll-advice .ll-msg { font-size: 14px; margin-top: 8px; }
.ll-advice.ll-steep { border-color: rgba(255,154,69,0.7); }
.ll-advice.ll-stop { border-color: var(--red); }
.ll-advice.ll-stop .ll-now { color: var(--red); }
.ll-advice.ll-flash { animation: ll-flash 1.2s ease-out 3; }
@keyframes ll-flash { 0% { background: rgba(255,154,69,0.45); } 100% { background: var(--bg2); } }
.ll-saved { border: 1px solid rgba(31,199,140,0.6); font-size: 14px; }
.ll-entry .ll-entry-h { font-size: 14px; }
.ll-entry .ll-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.ll-entry label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
/* value and Save on one line, the same height; the label sits above both */
.ll-entry .ll-when { font-size: 13px; }
.ll-entry .ll-mlbl { font-size: 13px; color: var(--muted); margin-bottom: -6px; }
.ll-entry .ll-saverow { align-items: stretch; }
.ll-entry .ll-saverow > * { margin: 0; height: 100%; box-sizing: border-box; }
.ll-table tr.ll-cur td { background: rgba(255,161,78,0.12); }
.ll-table tr[data-st] { cursor: pointer; }
/* runner view: big type and two big controls (Borg, Next stage). Upright
   (phone, iPad portrait) everything stacks full width; in landscape the
   advice and controls sit beside the curve. Loads wrap between words. */
.ll-sub { margin: 2px 2px 10px; }
.ll-runner { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.ll-runner > .card, .ll-side > .card { margin: 0; }
.ll-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.ll-runner .ll-advice .ll-now { font-size: clamp(44px, 12vw, 96px); line-height: 1.05; text-wrap: balance;
  overflow-wrap: anywhere; }
.ll-runner .ll-advice .ll-lbl { font-size: 15px; }
.ll-runner .ll-advice .ll-then { font-size: 22px; text-wrap: balance; }
.ll-runner .ll-facts { font-size: 19px; }
.ll-runner .ll-advice .ll-msg { font-size: 19px; text-wrap: balance; }
.ll-ctl { display: grid; grid-template-columns: 1fr; gap: 10px; }
.ll-ctl > * { min-width: 0; }
.ll-borg { width: 100%; font-size: 18px; padding: 14px 16px; border-radius: 14px; text-align: left; }
.ll-next { width: 100%; font-size: 21px; padding: 18px 16px; border-radius: 14px; line-height: 1.25; }
.ll-next b { white-space: nowrap; }
.ll-next.ll-waiting { background: transparent; color: var(--muted); border: 2px dashed var(--line); }
.ll-next-anyway { width: 100%; padding: 14px; border-radius: 14px; }
.ll-wait { text-align: center; font-size: 18px; color: var(--green); padding: 10px; }
.ll-tablecard { overflow-x: auto; }
.ll-tablehint { font-size: 12px; margin-top: 6px; }
body.ll-wide #view { max-width: 1280px; }
@media (min-width: 700px) {
  body.ll-wide .ll-table { font-size: 17px; }
  .ll-ctl { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); }
  .ll-ctl > :only-child { grid-column: 1 / -1; }
}
@media (min-width: 700px) and (orientation: landscape) {
  .ll-runner { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(0, 1.45fr); align-items: stretch; }
  .ll-runner .ll-advice { flex: 1; display: flex; flex-direction: column; justify-content: center; }
  .ll-runner .ll-advice .ll-now { font-size: clamp(44px, 5.6vw, 84px); }
  .ll-ctl { grid-template-columns: 1fr; }
}

/* QA environment ribbon: fixed across the top, since on desktop body is a flex
   row and an in-flow ribbon became a full-height column left of the sidebar.
   Body padding reserves its height; it takes over the safe-area inset. */
#env-ribbon { position: fixed; top: 0; left: 0; right: 0; z-index: 50; background: #7a3cff;
  color: #fff; font-size: 12px; font-weight: 600; line-height: 16px; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: calc(env(safe-area-inset-top, 0px) + 3px) 8px 3px; }
body:has(#env-ribbon) { padding-top: calc(env(safe-area-inset-top, 0px) + 22px); }
body:has(#env-ribbon) #topbar { padding-top: 14px; }
