/* tunacycling.cc – component library. Screens compose these (see js/ui.js and the /ui/ gallery) instead of styling their own.
 * Conventions: block (.tile), element (.tile__title), modifier (.tile--art), state (.is-on, .is-busy).
 */

/* ---------- base ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { font: 500 var(--fs)/1.35 var(--font); }
a { color: var(--accent-2); }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: var(--fs-xl); } h2 { font-size: var(--fs-lg); } h3 { font-size: var(--fs); }
p { margin: 0; }
code { background: var(--fill); padding: 1px 5px; border-radius: 6px; font: .92em var(--mono); }
[hidden] { display: none !important; }
.t-muted { color: var(--text-muted); } .t-ok { color: var(--ok); } .t-warn { color: var(--warn); } .t-bad { color: var(--bad); }
.t-sm { font-size: var(--fs-sm); } .t-xs { font-size: var(--fs-xs); }

/* ---------- layout helpers ---------- */
.row { display: flex; gap: var(--s2); align-items: center; }
.row--wrap { flex-wrap: wrap; } .row--between { justify-content: space-between; } .row--end { justify-content: flex-end; }
.col { display: flex; flex-direction: column; gap: var(--s3); }
.grow { flex: 1 1 0; min-width: 0; }
.grid { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fill, minmax(var(--min, 240px), 1fr)); }

/* ---------- button ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: var(--tap); padding: 0 18px;
  font: 650 var(--fs)/1.1 var(--font); color: var(--text); background: var(--fill); border: 1px solid var(--line); border-radius: var(--r);
  cursor: pointer; text-decoration: none; user-select: none; touch-action: manipulation; }
.btn:hover { background: var(--hover); }
.btn:disabled, .btn.is-busy { opacity: .5; pointer-events: none; }
.btn--primary { background: var(--accent-grad); border-color: transparent; color: var(--text-on-accent); box-shadow: 0 6px 22px var(--accent-glow); }
.btn--primary:hover { background: var(--accent-grad); filter: brightness(1.07); }
.btn--danger { color: color-mix(in srgb, var(--danger) 25%, var(--light)); background: color-mix(in srgb, var(--danger) 16%, transparent); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn--ghost { background: none; border-color: transparent; }
.btn--brand-strava { background: var(--brand-strava); color: var(--light); border: 0; }
.btn--lg { min-height: var(--tap-lg); font-size: 17px; }
.btn--sm { min-height: 40px; padding: 0 12px; font-size: 14px; gap: 6px; border-radius: var(--r-sm); }
.btn--xl { min-height: var(--tap-xl); font-size: 20px; padding: 0 34px; border-radius: var(--r-lg); }
.btn--block { width: 100%; }
.btn--icon { width: var(--tap); padding: 0; font-size: 20px; }
.btn.is-on { background: var(--accent); color: var(--text-on-accent); border-color: transparent; }
/* round, glassy buttons that float over the 3D world */
.btn--round { width: var(--round); height: var(--round); min-height: 0; padding: 0; border-radius: 50%; background: var(--glass); border-width: var(--hud-border); border-color: var(--line-strong);
  backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px); font-size: 20px; color: var(--text-on-art); }
.btn--round:active { background: color-mix(in srgb, var(--light) 22%, transparent); }
.btn--round.is-on { background: var(--hud-on); border-color: var(--text-on-art); color: var(--text-on-art); }   /* calm: no accent over the world */
.btn--round small { font-size: 13px; font-weight: 750; letter-spacing: .05em; }

/* ---------- card ---------- */
.card { background: var(--card-grad); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; }
.card__head > .row { flex: 0 1 auto; justify-content: flex-end; }
.card--accent { border-color: color-mix(in srgb, var(--accent) 60%, transparent); background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, transparent), var(--surface)); }
.card--warn { border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.card.is-on { border-color: var(--accent); }
button.card { font: inherit; color: inherit; text-align: left; width: 100%; cursor: pointer; }   /* a card you pick by tapping it (pickers) */
.link-row.is-on { background: var(--accent-tint); border-radius: var(--r-sm); }
/* step number in a card title: n, ✓ once done, lit while it's the step to do now */
.stepnum { display: inline-grid; place-items: center; flex: none; width: 28px; height: 28px; margin-inline-end: var(--s2); vertical-align: middle;
  border-radius: 50%; border: 2px solid var(--line-strong); color: var(--text-muted); font-size: var(--fs-sm); font-weight: 800; }
.stepnum.is-on { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px var(--accent-tint); }
.stepnum.is-ok { border-color: transparent; background: var(--hover); color: var(--ok); }
.stepnum .icon { margin: 0; }
.card__head h2:has(> .stepnum) { display: flex; align-items: center; }
.optional { margin-inline-start: var(--s2); font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- tile: a big selectable choice (world, route, device, workout) ---------- */
.tile { position: relative; display: flex; flex-direction: column; justify-content: center; gap: 2px; min-height: 72px; padding: var(--s3) 14px; text-align: left;
  border-radius: var(--r); border: 1px solid var(--line); background: var(--fill); color: var(--text); font: inherit; cursor: pointer; }
.tile.is-on:not(.tile--art) { border-color: var(--accent); background: var(--accent-tint); }
.tile__title { font-weight: 750; }
.tile__meta { color: var(--accent-2); font-weight: 650; font-size: var(--fs-sm); }
.tile__desc { color: var(--text-muted); font-size: 13px; }
.tile__badge { position: absolute; top: var(--s2); right: var(--s2); font-size: var(--fs-xs); background: color-mix(in srgb, var(--shade) 50%, transparent); padding: 3px 10px; border-radius: var(--r-pill); color: var(--ok); }
.tile--side { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--s3); align-content: center; }
.tile--side > :not(.tile__side, .tile__badge) { grid-column: 1; }
.tile__side { grid-column: 2; grid-row: 1 / span 4; align-self: center; display: flex; gap: var(--s2); }
@media (max-width: 560px) {   /* phones: the buttons go under the text */
  .tile--side { grid-template-columns: minmax(0, 1fr); row-gap: 4px; }
  .tile__side { grid-column: 1; grid-row: auto; justify-self: end; margin-top: var(--s2); }
}
.tile--art { min-height: 128px; justify-content: flex-end; border: 2px solid transparent; color: var(--text-on-art); text-shadow: var(--text-shadow); overflow: hidden; }
.tile--art .tile__title { font-size: 20px; font-weight: 800; }
.tile--art .tile__desc { color: color-mix(in srgb, var(--text-on-art) 90%, transparent); }
.tile--art.is-on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.tile.is-ok { border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
/* stacked: text on top, the buttons along the bottom (tiles in a grid, e.g. device connections) */
.tile--stack { justify-content: flex-start; }
.tile--stack .tile__side { display: flex; align-self: stretch; gap: var(--s2); margin-top: auto; padding-top: var(--s3); }
.tile--stack .tile__side > .row { display: contents; }
.tile--stack .tile__side .btn { flex: 1; }
@media (max-width: 700px) { .tile--art { min-height: 96px; } .tile--art .tile__desc { display: none; } }

/* ---------- chips & segmented control ---------- */
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip { min-height: 44px; padding: 0 16px; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--fill); color: var(--text); font: 600 var(--fs-sm) var(--font); cursor: pointer; }
.chip.is-on { background: var(--hover); color: var(--text); border-color: var(--line-strong); }
.seg { align-self: flex-start; display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface-sunk); }
.seg > button { min-height: var(--tap); padding: 0 16px; border: 0; background: none; color: var(--text); font: 600 var(--fs) var(--font); cursor: pointer; }
.seg > button.is-on { background: var(--hover); color: var(--text); }
.seg--block { display: flex; align-self: stretch; } .seg--block > button { flex: 1; }

/* ---------- form fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: var(--fs-sm); color: var(--text-muted); }
.field__hint { font-size: var(--fs-xs); color: var(--text-muted); }
.input { font: inherit; color: var(--text); background: var(--surface-sunk); border: 1px solid var(--line); border-radius: var(--r-sm); min-height: var(--tap); padding: 10px 14px; width: 100%; }
textarea.input { font: 14px/1.5 var(--mono); }
input[type=color].input { padding: 4px; }
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: var(--s3); min-height: var(--tap); cursor: pointer; }
.check input { width: 24px; height: 24px; accent-color: var(--accent); }
/* switch: an on/off toggle (UiSwitch) */
.switch { position: relative; display: inline-flex; align-items: center; gap: var(--s3); min-height: var(--tap); cursor: pointer; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track { position: relative; flex: none; width: 50px; height: 30px; border-radius: var(--r-pill); background: var(--surface-sunk); border: 1px solid var(--line-strong); transition: background .15s, border-color .15s; }
.switch__track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--text-muted); transition: transform var(--bounce-time) var(--ease-bounce), background .15s; }
.switch input:checked + .switch__track { background: var(--accent); border-color: transparent; }
.switch input:checked + .switch__track::after { transform: translateX(20px); background: var(--light); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch__label { display: flex; flex-direction: column; } .switch__hint { font-weight: 500; font-size: var(--fs-sm); color: var(--text-muted); }
.stepper { display: flex; align-items: center; gap: var(--s3); font-weight: 700; }
.stepper__value { min-width: 60px; text-align: center; }
.stepper .btn { width: var(--tap); padding: 0; font-size: 22px; }

/* ---------- stats ---------- */
.stat { display: flex; flex-direction: column; }
.stat__value { font-family: var(--font-digits); font-size: 22px; font-weight: 700; line-height: 1.2; letter-spacing: .02em; }   /* ride numbers: the HUD's 7-segment font everywhere */
.stat__label { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted); }
.stat--hero .stat__value { font-size: 46px; transition: color .3s; }
.stat--lg .stat__value { font-size: 32px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: var(--s3); }
/* exactly four numbers: one row, or 2 × 2 on phones (never 3 + 1) */
.legend-fade { display: inline-block; width: 22px; height: 3px; border-radius: 2px; background: linear-gradient(90deg, var(--path-start), var(--path-end)); }   /* the ridden line's colours, as a legend */
.num { font-family: var(--font-digits); font-weight: 700; letter-spacing: .02em; font-size: .9em; }   /* a number inside text (UiNums, link-row sides, choice columns) */
.stats--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 560px) { .num { font-family: var(--font-digits); font-weight: 700; letter-spacing: .02em; font-size: .9em; }   /* a number inside text (UiNums, link-row sides, choice columns) */
.stats--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- progress bar: a thin track and a fill (the workout panel; UiProgress / progress()) ---------- */
.progress { height: 4px; border-radius: 2px; background: var(--line-strong); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: var(--text-on-art); transition: width .3s linear; }

/* ---------- glass panel (HUD surfaces over the world): plain text, framed like the minimap ---------- */
.panel { background: var(--glass); backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px); border: var(--hud-border) solid var(--line-strong); border-radius: var(--r); padding: var(--s2) 14px;
  color: var(--text-on-art); font-variant-numeric: tabular-nums; }
.panel .stat__label { color: var(--text-on-art-muted); }
.panel--pill { border-radius: var(--r-pill); padding: var(--s1) var(--s3); }
.panel--round { border-radius: 40px; padding: 5px; }
.panel--lg { border-radius: var(--r-lg); padding: var(--s3) 14px; }

/* ---------- overlay, sheet, toast ---------- */
.overlay { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; overflow: auto; padding: calc(var(--s4) + var(--safe-t)) var(--s4) calc(var(--s4) + var(--safe-b));
  background: var(--scrim); backdrop-filter: blur(6px); }
.sheet { width: min(560px, 100%); max-height: 100%; overflow: auto; display: flex; flex-direction: column; gap: 14px; padding: var(--s5);
  background: var(--sheet-grad); border: 1px solid var(--line); border-radius: var(--r-xl); }
.toast { position: fixed; left: 50%; top: calc(var(--s4) + var(--safe-t)); transform: translateX(-50%); z-index: 100; max-width: min(92vw, 560px); text-align: center;
  padding: var(--s3) 18px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface-strong); font-weight: 600; box-shadow: var(--shadow); }

/* ---------- small things ---------- */
.tag { font-size: var(--fs-xs); padding: 2px 8px; border-radius: var(--r-pill); background: var(--gold-tint); color: var(--accent-2); font-weight: 700; }
.tag--custom { background: color-mix(in srgb, var(--custom) 20%, transparent); color: var(--tag-custom); }
.tag--z2 { background: color-mix(in srgb, var(--zone-2) 20%, transparent); color: var(--tag-z2); } .tag--z4 { background: color-mix(in srgb, var(--zone-4) 20%, transparent); color: var(--tag-z4); } .tag--z6 { background: color-mix(in srgb, var(--zone-6) 20%, transparent); color: var(--tag-z6); }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: var(--s2); vertical-align: -1px; box-shadow: 0 0 0 2px color-mix(in srgb, var(--shade) 40%, transparent); }
.note { background: color-mix(in srgb, var(--warn) 10%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); padding: 10px 14px; border-radius: var(--r-sm); font-size: var(--fs-sm); }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; padding: var(--s2) 0; border-top: 1px solid var(--line); min-height: var(--tap); }
.list-row:first-child { border-top: 0; }
.status { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--s2); padding: 6px 6px 6px 12px; border-radius: var(--r); background: var(--fill); font-size: var(--fs-sm); }
.status--ok { color: var(--ok); } .status--bad { color: var(--bad); } .status--busy { color: var(--warn); }
.status .btn { min-height: 40px; }
.chart { display: block; width: 100%; height: 64px; border-radius: var(--r-sm); background: var(--surface-sunk); }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.brand { color: var(--text); text-decoration: none; display: flex; align-items: center; gap: var(--s2); font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.brand__mark { display: block; width: 38px; height: 38px; border-radius: var(--r-sm); }
/* the brand as a link (title bars, cards): a pointer, and the tuna swims a little on hover */
a.brand { cursor: pointer; transition: color .2s; }
a.brand .brand__mark { transition: transform .45s var(--ease-bounce); }
@media (hover: hover) and (pointer: fine) {
  a.brand:hover { color: color-mix(in srgb, var(--text) 80%, var(--accent-2)); }
  a.brand:hover .brand__mark { transform: translateX(4px) rotate(-8deg) scale(1.08); }
}
@media (prefers-reduced-motion: reduce) { a.brand .brand__mark { transition: none; } a.brand:hover .brand__mark { transform: none; } }
.brand small { font-weight: 500; color: var(--text-muted); font-size: 13px; }

/* world artwork used by tiles (no images needed) */
.art-osnabrueck { background: var(--art-shade), var(--art-osnabrueck); }

/* ---------- avatar & dropdown menu (built on <details>, so it opens without JS) ---------- */
.avatar { position: relative; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; font-weight: 800; color: var(--ink); flex: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--light) 15%, transparent); }
.avatar__img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar--lg { width: 56px; height: 56px; font-size: 24px; }
/* the player picture on a profile: big, with a ring in the jersey colour; the initial stands in until pictures exist */
.avatar--xl { width: 112px; height: 112px; font-size: 48px; box-shadow: 0 0 0 4px var(--bg), 0 0 0 7px color-mix(in srgb, var(--ring, var(--accent)) 70%, transparent), var(--shadow); }
.avatar__badge { position: absolute; right: -6px; bottom: -6px; }
.avatar__badge .btn { min-height: 40px; width: 40px; border-radius: 50%; background: var(--surface-strong); }
/* hero card: the top of a profile, washed in the person's colour (--hero) */
.card--hero { --hero: var(--accent); border-color: color-mix(in srgb, var(--hero) 40%, var(--line));
  background: radial-gradient(120% 160% at 0% 0%, color-mix(in srgb, var(--hero) 30%, transparent), transparent 62%), var(--surface); }
.menu { position: relative; }
.menu > summary { list-style: none; display: flex; align-items: center; gap: var(--s2); min-height: var(--tap); padding: 0 var(--s2) 0 6px; border-radius: var(--r-pill);
  cursor: pointer; user-select: none; border: 1px solid transparent; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover, .menu[open] > summary { background: var(--fill); border-color: var(--line); }
.menu__caret { opacity: .7; font-size: 12px; }
.menu__list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 220px; padding: 6px; display: flex; flex-direction: column;
  background: var(--popover); backdrop-filter: var(--blur-glass); -webkit-backdrop-filter: var(--blur-glass);
  border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.menu__head { padding: 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu__item { display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 0 12px; border-radius: var(--r-sm); border: 0; background: none;
  color: var(--text); font: 600 var(--fs) var(--font); text-decoration: none; text-align: left; cursor: pointer; width: 100%; }
.menu__item:hover { background: var(--fill); }
.menu__item--danger { color: color-mix(in srgb, var(--bad) 55%, var(--light)); }
.menu__item form { display: contents; }

/* ---------- uniform sizes: grids give every item the same height; long text is clamped, not wrapped ---------- */
.grid--even { grid-auto-rows: 1fr; }
.grid--even > * { min-width: 0; }
.clamp-1, .clamp-2 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-1 { -webkit-line-clamp: 1; line-clamp: 1; } .clamp-2 { -webkit-line-clamp: 2; line-clamp: 2; }
.card__head h2 { min-width: 0; flex: 1 1 140px; }   /* actions wrap under the title when there is no room */
.card > .chart, .chart-box { flex: none; }
.chart-box { position: relative; }              /* a Vue chart: the canvas plus the glow / shine layers drawWorkout adds */
.card__foot { margin-top: auto; }

/* ---------- tab strip: big, scrollable tabs (worlds); grows to any number of items ---------- */
.tabstrip { display: flex; gap: var(--s2); overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 4px; scrollbar-width: thin; }
.tabstrip__tab { position: relative; flex: 0 0 auto; width: 190px; height: 76px; scroll-snap-align: start; display: flex; flex-direction: column; justify-content: flex-end;
  padding: 10px 12px; border-radius: var(--r); border: 2px solid var(--line); color: var(--text-on-art); text-align: left; font: inherit; cursor: pointer;
  text-shadow: var(--text-shadow); opacity: .6; transition: opacity .15s, border-color .15s, box-shadow .15s; }
.tabstrip__tab:hover { opacity: .9; }
.tabstrip__tab.is-on { opacity: 1; border-color: var(--accent); }
.tabstrip__title { font-weight: 700; font-size: 16px; }
.tabstrip__badge { position: absolute; top: 6px; right: 6px; font-size: 11px; background: color-mix(in srgb, var(--shade) 55%, transparent); padding: 2px 8px; border-radius: var(--r-pill); color: var(--ok); }
@media (max-width: 700px) { .tabstrip__tab { width: 150px; height: 64px; } .tabstrip__title { font-size: 15px; } }

/* ---------- choice list: one selectable row per option, stats in aligned columns ---------- */
.choices { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.choice { display: grid; grid-template-columns: 28px minmax(0, 1fr) repeat(var(--cols, 3), 84px); align-items: center; gap: var(--s3); min-height: 64px; padding: var(--s2) 14px;
  border: 0; border-top: 1px solid var(--line); background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.choice:first-child { border-top: 0; }
.choice:hover { background: var(--fill); }
.choice.is-on { background: var(--accent-tint); }
.choice__radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-strong); }
.choice.is-on .choice__radio { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 0 45%, transparent 50%); }
.choice__main { display: flex; flex-direction: column; min-width: 0; }
.choice__title { font-weight: 700; } .choice__desc { color: var(--text-muted); font-size: 13px; }
.choice__col { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.choice__col small { display: block; font-weight: 500; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
@media (max-width: 560px) {
  .choice { grid-template-columns: 24px repeat(var(--cols, 3), minmax(0, 1fr)); row-gap: 4px; }
  .choice__main { grid-column: 2 / -1; } .choice__radio { grid-row: 1 / span 2; }
  .choice__col { text-align: left; }
}

/* ---------- icons (Lucide, via icon() in ui.js) ---------- */
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
/* an icon in running text (card titles, headings, status lines, tags, chips) gets a little room before its words
   (--icon-gap); flex rows – buttons, menus, status pills – space theirs with gap instead */
:is(h1, h2, h3, h4, p, label, a, .chip, .tag, .note, .empty, .tile__title, .tile__meta, .link-row__title, .link-row__sub,
  .choice__title, .field__label, .tagline, .t-ok, .t-warn, .t-bad, .t-muted, .tabstrip__title, .stat__label, .step__title) > .icon { margin-inline-end: var(--icon-gap); }
:is(.btn, .menu__item, .menu > summary, .status, .check, .link-row, .titleback) > .icon { margin-inline-end: 0; }
.btn--round .icon { width: 24px; height: 24px; }
.btn--icon .icon { width: 20px; height: 20px; }
.icon--lg { width: 28px; height: 28px; }
.icon--spin { animation: spin 1s linear infinite; }

/* ---------- page header: back to home + title ---------- */
/* title-bar tabs (Home / Friends): the page you are on is lit in the accent colour */
.navtab { min-height: 44px; padding: 0 14px; color: var(--text-muted); }
.navtab.is-on { background: var(--accent-tint); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.titleback { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.titleback h1 { font-size: 20px; min-width: 0; }
.titleback .btn { flex: none; }
.pageactions { display: flex; justify-content: flex-end; gap: var(--s2); }

/* ---------- link row: a whole list row you can tap (preview lists on the home page) ---------- */
.link-row { display: flex; align-items: center; gap: var(--s3); min-height: 60px; padding: var(--s2) var(--s2) var(--s2) 4px; border-top: 1px solid var(--line);
  color: var(--text); text-decoration: none; cursor: pointer; background: none; border-left: 0; border-right: 0; border-bottom: 0; font: inherit; text-align: left; width: 100%; }
.link-row:first-child { border-top: 0; }
.link-row:hover { background: var(--fill); border-radius: var(--r-sm); }
.link-row__lead { flex: none; width: 44px; text-align: center; color: var(--accent-2); }
.link-row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.link-row__title { font-weight: 700; } .link-row__sub { color: var(--text-muted); font-size: 13px; }
.link-row__side { flex: none; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.link-row__side small { display: block; font-weight: 500; font-size: 11px; color: var(--text-muted); }
.link-row > .icon:last-child { color: var(--text-muted); }
.link-row--static { cursor: default; } .link-row--static:hover { background: none; }
.link-row__action { flex: none; }
@media (max-width: 560px) {
  :is(.link-row--static, .link-row:has(> .link-row__media)) { flex-wrap: wrap; row-gap: 8px; }
  :is(.link-row--static, .link-row:has(> .link-row__media)) .link-row__main { flex: 1 1 calc(100% - 60px); }      /* the name gets its own line … */
  :is(.link-row--static, .link-row:has(> .link-row__media)):has(.link-row__lead .avatar) .link-row__main { flex-basis: calc(100% - 76px); }   /* (next to a big avatar) */
  :is(.link-row--static, .link-row:has(> .link-row__media)):has(.link-row__lead .thumb--map-lg) .link-row__main { flex-basis: calc(100% - 96px); }
  :is(.link-row--static, .link-row:has(> .link-row__media)):has(.link-row__lead .thumb--map-lg) .link-row__side { margin-left: 88px; }
  :is(.link-row--static, .link-row:has(> .link-row__media)) .link-row__side { margin-left: 52px; text-align: left; } /* … time and preview below it … */
  :is(.link-row--static, .link-row:has(> .link-row__media)) .link-row__media { margin-left: auto; }
  .link-row__action { width: 100%; } .link-row__action .btn { width: 100%; } /* … and the button underneath */
}
.empty { color: var(--text-muted); font-size: var(--fs-sm); padding: var(--s2) 0; }
/* a bigger empty state: an icon in a soft circle and a sentence or two */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: var(--s3); padding: var(--s5) var(--s4); text-align: center; color: var(--text-muted); }
.empty-state__icon { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; background: var(--fill); color: var(--accent-2); }
.empty-state__icon .icon { width: 34px; height: 34px; }
.empty-state p { margin: 0; max-width: 420px; }

/* ---------- step list: workout steps (now / next) with their times ---------- */
.steps { display: flex; flex-direction: column; gap: 4px; }
.step { display: grid; grid-template-columns: 6px minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 6px 8px 6px 0; border-radius: var(--r-sm); }
.step.is-now { background: var(--fill); }
.step__bar { align-self: stretch; border-radius: 3px; }
.step__main { display: flex; flex-direction: column; min-width: 0; }
.step__label { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: var(--text-on-art-muted); }
.step__title { font-weight: 800; font-size: 20px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.step:not(.is-now) .step__title { font-size: 16px; }
.step__sub { font-size: 12px; color: var(--text-on-art-muted); }
.step__time { text-align: right; min-width: 52px; font-variant-numeric: tabular-nums; font-weight: 700; }
/* one compact line per step (a list of what comes next) */
.step--mini { padding: 1px 8px 1px 0; gap: 8px; }
.step--mini .step__main { flex-direction: row; align-items: baseline; gap: var(--s2); }
.step--mini .step__title, .step.step--mini:not(.is-now) .step__title { font-size: 14px; }
.step--mini .step__sub { font-size: 11px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step--mini .step__title { white-space: nowrap; flex: none; }
.step--mini .step__time { font-size: 13px; font-weight: 600; }
.step__of { font-weight: 600; color: var(--text-on-art-muted); }
.step__time small { display: block; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-on-art-muted); }
.title-link { color: inherit; text-decoration: none; } .title-link:hover { text-decoration: underline; }

/* ---------- thumbnails: little canvases drawn by previews.js (workout shape, route map, ridden track, elevation) ---------- */
.thumb { display: block; flex: none; border-radius: var(--r-sm); background: var(--surface-sunk); }
.thumb--workout { width: 240px; height: 68px; }
.thumb--map { width: 64px; height: 64px; background: var(--map-ground); }
.thumb--map-lg { width: 104px; height: 104px; background: var(--map-ground); border-radius: var(--r); }
@media (max-width: 560px) { .thumb--map-lg { width: 76px; height: 76px; } }
.thumb--elev { width: 100%; height: 26px; background: none; margin-top: 4px; }
.thumb--wide { width: 100%; height: 64px; }
.thumb--map-xl { width: 200px; height: 200px; background: var(--map-ground); border-radius: var(--r); }
@media (max-width: 560px) { .thumb--map-xl { width: 100%; height: 200px; } }
.thumb--big { width: 100%; height: 280px; background: var(--map-ground); border-radius: var(--r); }
.thumb--chart { width: 100%; height: 150px; background: none; }
.link-row__media { flex: none; }
.link-row__lead .thumb { margin: 0 auto; }
.link-row__lead:has(.thumb), .link-row__lead:has(.avatar) { width: auto; }
.link-row__lead > a { display: block; }
@media (max-width: 560px) { .thumb--workout { width: 170px; height: 54px; } .thumb--map { width: 56px; height: 56px; } .thumb--map-xl { width: 200px; height: 200px; background: var(--map-ground); border-radius: var(--r); }
@media (max-width: 560px) { .thumb--map-xl { width: 100%; height: 200px; } }
.thumb--big { height: 220px; } }

/* choice rows with a picture (route map); stacked when the list itself is narrow (phone, side column) */
.choices--media { container-type: inline-size; }
.choices--media .choice { grid-template-columns: 28px 64px minmax(0, 1fr) repeat(var(--cols, 3), 84px); }
.choice__media { display: flex; }
@container (max-width: 520px) {
  .choices--media .choice { grid-template-columns: 24px 56px repeat(var(--cols, 3), minmax(0, 1fr)); }
  .choices--media .choice__radio { grid-row: 1 / span 2; }
  .choices--media .choice__media { grid-column: 2; grid-row: 1 / span 2; }
  .choices--media .choice__main { grid-column: 3 / -1; }
  .choices--media .choice__col { grid-row: 2; }
}

/* the coloured aura around hard intervals (drawn by drawWorkout on an overlay canvas) – a steady glow */
.chart-glow { position: absolute; pointer-events: none; opacity: .6; }
/* alive only when you point at it (hover) or it is the selected workout (.is-alive): a shine sweeps across the bars
   (masked to their shape). Nothing moves otherwise; the glow stays steady. Transform only – cheap. */
.chart-shine { position: absolute; pointer-events: none; overflow: hidden; mask-size: 100% 100%; -webkit-mask-size: 100% 100%; mask-repeat: no-repeat; -webkit-mask-repeat: no-repeat; }
.chart-shine::before { content: ''; position: absolute; top: 0; bottom: 0; width: 40%; left: 0;
  background: linear-gradient(100deg, transparent, color-mix(in srgb, var(--light) 22%, transparent) 45%, color-mix(in srgb, var(--light) 32%, transparent) 50%, color-mix(in srgb, var(--light) 22%, transparent) 55%, transparent);
  transform: translateX(-120%); opacity: 0; }
:is(.card:not(:has(.card)), .link-row, .tile):hover .chart-shine::before, .is-alive .chart-shine::before { animation: chart-shine 2.4s ease-in-out infinite; }  /* only the card under the pointer, not its parent */
@keyframes chart-shine { 0% { transform: translateX(-120%); opacity: 1; } 55%, 100% { transform: translateX(300%); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .chart-shine::before { animation: none !important; } }

/* ---------- modal: a sheet over the page (openModal() in ui.js) ---------- */
.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b));
  background: var(--scrim); backdrop-filter: blur(6px); animation: modal-in .15s ease-out; }
.modal__sheet { width: min(620px, 100%); max-height: 100%; padding: 0; gap: 0; overflow: hidden; }
.modal__sheet--wide { width: min(1040px, 100%); height: 100%; }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s4) var(--s2) var(--s5); }
.modal__body { padding: var(--s2) var(--s5) var(--s4); overflow: auto; display: flex; flex-direction: column; gap: var(--s3); }
.modal__foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s2); padding: var(--s3) var(--s5) var(--s4); border-top: 1px solid var(--line); }
.modal__foot:empty { display: none; }
@keyframes modal-in { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 560px) { .modal { padding: 8px; align-items: end; } .modal__foot .btn { flex: 1; } }

/* options trigger (⋯): a clearly visible square icon button */
.menu--button > summary { width: 40px; min-height: 40px; padding: 0; justify-content: center; border-radius: var(--r-sm);
  background: var(--fill); border: 1px solid var(--line-strong); color: var(--text); }
.menu--button > summary .icon { width: 22px; height: 22px; }
.menu--button > summary:hover, .menu--button[open] > summary { background: var(--hover); border-color: var(--accent-2); color: var(--accent-2); }
/* a card with an open dropdown sits above its neighbours, so the menu is never covered by the next card */
.card:has(details.menu[open]) { position: relative; z-index: 40; }
/* square icon buttons next to a ⋯ menu (same 40 px size) */
.btn--square { width: 40px; min-height: 40px; border-radius: var(--r-sm); }
.btn--square .icon { width: 20px; height: 20px; }
/* a list of rows inside a card (Workouts library): rows separated by lines, like the Home lists */
.link-row__action .row { gap: 6px; }
@media (max-width: 560px) { .link-row__action .row { justify-content: flex-end; } .link-row__action .row .btn { width: auto; } }
.btn--square { flex: none; }
.link-row__action .row .btn--square { width: 40px; }
/* a card inside a card (e.g. workouts in the Library): a lighter, flatter surface so they read as part of the parent */
.card--inner { background: var(--surface-inner); border-color: color-mix(in srgb, var(--light) 8%, transparent); backdrop-filter: none; padding: 14px; box-shadow: none; }
.card--inner:hover { border-color: color-mix(in srgb, var(--light) 16%, transparent); }
/* a thin separating line, e.g. under a card's title before its content (like the first row line in list cards) */
.divider { border: 0; border-top: 1px solid var(--line); margin: 0; width: 100%; }
/* a small line of tags (+ a little text) under a title */
.tagline { display: flex; align-items: center; gap: 6px; margin-top: 4px; min-width: 0; }
.tagline .tag { flex: none; }
@media (max-width: 560px) { .chips { gap: 6px; } .chip { padding: 0 12px; } }
/* a title with a small note on the same line (e.g. workout name · time · TSS); the name shortens first */

/* ---------- press & hover: everything you can tap bounces a little (CSS only; values in tokens.css → motion) ----------
   Press: a quick squeeze; release: springs back with a small overshoot. Hover (mouse / trackpad only): small controls
   lift a pixel and brighten, tiles and tabs lift a little more; list rows keep their background highlight. */
.btn, .chip, .seg > button, .menu > summary, .menu__item { --press: var(--press-sm); --lift: var(--lift-sm); }
button.tile, button.card, .tabstrip__tab, .choice, .link-row:not(.link-row--static) { --press: var(--press-lg); --lift: var(--lift-lg); }
.choice, .link-row, .menu__item { --lift: 0px; }
:is(.btn, .chip, .seg > button, .menu > summary, .menu__item, button.tile, button.card, .tabstrip__tab, .choice, .link-row:not(.link-row--static)) {
  transition: transform var(--bounce-time) var(--ease-bounce), background-color .15s, border-color .15s, color .15s, filter .15s, opacity .15s; }
@media (hover: hover) and (pointer: fine) {
  :is(.btn, .chip, .seg > button, .menu > summary, button.tile, button.card, .tabstrip__tab):not(:disabled):hover { transform: translateY(var(--lift)); filter: brightness(var(--hover-bright)); }
  /* the lift moves the hit area too: a pointer resting at the bottom edge fell off the lifted control, lost the hover,
     the control dropped back under it, got hovered again … and the cursor flickered between the hand and the arrow.
     While hovered, the control reaches down past its lift (and the spring's overshoot), so it keeps the pointer. */
  :where(.btn, .chip, .seg > button, .menu > summary, button.tile, button.card, .tabstrip__tab) { position: relative; }
  :is(.btn, .chip, .seg > button, .menu > summary, button.tile, button.card, .tabstrip__tab):not(:disabled):hover::after {
    content: ""; position: absolute; left: 0; right: 0; top: 0; bottom: calc(var(--lift) * 3); }
}
:is(.btn, .chip, .seg > button, .menu > summary, .menu__item, button.tile, button.card, .tabstrip__tab, .choice, .link-row:not(.link-row--static)):not(:disabled):active {
  transform: scale(var(--press)); transition-duration: .07s; transition-timing-function: ease-out; }
@media (prefers-reduced-motion: reduce) {
  :is(.btn, .chip, .seg > button, .menu > summary, .menu__item, button.tile, button.card, .tabstrip__tab, .choice, .link-row):is(:hover, :active) { transform: none; }
}

/* ---------- the cursor: everything you can click shows the hand, disabled things say so. :where() keeps these weak, so a
   component's own cursor (the map's crosshair, a static link row, the zoom-in on a screenshot) still wins. ---------- */
:where(a[href], button, [role="button"], [role="tab"], [role="link"], [role="menuitem"], [role="option"], summary, select,
  input:is([type="checkbox"], [type="radio"], [type="range"], [type="submit"], [type="button"], [type="reset"], [type="file"], [type="color"]),
  label:has(> input:is([type="checkbox"], [type="radio"])), [data-act], [data-p], [data-modal-close]) { cursor: pointer; }
:where(button, input, select, textarea, [role="button"], [role="tab"]):is(:disabled, [aria-disabled="true"]) { cursor: not-allowed; }

/* ---------- page motion: a page fades + slides in, its cards rise in one after another (timings in tokens.css → motion).
   Only opacity / transform, filled backwards only – so nothing stays transformed (that would trap fixed children). ---------- */
@keyframes ui-rise { from { opacity: 0; transform: translateY(14px) scale(.985); } }
@keyframes ui-drop { from { opacity: 0; transform: translateY(-10px); } }
.page-enter-active { transition: opacity var(--page-in) ease, transform var(--page-in) cubic-bezier(.2, .8, .2, 1); }
.page-leave-active { transition: opacity var(--page-out) ease, transform var(--page-out) ease; }
.page-enter-from { opacity: 0; transform: translateY(10px); }
.page-leave-to { opacity: 0; transform: translateY(-6px); }
.page__in > * { animation: ui-rise var(--rise-time) cubic-bezier(.2, .8, .2, 1) backwards; }
.page__in > :nth-child(2) { animation-delay: calc(var(--rise-step) * 1); }
.page__in > :nth-child(3) { animation-delay: calc(var(--rise-step) * 2); }
.page__in > :nth-child(4) { animation-delay: calc(var(--rise-step) * 3); }
.page__in > :nth-child(5) { animation-delay: calc(var(--rise-step) * 4); }
.page__in > :nth-child(n + 6) { animation-delay: calc(var(--rise-step) * 5); }
.topbar { animation: ui-drop .5s cubic-bezier(.2, .8, .2, 1) backwards; }
/* the login / invite card: its parts come in one after another */
.auth-card > * { animation: ui-rise var(--rise-time) cubic-bezier(.2, .8, .2, 1) backwards; }
.auth-card > :nth-child(1) { animation-delay: .25s; } .auth-card > :nth-child(2) { animation-delay: .33s; }
.auth-card > :nth-child(3) { animation-delay: .41s; } .auth-card > :nth-child(4) { animation-delay: .49s; }
.auth-card > :nth-child(n + 5) { animation-delay: .57s; }
.auth-card form > * { animation: ui-rise var(--rise-time) cubic-bezier(.2, .8, .2, 1) backwards; }
.auth-card form > :nth-child(2) { animation-delay: .45s; } .auth-card form > :nth-child(3) { animation-delay: .52s; }
.auth-card form > :nth-child(n + 4) { animation-delay: .59s; }
@media (prefers-reduced-motion: reduce) {
  .page__in > *, .topbar, .auth-card > *, .auth-card form > * { animation: none !important; }
  .page-enter-active, .page-leave-active { transition: none; }
}
