/* Self-hosted fonts (Latin subset, variable woff2; licences beside the files in wwwroot/fonts/).
   Inter covers weights 400-700; Newsreader covers 500-600 with its optical-size axis. */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('../fonts/Inter-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Inter's figures with a line box that hugs them (lining figures stand 0.73em on the baseline), for board
   digits that share a cell: the Builder's cage sums and givens (PuzzleEditor.razor.css). The default
   ascent and descent add about half an em of empty space around a digit. */
@font-face {
    font-family: 'Inter Figures';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('../fonts/Inter-latin.woff2') format('woff2');
    /* digits, and the space: a face's line metrics are used only when it covers U+0020 */
    unicode-range: U+0020, U+0030-0039;
    ascent-override: 76%;
    descent-override: 2%;
    line-gap-override: 0%;
}
@font-face {
    font-family: 'Newsreader';
    font-style: normal;
    font-weight: 500 600;
    font-display: swap;
    src: url('../fonts/Newsreader-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ============================================================================
   Design tokens (Killer Sudoku Companion v5)
   ----------------------------------------------------------------------------
   Every colour, type size, space, radius, shadow and duration on every page
   comes from these custom properties. :root holds the light values; the
   @media (prefers-color-scheme: dark) block below redefines the colour names for
   dark mode, and an identical :root[data-theme="dark"] block forces them
   (data-theme="light" opts out of the media query). data-theme is the
   Settings sheet's theme choice; System leaves it off. Component stylesheets (app.css, every *.razor.css) use var(...)
   only; scoped razor.css inherits these from :root.

   Two families live here:
   - Chrome tokens (paper, surfaces, ink, lines, accent, danger, warn, type,
     spacing, radius, elevation, motion) are the v5 set from
     docs/ux-redesign/v5/mockups/tokens.css, with design.md section 5's measured
     contrast. One accent, no gradients, no glows.
   - Board-side tokens (board, cells, cages, values, marks, hint, coach,
     conflict, check, selection, match, scratch colours, Builder cells) keep
     their shipped names, except the owner-requested v5.4/v5.5 board inks
     (design.md section 10, "Coach board inks"): the Check tint and ink
     (--check-fill, --check-ink, from the danger pair), the dark coach fill and
     wash raised to #4f3f10 / #302710, and the answer pick drawn in the accent
     (--coach-pick, --coach-pick-text). The current-cell ring is --ink. Where a
     v5 name collides with another shipped board token (--hint-ink,
     --conflict-fill, --conflict-text), the shipped value is kept.

   Contrast (WCAG 2.1: text 4.5:1, non-text indicators 3:1)
   ----------------------------------------------------------------------------
   `python3 tools/contrast-check.py` measures every board foreground against the
   fixed set of backgrounds a cell can show (the bare surface, the selection
   fill, the hint-context wash and the conflict fill: the GATE tier), the
   Builder's cells and controls, and the chrome text and controls on the v5
   surfaces. An ADVISORY tier measures the translucent scratch-colour washes on
   each base surface.

   The only literal colours outside this block are the warning glyph inside
   the error boundary's SVG data URI.
   ============================================================================ */
:root {
    color-scheme: light dark;

    /* ---- safe-area insets: always 0 ----
       index.html has no `viewport-fit=cover`, so the page never draws under system bars and every
       safe-area inset is 0 by spec (Chrome and Safari report 0). Firefox for Android reports the system
       inset anyway (24px above the gesture bar), which pads a band into the page. All CSS reads these
       properties and never `env(safe-area-inset-*)` directly (SafeAreaInsetGuardTests enforces it).
       If `viewport-fit=cover` is ever added, set these to env(safe-area-inset-top/right/bottom/left). */
    --safe-top: 0px;
    --safe-right: 0px;
    --safe-bottom: 0px;
    --safe-left: 0px;

    /* ---- type: four sizes ---- */
    --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-display: 'Newsreader', 'Iowan Old Style', Georgia, serif;
    --t-small: 13px;   --lh-small: 18px;   /* meta, captions, tab labels, eyebrows */
    --t-body: 16px;    --lh-body: 24px;    /* body, buttons, list titles */
    --t-title: 21px;   --lh-title: 28px;   /* section and card titles (serif) */
    --t-display: 32px; --lh-display: 38px; /* one per screen: page title, finish time (serif) */

    /* ---- spacing: 4px grid ---- */
    --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

    /* ---- radius and elevation ---- */
    --r-sm: 8px;   /* buttons, inputs, chips */
    --r-md: 12px;  /* cards, row groups */
    --r-lg: 20px;  /* sheets, dialogs */
    --shadow-pop: 0 1px 2px rgba(28, 25, 20, .08), 0 12px 32px rgba(28, 25, 20, .14);
    /* bottom-anchored dock cards cast their shadow upward */
    --shadow-dock: 0 -4px 16px rgba(28, 25, 20, .10);

    /* ---- motion ---- */
    --ease: cubic-bezier(.2, .8, .2, 1);
    --ease-spring: cubic-bezier(.2, 1.35, .4, 1);   /* a touch of overshoot: a digit settling, a mark popping */
    --dur-1: 120ms; --dur-2: 220ms; --dur-3: 360ms;
    /* The board's own moments (approved motion study): a placed digit settling, a completed house or cage
       rippling out from the move (staggered 45ms a cell in C#, BoardMotion), a conflict's shake, a coach hint's
       tint (30ms a cell) and its target's one pulse, and the browse lists fading up (70ms an item). */
    --dur-settle: 200ms; --dur-ripple: 560ms; --dur-lift: 440ms; --dur-shake: 320ms;
    --dur-hint: 260ms; --dur-pulse: 760ms; --dur-enter: 380ms;

    /* ---- layout (browse shell; breakpoints: phone < 700, tablet 700-1049, desktop >= 1050) ---- */
    --appbar-h: 56px;
    --tabbar-h: 64px;
    --content-max: 1040px;
    --gutter: 16px;

    /* ---- chrome colour ---- */
    --bg: #f6f4ef;            /* page: warm paper */
    --surface: #ffffff;       /* cards, sheets, inputs, buttons */
    --surface-2: #efece5;     /* sunken fills, hover, insets, segmented track */
    --line: #e2ddd3;          /* hairlines, card borders */
    --line-strong: #8f887b;   /* input and control borders (3:1 non-text on surface) */
    --btn-line: #cbc4b7;      /* secondary button outline (the label carries the meaning) */
    --ink: #1c1b19;           /* primary text */
    --ink-2: #4f4b44;         /* secondary text */
    --ink-3: #6b665c;         /* meta text (still AA on bg) */
    --accent: #1d6a70;        /* the one accent: primary buttons, selection, status fill */
    --accent-hover: #175a5f;
    --on-accent: #ffffff;
    --accent-text: #1a5f65;   /* accent used as text or link */
    --accent-soft: #e2eeee;   /* selected chip, confirmation and readout fills */
    --danger: #a8321f;
    --danger-soft: #f8e8e4;
    --warn-bg: #fbf1d8;
    --warn-line: #e9cf8a;
    --warn-ink: #5c4300;
    --scrim: rgba(28, 25, 20, .42);
    --focus: #1d6a70;
    /* App extensions on the v5 set: the faint edge round a tinted notice
       (v5 _play.css draws the alert status line's border the same way). */
    --danger-line: color-mix(in srgb, var(--danger) 30%, transparent);
    --accent-line: color-mix(in srgb, var(--accent) 30%, transparent);

    /* ==== board-side tokens: shipped values, except the v5.5 coach fill and wash ==== */

    /* ---- scratch colour trio (corner dots, swatches, colour-button drop) ---- */
    --swatch-1: #9333ea;
    --swatch-2: #db2777;
    --swatch-3: #0d9488;
    --swatch-halo: rgba(255, 255, 255, 0.85);   /* the ring that lifts a corner dot off the cell */

    /* ---- Builder cells ----
       Cage fills are theme tokens rather than inline light-only pastel literals. */
    --editor-cell-bg: var(--board-surface);
    --editor-cell-text: #13263f;
    --editor-cage-text: #13263f;
    --editor-frame: #0f172a;
    --editor-grid-rule: var(--box-border);
    --editor-selection-ring: #17643c;
    --editor-selection-fill: #cfe3e2;            /* phase 3: the Builder selection fill (v5 --board-sel) */
    --editor-drag-ring: var(--editor-selection-ring);
    --editor-active-ring: var(--selection-ring);
    --editor-focus-ring: #13263f;
    --editor-grid-focus: #0071c1;
    --editor-pending-bg: #13263f;
    --editor-pending-text: var(--board-surface);
    --editor-cage-1: #fbe4e6;
    --editor-cage-2: #e3f1ff;
    --editor-cage-3: #e2f7ea;
    --editor-cage-4: #fdf2d5;
    --editor-cage-5: #f0e2ff;
    --editor-cage-6: #ffe5f6;
    --editor-cage-7: #e0f6f9;
    --editor-cage-8: #fff1e0;
    --editor-cage-9: #eef8d8;

    /* ---- board cells ----
       Flat and monochrome: one surface colour for every cell, a uniform hairline
       between them, a 2px rule on the 3x3 boxes and board edge, and the cage
       drawn as a dashed inset rule rather than a tint. --cage-inset is the
       proportional (not pixel) gap the dashed rule floats inside the cell, so it
       lands in the same place at any board size; theme-independent, so it lives
       here rather than in either colour block below. */
    --cage-inset: 4%;
    --board-surface: #ffffff;
    --grid-line: #d6d1c6;                         /* every cell-to-cell hairline (v5 board-thin) */
    --box-border: #1c1b19;                        /* 3x3 box rule + board edge (v5 board-box) */
    --cage-edge: #6b665c;                          /* dashed cage outline (v5 board-cage) */
    --cell-text: #15181c;
    --cage-label-text: #1c1b19;                    /* v5 board-sum (owner #38) */
    --thumb-filled: #e3e9e7;                       /* a filled cell in a 56px board thumbnail (v5 --board-filled-mini) */

    /* ---- selection ----
       One flat fill for every selected cell, the teal the v5 mockups call
       board-sel (play.html's selected cell); the current cell adds the 2.5px
       ink ring. The peer tint is the mockups' board-peer: with one cell
       selected, its row, column, box and cage take it. The ring colour (the
       accent) is the thin ring a selected cell keeps where a coach, Check or conflict fill takes its
       background, and the board's keyboard-focus ring. */
    --selection-ring: #1d6a70;
    --selection-fill: #d6e8e7;
    --selection-peer: #f1efe9;

    /* ---- value families ---- */
    --value-given: #15181c;                        /* 16.0:1 on --board-surface */
    --value-player: #1c1b19;                       /* v5 board-digit: the player's digits in ink (owner #38) */
    --value-coach: #6d3bc4;                        /*  7.4:1 */
    --mark: #4f4b44;                               /* v5 board-note */
    /* A ghost value (a lone mark left by a removal): the accent ink on a soft accent disc, which
       the selected and coach-filled cells swap for --board-surface (BoardCell.razor.css). Aliases, so
       the dark accent follows by itself; the digit on either disc is gated in tools/contrast-check.py. */
    --value-ghost-text: var(--accent-text);
    --value-ghost-disc: var(--accent-soft);

    /* ---- hint / status highlights ----
       The coach speaks in ONE colour. Placement, elimination and location used to
       be a green, a red and a purple ring, which made the board's palette argue
       with itself and read as three unrelated alarms. They are all the same claim
       -- "the coach is talking about this" -- so they share a hue and are told
       apart by device instead: location tints, a placement is ringed, and an
       elimination strikes the individual candidates it removes. */
    --hint-ink: #b45309;                           /* every hint ring, strike and mark */
    --hint-fill: #f8ddab;                          /* the cells a hint's pattern lives in */
    --hint-set: var(--hint-ink);
    --hint-elim: var(--hint-ink);
    /* The filled disc behind a candidate that *forms* the pattern, with the digit reversed out
       in --board-surface. Same ink as every other coach mark: the chip is told apart from the
       strike by being solid rather than by being another colour. */
    --hint-mark: var(--hint-ink);
    --hint-context-wash: #fdf0d8;                  /* flat wash: the house a hint acts on */
    /* Walkthrough answer mode. A pick is the player's own claim, not the coach's, so it is
       deliberately NOT the hint ink: it is the accent (v5.4, owner #5), an inset ring plus a
       corner badge with the tick reversed out. Aliases, so the dark accent follows by itself.
       --coach-ref-wash is the cool neutral grey that pointing at a named house/cage/cell in the
       walkthrough text lays on those cells (about 1.2:1 to the board, never amber or selection
       blue). All three are gated in tools/contrast-check.py. */
    --coach-pick: var(--accent);
    --coach-pick-text: var(--on-accent);
    --coach-ref-wash: #e6e9ee;                     /* 1.22:1 to the board */
    --conflict-ring: rgba(202, 27, 27, 0.95);
    --conflict-fill: #fdecec;
    --conflict-text: #b42318;                      /* 5.8:1 on --conflict-fill */
    /* Check's wrong cells (v5.4, owner #10): the danger tint with the digit or notes in the
       danger ink (5.6:1 light, 6.1:1 dark), plus a corner flag. A broken rule is a fill and red
       digits too, but never has the flag. Aliases of the chrome danger pair, so dark follows. */
    --check-fill: var(--danger-soft);
    --check-ink: var(--danger);

    /* ---- scratch colour washes (full-cell) ---- */
    --colour-1-wash: rgba(147, 51, 234, 0.04);
    --colour-2-wash: rgba(219, 39, 119, 0.04);
    --colour-3-wash: rgba(13, 148, 136, 0.04);

    /* ---- coach accents ---- */
    --coach-tech-bg: rgba(59, 162, 122, 0.16);
    --coach-tech-text: #12604a;
    --coach-confirm-text: #14532d;
    --coach-confirm-bg: rgba(34, 197, 94, 0.14);
    --coach-confirm-border: rgba(34, 197, 94, 0.4);
    --coach-check: #16a34a;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        /* ---- elevation ---- */
        --shadow-pop: 0 1px 2px rgba(0, 0, 0, .5), 0 16px 40px rgba(0, 0, 0, .55);
        --shadow-dock: 0 -4px 18px rgba(0, 0, 0, .5);

        /* ---- chrome colour ---- */
        --bg: #121315;
        --surface: #1b1d20;
        --surface-2: #25282c;
        --line: #2e3237;
        --line-strong: #7d848c;
        --btn-line: #464b52;
        --ink: #ece8e1;
        --ink-2: #bfb9af;
        --ink-3: #a29c92;
        --accent: #6cc0bd;
        --accent-hover: #86cfcc;
        --on-accent: #0b2524;
        --accent-text: #7fcfcb;
        --accent-soft: #1e3534;
        --danger: #f08a78;
        --danger-soft: #3a211d;
        --warn-bg: #33290f;
        --warn-line: #5e4b17;
        --warn-ink: #f1d99a;
        --scrim: rgba(0, 0, 0, .62);
        --focus: #6cc0bd;

        /* ==== board-side tokens: shipped values, except the v5.5 coach fill and wash ==== */

        /* ---- Builder cells ---- */
        --editor-cell-text: #e2e8f0;
        --editor-cage-text: #e2e8f0;
        --editor-frame: #020617;
        --editor-selection-ring: #86efac;
        --editor-selection-fill: #24413f;
        --editor-focus-ring: #e2e8f0;
        --editor-grid-focus: #60a5fa;
        --editor-pending-bg: #e2e8f0;
        --editor-cage-1: #33232b;
        --editor-cage-2: #1f2b3c;
        --editor-cage-3: #1e3028;
        --editor-cage-4: #342e20;
        --editor-cage-5: #2e253a;
        --editor-cage-6: #342435;
        --editor-cage-7: #1e3035;
        --editor-cage-8: #34291f;
        --editor-cage-9: #2b3122;

        /* ---- board cells ---- */
        --board-surface: #0b0d10;
        --grid-line: #3a3e44;
        --box-border: #b9b3a9;
        --cage-edge: #a29c92;
        --cell-text: #e8eaed;
        --cage-label-text: #ece8e1;
        --thumb-filled: #2a3533;

        /* ---- selection ---- */
        --selection-ring: #6cc0bd;
        --selection-fill: #223d3b;
        --selection-peer: #23262a;

        /* ---- value families ---- */
        --value-given: #e8eaed;
        --value-player: #ece8e1;
        --value-coach: #c4a6ff;
        --mark: #bfb9af;

        /* ---- hint / status highlights (rings brightened for visibility) ---- */
        --hint-ink: #fbbf24;
        --hint-fill: #4f3f10;                  /* v5.5: was #46340c (1.6:1 to the board), now 1.9:1; #534211 cost player digits their 4.5:1 */
        --hint-set: var(--hint-ink);
        --hint-elim: var(--hint-ink);
        --hint-mark: var(--hint-ink);
        --hint-context-wash: #302710;          /* v5.5: was #241b08, all but invisible */
        --coach-ref-wash: #22272e;          /* 1.30:1 to the board */
        --conflict-ring: rgba(252, 165, 165, 0.95);
        --conflict-fill: #2a1113;
        --conflict-text: #ff9d95;

        /* ---- scratch colour washes (reduced-opacity so light marks survive on top) ---- */
        --colour-1-wash: rgba(168, 85, 247, 0.04);
        --colour-2-wash: rgba(236, 72, 153, 0.04);
        --colour-3-wash: rgba(20, 184, 166, 0.04);

        /* ---- coach accents ---- */
        --coach-tech-bg: rgba(59, 162, 122, 0.24);
        --coach-tech-text: #6ee7b7;
        --coach-confirm-text: #86efac;
        --coach-confirm-bg: rgba(34, 197, 94, 0.16);
        --coach-confirm-border: rgba(34, 197, 94, 0.45);
        --coach-check: #4ade80;
    }
}

/* The same dark values, forced by data-theme="dark" on <html>: the player's Dark setting (ThemeService, and
   index.html's pre-paint script), or the components page's ?theme= preview for the capture. Keep this block identical
   to the media-query block above: tools/contrast-check.py fails when the two drift apart. */
:root[data-theme="dark"] {
    /* ---- elevation ---- */
    --shadow-pop: 0 1px 2px rgba(0, 0, 0, .5), 0 16px 40px rgba(0, 0, 0, .55);
    --shadow-dock: 0 -4px 18px rgba(0, 0, 0, .5);

    /* ---- chrome colour ---- */
    --bg: #121315;
    --surface: #1b1d20;
    --surface-2: #25282c;
    --line: #2e3237;
    --line-strong: #7d848c;
    --btn-line: #464b52;
    --ink: #ece8e1;
    --ink-2: #bfb9af;
    --ink-3: #a29c92;
    --accent: #6cc0bd;
    --accent-hover: #86cfcc;
    --on-accent: #0b2524;
    --accent-text: #7fcfcb;
    --accent-soft: #1e3534;
    --danger: #f08a78;
    --danger-soft: #3a211d;
    --warn-bg: #33290f;
    --warn-line: #5e4b17;
    --warn-ink: #f1d99a;
    --scrim: rgba(0, 0, 0, .62);
    --focus: #6cc0bd;

    /* ==== board-side tokens: shipped values, except the v5.5 coach fill and wash ==== */

    /* ---- Builder cells ---- */
    --editor-cell-text: #e2e8f0;
    --editor-cage-text: #e2e8f0;
    --editor-frame: #020617;
    --editor-selection-ring: #86efac;
    --editor-selection-fill: #24413f;
    --editor-focus-ring: #e2e8f0;
    --editor-grid-focus: #60a5fa;
    --editor-pending-bg: #e2e8f0;
    --editor-cage-1: #33232b;
    --editor-cage-2: #1f2b3c;
    --editor-cage-3: #1e3028;
    --editor-cage-4: #342e20;
    --editor-cage-5: #2e253a;
    --editor-cage-6: #342435;
    --editor-cage-7: #1e3035;
    --editor-cage-8: #34291f;
    --editor-cage-9: #2b3122;

    /* ---- board cells ---- */
    --board-surface: #0b0d10;
    --grid-line: #3a3e44;
    --box-border: #b9b3a9;
    --cage-edge: #a29c92;
    --cell-text: #e8eaed;
    --cage-label-text: #ece8e1;
    --thumb-filled: #2a3533;

    /* ---- selection ---- */
    --selection-ring: #6cc0bd;
    --selection-fill: #223d3b;
    --selection-peer: #23262a;

    /* ---- value families ---- */
    --value-given: #e8eaed;
    --value-player: #ece8e1;
    --value-coach: #c4a6ff;
    --mark: #bfb9af;

    /* ---- hint / status highlights (rings brightened for visibility) ---- */
    --hint-ink: #fbbf24;
    --hint-fill: #4f3f10;                  /* v5.5: was #46340c (1.6:1 to the board), now 1.9:1; #534211 cost player digits their 4.5:1 */
    --hint-set: var(--hint-ink);
    --hint-elim: var(--hint-ink);
    --hint-mark: var(--hint-ink);
    --hint-context-wash: #302710;          /* v5.5: was #241b08, all but invisible */
    --coach-ref-wash: #22272e;          /* 1.30:1 to the board */
    --conflict-ring: rgba(252, 165, 165, 0.95);
    --conflict-fill: #2a1113;
    --conflict-text: #ff9d95;

    /* ---- scratch colour washes (reduced-opacity so light marks survive on top) ---- */
    --colour-1-wash: rgba(168, 85, 247, 0.04);
    --colour-2-wash: rgba(236, 72, 153, 0.04);
    --colour-3-wash: rgba(20, 184, 166, 0.04);

    /* ---- coach accents ---- */
    --coach-tech-bg: rgba(59, 162, 122, 0.24);
    --coach-tech-text: #6ee7b7;
    --coach-confirm-text: #86efac;
    --coach-confirm-bg: rgba(34, 197, 94, 0.16);
    --coach-confirm-border: rgba(34, 197, 94, 0.45);
    --coach-check: #4ade80;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

@media (min-width: 700px) { :root { --gutter: 32px; } }
@media (min-width: 1050px) { :root { --gutter: 40px; } }

/* ============================================================================
   Base element rules
   ----------------------------------------------------------------------------
   Bootstrap is no longer loaded. The app used none of its components, only the
   element defaults of its "reboot" layer; these are the ones the pages relied on,
   restated so nothing shifts.
   ============================================================================ */
*, *::before, *::after { box-sizing: border-box; }

@media (prefers-reduced-motion: no-preference) {
    :root { scroll-behavior: smooth; }
}

/* The browse lists' entrance (EntranceStagger): Today's tiles, the archive day's rows and My puzzles' rows fade
   up as a page mounts, 70ms apart (--enter-d). With reduced motion, a fade only. Global, as three pages use it. */
@media (prefers-reduced-motion: no-preference) {
    .enter-up { animation: enter-up var(--dur-enter) var(--ease) backwards; animation-delay: var(--enter-d, 0ms); }
}
@media (prefers-reduced-motion: reduce) {
    .enter-up { animation: enter-fade 160ms linear backwards; }
}
@keyframes enter-up { from { opacity: 0; transform: translateY(10px); } }
@keyframes enter-fade { from { opacity: 0; } }

body {
    margin: 0;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4, h5, h6 { margin-top: 0; margin-bottom: 0.5rem; font-weight: 500; line-height: 1.2; }
h1 { font-size: calc(1.375rem + 1.5vw); }
h2 { font-size: calc(1.325rem + 0.9vw); }
h3 { font-size: calc(1.3rem + 0.6vw); }
h4 { font-size: calc(1.275rem + 0.3vw); }
@media (min-width: 1200px) {
    h1 { font-size: 2.5rem; }
    h2 { font-size: 2rem; }
    h3 { font-size: 1.75rem; }
    h4 { font-size: 1.5rem; }
}

p { margin-top: 0; margin-bottom: 1rem; }
ol, ul { padding-left: 2rem; margin-top: 0; margin-bottom: 1rem; }
ol ol, ol ul, ul ol, ul ul { margin-bottom: 0; }
b, strong { font-weight: bolder; }
small { font-size: 0.875em; }
a { text-decoration: underline; }

code, kbd, pre, samp {
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
    font-size: 1em;
}
code { font-size: 0.875em; word-wrap: break-word; }
kbd { padding: 0.2rem 0.4rem; font-size: 0.875em; border-radius: 0.2rem; }

img, svg { vertical-align: middle; }
label { display: inline-block; }

button { border-radius: 0; }
button:focus:not(:focus-visible) { outline: 0; }
button, input, optgroup, select, textarea { margin: 0; font-family: inherit; font-size: inherit; line-height: inherit; }
button, select { text-transform: none; }
[role="button"] { cursor: pointer; }
select { word-wrap: normal; }
button, [type="button"], [type="reset"], [type="submit"] { -webkit-appearance: button; }
button:not(:disabled), [type="button"]:not(:disabled), [type="reset"]:not(:disabled), [type="submit"]:not(:disabled) { cursor: pointer; }
textarea { resize: vertical; }
::-webkit-datetime-edit-fields-wrapper, ::-webkit-datetime-edit-text, ::-webkit-datetime-edit-minute,
::-webkit-datetime-edit-hour-field, ::-webkit-datetime-edit-day-field, ::-webkit-datetime-edit-month-field,
::-webkit-datetime-edit-year-field { padding: 0; }
::-webkit-inner-spin-button { height: auto; }

fieldset { min-width: 0; padding: 0; margin: 0; border: 0; }
legend { float: left; width: 100%; padding: 0; margin-bottom: 0.5rem; font-size: calc(1.275rem + 0.3vw); line-height: inherit; }
@media (min-width: 1200px) { legend { font-size: 1.5rem; } }
legend + * { clear: left; }

summary { display: list-item; cursor: pointer; }
[hidden] { display: none !important; }

/* The icon sprite in index.html holds <symbol>s only; it takes no space. */
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

html, body {
    font-family: var(--font-ui);
    background: var(--bg);
    color: var(--ink);
}

h1:focus {
    outline: none;
}

a {
    color: var(--accent-text);
}

#blazor-error-ui {
    background: var(--danger-soft);
    color: var(--ink);
    bottom: 0;
    box-shadow: var(--shadow-dock);
    box-sizing: border-box;
    display: none;
    font-family: var(--font-ui);
    font-size: var(--t-body);
    line-height: var(--lh-body);
    left: 0;
    padding: 12px 56px 12px 16px;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .reload {
        color: var(--accent-text);
        font-weight: 600;
        margin-left: 0.5rem;
    }

    #blazor-error-ui .dismiss {
        color: var(--ink);
        cursor: pointer;
        font-size: 1.25rem;
        line-height: 44px;
        min-width: 44px;
        position: absolute;
        right: 6px;
        text-align: center;
        text-decoration: none;
        top: 50%;
        transform: translateY(-50%);
    }

.blazor-error-boundary {
    background: var(--danger-soft);
    border: 1px solid var(--danger-line);
    border-radius: var(--r-md);
    color: var(--ink);
    padding: 16px;
}

    .blazor-error-boundary p {
        margin: 0 0 12px;
    }

/* ============================================================================
   Boot screen: Today's loading skeleton (index.html; design.md section 3.2,
   mockup home-loading.html). Static markup shown before the runtime starts. The
   bar, the page column and the tab bar repeat BrowseLayout's and the Ui
   components' measures exactly (BrowseLayout.razor.css, Wordmark, TopNav,
   TabBar), and the tiles GradeTile's skeleton, so the swap to the app moves
   nothing. Keep them in step. Still: no shimmer or pulse, so nothing to reduce.
   ============================================================================ */
.boot-screen {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--font-ui);
    color: var(--ink);
}

.boot-screen[data-boot="blank"] > * { display: none; }
.boot-screen[data-boot="browse"] .boot-page > * { display: none; }

.boot-wrap {
    width: 100%;
    max-width: calc(var(--content-max) + 2 * var(--gutter));
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.boot-appbar {
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
}

.boot-appbar-row {
    display: flex;
    align-items: center;
    gap: var(--s5);
    height: var(--appbar-h);
}

.boot-wordmark {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--ink);
    text-decoration: none;
}

.boot-logo { display: block; width: 237px; height: 32px; flex: none; }
/* Wordmark Responsive: the compact lockup at 340px and narrower, sliced from the full drawing. */
@media (max-width: 340px) { .boot-logo { width: 143px; } }

.boot-topnav { display: flex; gap: var(--s2); height: var(--appbar-h); }

.boot-topnav a {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 12px;
    border-bottom: 2px solid transparent;
    color: var(--ink-2);
    font: 500 var(--t-body)/var(--lh-body) var(--font-ui);
    text-decoration: none;
    white-space: nowrap;
}

.boot-topnav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

/* The bar's Settings button (BrowseLayout: an IconButton at the right end), drawn but not live. */
.boot-iconbtn { display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; margin-left: auto; color: var(--ink-2); }

.boot-main { flex: 1 0 auto; }
.boot-page { padding-top: var(--s7); padding-bottom: var(--s8); }

.boot-date {
    max-width: 640px;
    margin: 0;
    font: 500 var(--t-display)/var(--lh-display) var(--font-display);
    letter-spacing: -.01em;
}

.boot-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* One daily per date: one row as wide as the real single row (640px max), the height of the real GradeTile row (78px), at every width. */
.boot-tiles {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    max-width: 640px;
    gap: var(--s3);
    margin: var(--s6) 0 0;
    padding: 0;
    list-style: none;
}

.boot-tile {
    display: grid;
    grid-template-columns: 1fr 88px;
    align-items: center;
    gap: var(--s2) var(--s3);
    box-sizing: border-box;
    min-width: 0;
    height: 78px;
    padding: var(--s4);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface);
}

.boot-skel { display: block; height: 14px; border-radius: 6px; background: var(--surface-2); }
.boot-skel--title { width: 42%; height: 24px; }
.boot-skel--meta { width: 36%; }
.boot-skel--btn { grid-column: 2; grid-row: 1 / span 2; width: 100%; height: 44px; margin: 0; border-radius: var(--r-sm); }

.boot-tabbar { display: none; }

@media (max-width: 699px) {
    .boot-topnav { display: none; }
    .boot-page { padding-top: var(--s5); padding-bottom: var(--s7); }

    .boot-tiles { margin-top: var(--s5); }

    .boot-tabbar {
        position: sticky;
        bottom: 0;
        z-index: 20;
        display: flex;
        height: calc(var(--tabbar-h) + var(--safe-bottom));
        margin-top: auto;
        padding-bottom: var(--safe-bottom);
        border-top: 1px solid var(--line);
        background: var(--surface);
    }

    .boot-tabbar a {
        display: flex;
        flex: 1;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-width: 0;
        color: var(--ink-3);
        font: 500 var(--t-small)/var(--lh-small) var(--font-ui);
        text-decoration: none;
    }

    .boot-tabbar a[aria-current="page"] { color: var(--accent-text); }
}

.boot-icon {
    width: 24px;
    height: 24px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: middle;
}

.boot-tabbar a[aria-current="page"] .boot-icon { stroke-width: 2.1; }


code {
    color: var(--accent-text);
}

.json-input {
    width: 100%;
    min-height: 14rem;
    font-family: 'Fira Code', 'Consolas', 'Courier New', monospace;
    font-size: 0.9rem;
    border-radius: 6px;
    border: 1px solid var(--line-strong);
    padding: 0.75rem;
    background: var(--surface);
    color: var(--ink);
    margin-bottom: 0.6rem;
}

/* iOS Safari zooms the page into any focused field whose text is under 16px, and a
   pinch back out is needed every time. Touch devices get 16px in every text-entry
   control instead (the viewport stays zoomable: no maximum-scale). The :not() chain
   is also what lifts this above class and scoped-component rules such as .json-input. */
@media (pointer: coarse) {
    :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea) {
        font-size: 16px;
    }
}

.error-text {
    color: var(--danger);
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    background: var(--danger-soft);
    border: 1px solid var(--danger-line);
    margin: 0;
}

.tab-bar {
    display: flex;
    gap: 0.4rem;
    margin: 0.5rem 0 1.75rem;
    border-bottom: 1px solid var(--line);
}

.tab {
    appearance: none;
    border: none;
    background: none;
    padding: 0.75rem 1.4rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ink-3);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.tab:hover { color: var(--accent-text); }

.tab--active {
    color: var(--ink);
    border-bottom-color: var(--accent);
}

.builder-view {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.builder-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.builder-handoff-error { margin: 0; }

.section-heading {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.section-title {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 750;
    color: var(--ink);
}

.section-subtitle {
    margin: 0;
    font-size: 0.95rem;
    color: var(--ink-2);
}

.panel-card {
    padding: 1.1rem 1.2rem;
    border-radius: var(--r-md);
    border: 1px solid var(--line);
    background: var(--surface);
    box-sizing: border-box;
    width: 100%;
}

.panel-card--error {
    background: var(--danger-soft);
    border-color: var(--danger-line);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.85rem;
}

.panel-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--ink);
}

.panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.app-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.55rem 1.05rem;
    border-radius: var(--r-sm);
    border: 1px solid var(--btn-line);
    background: var(--surface);
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--dur-1) ease, box-shadow var(--dur-1) ease, background-color var(--dur-1) ease;
    color: var(--ink);
}

.app-button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-pop);
}

/* v5 has one filled button per group: --primary is it. --accent (the old green primary) is the
   secondary outline, so screens that paired the two no longer show two filled buttons side by side.
   Until the redesigned screens move to Components/Ui/Button. */
.app-button--primary {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--on-accent);
}

.app-button--primary:hover:not(:disabled) {
    border-color: var(--accent-hover);
    background: var(--accent-hover);
}

.app-button--accent {
    border-color: var(--btn-line);
    background: var(--surface);
    color: var(--ink);
}

.app-button--neutral {
    border-color: var(--line);
    background: var(--surface);
}

.app-button--ghost {
    border-color: transparent;
    background: transparent;
    color: var(--ink);
}

.app-button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    box-shadow: none;
}

.json-helper {
    margin: 0;
    font-size: 0.85rem;
    color: var(--ink-2);
}

@media (max-width: 500px) {
    .builder-view { gap: 0.75rem; }
    .builder-view .section-title { font-size: 1.25rem; }
    .builder-actions { gap: 0.5rem; align-items: stretch; }
    .builder-actions .app-button { flex: 1; min-height: 44px; padding: 0.5rem; }
    .builder-view .panel-header { flex-wrap: wrap; gap: 0.5rem; }
    .builder-view .json-card { padding: 0.75rem; }
}

.json-card summary { cursor: pointer; font-weight: 700; min-height: 44px; align-content: center; }
.json-card[open] .panel-header { margin-top: 0.5rem; }

/* ---------- journey pages (Today, Archive, My puzzles, Builder, Review) ----------
   Moved from Index.razor.css when Index was split into routed pages; the content is unchanged. Two
   rules there aimed at PuzzlePreview's root and never applied (scoped CSS does not reach a child
   component), so they are left out; the label and input rules keep to the pages' own fields, not the
   Builder's PuzzleEditor, as the scoped rules did. */
.journey-section { max-width: 1050px; margin: 0 auto; }
.journey-section > h1, .journey-section > h2 { font-size: clamp(1.7rem, 4vw, 2.6rem); margin: .4rem 0 1rem; }
.journey-actions { display: flex; flex-wrap: wrap; align-items: end; gap: .65rem; margin: .8rem 0; }
.journey-section label:not(.editor-root *) { display: grid; gap: .3rem; }
.journey-section input:not(.editor-root *) { min-height: 2.6rem; padding: .4rem .55rem; font: inherit; }
.journey-section .json-input { display: block; width: 100%; min-height: 8rem; margin: .5rem 0; }
@media (max-width: 560px) { .journey-actions .app-button { flex: 1 1 auto; } }
/* A review page's heading (Play.razor): visually hidden, as the play bar names the puzzle and SolvedReview shows it. */
.review-h { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
