/* ═══════════════════════════════════════════════════════════════════════════
   Fuji dashboard — Center Stage design system.

   The facelift (docs/dashboard-ui-scope.md). Everything is scoped under
   `.stage`, which base.html now sets by default, so this file styles every page.

   It is also the ONLY owner of chrome colour. base.html's inline <style> keeps
   structure — layout, spacing, sizing, and the resets a <button> needs — and no
   longer carries colour, so a theme is a change here and nowhere else.

   Three structural rules, each one taking something that used to be decoration
   and giving it a job:

     1. LIGHT IS HIERARCHY.  One lit zone per screen (.lit). Everything else
        sits in the wings at lower contrast. Replaces "every card looks the
        same, so nothing leads".
     2. FOOTLIGHTS MEAN LIVE.  The warm amber strip is state, not trim. It
        marks live / open / waiting-on-someone (.live) and nothing else.
     3. TWO HOUSES, TWO GELS.  Staff get the green spot; members get magenta.
        The member pages that exist (the vote run in rounds) wear it through
        .house-member; staff screens never do.

   Colours resolve through custom properties so the light theme is a
   re-declaration rather than a rewrite.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Faces. Three, each with one job. Self-hosted: no Google Fonts round-trip,
      and nothing breaks when fonts.googleapis.com is unreachable. Declarations
      are global because an unused @font-face downloads nothing. ── */
@font-face {
    font-family: 'Archivo';
    src: url('/static/fonts/archivo-var-400_700.woff2') format('woff2-variations');
    font-weight: 400 700;
    font-stretch: 62% 125%;
    font-display: swap;
}

@font-face {
    font-family: 'Public Sans';
    src: url('/static/fonts/publicsans-var-400_700.woff2') format('woff2-variations');
    font-weight: 400 700;
    font-display: swap;
}

@font-face {
    font-family: 'IBM Plex Mono';
    src: url('/static/fonts/plexmono-400.woff2') format('woff2');
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: 'IBM Plex Mono';
    src: url('/static/fonts/plexmono-500.woff2') format('woff2');
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: 'IBM Plex Mono';
    src: url('/static/fonts/plexmono-600.woff2') format('woff2');
    font-weight: 600;
    font-display: swap;
}

/* ══ Tokens ══════════════════════════════════════════════════════════════ */
.stage {
    /* Neutrals: Fuji's original blue-slate ramp, kept on Rae's call (2026-08-06
       — she liked the layout and wanted the old colours back). The warm
       near-black this briefly used is gone.

       Everything else about the direction is unaffected, which is the point of
       putting colour behind tokens in the first place: this was a swap of six
       values, not a redesign. The flat page stays (no gel gradients), and so do
       all three structural rules. */
    --ground: #111318;
    /* page */
    --ground-2: #0D0F15;
    /* sidebar: a step DOWN, so the wings sit under the stage */
    --surface: #1C1E24;
    /* panels */
    --surface-2: #22242C;
    /* raised inside a panel: table heads */
    --line: #2A2C34;
    --line-soft: #23252B;

    /* Contrast is measured, not eyeballed. Against the sidebar (--ground-2) and
       the panels (--surface): ink 14.5/12.6, ink-2 9.8/8.5, ink-3 7.6/6.6,
       ink-4 4.6/4.0. An earlier ramp shipped ink-3 at 4.4 on a panel — under the
       4.5 AA floor for normal text — and ink-4 at 2.4, which is what made the
       sidebar read as unlit rather than as quiet (Ash caught it). Anything
       carrying words needs ink-3 or better; ink-4 is for decoration,
       placeholders and rules.

       --ink-3 is Tailwind's gray-400 exactly, and that is deliberate: it is the
       single most-used colour in the templates (485 uses), so converting those
       utilities to tokens is a rename rather than a judgement call. */
    --ink: #E0E0E0;
    --ink-2: #B4BAC4;
    --ink-3: #9CA3AF;
    --ink-4: #757C89;

    /* Accents, one job each. */
    --spot: #33B839;
    /* light: focus, active nav, the one primary action */
    --spot-ink: #5FD465;
    /* the same green as TEXT — headings and figures. Fuji's build has always
       written those in green (`text-green-300`, 327 uses) and Rae asked for it
       back on 2026-08-06. Kept as its own token because --spot is too dark to
       read at body weight: 8.8:1 on a panel against 6.4. */
    --spot-soft: rgba(51, 184, 57, .13);
    --spot-line: rgba(51, 184, 57, .34);
    --foot: #D8A93F;
    /* live / open / waiting on someone. Never decoration. */
    --foot-soft: rgba(216, 169, 63, .13);
    --foot-line: rgba(216, 169, 63, .32);
    --gel: #C558B0;
    /* the member + public house. Absent from staff screens. */

    /* Semantic, deliberately separate from the accents so a red never has to
       compete with the accent for meaning. */
    --danger: #E5544B;
    --danger-soft: rgba(229, 84, 75, .13);
    --danger-line: rgba(229, 84, 75, .32);
    --caution: #E0A33C;
    --caution-soft: rgba(224, 163, 60, .13);
    --info: #6FA8DC;
    --info-soft: rgba(111, 168, 220, .13);

    --font-display: 'Archivo', 'Arial Narrow', system-ui, sans-serif;
    --font-text: 'Public Sans', system-ui, -apple-system, sans-serif;
    --font-num: 'IBM Plex Mono', ui-monospace, SFMono-Regular, monospace;

    /* Derived surfaces and states. These used to be literals scattered through
       the file; two of them (the mobile bar and the pinned-column hover) were
       still carrying warm near-black values from before Rae's revert, so they
       were quietly a shade off. */
    --hover-faint: rgba(255, 255, 255, .022);
    --hover: rgba(255, 255, 255, .04);
    --hover-2: rgba(255, 255, 255, .06);
    --bar: rgba(13, 15, 21, .97);
    --surface-hover: #21232A;
    --lit-wash: rgba(51, 184, 57, .085);
    --foot-glow: rgba(216, 169, 63, .22);
    --info-line: rgba(111, 168, 220, .3);
    --spot-hi: #45CB4B;
    --spot-badge: #6FD173;
    --btn-ink: #08210A;
    --danger-ink: #F0857D;
    --danger-hi: #F5A29B;

    --r-sm: 6px;
    --r: 10px;
    --r-lg: 14px;

    /* Spacing scale. Cards used p-4, p-5 and p-6 interchangeably and section gaps
       varied the same way; new page pieces take a step from here instead, so two
       pages built a month apart still sit on the same rhythm. */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 24px;
    --sp-6: 32px;

    /* Type scale, matching the sizes the stage already renders (the h1 has been
       1.85rem since phase 1) so adopting it changes nothing on screen. */
    --fs-xs: .75rem;
    --fs-sm: .875rem;
    --fs-base: 1rem;
    --fs-lg: 1.125rem;
    --fs-xl: 1.4rem;
    --fs-2xl: 1.85rem;
}

/* ══ Light ═══════════════════════════════════════════════════════════════
   The whole theme: one block of values, no template touched, because every
   colour on every page already resolves through these.

   Close to a REVERSAL of the ramp, which works precisely because the app is
   dark-first — the same shade serves a dark background and light text, so
   inverting flips both at once. Panels become the lightest surface and the page
   steps down, so the lit zone still lifts; the sidebar steps down again, which
   is what keeps it reading as the wings.

   Contrast is measured against the SIDEBAR, not the panel. In dark the sidebar
   is the darkest surface and text there has the most headroom; inverted it is
   the greyest and has the least, so setting the muted greys on white passes and
   then fails in the one place it matters. Against panel/page/sidebar:
   ink 18.1/16.3/15.0, ink-2 10.5/9.4/8.7, ink-3 7.7/6.9/6.4, ink-4 5.2/4.6/4.3,
   spot 5.8/5.2/4.8, spot-ink 6.7/6.0/5.5, foot 5.9/5.3/4.9. White on --spot is
   5.8, so the one primary button holds.

   Gold has to darken to stay readable on white, so the footlight reads as ochre
   rather than as a glow. The meaning survives; the material changes. */
:root[data-theme="light"] .stage {
    --ground: #F1F3F6;
    --ground-2: #E7EAEF;
    --surface: #FFFFFF;
    --surface-2: #F5F7F9;
    --line: #D5D9E0;
    --line-soft: #E5E8EE;

    --ink: #14161C;
    --ink-2: #39404B;
    --ink-3: #4C5460;
    --ink-4: #666E7A;

    --spot: #17761F;
    --spot-ink: #146B1C;
    --spot-soft: rgba(23, 118, 31, .09);
    --spot-line: rgba(23, 118, 31, .28);
    --foot: #8A5A00;
    --foot-soft: rgba(138, 90, 0, .09);
    --foot-line: rgba(138, 90, 0, .28);
    --gel: #A0348A;

    --danger: #B3261E;
    --danger-soft: rgba(179, 38, 30, .09);
    --danger-line: rgba(179, 38, 30, .28);
    --caution: #8A5A00;
    --caution-soft: rgba(138, 90, 0, .09);
    --info: #1B5FA8;
    --info-soft: rgba(27, 95, 168, .09);

    --hover-faint: rgba(0, 0, 0, .022);
    --hover: rgba(0, 0, 0, .045);
    --hover-2: rgba(0, 0, 0, .065);
    --bar: rgba(255, 255, 255, .97);
    --surface-hover: #F2F4F7;
    --lit-wash: rgba(23, 118, 31, .055);
    --foot-glow: rgba(138, 90, 0, .20);
    --info-line: rgba(27, 95, 168, .3);
    --spot-hi: #125E18;
    --spot-badge: #17761F;
    --btn-ink: #FFFFFF;
    --danger-ink: #B3261E;
    --danger-hi: #8E1D17;
}

/* The starfield is a dark-room device. On a light page it would be grit on
   paper, so it goes — the script checks this and skips drawing entirely. */
:root[data-theme="light"] body.stage #stage-canvas {
    display: none;
}

/* ══ Shell ═══════════════════════════════════════════════════════════════ */
/* Flat ground. The four fixed radial gradients go: they sat behind everything
   equally, so they read as wash rather than as an idea.

   The starfield stays, quieter (see base.html). It survives where the gradients
   did not because it is not a wash: the panels are opaque, so it only ever
   shows in the gutters around the content. That makes it the dark auditorium
   around the lit stage rather than a layer over it. It is also already off for
   reduced-motion and under 768px. */
body.stage {
    background-color: var(--ground);
    background-image: none;
    color: var(--ink);
    font-family: var(--font-text);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

/* Behind the content plane, not over it. The canvas is `z-index: 0` and
   positioned, so by the painting rules it lands ABOVE every static element —
   which is why the old build had to give `.card` its own stacking context, and
   why the first attempt here scattered stars across the mod-action feed. A
   negative index puts it under static content while still painting above the
   body background propagated to the viewport, so it shows only where nothing
   is drawn: the gutters. */
body.stage #stage-canvas {
    z-index: -1;
}

.stage ::selection {
    background: var(--spot-soft);
    color: var(--ink);
}

.stage ::-webkit-scrollbar-track {
    background: var(--ground);
}

.stage ::-webkit-scrollbar-thumb {
    background: var(--line);
}

.stage :focus-visible {
    outline: 2px solid var(--spot);
    outline-offset: 2px;
    border-radius: 3px;
}

/* Icons. One sizing rule for the whole sprite. */
.stage .ico {
    width: 1.05em;
    height: 1.05em;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: -0.16em;
}

.stage .ico-lg {
    width: 1.35em;
    height: 1.35em;
}

/* The emoji that these icons replace stay in the markup so every page that has
   not been converted yet is untouched. On a stage page they are swapped out. */
.stage .nav-emoji {
    display: none;
}

.nav-svg {
    display: none;
}

.stage .nav-svg {
    display: inline-block;
}

/* ── Top nav ── */
.stage .topnav {
    background: var(--ground);
    border-bottom: 1px solid var(--line);
    box-shadow: none;
    padding: 0 20px;
    height: 52px;
}

.stage .topnav-logo {
    font-family: var(--font-display);
    font-stretch: 80%;
    font-weight: 700;
    font-size: 1.02rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ink);
    text-shadow: none;
    gap: 9px;
}

.stage .topnav-logo .ico {
    color: var(--foot);
    width: 1.5em;
    height: 1.5em;
}

.stage .topnav-right {
    gap: 14px;
    color: var(--ink-3);
    font-size: .82rem;
}

.stage .topnav-right a,
.stage .topnav-right .logout {
    color: var(--ink-3);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    /* The logout control is a <button> carrying an inline style, so it takes the
       UA font off-stage. Set here rather than in the markup, so a page that has
       not been converted keeps exactly the button it had. */
    font-family: var(--font-text);
}

.stage .topnav-right a:hover {
    color: var(--ink);
}

.stage .topnav-right .logout:hover {
    color: var(--danger);
}

.stage .theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: none;
    color: var(--ink-3);
    cursor: pointer;
}

.stage .theme-toggle:hover {
    color: var(--ink);
    background: var(--hover);
}

.stage .theme-toggle .t-moon {
    display: none;
}

:root[data-theme="light"] .stage .theme-toggle .t-sun {
    display: none;
}

:root[data-theme="light"] .stage .theme-toggle .t-moon {
    display: inline-block;
}

.stage .hamburger span {
    background: var(--ink-3);
}

.stage .hamburger:hover span {
    background: var(--ink);
}

/* ── Sidebar. The wings: low contrast, so the stage reads as the lit thing. ── */
.stage .sidebar {
    width: 214px;
    background: var(--ground-2);
    border-right: 1px solid var(--line-soft);
    padding: 14px 0 0;
}

.stage .sidebar::after {
    background: linear-gradient(transparent, var(--ground-2));
}

.stage .sidebar-logo {
    padding: 0 16px 14px;
    border-bottom: 1px solid var(--line-soft);
}

.stage .sidebar-logo h2 {
    font-family: var(--font-display);
    font-stretch: 80%;
    font-weight: 700;
    font-size: .95rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ink-2);
    text-shadow: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stage .sidebar-logo h2 .ico {
    color: var(--foot);
}

.stage .sidebar-logo p {
    color: var(--ink-3);
    font-size: .72rem;
    margin-top: 2px;
}

.stage .nav-search input {
    background: var(--ground);
    border: 1px solid var(--line);
    color: var(--ink);
    border-radius: var(--r-sm);
    padding-left: 30px;
    font-family: var(--font-text);
}

.stage .nav-search input:focus {
    border-color: var(--spot);
    box-shadow: 0 0 0 2px var(--spot-soft);
}

.stage .nav-search-ico {
    color: var(--ink-3);
    display: flex;
}

.stage .nav-section {
    font-family: var(--font-display);
    font-stretch: 82%;
    font-weight: 600;
    color: var(--ink-3);
    font-size: .68rem;
    letter-spacing: .15em;
    padding: 12px 16px 5px;
}

.stage .nav-section::after {
    background: linear-gradient(to right, var(--line), transparent);
}

.stage .nav-section:hover {
    color: var(--ink-2);
}

/* No halo. The active page is lit from the left instead: a spot rail. */
.stage .sidebar a {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0 8px;
    padding: 6px 10px;
    border-radius: var(--r-sm);
    color: var(--ink-2);
    font-size: .845rem;
    font-weight: 400;
    letter-spacing: .002em;
}

.stage .sidebar a .ico {
    color: var(--ink-3);
    transition: color .15s;
}

.stage .sidebar a::before {
    display: none;
}

.stage .sidebar a:hover {
    background: var(--hover);
    color: var(--ink);
}

.stage .sidebar a:hover .ico {
    color: var(--ink-2);
}

.stage .sidebar a.active {
    background: var(--spot-soft);
    color: var(--ink);
    font-weight: 500;
    box-shadow: inset 2px 0 0 var(--spot);
}

.stage .sidebar a.active .ico {
    color: var(--spot);
}

.stage .sidebar a.active::before {
    display: none;
}

/* ── Main ── */
.stage .main {
    background: transparent;
    padding: 26px 30px 40px;
}

.stage .main h1 {
    font-family: var(--font-display);
    font-stretch: 82%;
    font-weight: 700;
    font-size: 1.85rem;
    line-height: 1.1;
    letter-spacing: .004em;
    color: var(--spot-ink);
    border-left: none;
    padding-left: 0;
    display: flex;
    align-items: center;
    gap: 11px;
}

.stage .main h1 .ico {
    color: var(--spot);
}

.stage .main h2,
.stage .main h3 {
    font-family: var(--font-display);
    font-stretch: 84%;
    font-weight: 600;
    color: var(--spot-ink);
}

.stage .main table tbody tr:hover {
    background: transparent;
}

.stage .page-sub {
    color: var(--ink-3);
    font-family: var(--font-text);
    font-size: .875rem;
    margin: 6px 0 0;
    max-width: 62ch;
}

/* ── Page pieces (`templates/_ui.html`) ──
   The markup for these lives in one macro file, so this is the one place each is
   styled. Header and banners are the "race card" set approved on 2026-10-23. */

/* The race-card header: group label, a lit icon tile, title, and a ruled line
   that closes the header off from the content. The tile is the header's one green
   spot (light is hierarchy: green is used once per zone). */
.stage .page-head {
    margin-bottom: var(--sp-5);
    padding-bottom: var(--sp-4);
    border-bottom: 1px solid var(--line);
}

.stage .page-head-tabbed {
    padding-bottom: 0;
}

.stage .page-eyebrow {
    margin: 0 0 var(--sp-2);
    font-family: var(--font-display);
    font-stretch: 84%;
    font-size: var(--fs-xs);
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.stage .page-head-row {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-4);
    flex-wrap: wrap;
}

.stage .page-tile {
    flex: none;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: var(--r);
    background: var(--spot-soft);
    border: 1px solid var(--spot-line);
    color: var(--spot-ink);
}

.stage .page-tile .ico {
    width: 24px;
    height: 24px;
}

.stage .page-head-text {
    flex: 1 1 320px;
    min-width: 0;
}

.stage .page-title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px var(--sp-3);
}

.stage .page-head .page-sub {
    margin-top: var(--sp-1);
}

.stage .page-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
    margin-left: auto;
}

/* "Waiting on someone". Amber already means that everywhere in Fuji, so this
   spends no new colour; the macro is only ever given it when something waits. */
.stage .page-live {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--foot-line);
    background: var(--foot-soft);
    color: var(--foot);
    font-family: var(--font-display);
    font-stretch: 88%;
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: .04em;
}

.stage .page-live .ico {
    width: 13px;
    height: 13px;
}

/* Hub tabs sit ON the header's bottom rule, so the views read as one page. They
   scroll sideways inside their own strip on a phone rather than widening it. */
.stage .page-tabs {
    display: flex;
    gap: var(--sp-5);
    margin-top: var(--sp-4);
    overflow-x: auto;
    scrollbar-width: none;
}

.stage .page-tabs a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 0 var(--sp-3);
    margin-bottom: -1px;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    font-family: var(--font-display);
    font-stretch: 88%;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--ink-3);
    text-decoration: none;
}

.stage .page-tabs a:hover {
    color: var(--ink);
}

.stage .page-tabs a.on {
    color: var(--spot-ink);
    border-bottom-color: var(--spot);
}

.stage .page-tabs .n {
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--ink-3);
    font-family: var(--font-num);
    font-size: .7rem;
}

.stage .page-tabs a.on .n {
    background: var(--spot-soft);
    color: var(--spot-ink);
}

/* The hub tab strip on its own, for a bespoke page that keeps its own header. Same
   tabs, same bottom rule, so it reads as the same thing the race-card header draws. */
.stage .page-tabs-bar {
    margin-top: var(--sp-4);
    margin-bottom: var(--sp-5);
    border-bottom: 1px solid var(--line);
}

.stage .page-tabs-bar .page-tabs {
    margin-top: 0;
}

/* The compact header for long log pages: one line, pinned under the 52px top
   bar while the table scrolls, so the page name and Export never leave view. */
.stage .page-head-compact {
    position: sticky;
    top: 52px;
    z-index: 5;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--sp-2) var(--sp-4);
    padding: var(--sp-3) 0;
    background: var(--ground);
    border-bottom: 1px solid var(--line);
}

.stage .page-head-compact h1 {
    font-size: var(--fs-xl);
    gap: 8px;
}

/* A log page that is also a hub tab (Mod Logs, Message Log, Audit Log) keeps its tabs
   as a second row inside the pinned bar, so switching view never means scrolling up. */
.stage .page-head-compact .page-tabs {
    flex-basis: 100%;
    margin-top: var(--sp-1);
    margin-bottom: calc(-1 * var(--sp-3) - 1px);
}

.stage .page-head-compact .page-sub {
    flex: 1 1 200px;
    min-width: 0;
    margin: 0;
}

/* The trail sits above the title in the eyebrow's voice: it answers "where am I"
   without competing with the heading for "what is this". */
.stage .crumbs ol {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-1) var(--sp-2);
    list-style: none;
    margin: 0 0 var(--sp-2);
    padding: 0;
    font-family: var(--font-display);
    font-stretch: 88%;
    font-size: var(--fs-xs);
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.stage .crumbs li + li::before {
    content: '/';
    margin-right: var(--sp-2);
    color: var(--ink-4);
}

.stage .crumbs a,
.stage .back-link {
    color: var(--ink-2);
    text-decoration: none;
}

.stage .crumbs a:hover,
.stage .back-link:hover {
    color: var(--spot-ink);
}

.stage .crumbs [aria-current] {
    color: var(--ink-3);
}

.stage .back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    margin-bottom: var(--sp-3);
    font-family: var(--font-display);
    font-stretch: 88%;
    font-size: var(--fs-sm);
}

/* Banners: a quiet panel with the colour in the icon, so a routine "Saved" does
   not shout and red keeps its meaning. An error also keeps a red edge. Bold lead
   says what happened, the rest says why. */
.stage .flash {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3);
    margin-bottom: var(--sp-3);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
}

.stage .flash p {
    flex: 1;
    min-width: 0;
    font-size: var(--fs-sm);
    line-height: 1.45;
    color: var(--ink-2);
}

.stage .flash strong {
    color: var(--ink);
    font-weight: 600;
}

.stage .flash-ico {
    flex: none;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 999px;
}

.stage .flash-ok .flash-ico {
    background: var(--spot-soft);
    color: var(--spot-ink);
}

.stage .flash-error {
    border-color: var(--danger-line);
}

.stage .flash-error .flash-ico {
    background: var(--danger-soft);
    color: var(--danger-ink);
}

.stage .flash-info .flash-ico {
    background: var(--info-soft);
    color: var(--info);
}

.stage .flash-x {
    flex: none;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: var(--r-sm);
    background: none;
    color: var(--ink-3);
    cursor: pointer;
}

.stage .flash-x:hover {
    background: var(--hover-2);
    color: var(--ink);
}

.stage .empty-state .ico-lg {
    display: block;
    margin: 0 auto var(--sp-2);
    color: var(--ink-4);
}

.stage .empty-state .empty-hint {
    margin-top: var(--sp-1);
    font-size: var(--fs-xs);
    color: var(--ink-3);
}

@media (max-width: 560px) {
    /* On a phone the title gets the width; the tile is decoration there. */
    .stage .page-tile {
        display: none;
    }

    .stage .page-actions {
        margin-left: 0;
    }
}

/* Overview: one flat link above Pinned and every heading, set off by a rule rather
   than a heading of its own (a heading over one link does no work). */
.stage .sidebar-nav .nav-flat {
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--line-soft);
}

/* Where something is up to (`ui.phase_track`). Green is done, amber is the step
   that is waiting on somebody now, dim is still to come. */
.stage .phase-track {
    display: flex;
    flex-wrap: wrap;
    gap: 4px var(--sp-5);
    margin: var(--sp-4) 0 0;
    padding: 0;
    list-style: none;
    font-family: var(--font-display);
    font-stretch: 86%;
    font-size: .72rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.stage .phase-track li {
    display: flex;
    align-items: center;
    gap: 7px;
}

.stage .phase-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1.5px solid var(--ink-4);
}

.stage .phase-track li.done .phase-dot {
    background: var(--spot);
    border-color: var(--spot);
}

.stage .phase-track li.on {
    color: var(--ink);
    font-weight: 700;
}

.stage .phase-track li.on .phase-dot {
    background: var(--foot);
    border-color: var(--foot);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--foot) 25%, transparent);
}

/* Tabs within one page (`ui.tab_panel`). A panel is a grid so a three-field card
   sits beside another instead of stretching across the whole page; `span-all`
   keeps a long list full width. */
.stage .tab-grid {
    display: grid;
    gap: var(--sp-5);
    align-items: start;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
}

.stage .tab-grid > * {
    min-width: 0;
    margin: 0;
}

.stage .tab-grid > .span-all {
    grid-column: 1 / -1;
}

.stage .tab-panel[hidden] {
    display: none;
}

.stage [data-tabbed] .tab-panel + .tab-panel {
    margin-top: var(--sp-6, 32px);
}

.stage [data-tabbed].tabs-on .tab-panel + .tab-panel {
    margin-top: 0;
}

.stage .tab-panel.tab-in {
    animation: tab-in .2s ease-out;
}

@keyframes tab-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

/* The tournament manager's team boxes, a grid instead of one column 81 deep. */
.stage .team-grid {
    display: grid;
    gap: var(--sp-3);
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
}

/* A long list that scrolls inside its card instead of making the card a page tall. */
.stage .list-scroll {
    max-height: 30rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 4px;
}

/* A card whose heading folds it (`ui.fold_card`). */
.stage .fold-head {
    margin: 0 0 var(--sp-2);
}

.stage .fold-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    text-align: left;
    color: var(--spot-ink);
    font-family: var(--font-display);
    font-size: .875rem;
    font-weight: 600;
}

.stage .fold-toggle .ico {
    width: 16px;
    height: 16px;
    color: var(--ink-3);
    transition: transform .15s;
}

.stage .fold-toggle[aria-expanded="false"] .ico {
    transform: rotate(-90deg);
}

.stage .fold-toggle:focus-visible {
    outline: 2px solid var(--spot);
    outline-offset: 3px;
    border-radius: 4px;
}

.stage .fold-n {
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--ink-3);
    font-family: var(--font-num);
    font-size: .72rem;
    font-weight: 500;
}

.stage .fold-body[hidden] {
    display: none;
}

/* The search box that sits directly above the list it filters (`ui.list_search`). */
.stage .list-search {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--sp-2) var(--sp-3);
    margin: var(--sp-2) 0 var(--sp-3);
}

.stage .list-search[hidden],
.stage .list-search-none[hidden],
.stage [data-list-hit="0"] {
    display: none !important;
}

.stage .list-search-box {
    position: relative;
    flex: 1 1 240px;
    max-width: 420px;
}

.stage .list-search-box .ico {
    position: absolute;
    left: 10px;
    top: 50%;
    width: 15px;
    height: 15px;
    transform: translateY(-50%);
    color: var(--ink-3);
    pointer-events: none;
}

.stage .list-search-box input {
    width: 100%;
    padding: 7px 10px 7px 32px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--ground);
    color: var(--ink);
    font-size: .85rem;
}

.stage .list-search-box input:focus {
    outline: none;
    border-color: var(--spot);
    box-shadow: 0 0 0 3px var(--spot-soft);
}

.stage .list-search-count {
    font-family: var(--font-num);
    font-size: .75rem;
    color: var(--ink-3);
}

.stage .list-search-extra {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.stage .list-search-none {
    margin: var(--sp-1) 0 var(--sp-3);
    font-size: .82rem;
    color: var(--ink-3);
}

/* A to-do list (`ui.todo`). The stripe and the chip carry the same meaning twice,
   so it reads at a glance and still reads without colour: red a dispute, amber a
   mod's to-do, a plain rule somebody else's. */
.stage .todo-list {
    display: grid;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.stage .todo {
    display: grid;
    grid-template-columns: 8rem minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--sp-3);
    padding: 9px 10px;
    border-left: 3px solid var(--line);
    border-radius: var(--r-sm);
}

.stage .todo:hover {
    background: var(--hover);
}

.stage .todo-red {
    border-left-color: var(--danger);
}

.stage .todo-amber {
    border-left-color: var(--foot);
}

.stage .todo .badge {
    justify-self: start;
}

.stage .todo-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    font-size: .86rem;
    color: var(--ink-2);
}

.stage .todo-text small {
    overflow: hidden;
    color: var(--ink-3);
    font-size: .75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stage .todo .btn-ghost {
    white-space: nowrap;
}

/* A row that arrived with the last refresh. */
.stage .todo.is-new {
    animation: todo-new 1.6s ease-out;
}

@keyframes todo-new {
    0% { opacity: 0; transform: translateY(-6px); background: color-mix(in srgb, var(--foot) 28%, transparent); }
    20% { opacity: 1; transform: none; }
    100% { background: transparent; }
}

@media (max-width: 560px) {
    .stage .todo {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .stage .todo .badge {
        grid-column: 1 / -1;
    }
}

/* "Live. Updated 12s ago." over a region that refreshes itself (`data-refresh`).
   Amber, because it is a live thing; grey once paused. */
.stage .live-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2) var(--sp-3);
    font-size: .8rem;
    color: var(--ink-3);
}

.stage .live-bar[hidden] {
    display: none;
}

.stage .live-bar strong {
    color: var(--ink-2);
}

.stage .live-text {
    flex: 1 1 220px;
    min-width: 0;
}

.stage .live-bar .btn-ghost {
    padding: 3px 10px;
    font-size: .75rem;
}

.stage .live-dot {
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--foot);
    animation: live-beat 2.4s ease-out infinite;
}

.stage .live-bar.paused .live-dot,
.stage .live-bar.stale .live-dot {
    background: var(--ink-4);
    animation: none;
}

@keyframes live-beat {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--foot) 60%, transparent); }
    70%, 100% { box-shadow: 0 0 0 7px transparent; }
}

/* The tournament manager's Race now heats: folded rows, the first open. */
.stage .race-heat {
    margin-bottom: var(--sp-2);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
}

.stage .race-heat summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px var(--sp-3);
    padding: 8px 12px;
    cursor: pointer;
    font-size: .8rem;
}

.stage .race-heat-teams {
    flex: 1;
    min-width: 0;
    color: var(--ink-2);
}

.stage .race-heat-form {
    padding: 4px 12px 12px;
}

/* Filter chips: a set of mutually exclusive filters over the list a `list_search`
   box sits above (`data-filter-chips`). Each carries its own count. */
.stage .filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 var(--sp-2);
}

.stage .filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: none;
    color: var(--ink-3);
    font-family: var(--font-display);
    font-size: .76rem;
    font-weight: 600;
    cursor: pointer;
}

.stage .filter-chip .n {
    font-family: var(--font-num);
    font-weight: 500;
    color: var(--ink-3);
}

.stage .filter-chip.on {
    border-color: var(--spot-line);
    background: var(--spot-soft);
    color: var(--ink);
}

.stage .filter-chip.on .n {
    color: var(--spot-ink);
}

.stage .filter-chip:focus-visible {
    outline: 2px solid var(--spot);
    outline-offset: 2px;
}

/* The tournament manager's roster (`_tournament_roster.html`). Each entrant is a
   <tbody> holding its row and its detail row, so search, filters and dragging move
   the pair together. Scrolls inside its own box with the header pinned. */
.stage .ro-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2) var(--sp-4);
    margin-bottom: var(--sp-3);
}

.stage .ro-cap {
    font-size: .78rem;
    color: var(--ink-3);
}

.stage .ro-cap a {
    color: var(--spot-ink);
}

.stage .ro-head-acts {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.stage .ro-drop {
    position: relative;
}

.stage .ro-drop > summary,
.stage .ro-menu > summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    list-style: none;
    cursor: pointer;
}

.stage .ro-drop > summary::-webkit-details-marker,
.stage .ro-menu > summary::-webkit-details-marker {
    display: none;
}

.stage .ro-drop > summary .ico,
.stage .ro-menu .ico {
    width: 14px;
    height: 14px;
}

.stage .ro-drop-body,
.stage .ro-pop {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 6;
    padding: var(--sp-3);
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface);
    box-shadow: 0 10px 30px rgb(0 0 0 / .45);
}

.stage details[data-flip].flip > .ro-pop {
    top: auto;
    bottom: calc(100% + 4px);
}

.stage .ro-drop-body {
    width: min(26rem, calc(100vw - 48px));
}

.stage .ro-drop-wide {
    width: min(34rem, calc(100vw - 48px));
}

.stage .ro-add {
    display: grid;
    gap: var(--sp-2);
}

.stage .ro-add-names {
    display: grid;
    gap: var(--sp-2);
}

.stage .ro-signups {
    margin-bottom: var(--sp-3);
    padding: var(--sp-3);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
}

.stage .ro-hint {
    margin: 4px 0 var(--sp-3);
    font-size: .76rem;
    color: var(--ink-3);
}

.stage .ro-scroll {
    max-height: 34rem;
    overflow: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
}

.stage .ro-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
}

.stage .ro-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
    text-align: left;
    font-family: var(--font-display);
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.stage .ro-table td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
    color: var(--ink-2);
}

.stage .ro-table tr.ro:hover td {
    background: var(--hover);
}

.stage .ro-team.open tr.ro td,
.stage .ro-detail td {
    background: var(--surface-2);
}

.stage .ro-seed {
    font-family: var(--font-num);
    font-size: .75rem;
    color: var(--ink-3);
}

.stage .roster .drag-handle {
    cursor: grab;
    color: var(--ink-3);
}

.stage .ro-open {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--ink);
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.stage .ro-open .ico {
    flex: none;
    width: 14px;
    height: 14px;
    color: var(--ink-3);
    transition: transform .15s;
}

.stage .ro-open[aria-expanded="true"] .ico {
    transform: rotate(90deg);
}

.stage .ro-struck {
    text-decoration: line-through;
    color: var(--ink-3);
}

.stage .ro-umas {
    max-width: 16rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink-3);
}

.stage .roster .cap {
    color: var(--spot-ink);
    font-size: .7rem;
}

.stage .roster .muted {
    color: var(--ink-3);
    font-style: italic;
}

.stage .ro-check {
    padding: 2px 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: none;
    color: var(--ink-3);
    font-size: .74rem;
    white-space: nowrap;
    cursor: pointer;
}

.stage .ro-check.on {
    border-color: var(--spot-line);
    background: var(--spot-soft);
    color: var(--spot-ink);
}

.stage .ro-room {
    color: var(--spot-ink);
    white-space: nowrap;
}

.stage .ro-acts {
    width: 1%;
    text-align: right;
}

.stage .ro-menu {
    position: relative;
    display: inline-block;
}

.stage .ro-menu > summary {
    padding: 3px 8px;
}

.stage .ro-pop {
    display: flex;
    flex-direction: column;
    min-width: 14rem;
    padding: 4px;
    text-align: left;
}

.stage .ro-pop form {
    display: flex;
    flex-direction: column;
}

.stage .ro-pop button,
.stage .ro-pop a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--ink-2);
    font-size: .8rem;
    text-align: left;
    cursor: pointer;
}

.stage .ro-pop button:hover,
.stage .ro-pop a:hover {
    background: var(--hover);
}

.stage .ro-pop .danger {
    color: var(--danger);
}

.stage .ro-detail[hidden] {
    display: none;
}

.stage .ro-detail-in {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: var(--sp-3) var(--sp-5);
    padding: 4px 2px 8px 22px;
}

.stage .ro-chips {
    display: flex;
    flex-wrap: wrap;
    flex-basis: 100%;
    align-items: center;
    gap: 6px;
}

.stage .ro-chip {
    padding: 2px 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: .75rem;
    color: var(--ink-2);
}

.stage .ro-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.stage .ro-form strong {
    margin-right: 4px;
    font-size: .74rem;
    font-weight: 600;
    color: var(--ink-3);
}

.stage .ro-form .form-input {
    width: 9.5rem;
    padding: 5px 8px;
    font-size: .78rem;
}

.stage .ro-tick {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: .75rem;
    color: var(--ink-3);
}

.stage .ro-full {
    display: inline-flex;
    align-self: center;
    align-items: center;
    gap: 4px;
    font-size: .78rem;
    color: var(--spot-ink);
}

.stage .ro-full .ico,
.stage .ro-pop a .ico {
    width: 14px;
    height: 14px;
}

@media (max-width: 820px) {
    .stage .ro-table thead {
        display: none;
    }

    .stage .ro-table,
    .stage .ro-table tbody {
        display: block;
    }

    .stage .ro-table tr.ro {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px 8px;
        padding: 10px;
        border-bottom: 1px solid var(--line);
    }

    .stage .ro-table tr.ro td {
        display: block;
        padding: 0;
        border: 0;
        background: none;
        font-size: .76rem;
    }

    .stage .ro-table tr.ro td.ro-name {
        flex: 1 1 0;
        min-width: 0;
        font-size: .86rem;
    }

    .stage .ro-table tr.ro td.ro-acts {
        order: 1;
        width: auto;
    }

    .stage .ro-table tr.ro td.ro-players {
        flex-basis: 100%;
        order: 2;
    }

    .stage .ro-table tr.ro td:not(.ro-name):not(.ro-acts):not(.ro-players) {
        order: 3;
    }

    .stage .ro-table tr.ro td.ro-umas,
    .stage .ro-table tr.ro td.ro-num {
        display: none;
    }

    .stage .ro-table tr.ro-detail,
    .stage .ro-table tr.ro-detail td {
        display: block;
    }

    .stage .ro-table tr.ro-detail[hidden] {
        display: none;
    }

    .stage .ro-detail-in {
        padding-left: 6px;
    }
}

/* Champions, once a tournament is over. */
.stage .podium {
    display: grid;
    gap: var(--sp-3);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
}

.stage .podium > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface-2);
}

.stage .podium > .podium-top {
    border-color: color-mix(in srgb, var(--foot) 55%, transparent);
}

.stage .podium small {
    font-family: var(--font-display);
    font-stretch: 86%;
    font-size: .68rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.stage .podium strong {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ink);
}

/* ── Rooms tab: the seeding picker and the whole bracket (redesign step 4) ──
   Every column of a track shares the card's width (minmax(0, 1fr)), so the
   whole bracket is in view with no sideways scroll; on a phone the columns
   stack. Hidden state here is set by the script, so with scripts off both the
   board and the list show, and every menu is a <details> of plain forms. */
.stage .sd-sub {
    margin: 0 0 8px;
    font: 600 .7rem var(--font-display);
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.stage .sd-methods {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
    margin-bottom: 18px;
}

.stage .sd-method {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
}

.stage .sd-method:has(input:checked) {
    border-color: var(--spot-line);
    background: var(--spot-soft);
}

.stage .sd-method input,
.stage .sd-inline input {
    margin-top: 3px;
    accent-color: var(--spot);
}

.stage .sd-method strong {
    display: block;
    font-size: .86rem;
    color: var(--ink);
}

.stage .sd-method small {
    display: block;
    margin-top: 2px;
    font-size: .76rem;
    line-height: 1.4;
    color: var(--ink-3);
}

.stage .sd-method em {
    font-style: normal;
    font-weight: 400;
    color: var(--spot-ink);
}

.stage .sd-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    margin: 0 0 10px;
    font-size: .8rem;
    color: var(--ink-2);
}

.stage .sd-inline label {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.stage .sd-preview {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
    margin-bottom: 16px;
}

.stage .sd-preview[hidden],
.stage .bk-pending[hidden],
.stage .bk-warn[hidden],
.stage .bk-edit-hint[hidden],
.stage [data-bk-pane][hidden] {
    display: none;
}

.stage .sd-room {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: .78rem;
}

.stage .sd-room b {
    display: block;
    margin-bottom: 4px;
    font: 600 .68rem var(--font-display);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.stage .sd-room div {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 1px 0;
    color: var(--ink-2);
}

.stage .sd-room .sd {
    font-family: var(--font-num);
    font-size: .72rem;
    color: var(--ink-3);
}

.stage .sd-go {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.stage .bk-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    margin-bottom: 8px;
}

.stage .bk-method {
    font-size: .78rem;
    color: var(--ink-3);
}

.stage .bk-method strong {
    font-weight: 600;
    color: var(--ink-2);
}

.stage .bk-view {
    display: inline-flex;
    gap: 2px;
    margin-left: auto;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.stage .bk-view[hidden],
.stage .bk-edit[hidden] {
    display: none;
}

.stage .bk-view button {
    padding: 4px 10px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--ink-3);
    font: 600 .76rem var(--font-display);
    cursor: pointer;
}

.stage .bk-view button.on {
    background: var(--spot-soft);
    color: var(--ink);
    box-shadow: inset 0 0 0 1px var(--spot-line);
}

.stage .bk-edit .ico {
    width: 14px;
    height: 14px;
}

.stage .bk-edit[aria-pressed="true"] {
    border-color: var(--foot);
    color: var(--foot);
}

.stage .bk-edit-hint {
    margin: 0 0 10px;
    font-size: .78rem;
    color: var(--foot);
}

.stage .bk-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
    margin-bottom: 12px;
    font-size: .72rem;
    color: var(--ink-3);
}

.stage .lg {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 4px;
    border-radius: 3px;
    vertical-align: -1px;
}

.stage .lg-adv {
    background: color-mix(in srgb, var(--spot) 55%, transparent);
}

.stage .lg-out {
    background: var(--line);
}

.stage .bk-track {
    margin-bottom: 18px;
}

.stage .bk-track-name {
    margin: 0 0 8px;
    font: 600 .7rem var(--font-display);
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--spot-ink);
}

.stage .bk-track-name.red {
    color: var(--foot);
}

.stage .bk-cols {
    display: grid;
    grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr));
    gap: 10px;
    align-items: stretch;
}

.stage .bk-grid .bk-col {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr));
    align-items: start;
}

.stage .bk-grid .bk-col-name {
    grid-column: 1 / -1;
    text-align: left;
}

.stage .bk-cols.bk-single {
    max-width: 26rem;
}

.stage .bk-col {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    gap: 8px;
    min-width: 0;
}

.stage .bk-col-name {
    margin-bottom: 2px;
    font-family: var(--font-display);
    font-size: .68rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    text-align: center;
    color: var(--ink-3);
}

.stage .bk-room {
    position: relative;
    min-width: 0;
    padding: 6px 8px 7px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-2);
}

.stage .bk-room.disputed {
    border-color: color-mix(in srgb, var(--danger) 65%, transparent);
}

.stage .bk-room.ready {
    border-color: color-mix(in srgb, var(--foot) 55%, transparent);
}

.stage .bk-room.conflict {
    border-color: var(--foot);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--foot) 35%, transparent);
}

.stage .bk-room-head {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
    font-size: .66rem;
    color: var(--ink-3);
}

.stage .bk-room-head .badge {
    margin-left: auto;
    padding: 0 5px;
    font-size: .58rem;
}

.stage .bk-seat {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    padding: 2px 4px;
    border-radius: 5px;
    font-size: .74rem;
    color: var(--ink-2);
}

.stage .bk-seat .nm {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stage .bk-seat .pl {
    font-family: var(--font-num);
    font-size: .68rem;
    color: var(--ink-3);
}

.stage .bk-seat .sd {
    width: 1.4em;
    font-family: var(--font-num);
    font-size: .62rem;
    text-align: right;
    color: var(--ink-4);
}

.stage .bk-seat.adv {
    background: color-mix(in srgb, var(--spot) 18%, transparent);
    color: var(--ink);
}

/* The viewer's own team on the member-facing bracket page. */
.stage .bk-seat.mine {
    box-shadow: inset 0 0 0 1px var(--spot-line);
    color: var(--ink);
}

.stage .bk-seat.tbd .nm {
    font-style: italic;
    color: var(--ink-3);
}

.stage .bk-seat .badge {
    padding: 0 4px;
    font-size: .55rem;
}

.stage .bk-note {
    margin: 4px 0 0;
    font-size: .7rem;
    color: var(--danger);
}

.stage .editing .bk-room[data-set] .bk-seat[data-seat] {
    outline: 1px dashed transparent;
    cursor: pointer;
}

.stage .editing .bk-room[data-set] .bk-seat[data-seat]:hover {
    outline-color: var(--foot);
}

.stage .editing .bk-room.locked {
    opacity: .55;
}

.stage .bk-seat.picked {
    outline: 2px solid var(--foot) !important;
    background: color-mix(in srgb, var(--foot) 18%, transparent);
}

.stage .bk-seat.moved {
    box-shadow: inset 3px 0 0 var(--foot);
}

.stage .bk-warn {
    margin: 0 0 8px;
    padding: 6px 10px;
    border-left: 3px solid var(--foot);
    border-radius: 0 6px 6px 0;
    background: color-mix(in srgb, var(--foot) 8%, transparent);
    font-size: .78rem;
    color: var(--foot);
}

.stage .bk-pending {
    position: sticky;
    bottom: 12px;
    z-index: 4;
    margin-top: 12px;
    padding: 12px 14px;
    border: 1px solid var(--foot);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 10px 30px rgb(0 0 0 / .4);
}

.stage .bk-pending-head {
    margin-bottom: 6px;
    font-size: .82rem;
    color: var(--ink);
}

.stage .bk-pending-n {
    font-weight: 400;
    color: var(--ink-3);
}

.stage .bk-pending-list {
    margin: 0 0 8px;
    padding-left: 18px;
    font-size: .78rem;
    color: var(--ink-2);
}

.stage .bk-pending-acts {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.stage .bk-menu > summary {
    padding: 0 2px;
    list-style: none;
    font-size: .8rem;
    line-height: 1;
    color: var(--ink-3);
    cursor: pointer;
}

.stage .bk-menu > summary::-webkit-details-marker {
    display: none;
}

.stage .bk-pop {
    position: absolute;
    top: 22px;
    right: 4px;
    z-index: 7;
    display: flex;
    flex-direction: column;
    min-width: 15rem;
    max-width: min(22rem, 86vw);
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 10px 30px rgb(0 0 0 / .45);
}

.stage .bk-menu.flip .bk-pop {
    top: auto;
    bottom: 22px;
}

.stage .bk-pop > a,
.stage .bk-pop > form > button,
.stage .bk-act > summary {
    display: block;
    width: 100%;
    padding: 7px 10px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--ink-2);
    font-size: .78rem;
    text-align: left;
    cursor: pointer;
}

.stage .bk-pop > a:hover,
.stage .bk-pop > form > button:hover,
.stage .bk-act > summary:hover {
    background: var(--hover);
}

.stage .bk-pop-note {
    margin: 0;
    padding: 7px 10px;
    font-size: .74rem;
    color: var(--ink-3);
}

.stage .bk-form {
    padding: 4px 10px 8px;
    font-size: .74rem;
}

.stage .bk-form label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    color: var(--ink-2);
}

.stage .bk-form input[type=number] {
    width: 52px;
    padding: 2px 4px;
}

.stage .bk-form input[type=text] {
    width: 100%;
    margin: 4px 0;
    padding: 4px 6px;
    font-size: .74rem;
}

.stage .bk-form .acts {
    display: flex;
    justify-content: flex-end;
    margin-top: 6px;
}

.stage .bk-form .note {
    margin: 2px 0 4px;
    font-size: .7rem;
    color: var(--ink-3);
}

.stage .ls-row {
    display: grid;
    grid-template-columns: 12rem minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    font-size: .8rem;
}

.stage .ls-row .t {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink-2);
}

.stage .ls-row .l {
    font-family: var(--font-num);
    font-size: .74rem;
    color: var(--ink-3);
}

@media (max-width: 820px) {
    .stage .bk-cols {
        grid-template-columns: 1fr;
    }

    .stage .ls-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .stage .ls-row .t {
        grid-column: 1 / -1;
        order: 3;
    }
}

/* ── Discord & assets tab (redesign step 5) ──
   Status as counts first; channel settings fold behind one summary line; room
   pictures grouped by round. Amber is a count that needs somebody, red a dispute. */
.stage .dc-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.stage .dc-head .badge,
.stage .dc-head .dc-all {
    margin-left: auto;
}

.stage .dc-sub {
    margin: 0 0 12px;
    font-size: .76rem;
    color: var(--ink-3);
}

.stage .dc-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.stage .dc-stat {
    padding: 4px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: .76rem;
    color: var(--ink-3);
}

.stage .dc-stat b {
    margin-right: 2px;
    font-family: var(--font-num);
    font-weight: 600;
    color: var(--ink);
}

.stage .dc-stat.amber {
    border-color: color-mix(in srgb, var(--foot) 45%, transparent);
}

.stage .dc-stat.amber b {
    color: var(--foot);
}

.stage .dc-stat.red {
    border-color: color-mix(in srgb, var(--danger) 55%, transparent);
}

.stage .dc-stat.red b {
    color: var(--danger);
}

.stage .dc-stat.green b {
    color: var(--spot-ink);
}

.stage .dc-who {
    margin: 0 0 6px;
    font-size: .76rem;
    color: var(--ink-2);
}

.stage .dc-who > span {
    color: var(--ink-3);
}

.stage .dc-who.muted {
    color: var(--ink-3);
}

.stage .dc-who.red {
    color: var(--danger);
}

.stage .dc-link,
.stage .dc-view {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.stage .dc-link {
    margin-left: 6px;
    font-size: .74rem;
    color: var(--spot-ink);
}

.stage .dc-link .ico,
.stage .dc-view .ico,
.stage .pic-zip .ico,
.stage .dc-all .ico {
    width: 13px;
    height: 13px;
}

.stage .dc-acts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    margin: 12px 0 4px;
}

.stage .dc-hint {
    flex-basis: 100%;
    font-size: .72rem;
    color: var(--ink-3);
}

.stage .dc-busy {
    font-size: .74rem;
    color: var(--foot);
}

.stage .dc-unset {
    color: var(--foot);
}

.stage .dc-settings {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
}

.stage .dc-settings > summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    list-style: none;
    font-size: .74rem;
    color: var(--ink-3);
    cursor: pointer;
}

.stage .dc-settings > summary::-webkit-details-marker,
.stage .pic-round > summary::-webkit-details-marker {
    display: none;
}

.stage .dc-settings b {
    font-weight: 600;
    color: var(--ink-2);
}

.stage .dc-settings b.dc-unset {
    color: var(--foot);
}

.stage .dc-change {
    margin-left: auto;
    color: var(--spot-ink);
}

.stage .dc-settings[open] .dc-change {
    color: var(--ink-3);
}

.stage .dc-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
    gap: 10px;
    align-items: end;
    margin-top: 10px;
}

.stage .dc-form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: .72rem;
    color: var(--ink-3);
}

.stage .pic-key {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
    gap: 6px 18px;
    margin: 0 0 14px;
    font-size: .74rem;
}

.stage .pic-key div {
    display: flex;
    gap: 8px;
}

.stage .pic-key dt {
    min-width: 3.2em;
    font-weight: 600;
    color: var(--ink-2);
}

.stage .pic-key dd {
    margin: 0;
    color: var(--ink-3);
}

.stage .pic-round {
    margin-bottom: 8px;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.stage .pic-round > summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    list-style: none;
    cursor: pointer;
}

.stage .pic-round-name {
    font: 600 .8rem var(--font-display);
    color: var(--ink);
}

.stage .pic-round .fold-n {
    white-space: nowrap;
}

.stage .pic-zip {
    margin-left: auto;
    white-space: nowrap;
}

.stage .pic-round ul {
    margin: 0;
    padding: 0 12px 6px;
    list-style: none;
}

.stage .pic-row {
    display: grid;
    grid-template-columns: 6.5rem minmax(0, 1fr) auto auto;
    gap: 10px;
    align-items: center;
    padding: 7px 0;
    border-top: 1px solid var(--line);
    font-size: .78rem;
}

.stage .pic-room {
    font-family: var(--font-num);
    font-size: .74rem;
    color: var(--ink-3);
}

.stage .pic-teams {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink-2);
}

.stage .pic-links {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stage .dc-dl {
    color: var(--spot-ink);
}

.stage .dc-dl.off {
    color: var(--ink-4);
    cursor: not-allowed;
}

.stage .dc-view {
    color: var(--ink-3);
}

@media (max-width: 820px) {
    .stage .pic-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .stage .pic-teams {
        grid-column: 1 / -1;
        order: 3;
        white-space: normal;
    }

    .stage .pic-links {
        grid-column: 1 / -1;
        order: 4;
    }
}

@media (max-width: 560px) {
    .stage .pic-zip .zl {
        display: none;
    }
}

/* ── Settings tab (redesign step 6) ──
   After the draw the format is a read-only summary; qualifying settings and points
   open behind Unlock, a <details> whose summary sits in the card's corner and reads
   Cancel while open, so it works with scripts off and a save redraws it closed. */
.stage .st-fixed .ico {
    width: 11px;
    height: 11px;
    vertical-align: -1px;
}

.stage .st-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
    gap: 10px 24px;
    margin: 0 0 12px;
}

.stage .st-grid.two {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr));
    margin: 0;
}

.stage .st-row dt {
    margin-bottom: 2px;
    font: 600 .66rem var(--font-display);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.stage .st-row dd {
    margin: 0;
    font-size: .86rem;
    color: var(--ink);
}

.stage .st-row dd small {
    display: block;
    font-size: .72rem;
    color: var(--ink-3);
}

.stage .st-lock {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
    margin: 0;
    padding-top: 10px;
    border-top: 1px solid var(--line);
    font-size: .76rem;
    color: var(--ink-3);
}

.stage .st-lock .ico {
    width: 13px;
    height: 13px;
}

.stage .st-card {
    position: relative;
}

.stage .st-unlock > summary {
    position: absolute;
    top: 16px;
    right: 20px;
    list-style: none;
    cursor: pointer;
}

.stage .st-unlock > summary::-webkit-details-marker,
.stage .st-danger > summary::-webkit-details-marker {
    display: none;
}

.stage .st-unlock > summary .ico {
    width: 13px;
    height: 13px;
}

.stage .st-unlock .st-shut,
.stage .st-unlock[open] .st-open {
    display: none;
}

.stage .st-unlock[open] .st-shut {
    display: inline;
}

.stage .st-unlock[open] ~ .st-view {
    display: none;
}

.stage .st-unlock .dc-form label input:disabled {
    opacity: .55;
}

.stage .st-why {
    font-size: .68rem;
    color: var(--ink-4);
}

.stage .st-acts {
    display: flex;
    grid-column: 1 / -1;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

.stage .pt-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 6px;
}

.stage .pt-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: .7rem;
    color: var(--ink-3);
}

.stage .pt-cell b {
    font-family: var(--font-num);
    font-size: .9rem;
    color: var(--ink);
}

.stage label.pt-cell input {
    width: 100%;
    padding: 3px;
    text-align: center;
}

.stage .card.st-danger {
    border-color: color-mix(in srgb, var(--danger) 35%, transparent);
}

.stage .st-danger > summary {
    list-style: none;
    font: 600 .86rem var(--font-display);
    color: var(--danger);
    cursor: pointer;
}

.stage .st-danger-in {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px 24px;
    margin-top: 12px;
}

.stage .st-danger-in strong {
    font-size: .84rem;
    color: var(--ink);
}

.stage .st-danger-in p {
    max-width: 38rem;
    margin: 4px 0 0;
    font-size: .76rem;
    color: var(--ink-3);
}

.stage .st-danger-in p strong {
    font-size: inherit;
}

.stage .st-del {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px;
}

.stage .st-del label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: .72rem;
    color: var(--ink-3);
}

@media (max-width: 560px) {
    .stage .pt-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* ── Tournaments list (redesign step 7) ──
   The list leads; the create form folds into a card that opens from its own
   summary. Rows carry the phase the manager's strip names. */
.stage .tl-new {
    margin-bottom: var(--sp-4);
}

.stage .tl-new > summary {
    display: flex;
    align-items: center;
    list-style: none;
    font: 600 .86rem var(--font-display);
    color: var(--spot-ink);
    cursor: pointer;
}

.stage .tl-new > summary::-webkit-details-marker {
    display: none;
}

.stage .tl-new > summary .ico {
    width: 15px;
    height: 15px;
    vertical-align: -2px;
}

.stage .tl-new-shut,
.stage .tl-new[open] .tl-new-label {
    display: none;
}

.stage .tl-new[open] .tl-new-shut {
    display: inline;
    margin-left: auto;
    font-weight: 500;
    color: var(--ink-3);
}

.stage .tl-new[open] > summary {
    margin-bottom: 14px;
}

.stage .tl-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.stage .tl-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    gap: 12px;
    align-items: center;
    padding: 10px 2px;
    border-top: 1px solid var(--line);
}

.stage .tl-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stage .tl-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
    color: var(--ink);
}

.stage .tl-name:hover {
    color: var(--spot-ink);
}

.stage .tl-meta {
    font-size: .74rem;
    color: var(--ink-3);
}

.stage .tl-open .ico {
    width: 13px;
    height: 13px;
}

.stage .tl-menu {
    position: relative;
}

.stage .tl-pop {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 6;
    width: min(20rem, calc(100vw - 48px));
    padding: var(--sp-3);
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface);
    box-shadow: 0 10px 30px rgb(0 0 0 / .45);
}

.stage details[data-flip].flip > .tl-pop {
    top: auto;
    bottom: calc(100% + 4px);
}

.stage .tl-pop > a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border-radius: 6px;
    font-size: .8rem;
    color: var(--ink-2);
}

.stage .tl-pop > a:hover {
    background: var(--hover);
}

.stage .tl-del {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
    padding: 10px;
    border-top: 1px solid var(--line);
    font-size: .74rem;
    color: var(--ink-3);
}

.stage .tl-del p {
    margin: 0;
}

.stage .tl-del label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stage .tl-del button {
    align-self: flex-start;
}

@media (max-width: 560px) {
    .stage .tl-row {
        grid-template-columns: minmax(0, 1fr) auto auto;
    }

    .stage .tl-open {
        display: none;
    }
}

/* ── Entrant page (redesign step 7) ── */
.stage .en-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.stage .en-player {
    padding: 10px 0;
    border-top: 1px solid var(--line);
}

.stage .en-player:first-child {
    border-top: 0;
    padding-top: 0;
}

.stage .en-pending {
    padding: 10px 12px;
    border: 1px dashed var(--line);
    border-radius: 8px;
}

.stage .en-name {
    font-size: .88rem;
    color: var(--ink);
}

.stage .en-meta {
    margin-top: 2px;
    font-size: .72rem;
    color: var(--ink-3);
}

.stage .en-none {
    font-style: italic;
}

.stage .en-umas {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
}

.stage .en-uma {
    padding: 2px 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: .74rem;
    color: var(--ink-2);
}

.stage .en-face {
    color: var(--spot-ink);
}

.stage .en-invites {
    margin: 10px 0 0;
}

.stage .en-pic {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.stage .en-pic-img img {
    display: block;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--ground);
    object-fit: cover;
}

.stage .en-pic-avatar .en-pic-img img {
    width: 64px;
    height: 64px;
}

.stage .en-pic-banner .en-pic-img {
    flex: 1 1 100%;
}

.stage .en-pic-banner .en-pic-img img {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 1;
}

.stage .en-pic-side {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.stage .en-pic-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: .8rem;
    color: var(--ink-2);
}

.stage .en-pic-acts,
.stage .en-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.stage .en-file {
    max-width: 13rem;
    font-size: .72rem;
    color: var(--ink-3);
}

.stage .btn-ghost.en-danger {
    color: var(--danger);
}

.stage .en-rename {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.stage .en-rename label {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 4px;
    min-width: 12rem;
    font-size: .72rem;
    color: var(--ink-3);
}

.stage .en-rooms {
    margin-left: auto;
}

.stage .en-race {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 4.5rem;
    gap: 12px;
    align-items: center;
    padding: 8px 2px;
    border-top: 1px solid var(--line);
    font-size: .8rem;
}

.stage .en-race-name {
    color: var(--ink-2);
}

.stage .en-race-name.red {
    color: var(--foot);
}

.stage .en-pts {
    font-family: var(--font-num);
    font-size: .76rem;
    text-align: right;
    color: var(--spot-ink);
}

.stage .en-notes {
    margin: 0;
    white-space: pre-line;
    font-size: .8rem;
    color: var(--ink-2);
}

/* A save that redrew the page in place marks the card it came from. */
.stage .live-saved {
    animation: live-saved .9s ease-out;
}

@keyframes live-saved {
    from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--spot) 55%, transparent); }
    to { box-shadow: 0 0 0 14px transparent; }
}

.stage [data-live-root][aria-busy="true"] button[type="submit"],
.stage [data-live-root][aria-busy="true"] form button:not([type]) {
    cursor: progress;
}

@media (prefers-reduced-motion: reduce) {
    .stage .tab-panel.tab-in,
    .stage .live-saved,
    .stage .todo.is-new,
    .stage .live-dot {
        animation: none;
    }
}

/* ── Bottom bar (mobile) ── */
.stage .bottom-nav {
    background: var(--bar);
    border-top: 1px solid var(--line);
}

.stage .bottom-nav a,
.stage .bottom-nav .bn-menu {
    color: var(--ink-4);
    font-family: var(--font-display);
    font-stretch: 88%;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    font-size: .58rem;
}

.stage .bottom-nav .bn-ico {
    display: flex;
    align-items: center;
    justify-content: center;
}

.stage .bottom-nav .bn-ico .ico {
    width: 1.3rem;
    height: 1.3rem;
}

.stage .bottom-nav a.active {
    color: var(--spot);
}

.stage .bottom-nav a.active .bn-ico {
    filter: none;
}

/* ── The admin Browse-as bar. It is chrome, so it stays in the wings; it must
      keep rendering (including on the 403 page) or an admin browsing as a
      member can strand themselves. Colour only. ── */
.stage .viewas {
    background: var(--ground-2) !important;
    border-color: var(--line) !important;
    border-radius: var(--r) !important;
}

/* ══ Rule 1 · light is hierarchy ══════════════════════════════════════════
   A panel is either lit or in the wings. The spot comes from directly above,
   as a gradient on the panel itself rather than a halo around it, so it reads
   as light falling on a surface. */
.stage .panel {
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-lg);
    position: relative;
}

.stage .panel.lit {
    background:
        radial-gradient(130% 80% at 50% -25%, var(--lit-wash), transparent 62%),
        var(--surface);
    border-color: var(--line);
}

.stage .wings {
    color: var(--ink-3);
}

/* Section headings sit above their zone like a bill: condensed caps, a rule
   running out to the edge. */
.stage .sec {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 12px;
    font-family: var(--font-display);
    font-stretch: 82%;
    font-weight: 600;
    font-size: .74rem;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--spot-ink);
}

.stage .sec .ico {
    color: var(--spot);
}

.stage .sec::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, var(--line), transparent);
}

.stage .sec .count {
    font-family: var(--font-num);
    letter-spacing: 0;
    color: var(--ink-4);
}

/* ══ Rule 2 · footlights mean live ════════════════════════════════════════
   One warm strip along the bottom edge. It marks live / open / waiting on
   someone. It is NOT applied to every card, which is what made it trim. */
.stage .live::after {
    content: '';
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 0;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--foot), transparent);
    box-shadow: 0 1px 12px 1px var(--foot-glow);
    pointer-events: none;
    border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* The card class inherited from base.html: on a stage page it is a plain panel.
   No rainbow halo on hover, no footlight on everything, no lift. */
.stage .card {
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-lg);
    box-shadow: none;
    animation: none;
}

.stage .card::before,
.stage .card::after {
    display: none;
}

.stage .card:hover {
    box-shadow: none;
    transform: none;
}

/* ══ Figures ══════════════════════════════════════════════════════════════
   Condensed caps and figures are the shared language of a race card and a
   theatre bill, which is the exact overlap Fuji sits in. This is where the
   character lives, so it carries the numbers rather than a serif display face
   (Inter + Playfair being one of the strongest AI tells in the old build). */
.stage .fig {
    font-family: var(--font-display);
    font-stretch: 76%;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: .95;
    letter-spacing: .005em;
    color: var(--spot-ink);
    display: block;
}

.stage .fig-xl {
    font-size: 2.6rem;
}

.stage .fig-lg {
    font-size: 1.85rem;
}

.stage .fig-sm {
    font-size: 1.15rem;
}

.stage .num {
    font-family: var(--font-num);
    font-variant-numeric: tabular-nums;
    font-size: .82rem;
}

.stage .lbl {
    font-family: var(--font-display);
    font-stretch: 84%;
    font-weight: 600;
    font-size: .7rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-3);
}

/* ══ Badges ══════════════════════════════════════════════════════════════ */
.stage .badge {
    font-family: var(--font-display);
    font-stretch: 86%;
    font-weight: 600;
    font-size: .68rem;
    letter-spacing: .06em;
    padding: 2px 8px;
    border-radius: var(--r-sm);
    gap: 5px;
}

.stage .badge-green {
    background: var(--spot-soft);
    color: var(--spot-badge);
    border-color: var(--spot-line);
}

.stage .badge-amber {
    background: var(--foot-soft);
    color: var(--foot);
    border-color: var(--foot-line);
}

.stage .badge-red {
    background: var(--danger-soft);
    color: var(--danger-ink);
    border-color: var(--danger-line);
}

.stage .badge-gray {
    background: var(--hover);
    color: var(--ink-3);
    border-color: var(--line);
}

.stage .badge-blue {
    background: var(--info-soft);
    color: var(--info);
    border-color: var(--info-line);
}

/* ══ Buttons ═════════════════════════════════════════════════════════════
   One primary action per screen gets the spot. Everything else is quiet. */
.stage .btn,
.stage .btn-green,
.stage .btn-red,
.stage .btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-display);
    font-stretch: 88%;
    font-weight: 600;
    font-size: .8rem;
    letter-spacing: .02em;
    border-radius: var(--r-sm);
    padding: 6px 12px;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}

.stage .btn-green {
    background: var(--spot);
    color: var(--btn-ink);
    border: 1px solid var(--spot);
}

.stage .btn-green::before {
    display: none;
}

.stage .btn-green:hover {
    background: var(--spot-hi);
    border-color: var(--spot-hi);
}

.stage .btn-green:hover::before {
    display: none;
    animation: none;
}

.stage .btn-ghost {
    background: transparent;
    color: var(--ink-2);
    border: 1px solid var(--line);
}

.stage .btn-ghost:hover {
    background: var(--hover);
    color: var(--ink);
    border-color: var(--ink-4);
}

.stage .btn-red {
    background: transparent;
    color: var(--danger-ink);
    border: 1px solid var(--danger-line);
}

.stage .btn-red:hover {
    background: var(--danger-soft);
    color: var(--danger-hi);
}

/* A quiet inline action inside a table row: text-sized, no chrome until hover. */
.stage .act {
    font-family: var(--font-display);
    font-stretch: 88%;
    font-weight: 600;
    font-size: .76rem;
    letter-spacing: .02em;
    color: var(--ink-3);
    background: none;
    border: none;
    padding: 2px 5px;
    border-radius: 4px;
    cursor: pointer;
}

.stage .act:hover {
    color: var(--ink);
    background: var(--hover-2);
}

.stage .act-go:hover {
    color: var(--spot);
}

.stage .act-bad:hover {
    color: var(--danger);
}

/* ══ Forms ═══════════════════════════════════════════════════════════════ */
.stage .form-input,
.stage .form-select,
.stage .form-textarea {
    background: var(--ground);
    border: 1px solid var(--line);
    color: var(--ink);
    border-radius: var(--r-sm);
    font-family: var(--font-text);
    font-size: .875rem;
    padding: 7px 11px;
}

.stage .form-input::placeholder {
    color: var(--ink-4);
}

.stage .form-input:focus,
.stage .form-select:focus,
.stage .form-textarea:focus {
    border-color: var(--spot);
    box-shadow: 0 0 0 2px var(--spot-soft);
}

/* The dropdown caret, drawn from two gradients rather than a data-URI SVG.
   A CSS variable cannot reach inside a data URI, and a <select> cannot carry a
   pseudo-element, so this is the way to make the arrow follow the theme. */
.stage .form-select {
    background-image:
        linear-gradient(45deg, transparent 50%, var(--ink-4) 50%),
        linear-gradient(135deg, var(--ink-4) 50%, transparent 50%);
    background-position: calc(100% - 16px) calc(50% - 1px), calc(100% - 11px) calc(50% - 1px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

.stage .form-label {
    font-family: var(--font-display);
    font-stretch: 86%;
    font-weight: 600;
    font-size: .7rem;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--ink-3);
}

/* Tabs: a filter set reads as one control, not five buttons. */
.stage .tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--r);
    padding: 3px;
}

.stage .tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 11px;
    border-radius: var(--r-sm);
    font-family: var(--font-display);
    font-stretch: 88%;
    font-weight: 600;
    font-size: .8rem;
    letter-spacing: .02em;
    color: var(--ink-3);
    text-decoration: none;
    transition: background .15s, color .15s;
}

.stage .tab:hover {
    color: var(--ink);
    background: var(--hover);
}

.stage .tab.on {
    background: var(--spot-soft);
    color: var(--ink);
    box-shadow: inset 0 0 0 1px var(--spot-line);
}

.stage .tab .n {
    font-family: var(--font-num);
    font-size: .72rem;
    color: var(--ink-4);
}

.stage .tab.on .n {
    color: var(--spot);
}

.stage .empty-state {
    color: var(--ink-3);
    font-family: var(--font-text);
    padding: 40px 16px;
}

/* ══ Tables ══════════════════════════════════════════════════════════════ */
/* Padding is tighter than the old table on purpose. A wide queue that overflows
   its box hides its right-hand columns under the pinned Actions column, which
   reads as broken rather than as scrolled, so buying back horizontal room is
   worth more here than air. */
.stage .data-table thead th {
    font-family: var(--font-display);
    font-stretch: 84%;
    font-weight: 600;
    font-size: .68rem;
    letter-spacing: .09em;
    color: var(--ink-3);
    background: var(--surface-2);
    padding: 9px 10px;
    white-space: nowrap;
}

.stage .data-table tbody td {
    border-top: 1px solid var(--line-soft);
    color: var(--ink-2);
    font-size: .84rem;
    padding: 8px 10px;
}

.stage .data-table tbody tr:hover {
    background: var(--hover-faint);
}

.stage .data-table th.sticky-col {
    background: var(--surface-2);
}

.stage .data-table td.sticky-col {
    background: var(--surface);
}

.stage .data-table tbody tr:hover td.sticky-col {
    background: var(--surface-hover);
}

.stage .data-table td.n,
.stage .data-table th.n {
    text-align: right;
    font-family: var(--font-num);
    font-variant-numeric: tabular-nums;
    font-size: .8rem;
}

.stage .data-table th.n {
    font-family: var(--font-display);
}

/* ══ The shared responsive table ══════════════════════════════════════════
   Agreed answer to "dense tables on mobile": one component, each page declaring
   its primary columns by putting `pri` on the <th>. Below the breakpoint a row
   becomes a card carrying those columns; the rest sit behind a per-row
   expander. stage.js mirrors `pri` and the column label down onto each <td>.

   With JS off every cell simply shows, labelled — longer, still correct. That
   is the same progressive-enhancement contract the HTMX panels keep. */
@media (max-width: 820px) {

    .stage .rtable,
    .stage .rtable tbody,
    .stage .rtable tr,
    .stage .rtable td {
        display: block;
        width: auto;
    }

    .stage .rtable thead {
        display: none;
    }

    /* A column stack rather than plain blocks, so the row's title can be
       ordered to the top whatever position it holds in the table. Reviewers
       scan a queue by name; making them read past a Status cell to find it
       would be letting the desktop column order dictate the phone. */
    .stage .rtable tr {
        display: flex;
        flex-direction: column;
        position: relative;
        background: var(--surface);
        border: 1px solid var(--line-soft);
        border-radius: var(--r);
        margin-bottom: 10px;
        padding: 10px 12px 8px;
    }

    .stage .rtable td.rt-lead {
        order: -1;
    }

    .stage .rtable td.rt-acts {
        order: 99;
    }

    .stage .rtable tr:hover {
        background: var(--surface);
    }

    .stage .rtable td {
        border-top: none;
        padding: 2px 0;
        text-align: left !important;
    }

    /* A labelled line: the column name sits in front of the value, so a cell
       out of its column still says what it is. */
    .stage .rtable td::before {
        content: attr(data-label);
        display: inline-block;
        min-width: 8.5em;
        font-family: var(--font-display);
        font-stretch: 84%;
        font-weight: 600;
        font-size: .66rem;
        letter-spacing: .1em;
        text-transform: uppercase;
        color: var(--ink-4);
    }

    /* The lead cell is the row's title: no label, and it gets the ink. */
    .stage .rtable td.rt-lead {
        font-family: var(--font-display);
        font-stretch: 84%;
        font-weight: 600;
        font-size: 1.02rem;
        color: var(--ink);
        padding-bottom: 4px;
    }

    .stage .rtable td.rt-lead::before {
        display: none;
    }

    /* Secondary columns collapse until asked for. */
    .stage .rtable tr:not(.open) td.rt-sec {
        display: none;
    }

    /* A pinned Actions column has nothing to pin against once the row is a
       card, and `position: sticky` on a block would drag it out of the flow. */
    .stage .rtable td.sticky-col {
        position: static;
        box-shadow: none;
        background: transparent;
    }

    .stage .rtable td.rt-acts {
        margin-top: 8px;
        padding-top: 8px;
        border-top: 1px solid var(--line-soft);
    }

    .stage .rtable td.rt-acts::before {
        display: none;
    }

    .stage .rtable .rt-more {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        margin-top: 6px;
        font-family: var(--font-display);
        font-stretch: 88%;
        font-weight: 600;
        font-size: .72rem;
        letter-spacing: .06em;
        text-transform: uppercase;
        color: var(--ink-3);
        background: none;
        border: none;
        padding: 3px 0;
        cursor: pointer;
    }

    .stage .rtable .rt-more:hover {
        color: var(--ink);
    }

    .stage .rtable tr.open .rt-more .ico {
        transform: rotate(180deg);
    }

    /* A row that is waiting on someone keeps its footlight as a card, too. */
    .stage .rtable tr.live::after {
        left: 10px;
        right: 10px;
        border-radius: 0 0 var(--r) var(--r);
    }

    .stage .main {
        padding: 16px 14px 40px;
    }

    .stage .main h1 {
        font-size: 1.45rem;
        gap: 9px;
    }

    .stage .fig-xl {
        font-size: 2.1rem;
    }

    .stage .page-sub {
        font-size: .84rem;
    }
}

/* A fold-on-mobile block (see stage.js). The summary is the only thing that
   shows on a phone until it is opened, and never shows on a wide screen. */
.stage details[data-fold-mobile]>summary {
    display: none;
}

@media (max-width: 820px) {
    .stage details[data-fold-mobile]>summary {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        cursor: pointer;
        list-style: none;
        font-family: var(--font-display);
        font-stretch: 88%;
        font-weight: 600;
        font-size: .72rem;
        letter-spacing: .07em;
        text-transform: uppercase;
        color: var(--ink-3);
        padding: 4px 0;
    }

    .stage details[data-fold-mobile]>summary::-webkit-details-marker {
        display: none;
    }

    .stage details[data-fold-mobile][open]>summary .ico {
        transform: rotate(180deg);
    }
}

/* Desktop: the expander and the mobile-only affordances stay out of the way. */
@media (min-width: 821px) {
    .stage .rtable .rt-more {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .stage * {
        transition: none !important;
    }
}

/* ── The last chrome colours that lived only in base.html ──────────────────
   Everything else there is now a duplicate of a rule above, so base.html keeps
   structure and this file owns colour. Four odds and ends:

   `.stat-num` is the gradient-filled figure a few pages use; it takes the two
   brand tokens so it themes with them. The placeholder / "(optional)" hint /
   nav chevron all had their own greys and now share --ink-4 with every other
   muted mark, which also fixes an inconsistency: the input and textarea
   placeholders were different colours. */
.stage ::-webkit-scrollbar-thumb:hover {
    background: var(--ink-4);
}

.stage .stat-num {
    background: linear-gradient(135deg, var(--spot), var(--foot));
    -webkit-text-fill-color: transparent;
    background-clip: text;
    -webkit-background-clip: text;
}

.stage .form-label .opt,
.stage .form-textarea::placeholder,
.stage .form-select::placeholder,
.stage .nav-section .chev {
    color: var(--ink-4);
}

/* The scrim behind the mobile drawer and the pinned-column shadow are shadows
   rather than chrome, so they read correctly on a light theme unchanged and
   stay in base.html. The `<select>` arrow is a data-URI SVG, whose colour a
   variable cannot reach; it is a known light-theme leftover. */

/* ══ Asset picker (D17) ═══════════════════════════════════════════════════
   The "From library" dialog, shared by the custom-command editor, the giveaway
   banner form and /sendmessage. Component classes rather than utilities because
   the markup is built in JS, and a Tailwind class assembled at runtime is exactly
   the thing the committed build cannot see. */
.stage .asset-picker {
    width: min(720px, calc(100vw - 32px));
    max-height: min(80vh, 720px);
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 18px;
    overflow: auto;
}

.stage .asset-picker::backdrop {
    background: rgba(0, 0, 0, .55);
}

.stage .asset-picker-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.stage .asset-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.stage .asset-pick-tile {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 0 0 7px;
    background: var(--surface-2);
    border: 1px solid var(--line-soft);
    border-radius: var(--r);
    cursor: pointer;
    overflow: hidden;
    text-align: left;
}

.stage .asset-pick-tile:hover {
    border-color: var(--spot-line);
    background: var(--surface-hover);
}

.stage .asset-pick-tile .ap-thumb {
    display: block;
    aspect-ratio: 4 / 3;
    background: var(--ground-2);
    border-bottom: 1px solid var(--line-soft);
}

.stage .asset-pick-tile .ap-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Tailwind's preflight sets img{max-width:100%}, which would clamp the width and
       leave the height alone -- the same trap the roster headshots documented. */
    max-width: none;
}

.stage .asset-pick-tile .ap-thumb-none {
    display: grid;
    place-items: center;
    font-family: var(--font-display);
    font-size: .66rem;
    letter-spacing: .09em;
    color: var(--ink-4);
}

.stage .asset-pick-tile .ap-name {
    font-size: .76rem;
    line-height: 1.3;
    color: var(--ink);
    padding: 0 8px;
    overflow-wrap: anywhere;
}

.stage .asset-pick-tile .ap-folder {
    font-size: .66rem;
    color: var(--ink-4);
    padding: 0 8px;
}

/* ══ The member house ════════════════════════════════════════════════════
   Rule 3 made real: the first pages that belong to the members (a vote run in
   rounds, utils/vote_rounds.py) wear the member gel where staff pages wear the
   spot. Redefining the spot tokens inside the wrapper recolours the shared
   pieces (header tile, title, buttons) with no second copy of their CSS. */
.stage .house-member { --spot: #D66EC2; --spot-hi: #E58AD3; --spot-ink: #E58AD3; --spot-soft: rgba(197, 88, 176, .14);
    --spot-line: rgba(197, 88, 176, .42); --btn-ink: #1A0716; --lit-wash: rgba(197, 88, 176, .10); }
:root[data-theme="light"] .stage .house-member { --spot: #A0348A; --spot-hi: #8A2C77; --spot-ink: #A0348A;
    --spot-soft: rgba(160, 52, 138, .08); --spot-line: rgba(160, 52, 138, .32); --btn-ink: #FFFFFF; --lit-wash: rgba(160, 52, 138, .06); }
.stage .house-member .page-head h1 { color: var(--spot-ink); }
