/* ==========================================================================
   Orbium dark mode — app/dark.css
   Loaded LAST on every page, after the page's own stylesheets.
   Nothing here applies in light mode: every rule is scoped to
   <html data-theme="dark">, which app/theme.js sets from the person's choice
   (System / Light / Dark; System follows the computer's setting).
   The light colours in app/orbium.css are unchanged.

   1. Tokens   — the dark twin of every colour token in app/orbium.css
   2. Fixes    — hand-tuned places where an inverted token is not enough
   3. Login    — the sign-in / sign-up pages (their own token set)
   4. Generated — rules that paint hard-coded light colours, re-coloured for
                  dark (generated from each stylesheet; same selectors)
   ========================================================================== */

/* ---------- 1. Tokens ---------- */
html[data-theme="dark"] {
  /* Surfaces: the frame is darkest, the main panel a step up, cards a step above that */
  --o-canvas: #18181C;
  --o-chrome: #111114;
  --o-surface: #212127;
  --o-subtle: #1D1D22;
  --o-fill: #2A2A31;
  --o-fill-hover: #32323A;
  --o-fill-press: #3A3A43;
  --o-line: #303038;
  --o-line-strong: #45454F;
  --o-hover: rgba(255, 255, 255, .06);
  --o-press: rgba(255, 255, 255, .10);

  /* Text: near-white ink, so the "ink" pill buttons become light pills with dark text */
  --o-ink: #ECECEF;
  --o-ink-2: #CDCDD4;
  --o-muted: #9C9CA5;
  --o-faint: #6E6E78;
  --o-on-ink: #16161A;
  --o-ink-hover: #FFFFFF;

  /* Accents: same hues, lifted so they read on dark */
  --o-indigo: #8A76FF;
  --o-indigo-soft: #2A2550;
  --o-coral: #F47B48;
  --o-coral-soft: #3A2419;
  --o-sun: #EDC21F;
  --o-sun-soft: #353015;
  --o-green: #3DB070;
  --o-green-soft: #17301F;
  --o-red: #F0585D;
  --o-red-soft: #3A1D20;
  --o-amber: #E08A2E;
  --o-amber-soft: #36270F;

  --o-indigo-ink: #B6AAFF;
  --o-coral-ink: #FFAA84;
  --o-sun-ink: #F2D66E;
  --o-green-ink: #7DDBA6;
  --o-red-ink: #FF9195;
  --o-amber-ink: #F5B76B;

  /* Class colours: the near-black and navy classes are lifted so they show on dark */
  --o-class-ink: #4A4A55;
  --o-class-ocean: #3470AE;

  /* Elevation: shadows read as depth on dark only when they are darker and wider */
  --o-shadow-pop: 0 18px 48px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .35), 0 0 0 1px rgba(255, 255, 255, .06);
  --o-shadow-raise: 0 1px 2px rgba(0, 0, 0, .4), 0 0 0 1px rgba(255, 255, 255, .04);
  --o-shadow-drawer: 12px 0 48px rgba(0, 0, 0, .6);
  --o-scrim: rgba(0, 0, 0, .6);
  --o-glass-edge: inset 0 1px 0 rgba(255, 255, 255, .06), inset 0 0 0 1px rgba(255, 255, 255, .04);

  --o-control-bg: var(--o-fill);
  --o-control-bg-hover: var(--o-fill-hover);

  color-scheme: dark;
}

/* Theme switch: a short cross-fade (app/theme.js adds the class for ~300ms). */
html.o-theme-fade,
html.o-theme-fade *,
html.o-theme-fade *::before,
html.o-theme-fade *::after {
  transition: background-color 280ms ease, color 280ms ease, border-color 280ms ease, box-shadow 280ms ease !important;
}

/* ---------- 2. Fixes ---------- */
html[data-theme="dark"] body { background-color: var(--o-chrome); }
html[data-theme="dark"] ::selection { background: var(--o-indigo-soft); color: var(--o-ink); }

/* Logos drawn in dark ink get a light version (see brand/). */
html[data-theme="dark"] img[src*="orbium-logo-light"],
html[data-theme="dark"] img[src*="orbium-wordmark"],
html[data-theme="dark"] img[src*="orbium-logo-full"] { filter: none; }

/* Toasts stay a raised dark pill (white text, coloured icons) instead of inverting. */
html[data-theme="dark"] .o-toast,
html[data-theme="dark"] #toast.toast {
  background: #2E2E36;
  color: #F4F4F6;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .08);
}

/* Switches: a light knob on the dark track; when on, the track is light and the knob dark. */
html[data-theme="dark"] .o-switch input::before,
html[data-theme="dark"] .cw-switch > span::after { background: #EDEDF1; box-shadow: 0 1px 3px rgba(0, 0, 0, .5); }
html[data-theme="dark"] .o-switch input:checked::before { background: var(--o-on-ink); }

/* Full-screen class code: keeps the dark-on-light pairing readable. */
html[data-theme="dark"] .cw-code-full { color: var(--o-on-ink); }

/* Confirm dialog (classroom/confirm-dialog.js injects its own styles). */
html[data-theme="dark"] .cn-btn-go { color: var(--o-on-ink); }
html[data-theme="dark"] .cn-danger .cn-btn-go { color: #fff; }

/* Danger and accent buttons keep white text on their colour. */
html[data-theme="dark"] .o-btn--primary.o-btn--danger:hover { background: #E04A50; }
html[data-theme="dark"] .o-btn--accent { background: #6E55FF; }
html[data-theme="dark"] .o-btn--accent:hover { background: #7C66FF; }

/* Native controls that ignore color-scheme in some browsers. */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea { color-scheme: dark; }
html[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
html[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator,
html[data-theme="dark"] input[type="datetime-local"]::-webkit-calendar-picker-indicator,
html[data-theme="dark"] input[type="month"]::-webkit-calendar-picker-indicator { filter: invert(.85); }
html[data-theme="dark"] select option { background: var(--o-surface); color: var(--o-ink); }

/* Images with a white page behind them (QR codes, uploaded pictures) keep it,
   so they still scan and read. */
html[data-theme="dark"] .qr-drop img,
html[data-theme="dark"] .qr-show img { background: #fff; }

/* Scrollbars */
html[data-theme="dark"] { scrollbar-color: #45454F transparent; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background-color: #3C3C45; }

/* Theme picker button in the top bar (app/shell.js). */
.o-topbar__theme .material-symbols-outlined { font-size: 20px; }

/* ---------- 3. Login and sign-up (login.page/login.css) ---------- */
html[data-theme="dark"] .auth-shell,
html[data-theme="dark"] body:has(.auth-shell) {
  --stage: #18181C;
  --card: #212127;
  --ink: #ECECEF;
  --muted: #9C9CA5;
  --faint: #6E6E78;
  --line: #45454F;
  --pill: #2A2A31;
  --red: #F0585D;
  --green: #3DB070;
}
html[data-theme="dark"] #useSelector .active-role,
html[data-theme="dark"] #roleSelector .active-role,
html[data-theme="dark"] .btn-primary { color: #16161A; }
html[data-theme="dark"] .btn-google:hover { background: #32323A; }
html[data-theme="dark"] .spark:not(.sm) { background: #ECECEF; }
/* The dark "scholar" character is lifted a little so it stands out from the dark stage. */
html[data-theme="dark"] .ch-cap { background: linear-gradient(160deg, #4C4C57 0%, #2E2E36 100%); }
html[data-theme="dark"] .cap-hat::before { background: #08080A; }

/* ---------- 4. Generated ---------- */

/* ---- from app/orbium.css ---- */
:where(html[data-theme="dark"]) .o-on-canvas {
    --o-control-bg-hover: var(--o-subtle)
}
:where(html[data-theme="dark"]) .o-topbar {
    --o-control-bg-hover: var(--o-subtle)
}
:where(html[data-theme="dark"]) .o-topbar__account:hover {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.128)
}
:where(html[data-theme="dark"]) .o-topbar__account[aria-expanded="true"] {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.192)
}
:where(html[data-theme="dark"]) .o-btn--primary.is-loading::after {
    border-color: var(--o-on-ink) var(--o-on-ink) var(--o-on-ink) transparent
}
:where(html[data-theme="dark"]) .o-input:focus,
:where(html[data-theme="dark"]) .o-select:focus,
:where(html[data-theme="dark"]) .o-textarea:focus,
:where(html[data-theme="dark"]) .o-input.is-focus,
:where(html[data-theme="dark"]) .o-select.is-focus,
:where(html[data-theme="dark"]) .o-textarea.is-focus {
    box-shadow: inset 0 0 0 1px var(--o-ink), 0 0 0 3px rgba(255, 255, 255, 0.128)
}
:where(html[data-theme="dark"]) .o-input[aria-invalid="true"],
:where(html[data-theme="dark"]) .o-select[aria-invalid="true"],
:where(html[data-theme="dark"]) .o-textarea[aria-invalid="true"],
:where(html[data-theme="dark"]) .o-input.is-invalid,
:where(html[data-theme="dark"]) .o-select.is-invalid,
:where(html[data-theme="dark"]) .o-textarea.is-invalid,
:where(html[data-theme="dark"]) .o-field.is-error .o-input,
:where(html[data-theme="dark"]) .o-field.is-error .o-select,
:where(html[data-theme="dark"]) .o-field.is-error .o-textarea {
    background-color: var(--o-subtle)
}
:where(html[data-theme="dark"]) .o-seg > .is-active,
:where(html[data-theme="dark"]) .o-seg > [aria-pressed="true"],
:where(html[data-theme="dark"]) .o-seg > [aria-selected="true"],
:where(html[data-theme="dark"]) .o-seg > [aria-current="page"],
:where(html[data-theme="dark"]) .o-seg > button.is-active:hover,
:where(html[data-theme="dark"]) .o-seg > button[aria-pressed="true"]:hover,
:where(html[data-theme="dark"]) .o-seg > button[aria-selected="true"]:hover,
:where(html[data-theme="dark"]) .o-seg > a.is-active:hover,
:where(html[data-theme="dark"]) .o-seg > a[aria-current="page"]:hover {
    color: var(--o-on-ink)
}
:where(html[data-theme="dark"]) .o-switch input::before {
    background: var(--o-surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.65)
}
:where(html[data-theme="dark"]) .o-check input:checked::after {
    border: solid var(--o-on-ink)
}
:where(html[data-theme="dark"]) .o-check input:indeterminate::after {
    background: var(--o-on-ink)
}
@media (hover: hover) {
    :where(html[data-theme="dark"]) .o-card--interactive:hover {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.308), inset 0 0 0 1px var(--o-line)
    }
}
:where(html[data-theme="dark"]) .o-chip--ink {
    color: var(--o-on-ink)
}
:where(html[data-theme="dark"]) button.o-chip.is-active,
:where(html[data-theme="dark"]) a.o-chip.is-active,
:where(html[data-theme="dark"]) button.o-chip[aria-pressed="true"] {
    color: var(--o-on-ink)
}
:where(html[data-theme="dark"]) .o-avatar--soft {
    background: color-mix(in srgb, var(--av) 14%, var(--o-surface))
}
:where(html[data-theme="dark"]) .o-table--striped tbody tr:nth-child(even) > * {
    background: var(--o-subtle)
}
:where(html[data-theme="dark"]) .o-item__tile {
    background: color-mix(in srgb, var(--c) 12%, var(--o-surface))
}
:where(html[data-theme="dark"]) .o-menu {
    box-shadow: var(--o-shadow-pop), 0 0 0 1px rgba(0, 0, 0, 0.204)
}
:where(html[data-theme="dark"]) .o-pop {
    box-shadow: var(--o-shadow-pop), 0 0 0 1px rgba(0, 0, 0, 0.204)
}
:where(html[data-theme="dark"]) .o-toast {
    color: var(--o-on-ink);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65)
}
:where(html[data-theme="dark"]) .o-skel {
    background: linear-gradient(90deg, var(--o-fill-hover) 0%, var(--o-fill) 40%, var(--o-fill-hover) 80%) 0 0 / 300% 100%
}
:where(html[data-theme="dark"]) .o-sidebar .o-skel {
    background-color: var(--o-fill-press);
    background-image: linear-gradient(90deg, var(--o-fill-press) 0%, var(--o-fill-press) 40%, var(--o-fill-press) 80%)
}
:where(html[data-theme="dark"]) .o-pagehead {
    --o-control-bg-hover: var(--o-subtle)
}
:where(html[data-theme="dark"]) .o-classhead {
    --o-control-bg-hover: var(--o-subtle)
}
:where(html[data-theme="dark"]) .o-classhead__tools {
    --o-control-bg-hover: var(--o-subtle)
}
:where(html[data-theme="dark"]) .o-week__col.is-today,
:where(html[data-theme="dark"]) .o-week__col.is-selected {
    background-color: var(--o-subtle)
}
:where(html[data-theme="dark"]) .o-block {
    background: color-mix(in srgb, var(--c) 13%, var(--o-surface))
}
:where(html[data-theme="dark"]) .o-block:hover {
    background: color-mix(in srgb, var(--c) 19%, var(--o-surface))
}
:where(html[data-theme="dark"]) .o-block--pending {
    background: repeating-linear-gradient(135deg, var(--o-amber-soft) 0 8px, var(--o-subtle) 8px 16px);
    box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--o-amber) 45%, var(--o-surface)), inset 3px 0 0 var(--o-amber)
}
:where(html[data-theme="dark"]) .o-datenav .o-datenav__now[aria-pressed="true"] {
    color: var(--o-on-ink)
}
:where(html[data-theme="dark"]) .o-week--half .o-week__col {
    background-image: linear-gradient(to bottom, var(--o-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--o-fill) 1px, transparent 1px)
}
:where(html[data-theme="dark"]) .o-week__off {
    background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.044) 0 6px, transparent 6px 12px)
}
:where(html[data-theme="dark"]) .o-week__col.is-drop {
    background-color: var(--o-fill)
}
:where(html[data-theme="dark"]) .o-week__ghost {
    background: color-mix(in srgb, var(--c) 6%, var(--o-surface))
}
:where(html[data-theme="dark"]) .o-block--conflict {
    box-shadow: inset 3px 0 0 var(--o-red), inset 0 0 0 1.5px color-mix(in srgb, var(--o-red) 45%, var(--o-surface))
}
:where(html[data-theme="dark"]) .o-agenda__item {
    background: color-mix(in srgb, var(--c) 9%, var(--o-surface))
}
:where(html[data-theme="dark"]) a.o-agenda__item:hover,
:where(html[data-theme="dark"]) button.o-agenda__item:hover {
    background: color-mix(in srgb, var(--c) 15%, var(--o-surface))
}
:where(html[data-theme="dark"]) .o-agenda__item.o-block--pending {
    background: repeating-linear-gradient(135deg, var(--o-amber-soft) 0 8px, var(--o-subtle) 8px 16px)
}
:where(html[data-theme="dark"]) .o-table--striped.o-table--sticky-first tbody tr:nth-child(even) > td:first-child {
    background: var(--o-subtle)
}
:where(html[data-theme="dark"]) .o-input[type="file"]::file-selector-button {
    color: var(--o-on-ink)
}
:where(html[data-theme="dark"]) .o-file__icon {
    background: color-mix(in srgb, var(--c) 12%, var(--o-surface))
}
:where(html[data-theme="dark"]) .o-file.is-error {
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--o-red) 40%, var(--o-surface))
}
:where(html[data-theme="dark"]) .o-banner,
:where(html[data-theme="dark"]) .o-callout {
    --o-control-bg-hover: var(--o-subtle)
}
:where(html[data-theme="dark"]) .o-step.is-active::before {
    color: var(--o-on-ink)
}
:where(html[data-theme="dark"]) .o-month__ev {
    background: color-mix(in srgb, var(--c) 13%, var(--o-surface))
}
:where(html[data-theme="dark"]) a.o-month__ev:hover {
    background: color-mix(in srgb, var(--c) 20%, var(--o-surface))
}
:where(html[data-theme="dark"]) .o-chat__unread::before,
:where(html[data-theme="dark"]) .o-chat__unread::after {
    background: color-mix(in srgb, var(--o-coral) 45%, var(--o-surface))
}
:where(html[data-theme="dark"]) .o-msg--mine .o-bubble {
    color: var(--o-on-ink)
}
:where(html[data-theme="dark"]) .o-react.is-mine {
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--o-indigo) 35%, var(--o-surface))
}
:where(html[data-theme="dark"]) .o-composer__input:focus {
    box-shadow: inset 0 0 0 1px var(--o-ink), 0 0 0 3px rgba(255, 255, 255, 0.128)
}
@media (prefers-reduced-motion: reduce) {
    :where(html[data-theme="dark"]) .o-skel {
        background: var(--o-fill-hover)
    }
}

/* ---- from app/motion.css ---- */
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    :where(html[data-theme="dark"]) .o-menu,
:where(html[data-theme="dark"]) .o-pop {
        box-shadow: var(--o-shadow-pop), 0 0 0 1px rgba(0, 0, 0, 0.256), var(--o-glass-edge)
    }
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    :where(html[data-theme="dark"]) .o-modal__box,
:where(html[data-theme="dark"]) .o-sheet__panel {
        box-shadow: var(--o-shadow-pop), 0 0 0 1px rgba(0, 0, 0, 0.23), var(--o-glass-edge)
    }
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    :where(html[data-theme="dark"]) .o-toast {
        box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, .14)
    }
}

/* ---- from app/leaderboard.css ---- */
:where(html[data-theme="dark"]) .lbv-title {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.568)
}
:where(html[data-theme="dark"]) .lbv-block {
    box-shadow: inset 0 -10px 18px -12px rgba(0, 0, 0, 0.412)
}

/* ---- from classroom/student-cards.css ---- */
:where(html[data-theme="dark"]) .teacher-student-head .avatar,
:where(html[data-theme="dark"]) .si-avatar {
    color: var(--o-on-ink)
}

/* ---- from classroom/classroom.css ---- */
:where(html[data-theme="dark"]) .editor-overlay {
    background: rgba(0, 0, 0, 0.65)
}
:where(html[data-theme="dark"]) .editor-item.assigned {
    box-shadow: inset 0 0 0 1px color-mix(in srgb,var(--o-indigo) 22%,var(--o-surface))
}
:where(html[data-theme="dark"]) .day-pill input:checked+span,
:where(html[data-theme="dark"]) .prio-pill input:checked+span,
:where(html[data-theme="dark"]) .assign-pill input:checked+span,
:where(html[data-theme="dark"]) .assign-preset.on {
    color: var(--o-on-ink)
}

/* ---- from classroom/payment.css ---- */
:where(html[data-theme="dark"]) .qr-drop img {
    background: var(--o-surface)
}
:where(html[data-theme="dark"]) .qr-show img {
    background: var(--o-surface)
}
:where(html[data-theme="dark"]) .month-tile.sel {
    color: var(--o-on-ink)
}

/* ---- from classwork/classwork.css ---- */
:where(html[data-theme="dark"]) .cw-main {
    --o-control-bg-hover: var(--o-subtle)
}
:where(html[data-theme="dark"]) .cw-main .o-banner {
    --o-control-bg-hover: var(--o-subtle)
}
:where(html[data-theme="dark"]) .cw-btn.light:hover {
    background: var(--o-subtle)
}
:where(html[data-theme="dark"]) .cw-input:focus,
:where(html[data-theme="dark"]) .cw-aud[open] > summary.cw-input {
    box-shadow: inset 0 0 0 1px var(--o-ink), 0 0 0 3px rgba(255, 255, 255, 0.128)
}
:where(html[data-theme="dark"]) .cw-switch > span::after {
    background: var(--o-surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.65)
}
:where(html[data-theme="dark"]) .cw-seg > button.on {
    color: var(--o-on-ink)
}
:where(html[data-theme="dark"]) .cw-skel {
    background: linear-gradient(90deg, var(--o-fill-hover) 0%, var(--o-fill) 40%, var(--o-fill-hover) 80%) 0 0 / 300% 100%
}
:where(html[data-theme="dark"]) .cw-kind-ic:not(.o-item__tile) {
    background: color-mix(in srgb, var(--th, var(--o-ink)) 12%, var(--o-surface))
}
@media (hover: hover) {
    :where(html[data-theme="dark"]) .cw-class-card:hover {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.308), inset 0 0 0 1px var(--o-line)
    }
}
:where(html[data-theme="dark"]) .cw-cc-pending:hover {
    background: color-mix(in srgb, var(--o-amber) 18%, var(--o-surface))
}
:where(html[data-theme="dark"]) .cw-set-nav a.o-item:hover {
    background: rgba(255, 255, 255, 0.063)
}
@media (hover: hover) {
    :where(html[data-theme="dark"]) .cw-feed-work:hover {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.308), inset 0 0 0 1px var(--o-line)
    }
}
:where(html[data-theme="dark"]) .cw-composer.open {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.308)
}
:where(html[data-theme="dark"]) .cw-comment-form textarea:focus {
    box-shadow: inset 0 0 0 1px var(--o-ink), 0 0 0 3px rgba(255, 255, 255, 0.128)
}
:where(html[data-theme="dark"]) .cw-topic-chips > button.on {
    color: var(--o-on-ink)
}
:where(html[data-theme="dark"]) .cw-item.open {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.308)
}
:where(html[data-theme="dark"]) .cw-grade-in:focus {
    box-shadow: inset 0 0 0 1px var(--o-ink), 0 0 0 3px rgba(255, 255, 255, 0.128)
}
:where(html[data-theme="dark"]) .cw-code-full {
    color: var(--o-on-ink)
}
:where(html[data-theme="dark"]) .cw-ed-side {
    --o-control-bg-hover: var(--o-subtle)
}
:where(html[data-theme="dark"]) .cw-yourwork {
    box-shadow: inset 0 0 0 1px var(--o-line), 0 8px 24px rgba(0, 0, 0, 0.256) !important
}
:where(html[data-theme="dark"]) .cw-quiz-q.right {
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--o-green) 40%, var(--o-surface))
}
:where(html[data-theme="dark"]) .cw-quiz-q.part {
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--o-sun) 55%, var(--o-surface))
}
:where(html[data-theme="dark"]) .cw-quiz-q.wrong {
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--o-red) 40%, var(--o-surface))
}

/* ---- from guardian.css ---- */
:where(html[data-theme="dark"]) .g-topics .o-chip[aria-pressed="true"] {
    color: var(--o-on-ink)
}

/* ---- from messaging.css ---- */
:where(html[data-theme="dark"]) .ms-bubble .ms-math {
    background: rgba(255, 255, 255, 0.1)
}

/* ---- from db-loading.css ---- */
:where(html[data-theme="dark"]) #databaseLoading {
    color: var(--o-ink)
}
:where(html[data-theme="dark"]) .database-loading-card {
    background: var(--o-surface);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.516), 0 2px 6px rgba(0, 0, 0, 0.256)
}
:where(html[data-theme="dark"]) .database-loading-text b {
    color: var(--o-ink)
}
:where(html[data-theme="dark"]) .database-loading-text small {
    color: var(--o-muted)
}
:where(html[data-theme="dark"]) .database-loading-spinner {
    border: 2.5px solid var(--o-line)
}

/* ---- from student/student.css ---- */
@media (hover: hover) {
    :where(html[data-theme="dark"]) .cw-class-card:hover {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.308), inset 0 0 0 1px var(--o-line)
    }
}
:where(html[data-theme="dark"]) .day-pill input:checked + span {
    color: var(--o-on-ink)
}

/* ---- from teacher/app-teacher.css ---- */
:where(html[data-theme="dark"]) #toast.toast {
    color: var(--o-on-ink);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65)
}
:where(html[data-theme="dark"]) .kpi-action:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.308), inset 0 0 0 1px var(--o-line)
}
:where(html[data-theme="dark"]) .pg-tip {
    color: var(--o-on-ink)
}
:where(html[data-theme="dark"]) .ht-ev.auto {
    background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--c) 7%, var(--o-surface)) 0 6px, var(--o-surface) 6px 12px);
    border: 1.5px dashed color-mix(in srgb, var(--c) 55%, var(--o-surface))
}
:where(html[data-theme="dark"]) .ht-ev.auto:hover {
    background: color-mix(in srgb, var(--c) 10%, var(--o-surface))
}
:where(html[data-theme="dark"]) .ht-ev.hw {
    background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--c) 15%, var(--o-surface)) 0 6px, color-mix(in srgb, var(--c) 7%, var(--o-surface)) 6px 12px)
}
:where(html[data-theme="dark"]) .ht-ev.at-risk {
    box-shadow: inset 3px 0 0 var(--o-red), inset 0 0 0 1.5px color-mix(in srgb, var(--o-red) 50%, var(--o-surface))
}
:where(html[data-theme="dark"]) .rs-manual {
    --o-control-bg-hover: var(--o-subtle)
}
:where(html[data-theme="dark"]) .wc-pop {
    box-shadow: var(--o-shadow-pop), 0 0 0 1px rgba(0, 0, 0, 0.204)
}
:where(html[data-theme="dark"]) .tte-day input:checked + span {
    color: var(--o-on-ink)
}

/* ===== Phone & tablet layout: seamless top bar (2026-11-01) =====
   The top bar has the same colour as the page below it, so the two read as
   one surface. While the page is scrolling, the bar takes the same light dark
   tint a button gets on hover, and fades back when scrolling stops. app/theme.js sets
   <html class="o-scrolled"> only while the page content is scrolling. Look only. */
@media (max-width: 899.98px) {
  :root { --o-navbar: var(--o-canvas); --o-navbar-tint: rgba(30, 30, 34, .05); /* same tint as a button hover (--o-hover) */ }
  html[data-theme="dark"] { --o-navbar-tint: rgba(0, 0, 0, .18); }

  body.o-app { background: var(--o-canvas); }
  .o-app > .o-topbar,
  .g-top {
    position: relative;
    z-index: var(--o-z-topbar);
    background: var(--o-navbar);
    border-bottom-color: transparent;
    box-shadow: none;
    transition: background-color var(--o-t) var(--o-ease), box-shadow var(--o-t) var(--o-ease);
  }
  html.o-scrolled .o-app > .o-topbar,
  html.o-scrolled .g-top {
    box-shadow: inset 0 0 0 100vmax var(--o-navbar-tint);
  }
  /* No gap or rounded corner between the bar and the page, so there is no seam. */
  .o-app > .o-main { margin-top: 0; border-radius: 0; }
}

/* ===== One flat page, Google Classroom style (2026-11-01) =====
   No separate panel behind the content: sidebar, top bar and page share one
   colour, and the white cards scroll up and slide under the top bar. The bar
   takes a light tint only while scrolling (app/theme.js). Phone and desktop. */
:root { --o-chrome: #FAF7F2; }
html[data-theme="dark"] { --o-chrome: #18181C; }
body.o-app { background: var(--o-canvas); }
.o-app > .o-main { margin: 0; border-radius: 0; background: transparent; }
.o-app > .o-topbar {
  background: var(--o-canvas);
  transition: box-shadow var(--o-t) var(--o-ease);
}
/* While scrolling, everything that stays still (top bar, sidebar, page
   header) takes the same light tint; only the moving content stays clear. */
html.o-scrolled .o-app > .o-topbar { box-shadow: inset 0 0 0 100vmax var(--o-navbar-tint, rgba(30, 30, 34, .05)); }
/* Sidebar: a see-through layer over the whole sidebar (items included), so
   the tint shows on everything in it; clicks pass straight through. */
.o-app > .o-sidebar::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 50;
  background: var(--o-navbar-tint, rgba(30, 30, 34, .05));
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--o-t) var(--o-ease);
}
html.o-scrolled .o-app > .o-sidebar::after { opacity: 1; }
:root { --o-navbar-tint: rgba(30, 30, 34, .05); }
html[data-theme="dark"] { --o-navbar-tint: rgba(0, 0, 0, .18); }

/* No extra frame around the page content: the page section (for example
   .section-page.th-home) fills the content area; only a small edge gap stays
   so cards do not touch the scrollbar or the screen edge. */
.o-app > .o-main,
.o-app > .o-main:not(.o-main--flush) { padding: 0 12px 24px 0; }
@media (max-width: 899.98px) {
  .o-app > .o-main,
  .o-app > .o-main:not(.o-main--flush) { padding: 0 16px 24px 16px; }
}

/* One layer only, so tighter spacing: the page title lines up with the
   top bar title and the header sits closer to the bar. */
@media (min-width: 900px) {
  .o-app > .o-topbar { padding-left: 0; }
}
.section-page > .o-pagehead:first-child,
.o-main > .o-pagehead:first-child { margin: 4px 0 16px; }

/* The page header (greeting, term line, main buttons) stays fixed under the
   top bar; only the content below it scrolls and slides under it. */
.section-page > .o-pagehead:first-child,
.o-main > .o-pagehead:first-child {
  position: sticky;
  top: 0;
  z-index: 4;
  margin-top: 0;
  margin-right: -12px;
  padding: 4px 12px 12px 0;
  background: var(--o-canvas);
  transition: box-shadow var(--o-t) var(--o-ease);
}
/* Treated as part of the nav bar: the same scroll tint, at the same time. The
   header runs to the right edge so the bar and header read as one strip. */
html.o-scrolled .section-page > .o-pagehead:first-child,
html.o-scrolled .o-main > .o-pagehead:first-child {
  box-shadow: inset 0 0 0 100vmax var(--o-navbar-tint);
}

/* ===== Page header balance (8px grid, 2026-11-01) =====
   Top bar title, greeting and the line under it share one left edge; the
   greeting is clearly the main title, the bar title is a quiet label; the
   meta line items are all 24px tall with even 8px gaps; the buttons sit
   centred against the greeting block instead of hanging at the bottom. */
.o-topbar__title { padding-left: 0; }
.o-topbar__title h1,
.o-topbar__h { font-size: 16px; line-height: 24px; font-weight: 600; }
.o-pagehead { align-items: center; gap: 16px 24px; }
.o-pagehead__title { font-size: clamp(22px, 1.6vw + 12px, 28px); line-height: 1.25; letter-spacing: -.015em; }
.o-pagehead__sub,
.th-head__sub {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 24px;
}
.o-pagehead__sub > .o-chip,
.th-head__sub > .o-chip { height: 24px; padding: 0 10px; font-size: 12px; }
.th-term { display: inline-flex; align-items: center; gap: 6px; height: 24px; }
.th-term .o-ic { font-size: 16px; width: 16px; height: 16px; }
.o-pagehead__actions > .o-chip,
.o-pagehead__actions > .o-btn { height: 40px; }
@media (max-width: 639.98px) {
  .o-topbar__title h1,
  .o-topbar__h { font-size: 16px; }
  .o-pagehead { gap: 12px; }
  /* Phone: the header buttons stay on one row (swipe sideways if they do not
     fit), so the fixed header stays short. */
  .o-pagehead__actions { width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-right: -16px; padding-right: 16px; }
  .o-pagehead__actions::-webkit-scrollbar { display: none; }
  .o-pagehead__actions > * { flex: none; }
  /* The main button comes first so it is always in view; status chip last. */
  .o-pagehead__actions > .o-btn--primary { order: -2; }
  .o-pagehead__actions > .o-btn:not(.o-btn--primary) { order: -1; }
}

/* Curved inner corner where the tinted sidebar meets the tinted header:
   a 16px concave piece under the header's left end, in the header's colour,
   so the frame curves round the scrolling content instead of meeting at a
   right angle. */
@media (min-width: 900px) {
  .section-page > .o-pagehead:first-child::after,
  .o-main > .o-pagehead:first-child::after {
    content: '';
    position: absolute;
    left: 0;
    top: 100%;
    width: 16px;
    height: 16px;
    background: var(--o-canvas);
    -webkit-mask: radial-gradient(circle at 100% 100%, transparent 15.5px, #000 16px);
    mask: radial-gradient(circle at 100% 100%, transparent 15.5px, #000 16px);
    pointer-events: none;
    transition: box-shadow var(--o-t) var(--o-ease);
  }
  html.o-scrolled .section-page > .o-pagehead:first-child::after,
  html.o-scrolled .o-main > .o-pagehead:first-child::after { box-shadow: inset 0 0 0 100vmax var(--o-navbar-tint); }
}

/* Smaller gap between the bar and the page header. */
.section-page > .o-pagehead:first-child,
.o-main > .o-pagehead:first-child { padding-top: 0; }

/* ===== Top bar icon alignment (2026-11-01) =====
   Every action in the top bar sits in the same 40px slot with the same gap,
   so their centres are evenly spaced; all icons draw at 20px; the "+" circle
   is the same 36px size as the account picture next to it. */
.o-topbar__actions { gap: 6px; }
.o-topbar__actions > .o-btn,
.o-topbar__actions > .o-topbar__account { width: 40px; height: 40px; margin: 0; flex: none; }
.o-topbar__actions > .o-btn > .o-ic,
.o-topbar__theme .material-symbols-outlined,
.o-topbar .o-topbar__menu > .o-ic { font-size: 20px; width: 20px; height: 20px; line-height: 1; margin: 0 !important; }
.o-topbar__actions > .o-btn--primary { --o-btn-h: 36px; width: 36px; height: 36px; margin: 2px; }
.o-topbar__account { padding: 0; }
.o-topbar__account > .o-avatar,
.o-topbar__account > .o-skel { width: 36px; height: 36px; }
@media (max-width: 639.98px) {
  .o-topbar__actions { gap: 4px; }
}

/* ===== Button colour (2026-11-01) =====
   Every filled button and "selected" pill uses very dark brown #1A1411 with
   white text (changed from teal #1A1411 on 2026-11-14). All other colours are
   the original Orbium ones. */
:root {
  --o-brand: #1A1411;
  --o-brand-hover: #2A201B;
  --o-on-brand: #FFFFFF;
}
html[data-theme="dark"] {
  --o-brand: #4A382F;
  --o-brand-hover: #5C463B;
  --o-on-brand: #FFFFFF;
}

/* Filled buttons and selected states: dark teal, white text */
.o-btn--primary,
.o-seg > .is-active,
.o-seg > [aria-pressed="true"],
.o-seg > [aria-selected="true"],
.o-seg > [aria-current="page"],
.o-seg > button.is-active:hover,
.o-seg > button[aria-pressed="true"]:hover,
.o-seg > button[aria-selected="true"]:hover,
.o-seg > a.is-active:hover,
.o-seg > a[aria-current="page"]:hover,
.o-chip--ink,
button.o-chip[aria-pressed="true"],
.o-datenav .o-datenav__now[aria-pressed="true"],
.o-step.is-active::before,
.o-msg--mine .o-bubble,
.o-minimonth__day.is-selected,
.o-input[type="file"]::file-selector-button,
.lbv-title,
.tte-day input:checked + span,
.day-pill input:checked + span,
.prio-pill input:checked + span,
.assign-pill input:checked + span,
.assign-preset.on,
.cw-btn:not(.light):not(.danger):not(.ghost):not(.outline),
.cw-seg > button.on,
.cw-counts > button.on,
.cw-topic-chips > button.on,
.g-topics .o-chip[aria-pressed="true"],
.month-tile.sel,
.cn-btn-go,
#useSelector .active-role,
#roleSelector .active-role,
.btn-primary {
  background: var(--o-brand);
  color: var(--o-on-brand);
  border-color: var(--o-brand);
}
.o-btn--primary:hover,
.cw-btn:not(.light):not(.danger):not(.ghost):not(.outline):hover,
.cn-btn-go:hover { background: var(--o-brand-hover); }
.btn-primary:hover { filter: none; background: var(--o-brand-hover); }
.o-btn--accent { background: var(--o-brand); color: var(--o-on-brand); }
.o-btn--accent:hover { background: var(--o-brand-hover); }
.o-check input:checked,
.o-check input:indeterminate,
.o-switch input:checked,
.cw-switch input:checked + span,
.pd.locked,
.tte-prio .pd.locked,
.onb-prog i.on,
.gw-notes__n,
.gw-mark::after { background-color: var(--o-brand); }
.gw-notes__n,
.gw-mark::after { color: #fff; }
.o-radio input:checked { box-shadow: inset 0 0 0 5.5px var(--o-brand); }
.cw-set-nav .o-item.is-active,
.cw-set-nav .o-item.is-active:hover { background: var(--o-brand); }
.cw-set-nav .o-item.is-active > .o-ic,
.cw-set-nav .o-item.is-active .o-item__title,
.cw-set-nav .o-item.is-active .o-item__sub,
.cw-set-nav .o-item.is-active .o-ic { color: var(--o-on-brand); }
:where(.o-app) :where(input[type="checkbox"], input[type="radio"], input[type="range"], progress) { accent-color: var(--o-brand); }

/* Dark mode: the filled states above keep white text (the old dark theme
   used light pills with dark text). */
html[data-theme="dark"] .o-btn--primary,
html[data-theme="dark"] .o-msg--mine .o-bubble,
html[data-theme="dark"] .cn-btn-go,
html[data-theme="dark"] .lbv-title,
html[data-theme="dark"] .o-minimonth__day.is-selected { color: var(--o-on-brand); }
html[data-theme="dark"] .o-switch input:checked::before { background: #FFFFFF; }

html[data-theme="dark"] #useSelector .active-role,
html[data-theme="dark"] #roleSelector .active-role,
html[data-theme="dark"] .btn-primary { background: var(--o-brand); color: #FFFFFF; }
input[type='checkbox'] { accent-color: var(--o-brand, #1A1411); }
.o-check input:checked,
.o-check input:indeterminate { box-shadow: inset 0 0 0 1.5px var(--o-brand); }
html[data-theme="dark"] .o-check input:checked::after { border: solid #FFFFFF; border-width: 0 2px 2px 0; }
html[data-theme="dark"] .o-check input:indeterminate::after { background: #FFFFFF; }
html[data-theme="dark"] .o-btn--accent { background: var(--o-brand); color: #FFFFFF; }
html[data-theme="dark"] .o-btn--accent:hover { background: var(--o-brand-hover); }

/* ===== Greeting on top, page name below (desktop, 2026-11-01) =====
   On pages with a page header, the greeting and its line move up into the
   top row (level with the bar icons) and the page name ("Home") shows as a
   small label under them. The bar's own title stays for screen readers.
   app/theme.js copies the page name into --o-page-name. Position only. */
@media (min-width: 900px) {
  body.o-app:has(.o-main .o-pagehead) > .o-main { grid-row: 1 / 3; grid-column: 2; }
  body.o-app:has(.o-main .o-pagehead) > .o-topbar {
    grid-area: top;
    z-index: 6;
    background: transparent !important;
    box-shadow: none !important;
    pointer-events: none;
  }
  body.o-app:has(.o-main .o-pagehead) > .o-topbar > * { pointer-events: auto; }
  body.o-app:has(.o-main .o-pagehead) > .o-topbar .o-topbar__actions { margin-left: auto; }
  body.o-app:has(.o-main .o-pagehead) > .o-topbar .o-topbar__title {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  body.o-app:has(.o-main .o-pagehead) .section-page > .o-pagehead:first-child,
  body.o-app:has(.o-main .o-pagehead) .o-main > .o-pagehead:first-child {
    padding-top: 14px;
    align-items: flex-end;
  }
  /* Keep the header buttons clear of the bar icons in the top row. */
  body.o-app:has(.o-main .o-pagehead) .o-pagehead__actions { margin-top: 56px; }
  body.o-app:has(.o-main .o-pagehead) .o-pagehead__text::after {
    content: var(--o-page-name, "");
    display: block;
    margin-top: 12px;
    font-size: 14px;
    line-height: 20px;
    font-weight: 600;
    color: var(--o-muted);
  }
}

/* ===== Whole-page scroll tint (2026-11-01) =====
   While scrolling, the whole page background behind the cards takes the
   same light tint as the bars (cards stay clear); it fades away as soon as
   scrolling stops, wherever the page is (app/theme.js, 250 ms after the last
   scroll). */
body.o-app { transition: box-shadow var(--o-t) var(--o-ease); }
html.o-scrolled body.o-app { box-shadow: inset 0 0 0 100vmax var(--o-navbar-tint, rgba(30, 30, 34, .05)); }

/* Cards take the tint too while scrolling (their own background only; rows,
   pills and other blocks inside keep their colour). */
:root { --o-card-tint: color-mix(in srgb, var(--o-surface) 95%, #1E1E22); }
html[data-theme="dark"] { --o-card-tint: color-mix(in srgb, var(--o-surface) 82%, #000); }
.o-main .o-card,
.o-main .o-kpi { transition: background-color 700ms var(--o-ease), box-shadow 700ms var(--o-ease); }
html.o-scrolled .o-main .o-card,
html.o-scrolled .o-main .o-kpi { background-color: var(--o-card-tint); }

/* Slow, soft fade in when scrolling starts and back out when it stops (700 ms). */
body.o-app,
.o-app > .o-topbar,
.o-app > .o-sidebar::after,
.section-page > .o-pagehead:first-child,
.o-main > .o-pagehead:first-child,
.section-page > .o-pagehead:first-child::after,
.o-main > .o-pagehead:first-child::after { transition-duration: 700ms; }
html.o-scrolled body.o-app,
html.o-scrolled .o-app > .o-topbar,
html.o-scrolled .o-app > .o-sidebar::after,
html.o-scrolled .section-page > .o-pagehead:first-child,
html.o-scrolled .o-main > .o-pagehead:first-child,
html.o-scrolled .section-page > .o-pagehead:first-child::after,
html.o-scrolled .o-main > .o-pagehead:first-child::after,
html.o-scrolled .o-main .o-card,
html.o-scrolled .o-main .o-kpi { transition-duration: 700ms; }

/* ===== Pop-ups redesign (2026-11-01) =====
   Every dialog, confirm box, side/bottom sheet, menu, popover and toast in
   the teacher, student, guardian, class and messages pages. Look only: no
   field, button or feature is added or removed.
   - Header: an icon tile (added by app/theme.js from the pop-up's title),
     a clear title and a quieter line under it, divided from the form.
   - Body: white bordered inputs, small section labels, lists and settings
     in bordered cards, the class/batch pickers grouped in a soft panel.
   - Footer: a soft band; extra actions on the left, Cancel as an outlined
     button, the one main action in teal (#1A1411) on the right.
   - Phones: bottom sheets with a grab handle and big tap targets.
   - Dark mode: every token below has a dark twin. */
:root {
  --o-pop-r: 20px;
  --o-pop-r-menu: 14px;
  --o-pop-r-item: 8px;
  --o-pop-scrim: rgba(16, 24, 28, .36);
  --o-pop-blur: blur(6px);
  --o-pop-shadow: 0 32px 64px -12px rgba(16, 24, 28, .24), 0 8px 20px -6px rgba(16, 24, 28, .10), 0 0 0 1px rgba(16, 24, 28, .06);
  --o-pop-shadow-sm: 0 16px 40px -8px rgba(16, 24, 28, .20), 0 4px 10px -4px rgba(16, 24, 28, .08), 0 0 0 1px rgba(16, 24, 28, .06);
  --o-pop-band: #F7F7F8;
  --o-pop-input: #FFFFFF;
  --o-pop-input-line: #DCDCE0;
  --o-pop-input-line-hover: #C4C4CB;
  --o-pop-panel: #F7F7F8;
  --o-pop-tile-bg: color-mix(in srgb, var(--o-brand, #1A1411) 9%, #FFFFFF);
  --o-pop-tile-ink: var(--o-brand, #1A1411);
  --o-pop-hover: color-mix(in srgb, var(--o-brand, #1A1411) 7%, transparent);
  --o-pop-ring: 0 0 0 3px color-mix(in srgb, var(--o-brand, #1A1411) 22%, transparent);
  --o-pop-toast: #1E1E22;
}
html[data-theme="dark"] {
  --o-pop-scrim: rgba(0, 0, 0, .6);
  --o-pop-shadow: 0 32px 64px -12px rgba(0, 0, 0, .7), 0 8px 20px -6px rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 255, 255, .08);
  --o-pop-shadow-sm: 0 16px 40px -8px rgba(0, 0, 0, .65), 0 0 0 1px rgba(255, 255, 255, .08);
  --o-pop-band: #1B1B20;
  --o-pop-input: #18181D;
  --o-pop-input-line: #3A3A44;
  --o-pop-input-line-hover: #4C4C57;
  --o-pop-panel: #1B1B20;
  --o-pop-tile-bg: color-mix(in srgb, #4A382F 30%, #212127);
  --o-pop-tile-ink: #9FD0DC;
  --o-pop-hover: rgba(255, 255, 255, .06);
  --o-pop-ring: 0 0 0 3px rgba(127, 179, 192, .38);
  --o-pop-toast: #2E2E36;
}

/* ---------- Backdrop ---------- */
.o-modal,
.o-sheet,
html .cn-confirm-overlay,
.editor-overlay {
  background: var(--o-pop-scrim);
  -webkit-backdrop-filter: var(--o-pop-blur);
  backdrop-filter: var(--o-pop-blur);
}
.cw-sheet-wrap.o-sheet > .cw-scrim { background: transparent; }

/* ---------- Boxes ---------- */
.o-modal__box,
.o-sheet__panel,
html .cn-confirm-card,
.editor-card {
  background: var(--o-surface);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: var(--o-pop-shadow);
}
.o-modal__box,
html .cn-confirm-card,
.editor-card { border-radius: var(--o-pop-r); }
.o-sheet__panel { border-radius: var(--o-pop-r) 0 0 var(--o-pop-r); }
.o-modal__box,
.o-sheet__panel,
.editor-card {
  /* Inputs inside pop-ups: white, with a fine border */
  --o-control-bg: var(--o-pop-input);
  --o-control-bg-hover: var(--o-pop-input);
  --cw-ctl-line: var(--o-pop-input-line);
}

/* ---------- Header ---------- */
.o-modal__head,
.o-sheet__head {
  align-items: flex-start;
  gap: 14px;
  padding: 20px 16px 18px 24px;
  border-bottom: 1px solid var(--o-line);
}
.o-modal__title,
.o-sheet__title,
.editor-head .o-modal__title,
html .cn-confirm-title {
  margin: 0;
  padding-top: 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 24px;
  letter-spacing: -.015em;
  color: var(--o-ink);
}
.o-modal__sub,
.o-sheet__sub {
  margin: 4px 0 0;
  max-width: 62ch;
  font-size: 13.5px;
  line-height: 20px;
  color: var(--o-muted);
}
/* Icon tile (inserted by app/theme.js) */
.o-pop-tile {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--o-pop-tile-bg);
  color: var(--o-pop-tile-ink);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--o-pop-tile-ink) 12%, transparent);
}
.o-pop-tile .o-ic { font-size: 21px; }
.o-pop-tile[data-tone="danger"],
.o-modal__box:has(.o-modal__foot > .o-btn--danger:not(.o-modal__foot-start)) .o-pop-tile {
  background: var(--o-red-soft);
  color: var(--o-red-ink);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--o-red) 16%, transparent);
}
/* Title block sits level with the tile */
.o-modal__head > .o-pop-tile + .o-grow,
.o-sheet__head > .o-pop-tile + .o-grow,
.o-sheet__head > .o-pop-tile + div { padding-top: 0; min-width: 0; }
.o-modal__head:has(> .o-pop-tile) .o-modal__title,
.o-sheet__head:has(> .o-pop-tile) .o-sheet__title { min-height: 24px; }
.o-modal__head:has(> .o-pop-tile) .o-modal__sub:only-of-type,
.o-sheet__head:has(> .o-pop-tile) .o-sheet__sub { margin-top: 2px; }
/* The close (x) and other header buttons */
.o-modal__head > .o-btn--icon,
.o-sheet__head > .o-btn--icon,
.o-modal__head [data-o-close],
.o-sheet__head [data-o-close],
.wc-pop-x {
  flex: none;
  width: 32px;
  height: 32px;
  min-height: 32px;
  margin-top: 4px;
  border-radius: 10px;
  background: transparent;
  color: var(--o-muted);
  box-shadow: none;
}
.o-modal__head > .o-btn--icon:hover,
.o-sheet__head > .o-btn--icon:hover,
.wc-pop-x:hover { background: var(--o-fill); color: var(--o-ink); }
.o-modal__head > .o-chip { margin-top: 8px; }

/* ---------- Body ---------- */
.o-modal__body { padding: 20px 24px 24px; color: var(--o-ink-2); line-height: 1.55; }
.o-sheet__body { padding: 20px 24px 24px; }
.o-modal__body.o-stack,
.o-modal__body .o-stack.o-gap-4 { gap: 20px; }
:is(.o-modal__box, .o-sheet__panel, .editor-card) .o-field { gap: 8px; }
:is(.o-modal__box, .o-sheet__panel, .editor-card) .o-field__label,
:is(.o-modal__box, .o-sheet__panel, .editor-card) .o-field > label:first-child {
  font-size: 13px;
  font-weight: 600;
  color: var(--o-ink);
}
:is(.o-modal__box, .o-sheet__panel, .editor-card) .o-field__opt { font-weight: 400; color: var(--o-muted); }
:is(.o-modal__box, .o-sheet__panel, .editor-card) .o-field__hint { font-size: 12.5px; }

/* Inputs: white with a fine border; teal ring when focused */
:is(.o-modal__box, .o-sheet__panel, .editor-card) :is(.o-input, .o-select, .o-textarea) {
  border-radius: 10px;
  background-color: var(--o-pop-input);
  box-shadow: inset 0 0 0 1px var(--o-pop-input-line), 0 1px 2px rgba(16, 24, 28, .04);
}
:is(.o-modal__box, .o-sheet__panel, .editor-card) :is(.o-input, .o-select, .o-textarea):hover {
  background-color: var(--o-pop-input);
  box-shadow: inset 0 0 0 1px var(--o-pop-input-line-hover), 0 1px 2px rgba(16, 24, 28, .04);
}
:is(.o-modal__box, .o-sheet__panel, .editor-card) :is(.o-input, .o-select, .o-textarea):focus {
  background-color: var(--o-pop-input);
  box-shadow: inset 0 0 0 1.5px var(--o-brand, #1A1411), var(--o-pop-ring);
}
html[data-theme="dark"] :is(.o-modal__box, .o-sheet__panel, .editor-card) :is(.o-input, .o-select, .o-textarea):focus {
  box-shadow: inset 0 0 0 1.5px #7FB3C0, var(--o-pop-ring);
}
:is(.o-modal__box, .o-sheet__panel, .editor-card) :is(.o-input, .o-select, .o-textarea):disabled {
  background-color: var(--o-pop-panel);
  color: var(--o-muted);
  box-shadow: inset 0 0 0 1px var(--o-line);
}
:is(.o-modal__box, .o-sheet__panel, .editor-card) :is(.o-input, .o-select, .o-textarea):is([aria-invalid="true"], .is-invalid),
:is(.o-modal__box, .o-sheet__panel, .editor-card) .o-field.is-error :is(.o-input, .o-select, .o-textarea) {
  box-shadow: inset 0 0 0 1.5px var(--o-red), 0 0 0 3px color-mix(in srgb, var(--o-red) 14%, transparent);
}
:is(.o-modal__box, .o-sheet__panel) .o-input-wrap > .o-ic { color: var(--o-muted); }

/* The class / batch pickers at the top of a dialog sit together in a soft panel */
.o-modal__body > .o-field-row:first-child,
.o-modal__body > .tp-hw-top:first-child {
  padding: 16px;
  border-radius: 14px;
  background: var(--o-pop-panel);
  box-shadow: inset 0 0 0 1px var(--o-line);
}

/* Small section labels ("Marks", "Students", "Homework for this class") */
:is(.o-modal__box, .o-sheet__panel) .tp-subhead {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--o-muted);
}
:is(.o-modal__box, .o-sheet__panel) .tp-listhead { margin-bottom: 10px; }
:is(.o-modal__box, .o-sheet__panel) .tp-listhead > .tp-subhead { margin: 0; }

/* Lists of students, marks, files and settings: one bordered card */
:is(.o-modal__box, .o-sheet__panel) :is(.tp-rows, .tp-people, .tp-settings) {
  border-radius: 14px;
  background: var(--o-surface);
  box-shadow: inset 0 0 0 1px var(--o-line);
  overflow: hidden;
}
:is(.o-modal__box, .o-sheet__panel) .tp-people { padding: 0; margin: 0; }
:is(.o-modal__box, .o-sheet__panel) .tp-people > li { padding: 10px 12px 10px 16px; border-radius: 0; }
:is(.o-modal__box, .o-sheet__panel) .rec-row {
  min-height: 56px;
  padding: 8px 12px 8px 16px;
  background: transparent;
  transition: background-color var(--o-t-fast) var(--o-ease);
}
:is(.o-modal__box, .o-sheet__panel) .rec-row:hover,
:is(.o-modal__box, .o-sheet__panel) .tp-people > li:hover { background: var(--o-pop-panel); }
:is(.o-modal__box, .o-sheet__panel) .rec-row .tm-mark { width: 72px; text-align: center; font-weight: 600; }
:is(.o-modal__box, .o-sheet__panel) .tp-outof { font-size: 13px; color: var(--o-muted); }
.tp-settings { padding: 0 16px; }
.tp-settings .tp-set-row { padding: 14px 0; }

/* ---------- Footer ---------- */
.o-modal__foot,
.o-sheet__foot,
.cw-sheet-foot {
  gap: 8px;
  padding: 16px 24px;
  background: var(--o-pop-band);
  border-top: 1px solid var(--o-line);
}
.o-modal__foot { border-radius: 0 0 var(--o-pop-r) var(--o-pop-r); }
.o-sheet__foot { border-radius: 0 0 0 var(--o-pop-r); }
:is(.o-modal__foot, .o-sheet__foot, .cw-sheet-foot, .editor-actions) .o-btn { min-height: 40px; height: 40px; padding: 0 18px; border-radius: 10px; }
:is(.o-modal__foot, .o-sheet__foot, .cw-sheet-foot, .editor-actions) .o-btn--primary {
  box-shadow: 0 1px 2px rgba(16, 24, 28, .18), inset 0 1px 0 rgba(255, 255, 255, .10);
}
/* Cancel / Close: outlined white button */
:is(.o-modal__foot, .o-sheet__foot, .cw-sheet-foot, .editor-actions) > :is(.o-btn--ghost, .o-btn--secondary):not(.o-modal__foot-start) {
  background: var(--o-surface);
  color: var(--o-ink);
  box-shadow: inset 0 0 0 1px var(--o-pop-input-line), 0 1px 2px rgba(16, 24, 28, .05);
}
:is(.o-modal__foot, .o-sheet__foot, .cw-sheet-foot, .editor-actions) > :is(.o-btn--ghost, .o-btn--secondary):not(.o-modal__foot-start):hover {
  background: var(--o-pop-panel);
  box-shadow: inset 0 0 0 1px var(--o-pop-input-line-hover), 0 1px 2px rgba(16, 24, 28, .05);
}
/* Extra actions on the left stay quiet text buttons */
.o-modal__foot > .o-modal__foot-start.o-btn--ghost { padding: 0 12px; margin-left: -8px; color: var(--o-ink-2); }
.o-modal__foot > .o-modal__foot-start.o-btn--ghost:hover { background: var(--o-fill); }

/* ---------- Confirm boxes (no form inside) ---------- */
.o-modal__box:has(.o-modal__foot [id^="oConfirmOk"]) { width: min(460px, 100%); }
.o-modal__box:has(.o-modal__foot [id^="oConfirmOk"]) .o-modal__head { border-bottom: 0; padding-bottom: 0; }
.o-modal__box:has(.o-modal__foot [id^="oConfirmOk"]) .o-modal__body { padding: 8px 24px 24px 78px; font-size: 14px; }
.o-modal__box:has(.o-modal__foot [id^="oConfirmOk"]) .o-modal__body > p { margin: 0; }

/* The older class-page confirm box, drawn the same way */
html .cn-confirm-card {
  position: relative;
  width: min(100%, 460px);
  padding: 24px 24px 0 78px;
  text-align: left;
  overflow: hidden;
}
html .cn-confirm-icon {
  position: absolute;
  top: 20px;
  left: 24px;
  width: 40px;
  height: 40px;
  margin: 0;
  border-radius: 12px;
  background: var(--o-pop-tile-bg);
  color: var(--o-pop-tile-ink);
}
html .cn-danger .cn-confirm-icon { background: var(--o-red-soft); color: var(--o-red-ink); }
html .cn-confirm-icon .material-symbols-outlined { font-size: 21px; }
html .cn-confirm-title { margin: 0 0 6px; }
html .cn-confirm-body { font-size: 14px; line-height: 1.55; color: var(--o-ink-2); }
html .cn-confirm-actions {
  justify-content: flex-end;
  gap: 8px;
  margin: 24px -24px 0 -78px;
  padding: 16px 24px;
  background: var(--o-pop-band);
  border-top: 1px solid var(--o-line);
}
html .cn-btn { flex: 0 0 auto; min-height: 40px; padding: 8px 18px; border-radius: 10px; font-size: 14px; }
html .cn-btn-ghost { background: var(--o-surface); box-shadow: inset 0 0 0 1px var(--o-pop-input-line); }
html .cn-btn-ghost:hover { background: var(--o-pop-panel); }
html .cn-consent-note { margin: 12px 0 0; }

/* The timetable "Assign class slot" / "Edit timetable" box */
.editor-card { padding: 0; gap: 0; }
.editor-head {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 14px;
  row-gap: 2px;
  padding: 20px 24px 18px;
  border-bottom: 1px solid var(--o-line);
}
.editor-head > :not(.o-pop-tile) { grid-column: 2; }
.editor-head > .o-pop-tile { grid-row: 1 / span 3; }
.editor-card > :not(.editor-head):not(.editor-actions) { margin: 16px 24px 0; }
.editor-card > .editor-list { margin-bottom: 20px; }
.editor-actions {
  gap: 8px;
  margin-top: auto;
  padding: 16px 24px;
  background: var(--o-pop-band);
  border-top: 1px solid var(--o-line);
}
.editor-item { border-radius: 14px; background: var(--o-surface); box-shadow: inset 0 0 0 1px var(--o-line); }

/* ---------- Menus ---------- */
.o-menu,
.cw-aud-pop {
  padding: 6px;
  border-radius: var(--o-pop-r-menu);
  background: var(--o-surface);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: var(--o-pop-shadow-sm);
}
.o-menu.is-static { box-shadow: none; }
.o-menu__item { min-height: 38px; padding: 8px 10px; gap: 12px; border-radius: var(--o-pop-r-item); font-size: 14px; }
.o-menu__item > .o-ic { font-size: 19px; }
.o-menu__item:hover,
.o-menu__item:focus-visible { background: var(--o-pop-hover); color: var(--o-ink); }
.o-menu__item:hover > .o-ic { color: var(--o-pop-tile-ink); }
.o-menu__item:focus-visible { box-shadow: var(--o-pop-ring); }
.o-menu__item--danger:hover { background: var(--o-red-soft); }
.o-menu__item--danger:hover > .o-ic { color: var(--o-red-ink); }
.o-menu__sep { margin: 6px 4px; }
.o-menu__label {
  padding: 8px 10px 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--o-muted);
}
/* Selected option (Appearance: Light / Dark / device) */
.o-menu__item:has(> .o-menu__check) { background: var(--o-pop-hover); color: var(--o-ink); font-weight: 600; }
.o-menu__item:has(> .o-menu__check) > .o-ic:first-child { color: var(--o-pop-tile-ink); }
.o-menu__check { color: var(--o-pop-tile-ink) !important; }
/* Account menu: a card with the picture, name and email */
.o-menu__head {
  margin: 0 0 6px;
  padding: 14px;
  border-radius: 10px;
  background: var(--o-pop-panel);
  box-shadow: inset 0 0 0 1px var(--o-line);
}
.o-menu__head + .o-menu__sep { display: none; }
.o-menu__head-text b { font-size: 15px; }

/* ---------- Popovers (notifications, session details) ---------- */
.o-pop {
  border-radius: 18px;
  background: var(--o-surface);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: var(--o-pop-shadow-sm);
}
.o-pop__head { padding: 16px 12px 14px 20px; }
.o-pop__title { font-size: 16px; line-height: 22px; }
.o-pop__sub { font-size: 12.5px; }
.o-pop__body { padding: 6px; }
.o-pop__body .o-item { padding: 10px 12px; border-radius: 12px; gap: 12px; }
.o-pop__body .o-item:hover { background: var(--o-pop-hover); }
.o-pop__body .o-item__tile { width: 36px; height: 36px; border-radius: 10px; }
.o-pop__body .o-item__title { font-size: 13.5px; line-height: 19px; }
.o-pop__body .o-empty__icon { width: 56px; height: 56px; border-radius: 16px; background: var(--o-pop-tile-bg); color: var(--o-pop-tile-ink); }
.o-pop__head .o-btn--icon { width: 32px; height: 32px; min-height: 32px; border-radius: 10px; color: var(--o-muted); }
.wc-pop {
  padding: 16px;
  border-radius: 18px;
  background: var(--o-surface);
  box-shadow: var(--o-pop-shadow-sm);
}
.wc-pop-actions { margin-top: 16px; justify-content: flex-end; }
.wc-pop-actions .o-btn { border-radius: 10px; }

/* ---------- Toasts ---------- */
.o-toast,
#toast.toast {
  min-height: 48px;
  padding: 10px 14px 10px 12px;
  gap: 12px;
  border-radius: 14px;
  background: var(--o-pop-toast);
  color: #F4F4F6;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: 0 16px 36px -8px rgba(16, 24, 28, .4), 0 0 0 1px rgba(255, 255, 255, .06);
}
html[data-theme="dark"] .o-toast,
html[data-theme="dark"] #toast.toast { background: var(--o-pop-toast); box-shadow: 0 16px 36px -8px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .1); }
.o-toast:not(:has(> .o-ic)),
#toast.toast:not(.ok):not(.err):not(.warn) { padding-left: 18px; }
.o-toast > .o-ic,
#toast.toast.ok::before,
#toast.toast.err::before,
#toast.toast.warn::before {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .08);
  font-size: 18px;
}
.o-toast__action {
  margin: -2px -4px -2px 8px;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .1);
  color: #A8DCE8;
}
.o-toast__action:hover { background: rgba(255, 255, 255, .18); }

/* ---------- Focus inside pop-ups ---------- */
:is(.o-modal, .o-sheet, .editor-card, .wc-pop) .o-btn:focus-visible,
html .cn-btn:focus-visible { outline: none; box-shadow: var(--o-pop-ring); }
:is(.o-modal, .o-sheet) .o-btn:focus:not(:focus-visible),
html .cn-btn:focus:not(:focus-visible) { outline: none; }

/* ---------- Phones: bottom sheets ---------- */
@media (max-width: 639.98px) {
  .o-modal__box,
  .o-modal__box--md,
  .o-modal__box--lg,
  .o-sheet__panel,
  .o-sheet__panel--wide,
  html .cn-confirm-card,
  .editor-card,
  .wc-pop.is-sheet { border-radius: 24px 24px 0 0; }
  .o-modal__box:has(.o-modal__foot [id^="oConfirmOk"]) { width: 100%; }
  /* Grab handle */
  .o-modal__box::before,
  html .cn-confirm-card::before,
  .editor-card::before,
  .wc-pop.is-sheet::before {
    content: "";
    display: block;
    flex: none;
    width: 36px;
    height: 4px;
    margin: 8px auto 0;
    border-radius: 4px;
    background: var(--o-line-strong);
  }
  html .cn-confirm-card::before { position: absolute; top: 0; left: 50%; margin-left: -18px; }
  .wc-pop.is-sheet::before { margin: -8px auto 12px; }
  .o-sheet__grip { margin: 8px auto -4px; width: 36px; }
  .o-modal__head,
  .o-sheet__head { padding: 14px 12px 14px 16px; gap: 12px; }
  .o-pop-tile { width: 36px; height: 36px; border-radius: 11px; }
  .o-modal__title,
  .o-sheet__title { font-size: 17px; }
  .o-modal__body,
  .o-sheet__body { padding: 16px; }
  .o-modal__box:has(.o-modal__foot [id^="oConfirmOk"]) .o-modal__body { padding: 4px 16px 20px 64px; }
  .o-modal__body > .o-field-row:first-child,
  .o-modal__body > .tp-hw-top:first-child { padding: 12px; }
  .o-modal__foot,
  .o-sheet__foot,
  .cw-sheet-foot,
  .editor-actions { padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); border-radius: 0; }
  :is(.o-modal__foot, .o-sheet__foot, .cw-sheet-foot, .editor-actions) > .o-btn { flex: 1 1 0; min-height: 48px; height: 48px; }
  /* An extra left-hand action takes its own full-width line above Cancel / Save */
  .o-modal__foot > .o-modal__foot-start { flex: 1 1 100%; order: -1; margin: 0 0 4px; justify-content: center; }
  .editor-head { padding: 14px 16px; column-gap: 12px; }
  .editor-card > :not(.editor-head):not(.editor-actions) { margin: 12px 16px 0; }
  html .cn-confirm-card { padding: 28px 16px 0 64px; }
  html .cn-confirm-icon { top: 24px; left: 16px; width: 36px; height: 36px; }
  html .cn-confirm-actions { flex-direction: row; margin: 20px -16px 0 -64px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); }
  html .cn-btn { flex: 1 1 0; min-height: 48px; }
  .o-toast,
  #toast.toast { border-radius: 14px; }
}
/* Settings rows keep their switch on the right, also on phones. */
.tp-set-row:has(> .o-switch) { flex-wrap: nowrap; align-items: center; }

/* ======================================================================
   Phone layout (2026-11-01)
   Same pages, same order, same colours; only size and placement change on
   phones (below 700px wide):
   - main links move to a bottom tab bar (built by app/theme.js), the
     + Create button becomes a round button above it, bottom right, where
     the thumb reaches (Google Classroom / Gmail pattern);
   - tighter, even spacing (8-point grid) and smaller summary cards so more
     fits on one screen;
   - nothing is cut off: header buttons keep their full text and swipe
     sideways, the calendar grid is shorter, wide rows stack.
   ====================================================================== */
@media (max-width: 699.98px) {
  :root { --o-bnav-h: 64px; --o-safe-b: env(safe-area-inset-bottom, 0px); }

  /* ---- Bottom tab bar ---- */
  .o-bnav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 25;
    display: flex;
    align-items: stretch;
    height: calc(var(--o-bnav-h) + var(--o-safe-b));
    padding: 0 4px var(--o-safe-b);
    background: var(--o-canvas, #FAF7F2);
    border-top: 1px solid var(--o-line, rgba(0, 0, 0, .08));
  }
  .o-bnav__item {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--o-muted, #6B6B73);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
    -webkit-tap-highlight-color: transparent;
  }
  .o-bnav__pill {
    position: relative;
    display: grid;
    place-items: center;
    width: 56px;
    height: 32px;
    border-radius: 999px;
    transition: background-color var(--o-t, 160ms) var(--o-ease, ease);
  }
  .o-bnav__pill .o-ic,
  .o-bnav__pill .material-symbols-outlined { font-size: 22px; width: 22px; height: 22px; }
  .o-bnav__pill svg { width: 22px; height: 22px; }
  .o-bnav__label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
  .o-bnav__item.is-active { color: var(--o-ink, #1E1E22); font-weight: 600; }
  .o-bnav__item.is-active .o-bnav__pill { background: color-mix(in srgb, var(--o-brand, #1A1411) 14%, transparent); color: var(--o-brand, #1A1411); }
  html[data-theme="dark"] .o-bnav__item.is-active .o-bnav__pill { background: color-mix(in srgb, var(--o-brand, #4A382F) 40%, transparent); color: #fff; }
  .o-bnav__item:active .o-bnav__pill { background: var(--o-hover, rgba(0, 0, 0, .06)); }
  .o-bnav__dot { display: none; position: absolute; top: 4px; right: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--o-red, #D93025); box-shadow: 0 0 0 2px var(--o-canvas, #FAF7F2); }
  .o-bnav__item.has-unread .o-bnav__dot { display: block; }

  /* The page stops above the tab bar; the last card can scroll clear of
     the round + button. */
  body.o-app.has-bnav > .o-main { margin-bottom: calc(var(--o-bnav-h) + var(--o-safe-b)); }
  body.o-app.has-bnav > .o-main:not(.o-main--flush) { padding-bottom: 88px; }

  /* ---- Round + Create button, bottom right ---- */
  body.has-bnav .o-topbar [data-o-plus] {
    position: fixed;
    right: 16px;
    bottom: calc(var(--o-bnav-h) + var(--o-safe-b) + 16px);
    width: 56px;
    height: 56px;
    --o-btn-h: 56px;
    border-radius: 16px;
    box-shadow: 0 8px 20px color-mix(in srgb, var(--o-brand, #1A1411) 30%, transparent), 0 2px 4px rgba(0, 0, 0, .08);
  }
  body.has-bnav .o-topbar [data-o-plus] { transition: transform 220ms var(--o-ease, ease), opacity 220ms var(--o-ease, ease), background-color var(--o-t, 160ms) var(--o-ease, ease); }
  html.o-fab-away body.has-bnav .o-topbar [data-o-plus]:not([aria-expanded="true"]) { transform: translateY(calc(100% + 24px)); opacity: 0; pointer-events: none; }
  body.has-bnav .o-topbar [data-o-plus] .o-ic,
  body.has-bnav .o-topbar [data-o-plus] svg { font-size: 26px; width: 26px; height: 26px; }

  /* Open chat (WhatsApp style): the conversation gets the whole screen. */
  body.has-bnav:has(#app.chat-open) .o-bnav,
  body.has-bnav:has(#app.chat-open) .o-topbar [data-o-plus] { display: none; }
  body.o-app.has-bnav:has(#app.chat-open) > .o-main { margin-bottom: 0; }
  body.o-app.has-bnav:has(#app.chat-open) > .o-main:not(.o-main--flush) { padding-bottom: 0; }

  /* ---- Top bar: title gets the room the + button left ---- */
  .o-topbar { height: 56px; }
  .o-topbar__title h1, .o-topbar__h { font-size: 18px; }
  .o-topbar__actions { gap: 4px; }

  /* ---- Page header ---- */
  .section-page > .o-pagehead:first-child,
  .o-main > .o-pagehead:first-child,
  .o-pagehead { margin-bottom: 16px; }
  .o-pagehead__title { font-size: 22px; line-height: 1.25; }
  .o-pagehead__sub { margin-top: 4px; }
  /* Buttons keep their full label; extra ones swipe sideways. */
  .o-pagehead__actions {
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    margin-right: -16px;
    padding-right: 16px;
  }
  .o-pagehead__actions::-webkit-scrollbar { display: none; }
  .o-pagehead__actions > * { flex-shrink: 0; scroll-snap-align: start; }
  .o-pagehead__actions .o-btn { white-space: nowrap; }

  /* ---- Summary cards: compact 2 x 2 ---- */
  .o-kpis { gap: 12px; margin-bottom: 16px; }
  .o-kpi { padding: 12px 14px; gap: 6px; border-radius: 16px; }
  .o-kpi__label { gap: 8px; font-size: 13px; line-height: 1.25; }
  .o-kpi__icon { width: 28px; height: 28px; border-radius: 8px; }
  .o-kpi__icon .o-ic, .o-kpi__icon svg { font-size: 16px; width: 16px; height: 16px; }
  .o-kpi__value { font-size: 22px; line-height: 1.15; }
  .o-kpi__foot { font-size: 12px; line-height: 1.35; }
  .kpi-go { position: absolute; right: 12px; bottom: 12px; }
  .kpi-action .o-kpi__foot { padding-right: 20px; }

  /* ---- Cards ---- */
  .o-card { padding: 16px; border-radius: 16px; }
  .o-card--flush { padding: 0; }
  .o-card__head { margin-bottom: 12px; }
  .th-home-grid, .sd-grid { gap: 16px; }

  /* Student home: class cards sit straight on the page instead of inside a
     second card, like the Classes page. */
  #modClasses.sd-mod { padding: 0; background: transparent; box-shadow: none; border: 0; }
  #modClasses.sd-mod > .sd-mod__head { padding: 0 4px; }

  /* ---- Class cards (Classes page, student home) ---- */
  .cw-class-grid { gap: 16px; }
  .cw-cc-top { min-height: 96px; padding: 16px 64px 16px 16px; }
  .cw-cc-avatar { width: 40px; height: 40px; }
  .cw-cc-body { padding: 20px 16px 12px; gap: 8px; }
  .cw-cc-foot { padding: 4px 8px; }

  /* ---- Class page header ---- */
  .o-classhead__banner { padding: 16px; border-radius: 16px; }
  .o-classhead__name { font-size: 20px; line-height: 1.25; }
  .o-classhead__sub { font-size: 13px; }
  .o-classhead__tools .o-btn--tools { --o-btn-h: 36px; width: 36px; }
  .o-classhead__banner:has(> .o-classhead__tools) .o-classhead__name { padding-right: calc(var(--tools-n, 3) * 40px); }
  .o-tabs { scrollbar-width: none; }
  .o-tabs::-webkit-scrollbar { display: none; }
  .o-tab { padding: 0 12px; font-size: 14px; flex-shrink: 0; }

  /* ---- Calendar month: shorter grid, today still a pill ---- */
  .is-month > .o-minimonth { padding: 12px; gap: 12px; }
  .o-minimonth__head { margin-bottom: 8px; }
  .o-minimonth__grid { gap: 4px 0; align-content: start; }
  .o-minimonth__dow { font-size: 12px; padding: 4px 0; }
  .o-minimonth__day { height: 44px; font-size: 15px; }
  .o-minimonth__day-list { padding-top: 12px; }

  /* Calendar: Month / Week switch gets its own full-width row, always in view. */
  .o-pagehead__actions:has(> .o-calviews) { flex-wrap: wrap; overflow: visible; margin-right: 0; padding-right: 0; gap: 8px; }
  .o-pagehead__actions > .o-calviews { order: 5; flex: 1 1 100%; display: flex; }
  .o-pagehead__actions > .o-calviews > a { flex: 1 1 0; justify-content: center; }
  #wcEditBtn#wcEditBtn { flex: 1 1 auto; }

  /* ---- Payments header: month stepper on its own full-width row ---- */
  .tp-pay__head .o-pagehead__actions { flex-wrap: wrap; overflow: visible; margin-right: 0; padding-right: 0; gap: 8px; }
  .tp-pay__head .o-datenav { order: -1; flex: 1 1 100%; justify-content: space-between; }

  /* Segmented switches that are wider than the screen swipe sideways. */
  .o-seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .o-seg::-webkit-scrollbar { display: none; }
  .o-seg > * { flex-shrink: 0; }

  /* ---- Lists and filters ---- */
  .o-filterbar { gap: 8px; }
  .o-chips, .o-filterbar .o-chips { scrollbar-width: none; }
  .o-empty { padding: 24px 16px; }

}

/* ======================================================================
   Phone: glass top fade + floating glass tab bar (2026-11-15)
   Look and motion only, phones only (below 700px). Same colours, icons,
   labels and links.
   - Top: the page now scrolls UNDER the top bar. The bar is see-through
     page colour with a blur, and its lower edge fades out, so content
     dissolves instead of being cut by a line.
   - Bottom: the tab bar is a floating rounded glass pill, inset from the
     edges; the current tab is a soft rounded highlight.
   - Scrolling down makes the pill a little smaller; scrolling up (or the
     top of the page) brings it back. Uses <html class="o-fab-away">, which
     app/theme.js already sets for the round + button.
   - No blur support: solid page colour. Reduced motion: no shrink.
   ====================================================================== */
@media (max-width: 699.98px) {
  :root {
    --o-bnav-b: max(10px, var(--o-safe-b));          /* gap under the pill */
    --o-glass-ease: cubic-bezier(.32, .72, 0, 1);    /* iOS-style settle */
    --o-glass-bg: var(--o-canvas, #FAF7F2);          /* fallback: solid */
    --o-glass-line: rgba(0, 0, 0, .07);
    --o-glass-shadow: 0 10px 30px rgba(0, 0, 0, .14), 0 2px 6px rgba(0, 0, 0, .06), inset 0 1px 0 rgba(255, 255, 255, .6);
    --o-top-fade: 24px;
  }
  html[data-theme="dark"] {
    --o-glass-line: rgba(255, 255, 255, .10);
    --o-glass-shadow: 0 10px 30px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .08);
  }

  /* ---- Top: content scrolls under the bar ---- */
  body.o-app > .o-main:not(.o-main--flush):not(.o-main--fill) {
    grid-row: 1 / -1;
    padding-top: calc(var(--o-top-h) + 12px);
    scroll-padding-top: calc(var(--o-top-h) + 72px);
  }
  body.o-app > .o-topbar,
  html.o-scrolled body.o-app > .o-topbar { background: transparent; box-shadow: none; }
  body.o-app > .o-topbar::before,
  body.o-app .section-page > .o-pagehead:first-child::before,
  body.o-app > .o-main > .o-pagehead:first-child::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: var(--o-glass-bg);
    transition: box-shadow 700ms var(--o-ease, ease);
  }
  /* Soft edge under the frosted bar: colour only, no blur, so text sliding
     under it fades cleanly instead of smudging. */
  body.o-app > .o-topbar::after,
  body.o-app .section-page > .o-pagehead:first-child::after,
  body.o-app > .o-main > .o-pagehead:first-child::after {
    content: '';
    position: absolute;
    left: 0; right: 0; top: 100%;
    width: auto;
    height: var(--o-top-fade);
    z-index: -1;
    pointer-events: none;
    background: linear-gradient(to bottom, color-mix(in srgb, var(--o-canvas, #FAF7F2) 85%, transparent), transparent);
    -webkit-mask: none; mask: none;
    box-shadow: none;
  }
  /* Same light tint while scrolling as before; it now fades out with the edge. */
  html.o-scrolled body.o-app > .o-topbar::before,
  html.o-scrolled body.o-app .section-page > .o-pagehead:first-child::before,
  html.o-scrolled body.o-app > .o-main > .o-pagehead:first-child::before { box-shadow: inset 0 0 0 100vmax var(--o-navbar-tint, rgba(30, 30, 34, .05)); }

  /* A page header that stays fixed under the bar joins the same glass. */
  body.o-app .section-page > .o-pagehead:first-child,
  body.o-app > .o-main > .o-pagehead:first-child,
  html.o-scrolled body.o-app .section-page > .o-pagehead:first-child,
  html.o-scrolled body.o-app > .o-main > .o-pagehead:first-child {
    top: -12px; /* sits right under the bar (the page's own top padding is counted first) */
    margin-top: -12px;
    padding-top: 12px;
    background: transparent;
    box-shadow: none;
  }

  /* ---- Bottom: floating glass pill ---- */
  .o-bnav {
    left: 12px; right: 12px;
    bottom: var(--o-bnav-b);
    height: var(--o-bnav-h);
    padding: 6px;
    border: 1px solid var(--o-glass-line);
    border-radius: 999px;
    background: var(--o-glass-bg);
    box-shadow: var(--o-glass-shadow);
    transform-origin: 50% 100%;
    transition: transform 500ms var(--o-glass-ease);
  }
  html.o-fab-away .o-bnav { transform: scale(.88); }
  .o-bnav__item { gap: 0; border-radius: 999px; transition: background-color 300ms var(--o-glass-ease); }
  .o-bnav__pill { height: 28px; }
  .o-bnav__item.is-active { background: color-mix(in srgb, var(--o-brand, #1A1411) 12%, transparent); }
  html[data-theme="dark"] .o-bnav__item.is-active { background: rgba(255, 255, 255, .12); }
  .o-bnav__item.is-active .o-bnav__pill,
  html[data-theme="dark"] .o-bnav__item.is-active .o-bnav__pill,
  .o-bnav__item:active .o-bnav__pill { background: transparent; }
  .o-bnav__item:active { background: var(--o-hover, rgba(0, 0, 0, .06)); }

  /* Content runs under the pill; the last card still scrolls clear of it. */
  body.o-app.has-bnav > .o-main:not(.o-main--flush):not(.o-main--fill) {
    margin-bottom: 0;
    padding-bottom: calc(var(--o-bnav-h) + var(--o-bnav-b) + 96px);
  }
  body.o-app.has-bnav > .o-main.o-main--flush,
  body.o-app.has-bnav > .o-main.o-main--fill { margin-bottom: calc(var(--o-bnav-h) + var(--o-bnav-b) + 8px); }
  body.has-bnav .o-topbar [data-o-plus] { bottom: calc(var(--o-bnav-h) + var(--o-bnav-b) + 16px); }
  body.o-app.has-bnav:has(#app.chat-open) > .o-main.o-main--flush,
  body.o-app.has-bnav:has(#app.chat-open) > .o-main.o-main--fill { margin-bottom: 0; }

  /* Real glass where the browser can blur what is behind. */
  @supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    :root { --o-glass-bg: color-mix(in srgb, var(--o-canvas, #FAF7F2) 72%, transparent); }
    body.o-app > .o-topbar::before,
    body.o-app .section-page > .o-pagehead:first-child::before,
    body.o-app > .o-main > .o-pagehead:first-child::before,
    .o-bnav {
      -webkit-backdrop-filter: blur(18px) saturate(170%);
      backdrop-filter: blur(18px) saturate(170%);
    }
  }
}
/* Glass bubble in the phone tab bar (2026-11-15). app/theme.js adds one
   .o-bnav__lens behind the tabs: it is the current-tab highlight, slides
   between tabs, and while a finger holds or drags on the bar it lifts into a
   clear glass bubble that follows the finger. */
.o-bnav__lens { display: none; }
@media (max-width: 699.98px) {
  .o-bnav.has-lens { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  .o-bnav.has-lens .o-bnav__item { position: relative; z-index: 1; -webkit-touch-callout: none; -webkit-user-drag: none; }
  .o-bnav.has-lens .o-bnav__item.is-active,
  html[data-theme="dark"] .o-bnav.has-lens .o-bnav__item.is-active,
  .o-bnav.has-lens .o-bnav__item:active { background: transparent; }
  .o-bnav__lens {
    display: block;
    position: absolute;
    left: 0; top: 6px; bottom: 6px;
    z-index: 0;
    width: 60px;
    border-radius: 999px;
    pointer-events: none;
    background: color-mix(in srgb, var(--o-brand, #1A1411) 12%, transparent);
    box-shadow: inset 0 0 0 0 rgba(255, 255, 255, 0);
    transition: translate 520ms cubic-bezier(.3, 1.35, .5, 1), width 300ms var(--o-glass-ease), scale 420ms cubic-bezier(.3, 1.5, .5, 1), opacity 200ms ease, background-color 250ms ease, box-shadow 250ms ease;
  }
  html[data-theme="dark"] .o-bnav__lens { background: rgba(255, 255, 255, .12); }
  .o-bnav__lens.is-still { transition: none; }
  /* Held: the bubble lifts, clears and tracks the finger exactly. */
  .o-bnav.is-held .o-bnav__lens {
    scale: 1.22 1.42;
    background: rgba(255, 255, 255, .22);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .7), inset 0 6px 10px -6px rgba(255, 255, 255, .9), inset 0 -6px 10px -8px rgba(0, 0, 0, .18), 0 6px 18px rgba(0, 0, 0, .16);
    transition: scale 420ms cubic-bezier(.3, 1.5, .5, 1), background-color 250ms ease, box-shadow 250ms ease, translate 60ms linear;
  }
  html[data-theme="dark"] .o-bnav.is-held .o-bnav__lens {
    background: rgba(255, 255, 255, .10);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28), inset 0 6px 10px -6px rgba(255, 255, 255, .35), 0 6px 18px rgba(0, 0, 0, .5);
  }
  @supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .o-bnav.is-held .o-bnav__lens { -webkit-backdrop-filter: blur(1px) brightness(1.08) saturate(1.6); backdrop-filter: blur(1px) brightness(1.08) saturate(1.6); }
  }
  .o-bnav.is-held { transform: scale(1.03); }
  .o-bnav.is-held .o-bnav__item { color: var(--o-muted, #6B6B73); font-weight: 500; transition: scale 300ms var(--o-glass-ease); }
  .o-bnav.is-held .o-bnav__item.is-under { color: var(--o-ink, #1E1E22); font-weight: 600; scale: 1.08; }
  html.o-fab-away .o-bnav.is-held { transform: scale(1.03); }
  .o-bnav.is-held .o-bnav__item:not(.is-under) .o-bnav__pill { color: inherit; }
}
@media (max-width: 699.98px) and (prefers-reduced-motion: reduce) {
  .o-bnav__lens, .o-bnav.is-held .o-bnav__lens { transition: none; }
  .o-bnav.is-held, html.o-fab-away .o-bnav.is-held { transform: none; }

  .o-bnav, .o-bnav__item { transition: none; }
  html.o-fab-away .o-bnav { transform: none; }
}

/* Under the status bar (2026-11-15): on an installed iPhone app the page
   starts at the very top of the screen; the top bar grows by the status-bar
   height so the frosted glass covers it. 0px everywhere else. */
@media (max-width: 699.98px) {
  :root { --o-safe-t: env(safe-area-inset-top, 0px); }
  body.o-app { grid-template-rows: calc(var(--o-top-h) + var(--o-safe-t)) minmax(0, 1fr); }
  body.o-app > .o-topbar { height: calc(56px + var(--o-safe-t)); padding-top: var(--o-safe-t); }
  body.o-app > .o-main:not(.o-main--flush):not(.o-main--fill) {
    padding-top: calc(var(--o-top-h) + var(--o-safe-t) + 12px);
    scroll-padding-top: calc(var(--o-top-h) + var(--o-safe-t) + 72px);
  }
  body.o-app .o-sidebar { padding-top: var(--o-safe-t); }
}

/* ===== Phone top bar: glass bubbles + hide on scroll (2026-11-15) =====
   Like Instagram / Substack: the menu button, page name and the icon group
   sit in floating glass bubbles over a soft fade (no full bar behind them).
   Scrolling down slides them away; the slightest scroll up brings them back
   (html.o-fab-away from app/theme.js). The page header that stays at the
   top moves up into the freed space. Children move with `top` (not
   transform) because the round + button lives inside the bar with
   position: fixed. */
@media (max-width: 699.98px) {
  :root { --o-bar-gone: calc(-1 * (var(--o-top-h) + 8px)); }
  /* Frosted strip only behind the status bar; a colour fade below it. */
  body.o-app > .o-topbar::before { bottom: auto; height: calc(var(--o-safe-t, 0px) + 6px); }
  body.o-app > .o-topbar::after {
    top: calc(var(--o-safe-t, 0px) + 6px);
    height: calc(var(--o-top-h) + 14px);
    background: linear-gradient(to bottom, color-mix(in srgb, var(--o-canvas, #FAF7F2) 92%, transparent), color-mix(in srgb, var(--o-canvas, #FAF7F2) 60%, transparent) 55%, transparent);
    transition: opacity 400ms var(--o-glass-ease);
  }
  html.o-fab-away body.o-app > .o-topbar::after { opacity: 0; }

  /* The bubbles */
  body.o-app > .o-topbar > .o-topbar__menu,
  body.o-app > .o-topbar > .o-topbar__title,
  body.o-app > .o-topbar > .o-topbar__actions {
    position: relative;
    top: 0;
    background: var(--o-glass-bg);
    border: 1px solid var(--o-glass-line);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .10), 0 1px 3px rgba(0, 0, 0, .05), inset 0 1px 0 rgba(255, 255, 255, .55);
    transition: top 450ms var(--o-glass-ease), opacity 300ms ease;
  }
  html[data-theme="dark"] body.o-app > .o-topbar > :is(.o-topbar__menu, .o-topbar__title, .o-topbar__actions) {
    box-shadow: 0 6px 18px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .08);
  }
  body.o-app > .o-topbar > .o-topbar__menu { width: 44px; height: 44px; border-radius: 50%; flex: none; }
  body.o-app > .o-topbar > .o-topbar__title { flex: 0 1 auto; height: 44px; padding: 0 16px; border-radius: 999px; }
  body.o-app > .o-topbar > .o-topbar__actions { margin-left: auto; height: 44px; padding: 0 4px; border-radius: 999px; gap: 0; z-index: 0; }
  /* The icon group's glass is drawn on a layer behind it: blur on the group
     itself would pin the round + button (inside it) to the group. */
  body.o-app > .o-topbar > .o-topbar__actions,
  html[data-theme="dark"] body.o-app > .o-topbar > .o-topbar__actions { background: transparent; border-color: transparent; box-shadow: none; }
  body.o-app > .o-topbar > .o-topbar__actions::before {
    content: '';
    position: absolute;
    inset: -1px;
    z-index: -1;
    border-radius: inherit;
    background: var(--o-glass-bg);
    border: 1px solid var(--o-glass-line);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .10), 0 1px 3px rgba(0, 0, 0, .05), inset 0 1px 0 rgba(255, 255, 255, .55);
    pointer-events: none;
  }
  html[data-theme="dark"] body.o-app > .o-topbar > .o-topbar__actions::before { box-shadow: 0 6px 18px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .08); }
  body.o-app > .o-topbar > .o-topbar__actions .o-topbar__btn:not([data-o-plus]):not([data-o-install]) { background: transparent; }

  /* Away while scrolling down */
  html.o-fab-away body.o-app > .o-topbar > :is(.o-topbar__menu, .o-topbar__title, .o-topbar__actions) { top: var(--o-bar-gone); opacity: 0; pointer-events: none; }
  html.o-fab-away body.o-app > .o-topbar { pointer-events: none; }
  html.o-fab-away body.o-app > .o-topbar [data-o-plus] { pointer-events: none; }
  body.o-app .section-page > .o-pagehead:first-child,
  body.o-app > .o-main > .o-pagehead:first-child { transition: translate 450ms var(--o-glass-ease); }
  html.o-fab-away body.o-app .section-page > .o-pagehead:first-child,
  html.o-fab-away body.o-app > .o-main > .o-pagehead:first-child { translate: 0 calc(-1 * var(--o-top-h)); }

  @supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    body.o-app > .o-topbar > :is(.o-topbar__menu, .o-topbar__title),
    body.o-app > .o-topbar > .o-topbar__actions::before {
      -webkit-backdrop-filter: blur(18px) saturate(170%);
      backdrop-filter: blur(18px) saturate(170%);
    }
  }
}
@media (max-width: 699.98px) and (prefers-reduced-motion: reduce) {
  body.o-app > .o-topbar > *, body.o-app > .o-topbar::after,
  body.o-app .section-page > .o-pagehead:first-child,
  body.o-app > .o-main > .o-pagehead:first-child { transition: none !important; }
}

/* ===== Phone top: content runs to the top edge (2026-11-15) =====
   No band or tint: cards and buttons stay clear as they scroll up and only
   dissolve (soft blur + fade to the page colour) in a thin strip at the very
   top edge of the screen, under the clock and battery. */
@media (max-width: 699.98px) {
  body.o-app > .o-topbar::before,
  html.o-scrolled body.o-app > .o-topbar::before,
  html.o-fab-away body.o-app > .o-topbar::before {
    bottom: auto;
    height: calc(var(--o-safe-t, 0px) + 20px);
    background: linear-gradient(to bottom, var(--o-canvas, #FAF7F2) 0, color-mix(in srgb, var(--o-canvas, #FAF7F2) 55%, transparent) 45%, transparent 100%);
    box-shadow: none;
    -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 40%, transparent 100%);
    mask-image: linear-gradient(to bottom, #000 0, #000 40%, transparent 100%);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    transition: none;
  }
  body.o-app > .o-topbar::after { display: none; }
}

/* ===== Liquid glass (2026-11-15) =====
   Phones only. The floating tab bar and the top-bar bubbles get the full
   glass material, in the same colours as before:
   - Gaussian blur of the page behind, with extra colour and light
   - a faint tint of the page colour (clear, not milky)
   - a refraction band: the rim bends the light, so what is behind looks
     brighter and richer along the edge
   - edge reflection: bright rim on top, soft dark rim underneath
   - a specular shine across the top
   The tab bar's glass sits on two layers behind the tabs (::before = body,
   ::after = rim), so each one can see the page. No blur support or
   "Reduce transparency": solid page colour, as before. */
@media (max-width: 699.98px) {
  :root {
    --lg-solid: var(--o-canvas, #FAF7F2);
    --lg-fill: color-mix(in srgb, var(--o-canvas, #FAF7F2) 38%, transparent);
    --lg-rim: rgba(255, 255, 255, .6);
    --lg-light: inset 0 1px 0.5px rgba(255, 255, 255, .95), inset 0 -1px 1px rgba(0, 0, 0, .08), inset 1px 0 1px rgba(255, 255, 255, .4), inset -1px 0 1px rgba(255, 255, 255, .4), inset 0 0 12px rgba(255, 255, 255, .3);
    --lg-drop: 0 10px 28px rgba(0, 0, 0, .14), 0 2px 6px rgba(0, 0, 0, .06);
    --lg-shine: radial-gradient(120% 90% at 22% -20%, rgba(255, 255, 255, .5), rgba(255, 255, 255, 0) 55%), linear-gradient(to bottom, rgba(255, 255, 255, .18), rgba(255, 255, 255, 0) 45%, rgba(255, 255, 255, 0) 72%, rgba(255, 255, 255, .12));
    --lg-filter: blur(14px) saturate(190%) brightness(1.05);
    --lg-bend: blur(3px) saturate(170%) brightness(1.12);
  }
  html[data-theme="dark"] {
    --lg-fill: color-mix(in srgb, var(--o-canvas, #18181C) 42%, transparent);
    --lg-rim: rgba(255, 255, 255, .2);
    --lg-light: inset 0 1px 0.5px rgba(255, 255, 255, .3), inset 0 -1px 1px rgba(0, 0, 0, .4), inset 0 0 12px rgba(255, 255, 255, .06);
    --lg-drop: 0 10px 28px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .3);
    --lg-shine: radial-gradient(120% 90% at 22% -20%, rgba(255, 255, 255, .14), rgba(255, 255, 255, 0) 55%), linear-gradient(to bottom, rgba(255, 255, 255, .06), rgba(255, 255, 255, 0) 45%);
    --lg-filter: blur(14px) saturate(170%) brightness(.95);
    --lg-bend: blur(3px) saturate(160%) brightness(1.22);
  }

  /* ---- Tab bar ---- */
  .o-bnav {
    background: transparent;
    border-color: transparent;
    box-shadow: var(--lg-drop);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .o-bnav::before,
  .o-bnav::after {
    content: '';
    position: absolute;
    inset: -1px;
    z-index: 0;
    border-radius: inherit;
    pointer-events: none;
  }
  .o-bnav::before {
    border: 0.5px solid var(--lg-rim);
    background: var(--lg-solid);
    box-shadow: var(--lg-light);
  }
  .o-bnav::after { display: none; }
  .o-bnav .o-bnav__item { position: relative; z-index: 1; }

  /* ---- Top bubbles ---- */
  body.o-app > .o-topbar > .o-topbar__menu,
  body.o-app > .o-topbar > .o-topbar__title,
  body.o-app > .o-topbar > .o-topbar__actions::before,
  html[data-theme="dark"] body.o-app > .o-topbar > :is(.o-topbar__menu, .o-topbar__title),
  html[data-theme="dark"] body.o-app > .o-topbar > .o-topbar__actions::before {
    border: 0.5px solid var(--lg-rim);
    box-shadow: var(--lg-light), var(--lg-drop);
  }

  @supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .o-bnav::before,
    body.o-app > .o-topbar > .o-topbar__menu,
    body.o-app > .o-topbar > .o-topbar__title,
    body.o-app > .o-topbar > .o-topbar__actions::before {
      background: var(--lg-shine), var(--lg-fill);
      -webkit-backdrop-filter: var(--lg-filter);
      backdrop-filter: var(--lg-filter);
    }
    /* Refraction band: a 5px ring along the tab bar's edge */
    .o-bnav::after {
      display: block;
      padding: 4px;
      -webkit-backdrop-filter: var(--lg-bend);
      backdrop-filter: var(--lg-bend);
      -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
      -webkit-mask-composite: xor;
      mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
    }
    /* Drag bubble: clear lens with a bright rim and a light catch */
    .o-bnav.is-held .o-bnav__lens {
      background: radial-gradient(100% 80% at 30% 10%, rgba(255, 255, 255, .5), rgba(255, 255, 255, .12) 60%);
      box-shadow: inset 0 1px 1px rgba(255, 255, 255, 1), inset 0 -2px 4px rgba(0, 0, 0, .12), inset 0 0 18px rgba(255, 255, 255, .55), 0 8px 22px rgba(0, 0, 0, .18);
    }
    html[data-theme="dark"] .o-bnav.is-held .o-bnav__lens {
      background: radial-gradient(100% 80% at 30% 10%, rgba(255, 255, 255, .18), rgba(255, 255, 255, .04) 60%);
      box-shadow: inset 0 1px 1px rgba(255, 255, 255, .4), inset 0 0 18px rgba(255, 255, 255, .12), 0 8px 22px rgba(0, 0, 0, .5);
    }
  }
}
@media (max-width: 699.98px) and (prefers-reduced-transparency: reduce) {
  .o-bnav::before,
  body.o-app > .o-topbar > .o-topbar__menu,
  body.o-app > .o-topbar > .o-topbar__title,
  body.o-app > .o-topbar > .o-topbar__actions::before { background: var(--lg-solid); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .o-bnav::after { display: none; }
}

/* ===== Liquid glass: real refraction (2026-11-15) =====
   Tab bar like the iOS 26 demo:
   - the drag bubble grows to 1.5x while a finger is on the bar, can run a
     little past the ends, and a soft light follows the finger
   - Chrome-family browsers only (app/theme.js adds <html class="o-lg-lens">
     after building the filters): the bar and the bubble refract what is
     behind them, with a specular rim. The bubble then sits above the icons,
     so they are seen through the glass. */
.o-bnav__glow { display: none; }
@media (max-width: 699.98px) {
  .o-bnav__glow {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 0;
    border-radius: inherit;
    clip-path: inset(0 round 999px);
    pointer-events: none;
    background: radial-gradient(240px 150px at var(--gx, 50%) var(--gy, 50%), rgba(255, 255, 255, .5) 0%, rgba(255, 255, 255, 0) 74%);
    opacity: 0;
    transition: opacity 180ms ease;
  }
  html[data-theme="dark"] .o-bnav__glow { background: radial-gradient(240px 150px at var(--gx, 50%) var(--gy, 50%), rgba(255, 255, 255, .14) 0%, rgba(255, 255, 255, 0) 74%); }
  .o-bnav.is-held .o-bnav__glow { opacity: 1; }
  /* the indicator moves with left/width, like the demo */
  .o-bnav.has-lens .o-bnav__lens {
    translate: none;
    transform-origin: center center;
    transition: left 240ms cubic-bezier(.2, .9, .22, 1), width 240ms cubic-bezier(.2, .9, .22, 1), scale 250ms ease, opacity 200ms ease, background-color 250ms ease, box-shadow 250ms ease;
  }
  .o-bnav.has-lens.is-held .o-bnav__lens,
  html[data-theme="dark"] .o-bnav.has-lens.is-held .o-bnav__lens {
    scale: 1.5;
    background: rgba(255, 255, 255, .16);
    transition: left 240ms cubic-bezier(.2, .9, .22, 1), width 240ms cubic-bezier(.2, .9, .22, 1), scale 250ms ease, opacity 200ms ease, background-color 250ms ease, box-shadow 250ms ease;
  }
  .o-bnav.has-lens.is-drag .o-bnav__lens,
  html[data-theme="dark"] .o-bnav.has-lens.is-drag .o-bnav__lens { transition: scale 200ms ease, background-color 200ms ease, box-shadow 200ms ease; }
  .o-bnav.has-lens .o-bnav__lens.is-still { transition: none; }
  .o-bnav.is-held { transition: transform 280ms cubic-bezier(.22, 1, .36, 1); }
}
@media (max-width: 699.98px) and (prefers-reduced-motion: reduce) {
  .o-bnav.has-lens .o-bnav__lens, .o-bnav.has-lens.is-held .o-bnav__lens, .o-bnav.has-lens.is-drag .o-bnav__lens { transition: none; }
}
@media (max-width: 699.98px) and (prefers-reduced-transparency: no-preference) {
  /* clear glass, as in the demo: almost no tint, no extra shine, so the bent
     and mirrored picture at the rim stays sharp */
  html.o-lg-lens .o-bnav::before { background: color-mix(in srgb, var(--o-canvas, #FAF7F2) 14%, transparent); box-shadow: none; border-color: transparent; backdrop-filter: url(#oLgLens); }
  html.o-lg-lens[data-theme="dark"] .o-bnav::before { background: color-mix(in srgb, var(--o-canvas, #18181C) 22%, transparent); box-shadow: none; border-color: transparent; backdrop-filter: url(#oLgLens); }
  html.o-lg-lens .o-bnav::after { display: none; }
  html.o-lg-lens .o-bnav.has-lens.is-held .o-bnav__lens,
  html.o-lg-lens[data-theme="dark"] .o-bnav.has-lens.is-held .o-bnav__lens {
    z-index: 5;
    background: rgba(255, 255, 255, .06);
    backdrop-filter: url(#oLgDrop);
  }
}
/* Press effect on phone nav buttons (2026-11-15): while a finger is on a
   button it presses in a little (scale .94) and turns into a small glass
   drop: bright rims on two opposite corners, a fine dark inner edge and a
   diagonal sheen. On release it springs back with a bounce. The icon group
   is not scaled as a whole (the round + button lives inside it); its
   buttons press one by one. */
@media (max-width: 699.98px) {
  :root {
    --lg-press: inset 2px -2px 1px -1px rgba(255, 255, 255, .9), inset -2px 2px 1px -1px rgba(255, 255, 255, .9), inset 6px -6px 1px -6px rgba(255, 255, 255, .55), inset -6px 6px 1px -6px rgba(255, 255, 255, .55), inset 0 0 2px rgba(0, 0, 0, .5), 0 4px 8px rgba(0, 0, 0, .2);
    --lg-press-sheen: linear-gradient(45deg, rgba(255, 255, 255, .55) 0%, transparent 25%, transparent 75%, rgba(255, 255, 255, .55) 100%);
  }
  html[data-theme="dark"] {
    --lg-press: inset 2px -2px 1px -1px rgba(255, 255, 255, .45), inset -2px 2px 1px -1px rgba(255, 255, 255, .45), inset 6px -6px 1px -6px rgba(255, 255, 255, .25), inset -6px 6px 1px -6px rgba(255, 255, 255, .25), inset 0 0 2px rgba(0, 0, 0, .8), 0 4px 8px rgba(0, 0, 0, .45);
    --lg-press-sheen: linear-gradient(45deg, rgba(255, 255, 255, .18) 0%, transparent 25%, transparent 75%, rgba(255, 255, 255, .18) 100%);
  }
  body.o-app > .o-topbar > .o-topbar__menu:active,
  html[data-theme="dark"] body.o-app > .o-topbar > .o-topbar__menu:active { box-shadow: var(--lg-press); }
  body.o-app > .o-topbar > .o-topbar__actions .o-topbar__btn:not([data-o-plus]):not([data-o-install]):active { background: var(--lg-press-sheen); box-shadow: var(--lg-press); }
  body.o-app > .o-topbar > .o-topbar__actions .o-topbar__btn[data-o-install]:active { box-shadow: var(--lg-press); }
}
@media (max-width: 699.98px) and (prefers-reduced-motion: no-preference) {
  /* release: spring back */
  body.o-app > .o-topbar > .o-topbar__menu { transition: top 450ms var(--o-glass-ease), opacity 300ms ease, transform 400ms cubic-bezier(.175, .885, .32, 2.2), box-shadow 250ms ease; }
  body.o-app > .o-topbar > .o-topbar__actions .o-topbar__btn:not([data-o-plus]) { transition: transform 400ms cubic-bezier(.175, .885, .32, 2.2), box-shadow 250ms ease; }
  /* press: go in */
  body.o-app > .o-topbar > .o-topbar__menu:active { transform: scale(.94); transition: top 450ms var(--o-glass-ease), opacity 300ms ease, transform 250ms ease, box-shadow 250ms ease; }
  body.o-app > .o-topbar > .o-topbar__actions .o-topbar__btn:not([data-o-plus]):active { transform: scale(.94); transition: transform 250ms ease, box-shadow 250ms ease; }
}
/* Top edge of the screen (2026-11-15): no blur and no fade any more. Cards
   and icons scroll straight up behind the clock, wifi and battery. In
   Chrome-family browsers the strip bends them like wavy glass (#oLgWave
   from app/theme.js); iPhone shows them clear. */
@media (max-width: 699.98px) {
  body.o-app > .o-topbar::before,
  html.o-scrolled body.o-app > .o-topbar::before,
  html.o-fab-away body.o-app > .o-topbar::before {
    background: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  html.o-lg-lens body.o-app > .o-topbar::before,
  html.o-lg-lens.o-scrolled body.o-app > .o-topbar::before,
  html.o-lg-lens.o-fab-away body.o-app > .o-topbar::before { backdrop-filter: url(#oLgWave); }
}

/* Top fade, status bar only (2026-11-15): soft blur + fade to the page
   colour from the very top edge of the screen down to just above the
   top-bar bubbles (avatar), never over them. Replaces the clear strip. */
@media (max-width: 699.98px) {
  body.o-app > .o-topbar::before,
  html.o-scrolled body.o-app > .o-topbar::before,
  html.o-fab-away body.o-app > .o-topbar::before,
  html.o-lg-lens body.o-app > .o-topbar::before,
  html.o-lg-lens.o-scrolled body.o-app > .o-topbar::before,
  html.o-lg-lens.o-fab-away body.o-app > .o-topbar::before {
    top: 0;
    bottom: auto;
    height: var(--o-safe-t, 0px);
    background: linear-gradient(to bottom, var(--o-canvas, #FAF7F2) 0, color-mix(in srgb, var(--o-canvas, #FAF7F2) 70%, transparent) 55%, transparent 100%);
    box-shadow: none;
    -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 55%, transparent 100%);
    mask-image: linear-gradient(to bottom, #000 0, #000 55%, transparent 100%);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    transition: none;
  }
}

/* Page header stays put (2026-11-15): the phone tab bar is built on every
   width but only styled under 700px; on wider screens it sat under the page
   and let the whole window scroll 44px, dragging the fixed page header up
   with it. Hide it there so only the content under the header scrolls. */
@media (min-width: 700px) {
  .o-bnav { display: none; }
}

/* ===== Phone motion pass (2026-11-15) =====
   1. No gap above the pinned page header: the page colour now runs from
      the header up to the very top of the screen (behind the top-bar bubbles
      and the clock), like the navigation bar in iOS / Instagram / Telegram,
      so cards no longer peek through between the screen edge and the header.
      (Drawn as a shadow of the header, so it moves with it.)
   2. Bottom sheets and the side menu settle without overshooting (iOS
      sheet curve); the old spring went a hair past the edge and showed a
      thin line under the sheet / beside the menu. */
@media (max-width: 699.98px) {
  body.o-app .section-page > .o-pagehead:first-child,
  body.o-app > .o-main > .o-pagehead:first-child,
  html.o-scrolled body.o-app .section-page > .o-pagehead:first-child,
  html.o-scrolled body.o-app > .o-main > .o-pagehead:first-child {
    --o-head-up: calc(-1 * (var(--o-top-h, 56px) + var(--o-safe-t, 0px) + 24px));
    box-shadow: 0 var(--o-head-up) 0 0 var(--o-canvas, #FAF7F2);
    transition: translate 450ms var(--o-glass-ease), box-shadow 700ms var(--o-ease, ease);
  }
  html.o-scrolled body.o-app .section-page > .o-pagehead:first-child,
  html.o-scrolled body.o-app > .o-main > .o-pagehead:first-child {
    box-shadow: 0 var(--o-head-up) 0 0 var(--o-navbar-tint, rgba(30, 30, 34, .05)), 0 var(--o-head-up) 0 0 var(--o-canvas, #FAF7F2);
  }
}
@media (max-width: 639.98px) {
  .o-modal__box,
  .o-modal__box--md,
  .o-modal__box--lg,
  .o-sheet__panel,
  .o-sheet__panel--wide { animation-timing-function: cubic-bezier(.32, .72, 0, 1); }
}
@media (max-width: 899.98px) {
  body.is-drawer-open > .o-sidebar { transition-timing-function: cubic-bezier(.32, .72, 0, 1), linear, cubic-bezier(.32, .72, 0, 1); }
}


/* Phone tab bar: no white border (2026-11-16) */
@media (max-width: 699.98px) {
  .o-bnav::before { border-color: transparent; box-shadow: none; }
  .o-bnav::after { display: none; }
}

/* Page header stays put on phones (2026-11-16): it no longer slides up when
   the top bar hides on scroll; it stays exactly where it is in every console. */
@media (max-width: 699.98px) {
  html.o-fab-away body.o-app .section-page > .o-pagehead:first-child,
  html.o-fab-away body.o-app > .o-main > .o-pagehead:first-child { translate: none; }
}

/* No top fade on phones (2026-11-16): the strip under the clock is plain page
   colour (no blur, no gradient) and the soft fade under the bar and the page
   header is gone, so the top ends in a clean edge. */
@media (max-width: 699.98px) {
  body.o-app > .o-topbar::before,
  html.o-scrolled body.o-app > .o-topbar::before,
  html.o-fab-away body.o-app > .o-topbar::before,
  html.o-lg-lens body.o-app > .o-topbar::before,
  html.o-lg-lens.o-scrolled body.o-app > .o-topbar::before,
  html.o-lg-lens.o-fab-away body.o-app > .o-topbar::before {
    background: var(--o-canvas, #FAF7F2);
    -webkit-mask-image: none; mask-image: none;
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  body.o-app > .o-topbar::after,
  body.o-app .section-page > .o-pagehead:first-child::after,
  body.o-app > .o-main > .o-pagehead:first-child::after { display: none; }
}

/* Page header scrolls with the page (2026-11-16, user: "it should not come
   with me while I scroll"): no longer pinned, in every console and width. */
body .section-page > .o-pagehead:first-child,
body .o-main > .o-pagehead:first-child,
html.o-scrolled body .section-page > .o-pagehead:first-child,
html.o-scrolled body .o-main > .o-pagehead:first-child { position: relative !important; top: auto !important; box-shadow: none !important; translate: none !important; }

/* Phone bars like Instagram (2026-11-16): the top bar (menu, title, bell,
   avatar) slides away on scroll down and comes back on any scroll up (the
   existing o-fab-away behaviour); the bottom tab bar stays put at full size.
   The top bar and the notifications panel sit above the page. */
@media (max-width: 699.98px) {
  html.o-fab-away .o-bnav { transform: none; }
}
body.o-app > .o-topbar { z-index: 50; }
.o-pop { z-index: 2147483001; }


/* ===== Back button (2026-11-16) =====
   "<" at the top left of the top bar on every page except Home (script at the
   end of app/theme.js). Phones: same glass circle as the menu button, and it
   hides/returns with the rest of the bar while scrolling. */
.o-topbar > .o-topbar__back { flex: none; margin-right: -4px; }
.o-topbar > .o-topbar__back[hidden] { display: none !important; }
.o-topbar > .o-topbar__back > .o-ic { font-size: 24px; width: 24px; height: 24px; line-height: 1; margin: 0 !important; }
@media (max-width: 699.98px) {
  body.o-app > .o-topbar > .o-topbar__back {
    position: relative;
    top: 0;
    width: 44px;
    height: 44px;
    margin: 0;
    border-radius: 50%;
    background: var(--o-glass-bg);
    border: 0.5px solid var(--lg-rim, var(--o-glass-line));
    box-shadow: var(--lg-light, 0 6px 18px rgba(0, 0, 0, .10)), var(--lg-drop, 0 1px 3px rgba(0, 0, 0, .05));
    transition: top 450ms var(--o-glass-ease), opacity 300ms ease, transform 400ms cubic-bezier(.175, .885, .32, 2.2), box-shadow 250ms ease;
  }
  @supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    body.o-app > .o-topbar > .o-topbar__back {
      background: var(--lg-shine, none), var(--lg-fill, var(--o-glass-bg));
      -webkit-backdrop-filter: var(--lg-filter, blur(18px) saturate(170%));
      backdrop-filter: var(--lg-filter, blur(18px) saturate(170%));
    }
  }
  html.o-fab-away body.o-app > .o-topbar > .o-topbar__back { top: var(--o-bar-gone); opacity: 0; pointer-events: none; }
  body.o-app > .o-topbar > .o-topbar__back:active { transform: scale(.94); box-shadow: var(--lg-press, inset 0 0 2px rgba(0, 0, 0, .2)); transition: top 450ms var(--o-glass-ease), opacity 300ms ease, transform 250ms ease, box-shadow 250ms ease; }
}
@media (max-width: 699.98px) and (prefers-reduced-transparency: reduce) {
  body.o-app > .o-topbar > .o-topbar__back { background: var(--lg-solid, var(--o-glass-bg)); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* ===== Phones: no scroll tint (2026-11-16) =====
   The page and the cards no longer darken while scrolling on phones, so the
   phone has nothing to repaint during a scroll. Desktop keeps the tint. */
@media (max-width: 699.98px) {
  body.o-app,
  html.o-scrolled body.o-app { box-shadow: none; transition: none; }
  .o-main .o-card,
  .o-main .o-kpi,
  html.o-scrolled .o-main .o-card,
  html.o-scrolled .o-main .o-kpi { transition: none; }
  html.o-scrolled .o-main .o-card,
  html.o-scrolled .o-main .o-kpi { background-color: var(--o-surface); }
  /* the page header (it scrolls away with the page) does not tint either */
  body.o-app .section-page > .o-pagehead:first-child,
  body.o-app > .o-main > .o-pagehead:first-child { --o-navbar-tint: transparent; }
  html body.o-app .section-page > .o-pagehead:first-child::before,
  html body.o-app > .o-main > .o-pagehead:first-child::before { transition: none; }
}
