:root {
    --bs-shadow: rgba(0, 0, 0, 0.1);
    
    /* Additional font sizes that complement Bootstrap's system */
    --font-size-xs: 0.75rem;      /* 12px - micro text, badges */
    --font-size-2xs: 0.6875rem;   /* 11px - very small text */
    
    /* Font weights for hierarchy (inherit Bootstrap's pattern) */
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    
    /* Bootstrap 5.3 z-index scale */
    --zindex-dropdown: 1000;
    --zindex-sticky: 1020;
    --zindex-fixed: 1030;
    --zindex-offcanvas-backdrop: 1040;
    --zindex-offcanvas: 1045;
    --zindex-modal-backdrop: 1050;
    --zindex-modal: 1055;
    --zindex-popover: 1070;
    --zindex-tooltip: 1080;
    --zindex-toast: 1090;
}

/* =========================================================================
   Token foundation (light + dark). Adomnio Studio, direction C "On Air"
   (2026-09-29): a cool slate neutral set (hue 229-236) that sits next to the
   brand's Night panel, the Cathode accent (hue 252) and the five semantic
   tones unchanged. --app-* tokens are mapped onto Bootstrap's --bs-*
   variables, so stock Bootstrap components inherit the theme for free. Every
   component stylesheet uses these tokens only: no hex, no rgba() (§1.10).
   Contrast of every pair: DESIGN.md "Measured contrast".
   ========================================================================= */
:root {
    /* Type: Inter is the body face and every campaign view's; Barlow Semi Condensed is the display face of the
       loud pages only (the wordmark, the start and login titles, the Night panel's line); Barlow sets the figures
       of the six-digit code and the loop's timecodes. All self-hosted, 400 and 600 only (Two Weights Rule). */
    --app-font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --app-font-display: "Barlow Semi Condensed", "Arial Narrow", "Inter", system-ui, sans-serif;
    --app-font-number: "Barlow", "Inter", system-ui, sans-serif;
    /* Surfaces: Paper, Card, Mist, Fog */
    --app-bg: #F5F7F8;              /* oklch(0.975 0.003 229) */
    --app-surface: #FFFFFF;
    --app-surface-2: #EEF2F4;       /* oklch(0.959 0.005 229) */
    --app-surface-3: #E3E9EC;       /* oklch(0.930 0.008 229) */
    /* Borders: Hairline, Rule Line */
    --app-border: #DAE2E6;          /* oklch(0.908 0.010 229) */
    --app-border-strong: #C3CED4;   /* oklch(0.845 0.015 231) */
    /* Form fields (mockup --input-bg/--input-border): surface-2 fill with a
       strong border so fields read as wells on white cards. */
    --app-input-bg: var(--app-surface-2);
    --app-input-border: var(--app-border-strong);
    /* Text: Ink, Slate, Pewter. WCAG 2.2 AA: every text token reads 4.5:1 or more on bg, surface, surface-2 and
       surface-3 (Pewter 4.9:1 on Fog: the old 4.4 exception is gone). */
    --app-text: #13222B;            /* oklch(0.243 0.027 236) */
    --app-text-muted: #4D5E68;      /* oklch(0.471 0.026 234) */
    --app-text-subtle: #56666F;     /* oklch(0.500 0.024 233) */
    /* Accent "Cathode": links, the focus ring, the primary button, the active tab, and Sent. One hue, 252. */
    --app-accent: #0B5EA6;          /* oklch(0.478 0.136 252) */
    --app-accent-strong: #094D89;   /* oklch(0.416 0.117 252) */
    --app-accent-soft: #E2EEF9;     /* oklch(0.943 0.020 246) */
    /* A large area in the accent (an assigned matching cell, Step 4 / F-8): accent-soft in light, where it is already
       quiet; a low-chroma blue in dark, where a grid of accent-soft cells out-shouted everything else on the page. */
    --app-accent-tint: var(--app-accent-soft);
    --app-accent-fg: #fff;
    /* A solid accent fill behind accent-fg (the primary button, the play button):
       the accent itself in light, a darker blue in dark, where the accent is too light for white text. */
    --app-accent-fill: var(--app-accent);
    /* The primary button's hover and pressed fill: accent-strong in light (darker than the fill); in dark see below. */
    --app-accent-fill-hover: var(--app-accent-strong);
    /* Semantic: unchanged by the identity (values and meanings). */
    --app-positive: oklch(0.52 0.14 155);
    --app-positive-soft: oklch(0.955 0.045 155);
    --app-negative: oklch(0.54 0.2 25);
    --app-negative-soft: oklch(0.96 0.04 25);
    --app-warning: oklch(0.7 0.14 68);
    --app-warning-soft: oklch(0.96 0.05 75);
    /* Warning as text or as an icon on a surface: the amber fill is 2.7:1 there, this reads 4.6:1 and up.
       Text on warning-soft stays --app-text. */
    --app-warning-strong: oklch(0.52 0.12 68);
    /* Text on a -soft chip (a status pill, an assigned cell). In light mode the semantic colour
       itself; dark mode needs its own, because the -soft tints there are strong (see below). */
    --app-accent-soft-fg: var(--app-accent-strong);
    --app-positive-soft-fg: var(--app-positive);
    --app-negative-soft-fg: var(--app-negative);
    /* Brand: loud surfaces only (the start page, the login, 404, privacy, the empty campaign list, the boot state).
       Never inside a campaign, never a state. The panel is Night in both themes. Signal Cyan is the one lit slot of
       the loop and nothing else: 1.8:1 on white, so it never meets a light surface (The One Lit Slot Rule). */
    --app-brand-panel: #0B1A24;           /* Night  oklch(0.210 0.029 239) */
    --app-brand-panel-edge: #0B1A24;      /* no edge in light */
    --app-brand-panel-safe: #1C3140;      /* the screen's safe-area line */
    --app-brand-on-panel: #E8F0F3;        /* 15.3:1 on Night */
    --app-brand-on-panel-muted: #93A9B4;  /* 7.2:1 on Night */
    --app-brand-unlit: #566975;           /* the unlit slots, 3.1:1 on Night */
    --app-brand-signal: #46D2E8;          /* Signal Cyan, 9.8:1 on Night */
    /* Radii */
    --app-radius-control: 10px;
    --app-radius-card: 16px;
    --app-radius-pill: 999px;
    /* Small inner shapes (Round 2): the focus ring around inline text (a group toggle, a "why" summary), a menu item inside a
       10 px menu, a tag on a thumbnail. */
    --app-radius-inline: 4px;
    /* Shadows */
    --app-shadow: 0 1px 2px rgba(11, 26, 36, .05), 0 1px 3px rgba(11, 26, 36, .05);
    --app-shadow-lg: 0 18px 44px -14px rgba(11, 26, 36, .22);
    /* The veil behind a dialog of ours (the library's confirm and preview) */
    --app-modal-backdrop: oklch(0.21 0.029 239 / 0.45);
    /* Spacing rhythm */
    --app-pad: 20px;
    --app-gap: 20px;
    /* The measure of a note (R5): 65-75 characters a line. In em, not ch: `ch` is the width of Inter's "0", wider than
       its average letter, so 68ch held about 86 (critique §13). Resolves at the note's own font size (34em = 442 px at
       0.8125rem, measured 68-74 characters a line). */
    --app-measure: 34em;

    /* ---- Map onto Bootstrap so the whole app inherits the look ---- */
    --bs-body-bg: var(--app-bg);
    --bs-body-color: var(--app-text);
    --bs-emphasis-color: var(--app-text);
    --bs-secondary-color: var(--app-text-muted);
    --bs-secondary-bg: var(--app-surface-2);
    --bs-tertiary-bg: var(--app-surface-2);
    --bs-border-color: var(--app-border);
    --bs-card-bg: var(--app-surface);
    --bs-card-border-color: var(--app-border);
    --bs-card-cap-bg: var(--app-surface);
    --bs-primary: var(--app-accent);
    --bs-link-color: var(--app-accent-strong);
    --bs-link-hover-color: var(--app-accent-strong);
    --bs-primary-text-emphasis: var(--app-accent-soft-fg);
    --bs-primary-bg-subtle: var(--app-accent-soft);
    --bs-box-shadow: var(--app-shadow-lg);
    --bs-box-shadow-sm: var(--app-shadow);
    /* Softer, larger radii to match the mockup */
    --bs-border-radius: 0.625rem;      /* 10px — controls */
    --bs-border-radius-sm: 0.5rem;     /* 8px */
    --bs-border-radius-lg: 0.875rem;   /* 14px */
    --bs-border-radius-xl: 1rem;       /* 16px */
    --bs-card-border-radius: var(--app-radius-card);
}

[data-bs-theme="dark"] {
    /* Direction C dark: a slate page (hue 240) under lighter cards; fields are darker wells; the -soft tints are
       strong so status pills stay readable on dark surfaces. */
    --app-bg: #091117;              /* oklch(0.173 0.018 241) */
    --app-surface: #111C24;         /* oklch(0.220 0.022 241) */
    --app-surface-2: #172530;       /* oklch(0.257 0.028 243) */
    --app-surface-3: #1F303C;       /* oklch(0.300 0.031 240) */
    --app-border: #253846;          /* oklch(0.331 0.035 241) */
    --app-border-strong: #3A5060;   /* oklch(0.420 0.038 240) */
    /* Inputs get their own darker-than-card fill + strong border: fields that reuse surface colours disappear
       on dark cards. */
    --app-input-bg: #0C161D;        /* oklch(0.194 0.020 240) */
    --app-input-border: #3A5060;
    --app-text: #E8F0F3;            /* oklch(0.950 0.009 222) */
    --app-text-muted: #9CAFB9;      /* oklch(0.743 0.026 231) */
    --app-text-subtle: #8A9EA9;     /* oklch(0.687 0.028 232): 4.9:1 on Fog */
    --app-accent: #6DB9F0;          /* oklch(0.758 0.110 242): the focus ring, borders, the Sent edge */
    --app-accent-strong: #8FCBF5;   /* oklch(0.816 0.086 240): link text */
    --app-accent-soft: #17507F;     /* oklch(0.420 0.097 248): Strong Soft Rule, the Sent bar */
    /* Darker and quieter than accent-soft: accent-soft-fg reads 10.8:1 on it, the accent border 6.3:1, and the
       cell's Sent / Confirmed chips keep an edge against it. */
    --app-accent-tint: #153149;     /* oklch(0.304 0.055 247) */
    --app-positive: oklch(0.78 0.17 155);
    --app-positive-soft: oklch(0.42 0.11 155);
    --app-negative: oklch(0.72 0.2 25);
    --app-negative-soft: oklch(0.42 0.13 25);
    --app-warning: oklch(0.82 0.15 78);
    --app-warning-soft: oklch(0.46 0.11 75);
    --app-warning-strong: var(--app-warning);
    /* White reads 6.2:1 on this fill; the accent itself is too light for white text. */
    --app-accent-fill: #1263AB;     /* oklch(0.494 0.136 251) */
    /* accent-strong is lighter than the fill in dark (white would fail): the hover darkens instead (7.7:1). */
    --app-accent-fill-hover: #0E5494; /* oklch(0.442 0.123 252) */
    /* The semantic colours read 3.1-4.3:1 on their own -soft tints here; these read 6:1 and up. */
    --app-accent-soft-fg: #D4EAFB;  /* oklch(0.926 0.033 241) */
    --app-positive-soft-fg: oklch(0.9 0.12 155);
    --app-negative-soft-fg: oklch(0.88 0.07 25);
    /* Brand: the panel stays Night; in dark it gets an edge so it does not dissolve into the page (1.08:1). */
    --app-brand-panel-edge: #2A4254;  /* oklch(0.368 0.043 242) */
    --app-shadow: 0 1px 2px rgba(0, 0, 0, .5);
    --app-shadow-lg: 0 20px 48px -14px rgba(0, 0, 0, .7);
    --app-modal-backdrop: oklch(0.1 0.01 240 / 0.7);

    /* Re-map onto Bootstrap dark (this block wins — app.css loads after Bootstrap) */
    --bs-body-bg: var(--app-bg);
    --bs-body-color: var(--app-text);
    --bs-emphasis-color: var(--app-text);
    --bs-secondary-color: var(--app-text-muted);
    --bs-secondary-bg: var(--app-surface-2);
    --bs-tertiary-bg: var(--app-surface-2);
    --bs-border-color: var(--app-border);
    --bs-card-bg: var(--app-surface);
    --bs-card-border-color: var(--app-border);
    --bs-card-cap-bg: var(--app-surface);
    --bs-primary: var(--app-accent);
    --bs-link-color: var(--app-accent-strong);
    --bs-link-hover-color: var(--app-accent-strong);
    --bs-primary-text-emphasis: var(--app-accent-soft-fg);
    --bs-primary-bg-subtle: var(--app-accent-soft);
}

/* Bootstrap redeclares these variables on the component class itself (.card sets --bs-card-bg
   to the body background, .form-control paints with --bs-body-bg), so the mapping on :root above
   never reaches them: cards sat flat on the page and fields ignored the input tokens. */
.card {
    --bs-card-bg: var(--app-surface);
    --bs-card-border-color: var(--app-border);
    --bs-card-cap-bg: var(--app-surface);
}

.form-control,
.form-select {
    background-color: var(--app-input-bg);
    border-color: var(--app-input-border);
}

/* R5: a focused text field or select draws the 2 px accent outline every other control draws, in both themes, not
   Bootstrap's stock glow (#86b7fe edge + a 25 % #0d6efd shadow: 1.39:1 light, 1.30:1 dark, under 1.4.11's 3:1). On
   :focus, not :focus-visible - a field shows where the typing goes however it was reached. */
.form-control:focus,
.form-select:focus {
    background-color: var(--app-input-bg);
    border-color: var(--app-accent);
    box-shadow: none;
    outline: 2px solid var(--app-accent);
    outline-offset: 2px;
}

/* Bootstrap hard-codes its stock blue and grey on the button classes and on links (#0d6efd, #6c757d):
   4.2-4.4:1 on the light page, under 4.5:1 on the dark surfaces too (the log-out, refresh and cancel
   buttons, "Upload for this group", the footer's privacy link). Every button and link reads the tokens. */
.btn-primary {
    --bs-btn-color: var(--app-accent-fg);
    --bs-btn-bg: var(--app-accent-fill);
    --bs-btn-border-color: var(--app-accent-fill);
    --bs-btn-hover-color: var(--app-accent-fg);
    --bs-btn-hover-bg: var(--app-accent-fill-hover);
    --bs-btn-hover-border-color: var(--app-accent-fill-hover);
    --bs-btn-active-color: var(--app-accent-fg);
    --bs-btn-active-bg: var(--app-accent-fill-hover);
    --bs-btn-active-border-color: var(--app-accent-fill-hover);
    --bs-btn-disabled-color: var(--app-accent-fg);
    --bs-btn-disabled-bg: var(--app-accent-fill);
    --bs-btn-disabled-border-color: var(--app-accent-fill);
}

.btn-outline-secondary {
    --bs-btn-color: var(--app-text-muted);
    --bs-btn-border-color: var(--app-text-subtle);
    --bs-btn-hover-color: var(--app-text);
    --bs-btn-hover-bg: var(--app-surface-3);
    --bs-btn-hover-border-color: var(--app-text-subtle);
    --bs-btn-active-color: var(--app-text);
    --bs-btn-active-bg: var(--app-surface-3);
    --bs-btn-active-border-color: var(--app-text-subtle);
    --bs-btn-disabled-color: var(--app-text-subtle);
    --bs-btn-disabled-border-color: var(--app-border-strong);
}

[data-bs-theme="dark"] .btn-outline-secondary {
    --bs-btn-border-color: var(--app-border-strong);
    --bs-btn-hover-border-color: var(--app-border-strong);
    --bs-btn-active-border-color: var(--app-border-strong);
    --bs-btn-disabled-border-color: var(--app-border);
}

.btn-outline-primary {
    --bs-btn-color: var(--app-accent-strong);
    --bs-btn-border-color: var(--app-accent);
    --bs-btn-hover-color: var(--app-accent-soft-fg);
    --bs-btn-hover-bg: var(--app-accent-soft);
    --bs-btn-hover-border-color: var(--app-accent);
    --bs-btn-active-color: var(--app-accent-soft-fg);
    --bs-btn-active-bg: var(--app-accent-soft);
    --bs-btn-active-border-color: var(--app-accent);
    --bs-btn-disabled-color: var(--app-accent);
    --bs-btn-disabled-border-color: var(--app-accent);
}

.btn-outline-danger {
    --bs-btn-color: var(--app-negative);
    --bs-btn-border-color: var(--app-negative);
    --bs-btn-hover-color: var(--app-negative-soft-fg);
    --bs-btn-hover-bg: var(--app-negative-soft);
    --bs-btn-hover-border-color: var(--app-negative);
    --bs-btn-active-color: var(--app-negative-soft-fg);
    --bs-btn-active-bg: var(--app-negative-soft);
    --bs-btn-active-border-color: var(--app-negative);
    --bs-btn-disabled-color: var(--app-negative);
    --bs-btn-disabled-border-color: var(--app-negative);
}

.btn-link {
    --bs-btn-color: var(--app-accent-strong);
    --bs-btn-hover-color: var(--app-accent-strong);
    --bs-btn-active-color: var(--app-accent-strong);
    --bs-btn-disabled-color: var(--app-text-subtle);
}

/* One link style (DESIGN.md, The Link Rule): a link inside a sentence is underlined at rest; a standalone text
   action (btn-link) is not, and underlines on hover and keyboard focus; navigation styles itself and never
   underlines. The underline sits clear of descenders, in the link's own colour. */
a {
    color: var(--app-accent-strong);
    text-decoration-thickness: from-font;
    text-underline-offset: .2em;
}

a:hover {
    color: var(--app-accent-strong);
}

.btn-link {
    text-decoration: none;
    text-decoration-thickness: from-font;
    text-underline-offset: .2em;
}

.btn-link:hover:not(:disabled),
.btn-link:focus-visible {
    text-decoration: underline;
}

.btn-link.link-inline {
    padding: 0 .125rem;
    vertical-align: baseline;
    text-decoration: underline;
}

/* Checkboxes (Round 2): Bootstrap paints a checked box and its focus glow in its stock blue on the class (#0d6efd,
   in both themes). A checked box is the accent fill with its white tick (5.5:1 light, 5.1:1 dark, the primary button's
   pair); an empty one is framed in text-subtle (4.6:1 and up, a control's edge must read at 3:1); keyboard focus is the
   2 px accent outline every other control draws, not the glow. */
.form-check-input {
    background-color: var(--app-input-bg);
    border-color: var(--app-text-subtle);
}

.form-check-input:checked,
.form-check-input[type="checkbox"]:indeterminate {
    background-color: var(--app-accent-fill);
    border-color: var(--app-accent-fill);
}

.form-check-input:focus {
    border-color: var(--app-accent);
    box-shadow: none;
}

.form-check-input:checked:focus {
    border-color: var(--app-accent-fill);
}

.form-check-input:focus-visible {
    outline: 2px solid var(--app-accent);
    outline-offset: 2px;
}

/* Bootstrap's alerts carry their own pinks and yellows on the class. A failed load or a wrong login code is the
   negative tone, as every other error (Step 4): negative-soft-fg on negative-soft, 4.8:1 light and 6.1:1 dark. */
.alert-danger {
    --bs-alert-color: var(--app-negative-soft-fg);
    --bs-alert-bg: var(--app-negative-soft);
    --bs-alert-border-color: var(--app-negative-soft);
    --bs-alert-link-color: var(--app-negative-soft-fg);
}

/* Stale data still showing after a failed read (Step 5a): the Deadline Amber rule's fill with `text` on it, never
   amber text; the edge is the fill itself, as the danger alert's is. */
.alert-warning {
    --bs-alert-color: var(--app-text);
    --bs-alert-bg: var(--app-warning-soft);
    --bs-alert-border-color: var(--app-warning-soft);
    --bs-alert-link-color: var(--app-text);
}

.text-primary {
    color: var(--app-accent-strong) !important;
}

.text-danger {
    color: var(--app-negative) !important;
}

html {
    /* Match body's overflow-x: hidden — without this, Chromium / Safari still
       show a page-level horizontal scrollbar when an inner element overflows
       its parent, because the scrollbar can promote to the root scrolling
       element instead of being clipped by body. */
    overflow-x: hidden;
}

body {
    margin: 0;
    padding: 0;
    /* clip, NOT hidden: with html's overflow non-visible, body's overflow no
       longer propagates to the viewport, so `hidden` turns body itself into a
       scroll container that never scrolls — and every position:sticky element
       inside (topbar, grid paging footer, action bars) silently stops
       sticking. clip contains horizontal overflow without that side effect. */
    overflow-x: clip;
    color: var(--bs-body-color);
    background-color: var(--bs-body-bg);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Body text: Inter, self-hosted under lib/inter; the display and number faces under lib/barlow (the page is
   cross-origin isolated, so a third-party font would be blocked; and it would send every visitor's IP away). */
body {
    font-family: var(--app-font-body);
}

/* FocusOnNavigate moves focus to each page's h1 (tabindex=-1) so a screen reader starts at the title; the
   heading is not a control, so it draws no focus rectangle (critique L-2 - it looked like a rendering bug). */
h1[tabindex="-1"]:focus {
    outline: none;
}

/* Every button's keyboard focus is the design system's 2 px accent outline (DESIGN.md), not Bootstrap's faint 25 %
   glow that fades in over 150 ms (S5 critique: the uploader's summary actions and the paused rows' buttons). */
.btn:focus-visible,
a:focus-visible {
    outline: 2px solid var(--app-accent);
    outline-offset: 2px;
}

/* Round 5 (Can's decision; DESIGN.md "Touch targets"): every target on a phone is at least 44 px - Bootstrap's buttons
   (links styled as buttons too), disclosures and tabs here, the component-drawn ones in their own files. The one exception
   is a word inside a sentence (a glossary word, 2.5.8's inline exception) and the Schedule's bars, which have a 44 px row
   head and the keyboard path beside them. */
@media (max-width: 575.98px) {
    .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 2.75rem;
    }

    summary {
        min-height: 2.75rem;
        padding-block: .625rem;
    }

    [role="tab"],
    .form-control,
    .form-select {
        min-height: 2.75rem;
    }
}
