/*
 * Milebud: base styles.
 *
 * The brand values are placeholders until the official Milebud palette and
 * logo are supplied; change them here only.
 */
:root {
    /* Colour (gap-closing Slice 7): every colour a rule uses is a token here,
       redefined for dark mode below, so a page is never half light and half
       dark. Text tokens meet WCAG 2.2 AA (4.5:1) on the surfaces they sit on
       in both themes; test/ui-tokens.test.ts checks the pairs. */
    color-scheme: light dark;
    --brand: #0f766e;
    --brand-strong: #115e59;
    --on-brand: #ffffff;
    --brand-soft: #ccfbf1;
    --focus-glow: rgba(15, 118, 110, 0.25);

    --canvas: #f5f6f8;
    --surface: #ffffff;
    --surface-hover: #fafbfc;
    --border: #e4e7ec;
    --ink: #1d2433;
    /* Darker than before: #667085 read at 4.4:1 on --brand-soft (a message
       of one's own) and only just passed on the grey surfaces. */
    --ink-muted: #5d6679;
    --topbar: #16181d;
    --on-topbar: #f2f4f7;
    --on-topbar-muted: rgba(242, 244, 247, 0.8);
    --topbar-hover: rgba(255, 255, 255, 0.12);
    --inverse: #101828;
    --on-inverse: #ffffff;
    --neutral-soft: #f2f4f7;

    --danger: #b42318;
    --on-danger: #ffffff;
    --danger-soft: #fef3f2;
    --danger-line: #fecdca;
    --success: #067647;
    --success-soft: #ecfdf3;
    --success-line: #abefc6;
    --warn: #b54708;
    --warn-soft: #fffaeb;
    --info: #175cd3;
    --info-soft: #eff8ff;
    --violet: #5925dc;
    --violet-soft: #f4f3ff;
    --indigo: #3538cd;
    --indigo-soft: #eef4ff;
    --pink: #c11574;
    --pink-soft: #fdf2fa;
    --orange: #b93815;
    --orange-soft: #fef6ee;
    --rose-soft: #fff1f3;
    --rose-line: #fecdd6;
    /* Marks that are not text (dots, bars, icons beside a label). */
    --mark-green: #12b76a;
    --mark-amber: #f79009;
    --mark-pink: #ee46bc;
    --mark-violet: #7a5af8;
    --mark-grey: #98a2b3;
    --mark-yellow: #fdb022;
    --mark-blue: #2e90fa;
    /* Two series side by side on one chart (income, costs): checked for colour vision and contrast in each theme. A third
       (a vehicle's tyres beside its fuel and repairs) is a teal of another lightness, at least 3:1 on the surface; the parts are
       drawn apart with a gap, since three colours cannot each hold 3:1 against both neighbours and the surface. */
    --chart-a: #3538cd;
    --chart-b: #b93815;
    --chart-c: #0e9384;
    /* The module tiles' backgrounds. */
    --tone-rose: #ffe4e6;
    --tone-amber: #fef3c7;
    --tone-pink: #fce7f3;
    --tone-orange: #ffedd5;
    --tone-lime: #ecfccb;
    --tone-green: #dcfce7;
    --tone-teal: #ccfbf1;
    --tone-cyan: #cffafe;
    --tone-purple: #f3e8ff;
    --tone-red: #fee2e2;
    --tone-sky: #e0f2fe;
    --shadow-sm: 0 2px 8px rgba(16, 24, 40, 0.18);
    --shadow-md: 0 6px 20px rgba(16, 24, 40, 0.18);
    --shadow-lg: 0 20px 50px rgba(16, 24, 40, 0.25);
    --backdrop: rgba(16, 24, 40, 0.5);

    --radius: 12px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    /* Design tokens (gap-closing Slice 7L). New and touched CSS uses these
       rather than raw sizes; page-specific rules move onto them as pages
       are touched.
       Spacing: a 4px scale. */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    /* Type: one scale; body text is --text-md. */
    --text-xs: 12px;
    --text-sm: 13px;
    --text-base: 14px;
    --text-md: 15px;
    --text-lg: 16px;
    --text-xl: 18px;
    --text-2xl: 20px;
    --text-3xl: 24px;
    --leading-tight: 1.25;
    --leading: 1.5;
    --weight-medium: 500;
    --weight-strong: 600;
    /* Controls: inputs and buttons, and the smallest tap target (WCAG 2.2). */
    --control-height: 40px;
    --control-radius: 8px;
    --tap-min: 44px;
    --focus-ring: 2px solid var(--brand);
    /* Breakpoints: ONE set, 480 / 768 / 1024 (phone < 480 ≤ large phone
       < 768 ≤ tablet < 1024 ≤ desktop). Custom properties cannot appear in
       @media, so queries use (max-width: 479.98px), (max-width: 767.98px)
       or (max-width: 1023.98px), or min-width 480px / 768px / 1024px;
       the design-token tests keep every query on this set. */

    /* The AI edge glow (web/src/lib/glow.ts): its colours, and its mask (only the mask's alpha counts). */
    --glow-blue: #5b8cff;
    --glow-cyan: #3fd0f2;
    --glow-violet: #8b6cff;
    --glow-purple: #b44be1;
    --glow-pink: #f06fb4;
    --glow-warm: #ffa66b;
    --glow-sky-soft: rgba(120, 200, 255, .9);
    --glow-violet-soft: rgba(196, 120, 255, .85);
    --glow-pink-soft: rgba(255, 140, 190, .8);
    --glow-rim: rgba(255, 255, 255, .28);
    --glow-rim-bloom: rgba(150, 140, 255, .45);
    --glow-mask: #000;
    --glow-mask-mid: rgba(0, 0, 0, .35);
}

/* Dark mode (gap-closing Slice 7): the device's setting, unless this
   browser chose (Settings › Appearance, <html data-theme>). The two blocks
   hold the same values; test/ui-tokens.test.ts keeps them equal. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --brand: #2dd4bf;
        --brand-strong: #5eead4;
        --on-brand: #04201d;
        --brand-soft: #123f3b;
        --focus-glow: rgba(45, 212, 191, 0.3);
        --canvas: #0c111d;
        --surface: #161b26;
        --surface-hover: #1f242f;
        --border: #333741;
        --ink: #f5f5f6;
        --ink-muted: #a3a7ae;
        --topbar: #161b26;
        --on-topbar: #f5f5f6;
        --on-topbar-muted: rgba(245, 245, 246, 0.78);
        --topbar-hover: rgba(255, 255, 255, 0.08);
        --inverse: #f5f5f6;
        --on-inverse: #101828;
        --neutral-soft: #262b36;
        --danger: #f97066;
        --on-danger: #1d0605;
        --danger-soft: #3b1514;
        --danger-line: #7a271a;
        --success: #47cd89;
        --success-soft: #0b2e1d;
        --success-line: #085d3a;
        --warn: #fdb022;
        --warn-soft: #2e2109;
        --info: #84caff;
        --info-soft: #102a43;
        --violet: #bdb4fe;
        --violet-soft: #27214a;
        --indigo: #a4bcfd;
        --indigo-soft: #1e2550;
        --pink: #faa7e0;
        --pink-soft: #3d1430;
        --orange: #f7b27a;
        --orange-soft: #3a1d0c;
        --rose-soft: #3a1520;
        --rose-line: #6b1d33;
        --mark-violet: #9b8afb;
        --mark-grey: #85888e;
        --chart-a: #2e90fa;
        --chart-b: #dc6803;
        --chart-c: #5fe9d0;
        --tone-rose: #3f1d27;
        --tone-amber: #3b2c0b;
        --tone-pink: #3d1a33;
        --tone-orange: #3d230f;
        --tone-lime: #26330f;
        --tone-green: #133322;
        --tone-teal: #123a37;
        --tone-cyan: #10343d;
        --tone-purple: #2c1f47;
        --tone-red: #3d1717;
        --tone-sky: #102f45;
        --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.5);
        --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.5);
        --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.6);
        --backdrop: rgba(0, 0, 0, 0.65);
}
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --brand: #2dd4bf;
    --brand-strong: #5eead4;
    --on-brand: #04201d;
    --brand-soft: #123f3b;
    --focus-glow: rgba(45, 212, 191, 0.3);
    --canvas: #0c111d;
    --surface: #161b26;
    --surface-hover: #1f242f;
    --border: #333741;
    --ink: #f5f5f6;
    --ink-muted: #a3a7ae;
    --topbar: #161b26;
    --on-topbar: #f5f5f6;
    --on-topbar-muted: rgba(245, 245, 246, 0.78);
    --topbar-hover: rgba(255, 255, 255, 0.08);
    --inverse: #f5f5f6;
    --on-inverse: #101828;
    --neutral-soft: #262b36;
    --danger: #f97066;
    --on-danger: #1d0605;
    --danger-soft: #3b1514;
    --danger-line: #7a271a;
    --success: #47cd89;
    --success-soft: #0b2e1d;
    --success-line: #085d3a;
    --warn: #fdb022;
    --warn-soft: #2e2109;
    --info: #84caff;
    --info-soft: #102a43;
    --violet: #bdb4fe;
    --violet-soft: #27214a;
    --indigo: #a4bcfd;
    --indigo-soft: #1e2550;
    --pink: #faa7e0;
    --pink-soft: #3d1430;
    --orange: #f7b27a;
    --orange-soft: #3a1d0c;
    --rose-soft: #3a1520;
    --rose-line: #6b1d33;
    --mark-violet: #9b8afb;
    --mark-grey: #85888e;
    --chart-a: #2e90fa;
    --chart-b: #dc6803;
    --chart-c: #5fe9d0;
    --tone-rose: #3f1d27;
    --tone-amber: #3b2c0b;
    --tone-pink: #3d1a33;
    --tone-orange: #3d230f;
    --tone-lime: #26330f;
    --tone-green: #133322;
    --tone-teal: #123a37;
    --tone-cyan: #10343d;
    --tone-purple: #2c1f47;
    --tone-red: #3d1717;
    --tone-sky: #102f45;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.6);
    --backdrop: rgba(0, 0, 0, 0.65);
}
:root[data-theme="light"] { color-scheme: light; }

*, *::before, *::after { box-sizing: border-box; }

html { font-family: var(--font); -webkit-font-smoothing: antialiased; }

body {
    margin: 0;
    min-height: 100dvh;
    background: var(--canvas);
    color: var(--ink);
    font-size: var(--text-md);
    line-height: var(--leading);
}

h1, h2, p { margin: 0; }
h1 { font-size: var(--text-xl); font-weight: var(--weight-strong); line-height: var(--leading-tight); }
h2 { font-size: var(--text-lg); font-weight: var(--weight-strong); line-height: var(--leading-tight); margin-bottom: var(--space-4); }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }

.muted { color: var(--ink-muted); font-size: var(--text-base); }

/* ── Shell ─────────────────────────────────────────────────────────────── */
.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 56px;
    padding: 0 16px;
    background: var(--topbar);
    color: var(--on-topbar);
}
.topbar-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-school { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar-button {
    padding: 6px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font-size: 14px;
    cursor: pointer;
}
.topbar-button:hover { background: var(--topbar-hover); }

.logo, .avatar {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--brand);
    color: var(--on-brand);
    font-weight: 700;
    font-size: 14px;
}
.logo { border-radius: 8px; }
.avatar { border-radius: 50%; font-size: 12px; font-weight: 600; }

.page {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    width: 100%;
    max-width: 1152px;
    margin: 0 auto;
    padding: var(--space-4);
}

.card {
    padding: var(--space-6);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

/* ── Modules grid ──────────────────────────────────────────────────────── */
.modules {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.module { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 8px; }
a.module:hover { background: var(--canvas); }
.module-icon { flex: none; width: 40px; height: 40px; border-radius: 8px; }
.module-label { min-width: 0; font-size: 14px; font-weight: 600; }
.module-label small { display: block; font-size: 12px; font-weight: 400; color: var(--ink-muted); }

.tone-rose   { background: var(--tone-rose); }
.tone-amber  { background: var(--tone-amber); }
.tone-pink   { background: var(--tone-pink); }
.tone-orange { background: var(--tone-orange); }
.tone-lime   { background: var(--tone-lime); }
.tone-green  { background: var(--tone-green); }
.tone-teal   { background: var(--tone-teal); }
.tone-cyan   { background: var(--tone-cyan); }
.tone-purple { background: var(--tone-purple); }
.tone-red    { background: var(--tone-red); }
.tone-sky    { background: var(--tone-sky); }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: var(--space-4); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: var(--text-base); font-weight: var(--weight-medium); }
.field input {
    height: var(--control-height);
    padding: 0 var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--control-radius);
    background: var(--surface);
    color: var(--ink);
}
.field input:focus { border-color: var(--brand); outline: 2px solid var(--focus-glow); }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: var(--control-height);
    padding: 0 var(--space-4);
    border: 0;
    border-radius: var(--control-radius);
    font-size: var(--text-base);
    font-weight: var(--weight-strong);
    cursor: pointer;
}
.button-primary { background: var(--brand); color: var(--on-brand); }
.button-primary:hover { background: var(--brand-strong); }
.button:focus-visible, .topbar-button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
/* Keyboard focus on every form control and on a choice drawn as a card: one clear outline (the glow alone was 25% and select and
   textarea had none). Both looks. */
input:focus-visible, select:focus-visible, textarea:focus-visible, .choose-option:focus-visible, .checks:focus-within, .filter-input:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.flash { padding: 10px var(--space-3); border-radius: var(--control-radius); font-size: var(--text-base); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash-success { background: var(--success-soft); color: var(--success); }

/* ── Results, field errors, empty states, busy buttons (Slice 7L) ───────
   The toast region (ui_toast()) is on every page, so a result announced
   later by a script is heard too (aria-live). A success fades by itself
   (also without JavaScript); an error stays until it is dismissed. */
.toast-region {
    position: fixed; z-index: 70;
    left: 50%; bottom: calc(var(--space-4) + var(--safe-bottom, 0px));
    width: min(480px, calc(100% - 2 * var(--space-4)));
    transform: translateX(-50%);
    display: flex; flex-direction: column; gap: var(--space-2);
    pointer-events: none;
}
body.in-app:not(.bare) .toast-region { bottom: calc(var(--tabbar-height) + var(--safe-bottom) + var(--space-3)); }
.toast {
    display: flex; align-items: flex-start; gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--control-radius);
    box-shadow: var(--shadow-md);
    font-size: var(--text-base); font-weight: var(--weight-medium); line-height: var(--leading);
    overflow-wrap: anywhere;
    pointer-events: auto;
}
.toast-error { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-line); }
.toast-success { background: var(--success-soft); color: var(--success); border: 1px solid var(--success-line); animation: toast-out .3s ease-in 8s forwards; }
.toast-close { flex: none; margin: -6px -8px -6px auto; width: 32px; height: 32px; border: 0; border-radius: 6px; background: transparent; color: inherit; font-size: 20px; line-height: 1; cursor: pointer; }
.toast-close:focus-visible { outline: var(--focus-ring); }
.toast.is-closed { display: none; }
@keyframes toast-out { to { opacity: 0; visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .toast-success { animation-duration: .01s; } }

.field-error { color: var(--danger); font-size: var(--text-sm); font-weight: var(--weight-medium); }
.field.has-error input, .field.has-error select, .field.has-error textarea, .checks.has-error, input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
.field.has-error > span:first-child { color: var(--danger); }
p.field-error { margin: 0; }

.empty-state { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); padding: var(--space-8) var(--space-4); text-align: center; }
.empty-state strong { font-size: var(--text-lg); font-weight: var(--weight-strong); }
.empty-state p { max-width: 42ch; color: var(--ink-muted); font-size: var(--text-base); }
.empty-state .button { margin-top: var(--space-2); }

/* A form being sent (app.js, data-busy): its submit button says so and cannot be pressed twice. */
.button.is-busy, .link-button.is-busy, form[data-sending="1"] .button[type="submit"] { cursor: progress; opacity: .8; }
/* The app's draft queue asks whether Milebud is reachable before it posts (mobile.js, data-sending). */
.button.is-busy::before, form[data-sending="1"] .button-primary[type="submit"]::before {
    content: ""; flex: none; width: 14px; height: 14px;
    border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
    animation: pull-spin .8s linear infinite;
}
@media (prefers-reduced-motion: reduce) { .button.is-busy::before, form[data-sending="1"] .button-primary[type="submit"]::before { animation: none; } }

/* ── Signed-out pages ──────────────────────────────────────────────────── */
.auth-wrap { display: flex; align-items: center; justify-content: center; min-height: 100dvh; padding: 16px; }
.auth-card { display: flex; flex-direction: column; gap: 20px; width: 100%; max-width: 384px; }
.auth-head { display: flex; align-items: center; gap: 12px; }

/* ── Top bar navigation ────────────────────────────────────────────────── */
.topbar-nav { display: flex; gap: 4px; margin-left: 16px; }
.topbar-nav a { padding: 6px 10px; border-radius: 8px; font-size: 14px; color: var(--on-topbar-muted); }
.topbar-nav a:hover { background: var(--topbar-hover); color: var(--on-topbar); }

/* ── Admin portal layout ───────────────────────────────────────────────── */
.admin { display: flex; align-items: flex-start; min-height: calc(100dvh - 56px); }
.sidenav {
    flex: none;
    width: 240px;
    align-self: stretch;
    padding: 12px 0 24px;
    border-right: 1px solid var(--border);
    background: var(--surface);
}
.sidenav-group { margin: 16px 20px 6px; font-size: 14px; font-weight: 600; }
.sidenav ul { margin: 0; padding: 0; list-style: none; }
.sidenav a { display: block; padding: 8px 20px; font-size: 14px; border-left: 3px solid transparent; }
.sidenav a:hover { background: var(--canvas); }
.sidenav a.is-active { background: var(--canvas); border-left-color: var(--ink); font-weight: 600; }
.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 16px; padding: 24px; }

@media (max-width: 1023.98px) {
    /* Stretch, not flex-start: a column item would otherwise be as wide as its widest content. */
    .admin { flex-direction: column; align-items: stretch; }
    .sidenav { width: 100%; border-right: 0; border-bottom: 1px solid var(--border); padding: 4px 0 8px; }
    /* One scrolling row per group, so the page starts near the top of a phone. */
    .sidenav ul { display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 0 12px; }
    .sidenav a { padding: 8px 10px; border-left: 0; border-radius: 8px; white-space: nowrap; }
    .sidenav-group { margin: 10px 20px 2px; font-size: 12px; color: var(--ink-muted); }
    .admin-main { padding: 16px; }
    .topbar-school { display: none; }
}

/* ── Page head, toolbar, tabs ──────────────────────────────────────────── */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.page-head h1 { font-size: var(--text-2xl); }
.page-head-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.page-head-text { min-width: 0; }
.page-head-text p { margin-top: var(--space-1); }
.breadcrumb { font-size: var(--text-sm); color: var(--ink-muted); }
/* A phone: the page's actions take the whole width, the primary one first. */
@media (max-width: 479.98px) {
    .page-head-actions { width: 100%; }
    .page-head-actions > .button { flex: 1 1 auto; }
}
.breadcrumb a { color: var(--brand); }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar input[type="search"], .toolbar select, .field select, .field textarea {
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 14px;
}
.toolbar input[type="search"] { flex: 1; min-width: 200px; max-width: 320px; }
.toolbar .count { color: var(--ink-muted); font-size: 14px; }
.toolbar .spacer { flex: 1; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs a { padding: 10px 14px; font-size: var(--text-base); font-weight: var(--weight-medium); color: var(--ink-muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.is-active { color: var(--ink); border-bottom-color: var(--ink); }

/* ── Tables ────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-base); }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-weight: 600; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-hover); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table .empty { padding: var(--space-8) 14px; text-align: center; color: var(--ink-muted); }
.table a.strong, .link { color: var(--brand); font-weight: 600; }
.cell-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-person small { display: block; color: var(--ink-muted); font-size: 12px; }

.avatar-soft { background: var(--brand-soft); color: var(--brand-strong); }

/* ── Pills, KPI cards, definition lists ───────────────────────────────── */
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill-good { background: var(--success-soft); color: var(--success); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-bad { background: var(--danger-soft); color: var(--danger); }
.pill-muted { background: var(--neutral-soft); color: var(--ink-muted); }
.pill-info { background: var(--info-soft); color: var(--info); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.kpi { padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.kpi strong { display: block; font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 13px; color: var(--ink-muted); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
.details dt { color: var(--ink-muted); }
.details dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.plain-list { margin: 0; padding: 0; list-style: none; font-size: 14px; }
.plain-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.route-list { margin: 0; padding-left: 18px; font-size: 14px; }
.route-list li { overflow-wrap: anywhere; }
/* Ask school documents (gap-closing Slice 9): an answer and its sources. */
.answer-text { margin: 8px 0 16px; white-space: normal; overflow-wrap: anywhere; line-height: 1.5; }
/* A web page's address (Slice W1, staff/web-source): long, without spaces, it wraps on a phone. */
.web-address { overflow-wrap: anywhere; }
.source-list { margin: 0 0 12px; padding-left: 22px; font-size: 14px; }
.source-list li { margin-bottom: 8px; overflow-wrap: anywhere; }
.plain-list li:last-child { border-bottom: 0; }
/* Gradebook overview: a class and its course. A long course name wraps, under the class when the row is too narrow, instead of widening the page. */
.plain-list.gradebook-classes li { flex-wrap: wrap; row-gap: var(--space-1); }
.plain-list.gradebook-classes li > .hint { flex: 0 1 auto; min-width: 0; white-space: normal; overflow-wrap: anywhere; }

/* ── Buttons, inline forms ─────────────────────────────────────────────── */
.button-secondary { border: 1px solid var(--border); background: var(--surface); color: var(--ink); }
.button-secondary:hover { background: var(--canvas); }
.button-danger { background: var(--danger); color: var(--on-danger); }
.link-button { padding: 0; border: 0; background: none; color: var(--brand); font-size: 14px; font-weight: 600; cursor: pointer; }
.link-button:hover { text-decoration: underline; }
.link-button.danger { color: var(--danger); }
.link-button[disabled] { color: var(--ink-muted); cursor: not-allowed; text-decoration: none; }
.icon-button { border: 0; background: none; font-size: 22px; line-height: 1; color: var(--ink-muted); cursor: pointer; }
.inline-form { display: inline; }
.inline-form + .inline-form, .link-button + .inline-form, .inline-form + .link-button { margin-left: 12px; }

/* ── Dialogs and richer forms ──────────────────────────────────────────── */
.dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); padding: 0; border: 0; border-radius: var(--radius); box-shadow: var(--shadow-lg); background: var(--surface); color: var(--ink); }
.dialog::backdrop { background: var(--backdrop); }
.dialog .form { padding: var(--space-5) var(--space-6); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head h2 { margin: 0; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.field abbr { margin-left: 2px; color: var(--danger); text-decoration: none; }
.field small, .hint { font-size: var(--text-xs); font-weight: 400; color: var(--ink-muted); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.checks { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.checks label { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.checks .check-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.checks select { height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; font: inherit; font-size: 13px; }
fieldset { margin: 0; padding: 0; border: 0; }
legend { padding: 0; margin-bottom: 6px; font-size: 14px; font-weight: 500; }

/* ── Masked codes ──────────────────────────────────────────────────────── */
.codes { display: flex; gap: 24px; flex-wrap: wrap; }
.code-field { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.code-label { color: var(--ink-muted); }
.code-field code { padding: 2px 8px; border-radius: 6px; background: var(--canvas); font-size: 14px; letter-spacing: 1px; }

/* ── Small refinements ─────────────────────────────────────────────────── */
.table select { height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; }
.table td.nowrap, .table th.nowrap { white-space: nowrap; }
.plain-list li > span:last-child, .plain-list li > form { flex: none; white-space: nowrap; }
.card-head .link-button, .card-head .link { flex: none; white-space: nowrap; }
ul.hint { margin: 0; padding-left: 18px; }

/* ── Student and family portals ────────────────────────────────────────── */
.topbar-light { background: var(--surface); color: var(--ink); border-bottom: 1px solid var(--border); }
.topbar-light .topbar-nav a { color: var(--ink-muted); }
.topbar-light .topbar-nav a:hover { background: var(--canvas); color: var(--ink); }
.topbar-light .topbar-button { color: var(--ink-muted); }
.topbar-light .topbar-button:hover { background: var(--canvas); color: var(--ink); }

.learner-home { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); gap: 24px; align-items: start; }
.learner-main { display: flex; flex-direction: column; gap: 16px; }
.learner-side { display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 1023.98px) { .learner-home { grid-template-columns: minmax(0, 1fr); } }

.section-title { margin: 8px 0 0; font-size: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.tile {
    display: flex;
    align-items: stretch;
    min-height: 88px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}
a.tile:hover { border-color: var(--brand); }
.tile-icon { flex: none; width: 88px; }
.tile-text { display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 12px 16px; min-width: 0; }
.tile-text strong { font-size: 15px; font-weight: 600; }
.tile-text span { font-size: 14px; color: var(--ink-muted); }
.tile-text small { font-size: 12px; color: var(--ink-muted); }

.class-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.class-list li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-size: 14px; }
.class-list small { display: block; color: var(--ink-muted); font-size: 12px; }
.class-badge { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; background: var(--brand-soft); color: var(--brand-strong); font-weight: 700; }

.tabs-small { margin-bottom: 12px; }
.tabs-small span { padding: 8px 10px; font-size: 13px; font-weight: 500; color: var(--ink-muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs-small span.is-active { color: var(--ink); border-bottom-color: var(--ink); }
.empty-panel { padding: 24px 0; text-align: center; }

.child-selector { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 16px 24px; }
.child-current { display: flex; align-items: center; gap: 12px; }
.child-chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 0; padding: 0; list-style: none; }
.child-chips a, .child-chips span { display: inline-block; padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; font-size: 14px; }
.child-chips a:hover { border-color: var(--brand); }
.child-chips a.is-active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; }
.child-chips .chip-waiting { color: var(--ink-muted); background: var(--canvas); }
.child-chips .chip-add { color: var(--brand); font-weight: 600; }

.code-input { text-transform: uppercase; letter-spacing: 2px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.auth-foot { text-align: center; }
/* The hidden attribute wins over a class's display (the app's sign-in hides and shows fields). */
[hidden] { display: none !important; }
/* The app's sign-in: the offer to unlock with a fingerprint or face. */
.signin-unlock { display: flex; flex-direction: column; gap: 8px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--brand-soft); }
.signin-unlock p { margin: 0; }
.signin-unlock-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.auth-card .tabs { margin-top: -4px; }

/* ── Attendance ────────────────────────────────────────────────────────── */
.att-chip { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 24px; padding: 0 6px; border-radius: 6px; background: color-mix(in srgb, var(--chip) 18%, var(--surface)); color: color-mix(in srgb, var(--chip) 65%, var(--ink)); font-size: 12px; font-weight: 700; }
.att-none { background: none; color: var(--ink-muted); font-weight: 400; }
.att-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; padding: 0; list-style: none; font-size: 13px; color: var(--ink-muted); }
.att-legend li { display: inline-flex; align-items: center; gap: 6px; }
.att-legend-values { flex-direction: column; margin-top: 8px; }
.att-grid th.att-day { text-align: center; font-weight: 600; vertical-align: top; }
.att-grid th.is-today { background: var(--brand-soft); }
.att-grid td.att-cell { text-align: center; }
.att-codes { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; border: 0; }
.att-option { position: relative; cursor: pointer; }
.att-option input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.att-option span { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--ink-muted); background: var(--surface); }
.att-option input:checked + span { background: var(--chip); border-color: var(--chip); color: var(--chip-ink, #ffffff); }
.att-option input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.button.is-disabled { opacity: 0.4; pointer-events: none; }
.button-small { height: 32px; padding: 0 10px; font-size: 13px; }
.att-resolve select { height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; font: inherit; font-size: 13px; }
/* The authenticator QR code: fixed black on white, so it scans in either theme. */
.qr { display: block; width: 200px; height: 200px; margin: 12px 0; border: 1px solid var(--border); border-radius: 8px; }

/* A left list of states with counts beside the list it filters (the excusals inbox). */
.inbox { display: grid; grid-template-columns: 240px 1fr; gap: 24px; align-items: start; }
.inbox-nav { display: flex; flex-direction: column; border-right: 1px solid var(--border); padding-right: 8px; }
.inbox-nav a { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 8px; color: var(--ink-muted); font-weight: var(--weight-medium); }
.inbox-nav a:hover { color: var(--ink); }
.inbox-nav a.is-active { background: var(--surface-muted, var(--border)); color: var(--ink); }
.inbox-count { font-variant-numeric: tabular-nums; }
.mark { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; margin-right: 10px; border-radius: 50%; background: var(--surface-muted, var(--border)); color: var(--ink); font-size: 13px; font-weight: var(--weight-medium); vertical-align: middle; flex: none; }
.pick-list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.pick-list li + li { border-top: 1px solid var(--border); }
.pick-list label { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; }
.inbox-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 767.98px) {
    .inbox { grid-template-columns: 1fr; }
    .inbox-nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 0 0 8px; }
}
.tabs-sub { border-bottom: 0; }
.tabs-sub a { padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; margin-right: 4px; }
.tabs-sub a.is-active { border-color: var(--ink); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.att-summary { position: relative; }
.att-summary summary { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; list-style: none; }
.att-summary summary::-webkit-details-marker { display: none; }
.att-summary summary strong { font-size: 22px; }
.att-summary summary span { font-size: 12px; color: var(--ink-muted); line-height: 1.3; }
.att-info { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border: 1px solid var(--ink-muted); border-radius: 50%; font-size: 11px !important; }
.att-popover { position: absolute; right: 0; z-index: 5; width: 300px; margin-top: 6px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-md); }
.att-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1023.98px) { .att-layout { grid-template-columns: minmax(0, 1fr); } }
.att-side h2 { margin: 16px 0 4px; font-size: 15px; }
.att-side h2:first-of-type { margin-top: 0; }
.side-tabs { display: flex; flex-direction: column; margin: -8px -8px 12px; }
.side-tabs a { padding: 8px 10px; border-radius: 8px; font-size: 14px; }
.side-tabs a.is-active { background: var(--canvas); font-weight: 600; }
.att-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.att-dot-present { background: var(--mark-green); } .att-dot-excused { background: var(--mark-amber); } .att-dot-unexcused { background: var(--mark-pink); }
.att-dot-tardy { background: var(--mark-violet); } .att-dot-uncategorized { background: var(--mark-grey); }
.att-months { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; margin-bottom: 16px; }
.att-month h3 { margin: 0 0 8px; font-size: 14px; text-align: center; }
.att-month table { width: 100%; border-collapse: collapse; font-size: 13px; text-align: center; }
.att-month th { padding: 4px 0; color: var(--ink-muted); font-weight: 500; }
.att-month td { padding: 6px 0; }
/* Contrast (Slice 7): muted, not the faint grey that read at 1.7:1. */
.att-month td.is-weekend, .att-month td.is-out { color: var(--ink-muted); font-weight: 400; }
.att-day-mark { padding-bottom: 2px; border-bottom: 3px solid var(--chip); font-weight: 600; }
.radio-row { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 14px; font-weight: 400; }
.radio-row label { display: inline-flex; align-items: center; gap: 6px; }
.radio-line { display: flex; align-items: flex-start; gap: 8px; margin: 6px 0; font-size: 14px; font-weight: 400; }
.radio-line input { margin-top: 3px; flex: none; }
.field textarea { height: auto; padding: 8px 12px; resize: vertical; }

/* ── Timetables ────────────────────────────────────────────────────────── */
.tt-grid th[scope="row"] { white-space: nowrap; width: 120px; }
.tt-grid td { vertical-align: top; min-width: 130px; }
.tt-break th, .tt-break td { background: var(--canvas); }
.tt-session { display: flex; flex-direction: column; gap: 2px; padding: 6px 8px; margin-bottom: 4px; border-left: 3px solid var(--brand); border-radius: 6px; background: var(--brand-soft); font-size: 13px; }
.tt-session span { color: var(--ink-muted); font-size: 12px; }
.tt-pick td { text-align: center; }
.tt-check { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.tt-check input { width: 18px; height: 18px; }
.att-period { margin: 1px; }

/* ── Notifications ─────────────────────────────────────────────────────── */
.topbar-bell { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; color: inherit; }
.topbar-bell:hover { background: var(--topbar-hover); }
.topbar-light .topbar-bell:hover { background: var(--canvas); }
.bell-badge { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: var(--on-danger); font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.notif-list { margin: 0; padding: 0; list-style: none; }
.notif-list li + li { border-top: 1px solid var(--border); }
.notif-item { display: flex; gap: 12px; width: 100%; padding: 12px 4px; border: 0; background: none; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.notif-item:hover { background: var(--canvas); }
.notif-dot { flex: none; width: 8px; height: 8px; margin-top: 7px; border-radius: 50%; background: transparent; }
.is-unread .notif-dot { background: var(--brand); }
.notif-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif-text span { font-size: 14px; color: var(--ink-muted); }
.notif-text small { font-size: 12px; color: var(--ink-muted); }
.is-unread .notif-text strong { font-weight: 700; }
.table .group-row { background: var(--canvas); font-size: 13px; }

/* ── Class workspace sidebar ───────────────────────────────────────────── */
.sidenav-title { display: flex; flex-direction: column; gap: 2px; margin: 8px 20px 4px; font-size: 14px; }
.sidenav-title span { color: var(--ink-muted); font-size: 12px; }
.sidenav-foot { margin-top: 16px !important; border-top: 1px solid var(--border); padding-top: 8px !important; }

/* ── Course plan, units, planner ───────────────────────────────────────── */
.unit-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin: 0; padding: 0; list-style: none; }
.unit-card > a, .unit-card > div { display: flex; flex-direction: column; height: 100%; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.unit-card > a:hover { border-color: var(--brand); }
.unit-cover { display: flex; align-items: center; justify-content: center; height: 110px; background: var(--unit); color: var(--unit-ink, #ffffff); font-size: 40px; font-weight: 700; }
.unit-cover-small { width: 56px; height: 56px; border-radius: 12px; font-size: 24px; flex: none; }
.unit-body { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px 14px; }
.unit-flags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.library-copy { display: flex; gap: 6px; margin-top: 8px; }
.library-copy select { flex: 1; min-width: 0; height: 32px; border: 1px solid var(--border); border-radius: 6px; font: inherit; font-size: 13px; }
.checks-inline { flex-direction: row; flex-wrap: wrap; gap: 6px 16px; max-height: none; }
/* A short list shown whole, each choice with its explanation under it (Admin portal › Integrations). */
.checks-full { max-height: none; gap: 10px; }
.checks-full label { align-items: flex-start; }
.checks-full label input { margin-top: 3px; }
.colour-swatch { position: relative; }
.colour-swatch input { position: absolute; opacity: 0; }
.colour-swatch span { display: inline-block; width: 28px; height: 28px; border-radius: 50%; background: var(--unit); border: 3px solid transparent; }
.colour-swatch input:checked + span { border-color: var(--ink); }
.colour-swatch input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.bullets { margin: 0; padding-left: 18px; }
.planner { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.planner-week { grid-column: 1 / -1; }
.planner-day h2 { font-size: 15px; margin-bottom: 8px; }
.planner-entry { display: flex; flex-direction: column; gap: 4px; padding: 10px 0; border-top: 1px solid var(--border); font-size: 14px; }
.planner-entry p { margin: 0; }
.poi th[scope="row"] { white-space: nowrap; }
.poi td { vertical-align: top; min-width: 150px; }
.poi-unit { display: flex; flex-direction: column; gap: 2px; padding: 6px 8px; margin-bottom: 4px; border-left: 3px solid var(--unit); border-radius: 6px; background: color-mix(in srgb, var(--unit) 12%, var(--surface)); font-size: 13px; }
.poi-unit span { color: var(--ink-muted); font-size: 12px; }
.class-list li > a { display: flex; align-items: center; gap: 12px; width: 100%; }
.class-list li:has(a:hover) { border-color: var(--brand); }
.unit-detail summary { display: flex; align-items: center; gap: 12px; cursor: pointer; list-style: none; }
.unit-detail summary::-webkit-details-marker { display: none; }
.unit-detail[open] summary { margin-bottom: 12px; }
.card h2 + p + .hint + h2, .card .hint + h2 { margin-top: 20px; }

/* ── Assignments ───────────────────────────────────────────────────────── */
.type-chip { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 22px; padding: 0 6px; border-radius: 6px; font-size: 11px; font-weight: 700; background: var(--indigo-soft); color: var(--indigo); vertical-align: middle; }
.type-quick_task { background: var(--pink-soft); color: var(--pink); }
.type-worksheet { background: var(--orange-soft); color: var(--orange); }
.type-formative { background: var(--success-soft); color: var(--success); }
.type-summative { background: var(--violet-soft); color: var(--violet); }
.task-list { display: flex; flex-direction: column; gap: 8px; margin: 0 0 16px; padding: 0; list-style: none; }
.task-item a { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.task-item a:hover { border-color: var(--brand); }
.task-item.is-soon a { background: var(--rose-soft); border-color: var(--rose-line); }
.task-main { display: flex; flex-direction: column; flex: 1; min-width: 0; font-size: 14px; }
.task-main small { color: var(--ink-muted); font-size: 12px; }
.task-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 12px; text-align: right; }
.task-soon { color: var(--danger); font-weight: 600; }
.task-list-compact .task-item a { padding: 10px 0; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: none; }
.task-list-compact .task-item.is-soon a { background: var(--rose-soft); padding-left: 8px; padding-right: 8px; border-radius: 8px; }
.tabs-small a { padding: 8px 10px; font-size: 13px; font-weight: 500; color: var(--ink-muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs-small a.is-active { color: var(--ink); border-bottom-color: var(--ink); }
.assign-row { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(200px, 1fr) minmax(200px, 1fr); gap: 12px; align-items: end; padding: 8px 0; border-top: 1px solid var(--border); }
.assign-class { display: flex; align-items: center; gap: 8px; padding-bottom: 10px; font-weight: 600; font-size: 14px; }
.field input[type="datetime-local"], .field input[type="file"] { height: 40px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 14px; }
.field input[type="file"] { max-width: 100%; }
.kpis-small { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 12px; }
.kpi-text { font-size: 15px !important; margin: 4px 0; }
.mini { margin: 16px 0 6px; font-size: 14px; }
.section-gap { margin-top: 24px; }
.activity { margin: 0; padding: 0; list-style: none; font-size: 14px; }
.activity li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.activity li .hint { display: block; }
.thread { display: flex; flex-direction: column; gap: 8px; margin: 0 0 12px; padding: 0; list-style: none; }
.thread li { max-width: 90%; padding: 8px 12px; border-radius: 12px; background: var(--canvas); }
.thread li.is-mine { align-self: flex-end; background: var(--brand-soft); }
.thread p { margin: 4px 0 0; font-size: 14px; }
.task-layout { grid-template-columns: minmax(0, 1fr) 340px; }
@media (max-width: 1023.98px) { .assign-row, .task-layout { grid-template-columns: minmax(0, 1fr); } }
.table .actions-stack { white-space: normal; }
.table .actions-stack .inline-form { display: block; margin: 0 0 4px; }
.table .actions-stack .inline-form + .inline-form { margin-left: 0; }

/* ── Gradebook ─────────────────────────────────────────────────────────── */
.gradebook th { min-width: 140px; vertical-align: bottom; }
.gradebook th[scope="row"] { min-width: 160px; }
.gradebook td a { display: block; }
/* Contrast (Slice 7): the amber text read at 2.2:1. */
.unshared { color: var(--warn); font-size: 10px; }
.cell-input { width: 100%; height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; font: inherit; font-size: 13px; }

/* ── Messaging, announcements ─────────────────────────────────────────── */
.chat { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1023.98px) { .chat { grid-template-columns: minmax(0, 1fr); } }
.chat-list { padding: 12px; }
.chat-list .is-current .notif-item { background: var(--canvas); }
.contact-list { max-height: 320px; }
.filter-input { height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 14px; }
.announcement h1 { font-size: 22px; }
.announcement-body { margin-top: 16px; font-size: 15px; line-height: 1.6; }
.audience-targets { margin-top: 4px; }
input[type="datetime-local"] { height: 40px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 14px; }
.agenda-day { margin: 20px 0 8px; font-size: 14px; color: var(--ink-muted); }
.agenda-day:first-child { margin-top: 0; }
.agenda-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 6px; border: 1px solid var(--border); border-radius: 10px; }
.agenda-item:hover { border-color: var(--brand); }
.agenda-event { border-left: 4px solid var(--brand); }
.agenda-task { border-left: 4px solid var(--mark-violet); }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--border); }
.month-head { padding: 8px; background: var(--surface); font-size: 12px; font-weight: 600; text-align: center; color: var(--ink-muted); }
.month-cell { min-height: 96px; padding: 6px; background: var(--surface); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.month-cell.is-empty { background: var(--canvas); }
.month-cell.is-today .month-day { background: var(--brand); color: var(--on-brand); border-radius: 50%; }
.month-day { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; font-size: 12px; font-weight: 600; }
.month-item { display: block; padding: 2px 6px; border-radius: 4px; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.month-event { background: var(--brand-soft); color: var(--brand-strong); }
.month-task { background: var(--violet-soft); color: var(--violet); }

/* ── Drive ─────────────────────────────────────────────────────────────── */
.drive-icon { display: inline-flex; margin-right: 8px; vertical-align: -4px; }
.drive-folder { color: var(--mark-yellow); }
.drive-file { color: var(--mark-blue); }
.drive-link { color: var(--mark-green); }

/* Class portfolio */
.pf-feed { display: flex; flex-direction: column; gap: 16px; max-width: 720px; }
/* A word longer than the card (an address, a pasted code) breaks inside it, so a post never makes a phone's page wider than its screen. */
.pf-post { overflow-wrap: anywhere; }
.pf-post > p { margin: 8px 0; }
.pf-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.pf-head > span:nth-child(2) { flex: 1; }
.pf-photo { display: block; max-width: 100%; max-height: 420px; margin: 8px 0; border-radius: 8px; object-fit: contain; background: var(--canvas); }
.pf-foot { display: flex; align-items: center; gap: 16px; padding-top: 8px; margin-top: 8px; border-top: 1px solid var(--border); }
.pf-post .thread { margin-top: 12px; }
.pf-tags { max-height: 200px; overflow-y: auto; }

/* Phone width: the top bar never widens the page; the platform's links
   scroll inside it, and a school person's places move to the bottom tabs. */
@media (max-width: 767.98px) {
    .topbar { gap: 8px; padding: 0 12px; }
    .topbar-nav { min-width: 0; margin-left: 4px; overflow-x: auto; scrollbar-width: none; }
    .topbar-nav a { padding: 6px 8px; white-space: nowrap; }
    body.has-tabbar .topbar-nav { display: none; }
    .topbar-end { gap: 6px; flex-shrink: 0; }
    .child-selector { padding: 12px 16px; }
    .page { padding-left: 16px; padding-right: 16px; }
}
.pf-head { flex-wrap: wrap; }
.pf-controls { display: flex; align-items: center; gap: 8px; }
.pf-comment { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.pf-comment .cell-input { flex: 1; min-width: 0; height: 32px; }
/* AI assist on a staff comment (Slice F4): the comment and Post stay on one row, AI assist and the review box each a row under them. */
.pf-comment > .ai-field-assist, .pf-comment > .ai-review-gate { flex: 1 0 100%; order: 1; margin-top: 0; }

/* Progress reports */
.row-actions { text-align: right; white-space: nowrap; }
.row-actions > * + * { margin-left: 12px; }
.rpt-progress { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-muted); }
.rpt-progress meter { width: 96px; height: 8px; }
.rpt-fields { flex-wrap: wrap; gap: 6px; }
.rpt-bank { max-width: 320px; margin-bottom: 8px; }
.rpt-section { display: flex; flex-direction: column; gap: 12px; }
.rpt-ratings-form { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 8px 16px; align-items: center; }
.rpt-ratings-form .radio-row { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.rpt-doc { display: flex; flex-direction: column; gap: 20px; max-width: 820px; padding: 32px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.rpt-doc h1 { margin: 4px 0 12px; font-size: 22px; }
.rpt-doc h2 { margin: 0 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); font-size: 17px; }
.rpt-doc h3 { margin: 12px 0 6px; font-size: 15px; }
.rpt-scale { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0; padding: 0; list-style: none; font-size: 14px; }
.rpt-ratings { max-width: 420px; }
@media print {
    .topbar, .page-head .button, .no-print, .flash, .toast-region, .tabs { display: none !important; }
    body { background: #fff; }
    .page { max-width: none; padding: 0; }
    .rpt-doc { border: 0; padding: 0; max-width: none; }
}
tr.is-selected td { background: var(--canvas); }
.notice { margin: 0; padding: 12px 16px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-size: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.trn-doc header h1 { margin: 0 0 6px; }
.trn-sign { margin-top: 24px; }
.trn-sign p { margin: 0; }
.entry-list { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.entry-list li { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; line-height: 1.5; }
.entry-list li:last-child { border-bottom: 0; }
.code-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.code-card { padding: 16px; border: 1px dashed var(--border); border-radius: 10px; background: var(--surface); font-size: 14px; break-inside: avoid; }
.code-card p { margin: 4px 0; }
.code-value { font: 600 20px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 1px; }
@media print { .code-sheet { grid-template-columns: repeat(2, 1fr); } }
.ready-table td:first-child { width: 96px; } .ready-table td:last-child { width: 64px; }

/* School / role chooser (auth/choose) */
.choose-list { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; padding: 0; list-style: none; }
.choose-option { display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); text-align: left; font: inherit; cursor: pointer; }
.choose-option:hover, .choose-option:focus-visible { border-color: var(--brand); }
.choose-option.is-current { border-color: var(--brand); background: var(--brand-soft); }

/* Paged lists (db_page): newest / older links under a list. */
.pager { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-top: 1rem; flex-wrap: wrap; }
.pager .button:only-child { margin-left: auto; }

/* A usage bar (Admin portal › AI). */
.meter { height: 6px; margin-top: 4px; border-radius: 3px; background: var(--border); overflow: hidden; max-width: 160px; }
.meter > span { display: block; height: 100%; background: var(--brand); }

/* Phones and tablets (B2): text links and link buttons are at least 24px tall to tap (WCAG 2.2 target size). */
@media (max-width: 1023.98px) {
    a.link, .link-button { display: inline-block; min-height: 24px; line-height: 24px; }
}
/* A table that may be wider than a phone scrolls inside its card, not the page (B2). */
.table-scroll { overflow-x: auto; }
.copilot-draft { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 14px; line-height: 1.5; }
/* The app and the web (B3b): offline and update notices, and the phone's safe areas. */
.offline-banner { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 50; padding: 12px 16px; border-radius: 10px; background: var(--inverse); color: var(--on-inverse); font-size: 14px; text-align: center; box-shadow: var(--shadow-md); }
/* The banner lies over the foot of the page: leave the room for it, so the last controls can be scrolled clear of it. (No scroll-padding on html: it also moves what a scrolling table is scrolled to.) */
body:has(#offline-banner) { padding-bottom: calc(var(--safe-bottom, 0px) + 72px); }
.topbar { height: calc(56px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); }
/* The app's offline drafts (mobile.js, gap-closing Slice M): a line under the
   form that was saved on the phone, and a notice at the top of the page. */
.draft-status { margin: 8px 0 0; font-size: 14px; color: var(--ink-muted); }
.draft-status.is-saved { color: var(--info); font-weight: 600; }
.draft-status.is-sent { color: var(--success); font-weight: 600; }
.draft-status.is-offline { color: var(--warn); }
.drafts-notice { padding: 10px 12px; border-radius: 8px; background: var(--info-soft); color: var(--info); font-size: 14px; }
.drafts-notice p { margin: 0; }
.drafts-notice p + p { margin-top: 6px; }


/* Milebud support (gap-closing Slice 4 step 9): the platform's banner, and a
   school's notice while a support session gives Milebud access. */
.support-banner { padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-size: 14px; }
.platform-banner { padding: 8px 24px; background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--warn); font-size: 14px; font-weight: 600; }
/* The One strip (shell/OneStrip.tsx): a thin bar on a session the One hub opened, in the owner's browser alone; an
   Override open is drawn as a warning. "View as" beside a person in a list goes to the hub, which asks first. */
.one-strip { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); padding: var(--space-1) var(--space-4); background: var(--info-soft); color: var(--info); border-bottom: 1px solid var(--info); font-size: var(--text-sm); }
.one-strip-override { background: var(--warn-soft); color: var(--warn); border-bottom-color: var(--warn); }
.one-strip-app, .one-strip-who { font-weight: 600; }
.one-strip-links { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-left: auto; }
.one-strip-links a { color: inherit; text-decoration: underline; }
.one-view-as { display: inline-block; margin-left: var(--space-2); font-size: var(--text-xs); }
.platform-main { display: flex; flex-direction: column; gap: 16px; max-width: 1100px; margin: 0 auto; padding: 24px 16px; }
/* Two-step sign-in: the key to type into the app, and the recovery codes. */
.steps { margin: 0 0 16px; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
code.secret { font: 600 15px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 1px; word-break: break-all; }
.code-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; margin: 12px 0 16px; padding: 0; list-style: none; font: 600 15px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ── The app's chrome (gap-closing Slice M, client-mobile.md) ──────────────
   Inside the Milebud app (body.in-app, from the web view's user agent) a
   signed-in page has a slim bar and a bottom tab bar instead of the desktop
   top bar and side navigation. Safe areas: env() on iOS and on Android's
   Chromium 140+, Capacitor's injected --safe-area-inset-* before that. */
:root {
    --safe-top: max(env(safe-area-inset-top, 0px), var(--safe-area-inset-top, 0px));
    --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--safe-area-inset-bottom, 0px));
    --safe-left: max(env(safe-area-inset-left, 0px), var(--safe-area-inset-left, 0px));
    --safe-right: max(env(safe-area-inset-right, 0px), var(--safe-area-inset-right, 0px));
    --tabbar-height: 60px;
}
body.in-app { padding-left: var(--safe-left); padding-right: var(--safe-right); overscroll-behavior-y: contain; }
body.in-app:not(.bare) { padding-bottom: calc(var(--tabbar-height) + var(--safe-bottom)); }
body.in-app.bare { padding-top: var(--safe-top); padding-bottom: var(--safe-bottom); }
.appbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: var(--space-3);
    min-height: calc(52px + var(--safe-top));
    padding: var(--safe-top) var(--space-3) 0;
    background: var(--surface); color: var(--ink);
    border-bottom: 1px solid var(--border);
}
.appbar-brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.appbar-title { font-size: var(--text-md); font-weight: var(--weight-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar .topbar-bell { flex: none; width: 44px; height: 44px; }
.appbar .topbar-bell:hover { background: var(--canvas); }
.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: flex;
    padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
    background: var(--surface);
    border-top: 1px solid var(--border);
}
.tabbar a {
    flex: 1 1 0; min-width: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    height: var(--tabbar-height); min-height: var(--tap-min);
    color: var(--ink-muted); font-size: var(--text-xs); font-weight: var(--weight-medium); line-height: var(--leading-tight);
}
.tabbar a span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabbar a.is-active { color: var(--brand); font-weight: var(--weight-strong); }
.tabbar a:focus-visible { outline: var(--focus-ring); outline-offset: -4px; }
body.in-app .admin { min-height: 0; }
body.in-app .offline-banner { bottom: calc(var(--tabbar-height) + var(--safe-bottom) + 12px); }
body.in-app.bare .offline-banner { bottom: calc(12px + var(--safe-bottom)); }
/* More: the desktop navigation as one list. */
.more-list { margin: 0; padding: 0; list-style: none; }
.more-list li + li { border-top: 1px solid var(--border); }
.more-list a { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 4px 0; font-size: 15px; }
.more-list small { color: var(--ink-muted); font-size: 13px; }
.more-label { display: inline-flex; align-items: center; gap: var(--space-3); }
.more-label .icon { color: var(--ink-muted); }
.more-logout { margin-top: 16px; }
/* Pull to refresh (data-pull-refresh, mobile.js). */
.pull-refresh {
    position: fixed; left: 50%; top: calc(var(--safe-top) + 8px); z-index: 60;
    width: 36px; height: 36px; margin-left: -18px; border-radius: 50%;
    background: var(--surface); box-shadow: var(--shadow-sm);
    display: flex; align-items: center; justify-content: center;
    transform: translateY(-60px); transition: transform .15s ease-out;
    pointer-events: none;
}
.pull-refresh::after { content: ""; width: 16px; height: 16px; border: 2px solid var(--brand); border-top-color: transparent; border-radius: 50%; }
.pull-refresh.is-ready::after, .pull-refresh.is-loading::after { animation: pull-spin .8s linear infinite; }
@keyframes pull-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .pull-refresh, .pull-refresh::after { transition: none; animation: none !important; } }

/* ── Role-first homes (gap-closing Slice 7L) ─────────────────────────────
   Today's lessons with the register taken in one tap, an administrator's
   attention list, a student's one list, a child's summary, and the one
   next step each home ends with. */
.lessons, .attention-list, .home-items { margin: 0; padding: 0; list-style: none; }
.lesson {
    display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; align-items: center; gap: var(--space-3);
    padding: var(--space-3) 0; border-bottom: 1px solid var(--border);
}
.lesson:last-child { border-bottom: 0; }
.lesson.is-now { margin: 0 calc(-1 * var(--space-3)); padding-left: var(--space-3); padding-right: var(--space-3); border-radius: var(--control-radius); background: var(--info-soft); }
.lesson-when { display: flex; flex-direction: column; gap: 2px; font-size: var(--text-sm); color: var(--ink-muted); }
.lesson-when strong { color: var(--ink); font-size: var(--text-base); }
.lesson-when .pill { align-self: flex-start; }
.lesson-main { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-1); min-width: 0; }
.lesson-main small { color: var(--ink-muted); font-size: var(--text-sm); }
.lesson-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-3); flex-wrap: wrap; }
.lesson-actions .button { min-height: var(--tap-min); }
.lesson-mark .draft-status { margin: 0; }
.lesson[data-state="marked"] .lesson-mark { display: none; }
@media (max-width: 767.98px) {
    .lesson { grid-template-columns: minmax(0, 1fr); gap: var(--space-2); }
    .lesson-when { flex-direction: row; align-items: center; gap: var(--space-2); }
    .lesson-actions { justify-content: flex-start; }
    .lesson-actions .lesson-mark { flex: 1 1 100%; }
    .lesson-actions .lesson-mark .button { width: 100%; }
}
.home-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
@media (max-width: 767.98px) { .home-grid { grid-template-columns: minmax(0, 1fr); } }
.attention { padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.attention:first-child { padding-top: 0; }
.attention:last-child { border-bottom: 0; padding-bottom: 0; }
.attention h3 { margin: 0; font-size: var(--text-md); font-weight: var(--weight-strong); }
.attention .card-head { margin-bottom: var(--space-2); }
.attention .row-actions { display: flex; align-items: center; gap: var(--space-3); flex: none; }
.attention .plain-list li > span:first-child { white-space: normal; }
.home-items li + li { border-top: 1px solid var(--border); }
.home-items a { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: var(--tap-min); padding: var(--space-2) 0; }
.home-item-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.home-item-main small { color: var(--ink-muted); font-size: var(--text-sm); }
.home-items a:hover strong { color: var(--brand); }
.home-child h1 { margin-bottom: var(--space-1); }
.home-facts { margin: var(--space-3) 0; }
.home-next { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.home-child .home-next { padding: var(--space-4) 0 0; border: 0; border-top: 1px solid var(--border); border-radius: 0; }
.home-next-actions { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
@media (max-width: 479.98px) {
    .home-next-actions > .button { flex: 1 1 100%; }
}
.tab-count { display: inline-block; min-width: 18px; margin-left: var(--space-1); padding: 0 5px; border-radius: 999px; background: var(--brand); color: var(--on-brand); font-size: var(--text-xs); font-weight: var(--weight-strong); line-height: 18px; text-align: center; }
.topbar-nav a[aria-current="page"] { background: var(--topbar-hover); color: var(--on-topbar); }
.topbar-light .topbar-nav a[aria-current="page"] { background: var(--canvas); color: var(--ink); }
/* What an island's save did (web/src/lib/form.ts): saving, refused. */
.draft-status.is-saving { color: var(--ink-muted); }
.draft-status.is-error { color: var(--danger); font-weight: var(--weight-medium); }

/* Account › Plans (gap-closing Slice 10) */
.plans-list li { flex-wrap: wrap; }
.plans-list li > div:first-child { min-width: 0; flex: 1 1 220px; }
.plans-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--space-2); }
.plans-price { margin: 0 0 var(--space-2); font-size: var(--text-xl); }
.plans-subscribe { margin-top: var(--space-3); }
.plans-go { border-color: var(--brand); }

/* ── Design system (gap-closing Slice 7) ─────────────────────────────────
   Icons from the sprite (ui_icon()), cards (ui_card()), tabs (ui_tabs()),
   tables (ui_table()), and the five places on the web as well. */
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { flex: none; display: inline-block; vertical-align: middle; pointer-events: none; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; min-width: var(--tap-min); min-height: var(--tap-min); margin: calc(-1 * var(--space-2)); border-radius: var(--control-radius); }
.icon-button:hover { background: var(--canvas); color: var(--ink); }
.icon-button:focus-visible, .toast-close:focus-visible { outline: var(--focus-ring); }
.toast-close { display: inline-flex; align-items: center; justify-content: center; }
.card-actions { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.tabs a { display: inline-flex; align-items: center; gap: var(--space-1); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs a:focus-visible { outline: var(--focus-ring); outline-offset: -2px; }
.tabs-sub a[aria-current="page"] { border-color: var(--ink); }
.table caption { padding: var(--space-3) 14px 0; text-align: left; font-weight: var(--weight-strong); }
.cell-input-narrow { max-width: 280px; }
.pill-code { background: var(--chip); color: var(--chip-ink); }
.module-icon, .tile-icon { display: inline-flex; align-items: center; justify-content: center; color: var(--ink); }
.module-icon .icon { width: 22px; height: 22px; }
.tile-icon .icon { width: 32px; height: 32px; }
a:focus-visible, .link:focus-visible { outline: var(--focus-ring); outline-offset: 2px; border-radius: 4px; }

/* The top bar's places: icon and word on a desktop. */
.topbar-nav a { display: inline-flex; align-items: center; gap: 6px; }
.topbar-nav a .icon { opacity: .85; }
.topbar-button { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.topbar-search { position: relative; display: flex; align-items: center; }
.topbar-search .icon { position: absolute; left: 10px; color: var(--ink-muted); pointer-events: none; }
.topbar-search input {
    width: 240px; height: 36px; padding: 0 var(--space-3) 0 34px;
    border: 1px solid var(--border); border-radius: var(--control-radius);
    background: var(--surface); color: var(--ink); font: inherit; font-size: var(--text-base);
}
.topbar-search input:focus { outline: var(--focus-ring); outline-offset: 1px; }
.topbar-search-link { display: none; }
@media (max-width: 1023.98px) {
    .topbar-search { display: none; }
    .topbar-search-link { display: inline-flex; }
    .topbar-nav a span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .topbar-nav a { padding: 8px; }
}
@media (max-width: 767.98px) {
    .topbar-end .avatar { display: none; }
    .topbar-logout .topbar-button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* The bottom tabs: always in the app; on the web at phone width only,
   the same places the top bar has on a wider screen. */
body.has-tabbar .tabbar { display: none; }
@media (max-width: 767.98px) {
    body.has-tabbar .tabbar { display: flex; }
    body.has-tabbar { padding-bottom: calc(var(--tabbar-height) + var(--safe-bottom)); }
    body.has-tabbar .toast-region { bottom: calc(var(--tabbar-height) + var(--safe-bottom) + var(--space-3)); }
    body.has-tabbar .offline-banner { bottom: calc(var(--tabbar-height) + var(--safe-bottom) + 12px); }
    body.has-tabbar:has(#offline-banner) { padding-bottom: calc(var(--tabbar-height) + var(--safe-bottom) + 72px); }
}
@media print { .tabbar { display: none !important; } }

/* Global search (staff/search). */
.search-form { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.search-form input[type="search"] { flex: 1 1 240px; min-width: 0; height: var(--control-height); padding: 0 var(--space-3); border: 1px solid var(--border); border-radius: var(--control-radius); background: var(--surface); color: var(--ink); font: inherit; }
.search-results { margin: 0; padding: 0; list-style: none; }
.search-results li + li { border-top: 1px solid var(--border); }
.search-results a { display: flex; align-items: center; gap: var(--space-3); min-height: var(--tap-min); padding: var(--space-2) 0; }
.search-results a:hover strong { color: var(--brand); }
.search-results .icon { color: var(--ink-muted); }
.search-result-main { display: flex; flex-direction: column; min-width: 0; }
.search-result-main small { color: var(--ink-muted); font-size: var(--text-sm); }
.search-results mark { background: var(--warn-soft); color: inherit; border-radius: 2px; }

/* Settings › Appearance: three choices side by side. */
.theme-choices { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.theme-choices label { display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--tap-min); padding: 0 var(--space-3); border: 1px solid var(--border); border-radius: var(--control-radius); font-weight: var(--weight-medium); cursor: pointer; }
.theme-choices label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); }

/* A setting that is on or off, with its line of help (ui_switch()). */
.switch-list { display: flex; flex-direction: column; gap: var(--space-2); }
.switch-row { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-2) 0; font-size: var(--text-base); font-weight: var(--weight-medium); cursor: pointer; }
.switch-row input { flex: none; width: 18px; height: 18px; margin-top: 2px; accent-color: var(--brand); }
.switch-text { display: flex; flex-direction: column; gap: 2px; }
.switch-text small { font-size: var(--text-xs); font-weight: 400; color: var(--ink-muted); }

/* The gradebook grid (gap-closing Slice 7 step 4): results typed into the
   table; a cell shows that it is saving, saved, or refused. */
.gradebook-grid td.grade-cell { position: relative; padding: var(--space-1) var(--space-2); white-space: nowrap; }
.gradebook-grid .grade-input { width: 4.5em; min-width: 0; height: 32px; padding: 0 var(--space-2); text-align: center; background: var(--surface); color: var(--ink); }
.gradebook-grid select.grade-input { width: auto; max-width: 9em; text-align: left; }
.gradebook-grid .grade-levels { display: inline-flex; gap: var(--space-1); }
.gradebook-grid .grade-level { display: inline-flex; flex-direction: column; align-items: center; font-size: var(--text-xs); color: var(--ink-muted); }
.gradebook-grid .grade-level .grade-input { width: 2.6em; padding: 0; }
.gradebook-grid .grade-open { display: inline-flex; vertical-align: middle; color: var(--ink-muted); }
.gradebook-grid .grade-input:focus { outline: var(--focus-ring); outline-offset: 1px; }
.gradebook-grid td.is-saving .grade-input { border-color: var(--info); }
.gradebook-grid td.is-saved .grade-input { border-color: var(--success); }
.gradebook-grid td.is-error .grade-input { border-color: var(--danger); background: var(--danger-soft); }

/* The Assistant panel (staff/copilot and account/assistant, the same
   panel): the conversation, then the
   request form. */
.assistant-thread { display: flex; flex-direction: column; gap: var(--space-3); margin-bottom: var(--space-4); }
.assistant-thread:not(:has(.assistant-message)) { display: none; }
.assistant-message { max-width: 100%; padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.assistant-message.is-person { align-self: flex-end; max-width: min(36em, 100%); background: var(--brand-soft); border-color: transparent; }
.assistant-message[aria-busy="true"] .assistant-text { color: var(--ink-muted); }
.assistant-who { margin: 0 0 var(--space-1); font-size: var(--text-xs); font-weight: var(--weight-strong); color: var(--ink-muted); }
.assistant-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.assistant-card + .hint, .assistant-body .field-error { margin-top: var(--space-2); }
.draft-card .card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); flex-wrap: wrap; }
.draft-card .card-head h3 { margin: 0; font-size: var(--text-lg); }
.assistant-composer { border-top: 1px solid var(--border); padding-top: var(--space-4); }
.assistant-thread:not(:has(.assistant-message)) + .assistant-composer { border-top: 0; padding-top: 0; }
/* An answer's parts (gap-closing Slice 6): its text, the steps the assistant
   took, and its cards, each card's left edge saying where it stands. */
.assistant-body > * + * { margin-top: var(--space-2); }
.assistant-step { margin: 0; color: var(--ink-muted); font-size: var(--text-sm); }
.assistant-card { padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-left: 4px solid var(--brand); border-radius: 10px; background: var(--surface); overflow-wrap: anywhere; }
.assistant-card-approval { border-left-color: var(--mark-amber); }
.assistant-card[data-state="used"], .assistant-card[data-state="approved"] { border-left-color: var(--success); }
.assistant-card[data-state="discarded"], .assistant-card[data-state="expired"], .assistant-card[data-state="withdrawn"],
.assistant-card[data-state="rejected"] { border-left-color: var(--border); }
.assistant-card[data-state="failed"] { border-left-color: var(--danger); }
.assistant-card-kind { margin: 0; font-size: var(--text-xs); font-weight: var(--weight-strong); color: var(--ink-muted); text-transform: uppercase; letter-spacing: .03em; }
.assistant-card-summary { margin: var(--space-1) 0; font-size: var(--text-base); font-weight: var(--weight-strong); }
.assistant-card-state { margin: 0; font-size: var(--text-sm); color: var(--ink-muted); }
.assistant-card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: var(--space-2); }
/* Editing a draft: "Use this version" is the card's one primary action while the form is open. */
.assistant-card-actions:has(> .assistant-edit[open]) > .assistant-use { display: none; }
.assistant-edit { flex-basis: auto; }
.assistant-edit[open] { flex-basis: 100%; order: 3; }
.assistant-edit > summary { list-style: none; }
.assistant-edit > summary::-webkit-details-marker { display: none; }
.assistant-edit-form { margin-top: var(--space-3); }
/* Slice R2: what Milebud reads before the answer (one line, as it reads), the answer's check against the
   records, and "What the AI used" (folded). */
.assistant-activity { margin: 0; color: var(--ink-muted); font-size: var(--text-sm); font-style: italic; }
.assistant-checked { margin: 0; font-size: var(--text-xs); font-weight: var(--weight-strong); color: var(--success); }
.assistant-checked.is-flagged { color: var(--mark-amber); }
.assistant-card-used { padding-top: var(--space-2); padding-bottom: var(--space-2); border-left-color: var(--border); }
.assistant-used > summary { cursor: pointer; font-size: var(--text-sm); color: var(--ink-muted); }
.assistant-used > ul { margin: var(--space-2) 0 0; padding-left: var(--space-4); font-size: var(--text-sm); color: var(--ink-muted); }
/* Slice R3: "This helped" / "Not useful, because..." under an answer or a draft. */
.assistant-feedback { margin-top: var(--space-2); }
.assistant-feedback-state { margin: 0 0 var(--space-1); font-size: var(--text-xs); color: var(--ink-muted); }
.assistant-feedback-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-2); }
.assistant-feedback-why > summary { list-style: none; cursor: pointer; }
.assistant-feedback-why > summary::-webkit-details-marker { display: none; }
.assistant-feedback-why[open] { flex-basis: 100%; }
.assistant-feedback-why > form { margin-top: var(--space-2); }
/* The rating of an AI assist draft without JavaScript (Slice R3 with the F chain): controls of the form it rates, so a block, not a form,
   laid out and spaced as the form above (a grid here sized its column to the reasons' list and reached past a phone's edge). */
.assistant-feedback-why > div.form { margin-top: var(--space-2); }
.assistant-feedback button[aria-pressed="true"] { border-color: var(--brand); color: var(--brand-strong); }
/* Each role's Assistant: the conversation's head, the kinds of help and the suggested questions. */
.assistant-head h2 { min-width: 0; overflow-wrap: anywhere; }
.assistant-modes, .assistant-suggestions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-3); }
.chip { min-height: 32px; padding: 4px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--ink); font: inherit; font-size: var(--text-sm); text-align: left; cursor: pointer; }
.chip:hover { border-color: var(--brand); color: var(--brand-strong); }
/* Admin portal › Assistant requests and Automations, and Prepared for you (gap-closing Slice 6). */
.approval-list { display: flex; flex-direction: column; gap: var(--space-3); }
/* AI tasks (portal/account/ai-tasks) */
.ai-tasks { display: flex; flex-direction: column; gap: var(--space-4); }
.ai-task-group h2 { margin: 0 0 var(--space-2); }
.ai-task-list { display: flex; flex-direction: column; gap: var(--space-3); margin: 0; padding: 0; list-style: none; }
.ai-task-title { min-width: 0; overflow-wrap: anywhere; font-weight: var(--weight-strong); color: inherit; }
.ai-task .hint { margin: var(--space-1) 0 0; }
.approval-summary { margin: 0; min-width: 0; overflow-wrap: anywhere; font-weight: var(--weight-strong); }
.approval .hint, .automation .hint, .prepared .hint { margin: var(--space-1) 0 0; }
.approval-form { margin-top: var(--space-3); }
.approval-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }
.automation-rule { margin: 0; }
.automation-settings { margin-top: var(--space-3); }
.automation-settings > summary { cursor: pointer; color: var(--brand); font-weight: var(--weight-strong); }
.automation-runs { margin: var(--space-2) 0 0; padding: 0; list-style: none; }
.automation-runs li { padding: var(--space-1) 0; overflow-wrap: anywhere; }

/* ── Rich text (gap-closing Slice 12): mb_rich() output and its editor ── */
.rich { overflow-wrap: anywhere; }
.rich > :first-child { margin-top: 0; }
.rich > :last-child { margin-bottom: 0; }
.rich p { margin: 0 0 8px; }
.rich ul, .rich ol { margin: 0 0 8px; padding-left: 22px; }
.rich li { margin: 2px 0; }
.rich a { color: var(--brand); text-decoration: underline; }
.rich img { display: block; max-width: 100%; height: auto; margin: 8px 0; border-radius: 8px; }
.thread .rich { margin-top: 4px; font-size: 14px; }
.thread .rich p { margin-bottom: 4px; }
.rich-toolbar { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 4px; }
.rich-tool { min-width: 36px; min-height: 36px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; }
.rich-tool:hover { background: var(--surface-hover); }
.rich-tool:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.rich-tool:disabled { opacity: 0.5; cursor: default; }
.rich-bold { font-weight: 700; }
.rich-italic { font-style: italic; }
.rich-preview-toggle { margin-left: auto; }
.rich-preview { min-height: 64px; padding: 10px 12px; border: 1px dashed var(--border); border-radius: 8px; background: var(--surface); }
.language-choice { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin: 16px auto 24px; padding: 0 16px; }
.language-choice button[aria-current] { color: var(--ink); font-weight: 600; text-decoration: none; cursor: default; opacity: 1; }

/* ── The Ask AI bar (Ctrl K; web/src/islands/ask.ts) ───────────────────── */
.ask-dialog { width: min(640px, calc(100vw - 32px)); margin-top: 10vh; padding: var(--space-4); }
.ask-head { display: flex; align-items: center; gap: 8px; }
.ask-input { flex: 1; min-width: 0; height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; font-size: 16px; }
.ask-results { margin: 8px 0 0; padding: 0; list-style: none; max-height: 50vh; overflow-y: auto; }
.ask-option { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.ask-option.is-active, .ask-option:hover { background: var(--brand-soft); }
.ask-group { flex: none; font-size: 12px; }
.ask-none { padding: 8px 10px; }
.ask-thread { max-height: 50vh; overflow-y: auto; margin-top: 8px; }
.ask-more { display: inline-block; margin-top: 8px; }
.ask-hint { margin: 8px 0 0; font-size: 12px; }
.assistant-links { margin: 4px 0 0; padding-left: 18px; }

/* ── The AI edge glow (web/src/lib/glow.ts, 2026-10-06) ────────────────────
   While the person's assistant is called, a soft light flows around the
   edges of the screen. One fixed layer above the page and below the toasts
   (dialogs are in the browser's top layer, above it): it never takes a click
   (pointer-events: none), never changes the layout and adds no scroll bar
   (contain: strict, overflow hidden). Two large conic gradients turn behind
   a mask that keeps the light at the edges and fades it inward, so the
   middle of the screen is untouched; only their rotation and the layer's
   opacity and scale animate (the graphics chip's work). With reduced motion
   the light stays still. */
.ai-glow {
    --glow-depth: clamp(26px, 5.5vmin, 64px);
    position: fixed; inset: 0; z-index: 65;
    pointer-events: none; overflow: hidden; contain: strict;
    opacity: 0; transform: scale(1.05);
    transition: opacity .7s cubic-bezier(.2, .7, .2, 1), transform .9s cubic-bezier(.2, .7, .2, 1);
}
.ai-glow[hidden] { display: none; }
.ai-glow[data-glow="listening"], .ai-glow[data-glow="thinking"], .ai-glow[data-glow="waiting"], .ai-glow[data-glow="done"] {
    transform: scale(1); transition-duration: .45s, .6s;
}
.ai-glow[data-glow="listening"] { opacity: 1; }
.ai-glow[data-glow="thinking"]  { opacity: 1; }
.ai-glow[data-glow="waiting"]   { opacity: .62; }
.ai-glow[data-glow="done"]      { opacity: .72; }
.ai-glow[data-glow="off"]       { transition-duration: .7s, 1s; }
/* The light: everything but a band along the four edges is masked away. */
.ai-glow-band {
    position: absolute; inset: 0;
    -webkit-mask-image: linear-gradient(to bottom, var(--glow-mask), var(--glow-mask-mid) calc(var(--glow-depth) * .45), transparent var(--glow-depth)),
        linear-gradient(to top, var(--glow-mask), var(--glow-mask-mid) calc(var(--glow-depth) * .45), transparent var(--glow-depth)),
        linear-gradient(to right, var(--glow-mask), var(--glow-mask-mid) calc(var(--glow-depth) * .45), transparent var(--glow-depth)),
        linear-gradient(to left, var(--glow-mask), var(--glow-mask-mid) calc(var(--glow-depth) * .45), transparent var(--glow-depth));
    mask-image: linear-gradient(to bottom, var(--glow-mask), var(--glow-mask-mid) calc(var(--glow-depth) * .45), transparent var(--glow-depth)),
        linear-gradient(to top, var(--glow-mask), var(--glow-mask-mid) calc(var(--glow-depth) * .45), transparent var(--glow-depth)),
        linear-gradient(to right, var(--glow-mask), var(--glow-mask-mid) calc(var(--glow-depth) * .45), transparent var(--glow-depth)),
        linear-gradient(to left, var(--glow-mask), var(--glow-mask-mid) calc(var(--glow-depth) * .45), transparent var(--glow-depth));
    animation: ai-glow-breathe 3.6s ease-in-out infinite alternate;
}
.ai-glow-flow {
    position: absolute; left: 50%; top: 50%;
    width: 150vmax; height: 150vmax; margin: -75vmax 0 0 -75vmax;
    border-radius: 50%;
    will-change: transform;
}
.ai-glow-a {
    background: conic-gradient(from 0deg, var(--glow-blue), var(--glow-cyan) 14%, var(--glow-violet) 30%, var(--glow-purple) 44%, var(--glow-pink) 56%, var(--glow-warm) 63%, var(--glow-pink) 70%, var(--glow-violet) 84%, var(--glow-blue));
    animation: ai-glow-spin 11s linear infinite;
}
.ai-glow-b {
    background: conic-gradient(from 180deg, transparent, var(--glow-sky-soft) 12%, transparent 28%, var(--glow-violet-soft) 46%, transparent 60%, var(--glow-pink-soft) 76%, transparent 90%);
    animation: ai-glow-spin 17s linear infinite reverse;
    opacity: .7;
}
/* A thin brighter rim at the very edge: glass-like. */
.ai-glow-rim {
    position: absolute; inset: 0;
    box-shadow: inset 0 0 0 1.5px var(--glow-rim), inset 0 0 14px 1px var(--glow-rim-bloom);
    animation: ai-glow-breathe 3.6s ease-in-out infinite alternate;
}
/* Thinking: slightly stronger, slower breathing; the colours drift slower. */
.ai-glow[data-glow="thinking"] .ai-glow-band, .ai-glow[data-glow="thinking"] .ai-glow-rim { animation-duration: 5.2s; animation-name: ai-glow-breathe-strong; }
.ai-glow[data-glow="thinking"] .ai-glow-a { animation-duration: 16s; }
.ai-glow[data-glow="thinking"] .ai-glow-b { animation-duration: 24s; opacity: .9; }
/* Waiting for a tap: calm. */
.ai-glow[data-glow="waiting"] .ai-glow-band, .ai-glow[data-glow="waiting"] .ai-glow-rim { animation-duration: 6s; }
.ai-glow[data-glow="waiting"] .ai-glow-a { animation-duration: 24s; }
@keyframes ai-glow-spin { to { transform: rotate(1turn); } }
@keyframes ai-glow-breathe { from { opacity: .78; } to { opacity: 1; } }
@keyframes ai-glow-breathe-strong { from { opacity: .9; } to { opacity: 1; } }
/* In the app the screen's corners are round: the light follows them (near enough: a page cannot read the radius). */
body.in-app .ai-glow { border-radius: 44px; }
/* A dark page: a little softer, so it never glares. */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ai-glow-a { opacity: .85; } }
:root[data-theme="dark"] .ai-glow-a { opacity: .85; }
@media (prefers-reduced-motion: reduce) {
    .ai-glow, .ai-glow[data-glow] { transform: none; transition: opacity .3s linear; }
    .ai-glow-flow, .ai-glow-band, .ai-glow-rim { animation: none !important; }
}
@media print { .ai-glow { display: none !important; } }

/* The Ask AI box no longer dims the page: the glow says the assistant is listening. */
.ask-dialog::backdrop { background: transparent; }
.ask-dialog { border: 1px solid var(--border); }
.ask-mic[aria-pressed="true"] { border-color: var(--brand); color: var(--brand); }
.ask-voice-status { margin: 8px 0 0; }
.ask-send-stop { margin-left: 4px; }
.assistant-voice { margin-left: 8px; }
.assistant-voice[aria-pressed="true"] { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

/* ── AI assist on a form (Slice F1, build-prompt Phase 5) ──────────────────
   Fill with AI and its intake at the top of the form, each prose field's
   AI assist under it, the review panel beside the form (above it on a
   phone), the review box above the buttons, and the marks on what the AI
   filled. The ai-assist island's markup. */
.ai-assist-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); padding: var(--space-3); border: 1px dashed var(--border); border-radius: 8px; background: var(--canvas); }
.ai-assist-bar .button, .ai-intake .button { display: inline-flex; align-items: center; gap: 6px; }
.ai-assist-bar .hint { flex: 1 1 220px; min-width: 0; }
/* "Look on the web" (Slice W1 with the F chain): a box the person ticks for one fill or draft, unticked by default. */
.ai-assist-bar .ai-web { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; font-size: var(--text-sm); font-weight: 600; }
.ai-intake { display: grid; gap: var(--space-3); padding: var(--space-4); border: 1px solid var(--border); border-radius: 8px; background: var(--surface); min-width: 0; }
.ai-intake[hidden], .ai-question[hidden], .ai-review-gate[hidden] { display: none; }
.ai-intake legend { font-weight: 600; }
.ai-question .hint { margin: var(--space-2) 0 var(--space-1); }
.ai-field-assist { margin-top: calc(-1 * var(--space-2)); min-width: 0; }
.ai-field-assist > summary { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; padding: 2px var(--space-2); border-radius: 6px; color: var(--brand); font-size: var(--text-xs); font-weight: 600; cursor: pointer; list-style: none; }
.ai-field-assist > summary::-webkit-details-marker { display: none; }
.ai-field-assist > summary:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.ai-field-assist[open] > summary { background: var(--brand-soft); }
.ai-field-assist-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-2); margin-top: var(--space-1); padding: var(--space-3); border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.ai-field-assist-body > .button { justify-self: start; }
.ai-field-assist-body label[hidden] { display: none; }
.ai-field-preview { padding: var(--space-3); border-left: 3px solid var(--brand); border-radius: 6px; background: var(--canvas); }
.ai-suggestion-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--text-base); line-height: 1.5; }
.ai-suggestion-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--space-2); }
.ai-suggestion-actions [aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); }
.ai-suggestion-edit { width: 100%; margin-top: var(--space-2); padding: var(--space-2); border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: var(--text-base); }
.ai-filled textarea, .ai-filled input, .ai-filled select { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand-soft); }
.ai-filled-note { display: flex; align-items: center; gap: 4px; margin: var(--space-1) 0 0; color: var(--brand); font-size: var(--text-xs); }
.ai-tag { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; padding: 0 6px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-strong); font-size: var(--text-xs); font-weight: 600; white-space: nowrap; }
.ai-before { font-size: var(--text-sm); }
.ai-before > summary { cursor: pointer; color: var(--ink-muted); min-height: 24px; }
.ai-review-gate { padding: var(--space-3); border: 1px solid var(--brand); border-radius: 8px; background: var(--brand-soft); }
.ai-review-gate .switch-row { padding: 0; }
.ai-provenance { display: flex; align-items: center; gap: 6px; margin: var(--space-2) 0 0; color: var(--ink-muted); font-size: var(--text-xs); }
/* A table's row with AI assist (a final grade comment per student, Slice F2): the control under the input, the mark beside it. */
td > .ai-field-assist { margin-top: var(--space-1); }
.ai-provenance-mark { display: inline-flex; align-items: center; margin-left: 4px; color: var(--ink-muted); vertical-align: middle; }
.ai-sources h3 { margin: var(--space-3) 0 var(--space-1); font-size: var(--text-sm); }
/* A source reads as one line of text (its number, its linked title, its date), not a list row's two ends: a number squeezed
   to its narrowest would break inside "[1]" at 390 px. */
.ai-sources li { display: block; overflow-wrap: anywhere; }
/* One column that never grows past the page: an auto track would take a control's own width (a file input's) and widen the page at 390 px. */
.ai-assist-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); min-width: 0; }
.ai-assist-layout > .ai-review-panel { order: -1; min-width: 0; }
.ai-review-panel[hidden] { display: none; }
.ai-review-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.ai-review-head h2 { margin: 0; }
.ai-review-status { margin: var(--space-2) 0; }
.ai-suggestions { display: grid; gap: var(--space-3); margin: 0 0 var(--space-3); padding: 0; list-style: none; }
.ai-suggestion { padding: var(--space-3); border: 1px solid var(--border); border-radius: 8px; min-width: 0; }
.ai-suggestion h3 { margin: 0 0 var(--space-1); font-size: var(--text-sm); }
.ai-suggestion.is-discarded .ai-suggestion-text { opacity: .55; text-decoration: line-through; }
@media (min-width: 1024px) {
    .ai-assist-layout.is-reviewing { grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); align-items: start; }
    .ai-assist-layout.is-reviewing > .ai-review-panel { order: 0; position: sticky; top: var(--space-4); max-height: calc(100dvh - 32px); overflow-y: auto; padding-top: 0; }
    /* Long suggestions scroll between the panel's heading and its buttons, which stay in view (Slice F6). */
    .ai-assist-layout.is-reviewing > .ai-review-panel:has(> .toolbar) { padding-bottom: 0; }
    .ai-assist-layout.is-reviewing > .ai-review-panel > .ai-review-head { position: sticky; top: 0; z-index: 1; padding: var(--space-6) 0 var(--space-2); background: var(--surface); }
    .ai-assist-layout.is-reviewing > .ai-review-panel > .toolbar { position: sticky; bottom: 0; z-index: 1; padding: var(--space-3) 0 var(--space-6); background: var(--surface); }
}

/* Fees (a family member's fee accounts, over MileBud Finance's API; ADR 0022): tokens only, nothing here names a colour. */
.fees-total { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; margin: 0; }
.fees-total strong { font-size: var(--text-2xl); font-variant-numeric: tabular-nums; }
.fees-accounts { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--space-3); }
.fees-account { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; min-height: var(--tap-min); color: inherit; text-decoration: none; }
.fees-account:hover { background: var(--surface-hover); }
.fees-account:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.fees-account-name { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.fees-account-balance { font-variant-numeric: tabular-nums; white-space: nowrap; }
.fees-account-title { font-size: var(--text-xl); margin: 0; }
.fees-pay { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3); max-width: 360px; }
.fees-pay .field { width: 100%; }
.fees-pay-amount { margin: 0; font-weight: var(--weight-medium); font-variant-numeric: tabular-nums; }
.fees-test-mode { margin: 0; padding: var(--space-2) var(--space-3); border-radius: var(--radius); background: var(--warn-soft); color: var(--ink); }
.fees-waiting { margin: 0; padding: 0; list-style: none; }
.fees-waiting li { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; padding: var(--space-2) 0; }
.fees-waiting li + li { border-top: 1px solid var(--border); }
.fees-more { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); padding-top: var(--space-3); }
.fees-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-4); margin: 0 0 var(--space-4); }
.fees-facts dt { font-size: var(--text-sm); color: var(--ink-muted); }
.fees-facts dd { margin: var(--space-1) 0 0; font-weight: var(--weight-medium); overflow-wrap: anywhere; }
@media print { .fees-pay, .fees-more { display: none; } }

/* The avatar's menu (AccountMenu.tsx): the person, their own pages and Log out. */
.account-menu { position: relative; }
.account-menu > summary { list-style: none; cursor: pointer; }
.account-menu > summary::-webkit-details-marker { display: none; }
.account-panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; display: flex; flex-direction: column; min-width: 260px; padding: 8px; background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-md); }
.account-who { display: flex; align-items: center; gap: 12px; padding: 8px 8px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.account-who .mark { margin-right: 0; background: var(--brand); color: var(--on-brand); }
.account-who > span:last-child { display: flex; flex-direction: column; }
.account-panel a { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: 8px; color: var(--ink); }
.account-panel a:hover, .account-panel .topbar-button:hover { background: var(--canvas); }
.account-panel .topbar-logout { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--border); }
.account-panel .topbar-button { width: 100%; padding: 10px 8px; color: var(--ink); }
@media (max-width: 767.98px) {
    .topbar-end .account-menu > .avatar { display: inline-flex; }
    .account-panel .topbar-logout .topbar-button span { position: static; width: auto; height: auto; clip: auto; overflow: visible; }
}
/* ── Fonts, motion and the mascot (used by the next look only; nothing here names it) ──────────────────────────────
   The phone app's type, from this site's own files (the policy allows nothing else): Bricolage Grotesque for headings and
   big numbers, Manrope for the rest. The mascot (ui/mascot.tsx) is the phone's berry ball, in 3D where the browser can
   draw it (a canvas) and as a flat picture until then. */
@font-face { font-family: "Manrope"; font-weight: 500; font-style: normal; font-display: swap; src: url("/portal/assets/fonts/Manrope_500Medium.ttf") format("truetype"); }
@font-face { font-family: "Manrope"; font-weight: 600; font-style: normal; font-display: swap; src: url("/portal/assets/fonts/Manrope_600SemiBold.ttf") format("truetype"); }
@font-face { font-family: "Manrope"; font-weight: 700; font-style: normal; font-display: swap; src: url("/portal/assets/fonts/Manrope_700Bold.ttf") format("truetype"); }
@font-face { font-family: "Bricolage Grotesque"; font-weight: 600; font-style: normal; font-display: swap; src: url("/portal/assets/fonts/BricolageGrotesque_600SemiBold.ttf") format("truetype"); }
@font-face { font-family: "Bricolage Grotesque"; font-weight: 700; font-style: normal; font-display: swap; src: url("/portal/assets/fonts/BricolageGrotesque_700Bold.ttf") format("truetype"); }
@keyframes rise-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes float-soft { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes drift { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(18px, -14px) scale(1.06); } }
.mascot { position: relative; display: inline-block; flex: none; width: var(--mascot, 56px); height: var(--mascot, 56px); cursor: pointer; }
.mascot-flat, .mascot-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.mascot-flat { padding: 18%; }
.mascot[data-drawn="three"] .mascot-flat { display: none; }

/* A screen's code is on its way (router.tsx, lazyScreen.tsx): a thin bar along the top says so; with less motion it just stays. */
@keyframes route-pending { from { background-position: -40% 0; } to { background-position: 140% 0; } }
.route-pending { position: fixed; z-index: 100; top: 0; left: 0; right: 0; height: 3px; pointer-events: none; background: linear-gradient(90deg, transparent, var(--brand), transparent) no-repeat; background-size: 40% 100%; animation: route-pending 1s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .route-pending { animation: none; background: var(--brand); opacity: .5; } }

/* ── The next look (shell/look.ts, <html data-look="next">) ─────────────────
   Tried out per browser (`?look=next`, back with `?look=classic`): calmer surfaces, larger titles, the places as a
   rail on a desktop, the Ask box docked at the foot of the page, and the glow's colours as the edge of what the AI
   drafted and nobody has checked yet. Everything is under the attribute, so a page without it is drawn exactly as
   before; MileBud Finance never sets it. The values below redefine tokens; the rules after them name none. */
:root[data-look="next"] {
    --canvas: #f5f7f6;
    --surface: #ffffff;
    --surface-hover: #f7f9f8;
    --border: #e4e9e6;
    --ink: #0e1512;
    --ink-muted: #5a6661;
    --topbar: #fbfcfb;
    --on-topbar: #0e1512;
    --on-topbar-muted: #5a6661;
    --topbar-hover: rgba(14, 21, 18, 0.06);
    --inverse: #0e1512;
    --neutral-soft: #eef1f0;
    --brand-strong: #0b5f58;
    --brand-soft: #ddf1ee;
    --shadow-sm: 0 1px 2px rgba(14, 21, 18, 0.05), 0 4px 12px rgba(14, 21, 18, 0.06);
    --shadow-md: 0 2px 4px rgba(14, 21, 18, 0.04), 0 14px 36px rgba(14, 21, 18, 0.1);
    --shadow-lg: 0 4px 8px rgba(14, 21, 18, 0.05), 0 28px 72px rgba(14, 21, 18, 0.16);
    --backdrop: rgba(14, 21, 18, 0.32);
    --radius: 20px;
    --control-radius: 12px;
    --text-title: 30px;
    --text-display: 40px;
    --rail-width: 88px;
    --dock-height: 56px;
    --look-ease: cubic-bezier(.2, .8, .2, 1);
    --hero-light: #19a699;
    --hero-blob-pink: #ffb3d0;
    --hero-blob-mint: #7ff0e0;
    --on-hero: #ffffff;
    --hero-deep: #06201e;
    --hero-mid: var(--brand);
    --hero-end: var(--brand-strong);
    --mascot-shadow: rgba(60, 5, 30, 0.35);
    --mascot-shadow-soft: rgba(94, 10, 48, 0.28);
}
@media (prefers-color-scheme: dark) {
    :root[data-look="next"]:not([data-theme="light"]) {
        --canvas: #0b0f0e;
        --surface: #141a18;
        --surface-hover: #1a211e;
        --border: #26302c;
        --ink: #eef2f0;
        --ink-muted: #9aa6a1;
        --topbar: #101514;
        --on-topbar: #eef2f0;
        --on-topbar-muted: #9aa6a1;
        --topbar-hover: rgba(255, 255, 255, 0.07);
        --inverse: #eef2f0;
        --neutral-soft: #1f2724;
        --brand-strong: #5eead4;
        --brand-soft: #123f3b;
        --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.5);
        --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.5);
        --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.6);
        --backdrop: rgba(0, 0, 0, 0.6);
        --hero-light: #1a8a80;
        --hero-blob-pink: #ffb3d0;
        --hero-blob-mint: #7ff0e0;
        --on-hero: #ffffff;
        --hero-deep: #06201e;
        --hero-mid: color-mix(in srgb, var(--brand) 32%, var(--hero-deep));
        --hero-end: var(--hero-deep);
        --mascot-shadow: rgba(60, 5, 30, 0.35);
        --mascot-shadow-soft: rgba(94, 10, 48, 0.28);
    }
}
:root[data-look="next"][data-theme="dark"] {
    --canvas: #0b0f0e;
    --surface: #141a18;
    --surface-hover: #1a211e;
    --border: #26302c;
    --ink: #eef2f0;
    --ink-muted: #9aa6a1;
    --topbar: #101514;
    --on-topbar: #eef2f0;
    --on-topbar-muted: #9aa6a1;
    --topbar-hover: rgba(255, 255, 255, 0.07);
    --inverse: #eef2f0;
    --neutral-soft: #1f2724;
    --brand-strong: #5eead4;
    --brand-soft: #123f3b;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.6);
    --backdrop: rgba(0, 0, 0, 0.6);
    --hero-light: #1a8a80;
    --hero-blob-pink: #ffb3d0;
    --hero-blob-mint: #7ff0e0;
    --on-hero: #ffffff;
    --hero-deep: #06201e;
    --hero-mid: color-mix(in srgb, var(--brand) 32%, var(--hero-deep));
    --hero-end: var(--hero-deep);
    --mascot-shadow: rgba(60, 5, 30, 0.35);
    --mascot-shadow-soft: rgba(94, 10, 48, 0.28);
}

/* Type and surfaces. */
[data-look="next"] h1 { letter-spacing: -0.02em; }
[data-look="next"] h2 { font-size: 17px; letter-spacing: -0.01em; }
[data-look="next"] .page { gap: var(--space-5); padding-top: var(--space-8); }
[data-look="next"] .page-head h1 { font-size: var(--text-display); line-height: 1.08; letter-spacing: -0.035em; }
[data-look="next"] .page-head-text p { margin-top: var(--space-2); }
[data-look="next"] .home-child h1, [data-look="next"] .announcement h1 { font-size: var(--text-title); line-height: 1.15; letter-spacing: -0.025em; }
[data-look="next"] .link, [data-look="next"] .table a.strong { color: var(--ink); font-weight: var(--weight-medium); }
[data-look="next"] .link:hover, [data-look="next"] .table a.strong:hover { color: var(--brand); }
[data-look="next"] .card-head .link, [data-look="next"] .breadcrumb a { color: var(--ink-muted); }
[data-look="next"] .card-head .link:hover, [data-look="next"] .breadcrumb a:hover { color: var(--brand); }
[data-look="next"] .pill { padding: 3px 10px; font-weight: var(--weight-medium); }
[data-look="next"] .table th { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--ink-muted); }
[data-look="next"] .tabs a { padding: 10px 2px; margin-right: var(--space-5); }
[data-look="next"] .tabs-sub a { padding: 6px 12px; margin-right: var(--space-1); }
[data-look="next"] .toolbar input[type="search"], [data-look="next"] .toolbar select, [data-look="next"] .field select,
[data-look="next"] .field textarea, [data-look="next"] .filter-input, [data-look="next"] input[type="datetime-local"],
[data-look="next"] .search-form input[type="search"], [data-look="next"] .copilot-draft, [data-look="next"] .checks { border-radius: var(--control-radius); }
[data-look="next"] .task-item a, [data-look="next"] .class-list li, [data-look="next"] .agenda-item, [data-look="next"] .choose-option { border-radius: 14px; }
[data-look="next"] .dialog { border-radius: 24px; }
[data-look="next"] .toast { border-radius: 14px; }

/* Controls answer a press. */
[data-look="next"] .button, [data-look="next"] .chip, [data-look="next"] .choose-option { transition: transform .12s ease, background-color .12s ease, border-color .12s ease; }
[data-look="next"] .button:active, [data-look="next"] .chip:active, [data-look="next"] .choose-option:active { transform: scale(.97); }
[data-look="next"] .button { font-weight: var(--weight-medium); }
[data-look="next"] .button-small { border-radius: 10px; }

/* The top bar is light for everyone, and its Log out is an icon. */
[data-look="next"] .topbar { border-bottom: 1px solid var(--border); }
[data-look="next"] .topbar-nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-strong); }
[data-look="next"] .topbar-search input { border-radius: var(--control-radius); background: var(--canvas); }
[data-look="next"] .avatar { background: var(--neutral-soft); color: var(--ink); }
[data-look="next"] .bell-badge { background: var(--brand); color: var(--on-brand); }

/* A desktop: the places are a rail down the side. A bar with more than six links (the platform's) stays a bar. */
@media (min-width: 1024px) {
    [data-look="next"] body:has(.topbar):not(:has(.topbar-nav a:nth-child(7))) { padding-left: var(--rail-width); }
    [data-look="next"] body:not(:has(.topbar-nav a:nth-child(7))) .topbar {
        position: fixed; z-index: 30; left: 0; top: 0; bottom: 0;
        flex-direction: column; gap: var(--space-2);
        width: var(--rail-width); height: auto; padding: var(--space-4) 0;
        border-bottom: 0; border-right: 1px solid var(--border);
        overflow-y: auto; scrollbar-width: none;
    }
    [data-look="next"] body:not(:has(.topbar-nav a:nth-child(7))) .topbar-brand { flex-direction: column; gap: var(--space-2); }
    [data-look="next"] body:not(:has(.topbar-nav a:nth-child(7))) .topbar-brand .logo { width: 40px; height: 40px; border-radius: 12px; font-size: var(--text-lg); }
    [data-look="next"] body:not(:has(.topbar-nav a:nth-child(7))) .topbar-school {
        display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden;
        max-width: calc(var(--rail-width) - 12px); white-space: normal; text-align: center;
        font-size: 10px; font-weight: var(--weight-medium); line-height: var(--leading-tight); color: var(--on-topbar-muted);
    }
    [data-look="next"] body:not(:has(.topbar-nav a:nth-child(7))) .topbar-nav { flex-direction: column; gap: var(--space-1); margin: var(--space-3) 0 0; }
    [data-look="next"] body:not(:has(.topbar-nav a:nth-child(7))) .topbar-nav a {
        flex-direction: column; justify-content: center; gap: 3px;
        width: 72px; min-height: 56px; padding: var(--space-2) 0; border-radius: 14px;
        font-size: 11px; font-weight: var(--weight-medium); text-align: center;
    }
    [data-look="next"] body:not(:has(.topbar-nav a:nth-child(7))) .topbar-nav a .icon { width: 20px; height: 20px; opacity: 1; }
    [data-look="next"] body:not(:has(.topbar-nav a:nth-child(7))) .topbar-end { flex-direction: column; gap: var(--space-2); margin: auto 0 0; }
    [data-look="next"] body:not(:has(.topbar-nav a:nth-child(7))) .topbar-search { display: none; }
    [data-look="next"] body:not(:has(.topbar-nav a:nth-child(7))) .topbar-search-link { display: inline-flex; }
    [data-look="next"] body:not(:has(.topbar-nav a:nth-child(7))) .topbar-logout .topbar-button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    [data-look="next"] body:not(:has(.topbar-nav a:nth-child(7))) .topbar-bell:not(.topbar-ask), [data-look="next"] body:not(:has(.topbar-nav a:nth-child(7))) .topbar-button { width: 44px; height: 44px; justify-content: center; border-radius: 12px; }
    /* The avatar's menu opens beside the rail, not inside it: the rail scrolls, so an absolute panel was clipped at its edge
       and most of Profile, Settings and Log out could not be seen. A fixed panel is not clipped by the rail's overflow. */
    [data-look="next"] body:not(:has(.topbar-nav a:nth-child(7))) .account-panel {
        position: fixed; right: auto; top: auto;
        left: calc(var(--rail-width) + var(--space-2)); bottom: var(--space-4);
        max-height: calc(100dvh - var(--space-8)); overflow-y: auto;
    }
    /* Inside it Log out keeps its words (the rail's icon-only button rules are for the rail itself). */
    [data-look="next"] body:not(:has(.topbar-nav a:nth-child(7))) .account-panel .topbar-button { width: 100%; height: auto; justify-content: flex-start; border-radius: 8px; }
    [data-look="next"] body:not(:has(.topbar-nav a:nth-child(7))) .account-panel .topbar-logout .topbar-button span { position: static; width: auto; height: auto; clip: auto; overflow: visible; white-space: normal; }
    [data-look="next"] .admin { min-height: 100dvh; }
    [data-look="next"] .sidenav { padding: var(--space-5) var(--space-3) var(--space-6); background: var(--topbar); }
    [data-look="next"] .sidenav a { padding: 7px var(--space-3); border-left: 0; border-radius: 10px; }
    [data-look="next"] .sidenav a.is-active { background: var(--neutral-soft); }
    [data-look="next"] .sidenav-group { margin: var(--space-5) var(--space-3) 6px; font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--ink-muted); }
    [data-look="next"] .sidenav-title { margin: var(--space-1) var(--space-3) var(--space-2); }
    [data-look="next"] .admin-main { padding: var(--space-8); }
}

/* A tablet and up: the Ask button is a bar at the top centre, said by its own title; the page makes room for it, so it never covers text. */
@media (min-width: 768px) {
    [data-look="next"] .topbar .topbar-ask {
        position: fixed; z-index: 45; left: 50%; top: var(--space-4); bottom: auto; transform: translateX(-50%);
        justify-content: flex-start; gap: var(--space-3);
        width: min(560px, calc(100vw - 2 * var(--space-6))); height: var(--dock-height); padding: 0 var(--space-6) 0 10px;
        border: 1px solid var(--border); border-radius: 32px;
        background: color-mix(in srgb, var(--surface) 92%, transparent); color: var(--ink-muted); box-shadow: var(--shadow-md); backdrop-filter: blur(10px);
        font-size: var(--text-md); font-weight: 600; cursor: text;
        transition: box-shadow .25s var(--look-ease), border-color .2s ease, transform .25s var(--look-ease);
    }
    [data-look="next"] .topbar .topbar-ask .mascot { margin-top: -10px; filter: drop-shadow(0 8px 10px var(--mascot-shadow)); }
    [data-look="next"] .topbar .topbar-ask:hover { transform: translateX(-50%) translateY(1px); }
    [data-look="next"] .topbar .topbar-ask::after { content: attr(title); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    [data-look="next"] .topbar .topbar-ask .icon { color: var(--glow-violet); }
    [data-look="next"] .topbar .topbar-ask:hover { background: var(--surface); border-color: var(--glow-violet); box-shadow: var(--shadow-lg); }
    [data-look="next"] body:has(.topbar-ask:not([hidden])) .page, [data-look="next"] body:has(.topbar-ask:not([hidden])) .admin-main { padding-top: calc(var(--dock-height) + var(--space-4) + var(--space-6)); padding-bottom: var(--space-10); }
    [data-look="next"] .toast-region { bottom: var(--space-6); }
}
/* A tablet has no rail: the bar sits in the top bar's own row, between the places and the icons, so nothing is covered. */
@media (min-width: 768px) and (max-width: 1023.98px) {
    [data-look="next"] .topbar .topbar-ask { position: static; transform: none; flex: 1 1 200px; width: auto; max-width: 360px; height: 40px; margin: 0 auto; padding: 0 var(--space-4) 0 6px; border-radius: 20px; box-shadow: none; }
    [data-look="next"] .topbar .topbar-ask:hover { transform: none; }
    [data-look="next"] .topbar .topbar-ask .mascot { margin-top: 0; }
    [data-look="next"] body:has(.topbar-ask:not([hidden])) .page, [data-look="next"] body:has(.topbar-ask:not([hidden])) .admin-main { padding-top: var(--space-6); }
}
@media (min-width: 1024px) {
    [data-look="next"] body:not(:has(.topbar-nav a:nth-child(7))) .topbar .topbar-ask { left: calc(50% + var(--rail-width) / 2); width: min(560px, calc(100vw - var(--rail-width) - 2 * var(--space-6))); }
    /* A page with its own menu beside the rail (the Admin portal, a class): the bar is centred over the page, not over the window. */
    [data-look="next"] body:not(:has(.topbar-nav a:nth-child(7))):has(.sidenav) .topbar .topbar-ask { left: calc(50% + (var(--rail-width) + 240px) / 2); width: min(560px, calc(100vw - var(--rail-width) - 240px - 2 * var(--space-6))); }
}

/* A phone: the bottom tabs. */
[data-look="next"] .tabbar { background: color-mix(in srgb, var(--surface) 86%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
[data-look="next"] .tabbar a.is-active { color: var(--brand-strong); }

/* The homes: the one next step first (the page draws it there in this look), the brief as lines, quiet tiles. */
[data-look="next"] .page > .home-next { gap: var(--space-4); padding: var(--space-6); box-shadow: var(--shadow-md); }
[data-look="next"] .page > .home-next .muted { color: var(--ink); font-size: var(--text-2xl); font-weight: var(--weight-strong); line-height: var(--leading-tight); letter-spacing: -0.015em; }
[data-look="next"] .home-next .button { min-height: 48px; padding: 0 var(--space-5); border-radius: 14px; font-size: var(--text-md); }
[data-look="next"] .brief { padding: 0; border: 0; background: none; }
[data-look="next"] .brief .card-head h2 { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--ink-muted); letter-spacing: 0; }
[data-look="next"] .brief .brief-list li { justify-content: flex-start; padding: var(--space-3) 0; }
[data-look="next"] .brief .brief-list li::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
[data-look="next"] .brief .brief-list a { font-size: 17px; }
[data-look="next"] .lesson.is-now { border-radius: 14px; background: var(--brand-soft); }
[data-look="next"] .module-icon, [data-look="next"] .tile-icon, [data-look="next"] .class-badge { background: var(--neutral-soft); color: var(--ink); }
[data-look="next"] .module { border-radius: 12px; }
[data-look="next"] .module-icon { width: 36px; height: 36px; border-radius: 10px; }
[data-look="next"] .tile-icon { width: 64px; }
[data-look="next"] .child-chips a, [data-look="next"] .child-chips span { padding: var(--space-2) var(--space-4); }
[data-look="next"] .child-chips a.is-active { border-color: var(--ink); background: var(--ink); color: var(--surface); }

/* What the AI drafted and nobody has checked yet wears the glow's colours as its edge; once used it is plain. */
[data-look="next"] .ai-assist-bar, [data-look="next"] .ai-field-preview, [data-look="next"] .ai-intake,
[data-look="next"] .assistant-card[data-state="pending"], [data-look="next"] .ask-dialog {
    border: 1.5px solid transparent;
    background: linear-gradient(var(--surface), var(--surface)) padding-box,
        linear-gradient(120deg, var(--glow-blue), var(--glow-violet) 45%, var(--glow-pink) 80%, var(--glow-warm)) border-box;
}
[data-look="next"] .ai-assist-bar, [data-look="next"] .ai-field-preview, [data-look="next"] .ai-intake, [data-look="next"] .assistant-card { border-radius: 16px; }
[data-look="next"] .assistant-card { border-left-width: 1px; }
[data-look="next"] .assistant-card[data-state="pending"] { border-left-width: 1.5px; }
[data-look="next"] .ai-field-assist > summary, [data-look="next"] .ai-filled-note { color: var(--violet); }
[data-look="next"] .ai-field-assist[open] > summary, [data-look="next"] .ai-tag { background: var(--violet-soft); color: var(--violet); }
[data-look="next"] .ai-filled textarea, [data-look="next"] .ai-filled input, [data-look="next"] .ai-filled select { border-color: var(--glow-violet); box-shadow: 0 0 0 3px var(--violet-soft); }
[data-look="next"] .ai-review-gate { border-radius: 14px; }
[data-look="next"] .ask-dialog { margin-top: 12vh; padding: var(--space-5); }
[data-look="next"] .ask-input { height: 48px; border-radius: 14px; font-size: 17px; }
[data-look="next"] .ask-option { padding: 10px var(--space-3); border-radius: 10px; }
[data-look="next"] .ask-option.is-active, [data-look="next"] .ask-option:hover { background: var(--neutral-soft); }
[data-look="next"] .assistant-message { padding: 0; border: 0; background: none; }
[data-look="next"] .assistant-message.is-person { padding: 10px var(--space-4); border-radius: 18px 18px 4px 18px; background: var(--brand-soft); }

/* Signed out. */
[data-look="next"] .auth-card { padding: var(--space-8); border-radius: 24px; box-shadow: var(--shadow-md); }

/* What a page draws settles into place, once and quickly: nothing waits its turn (a page that is ready shows at once),
   and nothing moves for someone who asked for less motion. */
@keyframes look-rise { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: no-preference) {
    [data-look="next"] .page > :not(.toast-region), [data-look="next"] .admin-main > :not(.toast-region) { animation: look-rise .14s var(--look-ease) backwards; }
}
@media (prefers-reduced-motion: reduce) {
    [data-look="next"] .button, [data-look="next"] .chip, [data-look="next"] .choose-option, [data-look="next"] .topbar .topbar-ask { transition: none; }
    [data-look="next"] .button:active, [data-look="next"] .chip:active, [data-look="next"] .choose-option:active { transform: none; }
}
@media print { [data-look="next"] .topbar-ask { display: none !important; } }

/* The next look: a link inside running text is underlined (colour alone does not tell a link from its sentence), and a long
   page title wraps instead of running off a phone. */
[data-look="next"] p .link, [data-look="next"] .auth-foot .link, [data-look="next"] .hint .link, [data-look="next"] .pager .link { text-decoration: underline; text-underline-offset: 2px; }
[data-look="next"] .page-head h1 { overflow-wrap: anywhere; }
@media (max-width: 479.98px) {
    [data-look="next"] { --text-title: 24px; --text-display: 28px; }
}

/* ── The next look: type, the signed-out pages and the mascot's stage ───────────────────────────────────────────────── */
[data-look="next"] { --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; --font-display: "Bricolage Grotesque", var(--font); }
[data-look="next"] h1, [data-look="next"] h2, [data-look="next"] .page-head h1 { font-family: var(--font-display); font-weight: 700; }
[data-look="next"] .button, [data-look="next"] .field > span { font-weight: 700; }

/* Sign in and the pages beside it: the mascot's side, and the form on a quiet page. */
[data-look="next"] .auth-wrap { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 0; box-sizing: border-box; min-height: 100dvh; padding: var(--space-4); align-items: stretch; background: var(--canvas); }
[data-look="next"] .auth-hero { position: relative; overflow: hidden; isolation: isolate; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-3); margin: 0; padding: var(--space-10) var(--space-8); border-radius: 32px; color: var(--on-hero); text-align: center; background: radial-gradient(120% 90% at 20% 10%, var(--hero-light) 0%, var(--hero-mid) 38%, var(--hero-end) 100%); }
[data-look="next"] .auth-hero::before, [data-look="next"] .auth-hero::after { content: ""; position: absolute; z-index: -1; border-radius: 50%; filter: blur(46px); opacity: .5; animation: drift 14s ease-in-out infinite; }
[data-look="next"] .auth-hero::before { width: 320px; height: 320px; left: -90px; bottom: -90px; background: var(--hero-blob-pink); opacity: .32; }
[data-look="next"] .auth-hero::after { width: 260px; height: 260px; right: -70px; top: -60px; background: var(--hero-blob-mint); animation-delay: -6s; }
[data-look="next"] .auth-hero-mascot { --mascot: 340px; display: grid; place-items: center; filter: drop-shadow(0 28px 36px var(--mascot-shadow)); animation: rise-in .7s var(--look-ease) both; }
[data-look="next"] .auth-hero-title { max-width: 18ch; margin: var(--space-3) 0 0; font-family: var(--font-display); font-weight: 700; font-size: clamp(26px, 3.2vw, 38px); line-height: 1.08; letter-spacing: -0.03em; animation: rise-in .7s .12s var(--look-ease) both; }
[data-look="next"] .auth-hero-lead { max-width: 34ch; margin: 0; font-size: var(--text-lg); line-height: 1.5; opacity: .88; animation: rise-in .7s .2s var(--look-ease) both; }
[data-look="next"] .card.auth-card { align-self: center; justify-self: center; max-width: 420px; padding: var(--space-8) var(--space-6); gap: var(--space-6); border: 0; border-radius: 0; background: transparent; box-shadow: none; animation: rise-in .6s .05s var(--look-ease) both; }
[data-look="next"] .auth-head { gap: var(--space-4); }
[data-look="next"] .auth-head h1 { font-size: 30px; line-height: 1.1; letter-spacing: -0.03em; }
[data-look="next"] .auth-head p { margin-top: 4px; font-size: var(--text-md); }

/* The four ways in as one segmented control (no scrollbar), and fields that read as touchable. */
[data-look="next"] .auth-card .tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; overflow: hidden; border: 0; border-radius: 16px; background: var(--neutral-soft); }
[data-look="next"] .auth-card .tabs a { padding: 10px 4px; border: 0; border-radius: 12px; text-align: center; font-size: var(--text-base); font-weight: 600; color: var(--ink-muted); transition: background .2s var(--look-ease), color .2s, box-shadow .2s; }
[data-look="next"] .auth-card .tabs a:hover { color: var(--ink); }
[data-look="next"] .auth-card .tabs a.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
[data-look="next"] .auth-card .field input { height: 54px; padding: 0 16px; border: 1.5px solid var(--border); border-radius: 16px; background: var(--surface); font-size: var(--text-lg); transition: border-color .2s, box-shadow .2s; }
[data-look="next"] .auth-card .field input::placeholder { color: var(--ink-muted); opacity: .7; }
[data-look="next"] .auth-card .field input:focus { border-color: var(--brand); outline: 0; box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 22%, transparent); }
[data-look="next"] .auth-card .field input:-webkit-autofill { -webkit-text-fill-color: var(--ink); box-shadow: 0 0 0 100px var(--surface) inset; caret-color: var(--ink); }
[data-look="next"] .auth-card .button-primary { height: 54px; border-radius: 16px; font-size: var(--text-lg); box-shadow: 0 10px 24px color-mix(in srgb, var(--brand) 38%, transparent); transition: transform .18s var(--look-ease), box-shadow .18s, background .18s; }
[data-look="next"] .auth-card .button-primary:hover { transform: translateY(-1px); box-shadow: 0 14px 30px color-mix(in srgb, var(--brand) 44%, transparent); }
[data-look="next"] .auth-card .button-primary:active { transform: scale(.98); }
[data-look="next"] .auth-foot { text-align: center; }
[data-look="next"] .language-choice { position: fixed; right: var(--space-6); bottom: var(--space-4); z-index: 2; margin: 0; padding: 6px 14px; border-radius: 999px; background: color-mix(in srgb, var(--surface) 82%, transparent); box-shadow: var(--shadow-sm); backdrop-filter: blur(8px); }

@media (max-width: 1023.98px) {
    [data-look="next"] .auth-wrap { grid-template-columns: 1fr; grid-template-rows: auto 1fr; padding: var(--space-3); }
    [data-look="next"] .auth-hero { margin: 0; padding: var(--space-6) var(--space-4); border-radius: 28px; }
    [data-look="next"] .auth-hero-mascot { --mascot: 170px; }
    [data-look="next"] .auth-hero-title { font-size: 22px; max-width: 24ch; }
    [data-look="next"] .auth-hero-lead { display: none; }
    [data-look="next"] .auth-card { padding: var(--space-6) var(--space-4) var(--space-10); }
    [data-look="next"] .language-choice { position: static; margin: 0 auto var(--space-6); width: max-content; box-shadow: none; background: transparent; }
}
@media (prefers-reduced-motion: reduce) {
    [data-look="next"] .auth-hero::before, [data-look="next"] .auth-hero::after, [data-look="next"] .auth-hero-mascot, [data-look="next"] .auth-hero-title, [data-look="next"] .auth-hero-lead, [data-look="next"] .auth-card { animation: none; }
}

/* An administrator's Today: the greeting band, four figures, four ways in (home/Glance.tsx). */
[data-look="next"] .glance-hero { position: relative; overflow: hidden; isolation: isolate; display: flex; align-items: center; justify-content: space-between; gap: var(--space-6); padding: var(--space-8) var(--space-10); border-radius: 28px; color: var(--on-hero); background: radial-gradient(120% 160% at 0% 0%, var(--hero-light) 0%, var(--hero-mid) 42%, var(--hero-end) 100%); box-shadow: var(--shadow-md); animation: rise-in .6s var(--look-ease) both; }
[data-look="next"] .glance-hero::before, [data-look="next"] .glance-hero::after { content: ""; position: absolute; z-index: -1; border-radius: 50%; filter: blur(44px); animation: drift 14s ease-in-out infinite; }
[data-look="next"] .glance-hero::before { width: 300px; height: 300px; right: 80px; bottom: -150px; background: var(--hero-blob-pink); opacity: .3; }
[data-look="next"] .glance-hero::after { width: 240px; height: 240px; left: 38%; top: -120px; background: var(--hero-blob-mint); opacity: .35; animation-delay: -6s; }
[data-look="next"] .glance-hero-text { min-width: 0; }
[data-look="next"] .glance-hero-line { margin: 0; font-size: var(--text-md); font-weight: 600; opacity: .85; }
[data-look="next"] .glance-hero h1 { margin: 6px 0 8px; font-size: clamp(30px, 4.2vw, 48px); line-height: 1.04; letter-spacing: -0.035em; color: inherit; }
[data-look="next"] .glance-hero-status { margin: 0; font-size: var(--text-xl); font-weight: 600; opacity: .95; }
[data-look="next"] .glance-hero-mascot { --mascot: 220px; flex: none; margin: -34px -14px -34px 0; filter: drop-shadow(0 22px 28px var(--mascot-shadow)); }
[data-look="next"] .glance-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--space-4); }
[data-look="next"] .glance-tile { display: flex; flex-direction: column; gap: 2px; padding: var(--space-5); border: 1px solid var(--border); border-radius: 24px; background: var(--surface); color: var(--ink); text-decoration: none; box-shadow: var(--shadow-sm); animation: rise-in .55s calc(var(--i, 0) * 70ms + 120ms) var(--look-ease) both; transition: transform .2s var(--look-ease), box-shadow .2s, border-color .2s; }
[data-look="next"] .glance-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--brand) 35%, var(--border)); }
[data-look="next"] .glance-tile:active { transform: scale(.985); }
[data-look="next"] .glance-tile-icon { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: var(--space-3); border-radius: 14px; background: var(--brand-soft); color: var(--brand-strong); }
[data-look="next"] .glance-tile-value { font-family: var(--font-display); font-size: 40px; font-weight: 700; line-height: 1; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
[data-look="next"] .glance-tile[data-alert="true"] .glance-tile-value { color: var(--warn, #b54708); }
[data-look="next"] .glance-tile[data-alert="true"] .glance-tile-icon { background: var(--warn-soft, #fef0c7); color: var(--warn, #b54708); }
[data-look="next"] .glance-tile-label { margin-top: var(--space-2); font-size: var(--text-md); font-weight: 600; }
[data-look="next"] .glance-tile-note { font-size: var(--text-sm); color: var(--ink-muted); }
[data-look="next"] .glance-quick { display: flex; flex-wrap: wrap; gap: var(--space-3); }
[data-look="next"] .glance-action { display: inline-flex; align-items: center; gap: var(--space-3); padding: 8px 18px 8px 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--ink); font-weight: 700; font-size: var(--text-md); text-decoration: none; box-shadow: var(--shadow-sm); transition: transform .2s var(--look-ease), box-shadow .2s, background .2s; }
[data-look="next"] .glance-action:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); background: var(--surface-hover); }
[data-look="next"] .glance-action-bubble { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-strong); }
@media (max-width: 767.98px) {
    [data-look="next"] .glance-hero { flex-direction: column-reverse; align-items: flex-start; padding: var(--space-6); }
    [data-look="next"] .glance-hero-mascot { --mascot: 150px; align-self: flex-end; margin: -10px -6px -30px 0; }
    [data-look="next"] .glance-tiles { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
    [data-look="next"] .glance-hero, [data-look="next"] .glance-hero::before, [data-look="next"] .glance-hero::after, [data-look="next"] .glance-tile { animation: none; }
}

/* Cards everywhere: rounder, softer, with a little life. */
[data-look="next"] .card { border-radius: 24px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }

/* The Admin portal's places: folded groups, the current page lit, and pages that read like the phone's (tabs, fields, tables). */
[data-look="next"] .sidenav-fold { margin: 0 0 var(--space-1); border-radius: 16px; }
[data-look="next"] .sidenav-fold > summary { display: flex; align-items: center; justify-content: space-between; margin: 0; cursor: pointer; list-style: none; padding: 10px 12px; font-size: var(--text-base); font-weight: 700; color: var(--ink); border-radius: 12px; transition: background .15s; }
[data-look="next"] .sidenav-fold > summary::-webkit-details-marker { display: none; }
[data-look="next"] .sidenav-fold > summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .2s var(--look-ease); opacity: .55; }
[data-look="next"] .sidenav-fold[open] > summary::after { transform: rotate(45deg); }
[data-look="next"] .sidenav-fold > summary:hover { background: var(--surface-hover); }
[data-look="next"] .sidenav-fold ul { padding: 2px 0 var(--space-2); }
[data-look="next"] .sidenav a { border-radius: 12px; transition: background .15s, color .15s; }
[data-look="next"] .sidenav a:hover { background: var(--surface-hover); }
[data-look="next"] .sidenav a.is-active { background: var(--brand-soft); color: var(--brand-strong); font-weight: 700; }
[data-look="next"] .page .tabs, [data-look="next"] .admin-main .tabs { gap: 6px; padding: 0; border: 0; overflow-x: auto; scrollbar-width: none; }
[data-look="next"] .page .tabs::-webkit-scrollbar, [data-look="next"] .admin-main .tabs::-webkit-scrollbar { display: none; }
[data-look="next"] .page .tabs a, [data-look="next"] .admin-main .tabs a { padding: 8px 16px; border: 0; border-radius: 999px; font-weight: 600; transition: background .15s, color .15s; }
[data-look="next"] .page .tabs a:hover, [data-look="next"] .admin-main .tabs a:hover { background: var(--surface-hover); }
[data-look="next"] .page .tabs a.is-active, [data-look="next"] .admin-main .tabs a.is-active { background: var(--brand-soft); color: var(--brand-strong); }
[data-look="next"] .field input, [data-look="next"] .field select, [data-look="next"] .field textarea, [data-look="next"] .filter-input, [data-look="next"] select, [data-look="next"] input[type="search"] { border-radius: 14px; }
[data-look="next"] .button { min-height: 44px; border-radius: 14px; transition: transform .18s var(--look-ease), box-shadow .18s, background .18s; }
[data-look="next"] .button:active { transform: scale(.98); }
[data-look="next"] .button-primary { box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 30%, transparent); }
[data-look="next"] .table-wrap { border-radius: 24px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); background: var(--surface); overflow: auto; }
[data-look="next"] .table th { font-size: var(--text-xs); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-muted); }
[data-look="next"] .table td, [data-look="next"] .table th { padding: 14px 16px; }
[data-look="next"] .table tbody tr { transition: background .12s; }
[data-look="next"] .table tbody tr:hover { background: var(--surface-hover); }

/* A page led by the mascot (the Assistant): it stands beside the title. */
[data-look="next"] .page-head-text:has(.page-head-mascot) { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: var(--space-5); align-items: center; }
[data-look="next"] .page-head-mascot { grid-row: 1 / span 2; filter: drop-shadow(0 14px 18px var(--mascot-shadow-soft)); }
[data-look="next"] .page-head-text:has(.page-head-mascot) > h1 { align-self: end; }

/* More: the places as tiles, as on the phone. */
[data-look="next"] .more-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--space-3); }
[data-look="next"] .more-list li + li { border-top: 0; }
[data-look="next"] .more-list a { flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: var(--space-2); height: 100%; min-height: 112px; padding: var(--space-4); border: 1px solid var(--border); border-radius: 20px; background: var(--surface); font-weight: 700; text-decoration: none; transition: transform .2s var(--look-ease), box-shadow .2s, border-color .2s; }
[data-look="next"] .more-list a:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--brand) 35%, var(--border)); }
[data-look="next"] .more-label { flex-direction: column; align-items: flex-start; gap: var(--space-3); }
[data-look="next"] .more-label .icon { box-sizing: border-box; width: 40px; height: 40px; padding: 10px; border-radius: 14px; background: var(--brand-soft); color: var(--brand-strong); }
[data-look="next"] .more-list small { font-weight: 500; }

/* The day's brief: a soft panel in the brand's tint, not another grey box. */
[data-look="next"] .card.brief { padding: var(--space-5) var(--space-6); border-color: transparent; background: var(--brand-soft); box-shadow: none; }
[data-look="next"] .card.brief > h2 { margin: 0 0 var(--space-2); }

/* More: every tile the same height, whatever a note adds to one of them. */
[data-look="next"] .more-list { grid-auto-rows: 1fr; }

/* The Assistant's head: the mascot's ball lines up with the column's edge, the title and its line sit together beside it, the button is centred on it. */
[data-look="next"] .page-head:has(.page-head-mascot) { align-items: center; }
[data-look="next"] .page-head-text:has(.page-head-mascot) { grid-template-rows: 1fr auto auto 1fr; row-gap: var(--space-1); }
[data-look="next"] .page-head-mascot { margin-left: -22px; grid-row: 1 / span 4; }
[data-look="next"] .page-head-text:has(.page-head-mascot) > h1 { grid-row: 2; margin: 0; align-self: end; }
[data-look="next"] .page-head-text:has(.page-head-mascot) > p { grid-row: 3; margin: 0; align-self: start; }

/* Page heads: the title and its line keep to a readable width, so the page's actions always sit at the top right, never below a long line. */
[data-look="next"] .page-head { align-items: flex-start; gap: var(--space-4) var(--space-6); }
[data-look="next"] .page-head > :first-child { flex: 1 1 360px; min-width: 0; max-width: 68ch; }
[data-look="next"] .page-head-actions { margin-left: auto; }
