/* =========================================================================
   Coach Ryborg design system: "Carbon, elevated"
   static/css/app.css  (loaded by templates/base.html on every app page)

   Live examples of everything below: /ui-kit (templates/ui_kit.html).

   HOW TO USE
   * New components all start with "ui-" so they never collide with the
     per-page classes older templates define (.stat, .chip, .num ...).
   * Legacy classes (.card, .btn, .btn-orange, .btn-ghost, .btn-green,
     .btn-red, .badge-*, .stat-box, .stats-grid, .form-row, .flash,
     .suggestion-box, .progress-bar) still work and are restyled to match,
     so untouched pages look right. New work should use the ui-* classes.
   * Colours: use the tokens, never hex. --orange IS the ice accent (its
     name is historical). Strava orange appears ONLY on .ui-strava-btn and
     the "Powered by Strava" footer link.

   CLASS INDEX (BEM-ish: block, block__part, block--variant, is-state)
     Layout      .ui-page .ui-page--narrow .ui-bleed .ui-grid .ui-span-{3,4,5,6,7,8,12}
                 .ui-stack .ui-stack--tight .ui-row .ui-spacer .ui-section
     Type        .ui-eyebrow .ui-title .ui-title--xl .ui-h2 .ui-h3 .ui-lede .ui-body
                 .ui-muted .ui-small .ui-num .ui-link .ui-sr-only .ui-thin (300 weight)
     Page header .ui-page-header > .ui-page-header__text (.ui-eyebrow + h1.ui-title
                 [+ .ui-subtitle]) + .ui-page-header__actions (ONE primary action)
     Stat atom   .ui-stats > .ui-stat [--sm|--lg|--xl|--giant] > .ui-stat__value
                 (+ .ui-stat__unit inside) + .ui-stat__label (+ .ui-stat__delta.is-up|.is-down)
     Card        .ui-card [--raised|--flush|--glass|--alert|--danger|--hero|--link]
                 > .ui-card__header (.ui-card__title + .ui-card__meta | .ui-card__link)
                 > .ui-card__body  > .ui-card__footer
     Pill        .ui-pill [--ice|--green|--yellow|--red] (+ .ui-dot inside)
                 .ui-pill--form.is-fresh|.is-neutral|.is-productive|.is-overreaching
     Chips       .ui-chips (segmented) > button.ui-chip[aria-pressed=true] (or .is-on)
     Tag         .ui-tag [--green|--yellow|--red|--quiet]
     Buttons     .ui-btn + --primary | --secondary | --quiet | --danger | --glass
                 sizes --sm | --lg, --block, --icon ; .ui-strava-btn (Connect with Strava)
     Coach       .ui-coach > .ui-coach__av + .ui-coach__text  ; .ui-coach--line (caption)
     Progress    .ui-progress[style="--value:62%;--pace:70%"] > .ui-progress__fill
                 (+ .ui-progress__tick for the pace marker) [--yellow|--red|--green|--thick]
     Empty       .ui-empty > .ui-empty__ghost (faded preview) + .ui-empty__title
                 + .ui-empty__text + one .ui-btn
     Skeleton    .ui-skel [--text|--title|--num|--block|--circle] ; .ui-skel-card
     Forms       .ui-field > .ui-label + .ui-input | .ui-select | .ui-textarea
                 + .ui-help | .ui-error ; .ui-form-grid [--2|--3]
                 .ui-choices (chip-group radios / checkboxes) > label.ui-choice > input + span
                 .ui-switch (checkbox) ; .ui-sticky-actions (sticky Save bar on phone)
     Table       .ui-table-wrap > table.ui-table (td.is-num, th.is-num)
     List rows   .ui-list > .ui-list__item (> .ui-list__media + .ui-list__main + .ui-list__aside)
     Sheet       dialog.ui-sheet > .ui-sheet__handle + .ui-sheet__header (.ui-sheet__title
                 + button[data-sheet-close]) + .ui-sheet__body ; open with
                 [data-sheet-open="<dialog id>"] or RyborgUI.openSheet(id)
                 Bottom sheet on phone, centred modal from 760px.
     Photos      .photo-bw (black and white treatment for every photo except the home hero)
                 .ui-photo (cover crop, set aspect-ratio) ; .ui-hero (full-bleed photo hero)
                 > .ui-hero__media (img/picture) + .ui-hero__scrim + .ui-hero__content
     Charts      .ui-chart (container for static/js/charts.js) .ui-chart-tip .ui-legend
     Misc        .ui-divider .ui-kv .ui-avatar .ui-dot .ui-icon .ui-alert-dot
   ========================================================================= */

/* ─── Tokens ────────────────────────────────────────────────────────────── */
:root {
  /* Carbon colours (exact; legacy names kept so every old template follows) */
  --orange: #62B6CB;            /* THE accent: ice. Name is historical, never orange */
  --accent-rgb: 98,182,203;
  --dark: #08090B;              /* page ground */
  --card: #0E1114;              /* card surface */
  --accent: #12161A;            /* raised surface (wells, inputs, stat boxes) */
  --line: #1B2126;              /* hairline */
  --line-strong: #262E35;
  --text: #E8EDF0;
  --bright: #F4F8FA;            /* big numerals, titles */
  --muted: #7D8A94;             /* secondary text (AA on --card and --dark) */
  --green: #5FC49A;  --green-rgb: 95,196,154;
  --yellow: #D9A94E; --yellow-rgb: 217,169,78;
  --red: #E06C5A;    --red-rgb: 224,108,90;

  /* Aliases with plain names (prefer these in new CSS) */
  --ice: var(--orange);
  --ice-rgb: var(--accent-rgb);
  --ice-ink: #051015;           /* text on an ice fill */
  --strava: #FC4C02;            /* ONLY for Strava attribution / Connect button */

  /* Surface ladder: s0 ground, s1 card, s2 raised, s3 hover/pressed, s4 top */
  --s0: #08090B;
  --s1: #0E1114;
  --s2: #12161A;
  --s3: #171C21;
  --s4: #1E252B;
  --line-2: #262E35;
  --text-2: #BAC5CC;            /* body copy on cards */
  --text-3: #9AA6AF;            /* tertiary, still AA */
  --glass: rgba(14,17,20,.78);
  --glass-line: rgba(255,255,255,.10);

  /* Ice ramp (workout profiles, zones) low to high intensity */
  --ice-1: #2A3A42; --ice-2: #3E6A78; --ice-3: #62B6CB; --ice-4: #9AD3E2; --ice-5: #D9F0F6;
  /* Fatigue line colour in charts (only chart use) */
  --fatigue: #C98BB9;

  /* Type */
  --font-ui: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --num-font: "Barlow Condensed", "Bahnschrift", "Arial Narrow", "Segoe UI", sans-serif;
  --fs-2xs: 11px;   /* tracked caps labels */
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 15px;
  --fs-md: 17px;
  --fs-lg: 20px;
  --fs-xl: 26px;
  --fs-2xl: 34px;
  --fs-3xl: 44px;
  --fs-4xl: 60px;
  --fs-hero: clamp(40px, 6.2vw, 76px);
  --num-sm: 22px;
  --num-md: 34px;
  --num-lg: 44px;
  --num-xl: 72px;
  --num-giant: clamp(112px, 34vw, 200px);
  --track-caps: .16em;

  /* Radius */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;                 /* cards */
  --r-xl: 22px;                 /* hero banners */
  --r-pill: 999px;

  /* Spacing (4px base) */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px; --sp-5: 20px;
  --sp-6: 24px; --sp-7: 32px; --sp-8: 40px; --sp-9: 56px; --sp-10: 72px;

  /* Elevation */
  --shadow-1: 0 1px 0 rgba(255,255,255,.02) inset, 0 8px 24px rgba(0,0,0,.25);
  --shadow-float: 0 24px 60px rgba(0,0,0,.45);
  --focus: 0 0 0 2px var(--dark), 0 0 0 4px var(--ice);

  /* Motion */
  --ease: cubic-bezier(.2,.7,.2,1);
  --dur-1: .12s;
  --dur-2: .2s;
  --dur-3: .4s;

  /* Shell */
  --page-max: 1200px;
  --gutter: 28px;
  --topbar-h: 64px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (max-width: 759.98px) {
  :root { --gutter: 16px; --topbar-h: 56px; }
}

/* ─── Base ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  line-height: 1.5;
  background: var(--dark);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
img, svg, video { max-width: 100%; }
img { display: block; height: auto; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
::selection { background: rgba(var(--accent-rgb), .3); }
:focus-visible { outline: 2px solid var(--ice); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* ─── Legacy layer (classes the existing templates use) ─────────────────── */
.container { max-width: var(--page-max); margin: 0 auto; padding: var(--sp-6) var(--gutter) var(--sp-8); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px;
  margin-bottom: var(--sp-5);
  min-width: 0;
}
.card h2 {
  font-size: var(--fs-xs);
  color: var(--muted);
  font-weight: 650;
  margin-bottom: var(--sp-4);
  text-transform: uppercase;
  letter-spacing: var(--track-caps);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 40px;
  padding: 9px 18px;
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  text-align: center;
  transition: background var(--dur-1), border-color var(--dur-1), color var(--dur-1), transform var(--dur-1);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-orange { background: var(--ice); color: var(--ice-ink); }
.btn-orange:hover { background: #79C3D6; }
.btn-green  { background: rgba(var(--green-rgb),.14); color: var(--green); border-color: rgba(var(--green-rgb),.35); }
.btn-red    { background: rgba(var(--red-rgb),.12);   color: var(--red);   border-color: rgba(var(--red-rgb),.35); }
.btn-ghost  { background: transparent; color: var(--text); border-color: var(--line-2); }
.btn-ghost:hover { border-color: var(--muted); background: var(--s2); }

.badge { display: inline-block; padding: 2px 9px; border-radius: var(--r-pill); font-size: var(--fs-2xs); font-weight: 650; letter-spacing: .04em; }
.badge-high   { background: rgba(var(--red-rgb),.14);    color: var(--red); }
.badge-medium { background: rgba(var(--yellow-rgb),.14); color: var(--yellow); }
.badge-low    { background: rgba(var(--green-rgb),.14);  color: var(--green); }

input, select, textarea {
  background: var(--accent);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  font-size: 15px;
  width: 100%;
  transition: border-color var(--dur-1), box-shadow var(--dur-1);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ice); box-shadow: 0 0 0 3px rgba(var(--accent-rgb),.18); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--ice); }
select option { background: var(--card); }
label { display: block; font-size: var(--fs-sm); color: var(--muted); margin-bottom: 6px; }

.form-row { display: grid; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: var(--fs-2xs); letter-spacing: .12em; color: var(--muted); text-transform: uppercase; font-weight: 650; padding: 10px 12px; border-bottom: 1px solid var(--line-2); }
td { padding: 11px 12px; font-size: 14px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-5); }
.stat-box { background: var(--accent); border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px; text-align: center; }
.stat-box .value { font-family: var(--num-font); font-size: 2.1rem; font-weight: 500; line-height: 1.05; color: var(--bright); font-variant-numeric: tabular-nums; }
.stat-box .label { font-size: var(--fs-2xs); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }

.suggestion-box {
  background: var(--accent);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ice);
  border-radius: var(--r-md);
  padding: 22px 26px;
  white-space: pre-wrap;
  line-height: 1.75;
  font-size: 15.5px;
  color: var(--text);
}

.progress-bar-wrap { background: var(--line); border-radius: var(--r-pill); height: 6px; margin-top: 6px; }
.progress-bar { background: var(--ice); height: 6px; border-radius: var(--r-pill); transition: width var(--dur-3) var(--ease); }

details summary { cursor: pointer; list-style: none; }
details summary::-webkit-details-marker { display: none; }

.flash { background: rgba(var(--accent-rgb),.08); border: 1px solid rgba(var(--accent-rgb),.35); padding: 12px 16px; border-radius: var(--r-sm); margin-bottom: var(--sp-4); }

@media (max-width: 700px) {
  .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }
  table { font-size: 13px; }
  th, td { padding: 9px 8px; }
  .stat-box .value { font-size: 1.6rem; }
  .card { padding: 18px; border-radius: 16px; }
  /* Wide legacy tables scroll inside their card instead of pushing the page sideways */
  .card:has(> table), .container > table { overflow-x: auto; }
  .container > table { display: block; }
}
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  input, select { min-height: 44px; }
}

/* ─── App shell: top bar ────────────────────────────────────────────────── */
.ui-skip { position: absolute; left: -9999px; top: 8px; z-index: 300; background: var(--ice); color: var(--ice-ink); padding: 10px 14px; border-radius: var(--r-sm); font-weight: 650; text-decoration: none; }
.ui-skip:focus { left: 8px; }

.ui-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  min-height: calc(var(--topbar-h) + var(--safe-t));
  padding: var(--safe-t) var(--gutter) 0;
  background: rgba(14,17,20,.9);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.ui-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 300;
  letter-spacing: .24em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  min-height: 44px;
}
.ui-brand b { font-weight: 750; }
.ui-brand__mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(140deg, #1D2A31, #0E1418);
  border: 1px solid #2B3A42;
  display: grid; place-items: center; flex: 0 0 auto;
}
.ui-brand__mark svg { width: 16px; height: 16px; }
.ui-brand__mark { color: var(--ice); }

.ui-nav { display: flex; align-items: center; gap: 2px; }
.ui-nav__link {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: var(--r-xs);
  border: 0;
  background: none;
  font-size: 14px;
  font-weight: 550;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--dur-1), background var(--dur-1);
}
.ui-nav__link:hover { color: var(--text); background: var(--s2); }
.ui-nav__link[aria-current="page"], .ui-nav__link.is-active { color: #fff; background: var(--s2); box-shadow: inset 0 -2px 0 var(--ice); }
.ui-nav__link svg { width: 14px; height: 14px; transition: transform var(--dur-2); }
.ui-nav__link[aria-expanded="true"] svg { transform: rotate(180deg); }

.ui-more { position: relative; }
.ui-more__menu {
  position: absolute; top: calc(100% + 8px); left: 0;
  min-width: 220px;
  padding: 6px;
  background: var(--s2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-float);
  display: grid;
  z-index: 120;
}
.ui-more__menu a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 14px;
}
.ui-more__menu a:hover, .ui-more__menu a:focus-visible { background: var(--s4); color: #fff; }
.ui-more__menu a[aria-current="page"] { color: #fff; background: rgba(var(--ice-rgb),.1); }
.ui-more__menu a svg { width: 18px; height: 18px; color: var(--muted); flex: 0 0 auto; }
.ui-more__menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }

.ui-topbar__right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.ui-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #2B4A55, #1A242A);
  display: inline-grid; place-items: center;
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
  color: #CFE7EE;
  text-decoration: none;
  overflow: hidden;
  flex: 0 0 auto;
  border: 1px solid var(--line-2);
}
.ui-avatar img { width: 100%; height: 100%; object-fit: cover; }
a.ui-avatar { min-width: 36px; }
.ui-topbar .ui-topbar__menu-btn { display: none; }   /* beats .ui-btn display */

/* Public (signed-out) variant; --overlay floats it over a full-bleed hero */
.ui-topbar--public { background: rgba(8,9,11,.72); }
.ui-topbar--overlay { position: absolute; left: 0; right: 0; background: transparent; border-bottom-color: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; }
.ui-topbar--public .ui-nav { margin-left: auto; gap: var(--sp-2); }
.ui-topbar--public .ui-nav__link { color: #C9D2D8; }
.ui-topbar--public .ui-topbar__right { margin-left: var(--sp-2); }

/* Phone: no inline links, bottom tab bar instead */
@media (max-width: 759.98px) {
  .ui-topbar--app .ui-nav, .ui-topbar--app .ui-topbar__ask { display: none; }
  .ui-topbar--public .ui-nav .ui-nav__link--wide { display: none; }
  .ui-brand { letter-spacing: .2em; font-size: 12px; }
  .ui-no-tabbar .ui-topbar__menu-btn { display: inline-flex; }
}
@media (min-width: 760px) and (max-width: 1023.98px) {
  .ui-topbar { gap: var(--sp-3); }
  .ui-nav__link { padding: 8px 9px; }
  .ui-topbar__ask .ui-btn__label { display: none; }
  .ui-brand__word { display: none; }
}

/* ─── App shell: bottom tab bar (phone) ─────────────────────────────────── */
.ui-tabbar { display: none; }
@media (max-width: 759.98px) {
  .ui-has-tabbar { padding-bottom: calc(var(--tabbar-h) + var(--safe-b)); }
  .ui-tabbar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: end;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 110;
    height: calc(var(--tabbar-h) + var(--safe-b));
    padding: 0 4px var(--safe-b);
    background: rgba(14,17,20,.96);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
  }
  .ui-no-tabbar .ui-tabbar { display: none; }
}
.ui-tab {
  display: grid; justify-items: center; align-content: center; gap: 3px;
  height: var(--tabbar-h);
  min-width: 44px;
  padding: 0;
  border: 0; background: none;
  font-size: 11px; font-weight: 600; letter-spacing: .01em;
  color: var(--muted);
  text-decoration: none;
}
.ui-tab svg { width: 22px; height: 22px; }
.ui-tab[aria-current="page"], .ui-tab.is-active { color: var(--ice); }
.ui-tab--coach { align-content: start; }
.ui-tab__coach {
  width: 54px; height: 54px; margin-top: -16px;
  border-radius: 50%;
  background: var(--ice); color: var(--ice-ink);
  display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(var(--ice-rgb),.35), 0 0 0 5px var(--dark);
}
.ui-tab--coach[aria-current="page"] .ui-tab__coach { box-shadow: 0 6px 18px rgba(var(--ice-rgb),.5), 0 0 0 5px var(--dark), 0 0 0 7px var(--ice); }
.ui-tab__coach svg { width: 24px; height: 24px; }

/* More sheet list */
.ui-sheet-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ui-sheet-nav a {
  display: flex; align-items: center; gap: 10px;
  min-height: 52px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--s2);
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  font-size: 14.5px; font-weight: 550;
}
.ui-sheet-nav a svg { width: 20px; height: 20px; color: var(--ice); flex: 0 0 auto; }
.ui-sheet-nav a[aria-current="page"] { border-color: rgba(var(--ice-rgb),.5); background: rgba(var(--ice-rgb),.08); }

/* ─── Footer ────────────────────────────────────────────────────────────── */
.ui-footer {
  max-width: var(--page-max);
  margin: var(--sp-8) auto 0;
  padding: var(--sp-6) var(--gutter) var(--sp-7);
  border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; justify-content: center;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}
.ui-footer a { color: var(--muted); text-decoration: none; }
.ui-footer a:hover { color: var(--text); }
.ui-footer .ui-powered { color: var(--strava); font-weight: 650; }
.ui-footer .ui-powered:hover { color: var(--strava); text-decoration: underline; }

/* ─── Global loading overlay (showGlobalLoader) ─────────────────────────── */
.ui-loader {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(8,9,11,.93);
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-6);
  padding: var(--sp-6);
  text-align: center;
}
.ui-loader__spin { width: 50px; height: 50px; border: 3px solid rgba(255,255,255,.08); border-top-color: var(--ice); border-radius: 50%; animation: ui-spin .8s linear infinite; }
.ui-loader__title { color: var(--ice); font-size: var(--fs-lg); font-weight: 700; }
.ui-loader__detail { color: var(--muted); font-size: 14px; }
@keyframes ui-spin { to { transform: rotate(360deg); } }
@keyframes globalspin { to { transform: rotate(360deg); } }

/* ─── Layout ────────────────────────────────────────────────────────────── */
.ui-page { max-width: var(--page-max); margin: 0 auto; padding: var(--sp-6) var(--gutter) var(--sp-8); }
.ui-page--narrow { max-width: 760px; }
.ui-bleed { width: 100%; }
.ui-section { margin-top: var(--sp-8); }
.ui-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--sp-4); }
.ui-grid > * { min-width: 0; }
.ui-span-3 { grid-column: span 3; } .ui-span-4 { grid-column: span 4; } .ui-span-5 { grid-column: span 5; }
.ui-span-6 { grid-column: span 6; } .ui-span-7 { grid-column: span 7; } .ui-span-8 { grid-column: span 8; }
.ui-span-12 { grid-column: 1 / -1; }
@media (max-width: 899.98px) { .ui-grid > [class*="ui-span-"] { grid-column: 1 / -1; } }
.ui-stack { display: grid; gap: var(--sp-4); align-content: start; }
.ui-stack--tight { gap: var(--sp-2); }
.ui-stack--loose { gap: var(--sp-6); }
.ui-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); }
.ui-row--between { justify-content: space-between; }
.ui-spacer { flex: 1 1 auto; }

/* ─── Type ──────────────────────────────────────────────────────────────── */
.ui-eyebrow { font-size: var(--fs-2xs); font-weight: 650; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.ui-eyebrow--ice { color: #9FB7C0; }
.ui-title { font-size: var(--fs-2xl); font-weight: 300; letter-spacing: -.02em; line-height: 1.1; color: #fff; text-wrap: balance; }
.ui-title b, .ui-title strong { font-weight: 700; }
.ui-title--xl { font-size: var(--fs-hero); line-height: 1.02; letter-spacing: -.025em; }
.ui-h2 { font-size: var(--fs-xl); font-weight: 650; letter-spacing: -.01em; line-height: 1.2; color: #fff; }
.ui-h3 { font-size: var(--fs-md); font-weight: 650; line-height: 1.3; color: #fff; }
.ui-thin { font-weight: 300; }
.ui-lede { font-size: 18px; line-height: 1.55; color: #C3CDD4; max-width: 60ch; }
.ui-body { font-size: var(--fs-base); line-height: 1.6; color: var(--text-2); }
.ui-body p + p { margin-top: .8em; }
.ui-muted { color: var(--muted); }
.ui-small { font-size: var(--fs-sm); }
.ui-num { font-family: var(--num-font); font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: .01em; color: var(--bright); }
.ui-link { color: var(--ice); text-decoration: none; font-weight: 550; }
.ui-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.ui-sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
@media (max-width: 759.98px) {
  .ui-title { font-size: 28px; }
  .ui-lede { font-size: 16px; }
}

/* ─── Page header ───────────────────────────────────────────────────────── */
.ui-page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-6); }
.ui-page-header__text { display: grid; gap: 6px; min-width: 0; }
.ui-subtitle { color: var(--muted); font-size: 14.5px; }
.ui-page-header__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
@media (max-width: 759.98px) {
  .ui-page-header { margin-bottom: var(--sp-5); }
  .ui-page-header__actions { width: 100%; }
  .ui-page-header__actions .ui-btn--primary { flex: 1 1 auto; }
}

/* ─── Stat atom ─────────────────────────────────────────────────────────── */
.ui-stats { display: flex; flex-wrap: wrap; gap: var(--sp-5) var(--sp-7); }
.ui-stat { display: grid; gap: 4px; min-width: 0; }
.ui-stat__value {
  font-family: var(--num-font);
  font-weight: 500;
  font-size: var(--num-md);
  line-height: 1;
  letter-spacing: .01em;
  color: var(--bright);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ui-stat__unit { font-family: var(--font-ui); font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .06em; margin-left: 3px; text-transform: uppercase; }
.ui-stat__label { font-size: var(--fs-2xs); font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.ui-stat__delta { font-size: var(--fs-xs); font-weight: 650; letter-spacing: 0; text-transform: none; margin-left: 6px; }
.ui-stat__delta.is-up { color: var(--green); }
.ui-stat__delta.is-down { color: var(--red); }
.ui-stat--sm .ui-stat__value { font-size: var(--num-sm); }
.ui-stat--lg .ui-stat__value { font-size: var(--num-lg); }
.ui-stat--xl .ui-stat__value { font-size: var(--num-xl); line-height: .92; }
.ui-stat--giant .ui-stat__value { font-size: var(--num-giant); line-height: .82; font-weight: 600; letter-spacing: -.01em; }
.ui-stat--giant .ui-stat__label { font-size: 12px; letter-spacing: .22em; color: var(--text-3); }
.ui-stat--ice .ui-stat__value { color: var(--ice); }
@media (max-width: 759.98px) {
  .ui-stats { gap: var(--sp-4) var(--sp-5); }
  .ui-stat__value { font-size: 28px; }
  .ui-stat--lg .ui-stat__value { font-size: 36px; }
  .ui-stat--xl .ui-stat__value { font-size: 56px; }
}

/* ─── Card ──────────────────────────────────────────────────────────────── */
.ui-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px;
  min-width: 0;
}
.ui-card--raised { background: var(--s2); }
.ui-card--flush { padding: 0; overflow: hidden; }
.ui-card--glass { background: var(--glass); border-color: var(--glass-line); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: var(--shadow-float); }
.ui-card--alert { border-color: rgba(var(--yellow-rgb),.35); background: linear-gradient(90deg, rgba(var(--yellow-rgb),.08), rgba(14,17,20,0) 70%), var(--card); }
.ui-card--danger { border-color: rgba(var(--red-rgb),.35); background: linear-gradient(90deg, rgba(var(--red-rgb),.08), rgba(14,17,20,0) 70%), var(--card); }
.ui-card--hero { border-color: #22313A; overflow: hidden; }
.ui-card--link { text-decoration: none; color: inherit; display: block; transition: border-color var(--dur-1), transform var(--dur-1); }
.ui-card--link:hover { border-color: var(--line-2); transform: translateY(-1px); }
.ui-card__header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: 14px; }
.ui-card__title { font-size: var(--fs-xs); font-weight: 650; letter-spacing: var(--track-caps); text-transform: uppercase; color: var(--muted); }
.ui-card__meta { font-size: var(--fs-xs); color: var(--muted); }
.ui-card__link { font-size: var(--fs-sm); font-weight: 550; color: var(--ice); text-decoration: none; min-height: 32px; display: inline-flex; align-items: center; }
.ui-card__link:hover { text-decoration: underline; text-underline-offset: 3px; }
.ui-card__body { display: grid; gap: var(--sp-3); }
.ui-card__footer { margin-top: var(--sp-4); padding-top: var(--sp-4); border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
@media (max-width: 759.98px) { .ui-card { padding: 18px; border-radius: 16px; } }

/* ─── Pill, dot, chips, tag ─────────────────────────────────────────────── */
.ui-pill {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 30px;
  padding: 5px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-pill);
  background: var(--card);
  font-size: var(--fs-sm); color: #C9D2D8;
  white-space: nowrap;
}
.ui-pill b { color: #fff; font-weight: 650; }
.ui-pill--ice { border-color: rgba(var(--ice-rgb),.35); background: rgba(var(--ice-rgb),.08); }
.ui-pill--green { border-color: rgba(var(--green-rgb),.35); background: rgba(var(--green-rgb),.08); }
.ui-pill--yellow { border-color: rgba(var(--yellow-rgb),.35); background: rgba(var(--yellow-rgb),.08); }
.ui-pill--red { border-color: rgba(var(--red-rgb),.35); background: rgba(var(--red-rgb),.08); }
.ui-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; flex: 0 0 auto; }
.ui-dot--ice { background: var(--ice); } .ui-dot--green { background: var(--green); }
.ui-dot--yellow { background: var(--yellow); } .ui-dot--red { background: var(--red); }
/* Form pill: "Form -15 · productive". Band classes set the dot colour. */
.ui-pill--form .ui-dot { background: var(--muted); }
.ui-pill--form.is-fresh .ui-dot { background: var(--green); }
.ui-pill--form.is-neutral .ui-dot { background: var(--text-3); }
.ui-pill--form.is-productive .ui-dot { background: var(--ice); }
.ui-pill--form.is-overreaching .ui-dot { background: var(--red); }
.ui-pill--form.is-overreaching { border-color: rgba(var(--red-rgb),.35); }

.ui-chips { display: inline-flex; gap: 2px; padding: 3px; background: var(--dark); border: 1px solid var(--line); border-radius: 10px; }
.ui-chip {
  border: 0; background: none;
  min-height: 30px; padding: 5px 11px;
  border-radius: 7px;
  font-size: var(--fs-xs); font-weight: 650;
  color: var(--muted);
  white-space: nowrap;
  transition: background var(--dur-1), color var(--dur-1);
}
.ui-chip:hover { color: var(--text); }
.ui-chip[aria-pressed="true"], .ui-chip.is-on { background: var(--s3); color: #fff; }
@media (pointer: coarse) { .ui-chip { min-height: 40px; padding: 8px 14px; } }

.ui-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--fs-2xs); font-weight: 650; letter-spacing: .04em;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: rgba(var(--ice-rgb),.1);
  color: var(--ice);
  white-space: nowrap;
  vertical-align: 1px;
}
.ui-tag--green { background: rgba(var(--green-rgb),.12); color: var(--green); }
.ui-tag--yellow { background: rgba(var(--yellow-rgb),.13); color: var(--yellow); }
.ui-tag--red { background: rgba(var(--red-rgb),.13); color: var(--red); }
.ui-tag--quiet { background: var(--s3); color: var(--text-3); }

/* ─── Buttons ───────────────────────────────────────────────────────────── */
.ui-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: none;
  color: var(--text);
  font: inherit; font-size: 14.5px; font-weight: 600; line-height: 1.2;
  text-decoration: none; text-align: center; white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur-1), border-color var(--dur-1), color var(--dur-1), transform var(--dur-1);
}
.ui-btn svg { width: 18px; height: 18px; flex: 0 0 auto; }
.ui-btn:active { transform: translateY(1px); }
.ui-btn:disabled, .ui-btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.ui-btn--primary { background: var(--ice); color: var(--ice-ink); }
.ui-btn--primary:hover { background: #79C3D6; }
.ui-btn--secondary { border-color: var(--line-2); background: var(--s2); }
.ui-btn--secondary:hover { border-color: var(--muted); background: var(--s3); }
.ui-btn--quiet { color: var(--text-2); padding-left: 12px; padding-right: 12px; }
.ui-btn--quiet:hover { color: #fff; background: var(--s2); }
.ui-btn--danger { color: var(--red); border-color: rgba(var(--red-rgb),.4); background: rgba(var(--red-rgb),.08); }
.ui-btn--danger:hover { background: rgba(var(--red-rgb),.16); }
.ui-btn--glass { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.16); color: #fff; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.ui-btn--glass:hover { background: rgba(255,255,255,.14); }
.ui-btn--sm { min-height: 36px; padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.ui-btn--lg { min-height: 52px; padding: 14px 24px; font-size: 16px; border-radius: 12px; }
.ui-btn--block { display: flex; width: 100%; }
.ui-btn--icon { padding: 0; width: 44px; }
.ui-btn--icon.ui-btn--sm { width: 36px; }
@media (pointer: coarse) { .ui-btn--sm { min-height: 44px; } .ui-btn--icon.ui-btn--sm { width: 44px; } }

.ui-strava-btn {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 48px;
  padding: 13px 22px;
  border: 0; border-radius: 6px;
  background: var(--strava); color: #fff;
  font: inherit; font-size: 15px; font-weight: 700; letter-spacing: .01em;
  text-decoration: none;
}
.ui-strava-btn:hover { background: #E34402; }
.ui-strava-btn svg { width: 18px; height: 18px; }

/* ─── Coach line / card (AI caption) ────────────────────────────────────── */
.ui-coach {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px;
  border-radius: var(--r-md);
  background: rgba(var(--ice-rgb),.07);
  border: 1px solid rgba(var(--ice-rgb),.18);
}
.ui-coach__av {
  flex: 0 0 30px; width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--ice); color: var(--ice-ink);
  font-family: var(--num-font); font-weight: 700; font-size: 15px;
  display: grid; place-items: center;
}
.ui-coach__text { font-size: 14.5px; line-height: 1.55; color: #D4DEE4; min-width: 0; }
.ui-coach__text b, .ui-coach__text strong { color: #fff; font-weight: 650; }
.ui-coach__text p + p { margin-top: .6em; }
.ui-coach__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ui-coach--line { padding: 0; background: none; border: 0; margin-top: 12px; }
.ui-coach--line .ui-coach__av { flex-basis: 24px; width: 24px; height: 24px; font-size: 13px; }
.ui-coach--line .ui-coach__text { font-size: 14px; color: var(--text-2); }

/* ─── Progress with pace tick ───────────────────────────────────────────── */
.ui-progress { --value: 0%; position: relative; height: 6px; border-radius: 6px; background: var(--line); margin-top: 10px; }
.ui-progress__fill { position: absolute; inset: 0 auto 0 0; width: var(--value); max-width: 100%; border-radius: inherit; background: var(--ice); transition: width var(--dur-3) var(--ease); }
.ui-progress__tick { position: absolute; top: -4px; left: var(--pace, 0%); width: 2px; height: calc(100% + 8px); background: #fff; opacity: .75; border-radius: 1px; transform: translateX(-1px); }
.ui-progress--thick { height: 10px; }
.ui-progress--green .ui-progress__fill { background: var(--green); }
.ui-progress--yellow .ui-progress__fill { background: var(--yellow); }
.ui-progress--red .ui-progress__fill { background: var(--red); }
.ui-progress__legend { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }

/* ─── Empty state with ghost preview ────────────────────────────────────── */
.ui-empty { display: grid; justify-items: center; gap: 10px; text-align: center; padding: var(--sp-7) var(--sp-5); }
.ui-empty__ghost {
  width: min(100%, 360px); height: 120px; margin-bottom: 6px;
  position: relative;
  opacity: .5;
  -webkit-mask-image: linear-gradient(180deg, #000 30%, transparent);
  mask-image: linear-gradient(180deg, #000 30%, transparent);
  pointer-events: none;
}
.ui-empty__ghost svg { width: 100%; height: 100%; }
.ui-empty__ghost--lines { background: repeating-linear-gradient(180deg, transparent 0 28px, var(--line) 28px 29px); border-radius: 12px; }
.ui-empty__title { font-size: var(--fs-md); font-weight: 650; color: #fff; }
.ui-empty__text { font-size: 14px; color: var(--muted); max-width: 44ch; }
.ui-empty .ui-btn { margin-top: 8px; }

/* ─── Skeleton ──────────────────────────────────────────────────────────── */
.ui-skel {
  display: block;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--s2) 0%, var(--s4) 50%, var(--s2) 100%);
  background-size: 200% 100%;
  animation: ui-shimmer 1.4s ease-in-out infinite;
}
.ui-skel--text { height: 12px; margin: 6px 0; }
.ui-skel--text:last-child { width: 70%; }
.ui-skel--title { height: 22px; width: 55%; margin-bottom: 12px; }
.ui-skel--num { height: 34px; width: 72px; }
.ui-skel--block { height: 160px; border-radius: 12px; }
.ui-skel--circle { width: 96px; height: 96px; border-radius: 50%; }
.ui-skel-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px; display: grid; gap: 10px; }
@keyframes ui-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ─── Forms ─────────────────────────────────────────────────────────────── */
.ui-field { display: grid; gap: 6px; min-width: 0; }
.ui-label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); margin: 0; }
.ui-label .ui-optional { font-weight: 400; color: var(--muted); }
.ui-input, .ui-select, .ui-textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--s2);
  color: var(--text);
  font: inherit; font-size: 15px;
}
.ui-textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.ui-select {
  appearance: none; -webkit-appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%237D8A94' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.ui-input::placeholder, .ui-textarea::placeholder { color: #5D6870; }
.ui-input:focus, .ui-select:focus, .ui-textarea:focus { outline: none; border-color: var(--ice); box-shadow: 0 0 0 3px rgba(var(--ice-rgb),.18); }
.ui-input[aria-invalid="true"] { border-color: var(--red); }
.ui-help { font-size: 12.5px; color: var(--muted); }
.ui-error { font-size: 12.5px; color: var(--red); }
.ui-form-grid { display: grid; gap: var(--sp-4); }
.ui-form-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ui-form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 699.98px) { .ui-form-grid--2, .ui-form-grid--3 { grid-template-columns: minmax(0, 1fr); } }
.ui-fieldset { border: 0; display: grid; gap: 8px; min-width: 0; }
.ui-fieldset legend { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); margin-bottom: 8px; padding: 0; }

/* Chip-group radios / checkboxes: <div class="ui-choices"><label class="ui-choice"><input type="radio" name=".." value=".."><span>45 min</span></label>... */
.ui-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.ui-choice { position: relative; display: inline-flex; margin: 0; color: inherit; font-size: inherit; }
.ui-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.ui-choice span {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; min-width: 44px;
  padding: 10px 16px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-pill);
  background: var(--s2);
  font-size: 14px; font-weight: 550; color: var(--text-2);
  cursor: pointer;
  transition: background var(--dur-1), border-color var(--dur-1), color var(--dur-1);
  user-select: none;
}
.ui-choice span:hover { border-color: var(--muted); color: #fff; }
.ui-choice input:checked + span { background: rgba(var(--ice-rgb),.14); border-color: var(--ice); color: #fff; }
.ui-choice input:focus-visible + span { box-shadow: var(--focus); }
.ui-choice input:disabled + span { opacity: .45; cursor: not-allowed; }
.ui-choices--block .ui-choice { flex: 1 1 140px; }
.ui-choices--block .ui-choice span { width: 100%; border-radius: var(--r-md); justify-content: flex-start; }

.ui-switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; margin: 0; color: var(--text-2); font-size: 14px; }
.ui-switch input { appearance: none; -webkit-appearance: none; width: 42px; height: 24px; min-height: 0; padding: 0; border-radius: 12px; background: var(--s4); border: 1px solid var(--line-2); position: relative; cursor: pointer; transition: background var(--dur-1); flex: 0 0 auto; }
.ui-switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--text-3); transition: transform var(--dur-2) var(--ease), background var(--dur-1); }
.ui-switch input:checked { background: rgba(var(--ice-rgb),.35); border-color: var(--ice); }
.ui-switch input:checked::after { transform: translateX(18px); background: var(--ice); }

.ui-sticky-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: var(--sp-6); }
@media (max-width: 759.98px) {
  .ui-sticky-actions {
    position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-b));
    margin: var(--sp-6) calc(-1 * var(--gutter)) 0;
    padding: 12px var(--gutter);
    background: rgba(8,9,11,.94);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    z-index: 20;
  }
  .ui-no-tabbar .ui-sticky-actions { bottom: var(--safe-b); }
  .ui-sticky-actions .ui-btn--primary { flex: 1 1 auto; }
}

/* ─── Tables ────────────────────────────────────────────────────────────── */
.ui-table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r-md); }
.ui-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ui-table th { text-align: left; font-size: var(--fs-2xs); font-weight: 650; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.ui-table td { padding: 12px; font-size: 14px; color: var(--text); border-bottom: 1px solid var(--line); vertical-align: middle; }
.ui-table tr:last-child td { border-bottom: 0; }
.ui-table tbody tr:hover td { background: rgba(255,255,255,.02); }
.ui-table .is-num { text-align: right; font-family: var(--num-font); font-size: 17px; font-weight: 500; color: var(--bright); white-space: nowrap; }
.ui-table th.is-num { font-family: var(--font-ui); font-size: var(--fs-2xs); color: var(--muted); }
@media (max-width: 759.98px) { .ui-table .hide-sm { display: none; } }

/* ─── List rows (rides, documents, components) ──────────────────────────── */
.ui-list { display: grid; }
.ui-list__item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.ui-list__item:first-child { border-top: 0; padding-top: 0; }
a.ui-list__item:hover .ui-list__title { color: var(--ice); }
.ui-list__media { width: 64px; height: 48px; border-radius: 10px; background: var(--s2); border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; }
.ui-list__main { min-width: 0; }
.ui-list__title { font-weight: 600; font-size: 14.5px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ui-list__meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.ui-list__aside { text-align: right; }

/* ─── Bottom sheet / modal (native <dialog>) ────────────────────────────── */
.ui-sheet {
  border: 1px solid var(--line-2);
  background: var(--s1);
  color: var(--text);
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  max-height: min(86vh, 760px);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-float);
  margin: auto;
  overflow: hidden;
}
.ui-sheet[open] { display: flex; flex-direction: column; }
.ui-sheet::backdrop { background: rgba(0,0,0,.6); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.ui-sheet__handle { display: none; }
.ui-sheet__header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 12px; }
.ui-sheet__title { font-size: var(--fs-lg); font-weight: 650; color: #fff; }
.ui-sheet__body { padding: 4px 20px 22px; overflow-y: auto; overscroll-behavior: contain; }
.ui-sheet__footer { padding: 14px 20px calc(16px + var(--safe-b)); border-top: 1px solid var(--line); display: flex; gap: 10px; flex-wrap: wrap; }
@media (max-width: 759.98px) {
  .ui-sheet {
    width: 100%; max-width: 100%;
    margin: auto 0 0;
    max-height: 88vh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    border-bottom: 0;
    padding-bottom: var(--safe-b);
  }
  .ui-sheet__handle { display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 10px auto 0; flex: 0 0 auto; }
  .ui-sheet__header { padding-top: 10px; }
}
@media (prefers-reduced-motion: no-preference) {
  .ui-sheet[open] { animation: ui-sheet-in var(--dur-2) var(--ease); }
  @media (max-width: 759.98px) { .ui-sheet[open] { animation-name: ui-sheet-up; } }
}
@keyframes ui-sheet-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes ui-sheet-up { from { transform: translateY(100%); } }
body.ui-sheet-open { overflow: hidden; }

/* ─── Photos ────────────────────────────────────────────────────────────── */
/* Every photo except the home hero is black and white so ice stays the only colour. */
.photo-bw { filter: grayscale(1) contrast(1.12) brightness(.96); }
.ui-photo { width: 100%; object-fit: cover; background: var(--s2); border-radius: var(--r-lg); }
.ui-photo--wide { aspect-ratio: 16 / 9; }
.ui-photo--card { aspect-ratio: 16 / 10; }
.ui-photo--tall { aspect-ratio: 3 / 4; }

/* Full-bleed photo hero:
   <section class="ui-hero"><picture class="ui-hero__media"><source media="(max-width:759px)" srcset="/static/img/photos/hero-speed-sm.jpg">
   <img src="/static/img/photos/hero-speed.jpg" alt="" width="2000" height="1286"></picture>
   <div class="ui-hero__scrim"></div><div class="ui-hero__content">...</div></section> */
.ui-hero { position: relative; isolation: isolate; min-height: min(740px, 92vh); display: flex; align-items: flex-end; overflow: hidden; background: var(--dark); }
.ui-hero__media, .ui-hero__media img { position: absolute; inset: 0; width: 100%; height: 100%; }
.ui-hero__media { z-index: -2; }
.ui-hero__media img { object-fit: cover; object-position: 62% 45%; }
.ui-hero__scrim {
  position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(90deg, rgba(8,9,11,.95) 0%, rgba(8,9,11,.78) 30%, rgba(8,9,11,.2) 60%, rgba(8,9,11,0) 100%),
    linear-gradient(0deg, var(--dark) 0%, rgba(8,9,11,0) 32%);
}
.ui-hero__content { width: 100%; max-width: var(--page-max); margin: 0 auto; padding: 120px var(--gutter) 140px; }
.ui-hero__content > * { max-width: 680px; }
.ui-hero--short { min-height: 360px; }
.ui-hero--short .ui-hero__content { padding-bottom: var(--sp-8); }
@media (max-width: 759.98px) {
  .ui-hero { min-height: 0; display: block; padding-top: 300px; }
  .ui-hero__media { height: 420px; bottom: auto; }
  .ui-hero__media img { height: 420px; object-position: 50% 0; }
  .ui-hero__scrim { background: linear-gradient(0deg, var(--dark) 0%, var(--dark) 52%, rgba(8,9,11,.35) 72%, rgba(8,9,11,.1) 100%); }
  .ui-hero__content { padding: 0 var(--gutter) var(--sp-7); }
}

/* ─── Charts (static/js/charts.js) ──────────────────────────────────────── */
.ui-chart { position: relative; width: 100%; min-height: 40px; touch-action: pan-y; }
.ui-chart svg { display: block; overflow: visible; }
.ui-chart-tip {
  position: absolute; z-index: 5; pointer-events: none;
  padding: 7px 9px;
  border-radius: 8px;
  background: var(--s2);
  border: 1px solid var(--line-2);
  color: var(--text);
  font-size: 12px; line-height: 1.4;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  opacity: 0;
  transition: opacity var(--dur-1);
}
.ui-chart-tip.is-on { opacity: 1; }
.ui-chart-tip b { color: #fff; }
.ui-chart-alt { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ui-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--muted); }
.ui-legend i { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: 6px; background: var(--ice); }
@media (prefers-reduced-motion: no-preference) {
  .ui-chart .ui-draw { stroke-dasharray: var(--len, 2400); stroke-dashoffset: var(--len, 2400); animation: ui-draw 1.1s var(--ease) forwards; }
  @keyframes ui-draw { to { stroke-dashoffset: 0; } }
}

/* ─── Misc ──────────────────────────────────────────────────────────────── */
.ui-divider { border: 0; border-top: 1px solid var(--line); margin: var(--sp-5) 0; }
.ui-kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 14px; }
.ui-kv dt { color: var(--muted); }
.ui-kv dd { color: var(--text); }
.ui-icon { width: 20px; height: 20px; flex: 0 0 auto; }
.ui-icon-tile { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: rgba(var(--ice-rgb),.12); color: var(--ice); }
.ui-icon-tile--yellow { background: rgba(var(--yellow-rgb),.14); color: var(--yellow); }
.ui-icon-tile--red { background: rgba(var(--red-rgb),.14); color: var(--red); }

/* ─── Reduced motion ────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .ui-skel { animation: none; background: var(--s3); }
  .btn:hover, .ui-card--link:hover { transform: none; }
}

/* == ONBOARD additions == */
/* Power zone colours Z1..Z6, shared by Flywheel (its --z1..--z6), the Garmin zone table and anything else that
   colours by zone. Z2..Z5 are the ice ramp the workout profile bars use (--ice-2..--ice-5); Z1 is a readable grey
   (ice-1 is too dark for Flywheel's zone-coloured power numeral) and Z6 is red for above VO2 max. */
:root {
  --zone-1: #7D8A94;
  --zone-2: var(--ice-2);
  --zone-3: var(--ice-3);
  --zone-4: var(--ice-4);
  --zone-5: var(--ice-5);
  --zone-6: var(--red);
}
