@layer reset, tokens, base, layout, components, calendar, utilities;

/* ───────── RESET ───────── */
@layer reset {
    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
    html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
    body, h1, h2, h3, h4, p, ul, ol, figure, blockquote, dl, dd { margin: 0; }
    ul, ol { list-style: none; }
    img, picture, video, canvas, svg { display: block; max-width: 100%; }
    button, input, select, textarea { font: inherit; color: inherit; }
    a { color: inherit; text-decoration: none; }
    table { border-collapse: collapse; }
}

/* ───────── DESIGN TOKENS ───────── */
@layer tokens {
    :root {
        color-scheme: light dark;
        --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
        --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", "Fira Code", monospace;

        --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
        --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
        --dur: 0.2s;
        --dur-lg: 0.4s;

        --radius-xs: 0.5rem;
        --radius-sm: 0.75rem;
        --radius-md: 1rem;
        --radius-lg: 1.25rem;
        --radius-xl: 1.5rem;
        --radius-full: 999px;

        --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.05);
        --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.06), 0 1px 2px rgb(0 0 0 / 0.04);
        --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
        --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
        --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.04);
        --shadow-glow: 0 0 24px color-mix(in srgb, var(--accent) 25%, transparent);
    }

    :root {
        --bg: #f8fafc;
        --bg-subtle: #f1f5f9;
        --surface: #ffffff;
        --surface-raised: #ffffff;
        --surface-overlay: rgb(255 255 255 / 0.82);
        --ink: #0f172a;
        --ink-secondary: #334155;
        --muted: #64748b;
        --faint: #94a3b8;
        --line: #e2e8f0;
        --line-strong: #cbd5e1;

        --accent: #B81F1A;
        --accent-light: #C62822;
        --accent-lighter: #FCE8E7;
        --accent-surface: #FDF2F2;
        --accent-ink: #491210;
        /* Lighter pair for gradients (oklch mixes on deep red look muddy / inconsistent) */
        --accent-2: #E24A43;

        --good: #10b981;
        --good-surface: #ecfdf5;
        --good-ink: #065f46;
        --warn: #f59e0b;
        --warn-surface: #fffbeb;
        --warn-ink: #92400e;
        --danger: #ef4444;
        --danger-surface: #fef2f2;
        --danger-ink: #991b1b;

        /*
         * App shell surfaces — use these for page canvas, hero bands, and cards.
         * Components reference these; tweak once to shift the whole UI.
         */
        --app-canvas-bg:
            radial-gradient(ellipse 92% 48% at 50% -18%, color-mix(in srgb, var(--accent) 11%, transparent), transparent),
            radial-gradient(ellipse 48% 34% at 100% 0%, color-mix(in srgb, var(--accent-2) 8%, transparent), transparent),
            radial-gradient(ellipse 42% 30% at 0% 94%, color-mix(in srgb, var(--accent) 6%, transparent), transparent),
            var(--bg);
        --surface-hero-bg:
            radial-gradient(ellipse 120% 90% at 100% -30%, color-mix(in srgb, var(--accent) 14%, transparent), transparent),
            radial-gradient(ellipse 70% 60% at 0% 110%, color-mix(in srgb, var(--accent-2) 11%, transparent), transparent),
            var(--surface);
        --surface-elevated-bg:
            linear-gradient(168deg, color-mix(in srgb, var(--accent) 7%, var(--surface)) 0%, var(--surface) 44%, var(--surface) 100%);
        --border-surface: 1px solid color-mix(in srgb, var(--line) 88%, var(--accent) 5%);
    }

    html[data-theme="dark"] {
        --bg: #020617;
        --bg-subtle: #0f172a;
        --surface: #1e293b;
        --surface-raised: #334155;
        --surface-overlay: rgb(30 41 59 / 0.88);
        --ink: #f1f5f9;
        --ink-secondary: #cbd5e1;
        --muted: #94a3b8;
        --faint: #64748b;
        --line: #334155;
        --line-strong: #475569;

        --accent: #F87171;
        --accent-light: #FCA5A5;
        --accent-lighter: #451a1a;
        --accent-surface: #3f1816;
        --accent-ink: #FEE2E2;
        /* Dark UI: gradient runs brand → brighter for highlights */
        --accent-2: #B81F1A;

        --good-surface: #064e3b;
        --good-ink: #6ee7b7;
        --warn-surface: #78350f;
        --warn-ink: #fcd34d;
        --danger-surface: #7f1d1d;
        --danger-ink: #fca5a5;

        --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.3);
        --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.3);
        --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3);
        --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3);
        --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.3);

        --app-canvas-bg:
            radial-gradient(ellipse 88% 44% at 50% -16%, color-mix(in srgb, var(--accent) 12%, transparent), transparent),
            radial-gradient(ellipse 44% 30% at 100% 0%, color-mix(in srgb, var(--accent-2) 10%, transparent), transparent),
            radial-gradient(ellipse 38% 26% at 0% 94%, color-mix(in srgb, var(--accent) 7%, transparent), transparent),
            var(--bg);
        --surface-hero-bg:
            radial-gradient(ellipse 120% 90% at 100% -30%, color-mix(in srgb, var(--accent) 16%, transparent), transparent),
            radial-gradient(ellipse 70% 60% at 0% 110%, color-mix(in srgb, var(--accent-2) 12%, transparent), transparent),
            var(--surface);
        --surface-elevated-bg:
            linear-gradient(168deg, color-mix(in srgb, var(--accent) 8%, var(--surface)) 0%, var(--surface) 50%, var(--surface) 100%);
        --border-surface: 1px solid color-mix(in srgb, var(--line) 75%, var(--accent) 9%);
    }

    @media (prefers-color-scheme: dark) {
        html[data-theme="system"] {
            --bg: #020617;
            --bg-subtle: #0f172a;
            --surface: #1e293b;
            --surface-raised: #334155;
            --surface-overlay: rgb(30 41 59 / 0.88);
            --ink: #f1f5f9;
            --ink-secondary: #cbd5e1;
            --muted: #94a3b8;
            --faint: #64748b;
            --line: #334155;
            --line-strong: #475569;

            --accent: #F87171;
            --accent-light: #FCA5A5;
            --accent-lighter: #451a1a;
            --accent-surface: #3f1816;
            --accent-ink: #FEE2E2;
            --accent-2: #B81F1A;

            --good-surface: #064e3b;
            --good-ink: #6ee7b7;
            --warn-surface: #78350f;
            --warn-ink: #fcd34d;
            --danger-surface: #7f1d1d;
            --danger-ink: #fca5a5;

            --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.3);
            --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.3);
            --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3);
            --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3);
            --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.3);

            --app-canvas-bg:
                radial-gradient(ellipse 88% 44% at 50% -16%, color-mix(in srgb, var(--accent) 12%, transparent), transparent),
                radial-gradient(ellipse 44% 30% at 100% 0%, color-mix(in srgb, var(--accent-2) 10%, transparent), transparent),
                radial-gradient(ellipse 38% 26% at 0% 94%, color-mix(in srgb, var(--accent) 7%, transparent), transparent),
                var(--bg);
            --surface-hero-bg:
                radial-gradient(ellipse 120% 90% at 100% -30%, color-mix(in srgb, var(--accent) 16%, transparent), transparent),
                radial-gradient(ellipse 70% 60% at 0% 110%, color-mix(in srgb, var(--accent-2) 12%, transparent), transparent),
                var(--surface);
            --surface-elevated-bg:
                linear-gradient(168deg, color-mix(in srgb, var(--accent) 8%, var(--surface)) 0%, var(--surface) 50%, var(--surface) 100%);
            --border-surface: 1px solid color-mix(in srgb, var(--line) 75%, var(--accent) 9%);
        }
    }

    html[data-theme="light"] { color-scheme: light; }
    html[data-theme="dark"] { color-scheme: dark; }
    html[data-theme="system"] { color-scheme: light dark; }
}

/* ───────── BASE ───────── */
@layer base {
    body {
        font-family: var(--font);
        background: var(--app-canvas-bg);
        color: var(--ink);
        line-height: 1.6;
        min-height: 100dvh;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        transition: background-color 0.25s var(--ease-out), color 0.25s var(--ease-out);
    }

    @media (prefers-reduced-motion: reduce) {
        *, *::before, *::after {
            animation-duration: 0.001ms !important;
            transition-duration: 0.001ms !important;
            scroll-behavior: auto !important;
        }
    }

    ::selection { background: var(--accent-lighter); color: var(--accent-ink); }
    :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-xs); }
    code { font-family: var(--mono); font-size: 0.88em; }
}

/* ───────── APP LAYOUT ───────── */
@layer layout {
    .skip-link {
        position: absolute; left: 1rem; top: -100px; padding: 0.65rem 1rem;
        border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line);
        z-index: 100; font-weight: 700; transition: top var(--dur) var(--ease-out);
    }
    .skip-link:focus { top: 1rem; }

    /* ── Topbar ── */
    .topbar {
        position: sticky; top: 0; z-index: 40;
        display: flex; align-items: center; gap: 0.5rem;
        height: 3.5rem;
        padding: 0 1rem;
        background: color-mix(in oklch, var(--surface-overlay) 94%, transparent);
        border-bottom: var(--border-surface);
        backdrop-filter: blur(20px) saturate(1.5);
        -webkit-backdrop-filter: blur(20px) saturate(1.5);
        box-shadow:
            0 1px 0 color-mix(in oklch, var(--line) 55%, transparent),
            0 18px 40px color-mix(in srgb, var(--accent) 5%, transparent);
    }

    .brand {
        display: inline-flex; align-items: center; gap: 0.5rem;
        font-weight: 800; letter-spacing: -0.02em; white-space: nowrap;
        margin-right: 0.75rem;
    }
    .brand-logo {
        display: block;
        height: 2rem;
        width: auto;
        max-width: min(11.5rem, 42vw);
        flex-shrink: 0;
        object-fit: contain;
        object-position: left center;
        transition: transform var(--dur) var(--ease-spring);
    }
    .brand:hover .brand-logo { transform: scale(1.03); }

    .nav {
        display: flex; flex: 1; gap: 0.125rem;
        overflow-x: auto; scrollbar-width: none;
    }
    .nav::-webkit-scrollbar { display: none; }

    .nav-link {
        display: inline-flex; align-items: center;
        height: 2.25rem; padding: 0 0.75rem;
        border-radius: var(--radius-full);
        font-size: 0.8125rem; font-weight: 600;
        color: var(--muted); white-space: nowrap;
        transition: all var(--dur) var(--ease-out);
    }
    .nav-link:hover { color: var(--ink); background: var(--bg-subtle); }
    .nav-link.is-active {
        color: var(--accent-ink); background: var(--accent-surface);
        font-weight: 700;
    }

    .nav-link.nav-link--icon {
        padding-inline: 0.5rem;
        min-width: 2.25rem;
        justify-content: center;
    }
    .nav-link.nav-link--icon svg {
        display: block;
        opacity: 0.92;
    }

    html[data-theme="dark"] .nav-link.is-active { color: var(--accent-light); }
    @media (prefers-color-scheme: dark) {
        html[data-theme="system"] .nav-link.is-active { color: var(--accent-light); }
    }

    .topbar-actions { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }

    /* ── Mobile menu button (hidden on desktop) ── */
    .topbar-menu-btn {
        display: none;
        align-items: center; justify-content: center;
        width: 2.25rem; height: 2.25rem;
        border: 0; border-radius: var(--radius-sm);
        background: transparent; color: var(--ink);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: background var(--dur) var(--ease-out);
    }
    .topbar-menu-btn:hover { background: var(--bg-subtle); }
    .topbar-menu-btn[aria-expanded="true"] {
        background: var(--accent-surface); color: var(--accent);
    }
    .topbar-menu-ico { font-size: 1.25rem; line-height: 1; }

    /* ── Theme switch — quiet pill, icon-only ── */
    .theme-switch {
        display: inline-flex;
        align-items: center;
        gap: 1px;
        padding: 3px;
        border-radius: 100px;
        flex-shrink: 0;
        background: color-mix(in oklch, var(--ink) 4.5%, var(--bg-subtle));
        border: 1px solid color-mix(in oklch, var(--line) 65%, transparent);
        box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06);
    }
    .theme-switch__btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        margin: 0;
        width: 2rem;
        height: 1.7rem;
        min-width: 2rem;
        border: 0;
        border-radius: 100px;
        padding: 0;
        background: transparent;
        color: var(--muted);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition:
            color 0.18s ease,
            background 0.18s ease,
            box-shadow 0.18s ease,
            transform 0.12s ease;
    }
    .theme-switch__btn:hover {
        color: var(--ink-secondary);
    }
    .theme-switch__btn:active {
        transform: scale(0.94);
    }
    .theme-switch__btn:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 1px;
    }
    .theme-switch__btn.is-active {
        color: var(--ink);
        background: var(--surface);
        box-shadow:
            0 1px 2px rgb(0 0 0 / 0.06),
            0 1px 3px rgb(0 0 0 / 0.04);
    }
    html[data-theme="dark"] .theme-switch__btn.is-active {
        box-shadow:
            0 1px 3px rgb(0 0 0 / 0.35),
            inset 0 1px 0 rgb(255 255 255 / 0.04);
    }
    .theme-switch__ico {
        display: grid;
        place-items: center;
        line-height: 0;
    }
    .theme-switch__svg {
        width: 14px;
        height: 14px;
        display: block;
        opacity: 0.65;
        transition: opacity 0.18s ease;
    }
    .theme-switch__btn:hover .theme-switch__svg { opacity: 0.85; }
    .theme-switch__btn.is-active .theme-switch__svg { opacity: 1; }

    /* ── Login / setup: icon-only theme (data-theme-pick + app.js like .theme-switch) ── */
    .auth-theme-icons {
        position: fixed;
        z-index: 200;
        top: max(0.75rem, env(safe-area-inset-top));
        right: max(0.75rem, env(safe-area-inset-right));
        display: flex;
        align-items: center;
        gap: 0.375rem;
    }
    .auth-theme-icons__btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 2.5rem;
        height: 2.5rem;
        margin: 0;
        padding: 0;
        border-radius: var(--radius-md);
        border: 1px solid var(--line);
        background: var(--surface-elevated-bg);
        color: var(--muted);
        cursor: pointer;
        box-shadow: var(--shadow-sm);
        -webkit-tap-highlight-color: transparent;
        transition:
            color 0.18s ease,
            background 0.18s ease,
            border-color 0.18s ease,
            box-shadow 0.18s ease,
            transform 0.12s ease;
    }
    .auth-theme-icons__btn:hover {
        color: var(--ink-secondary);
        border-color: var(--line-strong);
        background: var(--bg-subtle);
    }
    .auth-theme-icons__btn:active {
        transform: scale(0.94);
    }
    .auth-theme-icons__btn:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }
    .auth-theme-icons__btn.is-active {
        color: var(--accent);
        background: var(--accent-surface);
        border-color: color-mix(in oklch, var(--accent) 45%, var(--line));
        box-shadow: var(--shadow-xs);
    }
    .auth-theme-icons__btn svg {
        width: 1.125rem;
        height: 1.125rem;
        display: block;
        opacity: 0.85;
    }
    .auth-theme-icons__btn.is-active svg {
        opacity: 1;
    }

    /* ── User menu (username ▾: theme + account) ── */
    .user-menu {
        position: relative;
        flex-shrink: 0;
        min-width: 0;
    }
    .user-menu__trigger {
        display: inline-flex;
        align-items: center;
        gap: 0.25rem;
        max-width: 10rem;
        height: 2rem;
        padding: 0 0.5rem 0 0.65rem;
        font-size: 0.8125rem;
        font-weight: 600;
        color: var(--ink-secondary);
        border-radius: var(--radius-full);
    }
    .user-menu__name {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .user-menu__chev {
        font-size: 0.65rem;
        opacity: 0.65;
        flex-shrink: 0;
    }
    .user-menu__panel {
        position: fixed;
        margin: 0;
        z-index: 200;
        min-width: 13.5rem;
        padding: 0.625rem 0.625rem 0.5rem;
        border-radius: var(--radius-md);
        border: var(--border-surface);
        background: var(--surface-elevated-bg);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        box-shadow: var(--shadow-lg);
    }
    .user-menu__label,
    .user-menu__hint {
        margin: 0 0 0.375rem;
        padding: 0 0.25rem;
        font-size: 0.625rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--muted);
    }
    .user-menu__theme {
        margin-bottom: 0.5rem;
        padding-bottom: 0.5rem;
        border-bottom: 1px solid var(--line);
    }
    .user-menu__theme .theme-switch {
        width: 100%;
        justify-content: center;
    }
    .user-menu__theme .theme-switch__btn {
        flex: 1;
        min-width: 0;
    }
    .user-menu__item {
        display: block;
        width: 100%;
        padding: 0.5rem 0.5rem;
        margin: 0 -0.125rem;
        border-radius: var(--radius-sm);
        font-size: 0.875rem;
        font-weight: 600;
        color: var(--ink-secondary);
        text-align: left;
    }
    .user-menu__item:hover {
        background: var(--bg-subtle);
        color: var(--ink);
    }
    .topbar-logout { display: inline-flex; align-items: center; }

    /* ── Mobile accordion menu panel (opened via JS; fixed so it sits above content & dock) ── */
    .mobile-menu {
        display: none;
        position: fixed;
        top: 3rem;
        left: 0;
        right: 0;
        z-index: 100;
        max-height: min(70vh, calc(100dvh - 3rem - 4.5rem));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        background: color-mix(in oklch, var(--surface) 92%, transparent);
        backdrop-filter: blur(16px) saturate(1.2);
        -webkit-backdrop-filter: blur(16px) saturate(1.2);
        border-bottom: var(--border-surface);
        box-shadow: 0 18px 48px rgb(0 0 0 / 0.14);
    }
    .mobile-menu[hidden] { display: none !important; }
    .mobile-menu.is-open {
        display: block !important;
    }
    .mobile-menu-backdrop {
        display: none;
        position: fixed;
        inset: 3rem 0 0 0;
        z-index: 99;
        background: rgb(0 0 0 / 0.35);
        -webkit-tap-highlight-color: transparent;
    }
    .mobile-menu-backdrop.is-visible {
        display: block;
    }
    .mobile-menu__nav {
        display: flex; flex-direction: column;
        padding: 0.5rem;
        gap: 0.125rem;
    }
    .mobile-menu__link {
        display: flex; align-items: center;
        padding: 0.75rem 1rem;
        border-radius: var(--radius-sm);
        font-size: 0.9375rem; font-weight: 600;
        color: var(--ink-secondary);
        transition: background var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
        -webkit-tap-highlight-color: transparent;
    }
    .mobile-menu__link:hover,
    .mobile-menu__link:active { background: var(--bg-subtle); color: var(--ink); }
    .mobile-menu__link.is-active {
        background: var(--accent-surface); color: var(--accent);
        font-weight: 700;
    }

    @media (min-width: 769px) {
        .mobile-menu { display: none !important; }
        .mobile-menu-backdrop { display: none !important; pointer-events: none !important; }
        .topbar-menu-btn { display: none !important; }
    }

    .user-chip {
        display: none; max-width: 8rem;
        padding: 0.25rem 0.625rem; border-radius: var(--radius-full);
        font-size: 0.75rem; font-weight: 700; color: var(--muted);
        background: var(--bg-subtle);
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    @media (min-width: 768px) { .user-chip { display: inline-flex; } }

    /* ── Main shell ── */
    .shell {
        width: min(1200px, 100% - 2rem);
        margin: 1.5rem auto 6rem;
        min-width: 0;
    }

    /* ── Flash ── */
    .flash-stack { display: grid; gap: 0.5rem; margin-bottom: 1.25rem; }
    .alert {
        display: flex; align-items: center; gap: 0.5rem;
        padding: 0.75rem 1rem; border-radius: var(--radius-md);
        font-size: 0.875rem; font-weight: 600;
        border: var(--border-surface);
        box-shadow: var(--shadow-xs);
        animation: slideDown var(--dur-lg) var(--ease-out);
    }
    .alert[hidden] { display: none; }
    .alert.success {
        background: color-mix(in oklch, var(--good-surface) 90%, var(--surface));
        color: var(--good-ink);
        border-color: color-mix(in oklch, var(--good) 28%, var(--line));
    }
    .alert.danger {
        background: color-mix(in oklch, var(--danger-surface) 90%, var(--surface));
        color: var(--danger-ink);
        border-color: color-mix(in oklch, var(--danger) 28%, var(--line));
    }

    @keyframes slideDown {
        from { opacity: 0; transform: translateY(-0.75rem); }
        to { opacity: 1; transform: translateY(0); }
    }

    /* ── Mobile dock: floating glass tab bar ── */
    .dock {
        position: fixed;
        z-index: 50;
        left: max(0.65rem, env(safe-area-inset-left, 0px));
        right: max(0.65rem, env(safe-area-inset-right, 0px));
        bottom: max(0.5rem, env(safe-area-inset-bottom, 0px));
        display: grid;
        grid-template-columns: repeat(var(--dock-cols, 4), minmax(0, 1fr));
        gap: 0.125rem;
        padding: 0.35rem;
        max-width: 28rem;
        margin-inline: auto;
        border-radius: 1.15rem;
        min-width: 0;
        box-sizing: border-box;
        background: color-mix(in oklch, var(--surface) 78%, transparent);
        backdrop-filter: blur(28px) saturate(1.35);
        -webkit-backdrop-filter: blur(28px) saturate(1.35);
        border: 1px solid color-mix(in oklch, var(--line) 50%, transparent);
        box-shadow:
            inset 0 1px 0 rgb(255 255 255 / 0.05),
            0 4px 24px rgb(0 0 0 / 0.08),
            0 14px 40px rgb(0 0 0 / 0.06);
        -webkit-tap-highlight-color: transparent;
    }
    .dock a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.2rem;
        min-width: 0;
        min-height: 2.75rem;
        padding: 0.375rem 0.2rem 0.3rem;
        border-radius: 0.8rem;
        font-size: 0.6875rem;
        font-weight: 600;
        letter-spacing: 0.015em;
        color: var(--muted);
        text-decoration: none;
        transition:
            color var(--dur) var(--ease-out),
            background var(--dur) var(--ease-out),
            transform 0.2s var(--ease-spring);
    }
    .dock a:active:not(.is-active) {
        transform: scale(0.96);
    }
    .dock a .dock-ico {
        display: flex;
        align-items: center;
        justify-content: center;
        line-height: 0;
        color: inherit;
        transition: transform 0.2s var(--ease-spring), color var(--dur) var(--ease-out);
    }
    .dock a .dock-svg {
        width: 1.35rem;
        height: 1.35rem;
    }
    .dock a .dock-lbl {
        line-height: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    .dock a:hover:not(.is-active) {
        color: color-mix(in oklch, var(--muted) 40%, var(--ink-secondary));
        background: color-mix(in oklch, var(--ink) 4%, transparent);
    }
    .dock a.is-active {
        color: var(--accent);
        font-weight: 700;
        background: color-mix(in srgb, var(--accent) 16%, transparent);
        box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent);
    }
    .dock a.is-active .dock-ico {
        transform: translateY(-0.5px);
    }

    html[data-theme="dark"] .dock {
        background: color-mix(in oklch, var(--surface) 72%, transparent);
        border-color: color-mix(in oklch, var(--line) 45%, transparent);
        box-shadow:
            inset 0 1px 0 rgb(255 255 255 / 0.04),
            0 4px 28px rgb(0 0 0 / 0.45),
            0 14px 48px rgb(0 0 0 / 0.22);
    }
    @media (prefers-color-scheme: dark) {
        html[data-theme="system"] .dock {
            background: color-mix(in oklch, var(--surface) 72%, transparent);
            border-color: color-mix(in oklch, var(--line) 45%, transparent);
            box-shadow:
                inset 0 1px 0 rgb(255 255 255 / 0.04),
                0 4px 28px rgb(0 0 0 / 0.45),
                0 14px 48px rgb(0 0 0 / 0.22);
        }
    }

    @media (max-width: 767px) and (pointer: coarse) {
        .dock {
            padding: 0.4rem;
            gap: 0.2rem;
        }
        .dock a {
            min-height: 3rem;
        }
        .dock a .dock-svg {
            width: 1.42rem;
            height: 1.42rem;
        }
    }

    @media (min-width: 768px) {
        .dock { display: none; }
        body { padding-bottom: 0; }
    }

    /* ── Auth layout ── */
    .auth-page {
        min-height: 100dvh;
        display: grid; place-items: center; padding: 1rem;
        background: var(--app-canvas-bg);
    }
    .auth-card {
        width: min(26rem, 100%);
        padding: 2rem; border-radius: var(--radius-xl);
        background: var(--surface-elevated-bg);
        border: var(--border-surface);
        box-shadow: var(--shadow-xl), 0 0 80px color-mix(in srgb, var(--accent) 8%, transparent);
    }
    .auth-brand {
        margin-bottom: 1.75rem;
    }
    .auth-brand .brand-logo {
        height: 2.875rem;
        max-width: 100%;
    }
}

/* ───────── COMPONENTS ───────── */
@layer components {

    /*
     * Surface utilities — driven by tokens on :root (--surface-hero-bg, --surface-elevated-bg, --border-surface).
     * Use .surface-hero for title bands; .surface-elevated for optional card overrides.
     */
    .surface-hero {
        border-radius: var(--radius-lg);
        border: var(--border-surface);
        background: var(--surface-hero-bg);
        box-shadow: var(--shadow-sm);
    }
    .surface-elevated {
        border-radius: var(--radius-lg);
        border: var(--border-surface);
        background: var(--surface-elevated-bg);
        box-shadow: var(--shadow-xs);
    }

    /* ── Page heading ── */
    .page-heading {
        display: flex; align-items: flex-start; justify-content: space-between;
        gap: 1rem; margin-bottom: 1.75rem; flex-wrap: wrap;
        padding: 1.25rem 1.35rem;
        border-radius: var(--radius-lg);
        border: var(--border-surface);
        background: var(--surface-hero-bg);
        box-shadow: var(--shadow-xs);
    }
    .page-heading h1 {
        font-size: clamp(1.5rem, 3.5vw, 2.25rem);
        font-weight: 800; letter-spacing: -0.035em; line-height: 1.15;
    }
    .page-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
    .eyebrow {
        font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.1em;
        font-weight: 700; color: var(--accent); margin-bottom: 0.25rem;
    }
    .muted { color: var(--muted); }

    /* ── Account settings (self-service) ── */
    .account-page {
        display: grid;
        gap: 1.25rem;
        width: 100%;
        max-width: min(36rem, 100%);
        margin-inline: auto;
    }
    .account-page .page-heading {
        margin-bottom: 0;
    }
    .account-page__intro {
        font-size: 0.8125rem;
        line-height: 1.45;
        margin-top: 0.25rem;
    }
    .account-page .panel > h2 {
        margin-bottom: 0.5rem;
    }
    .account-page__section-lead {
        font-size: 0.8125rem;
        line-height: 1.45;
        margin: 0 0 0.75rem;
    }
    .account-page__form.stack {
        margin-top: 0;
    }
    .account-page__field-hint {
        font-size: 0.75rem;
        line-height: 1.35;
        margin: -0.35rem 0 0;
    }
    .account-page__input-readonly:disabled {
        cursor: not-allowed;
        opacity: 1;
        background: var(--bg-subtle);
        color: var(--muted);
        border-color: color-mix(in oklch, var(--line) 88%, var(--ink) 4%);
    }

    .lead { font-size: 1.0625rem; font-weight: 500; color: var(--ink-secondary); }
    .title {
        font-size: 1.5rem;
        font-weight: 800;
        letter-spacing: -0.03em;
        line-height: 1.15;
        margin: 0 0 0.25rem;
    }
    .title-sm {
        font-size: 1.25rem;
        font-weight: 700;
        letter-spacing: -0.02em;
        line-height: 1.2;
        margin: 0.5rem 0 0;
    }
    .pill{
        display: inline-flex;
        align-items: center;
        gap: 0.375rem;
        height: 2rem;
        padding: 0 0.75rem;
        border-radius: var(--radius-full);
        border: 1px solid var(--line);
        background: var(--bg-subtle);
        color: var(--ink-secondary);
        font-size: 0.8125rem;
        font-weight: 800;
        letter-spacing: -0.015em;
        white-space: nowrap;
    }
    .pill--accent{
        border-color: color-mix(in srgb, var(--accent) 25%, var(--line));
        background: color-mix(in srgb, var(--accent) 10%, var(--surface));
        color: var(--accent);
    }

    /* ── Card / Panel ── */
    .panel, .stat-card, .day-card {
        background: var(--surface-elevated-bg);
        border: var(--border-surface);
        border-radius: var(--radius-lg);
        padding: 1.25rem;
        box-shadow: var(--shadow-xs);
        transition: box-shadow var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
    }
    .panel:hover, .stat-card:hover {
        box-shadow: var(--shadow-md);
        border-color: color-mix(in oklch, var(--line-strong) 82%, var(--accent) 12%);
    }
    .panel h2 {
        font-size: 1rem; font-weight: 700; letter-spacing: -0.015em;
        margin-bottom: 0.875rem;
    }
    .hero-title{
        font-size: 1.25rem;
        font-weight: 800;
        letter-spacing: -0.02em;
        margin: 0;
    }
    .card-title{
        font-size: 0.9375rem;
        font-weight: 700;
        margin: 0;
    }

    .notice {
        margin-bottom: 1rem;
        border-radius: var(--radius-md);
        padding: 1rem 1.15rem;
        background: color-mix(in oklch, var(--accent-surface) 88%, var(--surface));
        box-shadow: var(--shadow-xs);
        border: var(--border-surface);
        border-left: 3px solid var(--accent);
    }

    /* ── Grid helpers ── */
    .grid { display: grid; gap: 1.25rem; }
    .two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    /* ── Users admin (/users) ── */
    .users-page {
        min-width: 0;
    }
    .users-page > .panel {
        min-width: 0;
    }
    /* Full-width list below create form on medium viewports — avoids cramped table + sideways scroll */
    @media (max-width: 1100px) {
        .users-page.two {
            grid-template-columns: 1fr;
        }
    }
    .users-table-wrap {
        min-width: 0;
    }
    .users-table-wrap table {
        width: 100%;
        table-layout: fixed;
    }
    .users-table-wrap th,
    .users-table-wrap td {
        overflow-wrap: anywhere;
        word-break: break-word;
        vertical-align: top;
    }
    /* Column share (no email column) */
    .users-table-wrap th:nth-child(1),
    .users-table-wrap td:nth-child(1) {
        width: 20%;
    }
    .users-table-wrap th:nth-child(2),
    .users-table-wrap td:nth-child(2) {
        width: 18%;
    }
    .users-table-wrap th:nth-child(3),
    .users-table-wrap td:nth-child(3) {
        width: 28%;
    }
    .users-table-wrap th:nth-child(4),
    .users-table-wrap td:nth-child(4) {
        width: 14%;
    }
    .users-table-wrap th:nth-child(5),
    .users-table-wrap td:nth-child(5) {
        width: 20%;
    }
    .users-table-wrap td .row-actions {
        justify-content: flex-start;
    }
    .create-user-roster-fieldset {
        margin: 0;
        padding: 0.75rem;
        border: 1px solid var(--line);
        border-radius: var(--radius-md);
        min-width: 0;
        background: color-mix(in oklch, var(--bg-subtle) 55%, transparent);
    }
    .create-user-roster-fieldset legend {
        font-size: 0.8125rem;
        font-weight: 700;
        padding: 0 0.25rem;
    }

    /* ── Stat cards ── */
    .stat-grid {
        display: grid;
        /* Five metrics: equal-width columns on one row, full shell width */
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 0.75rem; margin-bottom: 1.5rem;
    }
    .stat-card {
        position: relative; overflow: hidden;
        padding: 1rem 1.125rem;
        min-width: 0;
    }
    .stat-card::before {
        content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
        background: linear-gradient(90deg, var(--accent-2), var(--accent));
        opacity: 0; transition: opacity var(--dur) var(--ease-out);
    }
    .stat-card:hover::before { opacity: 1; }
    .stat-card span { font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
    .stat-card strong { display: block; margin-top: 0.375rem; font-size: 1.75rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
    .stat-hint { display: block; margin-top: 0.375rem; color: var(--faint); font-size: 0.6875rem; }
    .stat-card.warn strong { color: var(--warn); }
    a.stat-card--link {
        text-decoration: none;
        color: inherit;
        cursor: pointer;
    }
    a.stat-card--link:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }
    a.stat-card--link .stat-hint { color: var(--faint); }

    .visually-hidden {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
    .dashboard-panel-head {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem 1rem;
        margin-bottom: 0.625rem;
    }
    .dashboard-panel-head h2 {
        margin: 0;
        font-size: 1.0625rem;
    }

    /* ── Staff home (role: staff) ── */
    .staff-home {
        margin-bottom: 2rem;
    }
    .staff-home-hero {
        margin-bottom: 1.25rem;
        padding: 1.5rem 1.75rem;
    }
    .staff-home-hero h1 {
        font-size: clamp(1.5rem, 3.5vw, 2.25rem);
        font-weight: 800;
        letter-spacing: -0.035em;
        line-height: 1.15;
        margin: 0;
    }
    .staff-home-hero .eyebrow {
        margin-bottom: 0.35rem;
    }
    .dashboard-heading__intro {
        margin-top: 0.5rem;
        font-size: 0.9375rem;
        line-height: 1.45;
        max-width: 38rem;
    }
    .staff-home-date {
        margin-top: 1rem;
        font-size: 0.8125rem;
        font-weight: 700;
        color: var(--accent);
        letter-spacing: 0.02em;
    }
    .staff-home-pulse {
        margin-bottom: 1.25rem;
        padding: 1.125rem 1.25rem;
        display: grid;
        gap: 0.5rem;
        border-radius: var(--radius-md);
    }
    .staff-home-pulse--open {
        border: 1px solid color-mix(in srgb, var(--good) 35%, var(--line));
        background: color-mix(in srgb, var(--good-surface) 88%, var(--surface));
    }
    .staff-home-pulse--closed {
        border: 1px solid color-mix(in srgb, var(--warn) 32%, var(--line));
        background: color-mix(in srgb, var(--warn-surface) 55%, var(--surface));
    }
    .staff-home-pulse--quiet {
        border: var(--border-surface);
        background: var(--surface-elevated-bg);
    }
    .staff-home-pulse__title {
        margin: 0;
        font-size: 1.05rem;
        font-weight: 800;
        letter-spacing: -0.02em;
    }
    .staff-home-pulse__detail {
        margin: 0;
        font-size: 0.875rem;
        line-height: 1.45;
        max-width: 42rem;
    }
    .staff-home-pulse__countdown {
        margin: 0.15rem 0 0;
        font-size: 0.875rem;
        font-weight: 650;
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 0.35rem;
    }
    .staff-home-pulse__cd-label {
        color: var(--muted);
        font-weight: 600;
        font-size: 0.8125rem;
    }
    .staff-home-pulse__cd-value {
        font-family: var(--mono);
        font-variant-numeric: tabular-nums;
        letter-spacing: 0.04em;
    }
    .staff-home-pulse__actions {
        margin-top: 0.35rem;
    }
    .staff-home-section-label {
        margin-top: 0.25rem;
        margin-bottom: 0.625rem;
    }
    .staff-home-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
        gap: 1rem;
        margin-bottom: 2rem;
    }
    .staff-home-tile {
        --tile-accent: var(--accent);
        position: relative;
        display: flex;
        align-items: center;
        gap: 1rem;
        padding: 1.25rem 1.35rem;
        border-radius: var(--radius-lg);
        border: var(--border-surface);
        background: var(--surface-elevated-bg);
        text-decoration: none;
        color: inherit;
        box-shadow: var(--shadow-xs);
        overflow: hidden;
        min-height: 6.25rem;
        transition:
            border-color var(--dur) var(--ease-out),
            box-shadow var(--dur) var(--ease-out),
            transform var(--dur) var(--ease-out);
    }
    .staff-home-tile::before {
        content: '';
        position: absolute;
        inset: 0 0 0 auto;
        width: min(45%, 9rem);
        background: linear-gradient(
            115deg,
            transparent 0%,
            color-mix(in oklch, var(--tile-accent) 12%, transparent) 100%
        );
        pointer-events: none;
    }
    .staff-home-tile:hover {
        border-color: color-mix(in oklch, var(--tile-accent) 40%, var(--line));
        box-shadow: var(--shadow-md);
        transform: translateY(-2px);
    }
    .staff-home-tile:active {
        transform: translateY(0);
    }
    .staff-home-tile:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }
    .staff-home-tile--availability {
        --tile-accent: var(--good);
    }
    .staff-home-tile--shifts {
        --tile-accent: var(--accent);
    }
    .staff-home-tile--calendar {
        --tile-accent: var(--accent-2);
    }
    .staff-home-tile__icon {
        position: relative;
        z-index: 1;
        flex-shrink: 0;
        width: 3.5rem;
        height: 3.5rem;
        border-radius: var(--radius-md);
        display: grid;
        place-items: center;
        background: color-mix(in oklch, var(--tile-accent) 14%, var(--surface));
        border: 1px solid color-mix(in oklch, var(--tile-accent) 28%, var(--line));
        color: color-mix(in oklch, var(--tile-accent) 88%, var(--ink));
    }
    .staff-home-ico-svg {
        width: 1.75rem;
        height: 1.75rem;
    }
    .staff-home-tile__main {
        position: relative;
        z-index: 1;
        flex: 1;
        min-width: 0;
        display: grid;
        gap: 0.375rem;
    }
    .staff-home-tile__title {
        font-size: 1.0625rem;
        font-weight: 800;
        letter-spacing: -0.02em;
        line-height: 1.25;
    }
    .staff-home-tile__hint {
        font-size: 0.8125rem;
        line-height: 1.45;
    }
    .staff-home-tile__go {
        position: relative;
        z-index: 1;
        flex-shrink: 0;
        display: grid;
        place-items: center;
        width: 2rem;
        height: 2rem;
        border-radius: var(--radius-full);
        background: var(--bg-subtle);
        color: var(--muted);
        opacity: 0.65;
        transition:
            opacity var(--dur) var(--ease-out),
            transform var(--dur) var(--ease-out),
            background var(--dur) var(--ease-out),
            color var(--dur) var(--ease-out);
    }
    .staff-home-chevron {
        width: 1.125rem;
        height: 1.125rem;
    }
    .staff-home-tile:hover .staff-home-tile__go {
        opacity: 1;
        color: var(--tile-accent);
        background: color-mix(in oklch, var(--tile-accent) 12%, var(--surface));
        transform: translateX(3px);
    }
    .staff-home-bottom {
        align-items: stretch;
    }
    .staff-home-panel h2 {
        margin-bottom: 0.75rem;
    }
    .staff-home-tips {
        display: grid;
        gap: 0.875rem;
        margin: 0;
        padding: 0;
        list-style: none;
    }
    .staff-home-tips li {
        display: flex;
        gap: 0.75rem;
        align-items: flex-start;
        font-size: 0.875rem;
        line-height: 1.45;
        color: var(--ink-secondary);
    }
    .staff-home-tip-ico {
        flex-shrink: 0;
        width: 2.25rem;
        height: 2.25rem;
        border-radius: var(--radius-sm);
        display: grid;
        place-items: center;
        background: var(--accent-surface);
        border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
        color: var(--accent);
    }
    .staff-home-tip-ico svg {
        width: 1.125rem;
        height: 1.125rem;
    }
    .staff-home-panel--accent {
        background:
            linear-gradient(160deg, color-mix(in srgb, var(--accent) 10%, var(--surface)), var(--surface-elevated-bg));
        border-color: color-mix(in srgb, var(--accent) 18%, var(--line));
    }
    .staff-home-panel-accent-head {
        display: flex;
        align-items: center;
        gap: 0.625rem;
        margin-bottom: 0.625rem;
    }
    .staff-home-panel-accent-head h2 {
        margin: 0;
    }
    .staff-home-panel-accent-icon {
        width: 2.5rem;
        height: 2.5rem;
        border-radius: var(--radius-md);
        display: grid;
        place-items: center;
        background: linear-gradient(135deg, var(--accent-2), var(--accent));
        color: #fff;
        box-shadow: var(--shadow-sm);
    }
    .staff-home-panel-accent-icon svg {
        width: 1.25rem;
        height: 1.25rem;
    }
    .staff-home-panel__lead {
        font-size: 0.875rem;
        line-height: 1.5;
        margin-bottom: 1rem;
    }

    /* ── List rows ── */
    .list { display: grid; gap: 0.5rem; }
    .list-row {
        display: flex; align-items: center; justify-content: space-between;
        gap: 0.75rem; padding: 0.75rem 1rem;
        border: var(--border-surface); border-radius: var(--radius-md);
        background: var(--surface-elevated-bg);
        box-shadow: var(--shadow-xs);
        transition: all var(--dur) var(--ease-out);
    }
    a.list-row:hover {
        border-color: var(--accent);
        background: var(--accent-surface);
        transform: translateX(2px);
    }

    .list-row--stacked {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    /* ── Badge ── */
    .badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        min-height: 1.625rem;
        padding: 0.3125rem 0.65rem;
        border-radius: var(--radius-full);
        font-size: 0.6875rem;
        font-weight: 700;
        line-height: 1.15;
        text-transform: capitalize;
        white-space: nowrap;
        background: var(--bg-subtle);
        color: var(--muted);
    }
    .published, .OK { background: var(--good-surface); color: var(--good-ink); }
    .revised, .pending_approval, .Missing { background: var(--warn-surface); color: var(--warn-ink); }
    .draft { background: var(--accent-surface); color: var(--accent-ink); }
    .archived { opacity: 0.6; }

    /* ── Buttons ── */
    /* Base button styles must apply to both <button> and <a>. */
    .button, button, .primary, .ghost {
        display: inline-flex; align-items: center; justify-content: center;
        gap: 0.375rem; height: 2.5rem; padding: 0 1rem;
        border-radius: var(--radius-sm); border: 0;
        font-size: 0.8125rem; font-weight: 650; cursor: pointer;
        transition: all var(--dur) var(--ease-out);
    }
    .primary, .ghost { text-decoration: none; user-select: none; white-space: nowrap; }
    .primary:disabled, .ghost:disabled, button:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }
    .primary.sm, .ghost.sm, .button.sm {
        height: 2rem; padding: 0 0.625rem; font-size: 0.75rem;
        border-radius: var(--radius-xs);
    }
    .primary {
        color: #fff;
        background: linear-gradient(135deg, var(--accent-2), var(--accent));
        box-shadow: var(--shadow-sm), 0 0 0 0 transparent;
    }
    .primary:hover {
        filter: brightness(1.05);
        box-shadow: var(--shadow-md), var(--shadow-glow);
        transform: translateY(-1px);
    }
    .primary:active { transform: translateY(0); }

    .ghost {
        background: var(--surface); color: var(--ink-secondary);
        border: 1px solid var(--line);
    }
    .ghost:hover { border-color: var(--line-strong); background: var(--bg-subtle); }
    .ghost.danger { border-color: color-mix(in oklch, var(--danger) 35%, var(--line)); color: var(--danger); }
    .ghost.danger:hover { background: color-mix(in oklch, var(--danger) 8%, var(--surface)); }
    .full { width: 100%; }

    /* ── Forms ── */
    .stack { display: grid; gap: 0.875rem; }
    /* Grid/flex default min-width: auto blocks shrinking (date inputs have huge min-content) */
    .stack > * { min-width: 0; }
    /* minmax(0, 1fr): keep date/time inputs from forcing grid past the viewport */
    label { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.25rem; font-size: 0.8125rem; font-weight: 600; color: var(--ink-secondary); }

    input, select, textarea {
        width: 100%; height: 2.5rem;
        border-radius: var(--radius-sm); border: 1px solid var(--line);
        padding: 0.5rem 0.75rem; background: var(--surface);
        font-size: 0.875rem;
        transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
    }
    /* Make native date/time inputs feel more "designed". */
    input[type="date"], input[type="time"] {
        font-variant-numeric: tabular-nums;
        min-width: 0;
        max-width: 100%;
    }
    input[type="date"]::-webkit-calendar-picker-indicator,
    input[type="time"]::-webkit-calendar-picker-indicator {
        opacity: 0.9;
        cursor: pointer;
        filter: grayscale(0.2);
    }

    /* Wrapper for date/time only: native picker chrome, no duplicate glyph */
    .picker {
        display: grid;
        align-items: stretch;
        min-width: 0;
        max-width: 100%;
        width: 100%;
    }
    .picker > input {
        min-width: 0;
        max-width: 100%;
        width: 100%;
    }
    input:focus, select:focus, textarea:focus {
        border-color: var(--accent);
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
        outline: none;
    }
    textarea { height: auto; min-height: 5rem; resize: vertical; }
    .form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; min-width: 0; }
    .form-grid > label { min-width: 0; }

    .chip-grid { display: flex; flex-wrap: wrap; gap: 0.375rem; }
    .chip {
        display: inline-flex; align-items: center; gap: 0.25rem;
        height: 2.25rem; padding: 0 0.625rem;
        border-radius: var(--radius-full); border: 1px solid var(--line);
        background: var(--surface); font-size: 0.8125rem; font-weight: 600;
        transition: all var(--dur) var(--ease-out); cursor: pointer;
    }
    .chip:has(input:checked) {
        background: var(--accent-surface); border-color: var(--accent);
        color: var(--accent-ink);
    }
    .chip input { width: auto; height: auto; min-height: auto; }
    /* Checkbox + wrapping label text (e.g. Users → create user) */
    .chip.chip--multiline {
        height: auto;
        min-height: 2.25rem;
        align-items: center;
        padding: 0.5rem 0.75rem;
        max-width: 100%;
        line-height: 1.35;
    }
    .chip.chip--multiline input[type="checkbox"],
    .chip.chip--multiline input[type="radio"] {
        flex-shrink: 0;
        margin: 0;
        align-self: center;
        accent-color: var(--accent);
    }

    /* ── Staff card & stacked list rows ── */
    .staff-list { display: grid; gap: 0.5rem; }
    .row-actions {
        display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end;
        gap: 0.375rem;
    }
    .row-actions form {
        display: inline-flex;
        align-items: center;
        margin: 0;
        gap: 0.375rem;
    }

    .staff-card, .role-row {
        display: flex; align-items: center; justify-content: space-between;
        gap: 0.75rem; padding: 0.75rem 1rem;
        border: var(--border-surface); border-radius: var(--radius-md);
        background: var(--surface-elevated-bg);
        box-shadow: var(--shadow-xs);
        transition: all var(--dur) var(--ease-out);
    }
    .staff-card--two-line {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    .staff-card__top,
    .list-row__top {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 0.75rem;
        width: 100%;
        min-width: 0;
    }
    .staff-card__identity,
    .list-row__body {
        min-width: 0;
        display: grid;
        gap: 0.125rem;
    }
    .list-row__body .muted {
        font-size: 0.8125rem;
        line-height: 1.4;
    }
    .rota-list__link {
        font-weight: 650;
        color: inherit;
        text-decoration: none;
        line-height: 1.35;
    }
    .rota-list__link:hover {
        color: var(--accent);
        text-decoration: underline;
    }
    .rota-list__main {
        gap: 0.25rem;
    }
    .schema-check-label {
        font-size: 0.8125rem;
        font-weight: 700;
    }
    .list-row__body .muted.schema-check-detail {
        font-size: 0.75rem;
    }
    .staff-meta{
        color: var(--muted);
        font-size: 0.8125rem;
    }
    .section-subhead{
        margin-top: 1.5rem;
        font-size: 0.875rem;
        color: var(--muted);
    }
    .staff-card--inactive{
        opacity: 0.62;
    }
    .staff-card--inactive:hover{
        background: transparent;
        border-color: var(--line);
    }
    .staff-card--two-line .staff-skills {
        align-self: stretch;
        margin: 0;
        padding-top: 0.375rem;
        border-top: 1px solid var(--line);
        color: var(--muted);
        font-size: 0.8125rem;
        line-height: 1.45;
    }
    .staff-card--two-line .row-actions {
        flex-shrink: 0;
        align-self: flex-start;
        justify-content: flex-end;
    }
    .list-row__status {
        flex-shrink: 0;
    }
    .list-row__top > .row-actions {
        flex-shrink: 0;
    }
    .list-row--stacked .list-row__actions {
        flex-shrink: 0;
        align-self: stretch;
        justify-content: flex-end;
        margin-top: 0.125rem;
        padding-top: 0.5rem;
        border-top: 1px solid var(--line);
    }
    .staff-card:hover {
        border-color: var(--line-strong);
        background: var(--bg-subtle);
    }
    .staff-card strong { font-weight: 700; }
    .staff-card span { font-size: 0.8125rem; color: var(--muted); }
    .hours { font-size: 0.8125rem; font-weight: 700; color: var(--accent); white-space: nowrap; }

    .directory-layout {
        display: grid;
        gap: 1.25rem;
        grid-template-columns: minmax(0, 1fr) minmax(16rem, 22rem);
        align-items: start;
    }
    .staff-directory-grid {
        display: grid;
        gap: 0.75rem;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .staff-directory-card {
        display: grid;
        gap: 0.5rem;
        padding: 1rem;
        border: var(--border-surface);
        border-radius: var(--radius-md);
        background: var(--surface-elevated-bg);
        box-shadow: var(--shadow-xs);
        transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
    }
    .staff-directory-card:hover {
        border-color: color-mix(in srgb, var(--accent) 22%, var(--line));
        box-shadow: var(--shadow-sm);
    }
    .staff-directory-card--inactive {
        opacity: 0.7;
    }
    .staff-directory-card__who {
        display: grid;
        gap: 0.125rem;
        min-width: 0;
    }
    .staff-directory-card__who strong { font-size: 0.9375rem; letter-spacing: -0.015em; }
    .staff-directory-card__account {
        padding: 0.5rem 0.625rem;
        border-radius: var(--radius-sm);
        background: color-mix(in srgb, var(--accent) 5%, transparent);
        border: 1px solid color-mix(in oklch, var(--line) 70%, transparent);
        display: grid;
        gap: 0.375rem;
    }
    .staff-directory-login-line {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.375rem;
    }
    .staff-directory-handle {
        font-size: 0.8125rem;
        font-weight: 750;
        color: var(--ink);
        word-break: break-word;
    }
    .staff-directory-card .staff-skills {
        font-size: 0.8125rem;
        color: var(--muted);
        line-height: 1.35;
        border-top: 1px dashed var(--line);
        padding-top: 0.375rem;
    }
    .staff-directory-card__acts {
        border-top: 1px solid var(--line);
        padding-top: 0.5rem;
        justify-content: flex-start;
    }

    /* ── Absences: upcoming sections ── */
    .absences-upcoming__block + .absences-upcoming__block {
        margin-top: 1.25rem;
        padding-top: 1.25rem;
        border-top: 1px solid var(--line);
    }
    .absences-upcoming__h {
        font-size: 1rem;
        font-weight: 800;
        margin: 0;
        letter-spacing: -0.02em;
    }

    /* ── Timeline ── */
    .timeline { display: grid; gap: 0.5rem; }
    .timeline-row {
        display: grid; gap: 0.125rem; padding: 0.75rem 1rem;
        border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
        background: color-mix(in oklch, var(--surface-elevated-bg) 72%, var(--bg-subtle));
        border: var(--border-surface);
        border-left-width: 2px;
        border-left-color: var(--line);
        box-shadow: var(--shadow-xs);
        transition: border-color var(--dur) var(--ease-out);
    }
    .timeline-row:hover { border-left-color: var(--accent); }
    .timeline-row strong { font-size: 0.8125rem; font-weight: 700; }
    .timeline-row span { font-size: 0.75rem; color: var(--muted); }
    .timeline-row--split {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 0.75rem;
    }
    .timeline-row--split .timeline-row__body {
        display: grid;
        gap: 0.125rem;
        min-width: 0;
    }

    /* ── Tables ── */
    .table-wrap {
        overflow-x: auto; border-radius: var(--radius-md);
        border: var(--border-surface);
        background: var(--surface-elevated-bg);
        box-shadow: var(--shadow-xs);
    }
    table { width: 100%; }
    th {
        padding: 0.625rem 0.875rem;
        font-size: 0.6875rem; font-weight: 700; text-transform: uppercase;
        letter-spacing: 0.05em; color: var(--muted);
        background: var(--bg-subtle);
        border-bottom: 1px solid var(--line); text-align: left;
    }
    td {
        padding: 0.625rem 0.875rem;
        font-size: 0.8125rem;
        border-bottom: 1px solid var(--line);
    }
    tbody tr { transition: background var(--dur) var(--ease-out); }
    tbody tr:hover { background: var(--bg-subtle); }
    tbody tr:last-child td { border-bottom: 0; }

    .audit-entity-cell {
        min-width: 12rem;
    }
    .audit-entity-cell .audit-entity__type {
        display: block;
        font-weight: 600;
    }
    .audit-entity-cell .audit-entity__detail {
        display: block;
        font-size: 0.75rem;
        margin-top: 0.125rem;
        line-height: 1.35;
        word-break: break-word;
    }

    /* ── Lifecycle stepper ── */
    .lifecycle {
        display: flex; flex-wrap: wrap; gap: 0.25rem;
        padding: 0.75rem; margin-bottom: 1.25rem;
        border: var(--border-surface); border-radius: var(--radius-md);
        background: var(--surface-elevated-bg);
        box-shadow: var(--shadow-xs);
    }
    .lifecycle-step {
        display: inline-flex; align-items: center; gap: 0.375rem;
        padding: 0.25rem 0.5rem; border-radius: var(--radius-full);
        font-size: 0.6875rem; font-weight: 700; color: var(--faint);
    }
    .lifecycle-step .dot {
        width: 0.5rem; height: 0.5rem; border-radius: 50%;
        background: var(--line); transition: background var(--dur) var(--ease-out);
    }
    .lifecycle-step.is-past .dot { background: var(--good); }
    .lifecycle-step.is-current {
        color: var(--accent-ink); background: var(--accent-surface);
    }
    .lifecycle-step.is-current .dot { background: var(--accent); }

    /* ── Builder ── */
    .builder-toolbar { display: grid; gap: 0.625rem; margin-bottom: 1.25rem; }
    .toolbar-cluster { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
    .toolbar-note { font-size: 0.8125rem; color: var(--muted); }

    .builder-layout {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, min(22rem, 100%));
        gap: 1.25rem; align-items: start;
        min-width: 0;
    }
    .builder-main { display: grid; gap: 1.25rem; min-width: 0; }
    .builder-main > .panel { min-width: 0; }
    .builder-main > .panel.rota-draft-add-panel {
        padding-top: 1.5rem;
    }
    .rota-draft-add-panel__head {
        display: grid;
        gap: 0.1875rem;
        margin: 0 0 1rem;
    }
    .rota-draft-add-panel__eyebrow {
        margin: 0;
        font-size: 0.625rem;
        font-weight: 800;
        letter-spacing: 0.1em;
        text-transform: uppercase;
        color: color-mix(in oklch, var(--muted) 70%, var(--accent) 30%);
    }
    .rota-draft-add-panel__head > h2 {
        margin: 0;
        font-size: 1.0625rem;
        letter-spacing: -0.015em;
    }
    .rota-draft-add-panel__lead {
        margin: 0.1875rem 0 0;
        font-size: 0.8125rem;
        line-height: 1.5;
    }
    .rota-draft-add-panel__lead strong {
        color: color-mix(in oklch, var(--ink) 85%, var(--accent) 15%);
        font-weight: 800;
        margin-right: 0.0625rem;
    }
    .rota-draft-add-panel__live {
        display: inline-block;
        margin-top: 0.25rem;
        padding: 0.125rem 0.5rem;
        border-radius: 999px;
        background: var(--warn-surface);
        border: 1px solid color-mix(in oklch, var(--warn) 30%, var(--line));
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--warn-ink);
    }

    /*
     * Draft “Add service” — layout + visuals (desktop-first). Mobile tweaks in utilities @media max-width.
     */
    .rota-draft-add-panel__hint {
        font-size: 0.75rem;
        line-height: 1.4;
        margin: -0.125rem 0 0;
    }
    .rota-draft-add-panel__presets {
        margin-bottom: 0.25rem;
    }
    .rota-draft-add-panel__presets .shift-presets__label {
        align-self: center;
        flex-shrink: 0;
        font-size: 0.8125rem;
    }
    .rota-draft-add-panel .rota-day-tabs {
        display: flex;
        flex-wrap: nowrap;
        align-items: stretch;
        gap: 0.375rem;
        margin: 0 0 0.625rem;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        padding-bottom: 0.1875rem;
    }
    .rota-draft-add-panel .rota-day-tabs::-webkit-scrollbar {
        height: 5px;
    }
    .rota-draft-add-panel .rota-day-tabs::-webkit-scrollbar-thumb {
        background: color-mix(in oklch, var(--muted) 42%, var(--line));
        border-radius: 999px;
    }
    .rota-draft-add-panel .rota-day-tab {
        position: relative;
        flex: 1 1 0;
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        gap: 0.125rem;
        padding: 0.4375rem 0.375rem;
        border: 1px solid color-mix(in oklch, var(--line) 92%, transparent);
        border-radius: var(--radius-sm);
        background: color-mix(in oklch, var(--surface-elevated-bg) 96%, transparent);
        color: inherit;
        font-size: 0.78125rem;
        line-height: 1.2;
        cursor: pointer;
        transition:
            border-color var(--dur) var(--ease-out),
            background var(--dur) var(--ease-out),
            box-shadow var(--dur) var(--ease-out);
    }
    .rota-draft-add-panel .rota-day-tab:hover {
        border-color: color-mix(in oklch, var(--line) 72%, var(--accent) 16%);
        background: color-mix(in oklch, var(--surface-elevated-bg) 94%, var(--accent) 6%);
    }
    .rota-draft-add-panel .rota-day-tab.has-shifts {
        background: color-mix(in oklch, var(--accent) 5%, var(--surface-elevated-bg));
        border-color: color-mix(in oklch, var(--line) 78%, var(--accent) 18%);
    }
    .rota-draft-add-panel .rota-day-tab.is-active {
        border-color: var(--accent);
        background: color-mix(in oklch, var(--accent) 12%, var(--surface-elevated-bg));
        box-shadow: 0 0 0 1px color-mix(in oklch, var(--accent) 35%, transparent);
    }
    .rota-draft-add-panel .rota-day-tab__weekday {
        font-weight: 700;
        letter-spacing: 0.01em;
    }
    .rota-draft-add-panel .rota-day-tab .rota-day-tab__sub {
        font-size: 0.625rem;
        font-weight: 500;
        color: var(--muted);
    }
    .rota-draft-add-panel .rota-day-tab.is-active .rota-day-tab__sub {
        color: color-mix(in oklch, var(--muted) 55%, var(--accent) 45%);
    }
    .rota-draft-add-panel .rota-day-tab__count {
        position: absolute;
        top: -0.375rem;
        right: -0.375rem;
        min-width: 1.125rem;
        height: 1.125rem;
        padding: 0 0.3125rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 999px;
        background: var(--accent);
        color: var(--accent-ink, #fff);
        font-size: 0.625rem;
        font-weight: 800;
        line-height: 1;
        letter-spacing: 0;
        box-shadow: 0 0 0 2px var(--surface-elevated-bg);
    }
    .rota-active-day {
        display: grid;
        gap: 0.5rem;
        margin: 0 0 0.875rem;
        padding: 0.6875rem 0.8125rem;
        border-radius: var(--radius-sm);
        border: 1px solid color-mix(in oklch, var(--line) 88%, transparent);
        background: color-mix(in oklch, var(--surface-bg) 96%, transparent);
    }
    .rota-active-day__head {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 0.625rem;
        flex-wrap: wrap;
        margin: 0;
    }
    .rota-active-day__label {
        margin: 0;
        font-weight: 700;
        font-size: 0.9375rem;
        letter-spacing: 0.01em;
        color: color-mix(in oklch, var(--muted) 14%, inherit);
    }
    .rota-active-day__meta {
        margin: 0;
        font-size: 0.75rem;
        font-weight: 600;
    }
    /* Old caption class kept for back-compat — hidden if it ever renders */
    .rota-draft-add-panel .rota-active-day-caption {
        display: none;
    }
    .rota-draft-add-panel .rota-draft-saved-this-day {
        margin: 0 0 1.125rem;
    }
    .rota-draft-add-panel #rota-draft-day-scheduled {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }
    .rota-draft-add-panel .rota-draft-saved-shift {
        scroll-margin-top: 4rem;
        padding: 0.75rem 0.8125rem;
        border-radius: var(--radius-sm);
        border: 1px solid color-mix(in oklch, var(--line) 84%, var(--accent) 12%);
        background: color-mix(in oklch, var(--surface-bg) 98%, transparent);
    }
    .rota-draft-add-panel .rota-draft-saved-shift__head {
        display: flex;
        flex-wrap: wrap;
        align-items: flex-start;
        justify-content: space-between;
        gap: 0.75rem;
    }
    .rota-draft-add-panel .rota-draft-saved-shift__titles {
        flex: 1 1 10rem;
        min-width: 0;
    }
    .rota-draft-add-panel .rota-draft-saved-shift__name {
        margin: 0;
        font-size: 0.921875rem;
        font-weight: 700;
    }
    .rota-draft-add-panel .rota-draft-saved-shift__tools.toolbar-cluster {
        flex-shrink: 0;
        gap: 0.375rem;
        margin: 0;
        flex-wrap: wrap;
        justify-content: flex-end;
    }
    .rota-draft-add-panel .rota-draft-saved-shift__people.rota-staff-chips {
        min-height: auto;
        margin-top: 0.375rem;
        border-style: solid;
        border-color: color-mix(in oklch, var(--line) 92%, transparent);
    }
    .rota-draft-add-panel span.rota-staff-pill.rota-staff-pill--cal.rota-staff-pill--readonly {
        appearance: none;
        display: inline-flex;
        align-items: center;
        padding: 0.375rem 0.75rem;
        border-radius: 999px;
        font-size: 0.8125rem;
        font-weight: 600;
        line-height: 1.25;
        cursor: default;
        pointer-events: none;
    }
    /* Saved-shift assignment: tap pill → unassign dialog (same flow as picker pills) */
    .rota-draft-add-panel .rota-draft-saved-shift__unassign-form {
        display: inline-flex;
        margin: 0;
        padding: 0;
        border: none;
        background: none;
        vertical-align: baseline;
        max-width: 100%;
    }
    .rota-draft-add-panel .rota-draft-saved-shift__unassign-form .rota-draft-saved-shift__unassign-pill.rota-unassign-open {
        font: inherit;
    }
    .rota-draft-add-panel .rota-draft-add-heading {
        color: color-mix(in oklch, var(--muted) 92%, inherit);
        letter-spacing: 0.08em;
    }
    .rota-draft-pattern-cards {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0.5rem;
        margin: 0 0 0.75rem;
    }
    @media (max-width: 30rem) {
        .rota-draft-pattern-cards {
            grid-template-columns: repeat(2, minmax(0, 1fr));
        }
    }
    .rota-pattern-card {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.1875rem;
        margin: 0;
        padding: 0.625rem 0.6875rem;
        text-align: left;
        border-radius: var(--radius-sm);
        border: 1px solid color-mix(in oklch, var(--line) 88%, transparent);
        background: color-mix(in oklch, var(--surface-elevated-bg) 96%, transparent);
        color: inherit;
        font: inherit;
        cursor: pointer;
        transition:
            border-color var(--dur) var(--ease-out),
            background var(--dur) var(--ease-out),
            box-shadow var(--dur) var(--ease-out);
    }
    .rota-pattern-card:hover {
        border-color: color-mix(in oklch, var(--line) 72%, var(--accent) 16%);
        background: color-mix(in oklch, var(--surface-elevated-bg) 94%, var(--accent) 6%);
    }
    .rota-pattern-card.is-selected {
        border-color: var(--accent);
        background: color-mix(in oklch, var(--accent) 12%, var(--surface-elevated-bg));
        box-shadow: 0 0 0 1px color-mix(in oklch, var(--accent) 35%, transparent);
    }
    .rota-pattern-card--custom {
        border-style: dashed;
    }
    .rota-pattern-card--custom.is-selected {
        border-style: solid;
    }
    .rota-pattern-card__label {
        font-size: 0.8125rem;
        font-weight: 700;
        line-height: 1.2;
    }
    .rota-pattern-card__hint {
        font-size: 0.6875rem;
        line-height: 1.25;
        font-variant-numeric: tabular-nums;
    }

    .shift-patterns-form__fieldset {
        border: none;
        margin: 0 0 1.125rem;
        padding: 0;
    }

    .shift-patterns-form__fieldset .eyebrow {
        text-transform: capitalize;
    }

    .shift-patterns-form__row {
        display: grid;
        grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr);
        gap: 0.75rem;
        align-items: end;
    }

    @media (max-width: 40rem) {
        .shift-patterns-form__row {
            grid-template-columns: 1fr;
        }
    }
    #rota-draft-custom-fields:not(.is-visible) {
        display: none !important;
    }

    .rota-draft-add-panel #rota-draft-custom-fields.is-visible {
        display: grid !important;
        grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr);
        gap: 0.75rem;
        align-items: end;
        margin-top: 0.125rem;
        min-width: 0;
    }

    .rota-draft-add-panel .rota-draft-custom-slot-picker {
        grid-column: 1 / -1;
        margin-bottom: 0.125rem;
    }

    .rota-draft-add-panel .rota-draft-custom-slot-picker__title {
        margin: 0 0 0.375rem;
        display: block;
        font-size: 0.8125rem;
        font-weight: 600;
        min-width: 0;
        color: color-mix(in oklch, var(--muted) 88%, inherit);
    }

    .rota-draft-add-panel .rota-draft-custom-slot-cards {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(7.75rem, 1fr));
        gap: 0.5rem;
        margin: 0;
        padding: 0;
        min-width: 0;
    }

    @media (max-width: 30rem) {
        .rota-draft-add-panel .rota-draft-custom-slot-cards {
            grid-template-columns: repeat(2, minmax(0, 1fr));
        }
    }

    .rota-draft-add-panel #rota-draft-custom-fields.is-visible > label {
        min-width: 0;
    }

    @media (max-width: 40rem) {
        .rota-draft-add-panel #rota-draft-custom-fields.is-visible {
            grid-template-columns: 1fr !important;
        }
    }
    .rota-draft-add-panel .rota-staff-chip-zones {
        display: flex;
        flex-direction: column;
        gap: 0;
        margin-top: 0.875rem;
    }
    .rota-draft-add-panel .rota-staff-zone__label {
        display: flex;
        align-items: center;
        gap: 0.4375rem;
        margin: 0 0 0.4375rem;
        font-size: 0.6875rem;
        font-weight: 700;
        letter-spacing: 0.07em;
        text-transform: uppercase;
        color: color-mix(in oklch, var(--muted) 88%, var(--accent) 12%);
    }
    .rota-staff-zone__count {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 1.25rem;
        height: 1.25rem;
        padding: 0 0.375rem;
        border-radius: 999px;
        background: var(--accent);
        color: var(--accent-ink, #fff);
        font-size: 0.6875rem;
        font-weight: 800;
        letter-spacing: 0;
        text-transform: none;
        line-height: 1;
    }
    .rota-staff-zone__count.is-zero {
        background: color-mix(in oklch, var(--muted) 30%, var(--surface-elevated-bg));
        color: var(--muted);
    }
    .rota-staff-zone__hint {
        margin: -0.125rem 0 0.4375rem;
        font-size: 0.6875rem;
        line-height: 1.4;
    }
    .rota-draft-notes-label {
        display: block;
        margin-top: 0.25rem;
    }
    .rota-draft-notes-label__hint {
        font-size: 0.6875rem;
        font-weight: 500;
        margin-left: 0.1875rem;
    }
    .rota-draft-actions {
        display: flex;
        justify-content: flex-end;
        margin-top: 0.5rem;
    }
    .rota-draft-submit {
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        gap: 0.0625rem;
        padding-block: 0.5625rem;
        min-width: 12rem;
    }
    .rota-draft-submit__label {
        font-size: 0.9375rem;
        font-weight: 700;
        letter-spacing: 0.005em;
        line-height: 1.2;
    }
    .rota-draft-submit__day {
        font-size: 0.6875rem;
        font-weight: 500;
        letter-spacing: 0.02em;
        line-height: 1.2;
        opacity: 0.85;
    }
    @media (max-width: 24rem) {
        .rota-draft-actions {
            justify-content: stretch;
        }
        .rota-draft-submit {
            width: 100%;
        }
    }
    .rota-draft-add-panel .rota-staff-zone + .rota-staff-zone {
        margin-top: 0.75rem;
        padding-top: 0.875rem;
        border-top: 1px solid color-mix(in oklch, var(--line) 94%, transparent);
    }
    .rota-draft-add-panel .rota-staff-chips {
        display: flex;
        flex-wrap: wrap;
        gap: 0.4375rem;
        align-items: center;
        min-height: 2.625rem;
        padding: 0.5625rem 0.625rem;
        border-radius: var(--radius-sm);
        border: 1px dashed color-mix(in oklch, var(--line) 86%, var(--accent) 8%);
        background: color-mix(in oklch, var(--surface-bg) 97%, transparent);
    }
    .rota-draft-add-panel .rota-staff-chips.is-selected-zone {
        border-style: solid;
        border-color: color-mix(in oklch, var(--line) 65%, var(--accent) 20%);
        background: color-mix(in oklch, var(--accent) 9%, var(--surface-bg));
    }
    .rota-draft-add-panel .rota-staff-chips.is-selected-zone form.rota-draft-unassign-pill-form.unassign-form {
        display: inline-flex;
        margin: 0;
        padding: 0;
        border: 0;
        background: none;
        flex: 0 0 auto;
        align-items: center;
        min-width: 0;
    }
    /*
     * Staff pills reuse calendar palette tokens (same hex as .cal-staff-disk--* in this file).
     * Classes cal-staff-disk--c{n} / cal-staff-disk--cr-* only supply background + text colour.
     */
    .rota-draft-add-panel button.rota-staff-pill.rota-staff-pill--cal {
        appearance: none;
        -webkit-appearance: none;
        display: inline-flex;
        align-items: center;
        max-width: 100%;
        padding: 0.4rem 0.8125rem;
        border-radius: 999px;
        border: none;
        font-size: 0.8125rem;
        font-weight: 600;
        text-align: left;
        cursor: pointer;
        line-height: 1.25;
        box-sizing: border-box;
        box-shadow: none;
        transition:
            transform var(--dur) var(--ease-out),
            filter var(--dur) var(--ease-out),
            outline-color var(--dur) var(--ease-out);
    }
    .rota-draft-add-panel button.rota-staff-pill.rota-staff-pill--cal:hover {
        filter: brightness(1.1);
        transform: translateY(-1px);
    }
    .rota-draft-add-panel button.rota-staff-pill.rota-staff-pill--cal:focus-visible {
        outline: 2px solid color-mix(in oklch, var(--accent) 50%, transparent);
        outline-offset: 2px;
    }

    /* Saved roster (server): non-interactive pills match button sizing */
    .rota-draft-add-panel .rota-staff-chips.is-selected-zone span.rota-staff-pill.rota-staff-pill--cal {
        display: inline-flex;
        align-items: center;
        max-width: 100%;
        padding: 0.4rem 0.8125rem;
        border-radius: 999px;
        border: none;
        font-size: 0.8125rem;
        font-weight: 600;
        line-height: 1.25;
        box-sizing: border-box;
        box-shadow: none;
        cursor: default;
        user-select: none;
    }

    .rota-draft-add-panel button.rota-staff-pill--pending-assign {
        outline: 1px dashed color-mix(in srgb, #fff 70%, transparent);
        outline-offset: -2px;
    }

    .builder-main .stack { min-width: 0; }

    .day-heading { font-size: 0.875rem; font-weight: 700; letter-spacing: -0.01em; margin: 1.25rem 0 0.625rem; }
    .day-block:first-of-type .day-heading { margin-top: 0; }

    .coverage-grid, .mobile-rota { display: grid; gap: 0.75rem; }

    .service-card {
        scroll-margin-top: 4.5rem;
        display: grid; gap: 0.5rem;
        padding: 1rem; border-radius: var(--radius-md);
        border: var(--border-surface); background: var(--surface-elevated-bg);
        box-shadow: var(--shadow-xs);
        transition: box-shadow var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
        min-width: 0;
    }
    .service-card:hover { box-shadow: var(--shadow-sm); }
    .service-card-head {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 0.5rem;
    }
    .service-card-head__main { min-width: 0; flex: 1; }
    .service-card-actions {
        display: flex;
        flex-wrap: wrap;
        align-items: flex-start;
        justify-content: flex-end;
        gap: 0.35rem;
        flex-shrink: 0;
        margin: -0.125rem 0 0;
    }
    .remove-service-form {
        flex-shrink: 0;
        margin: 0;
        display: inline;
    }
    .service-card-actions .ghost.sm { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
    .service-card-head h4 { font-size: 0.9375rem; font-weight: 700; letter-spacing: -0.01em; }
    .service-card-head p { margin-top: 0.125rem; color: var(--muted); font-size: 0.8125rem; }

    .assignment-list {
        display: flex; flex-direction: column; gap: 0.375rem;
        padding: 0.25rem 0;
    }
    .assignment-row {
        display: flex; align-items: center; justify-content: space-between;
        gap: 0.5rem; padding: 0.375rem 0.625rem;
        background: var(--bg-subtle); border-radius: var(--radius-sm);
        font-size: 0.8125rem;
    }
    .assignment-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; flex: 0 1 auto; }
    .unassign-form {
        display: flex; align-items: center; justify-content: flex-end;
        gap: 0.375rem;
        min-width: 0;
        flex: 1 1 0;
        flex-wrap: nowrap;
    }
    .btn-icon {
        display: inline-flex; align-items: center; justify-content: center;
        flex: 0 0 auto;
        width: 2rem; height: 2rem;
        border: 1px solid var(--line); border-radius: var(--radius-sm);
        background: var(--surface); color: var(--muted);
        font-size: 0.8125rem;
        cursor: pointer;
        transition: all var(--dur) var(--ease-out);
    }
    .btn-icon:hover { background: var(--bg-subtle); }
    .btn-icon.danger { color: var(--danger); border-color: color-mix(in oklch, var(--danger) 30%, var(--line)); }
    .btn-icon.danger:hover { background: color-mix(in oklch, var(--danger) 10%, var(--surface)); }

    .assign-form {
        display: grid; gap: 0.5rem;
        min-width: 0;
    }
    .assign-form select,
    .assign-form input:not([type="hidden"]) {
        min-width: 0;
        max-width: 100%;
    }
    @container (min-width: 720px) {
        .assign-form { grid-template-columns: 1.2fr 1fr auto; align-items: end; }
    }

    /* Rota builder: unassign confirmation (native <dialog>)
       iOS/WebKit: inset+margin:auto is unreliable in the top layer; use transform centering.
       Explicit border/color-scheme avoids UA “white frame” + flat black panel on mobile. */
    .rota-dialog {
        position: fixed;
        z-index: 1;
        left: 50%;
        top: 50%;
        right: auto;
        bottom: auto;
        transform: translate3d(-50%, -50%, 0);
        margin: 0;
        padding: 0;
        width: min(28rem, calc(100vw - 1.25rem));
        max-width: calc(100% - 1.25rem);
        height: fit-content;
        max-height: 86dvh;
        max-height: min(
            86dvh,
            calc(100svh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 1.25rem)
        );
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        border: 1px solid color-mix(in srgb, var(--line) 82%, var(--accent) 8%);
        border-radius: var(--radius-md);
        background: var(--surface-elevated-bg);
        color: var(--text);
        color-scheme: light dark;
        box-shadow: var(--shadow-lg);
        outline: none;
        box-sizing: border-box;
    }
    .rota-dialog--wide {
        width: min(38rem, calc(100vw - 1.25rem));
    }
    .rota-dialog:focus {
        outline: none;
    }
    .rota-dialog::backdrop {
        /* Light theme: tint with ink (dark) — reads as a clean grey wash */
        background: color-mix(in oklch, var(--ink) 42%, transparent);
        backdrop-filter: blur(10px) saturate(1.08);
        -webkit-backdrop-filter: blur(10px) saturate(1.08);
    }
    html[data-theme="dark"] .rota-dialog::backdrop {
        /* Dark theme: never mix --ink (light text); use canvas bg so blur stays blue-neutral */
        background: color-mix(in srgb, var(--bg) 76%, transparent);
        backdrop-filter: blur(14px) saturate(1.06);
        -webkit-backdrop-filter: blur(14px) saturate(1.06);
    }
    @media (prefers-color-scheme: dark) {
        html[data-theme="system"] .rota-dialog::backdrop {
            background: color-mix(in srgb, var(--bg) 76%, transparent);
            backdrop-filter: blur(14px) saturate(1.06);
            -webkit-backdrop-filter: blur(14px) saturate(1.06);
        }
    }
    .rota-dialog__inner {
        padding: 1.25rem 1.25rem max(1rem, env(safe-area-inset-bottom, 0px));
        box-sizing: border-box;
    }
    .rota-dialog__title {
        font-size: 1.0625rem;
        font-weight: 800;
        letter-spacing: -0.02em;
        margin: 0;
        color: var(--ink);
    }
    .rota-dialog__lead {
        margin: 0.625rem 0 0;
        font-size: 0.875rem;
        line-height: 1.45;
        color: var(--muted);
    }
    .rota-dialog__reason-block {
        margin-top: 1rem;
        display: grid;
        gap: 0.375rem;
    }
    .edit-service-roles-toolbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        flex-wrap: wrap;
        margin-top: 0.5rem;
    }
    .edit-service-role-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    .edit-service-role-title {
        font-size: 0.75rem;
        font-weight: 800;
        letter-spacing: 0.02em;
        text-transform: uppercase;
        color: var(--muted);
    }
    .edit-service-role-fields {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        margin-top: 0.75rem;
    }
    .edit-service-role-field {
        margin: 0;
        padding: 0.65rem 0.75rem;
        border: var(--border-surface);
        border-radius: var(--radius-sm);
        background: var(--bg-subtle);
        min-width: 0;
    }
    .edit-service-role-legend {
        font-size: 0.75rem;
        font-weight: 800;
        padding: 0 0.25rem;
    }
    .edit-service-role-hint {
        font-size: 0.75rem;
        margin: 0.5rem 0 0;
    }
    .rota-dialog__label {
        font-size: 0.8125rem;
        font-weight: 700;
        color: var(--ink-secondary);
    }
    .rota-dialog__textarea {
        font: inherit;
        font-size: 0.875rem;
        line-height: 1.4;
        padding: 0.5rem 0.625rem;
        border: 1px solid var(--line);
        border-radius: var(--radius-sm);
        background: var(--surface);
        color: var(--text);
        min-height: 4.5rem;
        resize: vertical;
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }
    .rota-dialog__textarea:focus {
        outline: 2px solid var(--accent);
        outline-offset: 1px;
    }
    .rota-dialog__error {
        margin: 0.75rem 0 0;
        padding: 0.5rem 0.625rem;
        font-size: 0.8125rem;
    }
    .rota-dialog__error[hidden] {
        display: none !important;
    }
    .rota-dialog__actions {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 0.5rem;
        margin-top: 1.125rem;
        padding-top: 0.25rem;
    }

    .warning-panel { position: sticky; top: 4.5rem; display: grid; gap: 0.75rem; }
    .warning-panel__head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        margin: 0;
    }
    .warning-panel__head h2 {
        margin: 0;
    }
    .warning-panel__count {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 1.5rem;
        height: 1.5rem;
        padding: 0 0.5rem;
        border-radius: 999px;
        background: var(--warn-surface);
        color: var(--warn-ink);
        border: 1px solid color-mix(in oklch, var(--warn) 40%, var(--line));
        font-size: 0.75rem;
        font-weight: 800;
        line-height: 1;
        letter-spacing: 0;
    }
    .warning-panel__count.is-empty {
        background: var(--good-surface);
        color: var(--good-ink);
        border-color: color-mix(in oklch, var(--good) 38%, var(--line));
    }
    .warning-panel__empty {
        font-size: 0.8125rem;
        margin: 0;
    }
    .warning-stack { display: grid; gap: 0.5rem; }
    .warning {
        padding: 0.75rem; border-radius: var(--radius-md);
        border: 1px solid color-mix(in oklch, var(--warn) 30%, var(--line));
        background: var(--warn-surface);
    }
    .warning.blocker {
        border-color: color-mix(in oklch, var(--danger) 40%, var(--line));
        background: var(--danger-surface);
    }
    .warning.info {
        border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
        background: var(--accent-surface);
    }
    .warning-label { font-size: 0.625rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 800; color: var(--muted); }

    /* ── My rota ── */
    .day-card .date { color: var(--accent); font-weight: 800; font-size: 0.75rem; }
    .day-card h2, .day-card h3 { letter-spacing: -0.02em; }
    .day-card.compact { padding: 0.875rem; }
    .hero-shift {
        margin-bottom: 1.25rem; position: relative; overflow: hidden;
        background: linear-gradient(135deg, var(--accent-surface), var(--surface-elevated-bg));
        border: var(--border-surface);
        box-shadow: var(--shadow-sm);
    }
    .hero-shift::before {
        content: ''; position: absolute; top: -50%; right: -20%;
        width: 60%; height: 200%; border-radius: 50%;
        background: radial-gradient(circle, color-mix(in srgb, var(--accent) 8%, transparent), transparent 70%);
    }
    .section-title {
        font-size: 0.6875rem; text-transform: uppercase;
        letter-spacing: 0.1em; font-weight: 700; color: var(--muted);
        margin: 0.75rem 0;
    }

    /* ── Availability ── */
    .summary-grid .day-head {
        font-size: 0.625rem; font-weight: 700; text-align: center;
        white-space: nowrap; min-width: 2rem; padding: 0.375rem 0.125rem;
    }
    .summary-grid td:not(:first-child):not(:nth-child(2)):not(:last-child) {
        text-align: center; font-weight: 800; font-size: 0.75rem; padding: 0.375rem 0.125rem;
    }
    .summary-grid .cell-available { color: var(--good); }
    .summary-grid .cell-unavailable { color: var(--faint); }
    .summary-grid .cell-prefer_not { color: var(--warn); }
    .summary-grid .cell-unknown { color: var(--line); }
    .summary-grid td.summary-grid__note {
        max-width: 4rem;
        font-size: 0.75rem;
        line-height: 1.35;
        text-align: center;
        font-weight: 500;
        vertical-align: middle;
    }
    .summary-note-trigger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 2rem;
        height: 2rem;
        margin: 0;
        padding: 0;
        border: none;
        border-radius: var(--radius-xs);
        background: transparent;
        color: var(--accent);
        cursor: pointer;
    }
    .summary-note-trigger__icon {
        width: 1.125rem;
        height: 1.125rem;
        flex-shrink: 0;
    }
    .summary-note-trigger:focus {
        outline: none;
    }
    .summary-note-trigger:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
        border-radius: var(--radius-xs);
    }
    .summary-note-popover {
        position: fixed;
        z-index: 1200;
        box-sizing: border-box;
        min-width: 12rem;
        max-width: min(22rem, calc(100vw - 1.5rem));
        max-height: min(50vh, 18rem);
        overflow: auto;
        padding: 0.6rem 2rem 0.6rem 0.65rem;
        border-radius: var(--radius-sm);
        background: var(--surface);
        color: var(--ink);
        border: 1px solid var(--line);
        box-shadow: 0 0.35rem 1.25rem rgba(0, 0, 0, 0.18);
    }
    [data-theme='dark'] .summary-note-popover {
        box-shadow: 0 0.35rem 1.25rem rgba(0, 0, 0, 0.45);
    }
    .summary-note-popover__close {
        position: absolute;
        top: 0.25rem;
        right: 0.2rem;
        width: 1.75rem;
        height: 1.75rem;
        margin: 0;
        padding: 0;
        border: none;
        border-radius: var(--radius-xs);
        background: transparent;
        color: var(--faint);
        font-size: 1.35rem;
        line-height: 1;
        cursor: pointer;
    }
    .summary-note-popover__close:hover {
        color: var(--ink);
        background: var(--bg-subtle);
    }
    .summary-note-popover__body {
        margin: 0;
        font-size: 0.8125rem;
        line-height: 1.45;
        font-weight: 400;
        white-space: pre-wrap;
        word-break: break-word;
    }

    .day-vote-grid {
        display: grid;
        gap: 0.75rem;
        align-items: stretch;
        grid-template-columns: repeat(auto-fill, minmax(11.25rem, 1fr));
    }
    .day-vote-card {
        margin: 0;
        padding: 0.875rem;
        border: var(--border-surface);
        border-radius: var(--radius-md);
        background: var(--surface-elevated-bg);
        box-shadow: var(--shadow-xs);
        transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
        display: flex;
        flex-direction: column;
        min-height: 100%;
        min-width: 0;
    }
    .day-vote-card:focus-within {
        border-color: var(--accent);
        box-shadow: var(--shadow-sm);
    }
    .radio-line {
        display: flex; align-items: center; gap: 0.375rem;
        font-size: 0.8125rem; margin: 0.25rem 0; cursor: pointer;
    }
    .radio-line input { width: auto; height: auto; min-height: auto; margin: 0; }

    /* ── Availability: four colour-coded buttons per day ── */
    .availability-hint {
        display: block;
        margin: 0 0 0.25rem;
        font-size: 0.875rem;
        line-height: 1.45;
        max-width: 40rem;
    }
    .availability-intro { font-size: 0.8125rem; line-height: 1.45; max-width: 40rem; }
    .availability-heading__meta { font-size: 0.8125rem; margin-top: 0.25rem; }
    .availability-window-closed__cd-value {
        margin-left: 0.35rem;
        font-family: var(--mono);
        font-variant-numeric: tabular-nums;
        font-weight: 700;
    }
    .availability-form-body[inert] {
        opacity: 0.78;
    }
    .availability-heading__round {
        font-size: 0.875rem;
        font-weight: 600;
        margin-top: 0.25rem;
        max-width: 36rem;
        line-height: 1.45;
    }
    .availability-notes { margin-bottom: 1.25rem; }

    .availability-panel {
        display: flex;
        flex-direction: column;
        gap: 1.25rem;
    }
    .availability-panel .day-vote-calendar {
        margin: 0;
    }
    /* ISO weeks: each row is Mon → Sun (7 columns); multiple weeks stack vertically */
    .availability-collect .day-vote-scroll {
        margin-inline: -0.5rem;
        padding-inline: 0.5rem;
        padding-bottom: 0.35rem;
    }
    @media (min-width: 1100px) {
        .availability-collect .day-vote-scroll {
            margin-inline: 0;
            padding-inline: 0;
            padding-bottom: 0;
        }
    }
    .availability-collect .day-vote-calendar {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
        min-width: 0;
    }
    .availability-collect .day-vote-week {
        display: grid;
        grid-template-columns: repeat(7, minmax(0, 1fr));
        gap: 0.625rem;
        align-items: stretch;
        min-width: 0;
    }
    .availability-collect .day-vote-cell {
        min-width: 0;
        display: flex;
        flex-direction: column;
    }
    .availability-collect .day-vote-cell > .day-vote-card {
        flex: 1 1 auto;
        min-width: 0;
    }
    .availability-collect .day-vote-cell--empty {
        min-height: 0;
        pointer-events: none;
    }
    .availability-panel .day-vote-card {
        background: color-mix(in oklch, var(--bg-subtle) 50%, var(--surface));
        box-shadow: none;
        border-color: color-mix(in oklch, var(--line) 90%, var(--accent) 4%);
    }
    .availability-panel .day-vote-card:focus-within {
        box-shadow: var(--shadow-sm);
    }
    /* Weekend: same fill as weekdays; soft border + heading tint (no tinted panel background) */
    .availability-panel .day-vote-card--saturday {
        border-color: color-mix(in srgb, var(--accent) 12%, var(--ink));
    }
    .availability-panel .day-vote-card--saturday .day-vote-card__weekday {
        color: color-mix(in srgb, var(--accent) 32%, var(--muted));
        letter-spacing: 0.08em;
    }
    .availability-panel .day-vote-card--saturday .day-vote-card__date {
        color: color-mix(in srgb, var(--accent) 12%, var(--ink));
    }
    .availability-panel .day-vote-card--sunday {
        border-color: color-mix(in oklch, var(--danger) 38%, var(--ink));
    }
    .availability-panel .day-vote-card--sunday .day-vote-card__weekday {
        color: color-mix(in oklch, var(--danger) 52%, var(--muted));
        letter-spacing: 0.08em;
    }
    .availability-panel .day-vote-card--sunday .day-vote-card__date {
        color: color-mix(in oklch, var(--danger) 38%, var(--ink));
    }
    .availability-panel .availability-footer {
        margin-top: 0;
        padding-top: 1.25rem;
        border-top: 1px solid color-mix(in oklch, var(--line) 88%, var(--accent) 6%);
    }
    .availability-option-grid {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 0.5rem;
        flex: 1 1 auto;
        align-items: stretch;
        min-width: 0;
    }
    .availability-btn {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 3rem;
        margin: 0;
        padding: 0.55rem 0.65rem;
        width: 100%;
        border: 1px solid var(--line);
        border-radius: var(--radius-sm);
        cursor: pointer;
        text-align: center;
        -webkit-tap-highlight-color: transparent;
        transition:
            background 0.18s var(--ease-out),
            border-color 0.18s var(--ease-out),
            color 0.18s var(--ease-out),
            box-shadow 0.18s var(--ease-out);
    }
    .availability-btn:active { opacity: 0.92; }
    .availability-btn input {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
    .availability-btn:focus-within {
        outline: 2px solid var(--accent);
        outline-offset: 1px;
    }
    .availability-btn__text {
        font-size: 0.8125rem;
        font-weight: 700;
        line-height: 1.35;
        text-align: center;
        text-wrap: balance;
        padding-inline: 0.15rem;
    }
    .availability-btn__short {
        display: none;
    }

    /* Idle: same neutral grey; hover (fine pointers): tinted preview; checked: solid */
    .availability-btn--green,
    .availability-btn--red {
        background: color-mix(in oklch, var(--bg-subtle) 72%, var(--surface));
        border-color: var(--line);
        color: var(--muted);
        box-shadow: none;
    }

    @media (hover: hover) {
        .availability-btn--green:hover:not(:has(input:checked)) {
            background: color-mix(in oklch, var(--good) 24%, var(--surface));
            border-color: color-mix(in oklch, var(--good) 45%, var(--line));
            color: color-mix(in oklch, var(--good) 25%, var(--ink));
        }
        .availability-btn--red:hover:not(:has(input:checked)) {
            background: color-mix(in oklch, var(--danger) 22%, var(--surface));
            border-color: color-mix(in oklch, var(--danger) 44%, var(--line));
            color: color-mix(in oklch, var(--danger) 28%, var(--ink));
        }
    }

    .availability-btn--green:has(input:checked) {
        background: var(--good);
        border-color: color-mix(in oklch, var(--good) 85%, #000);
        color: #fff;
        box-shadow: inset 0 -1px 0 rgb(0 0 0 / 0.12);
    }
    .availability-btn--red:has(input:checked) {
        background: var(--danger);
        border-color: color-mix(in oklch, var(--danger) 82%, #000);
        color: #fff;
        box-shadow: inset 0 -1px 0 rgb(0 0 0 / 0.15);
    }

    fieldset.day-vote-card.day-vote-card--compact {
        padding: 0.75rem 0.875rem;
    }
    .day-vote-card__title {
        margin: 0 0 0.75rem;
        padding: 0;
        display: flex;
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: flex-start;
        gap: 0.125rem;
        line-height: 1.2;
        min-height: 2.65rem;
        width: 100%;
    }
    .day-vote-card__weekday {
        font-size: 0.6875rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.07em;
        color: var(--muted);
    }
    .day-vote-card__date {
        font-size: 1.0625rem;
        font-weight: 800;
        letter-spacing: -0.02em;
        color: var(--ink);
    }

    .day-vote-bands {
        display: flex;
        flex-direction: column;
        gap: 0.65rem;
        width: 100%;
        min-width: 0;
    }
    .day-vote-band__head {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        justify-content: space-between;
        gap: 0.25rem 0.5rem;
        margin-bottom: 0.35rem;
    }
    .day-vote-band__name {
        font-size: 0.6875rem;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: var(--ink-secondary);
    }
    .day-vote-band__hours {
        font-size: 0.625rem;
        font-weight: 600;
    }
    .availability-option-grid--band {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.375rem;
    }
    .availability-option-grid--band .availability-btn {
        min-height: 2.65rem;
        padding: 0.4rem 0.45rem;
    }
    .availability-option-grid--band .availability-btn__text {
        font-size: 0.75rem;
    }

    .summary-grid__bands {
        text-align: center;
        font-variant-numeric: tabular-nums;
        font-weight: 700;
        font-size: 0.8125rem;
        letter-spacing: 0.02em;
        white-space: nowrap;
    }

    .availability-footer {
        display: grid;
        gap: 0.75rem;
        margin-top: 0.5rem;
    }
    .availability-comment-label { display: grid; gap: 0.375rem; }
    .availability-comment-label__text { font-weight: 600; font-size: 0.8125rem; }
    .availability-save {
        min-height: 2.5rem;
        font-size: 0.9375rem;
        font-weight: 700;
    }

    .availability-period-list .availability-period-card,
    .availability-index-body a.availability-period-card {
        align-items: flex-start;
        gap: 0.75rem;
    }
    .availability-period-card__badges {
        flex-shrink: 0;
        padding-top: 0.125rem;
        line-height: 0;
    }
    .availability-index-body {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        padding: 1rem 1.125rem;
    }
    .availability-index-body .availability-period-card {
        margin: 0;
    }
    .availability-index-empty {
        margin: 0;
        padding: 0.5rem 0;
        line-height: 1.45;
    }
    .availability-period-card__main {
        display: grid;
        gap: 0.25rem;
        min-width: 0;
    }
    .availability-period-card__title { font-size: 1rem; line-height: 1.3; }
    .availability-period-card__meta {
        font-size: 0.8125rem;
        line-height: 1.45;
    }
    .availability-period-card__window {
        display: block;
        font-size: 0.75rem;
        line-height: 1.4;
        margin-top: 0.125rem;
    }
    .availability-period-card__cta { flex-shrink: 0; }

    /* ── Checklist ── */
    .checklist { display: grid; gap: 0.5rem; }
}

/* ───────── CALENDAR ───────── */
@layer calendar {
    .cal-heading-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
    .cal-scroll-hint {
        display: none;
        margin: 0;
        text-align: center;
        line-height: 1.45;
    }
    .cal-heading-meta { display: grid; justify-items: end; gap: 0.35rem; }
    .cal-view-row { display: flex; gap: 0.375rem; }

    .cal-toolbar {
        display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center;
        padding: 0.75rem 1rem; margin-bottom: 1.25rem;
        background: var(--surface-elevated-bg); border: var(--border-surface);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-xs);
    }
    .cal-mode-row { display: flex; gap: 0.375rem; }
    .cal-staff-filter { margin-left: auto; }
    .cal-staff-filter select { height: 2.25rem; min-width: 12rem; font-size: 0.8125rem; }

    .cal-wrap {
        overflow-x: auto; border-radius: var(--radius-lg);
        border: var(--border-surface); background: var(--surface-elevated-bg);
        box-shadow: var(--shadow-sm);
    }
    .cal-table {
        width: 100%; min-width: 48rem;
        border-collapse: separate; border-spacing: 0;
        table-layout: fixed;
    }
    .cal-day-head {
        padding: 0.625rem 0.25rem;
        font-size: 0.6875rem; font-weight: 700; text-transform: uppercase;
        letter-spacing: 0.06em; color: var(--muted);
        border-bottom: 1px solid var(--line); text-align: center;
        background: var(--bg-subtle);
    }
    .cal-day {
        vertical-align: top;
        border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
        padding: 0.375rem; width: 14.28%;
        height: 8.75rem;
        transition: background var(--dur) var(--ease-out);
    }
    .cal-day-inner {
        display: flex;
        flex-direction: column;
        min-height: 100%;
        height: 100%;
    }
    .cal-day:last-child { border-right: 0; }
    .cal-day:hover { background: var(--bg-subtle); }
    .cal-day--muted { color: var(--faint); }
    .cal-day--muted .cal-day-num { opacity: 0.4; }
    .cal-day--today { background: var(--accent-surface); }
    .cal-day--today .cal-day-num {
        display: inline-flex; align-items: center; justify-content: center;
        width: 1.5rem; height: 1.5rem; border-radius: 50%;
        background: var(--accent); color: #fff;
    }
    .cal-day-num {
        font-weight: 800; font-size: 0.75rem;
        margin-bottom: 0.25rem; line-height: 1;
        flex-shrink: 0;
    }
    .cal-day-patterns {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: stretch;
        gap: 1px;
    }
    .cal-day-patterns--weekend {
        opacity: 0.72;
    }
    .cal-day-pattern {
        flex: 1;
        min-height: 0;
        border-radius: 0.1875rem;
        display: flex;
        align-items: center;
        padding: 0.0625rem 0.1875rem;
    }
    .cal-day-pattern--morning {
        background: color-mix(in oklch, #3b82f6 14%, var(--surface-elevated-bg));
    }
    .cal-day-pattern--lunch {
        background: color-mix(in oklch, #eab308 12%, var(--surface-elevated-bg));
    }
    .cal-day-pattern--afternoon {
        background: color-mix(in oklch, #a855f7 12%, var(--surface-elevated-bg));
    }
    .cal-day-pattern__disks {
        display: flex;
        flex-wrap: wrap;
        gap: 0.125rem;
        align-content: center;
        justify-content: flex-start;
    }
    .cal-staff-disk {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 1.35rem;
        height: 1.35rem;
        padding: 0;
        border-radius: 50%;
        font-size: 0.5rem;
        font-weight: 900;
        line-height: 1;
        letter-spacing: -0.02em;
        color: #fff;
        flex-shrink: 0;
        box-sizing: border-box;
    }
    a.cal-staff-disk {
        text-decoration: none;
        color: inherit;
        cursor: pointer;
    }
    a.cal-staff-disk:focus-visible {
        outline: 2px solid color-mix(in oklch, #fff 75%, var(--accent));
        outline-offset: 1px;
        z-index: 1;
    }
    .cal-staff-disk--sm {
        width: 1.125rem;
        height: 1.125rem;
        font-size: 0.4375rem;
    }
    .cal-staff-disk--absence {
        box-shadow: 0 0 0 2px color-mix(in oklch, var(--warn) 85%, var(--line));
    }
    .cal-staff-disk--c0 { background: #2563eb; color: #fff; }
    .cal-staff-disk--c1 { background: #059669; color: #fff; }
    .cal-staff-disk--c2 { background: #d97706; color: #fff; }
    .cal-staff-disk--c3 { background: #dc2626; color: #fff; }
    .cal-staff-disk--c4 { background: #7c3aed; color: #fff; }
    .cal-staff-disk--c5 { background: #0d9488; color: #fff; }
    .cal-staff-disk--c6 { background: #db2777; color: #fff; }
    .cal-staff-disk--c7 { background: #475569; color: #fff; }
    /* College role (DB / AB / FT / C): match staff_college_role_short_label */
    .cal-staff-disk--cr-db { background: #c62828; color: #fff; }
    .cal-staff-disk--cr-ab { background: #2e7d32; color: #fff; }
    .cal-staff-disk--cr-ft { background: #111; color: #fff; }
    .cal-staff-disk--cr-c { background: #1565c0; color: #fff; }
    .cal-events { display: flex; flex-direction: column; gap: 0.1875rem; }
    .cal-event {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.0625rem;
        font-size: 0.625rem; line-height: 1.3;
        padding: 0.1875rem 0.3125rem; border-radius: var(--radius-xs);
        background: var(--accent-surface); color: var(--accent-ink);
        border-left: 2px solid var(--accent);
        transition: transform var(--dur) var(--ease-out);
        overflow: hidden;
    }
    .cal-event:hover { transform: scale(1.02); }
    a.cal-event {
        display: flex;
        flex-direction: column;
        text-decoration: none;
        color: inherit;
    }
    a.cal-event:hover { transform: scale(1.02); }
    a.cal-event:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }
    .cal-event-time { font-weight: 800; }
    .cal-event-what { display: block; color: var(--muted); font-weight: 600; }
    .cal-event-role { display: block; color: var(--faint); font-weight: 500; font-size: 0.5625rem; }

    .cal-staff-bubble {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        align-self: center;
        min-width: 1.65rem;
        height: 1.65rem;
        padding: 0 0.35rem;
        margin: 0.08rem 0;
        border-radius: 999px;
        background: color-mix(in srgb, var(--accent) 22%, var(--surface));
        border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--line));
        color: var(--accent-ink);
        font-size: 0.5rem;
        font-weight: 800;
        line-height: 1;
        text-align: center;
        max-width: 95%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        box-sizing: border-box;
    }
    .cal-staff-bubble--month {
        min-width: 1.75rem;
        height: 1.75rem;
    }
    .cal-staff-bubble--warn {
        background: color-mix(in oklch, var(--warn) 24%, var(--surface));
        border-color: color-mix(in oklch, var(--warn) 48%, var(--line));
        color: var(--warn-ink);
    }
    .cal-staff-bubble--tg {
        min-width: 1.45rem;
        height: 1.45rem;
        font-size: 0.4375rem;
        margin: 0;
    }
    .cal-staff-bubble--chip {
        min-width: 1.35rem;
        height: 1.35rem;
        font-size: 0.4rem;
        margin-bottom: 0.0625rem;
    }
    .cal-tg-event-bubble-row {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        gap: 0.125rem;
        width: 100%;
    }
    .cal-event--absence {
        background: var(--warn-surface);
        color: var(--warn-ink);
        border-left-color: var(--warn);
    }
    .cal-event--absence .cal-event-abs-pill { font-weight: 900; font-variant-numeric: tabular-nums; }
    .cal-event--absence .cal-event-what,
    .cal-event--absence .cal-event-role {
        color: color-mix(in oklch, var(--warn-ink) 75%, var(--muted));
    }

    /* Week/Day time-grid */
    .cal-timegrid-wrap{
        overflow-x: auto;
        border-radius: var(--radius-lg);
        border: var(--border-surface);
        background: var(--surface-elevated-bg);
        box-shadow: var(--shadow-sm);
    }
    .cal-timegrid{
        display: flex;
        flex-direction: column;
        min-width: 56rem;
    }
    .cal-timegrid.is-day{ min-width: 26rem; }
    /* Day view: two columns (morning / afternoon) */
    .cal-timegrid.is-day-bands {
        min-width: min(100%, 52rem);
    }
    .cal-timegrid.is-day-bands .cal-allday-lane {
        grid-template-columns: 4.25rem minmax(0, 1fr);
        min-width: 0;
    }
    .cal-day-bands-wrap {
        overflow-x: auto;
        border-radius: var(--radius-lg);
        border: var(--border-surface);
        background: var(--surface-elevated-bg);
        box-shadow: var(--shadow-sm);
    }
    .cal-day-bands-head {
        display: grid;
        grid-template-columns: 4.25rem minmax(0, 1fr);
        border-bottom: 1px solid var(--line);
        background: var(--bg-subtle);
        min-height: 3rem;
        align-items: center;
    }
    .cal-day-bands-corner {
        border-right: 1px solid var(--line);
        min-height: 100%;
    }
    .cal-day-bands-datepill {
        padding: 0.5rem 0.75rem;
        display: flex;
        flex-direction: column;
        gap: 0.125rem;
    }
    .cal-day-bands-datepill.is-today .cal-day-bands-dow,
    .cal-day-bands-datepill.is-today .cal-day-bands-ymd {
        color: var(--accent);
    }
    .cal-day-bands-dow {
        font-size: 0.6875rem;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: var(--muted);
    }
    .cal-day-bands-ymd {
        font-size: 1rem;
        font-weight: 800;
        letter-spacing: -0.02em;
    }
    .cal-day-bands {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.75rem;
        padding: 0.75rem;
        align-items: stretch;
    }
    .cal-day-band {
        min-width: 0;
        border-radius: var(--radius-md);
        border: var(--border-surface);
        background: color-mix(in oklch, var(--surface) 94%, var(--bg-subtle));
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    .cal-day-band--morning {
        border-top: 3px solid color-mix(in oklch, var(--accent) 40%, var(--line));
    }
    .cal-day-band--lunch {
        border-top: 3px solid color-mix(in oklch, #f59e0b 45%, var(--line));
    }
    .cal-day-band--afternoon {
        border-top: 3px solid color-mix(in oklch, #a855f7 45%, var(--line));
    }
    .cal-day-band__body {
        padding: 0.5rem;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        flex: 1;
        min-height: 4rem;
    }
    .cal-day-band__empty {
        margin: 0;
        font-size: 0.8125rem;
        padding: 0.25rem 0;
    }
    .cal-day-bands-global-empty {
        margin: 0;
        padding: 1rem 1rem 1.25rem;
        text-align: center;
        font-size: 0.875rem;
    }
    .cal-day-band-card {
        display: block;
        border-radius: var(--radius-sm);
        padding: 0.45rem 0.55rem;
        border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
        border-left: 3px solid var(--accent);
        background: var(--accent-surface);
        box-shadow: var(--shadow-xs);
        text-decoration: none;
        color: inherit;
        box-sizing: border-box;
    }
    a.cal-day-band-card:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }
    .cal-day-band-card--absence {
        border-color: color-mix(in oklch, var(--warn) 35%, var(--line));
        border-left-color: var(--warn);
        background: var(--warn-surface);
    }
    .cal-day-band-card__staff {
        display: flex;
        flex-wrap: wrap;
        gap: 0.125rem;
        margin: 0;
        justify-content: flex-start;
    }
    .cal-day-band-card__role {
        font-size: 0.6875rem;
        font-weight: 600;
        margin-top: 0.125rem;
    }
    .cal-day-band-card--absence .cal-day-band-card__role {
        color: var(--warn-ink);
    }
    @media (max-width: 768px) {
        .cal-day-bands {
            grid-template-columns: 1fr;
        }
    }

    .cal-allday-lane {
        display: grid;
        grid-template-columns: 4.25rem repeat(var(--tg-days, 7), minmax(9rem, 1fr));
        min-width: 56rem;
        border-bottom: 1px solid var(--line);
        background: color-mix(in oklch, var(--warn) 8%, var(--surface));
    }
    .cal-timegrid.is-day .cal-allday-lane { min-width: 26rem; }
    .cal-allday-corner {
        border-right: 1px solid var(--line);
        background: var(--bg-subtle);
        min-height: var(--cal-abs-lane, auto);
    }
    .cal-allday-cell {
        border-left: 1px solid var(--line);
        min-height: var(--cal-abs-lane, auto);
        padding: 0.25rem 0.35rem;
        display: flex;
        flex-direction: column;
        gap: 0.1875rem;
        justify-content: flex-start;
        background: color-mix(in oklch, var(--warn) 5%, transparent);
    }
    .cal-abs-chip {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.0625rem;
        padding: 0.125rem 0.25rem;
        border-radius: 0.3125rem;
        font-size: 0.5625rem;
        line-height: 1.25;
        font-weight: 800;
        background: var(--warn-surface);
        color: var(--warn-ink);
        border: 1px solid color-mix(in oklch, var(--warn) 35%, var(--line));
        border-left: 2px solid var(--warn);
        overflow: hidden;
    }
    .cal-abs-chip-type { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 900; text-transform: capitalize; }
    .cal-abs-chip-st { font-size: 0.5rem; font-weight: 700; opacity: 0.9; text-transform: capitalize; }

    a.cal-abs-chip-link {
        display: block;
        text-decoration: none;
        color: inherit;
        border-radius: 0.3125rem;
    }
    a.cal-abs-chip-link:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }
    a.cal-abs-chip-link:hover .cal-abs-chip {
        filter: brightness(0.97);
        box-shadow: var(--shadow-xs);
    }

    .cal-tg-head{
        display: grid;
        grid-template-columns: 4.25rem repeat(var(--tg-days, 7), minmax(9rem, 1fr));
        border-bottom: 1px solid var(--line);
        background: var(--bg-subtle);
        position: sticky;
        top: 0;
        z-index: 2;
    }
    .cal-tg-corner{ height: 3rem; }
    .cal-tg-dayhead{
        height: 3rem;
        display: grid;
        place-items: center;
        border-left: 1px solid var(--line);
        color: var(--ink-secondary);
    }
    .cal-tg-dayhead.is-today{
        background: color-mix(in srgb, var(--accent) 10%, transparent);
        color: var(--accent);
    }
    .cal-tg-dayname{ font-size: 0.6875rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
    .cal-tg-daynum{ font-size: 0.875rem; font-weight: 900; margin-top: -0.125rem; }

    .cal-tg-body{
        display: grid;
        grid-template-columns: 4.25rem repeat(var(--tg-days, 7), minmax(9rem, 1fr));
    }
    .cal-tg-times{
        position: relative;
        border-right: 1px solid var(--line);
        background: linear-gradient(to bottom, transparent 0, transparent 71px, color-mix(in oklch, var(--line) 60%, transparent) 72px) repeat-y;
        background-size: 100% 72px;
    }
    .cal-tg-time{
        height: 72px;
        padding: 0.125rem 0.5rem 0 0.5rem;
        font-size: 0.625rem;
        font-weight: 800;
        color: var(--muted);
        font-variant-numeric: tabular-nums;
        text-align: right;
    }
    .cal-tg-col{
        position: relative;
        border-left: 1px solid var(--line);
        background: linear-gradient(to bottom, transparent 0, transparent 71px, color-mix(in oklch, var(--line) 60%, transparent) 72px) repeat-y;
        background-size: 100% 72px;
    }
    .cal-tg-hourline{
        position: absolute;
        left: 0; right: 0;
        height: 1px;
        background: color-mix(in oklch, var(--line) 75%, transparent);
        opacity: 0.7;
        pointer-events: none;
        z-index: 1;
    }
    .cal-tg-event,
    a.cal-tg-event {
        position: absolute;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.0625rem;
        left: 0.375rem;
        right: 0.375rem;
        border-radius: var(--radius-md);
        background: var(--accent-surface);
        border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line));
        border-left: 3px solid var(--accent);
        padding: 0.375rem 0.5rem;
        overflow: hidden;
        box-shadow: var(--shadow-xs);
        z-index: 2;
    }
    a.cal-tg-event {
        text-decoration: none;
        color: inherit;
        box-sizing: border-box;
    }
    a.cal-tg-event:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 1px;
        z-index: 3;
    }
    .cal-tg-event--disks-only {
        justify-content: center;
        align-items: center;
        padding: 0.25rem 0.35rem;
        gap: 0;
    }
    .cal-tg-event--disks-only .cal-tg-event-bubble-row {
        flex-direction: column;
        flex-wrap: nowrap;
        justify-content: center;
        align-items: center;
        gap: 0.125rem;
        width: 100%;
    }
    .cal-timegrid.is-day .cal-staff-disk--fullname {
        width: auto;
        min-width: 0;
        max-width: 100%;
        height: auto;
        min-height: 1.1rem;
        padding: 0.1875rem 0.45rem;
        border-radius: 999px;
        font-size: 0.5625rem;
        font-weight: 800;
        line-height: 1.2;
        letter-spacing: 0;
        white-space: normal;
        word-break: break-word;
        text-align: center;
        hyphens: auto;
        overflow-wrap: anywhere;
    }
    .cal-tg-event-time{ font-size: 0.625rem; font-weight: 900; color: var(--accent-ink); font-variant-numeric: tabular-nums; }
    .cal-tg-event-title{ font-size: 0.75rem; font-weight: 900; color: var(--ink); margin-top: 0.125rem; }
    .cal-tg-event-sub{ font-size: 0.6875rem; font-weight: 700; color: var(--muted); margin-top: 0.125rem; }
    .cal-tg-event--absence {
        background: var(--warn-surface);
        border-color: color-mix(in oklch, var(--warn) 30%, var(--line));
        border-left-color: var(--warn);
    }
    .cal-tg-event--absence .cal-tg-event-time { color: var(--warn-ink); }
    .cal-tg-event--absence .cal-tg-event-title,
    .cal-tg-event--absence .cal-tg-event-sub { color: var(--warn-ink); }
    .cal-tg-event--draft-preview {
        background: color-mix(in oklch, var(--warn-surface) 40%, var(--accent-surface));
        border-style: dashed;
        border-color: color-mix(in oklch, var(--warn) 35%, var(--line));
        border-left-style: solid;
        border-left-color: color-mix(in oklch, var(--warn) 65%, var(--accent));
        opacity: 0.98;
    }
    a.cal-tg-event--draft-preview:focus-visible {
        outline-color: color-mix(in oklch, var(--warn) 50%, var(--accent));
    }
    .cal-staff-disk--draft-preview {
        box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--warn) 55%, transparent);
    }
    .cal-draft-preview-row {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.5rem 0.75rem;
        margin-top: 0.25rem;
    }
    .cal-draft-preview-hint {
        font-size: 0.8125rem;
    }
    .cal-empty{ padding: 0.75rem; }
}

/* ───────── UTILITIES ───────── */
@layer utilities {
    @media (max-width: 768px) {
        body.is-mobile-menu-open {
            overflow: hidden;
            touch-action: none;
        }
        .topbar {
            height: 3rem;
            padding: 0 0.75rem;
            gap: 0.5rem;
        }
        .brand {
            margin-right: 0.35rem;
            min-width: 0;
            /* Leave room for menu + user + sign out */
            max-width: calc(100% - 10.5rem);
        }
        .brand-logo {
            height: 2.125rem;
            width: auto;
            max-width: 100%;
            object-fit: contain;
            object-position: left center;
        }
        .nav { display: none; }
        .topbar-actions .ghost {
            height: 2rem;
            padding: 0 0.75rem;
            font-size: 0.75rem;
        }
        .topbar-menu-btn { display: flex; }
        .theme-switch__btn {
            width: 2.25rem;
            min-width: 2.25rem;
            height: 1.95rem;
        }
        .theme-switch__svg { width: 15px; height: 15px; }

        /* ── Shell & content spacing ── */
        .shell {
            margin-top: 1rem;
            margin-bottom: 1rem;
            overflow-x: clip;
        }
        .panel, .stat-card, .day-card { padding: 1rem; border-radius: var(--radius-md); }
        .panel.rota-draft-add-panel {
            padding-top: 1.625rem;
        }
        .panel h2 { margin-bottom: 0.625rem; }
        .panel.rota-draft-add-panel > h2 {
            margin-bottom: 0.8125rem;
        }
        .grid { gap: 0.75rem; }

        /* ── Layout stacking ── */
        .two, .form-grid, .builder-layout { grid-template-columns: minmax(0, 1fr); }
        .directory-layout { grid-template-columns: 1fr; }
        .warning-panel { position: static; order: -1; }

        /* ── Page headings ── */
        .page-heading {
            flex-direction: column;
            align-items: stretch;
            gap: 0.75rem;
            margin-bottom: 1rem;
            padding: 1rem 1.1rem;
        }
        .page-actions {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
            gap: 0.5rem;
        }
        .page-actions .button,
        .page-actions a.button,
        .page-actions .primary,
        .page-actions .ghost {
            width: 100%;
            justify-content: center;
            min-height: 2.75rem;
        }

        /* ── Users page: create form + roster table (mobile) ── */
        .users-page #create-user-form .primary.full {
            width: 100%;
            min-height: 2.75rem;
        }
        .users-page label.chip.chip--multiline {
            display: flex;
            width: 100%;
            max-width: none;
            align-items: flex-start;
            gap: 0.5rem;
            padding: 0.625rem 0.75rem;
        }
        .users-page label.chip.chip--multiline > span {
            flex: 1;
            min-width: 0;
            line-height: 1.4;
        }
        .users-table-wrap {
            -webkit-overflow-scrolling: touch;
            overscroll-behavior-x: contain;
            max-width: 100%;
        }
        .users-table-wrap table {
            min-width: 0;
            width: 100%;
        }
        .users-table-wrap th,
        .users-table-wrap td {
            padding: 0.5rem 0.625rem;
            font-size: 0.75rem;
            vertical-align: top;
        }
        .users-table-wrap td .row-actions {
            justify-content: flex-start;
        }
        .users-table-wrap .row-actions .button,
        .users-table-wrap .row-actions .ghost {
            white-space: normal;
            text-align: center;
            line-height: 1.2;
        }

        /* ── Staff home ── */
        .staff-home-hero {
            padding: 1.125rem 1.15rem;
        }
        .staff-home-grid {
            grid-template-columns: 1fr;
            gap: 0.75rem;
            margin-bottom: 1.5rem;
        }
        .staff-home-tile {
            padding: 1rem 1.1rem;
            min-height: 0;
        }
        .staff-home-tile:hover {
            transform: none;
        }
        .staff-home-tile__icon {
            width: 3rem;
            height: 3rem;
        }
        .staff-home-ico-svg {
            width: 1.5rem;
            height: 1.5rem;
        }
        .staff-home-tile:hover .staff-home-tile__go {
            transform: none;
        }

        /* ── Stats: 2-up grid ── */
        .stat-grid {
            grid-template-columns: repeat(2, 1fr);
            gap: 0.5rem;
            margin-bottom: 1rem;
        }
        .stat-card {
            padding: 0.75rem 0.875rem;
        }
        .stat-card strong { font-size: 1.5rem; }

        /* ── List rows: taller for touch ── */
        .list-row {
            padding: 0.875rem 0.875rem;
            gap: 0.625rem;
        }
        a.list-row:hover,
        a.list-row:active { transform: none; }

        /* ── Lifecycle: horizontal scroll ── */
        .lifecycle {
            flex-wrap: nowrap;
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
            gap: 0.375rem;
            padding: 0.625rem;
            margin-bottom: 1rem;
            scrollbar-width: thin;
        }
        .lifecycle-step { flex: 0 0 auto; }

        /* ── Calendar toolbar ── */
        .cal-toolbar {
            flex-direction: column;
            align-items: stretch;
            padding: 0.75rem;
            gap: 0.625rem;
        }
        .cal-staff-filter { margin-left: 0; }
        .cal-staff-filter select { min-width: 0; width: 100%; height: 2.75rem; }
        .cal-heading-meta { width: 100%; justify-items: stretch; }
        .cal-heading-actions {
            display: grid;
            grid-template-columns: 1fr 1fr 1fr;
            gap: 0.375rem;
            width: 100%;
        }
        .cal-heading-actions .button { justify-content: center; min-height: 2.75rem; }
        .cal-view-row {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 0.375rem; width: 100%;
        }
        .cal-view-row .button,
        .cal-mode-row .button { justify-content: center; width: 100%; min-height: 2.75rem; }
        .cal-mode-row {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 0.375rem; width: 100%;
        }

        /* ── Calendar grid ── */
        .cal-wrap,
        .cal-timegrid-wrap {
            -webkit-overflow-scrolling: touch;
            overscroll-behavior-x: contain;
        }
        .cal-scroll-hint {
            display: block;
            font-size: 0.8125rem;
            margin: -0.375rem 0 0.75rem;
            padding: 0 0.25rem;
        }

        /* ── Availability: compact colour buttons ── */
        .availability-hint { font-size: 0.8125rem; }
        .availability-heading--index .availability-intro { font-size: 0.875rem; }
        .availability-heading .availability-back {
            width: 100%;
            justify-content: center;
            min-height: 2.5rem;
        }
        .availability-collect .day-vote-scroll {
            overflow-x: visible;
            margin-inline: 0;
            padding-inline: 0;
            padding-bottom: 0.35rem;
        }
        .availability-collect .day-vote-calendar {
            gap: 0.875rem;
        }
        /* One day per row on small screens; calendar week row is for large screens only */
        .availability-collect .day-vote-week {
            display: grid;
            grid-template-columns: 1fr;
            width: 100%;
            max-width: none;
            gap: 0.625rem;
        }
        .availability-collect .day-vote-cell--empty {
            display: none !important;
        }
        .availability-collect fieldset.day-vote-card {
            scroll-margin-top: 0.75rem;
        }
        .availability-collect .day-vote-card__title {
            min-height: 2.5rem;
            margin-bottom: 0.625rem;
        }
        .availability-collect .day-vote-card__weekday {
            font-size: 0.625rem;
        }
        .availability-collect .day-vote-card__date {
            font-size: 1.125rem;
        }
        /* Vote UI: side-by-side + short labels — stacked full-width felt huge (3 bands × 2 rows) */
        .availability-collect .availability-btn__short {
            display: inline;
        }
        .availability-collect .availability-btn__long {
            display: none;
        }
        .availability-collect .day-vote-bands {
            gap: 0.45rem;
        }
        .availability-collect .day-vote-band__head {
            margin-bottom: 0.2rem;
        }
        .availability-collect .day-vote-band__name {
            font-size: 0.625rem;
        }
        .availability-collect .day-vote-band__hours {
            font-size: 0.5625rem;
        }
        .availability-collect .availability-option-grid--band {
            gap: 0.3rem;
        }
        .availability-collect .availability-option-grid--band .availability-btn {
            min-height: 2.375rem;
            padding: 0.28rem 0.3rem;
            border-radius: var(--radius-xs);
            touch-action: manipulation;
        }
        .availability-collect .availability-option-grid--band .availability-btn__text {
            font-size: 0.6875rem;
            font-weight: 750;
            line-height: 1.2;
        }
        .availability-collect .availability-comment {
            min-height: 4.5rem;
        }
        .availability-collect .availability-submit-wrap {
            position: sticky;
            bottom: calc(4.25rem + env(safe-area-inset-bottom, 0px));
            z-index: 10;
            margin-top: 0.25rem;
            padding-top: 0.75rem;
            margin-inline: -1rem;
            padding-inline: 1rem;
            background: color-mix(in oklch, var(--surface-elevated-bg) 92%, transparent);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border-top: 1px solid color-mix(in oklch, var(--line) 88%, var(--accent) 6%);
        }
        .availability-collect .availability-save {
            min-height: 2.75rem;
        }
        .availability-period-card {
            min-height: 3.75rem;
            padding: 0.875rem 1rem;
        }
        .availability-period-card__title { font-size: 1rem; }
        .availability-period-card__meta { font-size: 0.8125rem; }

        /* ── Builder / service cards ── */
        .builder-toolbar { margin-bottom: 0.75rem; }
        .assign-form { gap: 0.625rem; }
        /* Keep Reason + remove on one row; input grows, button stays fixed width */
        .unassign-form { flex-wrap: nowrap; align-items: center; gap: 0.5rem; flex: 1 1 auto; min-width: 0; justify-content: flex-end; }
        .btn-icon { width: 2.5rem; height: 2.5rem; }
        .service-card { padding: 0.875rem; scroll-margin-top: 5.5rem; }
        .builder-main > .panel {
            min-width: 0;
            max-width: 100%;
        }
        /* Date/time: no decorative icon; grid + min-height avoids collapsed fields on mobile */
        .picker {
            overflow: hidden;
            border-radius: var(--radius-sm);
            min-width: 0;
        }
        .picker > input {
            min-height: 2.5rem;
            width: 100%;
            min-width: 0;
        }
        .picker input[type="date"]::-webkit-datetime-edit,
        .picker input[type="date"]::-webkit-datetime-edit-fields-wrapper,
        .picker input[type="time"]::-webkit-datetime-edit,
        .picker input[type="time"]::-webkit-datetime-edit-fields-wrapper {
            min-width: 0;
            max-width: 100%;
        }
        .picker input[type="date"]::-webkit-datetime-edit-fields-wrapper,
        .picker input[type="time"]::-webkit-datetime-edit-fields-wrapper {
            overflow: hidden;
        }
        input[type="date"]::-webkit-calendar-picker-indicator,
        input[type="time"]::-webkit-calendar-picker-indicator {
            flex-shrink: 0;
            width: 1.25rem;
            height: 1.25rem;
            margin-inline: 0 0.125rem;
            margin-block: 0;
            padding: 0;
        }
        .toolbar-cluster.shift-presets .ghost.sm {
            flex: 1 1 auto;
            justify-content: center;
            min-height: 2.25rem;
        }

        /* Draft add panel — small screens: allow day tabs to wrap with row gap */
        .rota-draft-add-panel .rota-day-tabs {
            flex-wrap: wrap;
            row-gap: 0.625rem;
            column-gap: 0.5rem;
            overflow-x: visible;
            padding-bottom: 0;
        }
        .rota-draft-add-panel .rota-day-tab {
            flex: 1 1 auto;
            min-width: 3.85rem;
            align-items: flex-start;
            text-align: left;
            justify-content: center;
            font-size: 0.8125rem;
            line-height: 1.25;
            padding: 0.5rem 0.625rem;
        }
        .rota-draft-add-panel .rota-day-tab .rota-day-tab__sub {
            font-size: 0.6875rem;
        }

        .rota-draft-pattern-cards {
            grid-template-columns: 1fr;
        }

        /* ── Staff directory cards ── */
        .staff-directory-grid {
            grid-template-columns: 1fr;
        }
        .staff-directory-card__acts {
            flex-wrap: wrap;
            gap: 0.5rem;
        }

        /* ── Dock spacing (floating bar + safe area) ── */
        body { padding-bottom: calc(5.25rem + env(safe-area-inset-bottom, 0px)); }
    }

    @media (max-width: 768px) and (pointer: coarse) {
        /* Keep vote chips compact; primary save stays comfortable */
        .availability-collect .availability-option-grid--band .availability-btn {
            min-height: 2.5rem;
        }
        .availability-collect .availability-save {
            min-height: 2.875rem;
        }
    }

    /* Touch devices: prevent iOS zoom on input focus */
    @media (pointer: coarse) {
        input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="hidden"]),
        select,
        textarea {
            font-size: 1rem;
        }
        input, select { height: 2.75rem; }
    }

    @media (min-width: 769px) { body { padding-bottom: 0; } }

    .fade-in {
        animation: fadeIn var(--dur-lg) var(--ease-out);
    }
    @keyframes fadeIn {
        from { opacity: 0; transform: translateY(0.5rem); }
        to { opacity: 1; transform: translateY(0); }
    }
}
