/*
 * Bloop Arcade - the design system.
 *
 * One stylesheet for every page on the site, including the dashboard at /app/,
 * which is built on top of THIS file rather than beside it. So the component
 * classes below are a contract: rename one and the dashboard breaks quietly.
 * Add, don't rename.
 *
 * No web fonts, no images, no @import, no url() to anywhere. The site must paint
 * on a school Chromebook on a busy network, and everything it needs is here.
 *
 * =============================================================================
 * COMPONENT INDEX  (what to reach for, and the markup it expects)
 * =============================================================================
 *
 * LAYOUT
 *   .container                 centred column, max 1120px, 16px gutters (24 / 32 wider)
 *   .container-narrow          480px - forms (sign up, log in)
 *   .container-medium          720px - reading pages (privacy, terms, account)
 *   .section / .section-tight  vertical rhythm between page bands
 *   .section-tint              a band on the soft tinted background
 *   .stack                     vertical flow with a 16px gap; .stack-sm 8, .stack-lg 32
 *   .cluster                   wrapping row with an 8px gap (buttons, badges)
 *   .grid-auto                 responsive card grid, min 240px per column
 *   .split                     two columns from 880px up, stacked below
 *   .page-head                 title + intro at the top of a page
 *
 * CHROME
 *   .skip-link                 first element in <body>, targets <main id="main">
 *   .site-header > .header-inner > .brand (.brand-mark svg, .brand-name) + .site-nav
 *   .site-nav                  filled by js/site.js from GET /api/me
 *   .nav-avatar                round Bloop link to /account in the header
 *   .site-footer               brand line + .footer-links
 *
 * BUTTONS  (<a> or <button>; min 44px tall - fingers, not cursors)
 *   .btn + .btn-primary | .btn-secondary | .btn-ghost | .btn-danger
 *   sizes .btn-sm | .btn-lg; .btn-block for full width; .btn-icon for square
 *   busy state: aria-busy="true" shows a spinner and blocks clicks
 *
 * FORMS
 *   .field > label.field-label + .input|.select|.textarea + .field-hint + .field-error
 *   put aria-invalid="true" on the control and aria-describedby at the hint/error
 *   .field-row                 side-by-side fields that stack at 320px
 *   .input-group               an input with a button inside it (show password)
 *   .check                     label wrapping a checkbox and its text
 *   .switch                    <label class="switch"><input type="checkbox" role="switch">
 *                              <span class="switch-track" aria-hidden="true"></span> text</label>
 *   .segmented                 <fieldset class="segmented"><legend>..</legend>
 *                              <label><input type="radio" name=..><span>One</span></label>...</fieldset>
 *   .field-nudge               a friendly always-on line under a name box (with .field-hint)
 *   .form-error                error summary box at the top of a form (role="alert")
 *   .copy-field                read-only input + Copy button on one line
 *   .form-actions / .submit-row  the button row at the end of a form
 *   .link-btn                  a button that looks like a link ("Show", "Undo")
 *
 * CONTENT
 *   .card (.card-pad-lg, .card-flat, .card-interactive) > .card-title, .card-text, .card-actions
 *   .tabs[role=tablist] > .tab[role=tab][aria-selected]
 *   .badge + .badge-brand | .badge-success | .badge-danger | .badge-pro | .badge-muted | .badge-teacher
 *   .notice + .notice-info | .notice-success | .notice-danger | .notice-draft
 *   .empty > .empty-art, .empty-title, .empty-text, actions   (empty states)
 *   .list > .list-item          plain rows with a divider (sets, saved Bloops)
 *   .table                      a data table that scrolls inside its own wrapper .table-wrap
 *   .kv                         label/value rows (<dl class="kv"><div><dt>..<dd>..</div></dl>)
 *   .ticks                      a checklist: <li><span><strong>Title</strong><span>text</span></span></li>
 *   .eyebrow                    small uppercase label above a heading
 *   .prose                      long-form text (privacy, terms)
 *   .steps > .step              numbered "how it works" cards
 *   .modal-backdrop > .modal    for <dialog> or a plain overlay
 *   .icon-picker               the Change icon dialog (js/icon-picker.js): .icon-grid > .icon-tile[aria-pressed]
 *   .ck                        a game's controls (controls.js controlsHtml): .ck-group > .ck-title,
 *                              .ck-note, .ck-list > .ck-row (dt keys, dd what), .ck-table; keys are
 *                              .ck-key keycaps and .ck-word words, joined by .ck-or / .ck-plus
 *   .spinner, .skeleton         loading states
 *
 * MONEY  (amber is ONLY ever money)
 *   .purse    <span class="purse"><span class="coin" aria-hidden="true"></span>
 *             <span class="purse-amount">250</span><span class="visually-hidden"> BlooBucks</span></span>
 *   .coin     the BlooBuck coin on its own, sized by font-size
 *   .price    an amber price tag inline: coin + number, or a $ price
 *
 * BLOOPS  (rendered by js/bloops-ui.js)
 *   .bloop + .bloop-xs 24 | .bloop-sm 40 | .bloop-md 64 | .bloop-lg 96 | .bloop-xl 128
 *   .bloop-tile                a Bloop on a soft rounded tile (shop, picker)
 *
 * UTILITIES
 *   .visually-hidden, .muted, .text-sm, .text-xs, .text-lg, .center, .nowrap, .wrap-anywhere
 *   [hidden] always wins.
 *
 * =============================================================================
 * THE RULES THE TOKENS ENCODE
 * =============================================================================
 *   - Brand blue is the ONE action colour: buttons, links, focus.
 *   - Amber is ONLY money: coins, purses, prices. Never a warning, never a button.
 *   - Green is owned / ready / success. Red is ONLY errors and destructive actions.
 *   - Every colour is a token on :root and is REDEFINED in both dark blocks below.
 *     Add a colour token to one block and not the others and dark mode breaks
 *     silently - tests/bloopcade-public.test.js holds the three sets together.
 *
 * WHY TWO BLUES. #3D8BFF is the brand, but white text on it is 3.3:1 - under the
 * 4.5:1 WCAG AA asks of 15-17px button labels. So a filled button uses
 * --brand-fill (#2170E4, 4.7:1 with white), a hair deeper, and link text uses
 * --brand-ink, deep enough to clear 4.5:1 on the page background. The pure brand
 * blue stays on focus rings, the logo and decoration, where there is no text on it.
 * Red has the same problem for the same reason and the same fix (--danger-fill).
 */

/* ---------------------------------------------------------------------------
 * Tokens that do not change with the theme
 * ------------------------------------------------------------------------- */
:root {
  /* System fonts only. ui-rounded is SF Rounded on Apple devices, which gives
     the headings a friendly shape for free; everyone else falls through to
     their own system face. Nothing is downloaded. */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Type scale: 13 / 15 / 17 / 22 / 30 / 44. Nothing else. */
  --fs-xs: 13px;
  --fs-sm: 15px;
  --fs-md: 17px;
  --fs-lg: 22px;
  --fs-xl: 30px;
  --fs-2xl: 44px;

  /* 8px grid. --sp-half exists for the few 4px nudges (badge padding, icon gaps). */
  --sp-half: 4px;
  --sp-1: 8px;
  --sp-2: 16px;
  --sp-3: 24px;
  --sp-4: 32px;
  --sp-5: 40px;
  --sp-6: 48px;
  --sp-8: 64px;
  --sp-10: 80px;

  --r-card: 14px;
  --r-input: 10px;
  --r-pill: 999px;

  --tap: 44px;        /* minimum touch target */
  --header-h: 64px;

  --ease: cubic-bezier(.2, .7, .2, 1);
  --dur: 160ms;
}

/* ---------------------------------------------------------------------------
 * Colour tokens - LIGHT (the default)
 * ------------------------------------------------------------------------- */
:root {
  color-scheme: light;

  --bg: #F7F8FC;
  --bg-tint: #EEF3FF;
  --surface: #FFFFFF;
  --surface-2: #F1F3F9;
  --surface-3: #E7EBF4;
  --header-bg: rgba(247, 248, 252, 0.86);

  --ink: #10131E;
  --ink-2: #363D50;
  --muted: #5A6275;
  --line: #E1E5EF;
  --line-strong: #C3CAD9;
  --input-border: #8A93A6;

  --brand: #3D8BFF;
  --brand-fill: #2170E4;
  --chart-bar: #2170E4;      /* the staff Usage chart; validated >= 3:1 on --surface */
  --brand-fill-hover: #1A62D6;
  --brand-ink: #1A5FCF;
  --brand-soft: #E6F0FF;
  --brand-soft-2: #D3E4FF;
  --on-brand: #FFFFFF;
  --focus: #3D8BFF;

  --money: #FFB627;
  --money-deep: #D98E0B;
  --money-ink: #7A4E00;
  --money-soft: #FFF4DA;

  --success: #2FBF71;
  --success-ink: #13693C;
  --success-soft: #E2F6EB;

  --danger: #E5484D;
  --danger-fill: #CF3339;
  --danger-fill-hover: #B52A30;
  --danger-ink: #B3252B;
  --danger-soft: #FDECEC;

  /* The homepage stage: a sky that fades into a floor the Bloops stand on. */
  --stage-top: #DDEBFF;
  --stage-bottom: #F4F8FF;
  --stage-ground: #CFE0FA;
  --stage-bubble: rgba(61, 139, 255, 0.10);
  --bloop-shadow: rgba(16, 19, 30, 0.14);

  --shadow-1: 0 1px 2px rgba(16, 19, 30, 0.05), 0 1px 3px rgba(16, 19, 30, 0.07);
  --shadow-2: 0 2px 4px rgba(16, 19, 30, 0.04), 0 8px 20px rgba(16, 19, 30, 0.07);
  --shadow-3: 0 12px 40px rgba(16, 19, 30, 0.16);
  --overlay: rgba(16, 19, 30, 0.45);
  --on-danger: #FFFFFF;
  --knob: #FFFFFF;
  --knob-shadow: rgba(16, 19, 30, 0.30);
  --btn-shine: rgba(255, 255, 255, 0.18);
  --btn-glow: rgba(33, 112, 228, 0.28);
  --coin-shine: #FFE3A1;
  --coin-line: rgba(122, 78, 0, 0.45);
  --coin-drop: rgba(0, 0, 0, 0.12);
  --purse-border: rgba(217, 142, 11, 0.35);
  --gold-1: #F7E08A;
  --gold-2: #C9A227;
  --gold-3: #8C6D0F;
  --silver-1: #FFFFFF;
  --silver-2: #B8C0CC;
  --silver-3: #7D8795;
  --mark-ink: #10131E;
  --mark-eye: #FFFFFF;
  --bloop-halo: transparent;
}

/* ---------------------------------------------------------------------------
 * Colour tokens - DARK
 *
 * Twice, on purpose: once for the system preference (unless a page forced
 * light), once for a page that forces dark with data-theme="dark". The site has
 * no theme switch today; the dashboard may add one, and it only has to set the
 * attribute on <html>.
 * ------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: #0E1119;
    --bg-tint: #121828;
    --surface: #171B26;
    --surface-2: #1D2230;
    --surface-3: #252B3B;
    --header-bg: rgba(14, 17, 25, 0.86);

    --ink: #EEF1F8;
    --ink-2: #C9CFDD;
    --muted: #A0A8BA;
    --line: #272E40;
    --line-strong: #3A4359;
    --input-border: #69748B;

    --brand: #3D8BFF;
    --brand-fill: #2170E4;
    --chart-bar: #3D8BFF;
    --brand-fill-hover: #1A62D6;
    --brand-ink: #7EB2FF;
    --brand-soft: #15213A;
    --brand-soft-2: #1C2D4E;
    --on-brand: #FFFFFF;
    --focus: #6AA6FF;

    --money: #FFB627;
    --money-deep: #D98E0B;
    --money-ink: #FFC857;
    --money-soft: #2C2312;

    --success: #2FBF71;
    --success-ink: #5FD897;
    --success-soft: #11281C;

    --danger: #E5484D;
    --danger-fill: #CF3339;
    --danger-fill-hover: #B52A30;
    --danger-ink: #FF8A8E;
    --danger-soft: #2D1618;

    --stage-top: #16233D;
    --stage-bottom: #111827;
    --stage-ground: #1C2A45;
    --stage-bubble: rgba(61, 139, 255, 0.12);
    --bloop-shadow: rgba(0, 0, 0, 0.45);

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.30), 0 1px 3px rgba(0, 0, 0, 0.25);
    --shadow-2: 0 2px 4px rgba(0, 0, 0, 0.25), 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-3: 0 12px 40px rgba(0, 0, 0, 0.55);
    --overlay: rgba(0, 0, 0, 0.6);
    --on-danger: #FFFFFF;
    --knob: #FFFFFF;
    --knob-shadow: rgba(0, 0, 0, 0.50);
    --btn-shine: rgba(255, 255, 255, 0.10);
    --btn-glow: rgba(0, 0, 0, 0.35);
    --coin-shine: #FFE3A1;
    --coin-line: rgba(122, 78, 0, 0.55);
    --coin-drop: rgba(0, 0, 0, 0.35);
    --purse-border: rgba(255, 182, 39, 0.30);
    --gold-1: #F7E08A;
    --gold-2: #C9A227;
    --gold-3: #8C6D0F;
    --silver-1: #FFFFFF;
    --silver-2: #B8C0CC;
    --silver-3: #7D8795;
    --mark-ink: #10131E;
    --mark-eye: #FFFFFF;
    --bloop-halo: rgba(238, 241, 248, 0.28);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0E1119;
  --bg-tint: #121828;
  --surface: #171B26;
  --surface-2: #1D2230;
  --surface-3: #252B3B;
  --header-bg: rgba(14, 17, 25, 0.86);

  --ink: #EEF1F8;
  --ink-2: #C9CFDD;
  --muted: #A0A8BA;
  --line: #272E40;
  --line-strong: #3A4359;
  --input-border: #69748B;

  --brand: #3D8BFF;
  --brand-fill: #2170E4;
  --chart-bar: #3D8BFF;
  --brand-fill-hover: #1A62D6;
  --brand-ink: #7EB2FF;
  --brand-soft: #15213A;
  --brand-soft-2: #1C2D4E;
  --on-brand: #FFFFFF;
  --focus: #6AA6FF;

  --money: #FFB627;
  --money-deep: #D98E0B;
  --money-ink: #FFC857;
  --money-soft: #2C2312;

  --success: #2FBF71;
  --success-ink: #5FD897;
  --success-soft: #11281C;

  --danger: #E5484D;
  --danger-fill: #CF3339;
  --danger-fill-hover: #B52A30;
  --danger-ink: #FF8A8E;
  --danger-soft: #2D1618;

  --stage-top: #16233D;
  --stage-bottom: #111827;
  --stage-ground: #1C2A45;
  --stage-bubble: rgba(61, 139, 255, 0.12);
  --bloop-shadow: rgba(0, 0, 0, 0.45);

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.30), 0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-2: 0 2px 4px rgba(0, 0, 0, 0.25), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-3: 0 12px 40px rgba(0, 0, 0, 0.55);
  --overlay: rgba(0, 0, 0, 0.6);
  --on-danger: #FFFFFF;
  --knob: #FFFFFF;
  --knob-shadow: rgba(0, 0, 0, 0.50);
  --btn-shine: rgba(255, 255, 255, 0.10);
  --btn-glow: rgba(0, 0, 0, 0.35);
  --coin-shine: #FFE3A1;
  --coin-line: rgba(122, 78, 0, 0.55);
  --coin-drop: rgba(0, 0, 0, 0.35);
  --purse-border: rgba(255, 182, 39, 0.30);
  --gold-1: #F7E08A;
  --gold-2: #C9A227;
  --gold-3: #8C6D0F;
  --silver-1: #FFFFFF;
  --silver-2: #B8C0CC;
  --silver-3: #7D8795;
  --mark-ink: #10131E;
  --mark-eye: #FFFFFF;
  --bloop-halo: rgba(238, 241, 248, 0.28);
}

/* ---------------------------------------------------------------------------
 * Base
 * ------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Anchors land below the sticky header rather than under it. */
  scroll-padding-top: calc(var(--header-h) + var(--sp-2));
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  /* The belt to the braces below: nothing on any page may scroll sideways at
     320px. `clip` rather than `hidden` so it does not create a scroll container
     and break position: sticky on the header. */
  overflow-x: clip;
}

main { flex: 1 0 auto; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.2;
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--ink);
}
h1 { font-size: var(--fs-xl); font-weight: 800; }
h2 { font-size: var(--fs-lg); font-weight: 800; }
h3 { font-size: var(--fs-md); font-weight: 700; }
h4 { font-size: var(--fs-sm); font-weight: 700; }
@media (min-width: 640px) {
  h1 { font-size: var(--fs-2xl); letter-spacing: -0.02em; }
  h2 { font-size: var(--fs-xl); }
  h3 { font-size: var(--fs-lg); }
}

p { margin: 0; }
p + p { margin-top: var(--sp-2); }
ul, ol { margin: 0; padding-left: var(--sp-3); }
img, svg { max-width: 100%; }

a {
  color: var(--brand-ink);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}
a:hover { text-decoration-thickness: 2.5px; }

/* One focus style everywhere, only for keyboard users. A 3px ring with an
   offset reads on every surface in both themes. */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

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

[hidden] { display: none !important; }

code, kbd {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 var(--sp-half);
}

hr { border: 0; border-top: 1px solid var(--line); margin: var(--sp-4) 0; }

/* ---------------------------------------------------------------------------
 * Utilities
 * ------------------------------------------------------------------------- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
.muted { color: var(--muted); }
.text-xs { font-size: var(--fs-xs); }
.text-sm { font-size: var(--fs-sm); }
.text-lg { font-size: var(--fs-lg); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
/* Usernames, set titles - anything a person typed can be one long word. */
.wrap-anywhere { overflow-wrap: anywhere; }

/* ---------------------------------------------------------------------------
 * Layout
 * ------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: 1120px;
  margin-inline: auto;
  padding-inline: var(--sp-2);
}
@media (min-width: 640px) { .container { padding-inline: var(--sp-3); } }
@media (min-width: 1024px) { .container { padding-inline: var(--sp-4); } }
/* Narrow containers add their gutter to the max so the READING width is the
   number in the name, not the number minus padding. */
.container-narrow { max-width: calc(480px + 2 * var(--sp-2)); }
.container-medium { max-width: calc(720px + 2 * var(--sp-3)); }

.section { padding-block: var(--sp-6); }
.section-tight { padding-block: var(--sp-4); }
@media (min-width: 880px) { .section { padding-block: var(--sp-10); } }
.section-tint { background: var(--bg-tint); }

.stack > * + * { margin-top: var(--sp-2); }
.stack-sm > * + * { margin-top: var(--sp-1); }
.stack-lg > * + * { margin-top: var(--sp-4); }

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1);
}
.cluster-lg { gap: var(--sp-2); }

.grid-auto {
  display: grid;
  gap: var(--sp-2);
  /* min(100%, ...) is what stops a 240px minimum overflowing a 288px column. */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
}
@media (min-width: 640px) { .grid-auto { gap: var(--sp-3); } }

.split { display: grid; gap: var(--sp-4); align-items: center; }
@media (min-width: 880px) {
  .split { grid-template-columns: 1fr 1fr; gap: var(--sp-8); }
}

.page-head { padding-top: var(--sp-5); padding-bottom: var(--sp-3); }
.page-head p { color: var(--ink-2); margin-top: var(--sp-1); max-width: 60ch; }
@media (min-width: 640px) { .page-head { padding-top: var(--sp-8); } }

.eyebrow {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand-ink);
}

/* ---------------------------------------------------------------------------
 * Skip link, header, nav
 * ------------------------------------------------------------------------- */
.skip-link {
  position: absolute;
  left: var(--sp-2);
  top: -100px;
  z-index: 100;
  background: var(--surface);
  color: var(--ink);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-input);
  box-shadow: var(--shadow-2);
  font-weight: 700;
}
.skip-link:focus-visible { top: var(--sp-1); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-1);
  min-height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-md);
  letter-spacing: -0.01em;
  min-height: var(--tap);
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand-mark { width: 36px; height: 36px; flex-shrink: 0; }
/* The logo: a Bloop reduced to its silhouette - head, two feet, eyes looking
   right the way every Bloop faces. Coloured by token so it follows the theme. */
.mark-body, .mark-foot { fill: var(--brand); stroke: var(--mark-ink); stroke-width: 2.2; }
.mark-foot { fill: var(--brand-fill); }
.mark-eye { fill: var(--mark-eye); stroke: var(--mark-ink); stroke-width: 1.6; }
.mark-pupil { fill: var(--mark-ink); }
.mark-smile { fill: none; stroke: var(--mark-ink); stroke-width: 2; stroke-linecap: round; }
/*
 * Layout math, signed out. The wordmark is ~110-125px depending on the system
 * font, the mark 36, "Log in" + "Sign up" as small buttons ~175 with the gaps:
 * about 350px in all. At 320 (288px of room) that cannot fit, and at 380
 * (348px) it misses by a pixel in a wide font - so the wordmark steps out below
 * 400px. The link keeps its aria-label, and every page says the name in large
 * type directly underneath.
 */
@media (max-width: 399px) { .brand-name { display: none; } }

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  min-width: 0;
}
.nav-user {
  display: none;
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--ink-2);
  max-width: 16ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* From 720px: at 640 the full signed-in row (wordmark, avatar, a 16-character
   name, Dashboard, Log out) is ~585px of 592. Below 720 the avatar alone says
   who you are, and its aria-label carries the name. */
@media (min-width: 720px) { .nav-user { display: inline; } }
.nav-avatar {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  min-height: var(--tap);
  padding: 0 var(--sp-1) 0 0;
  border-radius: var(--r-pill);
  text-decoration: none;
  color: var(--ink);
}
.nav-avatar .bloop,
.nav-avatar .avatar-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-soft);
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
}
.nav-avatar .bloop svg { width: 32px; height: auto; }
/*
 * Layout math, signed in, at 320px (288px of room): mark 36 + avatar 36 +
 * "Dashboard" ~110 + "Log out" ~90 + three 8px gaps = 296. One button too
 * many, so below 480px Log out becomes a 44px icon button (its label stays for
 * screen readers) - 250px - and below 560px the wordmark steps aside while
 * signed in, because with it the row is ~360px.
 */
.nav-logout .icon { display: none; }
@media (max-width: 479px) {
  .nav-logout { width: var(--tap); padding: 0; }
  .nav-logout .icon { display: block; }
  .nav-logout .nav-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
  }
}
@media (max-width: 559px) {
  .site-header.is-signed-in .brand-name { display: none; }
}
/*
 * Layout math, signed in as STAFF: one more button (Staff, ~80px with its
 * label). Mark 36 + avatar 44 + Dashboard ~110 + Staff ~80 + Log out ~95 +
 * gaps ~32 = ~397px:
 *   - below 480 Staff folds to a 44px icon like Log out: ~310 - fits from 400
 *     (368px of room);
 *   - below 400 Dashboard folds to an icon too, for staff only: ~244 of 288 at
 *     320px. Everyone else keeps the word;
 *   - the wordmark stays out until 880, where the name (from 720, ~140) and
 *     the wordmark (~135) both fit: ~670 of 816.
 * Folded buttons keep their words in .nav-label for screen readers.
 */
.nav-staff .icon, .nav-dash .icon { display: none; }
@media (max-width: 479px) {
  .nav-staff { width: var(--tap); padding: 0; }
  .nav-staff .icon { display: block; }
  .nav-staff .nav-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
  }
}
@media (max-width: 399px) {
  .site-header.has-staff .nav-dash { width: var(--tap); padding: 0; }
  .site-header.has-staff .nav-dash .icon { display: block; }
  .site-header.has-staff .nav-dash .nav-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
  }
}
@media (max-width: 879px) {
  .site-header.has-staff .brand-name { display: none; }
}
/*
 * Layout math, signed in as a TEACHER: the Teacher badge (~70px with its gap)
 * rides inside the account link, after the name.
 *   - below 560 it is not drawn: at 480 a teacher who is also staff needs
 *     mark 36 + avatar 44 + badge 70 + Dashboard ~110 + Staff ~80 + Log out
 *     ~95 + gaps ~40 = ~475 of 448. The avatar's aria-label says "teacher"
 *     at every width, so nothing is lost to a screen reader.
 *   - from 560 (528 of room): the same row is ~475 - fits.
 *   - from 720 the name joins it (~140): ~615 of 672.
 *   - the wordmark (~135) stays out until 880 for teachers, as for staff:
 *     ~750 of 816.
 */
.nav-teacher { display: none; margin-left: var(--sp-half); }
@media (min-width: 560px) { .nav-teacher { display: inline-flex; } }
@media (max-width: 879px) {
  .site-header.has-teacher .brand-name { display: none; }
}

/* ---------------------------------------------------------------------------
 * Footer
 * ------------------------------------------------------------------------- */
.site-footer {
  margin-top: var(--sp-8);
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding-block: var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--muted);
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  align-items: center;
  justify-content: space-between;
}
.footer-brand { display: flex; align-items: center; gap: var(--sp-1); }
.footer-brand .brand-mark { width: 28px; height: 28px; }
.footer-brand strong { color: var(--ink); font-family: var(--font-display); }
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-half) var(--sp-3);
  list-style: none;
  margin: 0;
  padding: 0;
}
.footer-links a {
  color: var(--ink-2);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  font-weight: 600;
}
.footer-links a:hover { color: var(--brand-ink); text-decoration: underline; }
.footer-note { flex-basis: 100%; font-size: var(--fs-xs); }

/* ---------------------------------------------------------------------------
 * Buttons
 * ------------------------------------------------------------------------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--ink);
  --btn-border: var(--line-strong);
  --btn-bg-hover: var(--surface-2);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  min-height: var(--tap);
  padding: 0 var(--sp-3);
  border: 1.5px solid var(--btn-border);
  border-radius: var(--r-pill);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease),
              transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:hover { background: var(--btn-bg-hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { border-radius: var(--r-pill); }
.btn[disabled], .btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  --btn-bg: var(--brand-fill);
  --btn-fg: var(--on-brand);
  --btn-border: var(--brand-fill);
  --btn-bg-hover: var(--brand-fill-hover);
  box-shadow: 0 1px 0 var(--btn-shine) inset, 0 2px 6px var(--btn-glow);
}
.btn-primary:hover { border-color: var(--btn-bg-hover); }

.btn-secondary {
  --btn-bg: var(--surface);
  --btn-fg: var(--brand-ink);
  --btn-border: var(--brand-soft-2);
  --btn-bg-hover: var(--brand-soft);
}

.btn-ghost {
  --btn-bg: transparent;
  --btn-fg: var(--ink);
  --btn-border: transparent;
  --btn-bg-hover: var(--surface-2);
}

.btn-danger {
  --btn-bg: var(--danger-fill);
  --btn-fg: var(--on-danger);
  --btn-border: var(--danger-fill);
  --btn-bg-hover: var(--danger-fill-hover);
}
.btn-danger:hover { border-color: var(--btn-bg-hover); }

.btn-sm { min-height: 36px; padding: 0 var(--sp-2); font-size: var(--fs-sm); }
/* A small button is still a 44px target on a touch screen: the visible pill is
   36px, the invisible hit area is not. */
.btn-sm::after {
  content: "";
  position: absolute;
  inset: -4px -2px;
}
.btn-lg { min-height: 56px; padding: 0 var(--sp-4); font-size: var(--fs-md); }
.btn-block { display: flex; width: 100%; }
.btn-icon { padding: 0; width: var(--tap); }

.btn .icon { width: 20px; height: 20px; flex-shrink: 0; }

/* Busy: the label stays (so the width does not jump) but goes invisible, and a
   spinner sits where it was. pointer-events stops a double submit. */
.btn[aria-busy="true"] { color: transparent !important; pointer-events: none; }
.btn[aria-busy="true"]::before {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  left: 50%; top: 50%;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  border: 2.5px solid var(--btn-fg);
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}

/* Text-style button for inline actions ("Show", "Copy") */
.link-btn {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--brand-ink);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  min-height: var(--tap);
}

/* ---------------------------------------------------------------------------
 * Forms
 * ------------------------------------------------------------------------- */
.field { display: grid; gap: var(--sp-1); min-width: 0; }
.field + .field, .field + .field-row, .field-row + .field, .field-row + .field-row,
fieldset.field + .field, .field + fieldset.field { margin-top: var(--sp-3); }

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }

.field-label, fieldset.field > legend {
  font-weight: 700;
  font-size: var(--fs-sm);
  color: var(--ink);
}
fieldset.field > legend { margin-bottom: var(--sp-1); }
.field-hint { font-size: var(--fs-xs); color: var(--muted); }
/* A gentle word under a name box ("Pick a made-up name, not your real one.").
   Never an error: it is always there, never red, and never stops the form -
   the owners chose to ask rather than refuse run-together names. Brand ink,
   so it reads as friendly advice rather than small print. */
.field-nudge { color: var(--brand-ink); font-weight: 600; }
.field-error {
  display: flex;
  gap: var(--sp-half);
  align-items: flex-start;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--danger-ink);
}
.field-error:empty { display: none; }
.field-error::before {
  content: "!";
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: 16px; height: 16px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--danger-fill);
  color: var(--on-danger);
  font-size: var(--fs-xs);
  font-weight: 800;
  line-height: 1;
}

/* Side by side from 400px; stacked below, where two 140px inputs would be cramped. */
.field-row { display: grid; gap: var(--sp-2); }
.field-row > .field + .field { margin-top: 0; }
@media (min-width: 400px) {
  .field-row { grid-template-columns: 1fr 1fr; }
}

.input, .select, .textarea {
  width: 100%;
  min-height: 48px;
  padding: 0 var(--sp-2);
  border: 1.5px solid var(--input-border);
  border-radius: var(--r-input);
  background: var(--surface);
  color: var(--ink);
  /* 17px, never under 16: iOS zooms the page into any input set smaller. */
  font: inherit;
  font-size: var(--fs-md);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.textarea { padding: var(--sp-1) var(--sp-2); min-height: 120px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 1; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-2); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft-2);
  border-radius: var(--r-input);
}
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: var(--danger);
  background: var(--danger-soft);
}
.input[aria-invalid="true"]:focus-visible { box-shadow: 0 0 0 3px var(--danger-soft); }
.input[readonly] { background: var(--surface-2); }
.input[disabled], .select[disabled] { opacity: 0.6; cursor: not-allowed; }

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: var(--sp-5);
  /* The chevron is two gradients, not an image: no url(), nothing to fetch,
     and it follows the theme because it is drawn in currentColor's token. */
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
}

.input-group { position: relative; }
.input-group .input { padding-right: 84px; }
.input-group .input-action {
  position: absolute;
  right: var(--sp-half);
  top: 50%;
  transform: translateY(-50%);
  min-height: 40px;
  padding: 0 var(--sp-2);
  border: 0;
  border-radius: var(--r-input);
  background: transparent;
  color: var(--brand-ink);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 700;
  cursor: pointer;
}
.input-group .input-action:hover { background: var(--surface-2); }

/* Checkbox + text. The box is the native one, tinted - it is the most
   accessible checkbox there is, and accent-color makes it ours. */
.check {
  display: flex;
  gap: var(--sp-2);
  align-items: flex-start;
  padding: var(--sp-2);
  border: 1.5px solid var(--input-border);
  border-radius: var(--r-input);
  background: var(--surface);
  cursor: pointer;
  font-weight: 600;
  line-height: 1.4;
}
.check:hover { border-color: var(--muted); }
.check input {
  flex-shrink: 0;
  width: 22px; height: 22px;
  margin: 0;
  accent-color: var(--brand-fill);
  cursor: pointer;
}
.check:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.check:has(input[aria-invalid="true"]) { border-color: var(--danger); background: var(--danger-soft); }

/* Switch: a real checkbox (role="switch"), visually replaced by the track. */
.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--tap);
  cursor: pointer;
  font-weight: 600;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
}
.switch-track {
  position: relative;
  flex-shrink: 0;
  width: 48px; height: 28px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  border: 1.5px solid var(--input-border);
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 21px; height: 21px;
  border-radius: 50%;
  background: var(--knob);
  box-shadow: 0 1px 3px var(--knob-shadow);
  transition: transform var(--dur) var(--ease);
}
.switch input:checked + .switch-track { background: var(--brand-fill); border-color: var(--brand-fill); }
.switch input:checked + .switch-track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--focus); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: 0.5; }

/* Segmented toggle: radios in a pill. Each option is at least 44px tall and
   they share the width equally, so two options fit at 320px. */
.segmented {
  display: flex;
  padding: var(--sp-half);
  gap: var(--sp-half);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1.5px solid var(--input-border);
  width: 100%;
}
.segmented > legend { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.segmented label {
  flex: 1 1 0;
  min-width: 0;
  position: relative;
}
.segmented input {
  position: absolute;
  opacity: 0;
  inset: 0;
  width: 100%; height: 100%;
  margin: 0;
  cursor: pointer;
}
.segmented span {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: var(--sp-half) var(--sp-2);
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--ink-2);
  text-align: center;
  line-height: 1.25;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.segmented span small { font-size: var(--fs-xs); font-weight: 600; opacity: 0.85; }
.segmented input:hover + span { background: var(--surface); }
.segmented input:checked + span { background: var(--brand-fill); color: var(--on-brand); box-shadow: var(--shadow-1); }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
/* The tall variant, for choices that carry a second line (a price). */
.segmented-lg { border-radius: var(--r-card); }
.segmented-lg span { border-radius: var(--r-input); min-height: 64px; }

.form-error {
  display: flex;
  gap: var(--sp-2);
  align-items: flex-start;
  padding: var(--sp-2);
  border-radius: var(--r-input);
  background: var(--danger-soft);
  border: 1.5px solid var(--danger);
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.form-error::before {
  content: "!";
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--danger-fill);
  color: var(--on-danger);
  font-weight: 800;
  font-size: var(--fs-sm);
}
.form-error:empty { display: none; }
form > .form-error { margin-bottom: var(--sp-3); }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1) var(--sp-2);
  margin-top: var(--sp-4);
}

.copy-field { display: flex; gap: var(--sp-1); }
.copy-field .input { font-family: var(--font-mono); font-size: var(--fs-sm); min-width: 0; }
.copy-field .btn { flex-shrink: 0; }

/* ---------------------------------------------------------------------------
 * Cards
 * ------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-1);
  padding: var(--sp-3) var(--sp-2);
  min-width: 0;
}
@media (min-width: 640px) { .card { padding: var(--sp-3); } }
.card-pad-lg { padding: var(--sp-4) var(--sp-3); }
@media (min-width: 640px) { .card-pad-lg { padding: var(--sp-5); } }
.card-flat { box-shadow: none; }
.card-interactive {
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.card-interactive:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }
.card-title { font-size: var(--fs-lg); font-weight: 800; }
.card-text { color: var(--ink-2); margin-top: var(--sp-1); }
.card-actions { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin-top: var(--sp-3); }
.card-danger { border-color: var(--danger); }

/* ---------------------------------------------------------------------------
 * Tabs
 * ------------------------------------------------------------------------- */
.tabs {
  display: flex;
  gap: var(--sp-half);
  padding: var(--sp-half);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--line);
  /* Scrolls inside itself if a future tab list outgrows 320px; the page never does. */
  overflow-x: auto;
  scrollbar-width: none;
  max-width: 100%;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  min-height: 40px;
  padding: 0 var(--sp-2);
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tab:hover { background: var(--surface); color: var(--ink); }
.tab[aria-selected="true"], .tab[aria-current="page"] {
  background: var(--surface);
  color: var(--brand-ink);
  box-shadow: var(--shadow-1);
}
.tab:focus-visible { border-radius: var(--r-pill); }

/* ---------------------------------------------------------------------------
 * Badges
 * ------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-half);
  padding: 2px 10px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
  vertical-align: middle;
}
.badge-brand { background: var(--brand-soft); color: var(--brand-ink); border-color: var(--brand-soft-2); }
.badge-success { background: var(--success-soft); color: var(--success-ink); border-color: transparent; }
.badge-success::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
}
.badge-danger { background: var(--danger-soft); color: var(--danger-ink); border-color: transparent; }
.badge-muted { background: transparent; color: var(--muted); }
.badge-pro {
  background: var(--brand-fill);
  color: var(--on-brand);
  border-color: var(--brand-fill);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
/* A teacher's school account (DESIGN.md s.13). The success hues, outlined, so
   it reads as "who this is" and never as the Pro badge or a money colour. */
.badge-teacher {
  background: var(--success-soft);
  color: var(--success-ink);
  border-color: var(--success);
}
.badge-draft {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ---------------------------------------------------------------------------
 * Notices and banners
 * ------------------------------------------------------------------------- */
.notice {
  display: flex;
  gap: var(--sp-2);
  align-items: flex-start;
  padding: var(--sp-2);
  border-radius: var(--r-card);
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--fs-sm);
}
.notice > .notice-body > * + * { margin-top: var(--sp-1); }
.notice-info { background: var(--brand-soft); border-color: var(--brand-soft-2); }
.notice-success { background: var(--success-soft); border-color: var(--success); }
.notice-danger { background: var(--danger-soft); border-color: var(--danger); }
/* A draft banner must be impossible to miss and must not borrow a meaning:
   not red (it is not an error), not amber (it is not money). A striped ink
   edge says "unfinished" in any theme. */
.notice-draft {
  border: 2px dashed var(--ink-2);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

/* ---------------------------------------------------------------------------
 * Toasts
 * ------------------------------------------------------------------------- */
.toast-region {
  position: fixed;
  left: 50%;
  bottom: var(--sp-2);
  transform: translateX(-50%);
  z-index: 200;
  display: grid;
  gap: var(--sp-1);
  width: min(440px, calc(100vw - 2 * var(--sp-2)));
  pointer-events: none;
}
.toast {
  display: flex;
  gap: var(--sp-1);
  align-items: flex-start;
  padding: 12px var(--sp-2);
  border-radius: var(--r-card);
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow-3);
  font-size: var(--fs-sm);
  font-weight: 600;
  pointer-events: auto;
  animation: toast-in 200ms var(--ease);
}
.toast::before {
  content: "";
  flex-shrink: 0;
  width: 10px; height: 10px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--brand);
}
.toast-success::before { background: var(--success); }
.toast-error::before { background: var(--danger); }
.toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-close {
  flex-shrink: 0;
  background: none;
  border: 0;
  color: inherit;
  opacity: 0.7;
  font: inherit;
  font-size: var(--fs-lg);
  line-height: 1;
  width: 28px; height: 28px;
  margin: -2px -6px -2px 0;
  border-radius: 50%;
  cursor: pointer;
}
.toast-close:hover { opacity: 1; }
.toast.is-leaving { opacity: 0; transform: translateY(8px); transition: opacity 180ms, transform 180ms; }

/* ---------------------------------------------------------------------------
 * Empty states, lists, tables
 * ------------------------------------------------------------------------- */
.empty {
  display: grid;
  justify-items: center;
  gap: var(--sp-1);
  padding: var(--sp-6) var(--sp-2);
  text-align: center;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-card);
  background: var(--surface);
}
.empty-art { margin-bottom: var(--sp-1); }
.empty-art .bloop { width: 96px; }
.empty-title { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 800; }
.empty-text { color: var(--ink-2); max-width: 42ch; }
.empty > .btn, .empty > .cluster { margin-top: var(--sp-2); }

.list { list-style: none; margin: 0; padding: 0; }
.list-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.list-item:last-child { border-bottom: 0; }
.list-item-main { flex: 1; min-width: 0; }
.list-item-title { font-weight: 700; overflow-wrap: anywhere; }
.list-item-meta { font-size: var(--fs-xs); color: var(--muted); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-card); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { padding: 12px var(--sp-2); text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }

/* Definition-style rows: "Username   bloopfan" on the account page. */
.kv { display: grid; gap: var(--sp-2); margin: 0; }
.kv > div { display: grid; gap: 2px; }
.kv dt { font-size: var(--fs-xs); font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
@media (min-width: 480px) {
  .kv > div { grid-template-columns: 140px 1fr; align-items: baseline; gap: var(--sp-2); }
}

/* ---------------------------------------------------------------------------
 * Money - the only place amber appears
 * ------------------------------------------------------------------------- */
/* The BlooBuck: an original coin in pure CSS, sized by font-size so it sits in
   a line of text at the text's own size. */
.coin {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  width: 1.1em; height: 1.1em;
  border-radius: 50%;
  vertical-align: -0.15em;
  background: radial-gradient(circle at 35% 30%, var(--coin-shine) 0 18%, var(--money) 42%, var(--money-deep) 100%);
  box-shadow: inset 0 0 0 0.09em var(--money-deep), 0 1px 0 var(--coin-drop);
}
/* An inner ring, so it reads as a coin and not a dot. */
.coin::after {
  content: "";
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  border: 0.07em solid var(--coin-line);
}
.purse {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 8px;
  border-radius: var(--r-pill);
  background: var(--money-soft);
  color: var(--money-ink);
  border: 1px solid var(--purse-border);
  font-weight: 800;
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.purse .coin { width: 18px; height: 18px; }
.purse-lg { font-size: var(--fs-lg); padding: 6px 16px 6px 10px; }
.purse-lg .coin { width: 26px; height: 26px; }
.price {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-half);
  color: var(--money-ink);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.price-lg { font-family: var(--font-display); font-size: var(--fs-xl); letter-spacing: -0.02em; }

/* ---------------------------------------------------------------------------
 * Bloops
 * ------------------------------------------------------------------------- */
.bloop {
  display: inline-block;
  line-height: 0;
  flex-shrink: 0;
  vertical-align: middle;
}
.bloop svg {
  display: block; width: 100%; height: auto; overflow: visible;
  /* The Bloop's outline is near-black ink, which vanishes on the dark theme's
     near-black page. A faint light halo (transparent in light) keeps the
     silhouette readable without touching the game's own art. */
  filter: drop-shadow(0 0 1.5px var(--bloop-halo));
}
.bloop-xs { width: 24px; }
.bloop-sm { width: 40px; }
.bloop-md { width: 64px; }
.bloop-lg { width: 96px; }
.bloop-xl { width: 128px; }
/* A Bloop that has not arrived yet (or cannot) keeps its space as a soft blob,
   so nothing jumps when the art lands. */
.bloop:empty {
  aspect-ratio: 648 / 656;
  border-radius: 50% 50% 46% 46%;
  background: var(--surface-3);
}

.bloop-tile {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 12%;
  border-radius: var(--r-card);
  background: radial-gradient(circle at 50% 38%, var(--surface) 0 30%, var(--bg-tint) 100%);
  border: 1px solid var(--line);
}
.bloop-tile .bloop { width: 100%; }

/* ---------------------------------------------------------------------------
 * Modal
 * ------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: var(--sp-2);
  background: var(--overlay);
}
/* max-height twice: 100vh for browsers without dynamic viewport units, then
 * 100dvh. On iPhone Safari 100vh is the viewport with the toolbars HIDDEN,
 * while this fixed backdrop is the viewport you can actually see, so a tall
 * dialog sized by vh overflowed it at both ends - title and Close cut off at
 * the top, Save at the bottom - with no way to scroll them back. */
.modal, dialog.modal {
  width: min(520px, 100%);
  max-height: calc(100vh - 2 * var(--sp-2));
  max-height: calc(100dvh - 2 * var(--sp-2));
  overflow: auto;
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-3);
}
dialog.modal::backdrop { background: var(--overlay); }
/* While a dialog is up, the page behind it does not scroll. */
body.has-modal { overflow: hidden; }

/* ---------------------------------------------------------------------------
 * The icon picker (js/icon-picker.js): Bloop / Hat / Colour for a signed-in
 * person's icon, over the account page or the dashboard.
 *
 * Layout math at 320px: the backdrop's 16px padding leaves a 288px dialog;
 * 16px padding and its 1px border leave 254px inside. The tile grid is
 * minmax(72px, 1fr): three columns of ~79px with two 8px gaps. The three tabs
 * ("Bloop", "Hat", "Colour", ~70px each) fit the same 254px in one row.
 * ------------------------------------------------------------------------- */
.icon-picker { padding: var(--sp-2); }
@media (min-width: 480px) { .icon-picker { padding: var(--sp-3); } }
.icon-picker:focus { outline: none; }
.icon-picker-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-1); }
.icon-picker-title { font-size: var(--fs-lg); font-weight: 800; }
.icon-picker-stage {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: var(--sp-2) 0;
  min-width: 0;
}
.icon-picker-preview {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 88px;
  height: 88px;
  padding-top: var(--sp-1);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, var(--surface) 0 45%, var(--brand-soft) 100%);
  border: 1px solid var(--line);
}
.icon-picker-preview .bloop { width: 56px; }
.icon-picker-caption { min-width: 0; font-weight: 700; color: var(--ink-2); overflow-wrap: anywhere; }
.icon-picker-tabs { margin-bottom: var(--sp-2); }
.icon-panel { min-height: 120px; }
.icon-picker-sub { font-size: var(--fs-sm); font-weight: 800; color: var(--ink-2); margin: var(--sp-2) 0 var(--sp-1); }
.icon-panel > .icon-picker-sub:first-child { margin-top: 0; }
.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: var(--sp-1);
}
.icon-tile {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: var(--sp-half);
  min-width: 0;
  min-height: var(--tap);
  padding: var(--sp-1) var(--sp-half);
  border: 2px solid var(--line);
  border-radius: var(--r-input);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
}
.icon-tile:hover { border-color: var(--line-strong); }
/* Chosen: the brand border AND a tinted fill, never the colour alone. */
.icon-tile[aria-pressed="true"] {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-ink);
  box-shadow: inset 0 0 0 1px var(--brand);
}
.icon-tile:disabled { cursor: not-allowed; background: var(--surface-2); color: var(--muted); }
.icon-tile:disabled .icon-tile-art { opacity: 0.55; }
.icon-tile-art { display: grid; place-items: center; width: 48px; height: 48px; color: var(--ink); }
.icon-tile-art .bloop { width: 44px; }
.icon-tile-art > svg { display: block; width: 44px; height: auto; }
.icon-tile-art > .icon-swatch { width: 36px; }
.icon-tile-label { max-width: 100%; overflow-wrap: anywhere; }
.icon-tile-badge { position: absolute; top: var(--sp-half); right: var(--sp-half); padding: 0 var(--sp-half); font-size: var(--fs-xs); }
.icon-none { display: block; width: 32px; height: 32px; border: 2px dashed var(--line-strong); border-radius: var(--r-input); }
.icon-none-round { border-radius: 50%; }
.icon-picker-more { margin-top: var(--sp-2); font-size: var(--fs-sm); color: var(--ink-2); }
.icon-picker-note { display: grid; justify-items: start; gap: var(--sp-1); padding: var(--sp-2) 0; color: var(--ink-2); }
.icon-picker-error { margin-top: var(--sp-2); }
/* Save stays in reach at the bottom of a long list on a short phone. */
.icon-picker-actions {
  position: sticky;
  bottom: calc(-1 * var(--sp-2));
  margin: var(--sp-2) calc(-1 * var(--sp-2)) calc(-1 * var(--sp-2));
  padding: var(--sp-2);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
@media (min-width: 480px) {
  .icon-picker-actions {
    bottom: calc(-1 * var(--sp-3));
    margin: var(--sp-3) calc(-1 * var(--sp-3)) calc(-1 * var(--sp-3));
    padding: var(--sp-2) var(--sp-3) var(--sp-3);
  }
}

/* ---------------------------------------------------------------------------
 * Loading
 * ------------------------------------------------------------------------- */
.spinner {
  display: inline-block;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 3px solid var(--line-strong);
  border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}
.skeleton {
  display: block;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  min-height: 1em;
}
.loading-block { display: grid; place-items: center; padding: var(--sp-6) 0; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------------------
 * Long-form text (privacy, terms)
 * ------------------------------------------------------------------------- */
.prose { max-width: 70ch; color: var(--ink); }
.prose h2 { margin-top: var(--sp-6); margin-bottom: var(--sp-2); font-size: var(--fs-lg); }
.prose h3 { margin-top: var(--sp-4); margin-bottom: var(--sp-1); font-size: var(--fs-md); }
.prose p, .prose ul, .prose ol { margin-top: var(--sp-2); }
.prose li + li { margin-top: var(--sp-1); }
.prose .placeholder {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--brand-soft);
  color: var(--brand-ink);
  padding: 0 var(--sp-half);
  border-radius: 4px;
}
.prose .review-note {
  display: block;
  margin-top: var(--sp-2);
  padding: var(--sp-1) var(--sp-2);
  border-left: 3px dashed var(--ink-2);
  background: var(--surface-2);
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.notice-draft + .toc, .notice-draft + .prose, .toc + .prose { margin-top: var(--sp-3); }
.toc {
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-card);
  background: var(--surface);
  border: 1px solid var(--line);
}
.toc ol { margin-top: var(--sp-1); columns: 1; }
@media (min-width: 640px) { .toc ol { columns: 2; column-gap: var(--sp-5); } }
.toc li { break-inside: avoid; }

/* ---------------------------------------------------------------------------
 * How it works: numbered steps
 * ------------------------------------------------------------------------- */
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--sp-2);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  counter-reset: step;
}
@media (min-width: 640px) { .steps { gap: var(--sp-3); } }
.step {
  counter-increment: step;
  position: relative;
  padding: var(--sp-3);
  border-radius: var(--r-card);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
}
.step::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  margin-bottom: var(--sp-2);
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-md);
}
.step h3 { font-size: var(--fs-md); }
.step p { margin-top: var(--sp-1); color: var(--ink-2); font-size: var(--fs-sm); }

/* A list with check marks, for "what you get". */
.ticks { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--sp-2); }
.ticks li { display: flex; gap: 12px; align-items: flex-start; }
.ticks li::before {
  content: "";
  flex-shrink: 0;
  width: 24px; height: 24px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--success-soft);
  /* The tick is a rotated L drawn with borders: no image, no font glyph. */
  box-shadow: inset 0 0 0 1.5px var(--success);
}
.ticks li { position: relative; }
.ticks li::after {
  content: "";
  position: absolute;
  left: 8px; top: 6px;
  width: 6px; height: 11px;
  border: solid var(--success-ink);
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}
.ticks li > span { flex: 1; min-width: 0; }
.ticks strong { display: block; color: var(--ink); }
.ticks li > span > span { color: var(--ink-2); font-size: var(--fs-sm); }

/* ===========================================================================
 * PAGE: homepage
 * ======================================================================== */
.hero {
  padding-top: var(--sp-5);
  padding-bottom: var(--sp-4);
  text-align: center;
}
@media (min-width: 640px) { .hero { padding-top: var(--sp-8); } }
.hero-title {
  font-size: var(--fs-xl);
  font-weight: 900;
  letter-spacing: -0.02em;
}
@media (min-width: 480px) { .hero-title { font-size: var(--fs-2xl); letter-spacing: -0.03em; } }
.hero-title .hero-accent { color: var(--brand-ink); }
.hero-promise {
  margin: var(--sp-2) auto 0;
  max-width: 34ch;
  font-size: var(--fs-md);
  color: var(--ink-2);
}
@media (min-width: 640px) { .hero-promise { font-size: var(--fs-lg); } }
.hero-actions {
  display: grid;
  gap: var(--sp-1);
  margin: var(--sp-4) auto 0;
  max-width: 360px;
}
@media (min-width: 480px) {
  .hero-actions {
    grid-template-columns: 1fr 1fr;
    max-width: 440px;
    gap: var(--sp-2);
  }
}
.hero-trust {
  margin-top: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--muted);
}

/* The stage: a strip of sky and floor the Bloops stand on. */
.stage {
  position: relative;
  margin-top: var(--sp-5);
  border-radius: var(--r-card);
  background: linear-gradient(180deg, var(--stage-top), var(--stage-bottom));
  border: 1px solid var(--line);
  overflow: hidden;
  padding: var(--sp-5) var(--sp-2) 0;
  isolation: isolate;
}
/* Soft bubbles in the sky. Decoration only; pseudo-elements so they cost no markup. */
.stage::before, .stage::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  background: var(--stage-bubble);
}
.stage::before { width: 180px; height: 180px; left: -40px; top: -60px; }
.stage::after { width: 120px; height: 120px; right: 8%; top: -30px; }
/* The ground comes FIRST in the markup: it shares z-index -1 with the little
   floor shadows under each Bloop, and at equal z-index later paints on top -
   ground after shadows would hide them. */
.stage-ground {
  position: absolute;
  z-index: -1;
  left: 0; right: 0; bottom: 0;
  height: 28px;
  background: var(--stage-ground);
}
.bloop-row {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  /* Layout math at 320px: 288px row minus the stage's 2 x 16px padding = 256px.
     Four Bloops at 56px + three 8px gaps = 248px. Fits with room. */
  gap: var(--sp-1);
}
.bloop-row li {
  position: relative;
  width: 56px;
  padding-bottom: 12px;
}
/* A little shadow on the floor under each Bloop. */
.bloop-row li::after {
  content: "";
  position: absolute;
  z-index: -1;
  left: 15%; right: 15%;
  bottom: 6px;
  height: 10px;
  border-radius: 50%;
  background: var(--bloop-shadow);
  filter: blur(2px);
}
.bloop-row .bloop { width: 100%; }
/* Show only as many as fit. Everything is in the markup; CSS decides. */
.bloop-row li:nth-child(n+5) { display: none; }
@media (min-width: 480px) {
  .bloop-row li { width: 64px; }
  .bloop-row li:nth-child(5) { display: block; }
}
@media (min-width: 640px) {
  .bloop-row { gap: var(--sp-2); }
  .bloop-row li { width: 80px; }
  .bloop-row li:nth-child(6) { display: block; }
}
@media (min-width: 880px) {
  .bloop-row { gap: var(--sp-3); }
  .bloop-row li { width: 96px; }
  .bloop-row li:nth-child(n+7) { display: block; }
}
/* The biggest one in the middle, so the row has a shape rather than a ruler. */
@media (min-width: 880px) {
  .bloop-row li:nth-child(4) { width: 120px; }
}

/* Motion: a slow, staggered bob. Small, and off entirely for anyone who asks. */
@media (prefers-reduced-motion: no-preference) {
  .bloop-row .bloop { animation: bob 2.8s ease-in-out infinite; transform-origin: 50% 100%; }
  .bloop-row li:nth-child(2n) .bloop { animation-delay: -0.7s; animation-duration: 3.1s; }
  .bloop-row li:nth-child(3n) .bloop { animation-delay: -1.4s; animation-duration: 2.6s; }
  .bloop-row li:nth-child(5n) .bloop { animation-delay: -2.1s; }
  .bloop-row li:hover .bloop { animation: hop 0.5s var(--ease); }
}
@keyframes bob {
  0%, 100% { transform: translateY(0) scaleY(1); }
  50% { transform: translateY(-6px) scaleY(1.02); }
}
@keyframes hop {
  0% { transform: translateY(0) scale(1.05, 0.95); }
  45% { transform: translateY(-16px) scale(0.97, 1.04); }
  100% { transform: translateY(0) scale(1); }
}

/* Classroom promises under the hero. */
.promises {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--sp-2);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
}
.promises li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.promises strong { display: block; color: var(--ink); font-size: var(--fs-md); }
.promise-dot {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand-ink);
}
.promise-dot svg { width: 22px; height: 22px; }

/* Our story: text beside a little drawing of a shared doc with Bloops on it. */
.story-text p { color: var(--ink-2); font-size: var(--fs-md); }
.story-text h2 { margin-bottom: var(--sp-2); }
.story-doc {
  position: relative;
  margin: 0 auto;
  width: min(100%, 360px);
  padding: var(--sp-4) var(--sp-3) var(--sp-5);
  border-radius: var(--r-card);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-2);
}
.story-doc-line {
  display: block;
  height: 10px;
  margin-top: 12px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
}
.story-doc-line:first-child { width: 55%; height: 14px; margin-top: 0; background: var(--line-strong); }
.story-doc-line.short { width: 70%; }
.story-doc-line.shorter { width: 40%; }
.story-doc-game {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: var(--sp-1);
  margin-top: var(--sp-3);
  padding: var(--sp-2) var(--sp-2) 12px;
  border-radius: var(--r-input);
  background: linear-gradient(180deg, var(--stage-top), var(--stage-bottom));
  border: 1px solid var(--line);
}
.story-doc-game .bloop { width: 48px; }
.story-doc-game .bloop:nth-child(2) { width: 64px; }
.story-peek {
  position: absolute;
  right: -12px;
  bottom: -20px;
  width: 72px;
  transform: rotate(8deg);
}
@media (max-width: 399px) { .story-peek { right: -4px; width: 60px; } }

/* Section heading used above a grid (How it works, What Pro unlocks). */
.section-title { margin-bottom: var(--sp-3); }
.center-head { text-align: center; padding-top: 0; }
.center-head h2 { margin-top: var(--sp-1); }

/* Pro teaser */
.pro-teaser {
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-3);
  border-radius: var(--r-card);
  background: linear-gradient(135deg, var(--brand-soft), var(--surface) 70%);
  border: 1px solid var(--brand-soft-2);
}
@media (min-width: 880px) {
  .pro-teaser { grid-template-columns: 1.2fr 1fr; align-items: center; padding: var(--sp-6); }
}
.pro-teaser-price { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-1); }
@media (min-width: 880px) { .pro-teaser-price { justify-content: center; } }
.pro-teaser h2 { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1); }

/* ===========================================================================
 * PAGE: forms (sign up, log in, account)
 * ======================================================================== */
.auth-wrap { padding-top: var(--sp-4); }
@media (min-width: 640px) { .auth-wrap { padding-top: var(--sp-8); } }
.auth-card { padding: var(--sp-4) var(--sp-2); }
@media (min-width: 480px) { .auth-card { padding: var(--sp-5) var(--sp-4); } }
.auth-head { text-align: center; margin-bottom: var(--sp-4); }
.auth-head .bloop { width: 72px; margin-bottom: var(--sp-1); }
.auth-head h1 { font-size: var(--fs-xl); }
.auth-head p { margin-top: var(--sp-1); color: var(--ink-2); }
.auth-alt { margin-top: var(--sp-3); text-align: center; font-size: var(--fs-sm); color: var(--ink-2); }

/* School sign-in (DESIGN.md s.13): the Google button, when the site has it
   set up, and the line about the Comms Games button, below the username form
   and set off from it by a rule - a second way in, not a step of the first. */
.auth-school {
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--line);
  display: grid;
  gap: var(--sp-1);
}
.auth-school-note { text-align: center; font-size: var(--fs-sm); color: var(--ink-2); }
.auth-lead { margin-bottom: var(--sp-3); color: var(--ink-2); text-align: center; }

/* The sign-up button and the privacy link share a line on purpose: the link is
   right where the decision is made, not buried in the footer. */
.submit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1) var(--sp-2);
  margin-top: var(--sp-4);
}
.submit-row .btn { flex: 1 1 180px; }
.submit-row .submit-aside { flex: 1 1 140px; font-size: var(--fs-sm); color: var(--ink-2); }

.friendly-stop { text-align: center; }
.friendly-stop h1 { font-size: var(--fs-xl); margin-bottom: var(--sp-2); }
.friendly-stop .stack { color: var(--ink-2); }
.friendly-stop .form-actions { flex-direction: column; }

/* "Forgot your password?" - an honest answer, folded away until asked for. */
.help-details {
  margin-top: var(--sp-3);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-input);
  background: var(--surface-2);
  font-size: var(--fs-sm);
}
.help-details summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--brand-ink);
  min-height: var(--tap);
  display: flex;
  align-items: center;
}
.help-details p { padding-bottom: var(--sp-1); color: var(--ink-2); }

/* Account page */
.account-profile { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); min-width: 0; }
.account-profile > div { min-width: 0; }
.account-profile h2 { font-size: var(--fs-lg); }
.account-profile .bloop { width: 72px; }
@media (min-width: 640px) { .account-profile .bloop { width: 96px; } }
.account-profile-actions { margin-top: var(--sp-1); }
.delete-confirm { margin-top: var(--sp-3); }

.friendly-stop .bloop { width: 96px; margin-bottom: var(--sp-2); }

/* ===========================================================================
 * PAGE: Pro
 * ======================================================================== */
.pro-hero { text-align: center; padding-top: var(--sp-5); }
@media (min-width: 640px) { .pro-hero { padding-top: var(--sp-8); } }
.pro-hero p { margin: var(--sp-2) auto 0; max-width: 46ch; color: var(--ink-2); }
.pro-prices {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
}
.pro-price {
  flex: 1 1 140px;
  max-width: 220px;
  padding: var(--sp-3) var(--sp-2);
  border-radius: var(--r-card);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  text-align: center;
}
.pro-price .price { justify-content: center; }
.pro-price small { display: block; margin-top: var(--sp-half); color: var(--muted); font-size: var(--fs-xs); font-weight: 600; }
.perk-grid { display: grid; gap: var(--sp-2); grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.perk { padding: var(--sp-3); }
.perk-icon {
  display: grid;
  place-items: center;
  width: 48px; height: 48px;
  margin-bottom: var(--sp-2);
  border-radius: 14px;
  background: var(--brand-soft);
  color: var(--brand-ink);
}
.perk-icon svg { width: 26px; height: 26px; }
.perk h3 { font-size: var(--fs-md); }
.perk p { margin-top: var(--sp-1); color: var(--ink-2); font-size: var(--fs-sm); }
/* The two Pro colour chips. Swatches of a player colour, not money - so not amber. */
.swatch-pair { display: inline-flex; gap: 6px; }
.swatch {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--line-strong);
}
.swatch-gold { background: linear-gradient(135deg, var(--gold-1), var(--gold-2) 60%, var(--gold-3)); }
.swatch-silver { background: linear-gradient(135deg, var(--silver-1), var(--silver-2) 60%, var(--silver-3)); }

.ask-card { max-width: 560px; margin-inline: auto; }
.ask-card > .card-title { margin-bottom: var(--sp-2); }
.ask-card .form-error { margin-top: var(--sp-2); }
.pro-cash { margin-bottom: var(--sp-3); }
.pro-until { font-family: var(--font-display); font-weight: 800; font-size: var(--fs-lg); }
/*
 * The username, big enough for a staff member to read off a screen held up
 * across a desk, and in the monospace face so 0/O and l/1/I are told apart -
 * the one thing that must survive being typed in by somebody else. Never cut
 * short: a 20-character name wraps rather than ellipsing (320px fits ~14 at
 * this size).
 */
.pro-name-box {
  display: grid;
  justify-items: start;
  gap: var(--sp-1);
  padding: var(--sp-2);
  border-radius: var(--r-input);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.pro-name-label { font-size: var(--fs-xs); font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.pro-name {
  font-family: var(--font-mono);
  font-size: var(--fs-xl);
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
  max-width: 100%;
}
.pro-fair { margin-top: var(--sp-3); }
.pro-hero .badge-pro { margin-bottom: var(--sp-2); }

/* ===========================================================================
 * PAGE: Account - the Comms Games link code (DESIGN.md s.15)
 * A code read off the screen by a child and typed into the sidebar: big,
 * monospaced, spaced out, and never wrapped. "ABC-234" at --fs-2xl is about
 * 190px wide, so it fits a 320px screen inside the card's padding.
 * ======================================================================== */
.link-code-box {
  display: grid;
  justify-items: start;
  gap: var(--sp-1);
  padding: var(--sp-2);
  border-radius: var(--r-input);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.link-code-label { font-size: var(--fs-xs); font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.link-code {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-2xl);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0.08em;
  white-space: nowrap;
  color: var(--ink);
  max-width: 100%;
}
.link-code:focus { outline: none; }
.link-code:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.link-code.is-expired { color: var(--muted); text-decoration: line-through; }
.link-code-time { margin: 0; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
@media (max-width: 359px) {
  .link-code { font-size: var(--fs-xl); }
}

/* ===========================================================================
 * PAGE: a shared set (/s/<id> - share.html, DESIGN.md s.7)
 * Read-only questions, one card each. Text is set by js/pages/share.js
 * through esc(); long words break (wrap-anywhere) so 320px never scrolls.
 * ======================================================================== */
.share-head { padding-bottom: var(--sp-2); }
.share-head .eyebrow { margin-bottom: var(--sp-1); }
.share-desc { color: var(--ink-2); max-width: 60ch; white-space: pre-line; }
.share-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1); font-size: var(--fs-sm); color: var(--ink-2); }
.share-copy .card-title { font-size: var(--fs-md); }
.share-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); counter-reset: share-q; }
.share-item { counter-increment: share-q; }
.share-kind { font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.share-kind::before { content: counter(share-q) " \00B7  "; }
.share-q { margin-top: var(--sp-half); font-weight: 700; white-space: pre-line; }
.share-answers { margin-top: var(--sp-1); font-size: var(--fs-sm); color: var(--ink-2); }
.share-label { font-weight: 700; color: var(--ink); }
.share-right .share-label { color: var(--success-ink); }

/* ===========================================================================
 * PAGE: Staff (/staff/) - cash Pro and the cash log
 * ======================================================================== */
.staff-intro { color: var(--ink-2); max-width: 60ch; }
/* Username box and its button on one row; below 400px the button drops under
   it at full width rather than squeezing the box to nothing. */
.lookup-row { display: flex; gap: var(--sp-1); }
.lookup-row .input { flex: 1; min-width: 0; font-family: var(--font-mono); }
.lookup-row .btn { flex-shrink: 0; }
@media (max-width: 399px) {
  .lookup-row { flex-direction: column; }
}
.player-slot:not(:empty) { margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--line); }
.player-head { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.player-bloop { width: 72px; }
@media (min-width: 640px) { .player-bloop { width: 96px; } }
.player-id { min-width: 0; }
/* The same monospace, large face as the Pro page's username, so what the
   student holds up and what staff see here look alike. */
.player-name { font-family: var(--font-mono); font-size: var(--fs-lg); font-weight: 700; }
.player-pro { margin-top: var(--sp-half); font-size: var(--fs-sm); color: var(--ink-2); }
/*
 * The money controls. Arm buttons on top, the band under them: Confirm only
 * ever appears in the band, never where an arm button was, so a double tap on
 * an arm button can only arm and disarm (js/pages/staff.js). The band keeps a
 * minimum height so arming a plan does not push the page about under the
 * staff member's thumb.
 */
.grant { margin-top: var(--sp-3); display: grid; gap: var(--sp-2); }
.grant-arms { display: grid; gap: var(--sp-1); grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.grant-arm[aria-pressed="true"] {
  --btn-bg: var(--brand-soft); --btn-bg-hover: var(--brand-soft-2); --btn-fg: var(--brand-ink); --btn-border: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand);
}
.grant-undo[aria-pressed="true"] {
  --btn-bg: var(--danger-soft); --btn-bg-hover: var(--danger-soft); --btn-fg: var(--danger-ink); --btn-border: var(--danger);
  box-shadow: inset 0 0 0 1px var(--danger);
}
.grant-band {
  min-height: 104px;
  display: grid;
  align-content: start;
  gap: var(--sp-2);
  padding: var(--sp-2);
  border-radius: var(--r-input);
  background: var(--surface-2);
}
.grant-q { font-size: var(--fs-md); overflow-wrap: anywhere; }
.grant-actions { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.grant-band .notice { margin: 0; }

.log-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-1); }
.cash-total { margin-top: var(--sp-3); padding: var(--sp-2); border-radius: var(--r-input); background: var(--surface-2); }
.cash-total-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-1); font-weight: 700; }
.log-sub { margin-top: var(--sp-3); font-size: var(--fs-md); }
.staff-totals .list-item-meta { display: inline; }
.grant-log { margin-top: var(--sp-3); }
.grant-log:focus { outline: none; }
.grant-meta { display: block; overflow-wrap: anywhere; }
/* An undone grant stays in the log - it is part of the cash record - struck
   through, greyed, and labelled "Undone" in words, never by the line alone. */
.grant-row.is-undone .grant-strike,
.grant-row.is-undone .price { text-decoration: line-through; color: var(--muted); }
.log-foot:not(:empty) { margin-top: var(--sp-2); display: grid; justify-items: start; gap: var(--sp-1); }
.log-empty { margin-top: var(--sp-2); }

/* ===========================================================================
 * Controls: /controls, drawn from the game's own controls.js
 * ======================================================================== */
.controls-tabs { margin-bottom: var(--sp-2); }
.controls-card { animation: controls-in var(--dur) var(--ease) both; }
.controls-tag { margin-bottom: var(--sp-2); }
@keyframes controls-in { from { opacity: 0; transform: translateY(6px); } }
.ck-group + .ck-group { margin-top: var(--sp-3); padding-top: var(--sp-2); border-top: 1px solid var(--line); }
.ck-title { margin: 0 0 var(--sp-1); font-size: var(--fs-xs); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ck-note { margin: 0 0 var(--sp-1); font-size: var(--fs-xs); color: var(--muted); }
.ck-list { margin: 0; display: grid; gap: var(--sp-1); }
.ck-row { display: grid; grid-template-columns: minmax(150px, 36%) 1fr; gap: var(--sp-2); align-items: baseline; }
.ck-row dt, .ck-row dd { margin: 0; min-width: 0; }
.ck-row dd { color: var(--ink-2); }
.ck-keys { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--sp-half); }
.ck-key {
  display: inline-block; min-width: 30px; padding: 2px 8px; text-align: center;
  font: 700 var(--fs-xs)/1.5 var(--font); color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line-strong); border-bottom-width: 3px; border-radius: 7px;
}
.ck-word { font-size: var(--fs-xs); font-style: italic; color: var(--muted); }
.ck-or, .ck-plus { font-size: var(--fs-xs); color: var(--muted); }
.ck-table { width: 100%; border-collapse: collapse; }
.ck-table th, .ck-table td { padding: var(--sp-half) var(--sp-1); text-align: left; vertical-align: middle; }
.ck-table thead th { font-size: var(--fs-xs); color: var(--muted); }
.ck-table tbody th { font-weight: 700; }
.ck-table tbody tr + tr { border-top: 1px solid var(--line); }
@media (max-width: 520px) {
  .ck-row { grid-template-columns: 1fr; gap: 2px; }
  .ck-row + .ck-row { margin-top: var(--sp-half); }
}

/* ===========================================================================
 * Staff: Usage (js/usage-model.js). Totals only.
 * ======================================================================== */
.u-controls { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin: var(--sp-2) 0; }
.u-h { margin: var(--sp-3) 0 var(--sp-1); font-size: var(--fs-xs); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.u-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--sp-1); }
.u-tile { display: grid; gap: 2px; padding: var(--sp-1) var(--sp-2); border: 1px solid var(--line); border-radius: var(--r-input); background: var(--surface-2); }
.u-tile-l { font-size: var(--fs-xs); color: var(--muted); }
.u-tile-v { font-size: var(--fs-lg); font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.u-tile-s { font-size: var(--fs-xs); color: var(--ink-2); }
.u-chartwrap { position: relative; }
.u-chart { display: block; width: 100%; height: auto; }
.u-chart .u-grid { stroke: var(--line); stroke-width: 1; }
.u-chart .u-base { stroke: var(--line-strong); stroke-width: 1; }
.u-chart .u-ax { fill: var(--muted); font: 600 11px var(--font); font-variant-numeric: tabular-nums; }
.u-chart .u-bar { fill: var(--chart-bar); }
.u-chart .u-hit { cursor: default; }
.u-chart .u-hit.on { fill: var(--brand-soft); fill-opacity: .5; }
.u-tip { position: absolute; z-index: 2; pointer-events: none; display: grid; gap: 2px; min-width: 150px;
  padding: var(--sp-1) var(--sp-2); border: 1px solid var(--line); border-radius: var(--r-input);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2); font-size: var(--fs-xs); }
.u-tip span { color: var(--ink-2); }
.u-split { margin-top: var(--sp-1); }
.u-table td, .u-table th { font-variant-numeric: tabular-nums; }
.u-table tbody th { text-transform: none; letter-spacing: 0; font-size: var(--fs-sm); font-weight: 700; color: var(--ink); }

/* ===========================================================================
 * Motion off: everything above that moves, stops.
 * ======================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  /* The spinners are information, not decoration - keep them turning, slowly. */
  .spinner, .btn[aria-busy="true"]::before {
    animation-duration: 1.6s !important;
    animation-iteration-count: infinite !important;
  }
}

/* Windows High Contrast / forced colours: keep focus and buttons visible. */
@media (forced-colors: active) {
  .btn { border: 2px solid ButtonText; }
  .segmented input:checked + span { outline: 2px solid Highlight; }
  .switch-track::after { background: ButtonText; }
}
