/* The page-agnostic controls and surfaces (prototypes/design-system/README.md,
   decisions 1 and 4): what three or more pages draw, each drawing tokens.css.
   Every page loads tokens.css, then this file, then its own CSS. The sheet,
   prototypes/design-system/mockup.html, links this file and shows every control
   in every state: a control it lacks is added here and there before a page draws
   it. Page namespaces (.match-, .coach-, .pt-, .pk-, .up-, .lb-) stay in
   styles.css. The one thing here that is not a control: the layout utilities at the
   end (decision 15), which sit here because the legal pages and lab_compress load no styles.css. */

/* ───────── Buttons ───────── */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
  border: 1px solid transparent;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-tight-1);
  padding: var(--space-8) var(--space-16);
  border-radius: var(--radius-control);
  cursor: pointer;
  /* Named, not `all`: an eased visibility would keep a button painting for a beat
     after the layer holding it hides (layer-order.spec, sm0o.22). */
  transition-property: background-color, border-color, color, box-shadow, filter, transform, opacity;
  transition-duration: var(--dur-fast);
  transition-timing-function: var(--ease-out);
  white-space: nowrap;
  text-decoration: none;
  line-height: var(--lh-tight);
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; transform: none; filter: none; }
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border-btn);
}
/* --surface-3, not --surface: a ghost button sits on a --surface card as often as
   on the page, and --surface hovered there is no fill at all. */
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
/* The loading state of a button, and of a line that waits (the pack page's Top
   up and its "on the way", the upload gate's checking line, the invite card's
   Claiming, the render line's "Rendering…"): a 14px ring in the ink of what
   holds it, turning with status-turn (below) at --dur-spin. Beside a label, in
   a flex row; the caller disables a button, and the ring is a span inside it.
   A page sizes it with --spin-size: 12px on the invite button and the render
   line, 32px for the export render screen's ring. A stand-alone ring (the
   export ring, the render line) is coloured var(--accent) where it is placed;
   in-button and in-line rings take their holder's ink. The ring on a
   video scrim (.mp2-spin) and the step mark (.vp-mark) are not this ring. */
.btn-spin { flex: none; width: var(--spin-size, 14px); height: var(--spin-size, 14px); border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; }
/* A disabled ghost button (the match page's Invite before its player analytics
   answer, ws9c.1). Its own rule: only .btn-primary had a disabled look. */
.btn-ghost:disabled,
.btn-ghost:disabled:hover { opacity: 0.5; cursor: not-allowed; background: transparent; color: var(--text-2); }
.btn-quiet {
  background: transparent;
  color: var(--muted);
  padding: var(--space-8);
}
.btn-quiet:hover { color: var(--text); background: var(--surface-3); }
.btn-quiet:disabled,
.btn-quiet:disabled:hover { opacity: 0.5; cursor: not-allowed; background: transparent; color: var(--muted); }
/* The button is sized against its hit target, not against prose (ADR-054):
   14.5px is the one size in this file that is not a token. */
.btn-lg { padding: var(--space-12) var(--space-20); font-size: 14.5px; border-radius: var(--radius); }
.btn-sm { padding: var(--space-8); font-size: var(--fs-status); border-radius: var(--radius-sm); }
.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: color-mix(in oklab, var(--danger) 35%, var(--border));
}
.btn-danger:hover {
  background: color-mix(in oklab, var(--danger) 12%, transparent);
  color: var(--danger);
}
/* The pill (g2fr.32): Save and Cancel of an edit made in place, on the match
   page's details editor and rename and on the profile's name. 32px, a full pill,
   0 16px on both, as the details editor's foot had it (esei.47), on a primary
   (Save) or a quiet button (Cancel), which the pill fills surface-3 in text ink
   (and gives back the 16px sides .btn-quiet takes away). Was the details editor's own look (.up-foot,
   prototypes/match-details-v3/README.md, pills on a foot row). */
.btn-pill { height: 32px; padding: 0 var(--space-16); border-radius: var(--radius-pill); }
.btn-pill.btn-quiet,
.btn-pill.btn-quiet:disabled:hover { background: var(--surface-3); color: var(--text); }
.btn-pill.btn-quiet:hover { background: var(--border-2); }

.icon-btn {
  appearance: none;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  border-radius: var(--radius-control);
  cursor: pointer;
  /* Named, not `all`, as .btn: only what hover and disabled change animates. */
  transition-property: background-color, border-color, color, opacity;
  transition-duration: var(--dur-fast);
  transition-timing-function: var(--ease-out);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-2); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }
.icon-btn:disabled:hover { color: var(--text-2); border-color: var(--border); }
/* 16px glyph (the owner's call over 14, esei.14). This beats the width and
   height attributes of every svg inside an icon button; the player's own rules
   are more specific and keep their 20 and 22. flex: none because a button's
   default padding leaves a 24 or 28px icon button less than 16 to shrink into. */
.icon-btn svg { flex: none; width: 16px; height: 16px; }
/* The ring is --accent: dark green, and the light one inside the player's dark
   skin, whose scope in tokens.css renames it. */
.btn:focus-visible, .icon-btn:focus-visible, .btn-link:focus-visible, .btn-cta:focus-visible, .admin-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .btn, .icon-btn, .btn-cta { transition: none; } }

/* A 28px square with no frame: a tool on a surface that is framed already (the
   coach rail's Hide). The glyph is the caller's. Moved verbatim from the coach's
   Hide button; the match page's score info button draws it too (sm0o.2, g2fr.25). */
.icon-btn-quiet {
  appearance: none;
  display: grid;
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-control);
  background: none;
  color: var(--muted);
  place-items: center;
  cursor: pointer;
}
.icon-btn-quiet:hover { background: var(--surface-2); color: var(--text); }
.icon-btn-quiet:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* A row in a menu or listbox: a 14px leading cell (blank, or the tick of a
   chosen row), the label, a trailing note; 34px tall. Moved verbatim from the
   coach's @ menu; the library card's menu draws it (sm0o.7), and the match page's
   menus (sm0o.2); .xm-row is not a menu row. .is-hi is the row a keyboard has
   reached while focus stays in the field. */
.menu-item {
  appearance: none;
  min-width: 0;
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-8);
  height: 34px;
  padding: 0 var(--space-8);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: var(--fs-body);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.menu-item::before { content: ""; width: 12px; height: 12px; }
.menu-item.is-on { color: var(--text); font-weight: var(--fw-medium); }
.menu-item.is-on::before { background: var(--accent); -webkit-mask: var(--icon-check) center / contain no-repeat; mask: var(--icon-check) center / contain no-repeat; }
.menu-item:hover, .menu-item:focus-visible, .menu-item.is-hi { background: var(--surface-3); color: var(--text); outline: 0; }
/* Keyboard focus is a ring as well as the fill, which alone is as faint as hover
   (the .seg ring, inside the row). .is-hi is a highlight, focus stays in the
   field, so it draws none. */
.menu-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
/* After the hover rule: a destructive row keeps its ink on hover and focus. */
.menu-item.danger { color: var(--danger); }

/* The one panel every dropdown and popover draws (sm0o.16, prototypes/menu-panel/):
   the page's surface, a 1px ring, --shadow-float and 10px corners, the row's 6px
   plus the 4px in. System tokens only, so inside the player's dark scope
   (tokens.css) it turns dark with the picture's chrome; there is no dark variant. Showing and
   hiding, position, z-index, max-height and scrolling are the caller's. */
.menu {
  padding: var(--space-4);
  border-radius: var(--radius);
  border: 0;   /* a [popover] gets the UA's solid border; the edge is the ring below */
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 var(--ring-1) var(--border-2), var(--shadow-float);
  /* Forced colours drop box-shadow; this outline is that mode's edge, unseen otherwise. */
  outline: 1px solid transparent;
  outline-offset: -1px;
}
/* A popover with content (a label, a foot, controls): the same panel, 12px in. */
.menu.menu-pop { padding: var(--space-12); }

/* ───────── Surfaces & primitives ───────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  color: var(--muted);
  line-height: var(--lh-none);
}

/* A tooltip (sw5g.17): a control's name, what it does and its key, on --tip-bg
   (tokens.css :root, so it reads the same inside a dark scope, sw5g.26).
   One element per page (role="tooltip"), shown by the page's script after a pause
   and placed with --tip-x and --tip-y (viewport px); it never takes the pointer. */
.tooltip {
  position: fixed;
  left: var(--tip-x, 0);
  top: var(--tip-y, 0);
  z-index: var(--z-toast);
  max-width: 260px;
  padding: var(--space-4) var(--space-8);
  border-radius: var(--radius-control);
  background: var(--tip-bg);
  color: var(--tip-ink);
  font-size: var(--fs-sub);
  line-height: var(--lh-snug);
  box-shadow: var(--shadow-float);
  pointer-events: none;
}
.tooltip[hidden] { display: none; }
.tooltip b { font-weight: var(--fw-medium); }
.tooltip .kbd { margin-left: var(--space-4); border-color: transparent; background: var(--on-video-16); color: var(--on-video); }
.tooltip .kbd + .kbd { margin-left: var(--space-2); }
.tooltip-desc { display: block; margin-top: var(--space-2); color: var(--on-video-84); }

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--muted);
}

/* Chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-8);
  height: 24px;
  padding: 0 var(--space-8);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  /* ADR-054: the meta step, not 11.5px. The chip is shared, and this is the
     full list of what else draws it — the signed-out landing hero (three of
     them, the first thing a visitor sees), the account, clip-export,
     shared-match and video-detail screens, and the library card's fact pills. It is taken to the scale globally
     rather than overridden on the card, because one component at two sizes is
     the drift this change deletes. The box is a fixed 24px tall, so nothing
     above it moves on any of them. */
  font-size: var(--fs-meta);
  color: var(--text-2);
  font-family: var(--font-mono);
}
.chip-accent {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
}
.chip-warn {
  background: var(--warn-soft);
  border-color: var(--warn-line);
  color: var(--warn);
}
.chip-danger {
  background: var(--danger-soft);
  border-color: var(--danger-line);
  color: var(--danger);
}

/* Status tag (G2: prototypes/palette/status-blue.html, prototypes/player-
   credits decision 12). The one chip that states a match's status, on the
   library, the match page, the upload card and admin, and the nav balance
   (.st-balance); count and fact chips keep
   the mono .chip above. A tinted tag in Geist, not mono, with a 12px glyph in
   its own ink: status never relies on colour alone. The state class picks the
   tint and the glyph together; processing is the neutral base, its arc
   turning. Every ink reaches 4.5:1 on its own wash over white (info 5.3,
   ready 5.6, warn 4.7, danger 5.8, processing 4.9). */
.status-tag {
  --st-ink: var(--muted);
  --st-wash: var(--surface-3);
  --st-line: var(--border-2);
  --st-glyph: var(--icon-arc);
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
  height: 24px;
  padding: 0 var(--space-8);
  border-radius: var(--radius-sm);
  border: 1px solid var(--st-line);
  background: var(--st-wash);
  color: var(--st-ink);
  font-family: var(--font-sans);
  font-size: var(--fs-status);
  font-weight: var(--fw-medium);
  line-height: var(--lh-none);
  white-space: nowrap;
}
.status-tag::before {
  content: "";
  flex: none;
  width: 12px; height: 12px;
  background: currentColor;
  -webkit-mask: var(--st-glyph) center / contain no-repeat;
  mask: var(--st-glyph) center / contain no-repeat;
}
.status-tag.st-processing::before, .btn-spin { animation: status-turn var(--dur-spin) linear infinite; }
@media (prefers-reduced-motion: reduce) { .btn-spin { animation: none; } }
@keyframes status-turn { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .status-tag::before { animation: none !important; }
}
.status-tag.st-uploading { --st-ink: var(--info); --st-wash: var(--info-soft); --st-line: var(--info-line); --st-glyph: var(--icon-up); }
.status-tag.st-pending { --st-ink: var(--info); --st-wash: var(--info-soft); --st-line: var(--info-line); --st-glyph: var(--icon-clock); }
.status-tag.st-ready { --st-ink: var(--accent); --st-wash: var(--accent-soft); --st-line: var(--accent-line); --st-glyph: var(--icon-check); }
/* Paused by the person: neutral like processing, but nothing is turning. */
.status-tag.st-paused { --st-glyph: var(--icon-pause); }
/* Not enough balance, and a partial upload ("2 of 3 uploaded"): attention. */
.status-tag.st-attention { --st-ink: var(--warn); --st-wash: var(--warn-soft); --st-line: var(--warn-line); --st-glyph: var(--icon-alert); }
/* Failed, and every other dead end the upload card names (stopped, expired,
   discarded, not started). */
.status-tag.st-failed { --st-ink: var(--danger); --st-wash: var(--danger-soft); --st-line: var(--danger-line); --st-glyph: var(--icon-x); }
/* The nav balance (frrx.16) takes the tint of its tone (ready, attention,
   failed) but always the clock: it counts time left, it is not a match's state. */
.status-tag.st-balance { --st-glyph: var(--icon-clock); }
/* Beta is not a status, so no glyph (lsrn.50); the accent's tint. Its height is each
   context's own: the coach's head, the AI coach button. */
.status-tag.st-beta { --st-ink: var(--accent); --st-wash: var(--accent-soft); --st-line: var(--accent-line); }
.status-tag.st-beta::before { content: none; }
/* A label that is not a state (admin's "hidden", "pair", "survey"; sm0o.21): the neutral tag, no glyph. */
.status-tag.st-label::before { content: none; }

/* Form inputs */
.input,
.select,
.field input,
.field textarea,
.field select {
  appearance: none;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-8) var(--space-12);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  width: 100%;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
/* After the rule it undoes: a media query adds no specificity. */
@media (prefers-reduced-motion: reduce) { .input, .select, .field input, .field textarea, .field select { transition: none; } }
.input::placeholder,
.field input::placeholder,
.field textarea::placeholder { color: var(--muted); }
.input:disabled,
.select:disabled,
.field input:disabled,
.field textarea:disabled,
.field select:disabled { opacity: 0.5; cursor: not-allowed; }
.input:focus,
.select:focus,
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
/* 16px: under it iOS Safari zooms the page when the field takes focus. Where no
   focus zoom exists the field takes the body step, as the select does below. A
   threshold, not a step: the gate's exception list names `.input` and `.select`. */
.input { font-size: 16px; }
@media (hover: hover) and (pointer: fine) { .input { font-size: var(--fs-body); } }
/* The same threshold for the bare controls inside a .field (esei.39); the
   gate's exception list (OFF_SCALE_ELSEWHERE) has its own row for this selector. */
.field input, .field textarea, .field select { font-size: 16px; }
@media (hover: hover) and (pointer: fine) { .field input, .field textarea, .field select { font-size: var(--fs-body); } }
.select {
  /* 16px: under it iOS Safari zooms the page when the select takes focus. Where
     no focus zoom exists the select takes the field's body step. */
  font-size: 16px;
}
@media (hover: hover) and (pointer: fine) { .select { font-size: var(--fs-body); } }
/* The select is the field's chrome with a chevron; the padding keeps text
   off it. */
.select, .field select {
  background-image: var(--icon-chevron);
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  padding-right: var(--space-32);
  cursor: pointer;
}
.field { display: flex; flex-direction: column; gap: var(--space-8); }
.field label {
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--muted);
}
.field textarea { min-height: 72px; resize: vertical; }
/* Hint and error under a field. No page draws them yet; decision 4 names them. */
.field .hint { font-size: var(--fs-sub); color: var(--muted); }
.field .error { font-size: var(--fs-sub); color: var(--danger); }
/* The error look, in a .field (.is-invalid on the holder) or on a bare .input or
   .select that says it itself with aria-invalid="true" (sm0o.22: the admin forms,
   which set it for a screen reader already): the danger edge, and the danger halo
   in place of the accent one while focused. */
.field.is-invalid :is(input, textarea, select, .select),
:is(.input, .select)[aria-invalid="true"] { border-color: var(--danger); }
.field.is-invalid :is(input, textarea, select, .select):focus,
:is(.input, .select)[aria-invalid="true"]:focus { box-shadow: 0 0 0 var(--ring-3) var(--danger-soft); }

/* Input group (sm0o.22): a holder that is an .input too, so it draws the field's
   frame, around a bare input and what sits beside it (a search glyph, a Copy
   button). The input inside draws no frame, fill or outline of its own; the
   holder takes the focus ring while anything in it has focus. */
.input-group { display: flex; align-items: center; gap: var(--space-8); }
.input-group:focus-within { border-color: var(--accent); box-shadow: var(--shadow-focus); }
.input-group input {
  flex: 1;
  min-width: 0;
  appearance: none;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  outline: 0;
  color: inherit;
  font: inherit;
}
.input-group input::placeholder { color: var(--muted); }

/* The switch (padel-website-frrx.28): a native <input type="checkbox" role="switch" class="switch">
   drawn 34x20, accent when on; off, a --muted-2 track and border under a white thumb (3.13:1 on white, WCAG 1.4.11;
   frrx.32). */
.switch {
  appearance: none;
  flex: none;
  position: relative;
  width: 34px;
  height: 20px;
  margin: 0;
  border: 1px solid var(--muted-2);
  border-radius: var(--radius-pill);
  background: var(--muted-2);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-thumb);
  transition: transform var(--dur-base) var(--ease-out);
}
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { transform: translateX(14px); }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch:disabled { opacity: 0.5; cursor: default; }
@media (prefers-reduced-motion: reduce) { .switch, .switch::after { transition: none; } }
/* Forced colours paint every background as Canvas, which would hide the thumb and the on state. */
@media (forced-colors: active) {
  .switch::after { background: CanvasText; }
  .switch:checked { background: Highlight; border-color: Highlight; }
  .switch:checked::after { background: HighlightText; }
}
/* The small size, 28x16: same switch. No page draws it since the Rallies toolbar
   went (lsrn.89); the design-system mockups still show it. */
.switch.switch-sm { width: 28px; height: 16px; }
.switch.switch-sm::after { width: 10px; height: 10px; }
.switch.switch-sm:checked::after { transform: translateX(12px); }

/* Choice controls: one checkbox, one radio, one switch, each drawn on the
   native input so the label, the keyboard, the change event and the form stay
   the browser's. The hit target is the .choice row, not the box. */
.checkbox, .radio {
  appearance: none;
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0;
  border: 1px solid var(--border-control);
  background: var(--bg-2);
  cursor: pointer;
  display: inline-grid;
  place-content: center;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.checkbox { border-radius: var(--radius-xs); }
.radio { border-radius: var(--radius-pill); }
.checkbox::after, .radio::after {
  content: "";
  transform: scale(0);
  transition: transform var(--dur-base) var(--ease-out);
}
.checkbox::after {
  width: 12px; height: 12px;
  background: var(--accent-ink);
  -webkit-mask: var(--icon-check) center / contain no-repeat;
  mask: var(--icon-check) center / contain no-repeat;
}
.radio::after { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.checkbox:checked { background: var(--accent); border-color: var(--accent); }
.radio:checked { border-color: var(--accent); }
.checkbox:checked::after, .radio:checked::after { transform: scale(1); }
.checkbox:hover:not(:disabled), .radio:hover:not(:disabled) { border-color: var(--muted); }
.checkbox:checked:hover:not(:disabled) { border-color: var(--accent); }
.checkbox:focus-visible, .radio:focus-visible, .select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.checkbox:disabled, .radio:disabled { opacity: 0.5; cursor: default; }
/* A box that shows a state it does not own (sm0o.9): the picker's set and game
   headers are buttons that tick every rally under them, so the box is a span
   inside the button, never an input. It takes .is-checked or .is-mixed. A span is
   never :disabled, so a filled box keeps its accent border on hover by its own
   rule, and a box inside a disabled button does not answer the pointer. */
.checkbox.is-checked, .checkbox.is-mixed { background: var(--accent); border-color: var(--accent); }
.checkbox.is-checked::after { transform: scale(1); }
.checkbox.is-mixed::after {
  width: 10px; height: 2px;
  border-radius: var(--radius-2xs);
  -webkit-mask: none;
  mask: none;
  transform: scale(1);
}
.checkbox:is(.is-checked, .is-mixed):hover { border-color: var(--accent); }
button:disabled .checkbox:not(.is-checked):not(.is-mixed):hover { border-color: var(--border-control); }
/* Forced colours paint every background as Canvas, which would hide the tick, the dot and the on state. */
@media (forced-colors: active) {
  .checkbox:checked, .checkbox.is-checked, .checkbox.is-mixed { background: Highlight; border-color: Highlight; }
  .checkbox::after { background: HighlightText; }
  .radio:checked { border-color: Highlight; }
  .radio::after { background: Highlight; }
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-8);
  min-height: 24px;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-snug);
  color: var(--text);
  cursor: pointer;
}
.choice > .checkbox, .choice > .radio { margin-top: 1px; }
.choice .sub { display: block; font-size: var(--fs-sub); color: var(--muted); }
.choice:has(:disabled) { color: var(--muted); cursor: default; }
@media (prefers-reduced-motion: reduce) { .checkbox, .radio, .checkbox::after, .radio::after { transition: none; } }

/* Segmented control */
.seg {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  padding: var(--space-2);
  gap: 1px;
}
.seg :is(button, a) {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: var(--fs-status);
  font-weight: var(--fw-medium);
  padding: var(--space-4) var(--space-8);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
  text-decoration: none;
}
.seg :is(button, a):where(:not(:disabled)):hover { color: var(--text-2); }
.seg :is(button, a):focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.seg :is(button, a).active {
  background: var(--surface-3);
  color: var(--text);
}
/* The pill: the top bar's screen switcher (sm0o.11). Full-pill track and
   segments, links or buttons. The segment's line is a length, not `normal`: the
   pill is 35px (1 + 4 + 4 + 17 + 4 + 4 + 1: the 4px steps and a 17px line), the
   tallest thing on the bar's row; the bar's height is --nav-h (:root, styles.css). */
.seg-pill { align-items: center; gap: var(--space-2); padding: var(--space-4); border-radius: var(--radius-pill); }
.seg-pill :is(button, a) {
  font-size: var(--fs-sub);
  line-height: 17px;
  padding: var(--space-4) var(--space-12);
  border-radius: var(--radius-pill);
  letter-spacing: var(--ls-tight-1);
  transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}

/* Stat tile */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: var(--space-16);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.stat .label {
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--muted-2);
}
.stat .value {
  font-size: var(--fs-figure);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
}
.stat .sub { font-size: var(--fs-meta); color: var(--muted); }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  z-index: var(--z-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-24);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
}
/* A modal that is a native <dialog> (frrx.42): showModal() puts it in the top layer
   and gives focus in, focus back, Escape and a Tab that stays inside; it is the
   card itself, so there is no backdrop element and no z-index. The UA's dialog
   padding, colour and sizing give way to the card's. */
dialog.modal {
  padding: 0;
  color: var(--text);
  max-width: min(480px, calc(100% - 2 * var(--space-24)));
  max-height: calc(100dvh - 2 * var(--space-24));
  overflow: hidden auto;
}
dialog.modal::backdrop {
  background: var(--scrim);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: var(--space-20) var(--space-20) var(--space-12);
}
.modal-body {
  padding: 0 var(--space-20) var(--space-20);
  display: flex;
  flex-direction: column;
  gap: var(--space-16);
}

/* Toast */
/* A popover (manual), so a toast shown while a <dialog> is open stacks above it in the
   top layer; the UA's popover box (centred, inset 0, overflow auto) is taken back. */
.toast {
  position: fixed;
  inset: auto;
  margin: 0;
  overflow: visible;
  bottom: var(--space-16);
  /* --xm-gutter: the scrollbar the Export modal's lock takes away (styles.css body.xm-lock) */
  right: calc(var(--space-16) + var(--xm-gutter, 0px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-12) var(--space-16);
  font-size: var(--fs-body);
  color: var(--text);
  box-shadow: var(--shadow-2);
  z-index: var(--z-toast);
  display: flex;
  align-items: center;
  gap: var(--space-8);
}
.toast.hidden { display: none; }

/* ───────── Skeleton (loading in place, padel-website-frrx.17) ─────────
   prototypes/library-skeletons/: the page holds its shape from first paint and
   the data fills it in. A .skeleton is the shape of the text it stands for, in
   surface-3, inside a box of the real line height (.skeleton-line, or
   .skeleton-text for a line of prose), so a card does not change height when the
   words replace the bars (124.3px desktop, 232.3px phone, both states). What only one page draws
   (the library card and rail, the match page's rows and modal bodies, the packs
   tiles) stays in styles.css beside that page. */
.skeleton-line { display: flex; align-items: center; }
.skeleton {
  display: block;
  width: var(--w, 100%);
  height: 0.62em;
  border-radius: var(--radius-xs);
  background: var(--surface-3);
}
.skeleton-pill {
  width: var(--w, 64px);
  height: 23px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.skeleton-tag {
  display: inline-block;
  width: var(--w, 62px);
  height: 24px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  border: 1px solid var(--border);
}
/* In em, so it follows the phone h1. */
.skeleton-h1 { display: flex; align-items: center; height: 1.05em; }
.skeleton-h1 .skeleton { height: 0.72em; border-radius: var(--radius-sm); }

/* Screen readers hear one sentence, not a pile of empty boxes. Also the visually-hidden
   file inputs of the upload controls (index.html), which are not skeleton at all. */
/* The negative margin keeps base.html's #skeleton-slow-status, which sits after the
   100vh .app, from adding a pixel of page scroll. */
.skeleton-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Every block breathes together, one slow breath (the owner's pick, A). */
.skeleton, .skeleton-pill, .skeleton-tag, .skeleton-icon { animation: skeleton-breath var(--dur-breath) var(--ease-breath) infinite; }
@keyframes skeleton-breath { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* The list arrives in place: same boxes, the words fade up from an already
   visible state. One moment for the whole list, no stagger. */
.skeleton-arrive { animation: skeleton-arrive var(--dur-slow) var(--ease-out) both; }
@keyframes skeleton-arrive { from { opacity: 0.35; } to { opacity: 1; } }

/* A video stage that waits on its clip (frrx.23): the court under it, the
   poster over the court when there is one, and the video fades in over both
   once it can play. The stage is never a black box. Decorative blocks only
   are aria-hidden; the video itself keeps its controls from the moment it
   plays. The poster has the clip's shape, so it is contained as the video is:
   a portrait clip's bars are the poster's black, and the poster stays under the
   video until a frame comes. */
.skeleton-stage { position: relative; background: var(--bg-2); overflow: hidden; }
.skeleton-stage > .court { position: absolute; inset: 0; border-radius: 0; }
.skeleton-stage > .skeleton-poster {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--video-black); display: block;
  opacity: 0; transition: opacity var(--dur-slow) var(--ease-out);
}
.skeleton-stage > .skeleton-poster.is-loaded { opacity: 1; }
.skeleton-stage > video { transition: opacity var(--dur-slow) var(--ease-out); }
.skeleton-stage.is-waiting > video { opacity: 0; pointer-events: none; }
.skeleton-stage > .skeleton-slow {
  position: absolute; left: 12px; right: 12px; bottom: 10px; margin: 0;
  text-align: center; color: var(--text-2);
}
/* After 4 s still loading: say so, quietly, under the skeleton. */
.skeleton-slow {
  margin: var(--space-4) var(--space-2) 0;
  font-size: var(--fs-sub);
  color: var(--muted);
  opacity: 0;
  transition: opacity var(--dur-slow) var(--ease-out);
}
.skeleton-slow.is-shown { opacity: 1; }

/* A failed read: one quiet panel where the list would be, with a retry. */
.skeleton-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-16);
  flex-wrap: wrap;
  padding: var(--space-16) var(--space-20);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.skeleton-error p { margin: 0; font-size: var(--fs-body); color: var(--text-2); }
.skeleton-error .muted { font-size: var(--fs-sub); margin-top: var(--space-4); color: var(--muted); }

/* A bar standing in for a line of text sits in that text's own line box: the
   zero-width space the template puts after it gives the box the real font's
   line height, so the words that replace it cannot make the line taller or
   shorter. */
.skeleton-text .skeleton { display: inline-block; vertical-align: middle; }
/* The row's icon buttons. */
.skeleton-icon {
  display: block;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-control);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
/* Reduced motion: a still skeleton, and the words simply appear. */
@media (prefers-reduced-motion: reduce) {
  .skeleton, .skeleton-pill, .skeleton-tag, .skeleton-icon, .skeleton-arrive { animation: none; }
  .skeleton-slow, .skeleton-stage > video, .skeleton-stage > .skeleton-poster { transition: none; }
}

/* Notice (sm0o.8; was the upload card's `.banner`). An icon and one line of
   text, the clause in <b>. Tones: `notice-warn` for something that goes wrong
   if it is ignored, `notice-plain` for a state that is merely worth stating,
   `notice-bad` for something the person did that did not work, `notice-ok` for
   thanks. It is the upload card's, the pack page's banner and the sign-in, register and Google callback pages' error, and the export modal's failed footer. The body step,
   one line at 560px and two on a phone (the 720px step down is below). The
   margin belongs to the slot that holds it, never to the notice. */
.notice {
  display: flex;
  gap: var(--space-8);
  align-items: flex-start;
  padding: var(--space-12);
  border-radius: var(--radius);
  font-size: var(--fs-body);
  color: var(--text);
}
.notice-warn {
  background: color-mix(in oklab, var(--warn) 12%, var(--surface));
  border: 1px solid color-mix(in oklab, var(--warn) 35%, var(--border));
}
.notice-plain {
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.notice-bad {
  background: color-mix(in oklab, var(--danger) 10%, var(--surface));
  border: 1px solid color-mix(in oklab, var(--danger) 30%, var(--border));
}
.notice-ok {
  background: color-mix(in oklab, var(--accent) 10%, var(--surface));
  border: 1px solid color-mix(in oklab, var(--accent) 35%, var(--border));
}
.notice b { font-weight: var(--fw-medium); }
.notice-ico { flex-shrink: 0; margin-top: 1px; }
.notice-warn > .notice-ico { color: var(--warn); }
.notice-plain > .notice-ico { color: var(--muted); }
.notice-bad > .notice-ico { color: var(--danger); }
.notice-ok > .notice-ico { color: var(--accent); }
@media (max-width: 720px) {
  .notice { padding: var(--space-8); font-size: var(--fs-sub); }
}

/* Choice chip (sm0o.8; was the gate's `.up-gate-chip` and the club picks'
   `.up-pick`). A pill button that is pressed or not (aria-pressed), unlike the
   mono count `.chip`. `chip-choice-quiet` is the secondary one, beside a
   field: smaller padding, the body step, no fill until pressed. The library's
   date and status rail uses the quiet one. */
.chip-choice {
  appearance: none;
  font: inherit;
  font-size: var(--fs-sub);
  letter-spacing: var(--ls-tight-1);
  padding: var(--space-8) var(--space-12);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
}
.chip-choice:hover { border-color: var(--muted-2); }
.chip-choice:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip-choice[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: var(--fw-medium);
}
.chip-choice-quiet {
  font-size: var(--fs-body);
  letter-spacing: normal;
  color: var(--muted);
  background: transparent;
  border-color: var(--border);
  padding: var(--space-4) var(--space-12);
}

.chip-choice-quiet:hover { border-color: var(--border-2); color: var(--text-2); }
.chip-choice-quiet[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
  font-weight: inherit;
}

/* Admin chip (sm0o.18): the mono filter pill of the admin pages, a link or a button;
   `aria-current` marks the chosen one. Moved from the admin sheet: the
   matches, feedback, patterns, match and user pages all draw it. Its padding was `5px 11px`, taken to the
   space scale (4px 12px) so ui.css's px count does not rise: one pixel a side. Its focus ring
   is the buttons' (above, 4gt6q). Its mark toggle (.mk) stays in admin/_base.html. */
.admin-chip {
  font: var(--fs-status) var(--font-mono); color: var(--text-2); background: var(--surface);
  border: 1px solid var(--border-2); border-radius: var(--radius-pill); padding: var(--space-4) var(--space-12); text-decoration: none;
}
button.admin-chip { cursor: pointer; }
/* Chosen: aria-current on a link or a filter, aria-pressed on a toggle button
   (sm0o.22: the match inspector's play and speed buttons). One look. */
.admin-chip[aria-current="true"],
.admin-chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }

/* Landing CTA (sm0o.13; was `.lv2-btn` in landing.css and landing-v2.css):
   the Ledger's call to action, a 52px accent pill with an arrow. The secondary
   is the 70% white pill with a hairline. On a phone both stretch full width. */
.btn-cta {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
  min-height: 52px;
  padding: 0 var(--space-20);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: var(--fw-semibold);
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out);
}
.btn-cta:hover { transform: translateY(-2px); filter: brightness(1.05); }
.btn-cta svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.btn-cta svg .fill { fill: currentColor; stroke: none; }
.btn-cta-secondary { background: color-mix(in srgb, var(--surface) 70%, transparent); color: var(--text); border-color: var(--border-2); }
.btn-cta-secondary:hover { border-color: var(--muted-2); filter: none; }
@media (max-width: 760px) { .btn-cta { width: 100%; } }

/* Link button (sm0o.8; was `.up-linkbtn`): text that is a button, an accent
   underline, ink on hover. */
.btn-link {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}
.btn-link:hover { color: var(--text); }
.btn-link:disabled, .btn-link:disabled:hover { color: var(--accent); }

/* Add button (sm0o.8; was `.up-addbtn`): a dashed pill that adds a row. */
.btn-add {
  align-self: flex-start;
  appearance: none;
  background: none;
  border: 1px dashed var(--border-2);
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-family: inherit;
  font-size: var(--fs-sub);
  padding: var(--space-8) var(--space-12);
  cursor: pointer;
}
.btn-add:hover { color: var(--text-2); border-color: var(--muted-2); }

/* ───────── Trim lane (sw5g.10; shared with the match page, t0fhj.4) ─────────
   The lane an SVG draws for trimming a span: a ruler, the lane, the dimmed outside (.trim-cut), the accent
   frame round what is kept (.trim-keep), a handle flush on each cut (.trim-trh) and the playhead. DESIGN.md,
   Trim lane. The framing editor (framing-editor.css) and the match page's rally boundaries draw it, so its
   classes carry the neutral .trim- prefix, not the editor's .fe-. */
.trim-lane { fill: var(--surface-2); stroke: var(--border); stroke-width: 1; }
.trim-tick { stroke: var(--border-2); stroke-width: 1; }
.trim-tick-label { fill: var(--muted); font-family: var(--font-mono); font-size: var(--fs-meta); }
.trim-tick-label.is-cut { fill: var(--text-2); }
.trim-cut { fill: var(--video-shade-50); pointer-events: none; }
.trim-keep { fill: none; stroke: var(--accent); stroke-width: 2.5; pointer-events: none; }
.trim-trh { cursor: ew-resize; touch-action: none; }
.trim-trh-hit { fill: transparent; }
.trim-trh-body { fill: var(--accent); }
.trim-trh.is-on .trim-trh-body { stroke: var(--text); stroke-width: 2; }
.trim-trh-chev { fill: none; stroke: var(--accent-ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.trim-playhead { fill: var(--text); pointer-events: none; transition: opacity var(--dur-fast); }
/* While a handle is dragged the playhead steps aside: .is-cutting on the lane's host. */
.is-cutting .trim-playhead { opacity: 0; }
/* Where detection put an end, once a handle has left it: a dashed line through the lane and a ▾ in the
   ruler over it (the page's .tooltip names it). The line is --on-video, for a lane over frames; on a plain
   lane (.is-plain on the host) it is --muted inside the kept span and stays light over the dimmed outside
   (.is-out). The framing editor never draws them. */
.trim-det-line { stroke: var(--on-video); stroke-width: 1.5; stroke-dasharray: 3 3; pointer-events: none; }
.is-plain .trim-det-line:not(.is-out) { stroke: var(--muted); }
.trim-det { fill: var(--muted); pointer-events: none; }
.trim-det-hit { fill: transparent; }
/* A neighbour named at a lane's end ("‹ Rally 2"), under the lane. */
.trim-nb { fill: var(--muted); font-family: var(--font-mono); font-size: var(--fs-meta); }

/* Layout utilities (esei.25; prototypes/design-system/README.md, decision 15): the
   closed family a template reaches for instead of a `style=""` attribute. Its spacing
   steps are the space scale and nothing else (`.ml-auto` and `.text-left` are alignment);
   a value off the scale snaps to a step first (decision 17). A step is added when a template needs it, not before.
   `.gap-*` carries `!important` because `.row` and `.col` (styles.css) load after this
   file and set a gap of their own; the same `!important` also beats a later `el.style`
   write, so a gap utility does not go on a node a script spaces. */
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-8 { margin-top: var(--space-8); }
.mt-12 { margin-top: var(--space-12); }
.mt-16 { margin-top: var(--space-16); }
.mt-24 { margin-top: var(--space-24); }
.mt-28 { margin-top: var(--space-28); }
.mb-8 { margin-bottom: var(--space-8); }
.ml-auto { margin-left: auto; }
.gap-8 { gap: var(--space-8) !important; }
.gap-20 { gap: var(--space-20) !important; }
.gap-24 { gap: var(--space-24) !important; }
.gap-28 { gap: var(--space-28) !important; }
.flex-wrap { flex-wrap: wrap; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.w-full { width: 100%; }

/* Type and colour utilities (esei.27, decision 15's rule): the type-scale steps and
   two colours a template reaches for instead of a `font-size` or `color` in `style=""`.
   A size enters when a template needs a token's exact value; a value with no token
   stays where it is. `.muted` (styles.css) is the third colour. */
.text-meta { font-size: var(--fs-meta); }
.text-status { font-size: var(--fs-status); }
/* The one weight step a label reaches for (the export modes' titles, di1ni). */
.fw-medium { font-weight: var(--fw-medium); }
.text-sub { font-size: var(--fs-sub); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
/* A quiet button that stops something keeps the danger colour in every state. The plain
   selector holds rest, hover and disabled (the same specificity as .btn-quiet:hover and
   :disabled, and later in the file); the :hover one beats .btn-quiet:disabled:hover, which is
   more specific. Pinned in e2e/tests/design-sheet.spec.js. */
.btn-quiet.text-danger,
.btn-quiet.text-danger:hover { color: var(--danger); }
