/* Volleyball Practice Builder: design system and app shell (WP1).
   Source of truth: docs/design/spec.md §1 (tokens), §4 (components), §5 (layout).
   Class names here are the contract for the page stylesheets (library.css, plans.css, run.css).
   The CSP forbids inline styles: no style="" attributes. Computed widths go through
   data-pct / data-grow, which ui.js applies (UI.sizes()). */

/* ==========================================================================
   1. Tokens
   ========================================================================== */
:root {
  color-scheme: light dark;
  /* Neutrals */
  --bg: #F6F5F2;
  --surface: #FFFFFF;
  --surface-2: #EFEEEA;
  --ink: #16181D;
  --ink-2: #5A606B;
  --line: #DCDAD3;
  --line-strong: #8C8A83;
  --seg-on: #FFFFFF; /* selected segment: must read clearly against --surface-2 */
  /* Brand */
  --primary: #1D4ED8;
  --primary-ink: #FFFFFF;
  --primary-hover: #1A43BA;
  --primary-soft: #E5ECFD;
  --primary-strong: #173DA8;
  --accent: #F5B700;
  --accent-ink: #1A1400;
  --accent-text: #8A5A00;
  --accent-soft: #FFF4CC;
  /* Status */
  --success: #1E7A45; --success-soft: #E3F4EA;
  --warn: #9A5B00;    --warn-soft: #FFF1D6;
  --danger: #B42318;  --danger-soft: #FDECEA;
  --danger-ink: #FFFFFF;
  /* Focus, overlay, inverted toast action */
  --focus: #1D4ED8;
  --scrim: rgb(10 12 16 / .45);
  --toast-action: #A3BEFF;

  /* Type */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-num: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-overline: .6875rem;
  --fs-xs: .75rem;
  --fs-sm: .875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.75rem;
  --fs-3xl: 2.25rem;
  --fs-timer: clamp(5rem, 27vw, 13rem);
  --fs-timer-land: clamp(5rem, 22vw, 15rem);

  /* Space (4px base), layout */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px;
  --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;
  --gutter: 16px;
  /* App container: fluid, capped so very wide monitors keep a comfortable composition.
     Text blocks stay readable through --measure, not through the container width. */
  --content-max: 1680px;
  --measure: 68ch;
  --page-gutter-l: max(var(--gutter), env(safe-area-inset-left));
  --page-gutter-r: max(var(--gutter), env(safe-area-inset-right));
  --header-h: 52px;

  /* Radius */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-pill: 999px;

  /* Elevation */
  --shadow-1: 0 1px 2px rgb(16 24 40 / .06), 0 1px 1px rgb(16 24 40 / .04);
  --shadow-2: 0 4px 12px rgb(16 24 40 / .10), 0 2px 4px rgb(16 24 40 / .06);
  --shadow-3: 0 16px 40px rgb(16 24 40 / .18), 0 4px 12px rgb(16 24 40 / .10);

  /* Motion */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --dur-1: 120ms;
  --dur-2: 200ms;
  --dur-3: 280ms;
}
@media (min-width: 720px) {
  :root { --gutter: 24px; --header-h: 64px; }
}
@media (min-width: 1440px) {
  :root { --gutter: 40px; }
}

/* Dark: the same declarations twice (system preference, and a forced data-theme). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1116; --surface: #171B22; --surface-2: #1F242D;
    --ink: #ECEEF2; --ink-2: #A3AAB6; --line: #2B313B; --line-strong: #6B7585; --seg-on: #3A4250;
    --primary: #86A8FF; --primary-ink: #0B1020; --primary-hover: #A3BEFF;
    --primary-soft: #1C2A4D; --primary-strong: #C3D3FF;
    --accent: #FFC93C; --accent-ink: #1A1400; --accent-text: #FFC93C; --accent-soft: #3A2F0D;
    --success: #4CC38A; --success-soft: #12301F;
    --warn: #F5A524; --warn-soft: #33260C;
    --danger: #FF7A6E; --danger-soft: #3A1714; --danger-ink: #0E1116;
    --focus: #86A8FF; --scrim: rgb(0 0 0 / .6); --toast-action: #1D4ED8;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1116; --surface: #171B22; --surface-2: #1F242D;
  --ink: #ECEEF2; --ink-2: #A3AAB6; --line: #2B313B; --line-strong: #6B7585; --seg-on: #3A4250;
  --primary: #86A8FF; --primary-ink: #0B1020; --primary-hover: #A3BEFF;
  --primary-soft: #1C2A4D; --primary-strong: #C3D3FF;
  --accent: #FFC93C; --accent-ink: #1A1400; --accent-text: #FFC93C; --accent-soft: #3A2F0D;
  --success: #4CC38A; --success-soft: #12301F;
  --warn: #F5A524; --warn-soft: #33260C;
  --danger: #FF7A6E; --danger-soft: #3A1714; --danger-ink: #0E1116;
  --focus: #86A8FF; --scrim: rgb(0 0 0 / .6); --toast-action: #1D4ED8;
}

@media (prefers-reduced-motion: reduce) {
  :root { --dur-1: 0ms; --dur-2: 0ms; --dur-3: 0ms; }
}

/* ==========================================================================
   2. Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 8px); }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--fs-md)/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: break-word;
}
h1, h2, h3, h4, p, ul, ol, figure, blockquote, dl, dd { margin: 0; }
h1 { font-size: var(--fs-xl); line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: var(--fs-lg); line-height: 1.4; font-weight: 600; }
h3 { font-size: var(--fs-md); line-height: 1.4; font-weight: 600; }
ul, ol { padding: 0; list-style: none; }
img, svg, video { max-width: 100%; }
img, video { height: auto; display: block; }
a { color: var(--primary); text-underline-offset: .15em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
template { display: none; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: inherit; }
main:focus { outline: none; } /* focused only by the skip link */

::selection { background: var(--primary-soft); color: var(--ink); }

/* ==========================================================================
   3. Utilities
   ========================================================================== */
.sr-only {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.muted { color: var(--ink-2); }
.small { font-size: var(--fs-sm); }
.overline {
  font-size: var(--fs-overline); line-height: 1.2; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2);
}
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.truncate { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.measure { max-width: var(--measure); }
.prose { white-space: pre-line; max-width: var(--measure); }
.grow { flex: 1 1 auto; min-width: 0; }

/* Vertical rhythm and horizontal clusters. --gap overrides the default. */
.stack { display: flex; flex-direction: column; gap: var(--gap, var(--sp-4)); }
.stack > * { min-width: 0; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap, var(--sp-2)); }
.cluster > * { min-width: 0; }

/* Layout rule (audit #1): grid tracks are minmax(0,1fr), never a bare 1fr. */
.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap, var(--sp-4)); }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Responsive visibility */
@media (max-width: 719.98px) { .desktop-only { display: none !important; } }
@media (min-width: 720px) { .phone-only { display: none !important; } }

/* Icons from the _icons.html sprite */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; display: none; }
.i {
  width: 1.25em; height: 1.25em; flex: none; vertical-align: -.25em;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.i-sm { width: 16px; height: 16px; }
.i-lg { width: 24px; height: 24px; }
.i-xl { width: 32px; height: 32px; }
.mark { width: 28px; height: 28px; flex: none; display: block; }

/* Spinner (buttons, save pill) */
.spinner {
  width: 16px; height: 16px; flex: none; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .8s linear infinite;
}
.spinner-sm { width: 12px; height: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

/* ==========================================================================
   4. Shell: skip link, header, nav, page, tab bar, sticky actions
   ========================================================================== */
.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 100;
  padding: 10px 16px; border-radius: var(--r-md);
  background: var(--primary); color: var(--primary-ink); font-weight: 600; text-decoration: none;
  transform: translateY(-200%); transition: transform var(--dur-1) var(--ease);
}
.skip-link:focus, .skip-link:focus-visible { transform: none; }

/* Bottom chrome: the tab bar and sticky action bar reserve space at the end of the page.
   Pages may override --sticky-h (or --bottom-chrome) when their bars are taller. */
body {
  --tabbar-h: 0px;
  --sticky-h: 0px;
  --bottom-chrome: calc(var(--tabbar-h) + var(--sticky-h));
  padding-bottom: calc(var(--bottom-chrome) + env(safe-area-inset-bottom));
}
body:has(> .tabbar) { --tabbar-h: 56px; }
body:has(> .sticky-actions) { --sticky-h: 68px; }
html.kb-open body { --tabbar-h: 0px; }
@media (min-width: 720px) {
  body:has(> .tabbar) { --tabbar-h: 0px; }
  body:has(> .sticky-actions) { --sticky-h: 0px; }
}

.app-header {
  position: sticky; top: 0; z-index: 20;
  height: calc(var(--header-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.app-header-inner {
  height: 100%;
  display: flex; align-items: center; gap: 4px;
  max-width: calc(var(--content-max) + var(--page-gutter-l) + var(--page-gutter-r));
  margin: 0 auto;
  padding: 0 max(4px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
}
.brand {
  display: inline-flex; align-items: center; gap: 10px; flex: none;
  min-height: 44px; min-width: 44px; justify-content: center;
  color: var(--ink); text-decoration: none; border-radius: var(--r-md);
}
.wordmark-text { display: none; line-height: 1.1; }
.wordmark-eyebrow {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-2);
}
.wordmark-name { display: block; font-size: var(--fs-lg); font-weight: 750; letter-spacing: -.01em; color: var(--ink); }
.app-header.has-back .brand { display: none; }
.app-header-back { color: var(--ink); }
.app-header-title {
  flex: 1; min-width: 0; padding-left: 4px;
  font-size: var(--fs-lg); font-weight: 700; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-header-actions { display: flex; align-items: center; flex: none; }
.app-header-actions .btn-icon { color: var(--ink); }
.app-nav, .app-header-desktop { display: none; }

@media (min-width: 720px) {
  .app-header-inner { gap: var(--sp-6); padding: 0 var(--page-gutter-r) 0 var(--page-gutter-l); }
  .brand { justify-content: flex-start; }
  .wordmark-text { display: block; }
  .app-header.has-back .brand { display: inline-flex; }
  .app-header .app-header-back, .app-header .app-header-title, .app-header .app-header-actions { display: none; }
  /* The nav keeps its width; the right side (the workspace switcher) shrinks, so they never overlap. */
  .app-nav { display: flex; align-items: stretch; align-self: stretch; gap: var(--sp-1); flex: 1 0 auto; }
  .app-header-desktop { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-2); flex: 0 1 auto; min-width: 0; }
}
/* Narrow desktops and tablets: the mark without its words, and tighter gaps, to leave the switcher room. */
@media (min-width: 720px) and (max-width: 1023.98px) {
  .app-header-inner { gap: var(--sp-4); }
  .wordmark-text { display: none; }
}
/* Team first added a Team item: below 900px the main nav drops its icons and tightens, so Plans, Team,
   Drills, Club (or Framework) and the switcher still fit at 720px. */
@media (min-width: 720px) and (max-width: 899.98px) {
  .app-nav .nav-link { padding: 0 8px; }
  .app-nav .nav-link > .i { display: none; }
  .app-nav .nav-link[aria-current="page"]::after { left: 8px; right: 8px; }
}
.nav-link {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  padding: 0 12px; min-height: 44px;
  color: var(--ink-2); font-weight: 600; text-decoration: none;
  transition: color var(--dur-1) var(--ease);
}
.nav-link:hover { color: var(--ink); }
.nav-link[aria-current="page"] { color: var(--primary); }
.nav-link[aria-current="page"]::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px;
  height: 2px; border-radius: 2px; background: var(--primary);
}
.nav-link:focus-visible { outline-offset: -3px; border-radius: var(--r-md); }

/* Split button: [New plan][▾] */
.split { display: inline-flex; }
.split > .btn:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.split > .btn + .btn {
  border-radius: 0 var(--r-md) var(--r-md) 0; padding: 0; width: 40px; min-width: 40px;
  border-left: 1px solid color-mix(in srgb, var(--primary-ink) 30%, transparent);
}

/* Main page container */
.page {
  display: block;
  max-width: calc(var(--content-max) + var(--page-gutter-l) + var(--page-gutter-r));
  margin: 0 auto;
  padding: var(--sp-4) var(--page-gutter-r) var(--sp-8) var(--page-gutter-l);
}
@media (min-width: 720px) {
  .page { padding-top: var(--sp-6); padding-bottom: var(--sp-12); }
}

/* Page head: on phones the header bar already shows the title, so the h1 is kept for
   screen readers only; from 720px it is the visible page title. */
.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.page-head > * { min-width: 0; }
.page-head-main { flex: 1 1 260px; min-width: 0; }
.page-head h1 {
  position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.page-head .sub { color: var(--ink-2); font-size: var(--fs-sm); }
.page-head-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
@media (min-width: 720px) {
  .page-head { margin-bottom: var(--sp-6); }
  .page-head h1 {
    position: static; width: auto; height: auto; margin: 0; overflow: visible;
    clip: auto; clip-path: none; white-space: normal;
    font-size: var(--fs-2xl); line-height: 1.2; font-weight: 750;
  }
}

/* Tab bar (phone only) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex;
  height: calc(56px + env(safe-area-inset-bottom));
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tab {
  position: relative; flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ink-2); font-size: var(--fs-xs); font-weight: 600; text-decoration: none;
}
.tab .i { width: 24px; height: 24px; }
.tab > span { max-width: 100%; padding: 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }  /* six tabs at 320px */
.tab[aria-current="page"] { color: var(--primary); }
.tab[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; left: 50%; width: 32px; height: 4px;
  margin-left: -16px; border-radius: 0 0 4px 4px; background: var(--primary);
}
.tab:focus-visible { outline-offset: -3px; }
html.kb-open .tabbar { display: none; }
@media (min-width: 720px) { .tabbar { display: none; } }

/* Sticky action bar: fixed above the tab bar on phones, sticky at the bottom on desktop. */
.sticky-actions {
  position: fixed; left: 0; right: 0; z-index: 19;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  display: flex; gap: var(--sp-2); align-items: center;
  min-height: 68px;
  padding: 10px var(--page-gutter-r) 10px var(--page-gutter-l);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.sticky-actions > .btn { flex: 1 1 auto; }
.sticky-actions > .btn-icon { flex: none; }
body:not(:has(> .tabbar)) .sticky-actions,
html.kb-open .sticky-actions { bottom: 0; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
@media (min-width: 720px) {
  .sticky-actions {
    position: sticky; bottom: 0;
    max-width: calc(var(--content-max) + var(--page-gutter-l) + var(--page-gutter-r));
    margin: 0 auto; padding-bottom: calc(10px + env(safe-area-inset-bottom));
    border: 1px solid var(--line); border-bottom: 0;
    border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--shadow-2);
    justify-content: flex-end;
  }
  .sticky-actions > .btn { flex: none; }
}

/* ==========================================================================
   5. Buttons (§4.1)
   ========================================================================== */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  border-radius: var(--r-md); border: 1px solid transparent;
  background: transparent; color: var(--ink);
  font-size: var(--fs-md); font-weight: 600; line-height: 1.2;
  text-decoration: none; text-align: center; white-space: nowrap;
  cursor: pointer; user-select: none;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease),
    border-color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-danger { background: var(--danger); color: var(--danger-ink); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 88%, var(--ink)); }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-dashed { border: 1.5px dashed var(--line-strong); color: var(--primary); background: transparent; }
.btn-dashed:hover { background: var(--primary-soft); border-color: var(--primary); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: var(--fs-sm); }
.btn-lg { min-height: 52px; font-size: var(--fs-lg); }
.btn-block { display: flex; width: 100%; }
.btn-icon { width: 44px; min-width: 44px; padding: 0; }
/* A button whose label may be longer than a phone is wide: it wraps instead of running off. */
.btn-wrap { white-space: normal; max-width: 100%; padding-block: 8px; }
.btn-icon.btn-sm { width: 36px; min-width: 36px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%;
  border: 2px solid var(--ink); border-right-color: transparent;
  animation: spin .8s linear infinite;
}
.btn-primary.is-loading::after { border-color: var(--primary-ink); border-right-color: transparent; }

/* ==========================================================================
   6. Chips and badges (§4.2)
   ========================================================================== */
.chip {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 14px;
  border-radius: var(--r-pill); border: 1px solid transparent;
  background: var(--surface-2); color: var(--ink);
  font-size: var(--fs-sm); font-weight: 500; line-height: 1.2; white-space: nowrap;
  text-decoration: none;
}
/* Interactive chips (labels, links, buttons) get a 44px hit area. */
label.chip, a.chip, button.chip { cursor: pointer; user-select: none; margin-block: 4px; transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease); }
label.chip::before, a.chip::before, button.chip::before { content: ""; position: absolute; inset: -4px 0; }
label.chip:hover, a.chip:hover, button.chip:hover { border-color: var(--line-strong); }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.chip > .i { width: 0; height: 14px; overflow: hidden; transition: width var(--dur-2) var(--ease); }
.chip > .i.i-always { width: 16px; height: 16px; }
.chip:has(input:checked), .chip[aria-pressed="true"], .chip.is-selected {
  background: var(--primary-soft); color: var(--primary-strong);
}
.chip:has(input:checked) > .i, .chip[aria-pressed="true"] > .i, .chip.is-selected > .i { width: 14px; }
.chip:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.chip:has(input:disabled) { opacity: .45; cursor: default; }
.chip-sm {
  min-height: 28px; padding: 0 10px; font-size: var(--fs-xs); font-weight: 600;
  margin: 0; cursor: default;
}
.chip-sm::before { display: none; }

.chip-row {
  display: flex; gap: var(--sp-2);
  overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x proximity; scrollbar-width: none;
  padding-inline: 2px;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip-row > * { flex: none; scroll-snap-align: start; }
/* Edge fades, toggled by ui.js as the row scrolls. */
.chip-row.fade-start { mask-image: linear-gradient(90deg, transparent 0, #000 24px); }
.chip-row.fade-end { mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent); }
.chip-row.fade-start.fade-end { mask-image: linear-gradient(90deg, transparent 0, #000 24px, #000 calc(100% - 24px), transparent); }
.chip-group { display: flex; flex-wrap: wrap; gap: 0 var(--sp-2); }
.chip-group > .chip-sm { margin-block: 2px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 7px; border-radius: var(--r-sm);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1; white-space: nowrap;
  vertical-align: 2px;
  background: var(--surface-2); color: var(--ink);
}
.badge .i { width: 13px; height: 13px; }
.badge-neutral { background: var(--surface-2); color: var(--ink); }
.badge-primary { background: var(--primary-soft); color: var(--primary-strong); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-count {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--r-pill); background: var(--primary); color: var(--primary-ink);
  font-size: var(--fs-xs); font-weight: 700; line-height: 1;
}

/* ==========================================================================
   7. Cards, rows, alerts (§4.3)
   ========================================================================== */
.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: var(--sp-4);
  min-width: 0;
}
@media (min-width: 720px) { .card { padding: var(--sp-5); } }
a.card, .drill-card, .plan-card {
  color: inherit; text-decoration: none;
  transition: border-color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
a.card:hover, a.drill-card:hover, a.plan-card:hover { border-color: var(--line-strong); }
a.card:active, a.drill-card:active, a.plan-card:active { transform: scale(.995); }
.card-title { font-size: var(--fs-lg); font-weight: 600; line-height: 1.3; }

/* Builder row (WP3 fills in the inside; the grid and states are shared). */
.plan-item {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto 44px;
  align-items: center; gap: var(--sp-2);
  min-height: 64px; padding: 8px 8px 8px 4px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  transition: height var(--dur-2) var(--ease), opacity var(--dur-2) var(--ease);
}
.plan-item > * { min-width: 0; }
.plan-item.is-dragging { background: var(--surface); box-shadow: var(--shadow-2); transform: scale(1.02); border-color: var(--primary); position: relative; z-index: 2; }
.plan-item.is-ghost { opacity: .4; outline: 2px dashed var(--primary); box-shadow: none; }
.plan-item.is-lifted { outline: 2px solid var(--primary); outline-offset: 0; }
.plan-item.is-removing { height: 0; min-height: 0; padding-block: 0; opacity: 0; overflow: hidden; border-width: 0; }
.drag-handle { color: var(--ink-2); cursor: grab; touch-action: none; }
.drag-handle[aria-pressed="true"] { color: var(--primary); }

.alert {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  border: 1px solid transparent; font-size: var(--fs-sm);
  background: var(--surface-2); color: var(--ink);
}
.alert > .i { margin-top: 1px; }
.alert-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--ink); }
.alert-danger > .i { color: var(--danger); }
.alert-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.alert-warn > .i { color: var(--warn); }
.alert-success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.alert-success > .i { color: var(--success); }
.alert-info { background: var(--primary-soft); }
.alert-info > .i { color: var(--primary); }
.alert a { color: inherit; font-weight: 600; }
/* "Still running" (drills/_run_resume.html): the way back to a practice this device is running.
   Here, not plans.css: the offline page shows it too. */
.run-resume { align-items: center; margin-bottom: var(--sp-4); }
.run-resume-x { margin: -6px -8px -6px 0; color: var(--ink-2); }
.run-resume > p { flex: 1; min-width: 0; margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); }
.run-resume .run-resume-go { color: var(--primary-ink); }

/* ==========================================================================
   8. Inputs (§4.4)
   ========================================================================== */
.field { margin-bottom: var(--sp-4); min-width: 0; }
.field > label, .field > .label, .legend {
  display: block; margin-bottom: 6px;
  font-size: var(--fs-sm); font-weight: 600; color: var(--ink);
}
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }
.input,
.field input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=file]),
.field select,
.field textarea {
  display: block; width: 100%; min-height: 48px;
  padding: 0 14px;
  font-size: var(--fs-md); line-height: 1.4; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  transition: border-color var(--dur-1) var(--ease);
}
textarea.input, .field textarea { padding: 12px 14px; resize: vertical; }
.field select, select.input { appearance: none; padding-right: 40px; background-image: none; }
.select-wrap { position: relative; }
.select-wrap > .i { position: absolute; right: 12px; top: 50%; translate: 0 -50%; pointer-events: none; color: var(--ink-2); }
.field .tz-search { margin-bottom: var(--sp-2); }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  outline: 3px solid color-mix(in srgb, var(--focus) 35%, transparent);
  outline-offset: 0;
}
.input::placeholder, .field ::placeholder { color: var(--ink-2); opacity: 1; }
.help { margin-top: 6px; font-size: var(--fs-sm); color: var(--ink-2); }
.field-error, .field .errorlist {
  display: flex; gap: 6px; align-items: center; margin: 6px 0 0; padding: 0;
  font-size: var(--fs-sm); color: var(--danger); list-style: none;
}
.field-error .i { width: 16px; height: 16px; }
.field.has-error input, .field.has-error select, .field.has-error textarea,
.field [aria-invalid="true"] { border-color: var(--danger) !important; }

/* Checkbox and radio */
input[type=checkbox], input[type=radio] { accent-color: var(--primary); width: 20px; height: 20px; }

/* Stepper: [−][12][+] */
.stepper {
  display: inline-flex; align-items: center; height: 44px;
  border-radius: var(--r-md); background: var(--surface-2);
}
.stepper .btn-icon { min-height: 44px; color: var(--primary); }
.stepper input {
  width: 3.5ch; min-width: 0; height: 44px; padding: 0;
  text-align: center; border: 0; background: transparent; color: var(--ink);
  font: 600 var(--fs-lg) var(--font-num); font-variant-numeric: tabular-nums;
  -moz-appearance: textfield; appearance: textfield;
}
/* Typing in the number: it turns into a white field with a ring, so it's clear it's editable. */
.stepper input:focus { outline: none; background: var(--surface); border-radius: var(--r-sm); box-shadow: inset 0 0 0 2px var(--focus); }
.stepper:focus-within { box-shadow: 0 0 0 1px var(--focus); }
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus-visible { outline-offset: -2px; border-radius: var(--r-sm); }
.stepper .unit { font-size: var(--fs-xs); color: var(--ink-2); margin: 0 2px 0 -2px; }

/* Segmented control (radios) */
.segmented { display: flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: var(--r-md); }
.segmented label {
  flex: 1 1 0; min-width: 0; position: relative;
  display: grid; place-items: center; min-height: 40px; padding: 0 8px;
  border-radius: 8px; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2);
  cursor: pointer; text-align: center;
  transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
/* Options of uneven length (Practice type): each as wide as its words, so "Team practice" keeps one line. */
.segmented-fit label { flex: 1 1 auto; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--seg-on); color: var(--ink); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line); }
.segmented label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 0; }

/* Switch: <label class="switch"><input type="checkbox" role="switch"><span>Label</span></label> */
.switch { display: inline-flex; align-items: center; gap: var(--sp-3); min-height: 44px; cursor: pointer; }
.switch input {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 52px; height: 32px; margin: 0; border-radius: var(--r-pill);
  background: var(--line-strong); position: relative; cursor: pointer;
  transition: background var(--dur-2) var(--ease);
}
.switch input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-1);
  transition: transform var(--dur-2) var(--ease);
}
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(20px); }

/* Search field */
.search-field { position: relative; min-width: 0; }
.search-field > .i { position: absolute; left: 14px; top: 50%; translate: 0 -50%; color: var(--ink-2); pointer-events: none; }
.search-field input {
  width: 100%; min-height: 48px; padding: 0 48px 0 44px;
  font-size: var(--fs-md); color: var(--ink);
  background: var(--surface-2); border: 1px solid transparent; border-radius: var(--r-pill);
  -webkit-appearance: none; appearance: none;
}
.search-field input::-webkit-search-cancel-button { display: none; }
.search-field input::placeholder { color: var(--ink-2); }
.search-field input:focus {
  background: var(--surface); border-color: var(--primary);
  outline: 3px solid color-mix(in srgb, var(--focus) 35%, transparent); outline-offset: 0;
}
.search-field .clear { position: absolute; right: 2px; top: 50%; translate: 0 -50%; border-radius: var(--r-pill); color: var(--ink-2); }
.search-field input:placeholder-shown ~ .clear { display: none; }

/* List editor (WP2's library.js drives it) */
.list-editor { display: grid; gap: var(--sp-2); }
.list-editor-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) 44px; align-items: start; gap: var(--sp-2); }
.list-editor-row::before { content: ""; width: 6px; height: 6px; margin-top: 19px; border-radius: 50%; background: var(--line-strong); justify-self: center; }
.list-editor-row textarea { min-height: 44px; padding: 10px 14px; resize: none; overflow: hidden; }
.list-editor-add {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%;
  min-height: 44px; padding: 0 14px; margin-left: 20px; width: calc(100% - 20px);
  border: 1.5px dashed var(--line-strong); border-radius: var(--r-md);
  background: transparent; color: var(--primary); font-weight: 600; text-align: left;
}
.list-editor-add:hover { background: var(--primary-soft); border-color: var(--primary); }

/* ==========================================================================
   9. Sheets, dialogs, menus (§4.5)
   ========================================================================== */
dialog { color: var(--ink); }
html.sheet-open { overflow: hidden; }
.sheet {
  position: fixed; inset: auto 0 0 0;
  width: 100%; max-width: 100%; max-height: 92dvh;
  margin: 0; padding: 0 0 env(safe-area-inset-bottom);
  display: none; flex-direction: column;
  background: var(--surface); border: 0;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-3);
  overflow: hidden;
  transform: translateY(100%);
  transition: transform var(--dur-3) var(--ease), overlay var(--dur-3) allow-discrete, display var(--dur-3) allow-discrete;
}
.sheet[open] { display: flex; transform: none; }
@starting-style { .sheet[open] { transform: translateY(100%); } }
.sheet::backdrop {
  background: var(--scrim); opacity: 0;
  transition: opacity var(--dur-3) var(--ease), overlay var(--dur-3) allow-discrete, display var(--dur-3) allow-discrete;
}
.sheet[open]::backdrop { opacity: 1; }
@starting-style { .sheet[open]::backdrop { opacity: 0; } }
.sheet.is-dragging { transition: none; }
/* Markup: <div class="sheet-grab" aria-hidden="true"></div> (not a button, so showModal()
   focuses the first real control; the close button in .sheet-head is the accessible close). */
.sheet-grab {
  flex: none; display: block; width: 100%; height: 20px; padding: 0; border: 0; background: none;
  cursor: grab; touch-action: none; position: relative;
}
.sheet-grab::after {
  content: ""; position: absolute; left: 50%; top: 8px; width: 36px; height: 4px;
  margin-left: -18px; border-radius: 4px; background: var(--line-strong);
}
.sheet-head {
  flex: none; display: flex; align-items: center; gap: var(--sp-2);
  min-height: 52px; padding: 0 4px 0 var(--gutter);
}
.sheet-head h2 { flex: 1; min-width: 0; font-size: var(--fs-lg); font-weight: 700; }
.sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-2) var(--gutter) var(--sp-4); }
.sheet-foot {
  flex: none; display: flex; gap: var(--sp-2); align-items: center;
  padding: 10px var(--gutter); border-top: 1px solid var(--line); background: var(--surface);
}
.sheet-foot > .btn { flex: 1 1 auto; }
@media (min-width: 720px) {
  .sheet {
    inset: 0; margin: auto; width: calc(100% - 48px); max-width: 560px; height: fit-content; max-height: min(720px, 88dvh);
    padding-bottom: 0; border-radius: var(--r-xl);
    transform: scale(.96); opacity: 0;
    transition: transform var(--dur-3) var(--ease), opacity var(--dur-3) var(--ease), overlay var(--dur-3) allow-discrete, display var(--dur-3) allow-discrete;
  }
  .sheet[open] { transform: none; opacity: 1; }
  @starting-style { .sheet[open] { transform: scale(.96); opacity: 0; } }
  .sheet-grab { display: none; }
  .sheet-head { padding-top: var(--sp-2); }
}
@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet[open] { transform: none; }
  @starting-style { .sheet[open] { transform: none; } }
}
:root[data-theme="dark"] .sheet { border: 1px solid var(--line); background: var(--surface-2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sheet { border: 1px solid var(--line); background: var(--surface-2); } }

/* Action sheet rows (also used inside menus) */
.sheet-actions .sheet-body { padding: 0 0 var(--sp-2); }
.action-list { display: grid; }
.action-item, .menu-item {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%;
  min-height: 52px; padding: 0 var(--gutter);
  border: 0; background: none; color: var(--ink);
  font-size: var(--fs-md); font-weight: 500; text-align: left; text-decoration: none;
  cursor: pointer;
}
.action-item:hover, .menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); }
.action-item .i, .menu-item .i { color: var(--ink-2); }
.action-item.is-danger, .menu-item.is-danger, .action-item.is-danger .i, .menu-item.is-danger .i { color: var(--danger); }
.menu-item:focus-visible, .action-item:focus-visible { outline-offset: -3px; border-radius: 0; }
.menu form { margin: 0; }
/* A menu item with a help line: its title, then the help under it (any menu, not only + Section's). */
.menu-item:has(> span > .menu-help) { align-items: flex-start; padding-block: 8px; }
.menu-item:has(> span > .menu-help) > .i { margin-top: 2px; }
.menu-item > span:has(> .menu-help) { display: flex; flex-direction: column; gap: 2px; text-align: left; }
.menu-sep { height: 1px; margin: 4px 0; background: var(--line); }
.menu-label { padding: 10px var(--gutter) 4px; }

/* Popover menu: a bottom action sheet on phones, an anchored dropdown from 720px
   (ui.js positions it under its trigger). <div class="menu" popover id="…"> */
.menu {
  position: fixed; inset: auto 0 0 0; margin: 0;
  width: 100%; max-width: 100%;
  padding: var(--sp-2) 0 calc(var(--sp-2) + env(safe-area-inset-bottom));
  border: 0; border-radius: var(--r-xl) var(--r-xl) 0 0;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-3);
  opacity: 0; transform: translateY(16px);
  transition: opacity var(--dur-2) var(--ease), transform var(--dur-2) var(--ease), overlay var(--dur-2) allow-discrete, display var(--dur-2) allow-discrete;
}
.menu:popover-open { opacity: 1; transform: none; }
@starting-style { .menu:popover-open { opacity: 0; transform: translateY(16px); } }
.menu::backdrop { background: var(--scrim); }
@media (min-width: 720px) {
  .menu {
    inset: auto; min-width: 220px; max-width: 320px; width: max-content;
    padding: 6px 0; border: 1px solid var(--line); border-radius: var(--r-md);
    transform: translateY(-4px);
  }
  @starting-style { .menu:popover-open { opacity: 0; transform: translateY(-4px); } }
  .menu::backdrop { background: transparent; }
  .menu .menu-item { min-height: 40px; padding: 0 var(--sp-4); font-size: var(--fs-sm); }
}
:root[data-theme="dark"] .menu { background: var(--surface-2); border: 1px solid var(--line); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .menu { background: var(--surface-2); border: 1px solid var(--line); } }

/* ==========================================================================
   10. Toasts (§4.6)
   ========================================================================== */
.toasts {
  position: fixed; left: 0; right: 0; z-index: 60;
  bottom: var(--toast-offset, calc(var(--bottom-chrome, 0px) + env(safe-area-inset-bottom) + 12px));
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  padding: 0 12px; pointer-events: none;
}
body.run .toasts { top: calc(12px + env(safe-area-inset-top)); bottom: auto; }
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: var(--sp-2);
  width: max-content; max-width: min(480px, 100%); min-height: 48px;
  padding: 0 6px 0 18px;
  border-radius: var(--r-pill);
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow-3);
  font-size: var(--fs-sm); font-weight: 500;
  animation: toast-in var(--dur-2) var(--ease);
}
.toast:not(:has(.toast-action)) { padding-right: 18px; }
.toast-msg { flex: 1 1 auto; min-width: 0; padding: 12px 0; }
.toast form { margin: 0; display: contents; }
.toast-action {
  flex: none; min-height: 44px; padding: 0 12px; border: 0; border-radius: var(--r-pill);
  background: none; color: var(--toast-action); font-weight: 700; font-size: var(--fs-sm);
  cursor: pointer;
}
.toast-action:focus-visible { outline-color: var(--toast-action); outline-offset: -3px; }
/* A toast with an action has no time limit: its × closes it. */
.toast-close {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; margin-left: -6px; padding: 0; border: 0; border-radius: var(--r-pill);
  background: none; color: inherit; opacity: .8; cursor: pointer;
}
.toast-close:hover { opacity: 1; }
.toast-close:focus-visible { outline-color: var(--toast-action); outline-offset: -3px; opacity: 1; }
.toast-close .i { width: 18px; height: 18px; }
.toast.is-leaving { opacity: 0; transition: opacity var(--dur-2) var(--ease); }
.toast-error .toast-msg::before { content: ""; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } .toast.is-leaving { transition: none; } }
/* While a toast that waits (Undo, Retry) is up, focused rows scroll clear of it. */
html.has-toast { scroll-padding-bottom: calc(var(--bottom-chrome, 0px) + env(safe-area-inset-bottom) + 84px); }
html.has-toast:has(> body.run) { scroll-padding-bottom: 0; scroll-padding-top: calc(env(safe-area-inset-top) + 84px); }

/* ==========================================================================
   11. Progress (§4.8)
   ========================================================================== */
.meter { height: 6px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.meter-sm { height: 4px; }
.meter > span {
  display: block; height: 100%; width: 0; max-width: 100%;
  background: var(--primary); border-radius: inherit;
  transition: width var(--dur-2) var(--ease);
}
.meter.is-full > span { background: var(--success); }
.meter.is-over > span { background: var(--danger); }

.segbar { display: flex; gap: 2px; height: 6px; min-width: 0; }
.segbar > span { flex: 1 1 0; min-width: 2px; background: var(--primary); }
.segbar > span:nth-child(even) { background: var(--primary-hover); }
.segbar > span:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.segbar > span:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.segbar > span:only-child { border-radius: var(--r-sm); }
.segbar > .segbar-rest { background: var(--surface-2); }
.segbar > .is-done { opacity: .55; }
.segbar > .is-current { background: var(--success); }
.segbar > .is-over, .segbar > .segbar-overflow { background: var(--danger); }
.segbar.is-over { outline: 1px solid var(--danger); outline-offset: 1px; border-radius: var(--r-sm); }

/* ==========================================================================
   12. Empty states (§3.11)
   ========================================================================== */
.empty { text-align: center; padding: var(--sp-8) var(--sp-4); max-width: 420px; margin: 0 auto; }
.empty-icon {
  width: 72px; height: 72px; margin: 0 auto var(--sp-3);
  display: grid; place-items: center; border-radius: 50%;
  background: var(--surface-2); color: var(--ink-2);
}
.empty-icon .i { width: 48px; height: 48px; stroke-width: 1.5; }
.empty-title { font-size: var(--fs-lg); font-weight: 600; margin-bottom: var(--sp-1); }
.empty-help { color: var(--ink-2); margin-bottom: var(--sp-4); }
.empty-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: center; }

/* ==========================================================================
   13. Auth pages (base_auth.html)
   ========================================================================== */
.auth-page { display: grid; place-items: center; min-height: 100dvh; padding: var(--sp-8) var(--page-gutter-r) var(--sp-8) var(--page-gutter-l); }
.auth { width: 100%; max-width: 400px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--sp-2); margin-bottom: var(--sp-6); }
.auth-brand .mark { width: 56px; height: 56px; }
.auth-brand h1 { font-size: var(--fs-xl); }
.auth-brand p { color: var(--ink-2); }
/* The brand tagline (settings.SITE_TAGLINE), quiet under the name: home and sign-in only. */
.auth-brand .auth-motto { margin-top: calc(-1 * var(--sp-1)); font-size: var(--fs-sm); font-style: italic; }

/* ==========================================================================
   14. Print: no app chrome (.print-only: text that stands in for something on paper)
   ========================================================================== */
.print-only { display: none; }
@media print {
  .app-header, .tabbar, .sticky-actions, .toasts, .skip-link, .no-print { display: none !important; }
  .print-only { display: block; overflow-wrap: anywhere; }
  body { background: #fff; color: #000; padding: 0; }
  .page { max-width: none; padding: 0; }
  .page-head h1 { position: static; width: auto; height: auto; margin: 0; clip: auto; clip-path: none; white-space: normal; font-size: 18pt; }
  .card { box-shadow: none; border-color: #999; }
}

/* Account menu (desktop header + phone tab bar) */
.tab-btn { background: none; border: 0; padding: 0; font-family: inherit; cursor: pointer; }
.account-who { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px 8px; }
.account-email { font-size: var(--fs-sm); font-weight: 600; color: var(--ink); overflow-wrap: anywhere; text-transform: none; letter-spacing: 0; }

/* Formatted drill text (drills/richtext.py): setup, rotation, safety. Overrides .prose's
   pre-line, since the HTML carries its own paragraphs and breaks. */
.rich { white-space: normal; }
.rich > :first-child { margin-top: 0; }
.rich > :last-child { margin-bottom: 0; }
.rich p { margin: 0 0 .75em; }
.rich ul, .rich ol { margin: 0 0 .75em; padding-left: 1.4em; }
.rich ul { list-style: disc; }
.rich ul ul { list-style: circle; }
.rich ol ol { list-style: lower-alpha; }
.rich ol { list-style: decimal; }
.rich li { margin: 0 0 .25em; }
.rich li::marker { color: var(--ink-2); }
.rich strong { font-weight: 700; }
.rich a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }

/* The header's workspace switcher (drills/_workspace_menu.html): a long club name ends in "…" (the
   full name is its title); its icons always show, and it gives up room first when the header is narrow. */
.workspace-btn { justify-content: flex-start; min-width: 4.5rem; max-width: 14rem; }
.workspace-btn > .i, .workspace-chip > .i { flex: none; }
.workspace-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-chip { max-width: 100%; }
.menu-item-text { flex: 1; min-width: 0; }
.menu-item > .menu-check { flex: none; margin-left: auto; }
.menu-item-sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-xs); color: var(--ink-2); }

/* Team first: the header's team pill (desktop, and phones next to the mark) and its menu. A long team or
   club name ends in "…"; on a page with a back arrow the phone shows the title instead of the pill. */
.workspace-btn { min-height: 44px; }
.workspace-pill { flex: 0 1 auto; min-width: 0; max-width: 48vw; padding: 0 8px; color: var(--ink); }
.app-header.has-back .workspace-pill { display: none; }
.workspace-club { flex: 0 1 auto; min-width: 0; max-width: 6rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.ws-menu { max-height: min(80vh, 640px); overflow-y: auto; overscroll-behavior: contain; }
.ws-menu .menu-item { min-height: 48px; }
.ws-item-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 720px) { .ws-menu .menu-item { min-height: 44px; } }

/* Team colors: the dot before a team's name (pickers, chips, the header's switcher). */
.team-blue { --team: #3B82F6; }
.team-green { --team: #22A05B; }
.team-orange { --team: #F07C1E; }
.team-purple { --team: #8B5CF6; }
.team-red { --team: #E5484D; }
.team-teal { --team: #14A3A3; }
.team-gold { --team: #D9A400; }
.team-gray { --team: #8A93A3; }
.team-dot {
  display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%;
  background: var(--team, var(--line-strong)); vertical-align: middle;
}

/* Make groups (groups.js, _groups_sheet.html): on a team's Who's here page and in run mode. Big, readable lists. */
.groups-by { border: 0; padding: 0; margin: 0 0 var(--sp-3); }
.groups-stepper { display: flex; align-items: center; justify-content: center; gap: var(--sp-4); margin-bottom: var(--sp-3); }
.groups-n { margin: 0; font-size: var(--fs-lg); min-width: 8rem; text-align: center; }
.groups-n b { font-size: var(--fs-2xl); }
.groups-out { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); }
.groups-out[hidden] { display: none; }
.groups-group { border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-3); }
.groups-name { margin: 0 0 var(--sp-2); font-size: var(--fs-lg); }
.groups-size { font-weight: 400; color: var(--ink-2); }
.groups-players { list-style: none; padding: 0; margin: 0; font-size: var(--fs-xl); line-height: 1.4; font-weight: 600; }
.groups-player { display: block; width: 100%; min-height: 44px; padding: 2px 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.groups-player[aria-expanded="true"] { text-decoration: underline; text-underline-offset: 3px; }
.groups-move { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin: 0 0 var(--sp-2); font-size: var(--fs-sm); }
.groups-modes { flex-wrap: wrap; }

/* Desktop back link (base.html): the header's back arrow is phone-only, so desktops get it above the page. */
.page-back { display: inline-flex; align-items: center; gap: var(--sp-1); min-height: 32px; margin-bottom: var(--sp-2); color: var(--ink-2); font-size: var(--fs-sm); text-decoration: none; border-radius: var(--r-sm); }
.page-back:hover { color: var(--ink); text-decoration: underline; }
.page-back:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Who's here on today's practice (team page, Next practice card): its count after the label. */
.whos-here-btn { gap: var(--sp-2); }
.whos-here-btn .muted { font-weight: 400; }
.team-hub-h + .whos-here-btn { margin-bottom: var(--sp-3); }

/* The labeled-team offer (_labeled_note.html): its two choices on one row, wrapping on phones. */
.labeled-offer p { margin: 0 0 var(--sp-2); }
.labeled-offer-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.labeled-offer-actions form { margin: 0; }
