/* Ippo design system, part 2: base styles and components for page content.
   Loaded only by pages on the new system (a template sets `ippo_ui = true`; see
   base.html). Tokens and the app shell are in ippo_shell.css, which loads first.
   The living reference is /dev/styles; this file is its production port.

   Rules: tokens only (no raw hex, no pixel font sizes outside the scale), no
   !important. A page may add at most one small stylesheet built on these tokens. */

/* ───────────────────────── Base ───────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; min-height: 100vh;
  font-family: var(--font); font-optical-sizing: auto; font-size: var(--fs-body); line-height: 1.5;
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--bnav-h) + var(--sab));
}
@media (min-width: 901px) {
  body { padding-bottom: var(--s6); }
}
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-ink); }
img { display: block; max-width: 100%; }
code { font-family: var(--mono); font-size: 0.86em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 5px; }
.code-block { margin: 0; padding: var(--s3); border-radius: var(--r-sm); background: var(--surface-2); font-family: var(--mono); font-size: var(--fs-cap); white-space: pre-wrap; overflow-wrap: anywhere; }
.break { overflow-wrap: anywhere; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
/* The id in :not() lifts this above any component's display rule, without !important. */
[hidden]:not(#ip-never) { display: none; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-2); }
.fw4 { font-weight: 400; }
.num { font-variant-numeric: tabular-nums; }

.t-display { font-size: var(--fs-display); line-height: 1.09; font-weight: 800; letter-spacing: -0.03em; }
.t-title { font-size: var(--fs-title); line-height: 1.2; font-weight: 750; letter-spacing: -0.02em; }
.t-h { font-size: var(--fs-h); line-height: 1.3; font-weight: 700; letter-spacing: -0.01em; }
.t-body { font-size: var(--fs-body); line-height: 1.5; }
.t-small { font-size: var(--fs-small); line-height: 1.43; font-weight: 500; }
.t-cap { font-size: var(--fs-cap); line-height: 1.33; font-weight: 600; letter-spacing: 0.02em; }

/* ───────────────────────── Layout ───────────────────────── */
.page {
  max-width: 640px; margin: 0 auto;
  padding: var(--s4) max(var(--s4), var(--sar)) var(--s6) max(var(--s4), var(--sal));
  display: flex; flex-direction: column; gap: var(--s4);
}
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); min-height: 52px; }
.page-head-back { margin: 0 -6px; }
.page-head-back > .t-h { flex: 1; text-align: center; }
.page-head-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blk { display: flex; flex-direction: column; }
.blk-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s2); min-height: 32px; }
.group-l { font-size: 0.8125rem; font-weight: 700; color: var(--ink-2); margin: 6px 4px -8px; }
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.wrap { display: flex; flex-wrap: wrap; gap: var(--s2); }

/* Flash messages from the server */
.alert {
  padding: var(--s3) var(--s4); border-radius: var(--r-md); cursor: pointer;
  background: var(--freeze-soft); color: var(--freeze); font-size: var(--fs-small); font-weight: 600;
}
.alert-autodismiss { cursor: pointer; transition: opacity 0.35s ease; }
.alert-autodismiss.is-leaving { opacity: 0; }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-warning { background: var(--warn-soft); color: var(--warn); }
.alert-error, .alert-danger { background: var(--danger-soft); color: var(--danger); }

/* ───────────────────────── Card ───────────────────────── */
.card { background: var(--surface); border-radius: var(--r-lg); border: 1px solid var(--card-line); box-shadow: var(--sh-1); }
.card-pad { padding: var(--s4); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); margin-bottom: 6px; }

/* ───────────────────────── Buttons ───────────────────────── */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 48px; padding: 0 20px; border-radius: var(--r-md);
  border: 1.5px solid transparent; font-size: var(--fs-body); font-weight: 700; line-height: 1.1;
  text-decoration: none; white-space: nowrap;
  transition: filter 0.12s ease, background-color 0.12s ease, transform 0.08s ease;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.07); }
.btn-secondary { background: var(--btn2-bg); color: var(--btn2-ink); border-color: var(--btn2-line); }
.btn-secondary:hover:not(:disabled) { filter: brightness(0.97); }
.btn-ghost { background: transparent; color: var(--accent-ink); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: var(--on-danger); }
.btn-danger-text { color: var(--danger); }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: var(--fs-small); border-radius: calc(var(--r-md) - 2px); gap: 6px; }
.btn-sm::after { content: ""; position: absolute; inset: -4px; }
.btn-block { width: 100%; }
.btn-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-pair > .btn { padding: 0 12px; }
.btn-pair > .btn:only-child { grid-column: 1 / -1; }
.btn:disabled { cursor: default; opacity: 0.55; }
.btn.is-done { opacity: 1; background: var(--success-soft); color: var(--success); border-color: transparent; }
.btn-icon {
  position: relative; width: 44px; height: 44px; flex: none; display: inline-grid; place-items: center;
  padding: 0; border: 0; border-radius: 999px; background: transparent; color: var(--ink);
  font-size: 1.375rem; font-weight: 600; line-height: 1;
}
.btn-icon:hover { background: var(--surface-2); }
.btn-icon-fill { background: var(--accent-soft); color: var(--accent-soft-ink); }
.btn-icon-fill:hover { background: var(--accent-soft); filter: brightness(0.97); }
.btn-icon-sm { width: 36px; height: 36px; }
.btn-icon-sm::after { content: ""; position: absolute; inset: -4px; }
.btn-icon-spacer { width: 44px; flex: none; }
.badge-n {
  position: absolute; top: 4px; right: 3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: var(--on-danger); font-size: var(--fs-cap); font-weight: 800; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--bg);
}
.link { display: inline-flex; align-items: center; min-height: 44px; font-size: 0.9375rem; font-weight: 600; color: var(--accent-ink); text-decoration: none; }

/* ───────────────────────── Fields ───────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-l { font-size: var(--fs-small); font-weight: 600; color: var(--ink); }
.field-err { font-size: 0.8125rem; color: var(--danger); font-weight: 500; }
.input {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1.5px solid var(--field-line); background: var(--field-bg); color: var(--ink);
  font-size: var(--fs-body); appearance: none; -webkit-appearance: none;
}
.input::placeholder { color: var(--ink-3); opacity: 1; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.is-error { border-color: var(--danger); }
.input-sm { min-height: 40px; }
textarea.input { padding: 12px 14px; min-height: 96px; resize: vertical; }
/* Radio choices: a bordered row per option, title + caption (visibility, report reasons) */
.choices { display: flex; flex-direction: column; gap: var(--s2); }
.choice {
  display: flex; align-items: flex-start; gap: var(--s3); min-height: 48px; padding: var(--s3);
  border: 1.5px solid var(--line); border-radius: var(--r-md); cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--primary); }
.choice > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.select, .input-ic { position: relative; display: block; }
.select .ic { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-2); pointer-events: none; }
.select .input { padding-right: 42px; }
.input-ic > .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.input-ic > .input { padding-left: 42px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 48px; font-size: 0.9375rem; }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; margin: 0;
  width: 52px; height: 32px; border-radius: 999px; background: var(--line-strong); transition: background-color 0.15s ease;
}
.switch::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--knob); box-shadow: var(--sh-knob); transition: transform 0.15s ease;
}
.switch::after { content: ""; position: absolute; inset: -6px -4px; } /* 44 px hit area, same look */
.switch:checked { background: var(--primary); }
.switch:checked::before { transform: translateX(20px); background: var(--knob-on); }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper .btn-icon { background: var(--surface-2); }
.stepper .num { min-width: 1.5ch; text-align: center; }
.stepper-sm { gap: 6px; }
.stepper-sm b { font-size: 1.0625rem; min-width: 1.5ch; text-align: center; }
.stepper .btn-icon:disabled { opacity: 0.35; cursor: default; filter: none; }
/* − [number unit] +, the stepper with a typed value (Journal trackers, lifts) */
.stepper-in { gap: 4px; }
.stepper .btn-icon:not(:disabled):hover { filter: brightness(0.97); }

/* Number field with its unit inside the box: the wrapper is the box and the
   number and unit sit side by side, so they never overlap (a long number
   scrolls in its own input; a long unit ellipsizes). .unit-field-wide fills
   the row (forms). */
.unit-field {
  display: flex; align-items: center; gap: 2px; min-width: 76px; max-width: 104px; min-height: 44px; padding: 0 6px;
  border: 1.5px solid var(--field-line); border-radius: var(--r-sm); background: var(--field-bg); cursor: text;
}
.unit-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--accent-soft); }
.unit-field .input {
  flex: 1 0 2.75em; width: 2.75em; min-width: 0; min-height: 40px; padding: 0;
  border: 0; border-radius: 0; background: none; text-align: center; font-weight: 700;
}
.unit-field:has(.unit-field-u:not(:empty)) .input { text-align: right; }
.unit-field .input:focus { box-shadow: none; }
.unit-field .input::placeholder { font-weight: 500; }
.unit-field-u {
  flex: 0 1 auto; min-width: 0; max-width: 4.5em; padding-left: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: var(--fs-cap); font-weight: 600; color: var(--ink-3);
}
.unit-field-u:empty { display: none; }
.unit-field-wide { width: 100%; max-width: none; min-height: 48px; padding: 0 14px; }
.unit-field-wide .input, .unit-field-wide:has(.unit-field-u:not(:empty)) .input { text-align: left; }
.unit-field-wide .unit-field-u { font-size: var(--fs-small); max-width: 8em; }

/* Scale chips: 1–5 (or 1–10, two rows) tap targets with optional labels */
.scale-chips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; width: 100%; }
.scale-chip {
  min-height: 48px; padding: 4px 2px; border-radius: var(--r-sm); border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; line-height: 1.15;
}
.scale-chip b { font-size: var(--fs-body); font-weight: 750; color: var(--ink); }
.scale-chip small { font-size: var(--fs-cap); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.scale-chip:hover { background: var(--surface-2); }
.scale-chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-soft-ink); }
.scale-chip[aria-pressed="true"] b { color: var(--accent-soft-ink); }
.scale-chips-10 .scale-chip { min-height: 44px; }

/* Day switcher: ‹ [day, tap for a date picker] › in a card */
.day-switch { display: flex; align-items: center; gap: var(--s1); padding: 6px; }
.day-switch .btn-icon:disabled { opacity: 0.35; cursor: default; background: transparent; }
.day-switch-mid {
  position: relative; flex: 1; min-width: 0; min-height: 44px; border-radius: var(--r-md);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; cursor: pointer;
}
.day-switch-mid:hover { background: var(--surface-2); }
.day-switch-t { font-size: var(--fs-h); font-weight: 750; line-height: 1.2; letter-spacing: -0.01em; }
.day-switch-s { font-size: var(--fs-cap); font-weight: 600; color: var(--ink-2); }
.day-switch-input {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer;
  border: 0; padding: 0; font-size: var(--fs-body);
}
.day-switch-input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.day-switch-mid:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ───────────────────────── List rows ───────────────────────── */
.list { padding: 4px 0; overflow: hidden; }
.row {
  position: relative; display: flex; align-items: center; gap: var(--s3); min-height: 64px; padding: 10px var(--s4);
  color: inherit; text-decoration: none;
}
a.row:hover, button.row:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
button.row { width: 100%; border: 0; background: transparent; text-align: left; font: inherit; }
.list > .row + .row::before { content: ""; position: absolute; top: 0; left: 68px; right: 0; height: 1px; background: var(--line); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.row-t { font-size: var(--fs-body); font-weight: 650; line-height: 1.35; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row-s { font-size: var(--fs-small); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-v { font-size: 0.9375rem; color: var(--ink-2); white-space: nowrap; }
.row-chev { color: var(--ink-3); margin-right: -4px; }
.row-lg { min-height: 84px; }
.row-t.t-h { font-size: var(--fs-h); font-weight: 700; }
.row-danger .row-t { color: var(--danger); }
/* A header inside a list card (e.g. the month on the workouts list) */
.list-h {
  margin: 0; padding: var(--s3) var(--s4) var(--s1);
  font-size: var(--fs-cap); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-2);
}
.list > .list-h:not(:first-child) { border-top: 1px solid var(--line); margin-top: var(--s1); padding-top: var(--s4); }
/* Label / value pairs (workout and badge details) */
.kv { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--s4); }
.kv > div { display: flex; flex-direction: column; gap: 1px; padding: 10px 0; border-top: 1px solid var(--line); min-width: 0; }
.kv dt { font-size: var(--fs-cap); font-weight: 600; color: var(--ink-2); }
.kv dd { margin: 0; font-size: var(--fs-body); font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
.tile { width: 40px; height: 40px; flex: none; border-radius: 12px; display: grid; place-items: center; }
.tile-lg { width: 52px; height: 52px; border-radius: 16px; }
.t-run, .t-accent { background: var(--accent-soft); color: var(--accent-soft-ink); }
.t-bike, .t-steps { background: var(--steps-soft); color: var(--steps); }
.t-lift, .t-rest { background: var(--rest-soft); color: var(--rest); }
.t-swim, .t-info { background: var(--freeze-soft); color: var(--freeze); }
.t-warn { background: var(--warn-soft); color: var(--warn); }
.t-success { background: var(--success-soft); color: var(--success); }
.t-danger { background: var(--danger-soft); color: var(--danger); }
.t-neutral { background: var(--surface-2); color: var(--ink-2); }

.av { width: var(--av, 40px); height: var(--av, 40px); flex: none; border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.av-28 { --av: 28px; } .av-32 { --av: 32px; } .av-44 { --av: 44px; } .av-52 { --av: 52px; } .av-56 { --av: 56px; } .av-64 { --av: 64px; } .av-72 { --av: 72px; } .av-88 { --av: 88px; }
.av-ring { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--accent); }

/* ───────────────────────── Chips & pills ───────────────────────── */
.chip {
  position: relative; display: inline-flex; align-items: center; gap: 6px; flex: none;
  min-height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink-2);
  font-size: var(--fs-small); font-weight: 650; white-space: nowrap;
}
.chip::after { content: ""; position: absolute; inset: -4px 0; }
.chip.is-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-soft-ink); }
.chip-freeze { background: var(--freeze-soft); border-color: transparent; color: var(--freeze); }
.chip-sm { min-height: 32px; padding: 0 12px; font-weight: 750; }
.chip-sm::after { inset: -6px 0; } /* 44 px hit area */
/* A row of chips that scrolls sideways, edge to edge inside a .page */
.chip-scroll {
  display: flex; gap: var(--s2); overflow-x: auto; margin: 0 calc(var(--s4) * -1); padding: 4px var(--s4) 6px;
  scrollbar-width: none;
}
.chip-scroll::-webkit-scrollbar { display: none; }
.chip-scroll .chip { flex: none; min-height: 40px; }
.chip-more { border-style: dashed; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; flex: none; height: 24px; padding: 0 10px; border-radius: 999px;
  font-size: var(--fs-cap); font-weight: 700; line-height: 1; white-space: nowrap; letter-spacing: 0.01em;
}
.pill-xs { height: 20px; padding: 0 7px; }
.pill-lg { height: 36px; padding: 0 14px; font-size: var(--fs-small); }
.p-success { background: var(--success-soft); color: var(--success); }
.p-warn { background: var(--warn-soft); color: var(--warn); }
.p-neutral { background: var(--surface-2); color: var(--ink-2); }
.p-info { background: var(--steps-soft); color: var(--steps); }
.p-accent { background: var(--accent-soft); color: var(--accent-soft-ink); }
.p-danger { background: var(--danger-soft); color: var(--danger); }

/* ───────────────────────── Segmented tabs ───────────────────────── */
.seg { display: inline-flex; gap: 2px; padding: 4px; border-radius: calc(var(--r-md) + 2px); background: var(--surface-2); }
.seg-full { display: flex; width: 100%; }
.seg-btn {
  position: relative; flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border: 0; border-radius: calc(var(--r-md) - 2px);
  background: transparent; color: var(--ink-2); font-size: var(--fs-small); font-weight: 650; white-space: nowrap;
}
.seg-btn[aria-selected="true"], .seg-btn[aria-checked="true"], .seg-btn.is-on { background: var(--seg-on); color: var(--ink); box-shadow: var(--sh-seg); }
.seg-btn::after { content: ""; position: absolute; inset: -4px -1px; } /* 48 px hit area */
.seg-sm .seg-btn { padding: 0 12px; }
.count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--primary); color: var(--on-primary); font-size: var(--fs-cap); font-weight: 750; line-height: 20px; }
.count-muted { background: var(--line); color: var(--ink-2); }

/* ───────────────────────── Progress ───────────────────────── */
.bar-wrap { display: flex; flex-direction: column; gap: 6px; }
.bar-top { display: flex; justify-content: space-between; gap: var(--s2); }
.bar-top b { font-weight: 800; color: var(--ink); }
.bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; width: var(--p, 0%); height: 100%; border-radius: inherit; background: var(--accent); }
.bar-sm { height: 8px; }
.bar-xs { height: 6px; width: 80%; }
.ring { --sz: 56px; position: relative; width: var(--sz); height: var(--sz); flex: none; display: grid; place-items: center; }
.ring > * { grid-area: 1 / 1; }
.ring > svg:not(.ic) { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke: var(--surface-2); stroke-width: 5; }
.ring .ring-v { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: var(--p, 0) 100; }
.ring b { font-size: 0.9375rem; font-weight: 800; }
.ring b small { font-size: 0.7em; color: var(--ink-2); font-weight: 700; }
.ring-done .ring-v { stroke: var(--success); }
.ring-done .ic { color: var(--success); }
.ring-lg { --sz: 76px; }
.ring-lg b { font-size: 1.25rem; }

/* ───────────────────────── Week view ───────────────────────── */
.week { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.day-l { font-size: var(--fs-cap); font-weight: 700; color: var(--ink-2); }
.day-dot { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; border: 2px solid transparent; }
.d-workout .day-dot { background: var(--accent); color: var(--on-accent); }
.d-steps .day-dot { background: var(--steps-soft); color: var(--steps); }
.d-rest .day-dot { background: var(--rest-soft); color: var(--rest); }
.d-freeze .day-dot { background: var(--freeze-soft); color: var(--freeze); }
.d-open .day-dot { border: 2px dashed var(--line-strong); }
.d-today .day-dot { border: 2px dashed var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.d-today .day-l { color: var(--accent-ink); }
.d-future .day-dot { border: 2px dashed var(--line); }
.d-future .day-l { color: var(--ink-3); }
/* Each day is one 44 px+ target; workout days are buttons that open the workout (_ippo_macros.week_day) */
.day-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; min-height: 64px;
  padding: 0; border: 0; border-radius: var(--r-sm); background: transparent; color: inherit; font: inherit;
}
button.day-btn:hover .day-dot { filter: brightness(1.06); }
.day.is-today .day-l { color: var(--accent-ink); }
.day.is-today:not(.d-today) .day-dot { box-shadow: 0 0 0 3px var(--day-gap, var(--surface)), 0 0 0 5px var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 14px; font-size: 0.8125rem; color: var(--ink-2); font-weight: 500; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; }
.lg-workout { background: var(--accent); color: var(--on-accent); }
.lg-steps { background: var(--steps-soft); color: var(--steps); }
.lg-rest { background: var(--rest-soft); color: var(--rest); }
.lg-freeze { background: var(--freeze-soft); color: var(--freeze); }
.lg-open { border: 2px dashed var(--line-strong); }

/* ───────────────────────── Stats strip ───────────────────────── */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; background: var(--surface); border: 1px solid var(--card-line); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.stats > div { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: var(--s3) 6px; text-align: center; }
.stats > div + div { border-left: 1px solid var(--line); }
.stats b { font-size: 1.375rem; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; gap: 3px; letter-spacing: -0.02em; }
.stats b .ic { color: var(--accent); }
.stats span { font-size: var(--fs-cap); font-weight: 600; color: var(--ink-2); }

/* ───────────────────────── Medals ───────────────────────── */
.medal {
  --m: 56px; position: relative; width: var(--m); height: var(--m); flex: none; border-radius: 50%;
  display: grid; place-items: center; color: var(--m-ink);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.35), inset 0 -6px 12px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(80, 40, 0, 0.18);
}
.medal .ic { stroke-width: 2.2; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.2)); }
.m-gold { background: var(--m-gold); }
.m-orange { background: var(--m-orange); }
.m-silver { background: var(--m-silver); }
.medal.is-locked { background: var(--surface-2); color: var(--ink-3); box-shadow: inset 0 0 0 2px var(--line); }
.medal.is-locked .ic { filter: none; }
.medal-lg { --m: 80px; }
.medal-empty { background: transparent; color: var(--ink-3); box-shadow: none; border: 2px dashed var(--line-strong); }

/* Pinned badges: three medals in a row (Home, Profile, Badges) */
.pins { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); }
.pins-card { background: var(--surface); border: 1px solid var(--card-line); border-radius: var(--r-lg); box-shadow: var(--sh-1); padding: var(--s3) var(--s2); }
.pin {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s1); min-width: 0;
  padding: var(--s2) var(--s1); border: 0; border-radius: var(--r-md); background: transparent; color: var(--ink); text-decoration: none;
}
button.pin:hover, a.pin:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.pin .medal { margin-bottom: 6px; }
.pin b { font-size: 0.8125rem; font-weight: 750; line-height: 1.25; overflow-wrap: anywhere; }
.pin > span:not(.medal) { font-size: var(--fs-cap); color: var(--ink-2); font-weight: 600; }
.pin-empty b { color: var(--ink-2); }

/* ───────────────────────── Sport picker (_sport_picker.html, sport_picker.js) ───────────────────────── */
.sp-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s2); }
.sp-tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; min-height: 72px; padding: 12px 2px 10px;
  border-radius: var(--r-md); border: 1.5px solid var(--line); background: var(--surface); color: var(--ink-2);
  font-size: 0.8125rem; font-weight: 650; line-height: 1.25; text-align: center;
}
.sp-tile > span {
  max-width: 100%; overflow: hidden; overflow-wrap: break-word; hyphens: auto;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.sp-tile[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-soft-ink); }
.sp-more[aria-checked="false"] { border-style: dashed; }
.sp-sheet { height: min(680px, calc(100% - var(--sat) - var(--s5))); }
.sp-sheet [hidden] { display: none; }
.sp-search { position: sticky; top: -6px; z-index: 1; margin: 0 -2px; padding: 6px 2px var(--s2); background: var(--surface); }
.sp-groups { display: flex; flex-direction: column; }
.sp-group + .sp-group { border-top: 1px solid var(--line); }
.sp-group > summary {
  display: flex; align-items: center; gap: var(--s3); min-height: 56px; cursor: pointer; list-style: none;
  font-weight: 650; color: var(--ink);
}
.sp-group > summary::-webkit-details-marker { display: none; }
.sp-gic { width: 36px; height: 36px; flex: none; display: inline-grid; place-items: center; border-radius: var(--r-sm); background: var(--surface-2); color: var(--ink-2); }
.sp-gl { flex: 1; min-width: 0; }
.sp-n { font-size: var(--fs-small); font-weight: 600; color: var(--ink-3); }
.sp-chev { color: var(--ink-3); transition: transform 0.15s ease; }
.sp-group[open] > summary .sp-chev { transform: rotate(180deg); }
.sp-list { display: flex; flex-direction: column; padding-bottom: var(--s2); }
.sp-opt {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2); min-height: 48px;
  padding: 0 var(--s2) 0 calc(36px + var(--s3)); border: 0; border-radius: var(--r-sm); background: none;
  color: var(--ink); font-size: var(--fs-body); font-weight: 550; text-align: left;
}
.sp-results .sp-opt { padding-left: var(--s2); }
.sp-opt:hover { background: var(--surface-2); }
.sp-opt .ic { color: var(--accent-ink); visibility: hidden; }
.sp-opt[aria-current="true"] { color: var(--accent-ink); font-weight: 700; }
.sp-opt[aria-current="true"] .ic { visibility: visible; }
.sp-none { margin: var(--s2) 0 0; }

/* ───────────────────────── Workout sheet (Ippo.workoutSheet) ───────────────────────── */
.wk { display: flex; flex-direction: column; gap: var(--s4); }
.wk-head { display: flex; align-items: center; gap: var(--s3); }
.wk-when { font-size: var(--fs-small); color: var(--ink-2); font-weight: 500; }
.wk-stats { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); box-shadow: none; }

/* Badge detail sheet */
.bdg { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s1); }
.bdg .medal { margin-bottom: var(--s2); }
.bdg .kv { width: 100%; margin-top: var(--s3); text-align: left; }
.bdg-reacts { justify-content: center; margin-top: var(--s2); }

/* Emoji reactions (Ippo.reactions: badge sheet, feed) */
.reacts { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.react {
  position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; min-width: 44px; padding: 0 12px;
  border-radius: 999px; border: 1.5px solid transparent; background: var(--surface-2); color: var(--ink-2);
  font-size: var(--fs-small); font-weight: 750; justify-content: center;
}
button.react::after { content: ""; position: absolute; inset: -4px -1px; }
button.react:hover { filter: brightness(0.97); }
.react.is-mine { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-soft-ink); }
.react:disabled { opacity: 0.6; }
.emo { font-size: 1rem; line-height: 1; }
.react-add { color: var(--ink-2); border-color: var(--line); background: transparent; }
.react-add .ic { flex: none; }
/* Emoji picker in a sheet (feed and badge reactions, group cheers) */
.emoji-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.emoji-grid .btn { font-size: 1.5rem; min-height: 56px; }
.emoji-grid .btn.is-mine { background: var(--accent-soft); border-color: var(--accent); }

/* ───────────────────────── Empty & skeleton ───────────────────────── */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s2); padding: 28px var(--s5); }
/* Ippo in an empty state: a whole figure from static/img/cast/ (140 x 150), not cropped */
.empty-img { width: 104px; height: auto; aspect-ratio: 140 / 150; object-fit: contain; margin-bottom: 2px; }
/* A character doing a workout (static/img/cast/<id>-<pose>.svg): one per card in the feed,
   group activity and plans, always 64px wide */
.cast-pose { flex: none; width: 64px; height: auto; aspect-ratio: 140 / 150; }
/* A person's avatar in an empty state: a round head, like other avatars */
.empty-img.empty-av { width: 96px; aspect-ratio: 1; border-radius: 50%; margin-bottom: 6px; }
.empty .btn { margin-top: var(--s2); }
.empty .t-small { max-width: 30ch; }
.sk {
  display: block; border-radius: 8px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 45%, var(--surface-2) 65%);
  background-size: 300% 100%; animation: sk 1.4s ease-in-out infinite;
}
.sk-av { width: 44px; height: 44px; border-radius: 50%; flex: none; }
.sk-l { height: 14px; }
.sk-s { height: 12px; margin-top: 8px; }
@keyframes sk { from { background-position: 100% 0; } to { background-position: 0 0; } }

@media (prefers-reduced-motion: reduce) {
  .sk { animation: none; }
  .btn, .switch, .switch::before { transition: none; }
}

/* ───────── Chart (Ippo.chart in ippo.js) ───────── */
.chart { position: relative; min-height: 180px; transition: opacity 0.15s ease; }
.chart.is-loading { opacity: 0.5; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis { stroke: var(--line-strong); stroke-width: 1; }
.chart-tick { fill: var(--ink-2); font-size: var(--fs-cap); font-weight: 600; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart-band { fill: var(--accent-soft); opacity: 0.85; }
.chart-goal { stroke: var(--ink-2); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart-line { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart-line.s1 { stroke: var(--accent); }
.chart-line.s2 { stroke: var(--rest); }
.chart-dot { stroke: var(--surface); stroke-width: 2; }
.chart-dot.s1, .chart-bar.s1 { fill: var(--accent); }
.chart-dot.s2, .chart-bar.s2 { fill: var(--rest); }
.chart-cross { stroke: var(--ink-3); stroke-width: 1; }
.chart-halo { fill: none; stroke: var(--ink); stroke-width: 2; }
.chart-tip {
  position: absolute; z-index: 2; pointer-events: none; display: flex; flex-direction: column; gap: 1px;
  padding: 6px 10px; border-radius: var(--r-sm); background: var(--toast-bg); color: var(--toast-ink);
  font-size: var(--fs-cap); font-weight: 600; white-space: nowrap; box-shadow: var(--sh-2);
}
.chart-tip b { font-weight: 750; }
.chart-tip-w { opacity: 0.85; }
.chart-empty { display: grid; place-items: center; min-height: 180px; text-align: center; padding: 0 var(--s4); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px var(--s4); color: var(--ink-2); }
.chart-legend:empty { display: none; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-sw { display: inline-block; width: 14px; height: 4px; border-radius: 2px; }
.chart-sw.s1 { background: var(--accent); }
.chart-sw.s2 { background: var(--rest); }
.chart-sw-goal { height: 0; border-top: 2px dashed var(--ink-2); border-radius: 0; }
.chart-sw-band { width: 10px; height: 12px; background: var(--accent-soft); border-radius: 2px; }

/* ───────── Member colors (groups): `mc-N` sets --mc for slot N, `mc-o` the rest of the group.
   Moved from groups.css when Home's groups preview needed them (tokens in ippo_shell.css). ───────── */
.mc-1 { --mc: var(--member-1); }
.mc-2 { --mc: var(--member-2); }
.mc-3 { --mc: var(--member-3); }
.mc-4 { --mc: var(--member-4); }
.mc-5 { --mc: var(--member-5); }
.mc-6 { --mc: var(--member-6); }
.mc-7 { --mc: var(--member-7); }
.mc-8 { --mc: var(--member-8); }
.mc-9 { --mc: var(--member-9); }
.mc-10 { --mc: var(--member-10); }
.mc-11 { --mc: var(--member-11); }
.mc-12 { --mc: var(--member-12); }
.mc-o { --mc: var(--member-others); }
