/* ============================================================================
   Theming layer
   ----------------------------------------------------------------------------
   All colours that carry meaning flow through these semantic custom properties.
   :root holds the light values; the single @media (prefers-color-scheme: dark)
   block below redefines the same names for dark mode. Component stylesheets
   (app.css, PlayBoard.razor.css, MainLayout.razor.css) consume var(...) only —
   scoped razor.css inherits these custom properties from :root fine.

   Contrast (WCAG 2.1: text 4.5:1, non-text indicators 3:1)
   ----------------------------------------------------------------------------
   Cage fills are hsl(var(--cage-h), var(--cage-s), var(--cage-l)) with --cage-h on
   the golden-angle sequence, so every board foreground sits on a *family* of
   same-S/L backgrounds across all 360 hues. `python3 tools/contrast-check.py`
   recomputes the worst case over that family from these tokens -- re-run it after
   touching any colour below. Worst-case ratios, before this pass -> now:

     light (tint hsl(*, 62% -> 45%, 90% -> 91%))    dark (tint hsl(*, 24%, 26% -> 24%))
       --value-player    3.35 -> 5.52                 --value-player     3.15 -> 4.90
       --value-coach     4.99 -> 6.76                 --value-coach      2.94 -> 4.78
       --value-given    12.55 -> 13.43                --value-given      7.31 -> 8.06
       --mark           10.28 -> 11.01                --mark             5.40 -> 5.95
       --value-ghost-*   1.59 -> 4.57 (text)          --value-ghost-*    1.70 -> 4.59 (text)
       --hint-set        1.50 -> 3.29                 --hint-elim        2.48 -> 4.09
       --hint-elim       2.21 -> 4.37                 --conflict-ring    2.75 -> 4.37
       --check-ring      2.09 -> 3.54                 --selection-ring-soft 2.54 -> 3.74
       --selection-ring-soft 1.91 -> 3.15             --box-border       1.98 -> 3.40
       --box-border      2.40 -> 3.18                 (--hint-set/--check-ring/
       --conflict-ring   3.18 -> 3.37                  --selection-ring/--cage-edge
       --conflict-text   4.30 -> 4.99 (on its bg)      already cleared 3:1)

   The ghost digit is measured as text on its fill (4.5:1), not as an outline: the
   solid stroke plus the italic, not a faint fill, now carry "not yet penned".

   Known shortfall, deliberately out of scope here: the translucent washes layered over
   a tint (scratch colours, --match-strong, --hint-context-wash, --selection-fill) drag
   every foreground down, and two of them can land on one cell -- selecting a cell that
   holds a digit also value-matches it. Worst measured: light --value-player 3.42:1 and
   dark --value-player 2.73:1, both under --match-strong + --selection-fill.
   contrast-check.py prints these as ADVISORY rather than failing on them. Dark is the
   structural half of the problem: the washes are pale and additive, so they lift the
   background *towards* the light accents; clearing 4.5:1 there needs darkening washes
   (or near-white accents), not a token tweak. Tracked as open item-19 work.

   Deliberate literals (documented, theme-independent): the saturated scratch
   colour dots/swatches (#9333ea / #db2777 / #0d9488) read on both themes and
   stay identity-stable; the solved-banner celebration gradient; the Blazor
   template's form-validation red/green and error-boundary chrome. Those are the
   only hardcoded colours that survive the conversion.
   ============================================================================ */
:root {
    color-scheme: light dark;

    /* ---- surfaces ---- */
    --surface-page: #ffffff;
    --surface-sunken: #f7f7f7;
    --surface-card-top: #f9fbff;
    --surface-card-bottom: #eef1f7;
    --surface-inset: rgba(255, 255, 255, 0.7);   /* coach explanation/flag/step insets */
    --surface-struck: #f1f5f9;
    --board-frame: #0f172a;
    --board-frame-shadow: rgba(10, 15, 28, 0.45);

    /* ---- text ---- */
    --text-primary: #13263f;
    --text-heading: #101828;
    --text-secondary: #55657b;
    --text-muted: #64748b;
    --text-label: #33415a;
    --text-disabled: #9aa6b8;
    --text-on-accent: #ffffff;
    --code-text: #c02d76;

    /* ---- borders ---- */
    --border: #d0d7e2;
    --border-strong: #c3ccda;
    --border-input: #c7d0de;

    /* ---- accent / action ---- */
    --accent: #2d8cff;
    --accent-strong: #1d6fe0;
    --link: #0071c1;
    --shadow-btn: rgba(15, 23, 42, 0.14);
    --btn-bg-top: #ffffff;
    --btn-bg-bottom: #f4f6fb;
    --btn-text: #13263f;
    --btn-neutral-top: #fefefe;
    --btn-neutral-bottom: #f1f3f8;
    --btn-ghost-text: #1f2d3f;
    --btn-primary-top: #4da6ff;
    --btn-primary-bottom: #2d8cff;
    --btn-primary-border: #2d8cff;
    --btn-primary-shadow: rgba(45, 140, 255, 0.35);
    --btn-accent-top: #53d6a5;
    --btn-accent-bottom: #3ba27a;
    --btn-accent-border: #3ba27a;
    --btn-accent-text: #0b1c12;
    --btn-accent-shadow: rgba(59, 162, 122, 0.35);

    /* ---- chips / number-pad keys ---- */
    --chip-bg-top: #ffffff;
    --chip-bg-bottom: #eef2fb;
    --chip-text: #13263f;
    --chip-border: #c3ccda;

    /* ---- inputs ---- */
    --input-bg: #ffffff;

    /* ---- kbd ---- */
    --kbd-bg: #e2e8f0;
    --kbd-text: #1e293b;

    /* ---- focus / selection ---- */
    --focus-ring: #7cb0ff;
    --focus-ring-btn: #258cfb;
    --selection-ring: #1d6fe0;
    --selection-ring-soft: rgba(29, 111, 224, 0.9);
    --selection-fill: rgba(45, 140, 255, 0.18);

    /* ---- board cells ---- */
    --cage-s: 45%;                                /* cage-tint saturation (kept modest so saturated value/mark text clears 4.5:1 on a same-hue tint) */
    --cage-l: 91%;                                /* cage-tint lightness  */
    --cell-text: #0f172a;
    --cell-border: rgba(148, 163, 184, 0.25);
    --box-border: rgba(15, 23, 42, 0.5);          /* 0.4 read 2.43:1 on the palest tint; 0.5 -> 3.18:1 */
    --cage-edge: rgba(15, 23, 42, 0.82);
    --cage-label-bg: rgba(255, 255, 255, 0.9);
    --cage-label-text: #0f172a;
    --cage-label-shadow: rgba(15, 23, 42, 0.14);

    /* ---- value families ---- */
    --value-given: #0f172a;
    --value-player: #1256a0;
    --value-coach: #5b21b6;
    --mark: #1e293b;
    /* The ghost digit is text, so its fill carries the 4.5:1 duty: 0.45 alpha read
       2.00:1, 0.9 reads 4.57:1 -- still lighter than a penned player value (5.52:1),
       with the solid stroke and the italic doing the "not yet penned" signalling. */
    --value-ghost-fill: rgba(18, 86, 160, 0.9);
    --value-ghost-stroke: #1256a0;

    /* ---- hint / status highlights ---- */
    --hint-set: rgba(21, 128, 61, 0.9);
    --hint-set-glow: rgba(34, 197, 94, 0.35);
    --hint-elim: rgba(185, 28, 28, 0.9);
    --hint-focus: rgba(109, 40, 217, 0.95);
    --hint-context-wash: rgba(251, 191, 36, 0.16);
    --conflict-ring: rgba(202, 27, 27, 0.95);     /* red-600 @0.9 was 2.92:1 on its own cell's --conflict-bg-bottom */
    --conflict-bg-top: #ffd9dc;
    --conflict-bg-bottom: #ffc2c8;
    --conflict-text: #a51b14;                     /* #b3261e was 4.30:1 on --conflict-bg-bottom */
    --check-ring: rgba(180, 83, 9, 0.95);
    --check-glow: rgba(217, 119, 6, 0.3);
    --match-strong: rgba(45, 140, 255, 0.26);
    --match-faint: rgba(45, 140, 255, 0.11);

    /* ---- scratch colour trio (full-cell washes; the corner dots stay literal) ---- */
    --colour-1-wash: rgba(147, 51, 234, 0.20);
    --colour-2-wash: rgba(219, 39, 119, 0.18);
    --colour-3-wash: rgba(13, 148, 136, 0.20);

    /* ---- feedback / semantic surfaces ---- */
    --success-text: #14532d;
    --success-bg: rgba(34, 197, 94, 0.12);
    --success-border: rgba(34, 197, 94, 0.35);
    --warn-text: #92400e;
    --warn-bg: rgba(217, 119, 6, 0.12);
    --warn-border: rgba(217, 119, 6, 0.4);
    /* #d92d20 on --error-bg measured 4.24:1 — under the 4.5:1 bar everywhere error text is shown.
       #b42318 on the same background is 5.77:1. */
    --error-text: #b42318;
    --error-bg: #feeceb;
    --error-border: #f3c5c0;
    --error-detail-text: #7a2820;
    --danger-text: #9f1239;
    --danger-bg: #fee2e2;
    --danger-bg-top: #fef2f2;
    --danger-bg-bottom: #fde0e0;
    --strike: #dc2626;

    /* ---- 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;
    --inset-border: rgba(15, 23, 42, 0.08);

    /* ---- selection-sum readout ---- */
    --sum-bg-top: #eef5ff;
    --sum-bg-bottom: #e3edff;
    --sum-border: #c7dbfb;
    --sum-text: #2a3f5f;
    --sum-value: #14417a;
    --sum-detail: #4b6485;

    /* ---- status badge (layout) ---- */
    --badge-success-text: #0b5d1e;
    --badge-success-bg: #dff6e3;
    --badge-success-border: #bfe9c7;
    --badge-warn-text: #7a3c00;
    --badge-warn-bg: #fff3e0;
    --badge-warn-border: #ffd7a8;

    /* ---- loading spinner ---- */
    --loading-track: #e0e0e0;
    --loading-fill: #1b6ec2;
}

@media (prefers-color-scheme: dark) {
    :root {
        /* ---- surfaces ---- */
        --surface-page: #020617;
        --surface-sunken: #0b1220;
        --surface-card-top: #111a2e;
        --surface-card-bottom: #0c1322;
        --surface-inset: rgba(148, 163, 184, 0.08);
        --surface-struck: #141d31;
        --board-frame: #0f172a;
        --board-frame-shadow: rgba(0, 0, 0, 0.55);

        /* ---- text ---- */
        --text-primary: #e2e8f0;
        --text-heading: #f1f5f9;
        --text-secondary: #94a3b8;
        --text-muted: #8595a8;
        --text-label: #b4c0d3;
        --text-disabled: #64748b;
        --code-text: #f0a3c8;

        /* ---- borders ---- */
        --border: #24314a;
        --border-strong: #33415a;
        --border-input: #33415a;

        /* ---- accent / action ---- */
        --link: #60a5fa;
        --shadow-btn: rgba(0, 0, 0, 0.5);
        --btn-bg-top: #1c2740;
        --btn-bg-bottom: #141d31;
        --btn-text: #e2e8f0;
        --btn-neutral-top: #1c2740;
        --btn-neutral-bottom: #141d31;
        --btn-ghost-text: #cbd5e1;

        /* ---- chips / number-pad keys ---- */
        --chip-bg-top: #1c2740;
        --chip-bg-bottom: #141d31;
        --chip-text: #e2e8f0;
        --chip-border: #33415a;

        /* ---- inputs ---- */
        --input-bg: #0d1526;

        /* ---- kbd ---- */
        --kbd-bg: #334155;
        --kbd-text: #e2e8f0;

        /* ---- focus / selection ---- */
        --focus-ring: #93c5fd;
        --selection-ring: #60a5fa;
        --selection-ring-soft: rgba(147, 197, 253, 0.8);  /* blue-400 @0.8 was 2.54:1; blue-300 -> 3.74:1 */
        --selection-fill: rgba(96, 165, 250, 0.22);

        /* ---- board cells ---- */
        --cage-s: 24%;
        --cage-l: 24%;                            /* 26% left blue/violet values at ~3:1; 24% + the lightened ramp below clears 4.5:1 */
        --cell-text: #e2e8f0;
        --cell-border: rgba(148, 163, 184, 0.16);
        --box-border: rgba(226, 232, 240, 0.55);   /* slate-200 @0.55 -> 3.40:1; slate-300 @0.35 was 1.98:1 */
        --cage-edge: rgba(203, 213, 225, 0.6);
        --cage-label-bg: rgba(2, 6, 23, 0.82);
        --cage-label-text: #e2e8f0;
        --cage-label-shadow: rgba(148, 163, 184, 0.25);

        /* ---- value families ---- */
        --value-given: #f1f5f9;
        --value-player: #93c5fd;                  /* blue-400 was 3.15:1 on the palest tint; blue-300 -> 4.90:1 */
        --value-coach: #c4b5fd;                   /* violet-400 was 2.94:1; violet-300 -> 4.78:1 */
        --mark: #cbd5e1;
        --value-ghost-fill: rgba(147, 197, 253, 0.95);
        --value-ghost-stroke: #93c5fd;

        /* ---- hint / status highlights (rings brightened for visibility) ---- */
        --hint-set: rgba(74, 222, 128, 0.9);
        --hint-set-glow: rgba(74, 222, 128, 0.4);
        --hint-elim: rgba(252, 165, 165, 0.9);     /* red-400 @0.85 was 2.48:1; red-300 @0.9 -> 4.09:1 */
        --hint-focus: rgba(196, 181, 253, 0.95);
        --hint-context-wash: rgba(251, 191, 36, 0.12);
        --conflict-ring: rgba(252, 165, 165, 0.95);/* matched to --hint-elim's red-300; red-400 sat at 2.75:1 */
        --conflict-bg-top: #4a1418;
        --conflict-bg-bottom: #3a0f13;
        --conflict-text: #fca5a5;
        --check-ring: rgba(245, 158, 11, 0.95);
        --check-glow: rgba(245, 158, 11, 0.35);
        --match-strong: rgba(96, 165, 250, 0.3);
        --match-faint: rgba(96, 165, 250, 0.14);

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

        /* ---- feedback / semantic surfaces ---- */
        --success-text: #86efac;
        --success-bg: rgba(34, 197, 94, 0.16);
        --success-border: rgba(34, 197, 94, 0.4);
        --warn-text: #fbbf24;
        --warn-bg: rgba(217, 119, 6, 0.18);
        --warn-border: rgba(217, 119, 6, 0.45);
        --error-text: #fca5a5;
        --error-bg: #3a1416;
        --error-border: #5c2327;
        --error-detail-text: #fca5a5;
        --danger-text: #fda4af;
        --danger-bg: #3a1416;
        --danger-bg-top: #3a1416;
        --danger-bg-bottom: #2c0f12;
        --strike: #f87171;

        /* ---- 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;
        --inset-border: rgba(148, 163, 184, 0.16);

        /* ---- selection-sum readout ---- */
        --sum-bg-top: #10203a;
        --sum-bg-bottom: #0c1a30;
        --sum-border: #24405f;
        --sum-text: #b4c0d3;
        --sum-value: #7cb0ff;
        --sum-detail: #8ea3c0;

        /* ---- status badge (layout) ---- */
        --badge-success-text: #86efac;
        --badge-success-bg: rgba(34, 197, 94, 0.16);
        --badge-success-border: rgba(34, 197, 94, 0.4);
        --badge-warn-text: #fbbf24;
        --badge-warn-bg: rgba(217, 119, 6, 0.18);
        --badge-warn-border: rgba(217, 119, 6, 0.45);

        /* ---- loading spinner ---- */
        --loading-track: #1e293b;
        --loading-fill: #3b82f6;
    }
}

html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: var(--surface-page);
    color: var(--text-primary);
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: var(--link);
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

.container {
    max-width: 78rem;
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
}

.container > header {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1.8rem;
}

.container > header h1 {
    margin: 0;
    font-size: 2.35rem;
    font-weight: 800;
    color: var(--text-heading);
    letter-spacing: -0.01em;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

    .loading-progress circle {
        fill: none;
        stroke: var(--loading-track);
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: var(--loading-fill);
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

code {
    color: var(--code-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(--border-input);
    padding: 0.75rem;
    background: var(--input-bg);
    color: var(--text-primary);
    margin-bottom: 0.6rem;
}

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

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

.tab {
    appearance: none;
    border: none;
    background: none;
    padding: 0.75rem 1.4rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-muted);
    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-strong); }

.tab--active {
    color: var(--text-primary);
    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(--text-primary);
}

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

.panel-card {
    padding: 1.1rem 1.2rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, var(--surface-card-top) 0%, var(--surface-card-bottom) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 14px 26px rgba(15, 23, 42, 0.12);
    box-sizing: border-box;
    width: 100%;
}

.panel-card--error {
    background: var(--error-bg);
    border-color: var(--error-border);
    box-shadow: none;
}

.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(--text-primary);
}

.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: 8px;
    border: 1px solid var(--border-strong);
    background: linear-gradient(180deg, var(--btn-bg-top) 0%, var(--btn-bg-bottom) 100%);
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
    color: var(--btn-text);
}

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

.app-button--primary {
    border-color: var(--btn-primary-border);
    background: linear-gradient(180deg, var(--btn-primary-top) 0%, var(--btn-primary-bottom) 100%);
    color: #fff;
    box-shadow: 0 10px 22px var(--btn-primary-shadow);
}

.app-button--accent {
    border-color: var(--btn-accent-border);
    background: linear-gradient(180deg, var(--btn-accent-top) 0%, var(--btn-accent-bottom) 100%);
    color: var(--btn-accent-text);
    box-shadow: 0 10px 22px var(--btn-accent-shadow);
}

.app-button--neutral {
    border-color: var(--border);
    background: linear-gradient(180deg, var(--btn-neutral-top) 0%, var(--btn-neutral-bottom) 100%);
}

.app-button--ghost {
    border-color: transparent;
    background: linear-gradient(180deg, var(--btn-bg-top) 0%, var(--btn-bg-bottom) 100%);
    color: var(--btn-ghost-text);
}

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

.generate-view { display: flex; flex-direction: column; gap: 1.25rem; }
.generate-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.generate-stats { display: flex; gap: .7rem 1rem; flex-wrap: wrap; color: #40516a; font-size: .9rem; }
.generate-budget { display: inline-flex; gap: .4rem; align-items: center; color: #40516a; font-size: .9rem; }
.generate-budget select { border: 1px solid #c3ccda; border-radius: 6px; background: #fff; padding: .4rem; color: #13263f; }
.generate-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(18rem, 1fr); gap: 1.25rem; align-items: start; }
.generate-table-wrap { overflow: auto; max-height: 33rem; }
.generate-table { border-collapse: collapse; width: 100%; font-size: .8rem; }
.generate-table th, .generate-table td { text-align: left; padding: .55rem; border-bottom: 1px solid #dce3ee; white-space: nowrap; }
.generate-table tbody tr { cursor: pointer; }
.generate-table tbody tr:hover, .generate-table tbody tr.selected { background: #e8f3ff; }
.generate-table tbody tr.generate-table__running { background: #fff7df; color: #735313; font-style: italic; cursor: progress; }
.lab-grid { display: grid; grid-template-columns: repeat(9, 1fr); width: min(100%, 18rem); aspect-ratio: 1; border: 2px solid #263850; margin-bottom: 1rem; }
.lab-cell { border: 1px solid #b8c4d5; padding: .1rem; font-size: .65rem; color: #235a91; }
.generate-evidence { display: grid; grid-template-columns: max-content 1fr; gap: .45rem .8rem; font-size: .88rem; margin: 0; }
.generate-evidence dt { font-weight: 700; color: #334155; }.generate-evidence dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 900px) { .generate-layout { grid-template-columns: 1fr; } }

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