/* ==========================================================================
   UCExams design system
   Tokens, then base, then layout (auth, shell), then components, then utilities.
   One brand colour per school (--brand, set per page in layout.php). Every tint
   is derived with color-mix(), so a school's colour is applied consistently.
   Light and dark themes: see Tokens below (Phase 12a).
   ========================================================================== */

@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("../fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("../fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face { /* dot-below letters used in Yoruba and Igbo names: ẹ ọ ị ụ */
  font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("../fonts/inter-dotbelow.woff2") format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

/* ---------- Tokens ----------
   Light and dark themes (Phase 12a, DM1–DM3). Components use ONLY these tokens, never raw colours.
   - Non-colour tokens and the school's --brand live on :root.
   - Light colour tokens apply to :root and to "light islands" (.light-island, .rc report cards): things that are
     paper and stay light inside a dark page (DM5).
   - Dark colour tokens: :root[data-theme="dark"] (the person chose Dark) and, for System, the same values inside
     @media (prefers-color-scheme: dark) on :root:not([data-theme="light"]). The two dark blocks MUST stay identical
     (tools/contrast_check.php compares them, 12b).
   - The server writes data-theme on <html> (layout_head), so the first paint is already in the right theme. */

:root {
  /* Brand (per school; the default is overridden inline by layout.php's brand_style()) */
  --brand: #2563EB; --brand-ink: #ffffff;

  /* Product colour for UCExams' own surfaces (auth panel, platform) */
  --ucx: #2563EB; --ucx-deep: #1e3a8a;

  /* Type */
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --fs-xs: 0.75rem; --fs-sm: 0.8125rem; --fs-base: 0.875rem; --fs-md: 1rem; --fs-lg: 1.125rem;
  --fs-xl: 1.25rem; --fs-2xl: 1.5rem; --fs-3xl: 1.875rem;
  --lh: 1.5;

  /* Space (4px base) */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px;

  /* Shape */
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px; --r-full: 999px;

  --sidebar-w: 256px; --topbar-h: 64px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

/* Light colours: the page, and light islands inside a dark page. */
:root, .light-island, .rc {
  color-scheme: light;

  /* Neutrals (slate) */
  --n-0: #ffffff; --n-25: #fcfcfd; --n-50: #f8fafc; --n-100: #f1f5f9; --n-150: #eaeef3; --n-200: #e2e8f0;
  --n-300: #cbd5e1; --n-400: #94a3b8; --n-500: #64748b; --n-600: #475569; --n-700: #334155;
  --n-800: #1e293b; --n-900: #0f172a;

  /* Brand tints */
  --brand-hover: color-mix(in srgb, var(--brand) 86%, #000);
  --brand-soft: color-mix(in srgb, var(--brand) 9%, #fff);
  --brand-softer: color-mix(in srgb, var(--brand) 5%, #fff);
  --brand-border: color-mix(in srgb, var(--brand) 30%, #fff);
  --brand-text: color-mix(in srgb, var(--brand) 88%, #000);

  /* Semantic: the colour (icons, text accents, small marks), a soft fill, a border, readable text on the soft fill,
     and a solid fill that white text sits on. */
  --success: #15803d; --success-soft: #ecfdf3; --success-border: #bbf7d0; --success-text: #166534; --success-solid: #15803d;
  --warning: #b45309; --warning-soft: #fffbeb; --warning-border: #fde68a; --warning-text: #92400e;
  --danger:  #d62525; --danger-soft:  #fef2f2; --danger-border:  #fecaca; --danger-text:  #991b1b; --danger-solid: #dc2626; --danger-hover: #b91c1c;
  --info:    #0369a1; --info-soft:    #f0f9ff; --info-border:    #bae6fd; --info-text:    #075985;
  --on-color: #ffffff;              /* text and icons on a solid colour (brand excepted: --brand-ink) */
  --meter-weak: var(--danger); --meter-mid: #d07f0c; --meter-good: #1ea751;   /* 3:1 on white (12b) */

  /* Surfaces and text */
  --bg: #f5f7fa; --surface: var(--n-0); --surface-2: var(--n-50);
  --border: var(--n-200); --border-strong: var(--n-300);
  --text: var(--n-900); --text-2: var(--n-600); --text-3: #607087; --text-disabled: var(--n-400);   /* --text-3: 4.5:1 on every light surface (12b) */
  --topbar-bg: rgb(255 255 255 / .9);
  --image-bg: #ffffff;              /* behind question images and logos: they are drawn for white (DM6) */
  --knob: #ffffff;                  /* switch knobs */
  --control-border: #7b8a9f;        /* inputs, selects, textareas, switch tracks: 3:1 or better on every surface (12b) */
  --control-border-hover: #64748b;

  /* Overlays, toasts */
  --overlay: rgb(15 23 42 / .4); --backdrop: rgb(15 23 42 / .42); --overlay-strong: rgb(15 23 42 / .55); --overlay-max: rgb(15 23 42 / .72);
  --toast-bg: #0f172a; --toast-fg: #ffffff; --toast-muted: rgb(255 255 255 / .6); --toast-action: rgb(255 255 255 / .14);
  --toast-success: #4ade80; --toast-danger: #f87171; --toast-info: #7dd3fc;
  --watermark: rgb(100 116 139 / .13);

  /* Depth */
  --shadow-xs: 0 1px 2px rgb(15 23 42 / .05);
  --shadow-sm: 0 1px 3px rgb(15 23 42 / .08), 0 1px 2px rgb(15 23 42 / .04);
  --shadow-md: 0 8px 20px -6px rgb(15 23 42 / .14), 0 2px 6px rgb(15 23 42 / .06);
  --shadow-lg: 0 24px 48px -12px rgb(15 23 42 / .22);
  --shadow-pop: 0 20px 50px rgb(15 23 42 / .3);
  --ring: 0 0 0 3px color-mix(in srgb, var(--brand) 28%, transparent);
  --ring-danger: 0 0 0 3px rgb(220 38 38 / .18);
}

/* Dark colours: chosen Dark. KEEP IDENTICAL to the System block below. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --n-0: #121a2b; --n-25: #141d30; --n-50: #172136; --n-100: #1c2740; --n-150: #222e48; --n-200: #2a3650;
  --n-300: #3a4763; --n-400: #5b6884; --n-500: #8b97ad; --n-600: #a7b1c2; --n-700: #c3cad6;
  --n-800: #dde2ea; --n-900: #f1f4f8;
  --brand-hover: color-mix(in srgb, var(--brand) 82%, #fff);
  --brand-soft: color-mix(in srgb, var(--brand) 20%, #121a2b);
  --brand-softer: color-mix(in srgb, var(--brand) 11%, #121a2b);
  --brand-border: color-mix(in srgb, var(--brand) 48%, #121a2b);
  --brand-text: color-mix(in srgb, var(--brand) 52%, #fff);
  --success: #4ade80; --success-soft: #10291d; --success-border: #1f5a3a; --success-text: #86efac; --success-solid: #15803d;
  --warning: #fbbf24; --warning-soft: #2c220c; --warning-border: #6b4f12; --warning-text: #fcd34d;
  --danger:  #f87171; --danger-soft:  #2e1517; --danger-border:  #6e2a2e; --danger-text:  #fca5a5; --danger-solid: #dc2626; --danger-hover: #b91c1c;
  --info:    #38bdf8; --info-soft:    #0c2333; --info-border:    #1d4f6e; --info-text:    #7dd3fc;
  --on-color: #ffffff;
  --meter-weak: #f87171; --meter-mid: #fbbf24; --meter-good: #4ade80;
  --bg: #0b1220;
  --text-3: var(--n-500);
  --topbar-bg: rgb(18 26 43 / .88);
  --image-bg: #ffffff;
  --knob: #f1f4f8;
  --control-border: #67748e;
  --control-border-hover: #8b97ad;
  --overlay: rgb(2 6 23 / .6); --backdrop: rgb(2 6 23 / .62); --overlay-strong: rgb(2 6 23 / .7); --overlay-max: rgb(2 6 23 / .82);
  --toast-bg: #2a3650; --toast-fg: #f1f4f8; --toast-muted: rgb(241 244 248 / .65); --toast-action: rgb(241 244 248 / .14);
  --toast-success: #4ade80; --toast-danger: #f87171; --toast-info: #7dd3fc;
  --watermark: rgb(148 163 184 / .14);
  --shadow-xs: 0 1px 2px rgb(0 0 0 / .3);
  --shadow-sm: 0 1px 3px rgb(0 0 0 / .4), 0 1px 2px rgb(0 0 0 / .25);
  --shadow-md: 0 8px 20px -6px rgb(0 0 0 / .55), 0 2px 6px rgb(0 0 0 / .3);
  --shadow-lg: 0 24px 48px -12px rgb(0 0 0 / .65);
  --shadow-pop: 0 20px 50px rgb(0 0 0 / .6);
  --ring: 0 0 0 3px color-mix(in srgb, var(--brand) 50%, transparent);
  --ring-danger: 0 0 0 3px rgb(248 113 113 / .3);
}

/* Dark colours: System, when the device is in dark mode. KEEP IDENTICAL to the block above. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --n-0: #121a2b; --n-25: #141d30; --n-50: #172136; --n-100: #1c2740; --n-150: #222e48; --n-200: #2a3650;
    --n-300: #3a4763; --n-400: #5b6884; --n-500: #8b97ad; --n-600: #a7b1c2; --n-700: #c3cad6;
    --n-800: #dde2ea; --n-900: #f1f4f8;
    --brand-hover: color-mix(in srgb, var(--brand) 82%, #fff);
    --brand-soft: color-mix(in srgb, var(--brand) 20%, #121a2b);
    --brand-softer: color-mix(in srgb, var(--brand) 11%, #121a2b);
    --brand-border: color-mix(in srgb, var(--brand) 48%, #121a2b);
    --brand-text: color-mix(in srgb, var(--brand) 52%, #fff);
    --success: #4ade80; --success-soft: #10291d; --success-border: #1f5a3a; --success-text: #86efac; --success-solid: #15803d;
    --warning: #fbbf24; --warning-soft: #2c220c; --warning-border: #6b4f12; --warning-text: #fcd34d;
    --danger:  #f87171; --danger-soft:  #2e1517; --danger-border:  #6e2a2e; --danger-text:  #fca5a5; --danger-solid: #dc2626; --danger-hover: #b91c1c;
    --info:    #38bdf8; --info-soft:    #0c2333; --info-border:    #1d4f6e; --info-text:    #7dd3fc;
    --on-color: #ffffff;
    --meter-weak: #f87171; --meter-mid: #fbbf24; --meter-good: #4ade80;
    --bg: #0b1220;
    --text-3: var(--n-500);
    --topbar-bg: rgb(18 26 43 / .88);
    --image-bg: #ffffff;
    --knob: #f1f4f8;
    --control-border: #67748e;
    --control-border-hover: #8b97ad;
    --overlay: rgb(2 6 23 / .6); --backdrop: rgb(2 6 23 / .62); --overlay-strong: rgb(2 6 23 / .7); --overlay-max: rgb(2 6 23 / .82);
    --toast-bg: #2a3650; --toast-fg: #f1f4f8; --toast-muted: rgb(241 244 248 / .65); --toast-action: rgb(241 244 248 / .14);
    --toast-success: #4ade80; --toast-danger: #f87171; --toast-info: #7dd3fc;
    --watermark: rgb(148 163 184 / .14);
    --shadow-xs: 0 1px 2px rgb(0 0 0 / .3);
    --shadow-sm: 0 1px 3px rgb(0 0 0 / .4), 0 1px 2px rgb(0 0 0 / .25);
    --shadow-md: 0 8px 20px -6px rgb(0 0 0 / .55), 0 2px 6px rgb(0 0 0 / .3);
    --shadow-lg: 0 24px 48px -12px rgb(0 0 0 / .65);
    --shadow-pop: 0 20px 50px rgb(0 0 0 / .6);
    --ring: 0 0 0 3px color-mix(in srgb, var(--brand) 50%, transparent);
    --ring-danger: 0 0 0 3px rgb(248 113 113 / .3);
  }
}

/* A light island draws its own text colour too: inherited text from a dark page would be light-on-light (12b). */
.light-island { color: var(--text); color-scheme: light; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }   /* the overscroll area matches the theme too */
body {
  margin: 0; font-family: var(--font); font-size: var(--fs-base); line-height: var(--lh);
  color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.012em; color: var(--text); }
h1 { font-size: var(--fs-2xl); font-weight: 650; }
h2 { font-size: var(--fs-lg); font-weight: 600; }
h3 { font-size: var(--fs-md); font-weight: 600; }
p { margin: 0; }
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
.icon { width: 18px; height: 18px; flex: none; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 22px; height: 22px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Brand marks ---------- */
.brand-logo {
  width: 36px; height: 36px; border-radius: var(--r-md); flex: none; object-fit: contain;
  display: inline-grid; place-items: center; background: var(--surface); border: 1px solid var(--border);
}
/* DM6 (12b): a school logo is drawn for white, so it always sits on a light backing, also in dark mode. */
img.brand-logo { background: var(--image-bg); padding: 2px; }
.brand-logo--initials { background: var(--brand); color: var(--brand-ink); border: 0; font-weight: 700; font-size: var(--fs-sm); letter-spacing: .02em; }
.brand-logo--ucx { background: linear-gradient(135deg, var(--ucx), var(--ucx-deep)); color: var(--on-color); border: 0; }
.brand-logo--ucx svg { width: 24px; height: 24px; }
/* 13b: an uploaded product logo, like a school logo, always sits on its light backing (also on the sign-in panel). */
img.brand-logo--product, .auth-logo img.brand-logo--product { background: var(--image-bg); padding: 3px; }

/* ==========================================================================
   Auth pages
   ========================================================================== */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 44%) 1fr; background: var(--surface); }
/* The sign-in side panel is fixed UCExams artwork (white on deep blue): the same in light and dark, so its colours are
   written here rather than taken from the theme tokens. */
.auth-panel {
  position: relative; overflow: hidden; color: #fff;
  background:
    radial-gradient(900px 500px at 110% 110%, rgb(255 255 255 / .14), transparent 60%),
    radial-gradient(600px 400px at -10% -10%, rgb(147 197 253 / .35), transparent 60%),
    linear-gradient(150deg, #1d4ed8 0%, #1e3a8a 60%, #172554 100%);
}
.auth-panel::after { /* fine grid texture */
  content: ""; position: absolute; inset: 0; opacity: .12;
  background-image: linear-gradient(rgb(255 255 255 / .5) 1px, transparent 1px), linear-gradient(90deg, rgb(255 255 255 / .5) 1px, transparent 1px);
  background-size: 44px 44px; mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
}
.auth-panel-inner { position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; padding: var(--s-10) clamp(32px, 5vw, 64px); }
.auth-logo, .auth-mobile-logo { display: flex; align-items: center; gap: var(--s-3); font-weight: 650; font-size: var(--fs-lg); letter-spacing: -0.01em; }
.auth-logo .brand-logo { background: rgb(255 255 255 / .14); border: 1px solid rgb(255 255 255 / .22); }
.auth-pitch { margin: auto 0; max-width: 460px; }
.auth-pitch h2 { color: #fff; font-size: clamp(1.6rem, 2.4vw, 2.1rem); font-weight: 650; letter-spacing: -0.022em; line-height: 1.2; }
.auth-pitch ul { list-style: none; margin: var(--s-8) 0 0; padding: 0; display: grid; gap: var(--s-4); }
.auth-pitch li { display: flex; gap: var(--s-3); align-items: flex-start; color: rgb(255 255 255 / .88); font-size: var(--fs-md); }
.auth-pitch li .icon { color: #93c5fd; margin-top: 2px; }
.auth-panel-foot { color: rgb(255 255 255 / .6); font-size: var(--fs-sm); }
.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--s-10) var(--s-6); }
.auth-mobile-logo { display: none; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { font-size: var(--fs-2xl); }
.auth-card .lead { color: var(--text-2); margin-top: var(--s-2); }
.auth-card form { margin-top: var(--s-6); display: grid; gap: var(--s-4); }
.auth-foot { margin-top: var(--s-6); color: var(--text-3); font-size: var(--fs-sm); text-align: center; }

@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; background: var(--surface); }
  .auth-panel { display: none; }
  .auth-main { justify-content: flex-start; padding: var(--s-6) var(--s-4) var(--s-10); }
  .auth-mobile-logo { display: flex; align-self: flex-start; margin-bottom: var(--s-8); }
  .auth-mobile-logo .brand-logo { width: 32px; height: 32px; }
}

/* ==========================================================================
   App shell
   ========================================================================== */
.shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.sidebar-brand { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-4); height: var(--topbar-h); border-bottom: 1px solid var(--border); }
.brand-text { display: grid; min-width: 0; line-height: 1.25; }
.brand-text strong { font-weight: 650; font-size: var(--fs-base); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.brand-text small { color: var(--text-3); font-size: var(--fs-xs); }
.icon-btn.sidebar-close { display: none; margin-left: auto; flex: none; }
.nav { flex: 1; overflow-y: auto; padding: var(--s-3) var(--s-3) var(--s-4); }
.nav-section + .nav-section { margin-top: var(--s-4); }
.nav-label { padding: var(--s-2) var(--s-3) var(--s-1); font-size: var(--fs-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.nav-item {
  position: relative; display: flex; align-items: center; gap: var(--s-3); padding: 8px var(--s-3);
  border-radius: var(--r-md); color: var(--text-2); font-weight: 500; text-decoration: none;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nav-item:hover { background: var(--n-100); color: var(--text); text-decoration: none; }
.nav-item .icon { color: var(--text-3); }
.nav-item.is-active { background: var(--brand-soft); color: var(--brand-text); font-weight: 600; }
.nav-item.is-active .icon { color: var(--brand); }
.nav-item.is-active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
.nav-item.is-soon { color: var(--text-disabled); cursor: default; }
.nav-item.is-soon:hover { background: none; color: var(--text-disabled); }
.nav-item.is-soon .icon { color: var(--n-300); }
.nav-item em { margin-left: auto; font-style: normal; font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); background: var(--n-100); border-radius: var(--r-full); padding: 1px 7px; }
/* 036: unread count on a menu item (shared by every kind of message: announcements now, the support chat later) */
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-full); background: var(--danger-solid); color: var(--on-color); font-size: 11px; font-weight: 700; line-height: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.sidebar-foot { display: flex; align-items: center; gap: var(--s-2); margin: var(--s-3); padding: var(--s-3); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); font-size: var(--fs-sm); font-weight: 500; }
.sidebar-foot .icon { color: var(--brand); width: 16px; height: 16px; }
/* 13b: the product logo previews on Platform settings → Branding (light and dark). */
.brand-preview { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface); color: var(--text); min-width: 0; }
.brand-preview .subtle { margin-left: auto; padding-left: var(--s-3); }
/* 13b (BR4): the one product line inside a school's portal. */
.sidebar-powered { margin: 0 var(--s-3) var(--s-3); padding: 0 var(--s-3); color: var(--text-3); font-size: var(--fs-xs); }
.sidebar-scrim { display: none; }

.main { margin-left: var(--sidebar-w); min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--s-3); padding: 0 var(--s-8);
  background: var(--topbar-bg); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.icon-btn.topbar-menu { display: none; }
.topbar-spacer { flex: 1; }
.content { max-width: 1240px; margin: 0 auto; padding: var(--s-8) var(--s-8) var(--s-12); }

.switcher, .user-btn {
  display: inline-flex; align-items: center; gap: var(--s-2); border: 1px solid transparent; background: none;
  border-radius: var(--r-md); padding: 6px 10px; cursor: pointer; color: var(--text); max-width: 100%;
}
.switcher { border-color: var(--border); background: var(--surface); font-weight: 550; box-shadow: var(--shadow-xs); }
.switcher .icon { color: var(--text-3); }
.switcher-name { max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.switcher:hover, .user-btn:hover { background: var(--n-100); }
.user-btn { padding: 4px 8px 4px 4px; }
.user-btn-text { display: grid; text-align: left; line-height: 1.2; }
.user-btn-text strong { font-weight: 600; font-size: var(--fs-sm); }
.user-btn-text small { color: var(--text-3); font-size: var(--fs-xs); }
.avatar { width: 34px; height: 34px; border-radius: var(--r-full); display: grid; place-items: center; font-size: var(--fs-xs); font-weight: 650; background: var(--brand-soft); color: var(--brand-text); border: 1px solid var(--brand-border); }

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s var(--ease); box-shadow: none; }
  .sidebar.is-open { transform: none; box-shadow: var(--shadow-lg); }
  .icon-btn.sidebar-close { display: inline-grid; }
  .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 35; background: var(--overlay); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .sidebar.is-open + .sidebar-scrim { opacity: 1; pointer-events: auto; }
  .main { margin-left: 0; }
  .topbar { padding: 0 var(--s-4); }
  .icon-btn.topbar-menu { display: inline-grid; }
  .content { padding: var(--s-6) var(--s-4) var(--s-10); }
}
@media (max-width: 640px) {
  .user-btn-text { display: none; }
  .switcher-name { max-width: 150px; }
  /* Menu, switcher, Help and the avatar must fit a 320-375px phone: the school name gives way (it ends in "…") */
  .topbar { gap: var(--s-2); }
  .dropdown--switcher { min-width: 0; flex: 0 1 auto; }
  .dropdown--switcher .switcher { min-width: 0; width: 100%; padding: 6px 8px; }
  .switcher-name { min-width: 0; }
  .switcher .icon { flex: none; }
}

/* ==========================================================================
   Components
   ========================================================================== */

/* ---------- Page header ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-6); }
.page-header p { color: var(--text-2); margin-top: var(--s-1); }
.page-header .actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }
@media (max-width: 640px) {
  .page-header .actions { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
  .page-header .actions .btn-primary { grid-column: 1 / -1; order: -1; }
  .page-header .actions > .btn:only-child { grid-column: 1 / -1; }
}
.eyebrow { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--brand-text); margin-bottom: var(--s-1); }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-border: var(--border-strong); --btn-hover: var(--n-50);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: 40px; padding: 0 var(--s-4); border-radius: var(--r-md); border: 1px solid var(--btn-border);
  background: var(--btn-bg); color: var(--btn-fg); font-weight: 600; font-size: var(--fs-base);
  cursor: pointer; white-space: nowrap; text-decoration: none; box-shadow: var(--shadow-xs);
  transition: background .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease), transform .05s;
}
.btn:hover { background: var(--btn-hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { --btn-bg: var(--brand); --btn-fg: var(--brand-ink); --btn-border: var(--brand); --btn-hover: var(--brand-hover); }
.btn-primary:hover { border-color: var(--brand-hover); }
.btn-ghost { --btn-bg: transparent; --btn-border: transparent; --btn-hover: var(--n-100); box-shadow: none; }
.btn-danger { --btn-bg: var(--danger-solid); --btn-fg: var(--on-color); --btn-border: var(--danger-solid); --btn-hover: var(--danger-hover); }
.btn-sm { height: 32px; padding: 0 var(--s-3); font-size: var(--fs-sm); }
.btn-lg { height: 46px; padding: 0 var(--s-5); font-size: var(--fs-md); }
.btn-block { width: 100%; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--btn-fg); border-right-color: transparent; animation: spin .7s linear infinite;
}
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: var(--r-md); border: 0; background: none; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--n-100); color: var(--text); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field-label { font-weight: 550; font-size: var(--fs-sm); color: var(--n-700); display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-2); }
.field-label .optional { font-weight: 400; color: var(--text-3); }
.field-hint { font-size: var(--fs-sm); color: var(--text-3); }
.field-error { font-size: var(--fs-sm); color: var(--danger); display: flex; gap: 6px; align-items: flex-start; }
.field-error::before { content: ""; flex: none; width: 14px; height: 14px; margin-top: 3px; border-radius: 50%; background: var(--danger); mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm1 15h-2v-2h2zm0-4h-2V7h2z'/%3E%3C/svg%3E") center/contain no-repeat; }
.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 var(--s-3); border-radius: var(--r-md);
  border: 1px solid var(--control-border); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 96px; padding: var(--s-2) var(--s-3); resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }   /* 4.5:1 or better in both themes (12a) */
.input:hover, .select:hover, .textarea:hover { border-color: var(--control-border-hover); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-2); color: var(--text-3); cursor: not-allowed; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--danger); }
.field.has-error .input:focus, .field.has-error .textarea:focus { box-shadow: var(--ring-danger); }
.select {
  appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 18px;
}
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-right: 44px; }
.input-group .input-addon { position: absolute; right: 4px; }
.input-affix { position: relative; display: flex; align-items: center; }
.input-affix .prefix, .input-affix .suffix { position: absolute; color: var(--text-3); font-size: var(--fs-sm); pointer-events: none; }
.input-affix .prefix { left: 12px; }
.input-affix .suffix { right: 12px; }
.input-affix .prefix + .input { padding-left: 30px; }
.input-affix .input:has(+ .suffix) { padding-right: 76px; }
.form-grid { display: grid; gap: var(--s-4) var(--s-5); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.check { display: inline-flex; align-items: center; gap: var(--s-2); cursor: pointer; font-weight: 500; }

/* Segmented control (also used as tabs on the sign-in page) */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--n-100); border: 1px solid var(--border); border-radius: var(--r-md); }
.segmented button {
  flex: 1; border: 0; background: none; border-radius: 6px; padding: 7px 14px; font-weight: 550; font-size: var(--fs-sm);
  color: var(--text-2); cursor: pointer; white-space: nowrap; transition: background .15s, color .15s, box-shadow .15s;
}
.segmented button:hover:not(:disabled) { color: var(--text); }
.segmented button[aria-checked="true"], .segmented button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--control-border), var(--shadow-sm); }
.segmented button:disabled { opacity: .45; cursor: not-allowed; }
.segmented--block { display: flex; width: 100%; }
/* A full-width set of choices must fit a 320 px phone (the sign-in tabs were 344 px): labels may wrap */
@media (max-width: 380px) { .segmented--block button { min-width: 0; white-space: normal; padding: 7px 6px; line-height: 1.25; } }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--control-border), var(--shadow-sm); }
.segmented--sm button { padding: 5px 8px; font-size: var(--fs-xs); display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
/* Appearance (12a) in the user menu: System / Light / Dark */
.menu-appearance { padding: 6px var(--s-3) var(--s-2); display: grid; gap: 6px; }
.menu-appearance-label { font-size: var(--fs-xs); font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.menu-appearance .segmented { display: flex; width: 100%; }
.segmented--sm button { padding: 5px 12px; }

/* Choice cards (radio-like selectable rows) */
.choice-list { display: grid; gap: var(--s-2); }
.choice {
  display: flex; align-items: center; gap: var(--s-3); width: 100%; text-align: left; padding: var(--s-3) var(--s-4);
  border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.choice:hover { border-color: var(--brand-border); background: var(--brand-softer); }
.choice:focus-visible { box-shadow: var(--ring); border-color: var(--brand); }
.choice .choice-icon { width: 40px; height: 40px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.choice .choice-text { display: grid; flex: 1; min-width: 0; }
.choice .choice-text strong { font-weight: 600; }
.choice .choice-text small { color: var(--text-3); }
.choice > .icon:last-child { color: var(--text-3); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-xs); }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); padding: var(--s-5) var(--s-6) 0; }
.card-header p { color: var(--text-2); margin-top: 2px; font-size: var(--fs-sm); }
.card-body { padding: var(--s-5) var(--s-6); }
.card-footer { display: flex; justify-content: flex-end; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-6); border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.card-footer .footer-note { margin-right: auto; color: var(--text-3); font-size: var(--fs-sm); }
@media (max-width: 640px) {
  .card-header, .card-body { padding-left: var(--s-4); padding-right: var(--s-4); }
  .card-footer { padding: var(--s-3) var(--s-4); }
}
.stack { display: grid; gap: var(--s-6); }
.stack > * { min-width: 0; }   /* let wide tables scroll inside their card instead of widening the page */
.grid { display: grid; gap: var(--s-4); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 800px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .grid-4 { gap: var(--s-3); }
  .grid-4 .stat { padding: var(--s-4); gap: var(--s-2); }
  .grid-4 .stat-value { font-size: var(--fs-2xl); }
  .grid-4 .stat-icon { width: 30px; height: 30px; }
  .grid-4 .stat-icon .icon { width: 16px; height: 16px; }
}
@media (max-width: 340px) { .grid-4 { grid-template-columns: 1fr; } }

/* Stat card */
.stat { padding: var(--s-5); display: grid; gap: var(--s-3); align-content: start; }
.stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--text-2); font-weight: 550; font-size: var(--fs-sm); }
.stat-icon { width: 36px; height: 36px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.stat-value { font-size: var(--fs-3xl); font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-note { color: var(--text-3); font-size: var(--fs-sm); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: var(--r-full); font-size: var(--fs-xs); font-weight: 600; background: var(--n-100); color: var(--n-700); border: 1px solid var(--border); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge--plain::before { display: none; }
.badge--success { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.badge--warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }
.badge--danger  { background: var(--danger-soft);  color: var(--danger);  border-color: var(--danger-border); }
.badge--info    { background: var(--info-soft);    color: var(--info);    border-color: var(--info-border); }
.badge--brand   { background: var(--brand-soft);   color: var(--brand-text); border-color: var(--brand-border); }

/* ---------- Alerts ---------- */
.alert { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface-2); color: var(--n-700); font-size: var(--fs-sm); }
.alert .icon { margin-top: 1px; }
.alert strong { display: block; font-weight: 600; color: inherit; }
.alert li strong, .alert p strong, .alert strong.inline { display: inline; }
.alert--danger  { background: var(--danger-soft);  border-color: var(--danger-border);  color: var(--danger-text); }
.alert--warning { background: var(--warning-soft); border-color: var(--warning-border); color: var(--warning-text); }
.alert--success { background: var(--success-soft); border-color: var(--success-border); color: var(--success-text); }
.alert--info    { background: var(--info-soft);    border-color: var(--info-border);    color: var(--info-text); }

/* ---------- Lists / checklist ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) 0; border-top: 1px solid var(--border); }
.list-row:first-child { border-top: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row small { display: block; color: var(--text-3); overflow-wrap: anywhere; }   /* long file paths (System health) wrap on phones */
.dot-icon { width: 28px; height: 28px; border-radius: var(--r-full); display: grid; place-items: center; flex: none; }
.dot-icon .icon { width: 16px; height: 16px; }
.dot-icon--done { background: var(--success-soft); color: var(--success); }
.dot-icon--todo { background: var(--n-100); color: var(--text-3); }
.dot-icon--warn { background: var(--warning-soft); color: var(--warning); }
.dot-icon--fail { background: var(--danger-soft); color: var(--danger); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); position: relative; }   /* positioned: screen-reader-only labels inside scrolled tables stay contained instead of widening the page on phones (12b) */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-base); }
.table th { text-align: left; font-size: var(--fs-xs); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); background: var(--surface-2); padding: 10px var(--s-4); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px var(--s-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--brand-softer); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Empty state ---------- */
.empty { display: grid; justify-items: center; text-align: center; gap: var(--s-2); padding: var(--s-10) var(--s-6); }
.empty-icon { width: 52px; height: 52px; border-radius: var(--r-xl); display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); margin-bottom: var(--s-2); }
.empty-icon .icon { width: 24px; height: 24px; }
.empty p { color: var(--text-2); max-width: 420px; }

/* ---------- Skeletons ---------- */
.skeleton { border-radius: var(--r-sm); background: linear-gradient(90deg, var(--n-100) 25%, var(--n-150) 50%, var(--n-100) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
.skeleton-line { height: 12px; margin: 8px 0; }
.skeleton-input { height: 42px; border-radius: var(--r-md); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Dropdown menus ---------- */
.dropdown { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 240px; max-width: calc(100vw - 24px);
  padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-md);
  opacity: 0; transform: translateY(-4px) scale(.98); transform-origin: top right; pointer-events: none; visibility: hidden;
  transition: opacity .12s, transform .12s var(--ease), visibility 0s .12s;
}
.menu--left { right: auto; left: 0; transform-origin: top left; }
.dropdown.is-open .menu { opacity: 1; transform: none; pointer-events: auto; visibility: visible; transition: opacity .12s, transform .12s var(--ease); }
.menu-head { padding: var(--s-2) var(--s-3) var(--s-3); display: grid; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu-head small { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; }
.menu-label { padding: 6px var(--s-3); font-size: var(--fs-xs); font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.menu-item { display: flex; align-items: center; gap: var(--s-3); width: 100%; padding: 8px var(--s-3); border: 0; background: none; border-radius: var(--r-md); color: var(--text); text-align: left; cursor: pointer; font-weight: 500; text-decoration: none; }
.menu-item:hover { background: var(--n-100); text-decoration: none; }
.menu-item .icon { color: var(--text-3); }
.menu-item-text { flex: 1; display: grid; min-width: 0; }
.menu-item-text small { color: var(--text-3); font-weight: 400; }
.menu-item[aria-current="true"] { background: var(--brand-softer); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 0; }
.text-brand { color: var(--brand) !important; }

/* ---------- Toasts ---------- */
.toast-region { position: fixed; z-index: 100; right: var(--s-6); bottom: var(--s-6); display: grid; gap: var(--s-2); width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border-radius: var(--r-lg);
  background: var(--toast-bg); color: var(--toast-fg); box-shadow: var(--shadow-lg); font-weight: 500;
  animation: toast-in .22s var(--ease);
}
.toast .icon { margin-top: 1px; }
.toast--success .icon { color: var(--toast-success); }
.toast--danger .icon { color: var(--toast-danger); }
.toast--info .icon { color: var(--toast-info); }
.toast-close { margin-left: auto; border: 0; background: none; color: var(--toast-muted); cursor: pointer; padding: 0; }
.toast.is-leaving { animation: toast-out .18s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(4px); } }
@media (max-width: 640px) { .toast-region { left: 16px; right: 16px; bottom: 16px; width: auto; } }

/* ---------- Password strength ---------- */
.strength { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 2px; }
.strength span { height: 4px; border-radius: 2px; background: var(--n-200); transition: background .2s; }
.strength[data-score="1"] span:nth-child(-n+1) { background: var(--meter-weak); }
.strength[data-score="2"] span:nth-child(-n+2) { background: var(--meter-mid); }
.strength[data-score="3"] span:nth-child(-n+3) { background: var(--meter-good); }
.strength[data-score="4"] span { background: var(--meter-good); }

/* ---------- Utilities ---------- */
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.small { font-size: var(--fs-sm); }
.mt-2 { margin-top: var(--s-2); } .mt-4 { margin-top: var(--s-4); } .mt-6 { margin-top: var(--s-6); }
.row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.btn-row { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.btn-danger-ghost { --btn-fg: var(--danger-text); }
.btn-danger-ghost:hover { --btn-bg: var(--danger-soft); --btn-border: var(--danger-border); }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--text-2); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
/* An attached or uploaded file: icon, name (a download link), size, remove */
.file-chip { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3); border: 1px solid var(--border); border-radius: var(--r-md, 8px); background: var(--surface-2, transparent); min-width: 0; }
.file-chip a { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.file-chip .icon-btn { margin-left: auto; }
.file-chip-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.file-chip .btn { flex: none; }
.stack-sm { display: grid; gap: var(--s-3); }
.stack-sm > * { min-width: 0; }
/* Assignments: text as typed (line breaks kept, long words wrapped) */
.asg-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
.asg-answer { padding: var(--s-3) var(--s-4); border: 1px solid var(--border); border-radius: var(--r-md, 8px); background: var(--surface-2, transparent); }
.asg-row .cell-main a { color: inherit; }
.asg-row .badge { flex: none; }
/* Page guides (Help drawer) */
.topbar-help { flex: none; }
@media (max-width: 640px) { .topbar-help span { display: none; } }   /* icon only on phones (it keeps its aria-label) */
.guide-intro { font-size: var(--fs-md); color: var(--text); }
.guide-steps { margin: 0; padding-left: 1.4em; display: grid; gap: var(--s-3); }
.guide-steps li { padding-left: var(--s-1); }
.guide-steps li::marker { font-weight: 700; color: var(--brand-text); }
.guide-steps strong { display: block; color: var(--text); }
.guide-steps span { color: var(--text-2); line-height: 1.55; }
.guide-rules { border-top: 1px solid var(--border); padding-top: var(--s-4); }
.guide-rules h3 { font-size: var(--fs-md); margin-bottom: var(--s-2); }
.guide-rules ul { margin: 0; padding-left: 1.2em; display: grid; gap: var(--s-2); color: var(--text-2); line-height: 1.55; }
/* A returned mark, for the student and parent */
.asg-result { display: flex; gap: var(--s-4); align-items: flex-start; padding: var(--s-4); border: 1px solid var(--success-border); background: var(--success-soft); border-radius: var(--r-md); }
.asg-score { display: flex; align-items: baseline; gap: 4px; flex: none; }
.asg-score-n { font-size: var(--fs-3xl); font-weight: 700; line-height: 1; color: var(--success-text); }
.asg-score-of { font-size: var(--fs-md); color: var(--success-text); }
.asg-result .asg-text, .asg-result .field-label { color: var(--text); }
/* Assignments marking page (stage 3) */
.asg-counts { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: var(--s-3); }
.asg-count { display: grid; gap: 2px; }
.asg-count-n { font-size: var(--fs-xl, 1.5rem); font-weight: 700; line-height: 1.1; }
.asg-count-l { font-size: var(--fs-sm); color: var(--text-2); }
.asg-toolbar { flex-wrap: wrap; justify-content: space-between; }
.asg-toolbar .segmented { max-width: 100%; overflow-x: auto; }
.asg-toolbar .segmented button { white-space: nowrap; }
.asg-image { margin: 0; display: grid; gap: var(--s-1); }
.asg-image img { display: block; max-width: 100%; height: auto; max-height: 70vh; object-fit: contain; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--image-bg); }
.asg-previous { border-top: 1px solid var(--border); padding-top: var(--s-3); }
.asg-previous summary { cursor: pointer; font-weight: 600; }
.asg-nav { border-bottom: 1px solid var(--border); padding-bottom: var(--s-3); }
.asg-mark-footer { flex-wrap: wrap; }
.divider { display: flex; align-items: center; gap: var(--s-3); color: var(--text-3); font-size: var(--fs-sm); }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ==========================================================================
   Phase 3 components
   ========================================================================== */

/* ---------- Drawer (side panel) and modal: native <dialog> ---------- */
dialog { padding: 0; border: 0; color: var(--text); max-width: none; max-height: none; }
dialog::backdrop { background: var(--backdrop); animation: fade-in .18s var(--ease); }
.drawer {
  position: fixed; inset: 0 0 0 auto; margin: 0; width: min(520px, 100vw); height: 100dvh;
  background: var(--surface); box-shadow: var(--shadow-lg); flex-direction: column;
  animation: drawer-in .22s var(--ease);
}
.drawer[open] { display: flex; }
.drawer--wide { width: min(760px, 100vw); }
.drawer.is-closing { animation: drawer-out .18s var(--ease) forwards; }
.drawer-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); padding: var(--s-5) var(--s-6); border-bottom: 1px solid var(--border); }
.drawer-header p { color: var(--text-2); font-size: var(--fs-sm); margin-top: 2px; }
.drawer-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.drawer-body > form, .drawer-body > .drawer-pane { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.drawer-content { padding: var(--s-5) var(--s-6); display: grid; gap: var(--s-4); align-content: start; flex: 1; overflow-y: auto; }
.drawer-footer { display: flex; justify-content: flex-end; gap: var(--s-3); padding: var(--s-4) var(--s-6); border-top: 1px solid var(--border); background: var(--surface-2); padding-bottom: calc(var(--s-4) + env(safe-area-inset-bottom)); }
.drawer-footer .footer-left { margin-right: auto; }
.drawer-section { display: grid; gap: var(--s-3); padding-top: var(--s-4); border-top: 1px solid var(--border); align-content: start; }
.drawer-section:first-child { border-top: 0; padding-top: 0; }
.drawer-section h3 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; }
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } }
@keyframes drawer-out { to { transform: translateX(24px); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
@media (max-width: 640px) {
  .drawer-header, .drawer-content { padding-left: var(--s-4); padding-right: var(--s-4); }
  .drawer-footer { padding-left: var(--s-4); padding-right: var(--s-4); flex-wrap: wrap; }
  .drawer-footer .btn { flex: 1; }
}

.modal { margin: auto; width: min(440px, calc(100vw - 32px)); border-radius: var(--r-xl); background: var(--surface); box-shadow: var(--shadow-lg); animation: modal-in .18s var(--ease); }
.modal-body { display: flex; gap: var(--s-4); padding: var(--s-6); }
.modal-body p { color: var(--text-2); margin-top: var(--s-2); }
.modal-icon { width: 40px; height: 40px; flex: none; border-radius: var(--r-full); display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.modal-icon--danger { background: var(--danger-soft); color: var(--danger); }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--s-3); padding: var(--s-4) var(--s-6); background: var(--surface-2); border-top: 1px solid var(--border); border-radius: 0 0 var(--r-xl) var(--r-xl); }
/* the waiting bank transfers reminder (046): the two buttons share the row, and stack on a narrow phone */
.fee-remind .modal-footer { flex-wrap: wrap; }
.fee-remind .modal-footer .btn { flex: 1 1 auto; justify-content: center; }
/* the bank transfer review (046): the parent's details beside their receipt, stacked on a phone or a narrow drawer */
.fee-compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--s-4); align-items: start; }
.fee-compare-facts { display: grid; gap: var(--s-3); }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- Underline tabs ---------- */
.tabs { display: flex; gap: var(--s-6); border-bottom: 1px solid var(--border); margin-bottom: var(--s-6); overflow-x: auto; scrollbar-width: none; }
.tabs button { position: relative; border: 0; background: none; padding: var(--s-3) 0; font-weight: 550; color: var(--text-2); cursor: pointer; white-space: nowrap; display: inline-flex; gap: var(--s-2); align-items: center; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--brand-text); }
.tabs button[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--brand); border-radius: 2px; }
.tab-count { font-size: var(--fs-xs); background: var(--n-100); color: var(--text-2); border-radius: var(--r-full); padding: 0 7px; font-weight: 600; }

/* ---------- Stepper (signup) ---------- */
.stepper { display: flex; gap: var(--s-2); margin-top: var(--s-6); }
.stepper span { flex: 1; height: 4px; border-radius: 2px; background: var(--n-200); transition: background .25s; }
.stepper span.is-done { background: var(--ucx); }
.step-label { margin-top: var(--s-2); font-size: var(--fs-xs); font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }

/* ---------- Checkbox tiles and lists ---------- */
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
.check-tile { position: relative; display: flex; align-items: center; gap: var(--s-3); padding: 10px var(--s-3); border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface); cursor: pointer; font-weight: 500; transition: border-color .15s, background .15s; min-width: 0; }
.check-tile:hover { border-color: var(--n-400); }
.check-tile input { width: 16px; height: 16px; accent-color: var(--brand); flex: none; margin: 0; }
.check-tile:has(input:checked) { border-color: var(--brand); background: var(--brand-softer); }
.check-tile:has(input:focus-visible) { box-shadow: var(--ring); }
.check-tile small { display: block; color: var(--text-3); font-weight: 400; font-size: var(--fs-xs); }
.check-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px var(--s-4); max-height: 240px; overflow-y: auto; padding: var(--s-3); border: 1px solid var(--border); border-radius: var(--r-md); }
.check-list label { display: flex; align-items: center; gap: var(--s-2); cursor: pointer; }
.check-list input { accent-color: var(--brand); width: 16px; height: 16px; flex: none; }
@media (max-width: 480px) { .check-grid, .check-list { grid-template-columns: 1fr; } }

.switch { display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; font-weight: 500; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 11px; background: var(--control-border); position: relative; cursor: pointer; transition: background .15s; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--knob); box-shadow: var(--shadow-sm); transition: transform .15s var(--ease); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(16px); }
.switch input:focus-visible { box-shadow: var(--ring); }

.input-status { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: 500; min-height: 20px; }
.input-status .icon { width: 15px; height: 15px; }
.input-status--ok { color: var(--success); }
.input-status--bad { color: var(--danger); }
.input-status--busy { color: var(--text-3); }
.input-upper { text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }

/* ---------- Toolbar, filters, pagination ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border); }
.toolbar .search { position: relative; flex: 1 1 260px; min-width: 200px; }
.toolbar .search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.toolbar .search .input { padding-left: 38px; }
.toolbar .select { width: auto; min-width: 150px; flex: 0 1 190px; }
@media (max-width: 640px) { .toolbar { padding: var(--s-3) var(--s-4); } .toolbar .select { flex: 1 1 140px; min-width: 0; } }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border); flex-wrap: wrap; }
.pagination-info, .pagination-page { color: var(--text-2); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.pagination-buttons { display: flex; align-items: center; gap: var(--s-2); }
.toast-action { border: 0; background: var(--toast-action); color: var(--toast-fg); font-weight: 600; border-radius: var(--r-sm); padding: 3px 10px; cursor: pointer; margin-left: auto; white-space: nowrap; }
.toast-action + .toast-close { margin-left: var(--s-2); }

/* ---------- Tables: clickable rows, error rows, mobile cards ---------- */
.table tr[data-open] { cursor: pointer; }
.table tr.is-clickable { cursor: pointer; }   /* school fees (044): rows that open a drawer */
.table tr.is-clickable:hover td, .table tr.is-clickable:focus-visible td { background: var(--brand-softer); }
.cell-main { font-weight: 600; }
.cell-sub { color: var(--text-3); font-size: var(--fs-sm); }
.table .actions-col { width: 1%; white-space: nowrap; text-align: right; }
.table tr.is-error td { background: var(--danger-soft); }
.table .show-mobile, .table .show-mobile-inline { display: none; }
@media (max-width: 720px) {
  .table--cards .show-mobile { display: block; }
  .table--cards .show-mobile-inline { display: inline; }
  .table--cards thead { display: none; }
  .table--cards, .table--cards tbody, .table--cards tr, .table--cards td { display: block; width: 100%; }
  .table--cards tr { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); }
  .table--cards tr:last-child { border-bottom: 0; }
  .table--cards td { padding: 2px 0; border: 0; }
  .table--cards td.hide-mobile { display: none; }
  .table--cards .actions-col { text-align: left; width: auto; }
}

/* ---------- Classes page ---------- */
.group-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-5) var(--s-3); }
.group-head h3 { display: flex; align-items: center; gap: var(--s-2); }
@media (max-width: 400px) { .group-head { flex-wrap: wrap; } .group-head h3 { flex-wrap: wrap; min-width: 0; } }   /* 043: a level name, its badge and "Add class" fit at 320 */
.class-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1.1fr) auto; gap: var(--s-4); align-items: center; padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border); }
.class-row:hover { background: var(--brand-softer); }
.class-row .meta { color: var(--text-2); font-size: var(--fs-sm); display: flex; align-items: center; gap: 6px; min-width: 0; }
.class-row .meta .icon { width: 15px; height: 15px; color: var(--text-3); flex: none; }
.class-row .row-end { display: flex; gap: var(--s-1); }
@media (max-width: 720px) {
  .class-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: 4px; padding: var(--s-3) var(--s-4); }
  .class-row > .meta { grid-column: 1; }
  .class-row > .row-end { grid-column: 2; grid-row: 1 / span 3; align-self: start; }
  .group-head { padding: var(--s-4) var(--s-4) var(--s-2); }
}

/* ---------- Result panel, drop zone, misc ---------- */
.result-panel { text-align: center; display: grid; justify-items: center; gap: var(--s-3); padding: var(--s-8) var(--s-6); }
.result-panel .big-id { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: .04em; padding: var(--s-3) var(--s-5); border-radius: var(--r-md); background: var(--surface-2); border: 1px dashed var(--border-strong); font-variant-numeric: tabular-nums; }
.dropzone { position: relative; display: grid; justify-items: center; gap: var(--s-2); text-align: center; padding: var(--s-8) var(--s-5); border: 2px dashed var(--border-strong); border-radius: var(--r-lg); background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.is-over { border-color: var(--brand); background: var(--brand-softer); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone:has(input:focus-visible) { box-shadow: var(--ring); }
.btn-google { --btn-bg: var(--surface); --btn-border: var(--border-strong); gap: var(--s-3); }
.btn-google svg { width: 18px; height: 18px; }
.kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; background: var(--n-100); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: var(--s-2) var(--s-5); margin: 0; }
.dl dt { color: var(--text-3); font-size: var(--fs-sm); }
.dl dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

/* School settings: branding */
.branding-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 320px); gap: var(--s-8); align-items: start; }
@media (max-width: 860px) { .branding-grid { grid-template-columns: 1fr; } }
.logo-box { width: 64px; height: 64px; border-radius: var(--r-lg); border: 1px solid var(--border); display: grid; place-items: center; background: var(--surface-2); overflow: hidden; }
.logo-box img { max-width: 56px; max-height: 56px; background: var(--image-bg); border-radius: 6px; padding: 2px; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, 36px); gap: var(--s-2); }
.swatch { width: 36px; height: 36px; border-radius: var(--r-md); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--text); }
.preview { display: grid; gap: var(--s-2); }
.preview-label { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
/* Branding preview (12b): the light pane is a .light-island; the dark pane carries the dark surface tokens itself
   (KEEP equal to the dark token block; tools/contrast_check.php compares them). --brand, --brand-ink and --brand-text
   come from the server palette (school_settings brand_palette). */
.preview-shell--dark { color-scheme: dark; color: var(--text); --bg: #0b1220; --surface: #121a2b; --surface-2: #172136; --border: #2a3650;
  --text: #f1f4f8; --text-2: #a7b1c2; --text-3: #8b97ad; --brand-soft: color-mix(in srgb, var(--brand) 20%, #121a2b); }
.preview-shell {
  display: grid; grid-template-columns: 130px 1fr; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--bg); font-size: 12px; min-height: 170px; }
.preview-side { background: var(--surface); border-right: 1px solid var(--border); padding: 10px; display: grid; gap: 6px; align-content: start; }
.pv-logo { width: 24px; height: 24px; border-radius: 6px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; font-size: 10px; flex: none; overflow: hidden; }
.pv-logo img { width: 100%; height: 100%; object-fit: contain; background: var(--image-bg); }
.pv-nav { display: flex; gap: 6px; align-items: center; padding: 5px 6px; border-radius: 6px; color: var(--text-2); }
.pv-nav.is-active { background: var(--brand-soft); color: var(--brand-text); font-weight: 600; }
.preview-main { padding: 14px; }
.pv-eyebrow { color: var(--brand-text); font-size: 10px; }
.pv-btn { background: var(--brand); color: var(--brand-ink); padding: 6px 10px; border-radius: 6px; font-weight: 600; }
.pv-link { color: var(--brand-text); font-weight: 600; }
.feature-row { display: flex; gap: var(--s-4); align-items: flex-start; cursor: pointer; }
.feature-row span { display: grid; gap: 2px; }
.feature-row small { color: var(--text-2); font-size: var(--fs-sm); line-height: 1.5; }
.feature-row input { appearance: none; width: 38px; height: 22px; border-radius: 11px; background: var(--control-border); position: relative; cursor: pointer; transition: background .15s; flex: none; margin: 2px 0 0; }
.feature-row input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--knob); box-shadow: var(--shadow-sm); transition: transform .15s var(--ease); }
.feature-row input:checked { background: var(--brand); }
.feature-row input:checked::after { transform: translateX(16px); }
.feature-row input:focus-visible { box-shadow: var(--ring); }

.term-row { display: flex; align-items: center; gap: var(--s-4); padding: var(--s-4); border: 1px solid var(--border); border-radius: var(--r-lg); flex-wrap: wrap; }
.term-row .grow { flex: 1; min-width: 200px; display: grid; gap: 2px; }
.term-row.is-current { border-color: var(--brand-border); background: var(--brand-softer); }
.term-no { width: 40px; height: 40px; border-radius: var(--r-full); display: grid; place-items: center; font-weight: 700; background: var(--n-100); color: var(--text-2); flex: none; }
.term-row.is-current .term-no { background: var(--brand); color: var(--brand-ink); }
.level-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) auto auto; gap: var(--s-3); align-items: end; padding-bottom: var(--s-3); border-bottom: 1px solid var(--border); }
.level-row:last-of-type { border-bottom: 0; }
@media (max-width: 720px) { .level-row { grid-template-columns: 1fr 1fr; } .level-row .field:first-child { grid-column: 1 / -1; } }
@media (max-width: 560px) { .hide-sm { display: none; } }

/* Students: selection + bulk actions */
.select-col { width: 44px; }
.select-col input { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; }
.bulk-bar { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; padding: var(--s-3) var(--s-5); background: var(--brand-softer); border-bottom: 1px solid var(--brand-border); }
/* Reset for a student (exam-reset.js) */
.reset-what, .reset-names { margin: 6px 0 0; padding-left: 1.1em; display: grid; gap: 4px; }
.reset-names { gap: 2px; }
.field > .reset-names { margin: 0; }
.reset-note p { margin: 4px 0 0; }
@media (max-width: 720px) { .table--cards td.select-col { position: absolute; right: var(--s-4); width: auto; } .table--cards tr { position: relative; } .bulk-bar { padding: var(--s-3) var(--s-4); } }

/* Promotion wizard (Phase 5) */
.step-dot { width: 32px; height: 32px; border-radius: var(--r-full); display: grid; place-items: center; font-weight: 700; background: var(--n-100); color: var(--text-2); flex: none; }
.step-dot.is-done { background: var(--brand); color: var(--brand-ink); }
.card.is-disabled { opacity: .6; }
.card.is-disabled .card-body { pointer-events: none; }
.promo-row { display: flex; align-items: center; gap: var(--s-4); padding: var(--s-3) var(--s-4); border: 1px solid var(--border); border-radius: var(--r-lg); flex-wrap: wrap; }
.promo-row .grow { flex: 1; min-width: 220px; display: grid; gap: 2px; }
/* Administrators / your schools */
.admin-row { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.admin-row:first-child { border-top: 0; }
.admin-row .grow { flex: 1; min-width: 200px; display: grid; gap: 2px; }
.school-card { display: flex; align-items: center; gap: var(--s-4); padding: var(--s-4); border: 1px solid var(--border); border-radius: var(--r-lg); flex-wrap: wrap; }
.school-card .grow { flex: 1; min-width: 200px; display: grid; gap: 2px; }
.school-card.is-current { border-color: var(--brand-border); background: var(--brand-softer); }
@media (max-width: 720px) {
  .promo-table td:nth-child(2), .promo-table td:nth-child(3) { display: inline-block; width: auto; margin: 6px 8px 0 0; vertical-align: top; }
  .promo-table .select { min-width: 140px !important; }
}

/* ---------------------------------------------------------------------------
   Exams (Phase 6a)
   --------------------------------------------------------------------------- */
.mb-4 { margin-bottom: var(--s-4); }
.mb-6 { margin-bottom: var(--s-6); }
.center { text-align: center; }
.progress { height: 6px; border-radius: 3px; background: var(--n-150); overflow: hidden; min-width: 80px; }
.progress span { display: block; height: 100%; background: var(--brand); border-radius: 3px; transition: width .3s var(--ease); }
.q-snippet { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }

/* Symbol bar (E4) */
.symbol-bar { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.symbol-bar button { min-width: 30px; height: 30px; padding: 0 6px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); font: inherit; font-size: 15px; cursor: pointer; color: var(--text); }
.symbol-bar button:hover { background: var(--brand-softer); border-color: var(--brand-border); }

/* Question editor */
.q-image { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.q-image img { max-height: 140px; max-width: 100%; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--image-bg); }
.q-image.is-busy { opacity: .5; pointer-events: none; }
.option-grid { display: grid; gap: var(--s-2); }
.option-row { display: flex; align-items: center; gap: var(--s-2); }
.option-row .input { flex: 1; }
.option-key { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; flex: none; }
.option-key input { width: 18px; height: 18px; accent-color: var(--success); cursor: pointer; margin: 0; }
.option-key span { width: 28px; height: 28px; border-radius: var(--r-full); display: grid; place-items: center; font-weight: 700; background: var(--n-100); color: var(--text-2); }
.option-key input:checked + span { background: var(--success-solid); color: var(--on-color); }

/* Builder */
.exam-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--s-4); }
.exam-facts div { display: grid; gap: 2px; min-width: 0; }
.exam-facts span { font-size: var(--fs-xs); color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.exam-facts strong { font-weight: 600; overflow-wrap: anywhere; }
.exam-facts--compact { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: var(--s-4); border-radius: var(--r-lg); background: var(--surface-2); }
.section-card.is-off .card-header h2 { color: var(--text-3); }
.section-instr { padding-top: 0; white-space: pre-line; }
.q-list { list-style: none; margin: 0; padding: 0; }
.q-item { display: flex; gap: var(--s-4); padding: var(--s-4) var(--s-5); border-top: 1px solid var(--border); align-items: flex-start; }
/* Questions just imported into a section (CSV): a soft highlight that fades */
.q-item.is-new { animation: q-new 2.4s ease-out; }
@keyframes q-new { from { background: var(--brand-soft); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .q-item.is-new { animation: none; background: var(--brand-softer); } }
/* Class tagging: the "Classes" chips in the question editor, grouped by level */
.grade-chips { display: grid; gap: var(--s-2); }
.grade-group { display: grid; grid-template-columns: 7.5rem 1fr; gap: var(--s-2); align-items: start; }
.grade-group-label { font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); padding-top: 6px; }
.grade-group-chips { display: flex; flex-wrap: wrap; gap: var(--s-1); min-width: 0; }
.grade-chip { position: relative; display: inline-flex; }
.grade-chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.grade-chip span { display: inline-block; padding: 4px 10px; border: 1px solid var(--control-border); border-radius: var(--r-full); font-size: var(--fs-sm); background: var(--surface); color: var(--text); }
.grade-chip input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.grade-chip input:focus-visible + span { box-shadow: var(--ring); }
.grade-tags { display: inline-flex; flex-wrap: wrap; gap: 4px; }
@media (max-width: 640px) { .grade-group { grid-template-columns: 1fr; gap: var(--s-1); } .grade-group-label { padding-top: 0; } }
/* A duplicate row's choices in the section CSV import preview */
.dup-choices { border: 0; margin-inline: 0; padding: 0; display: grid; gap: var(--s-1); min-width: 0; }
.dup-choices .check { font-size: var(--fs-sm); align-items: flex-start; }
.q-num { width: 28px; height: 28px; border-radius: var(--r-full); background: var(--n-100); display: grid; place-items: center; font-weight: 700; font-size: var(--fs-sm); flex: none; }
.q-body { flex: 1; min-width: 0; display: grid; gap: 6px; }
.q-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.q-thumb { max-height: 120px; max-width: 100%; justify-self: start; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--image-bg); }
.q-options { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: var(--fs-sm); color: var(--text-2); }
.q-options li { display: flex; gap: 8px; align-items: baseline; }
.q-options li > span { font-weight: 700; color: var(--text-3); }
.q-options li.is-correct { color: var(--success); font-weight: 600; }
.q-options li.is-correct > span { color: var(--success); }
.q-actions { display: flex; align-items: center; gap: var(--s-3); flex: none; }
.q-mark { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-2); }
.q-mark .input { width: 76px; }
.bank-pick { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--r-md); }
.bank-pick li + li { border-top: 1px solid var(--border); }
.bank-pick label { display: flex; gap: var(--s-3); padding: var(--s-3) var(--s-4); cursor: pointer; align-items: flex-start; }
.bank-pick label:hover { background: var(--brand-softer); }
.bank-pick input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--brand); flex: none; }
.bank-pick span { display: grid; gap: 2px; min-width: 0; }
@media (max-width: 640px) {
  .q-item { flex-wrap: wrap; padding: var(--s-4); }
  .q-actions { width: 100%; justify-content: space-between; padding-left: 44px; }
  .exam-facts--compact { grid-template-columns: 1fr 1fr 1fr; gap: var(--s-2); }
}

/* Monitoring */
.stat-row { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.stat-chip { display: grid; gap: 0; text-align: left; padding: var(--s-3) var(--s-4); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); cursor: pointer; min-width: 110px; font: inherit; color: var(--text); }
.stat-chip strong { font-size: var(--fs-xl); line-height: 1.2; }
.stat-chip span { font-size: var(--fs-sm); color: var(--text-2); }
.stat-chip:hover { border-color: var(--brand-border); }
.stat-chip.is-active { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); background: var(--brand-softer); }
.live-dot { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--success); }
.live-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--success); animation: ucx-pulse 1.6s infinite; }
@keyframes ucx-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 50%, transparent); } 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .live-dot::before { animation: none; } }
.event-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
@media (max-width: 640px) { .stat-chip { min-width: 0; flex: 1 1 30%; padding: var(--s-2) var(--s-3); } }

/* Student: my exams */
.exam-card { display: flex; align-items: center; gap: var(--s-4); padding: var(--s-4); border: 1px solid var(--border); border-radius: var(--r-lg); flex-wrap: wrap; }
.exam-card .grow { flex: 1; min-width: 200px; display: grid; gap: 2px; }
.exam-card--in_progress { border-color: var(--brand-border); background: var(--brand-softer); }
.score-pill { display: inline-grid; justify-items: end; font-size: var(--fs-lg); font-weight: 700; color: var(--brand-text); }
.score-pill small { font-size: var(--fs-xs); font-weight: 500; color: var(--text-3); }

/* Student: taking an exam (focused layout, no sidebar) */
.page-exam { background: var(--bg); min-height: 100vh; }
.exam-bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); padding: var(--s-3) var(--s-6); background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-xs); }
.exam-bar-brand { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.exam-bar-title { display: grid; min-width: 0; }
.exam-bar-title strong, .exam-bar-title small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exam-bar-title small { color: var(--text-3); font-size: var(--fs-xs); }
.exam-bar-status { display: flex; align-items: center; gap: var(--s-3); flex: none; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: var(--fs-lg); padding: 4px 12px; border-radius: var(--r-md); background: var(--n-100); min-width: 72px; text-align: center; }
.timer.is-warning { background: var(--warning-soft); color: var(--warning); }
.timer.is-danger { background: var(--danger-soft); color: var(--danger); }
.save-state { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-2); }
.save-state.is-ok { color: var(--success); }
.save-state.is-bad { color: var(--danger); font-weight: 600; }
.exam-main { max-width: 1100px; margin: 0 auto; padding: var(--s-6) var(--s-6) 96px; }
.exam-intro { max-width: 720px; margin: 0 auto; }
.exam-intro h1 { margin: 0; }
.exam-instructions { white-space: pre-line; padding: var(--s-4); border-left: 3px solid var(--brand); background: var(--brand-softer); border-radius: 0 var(--r-md) var(--r-md) 0; }
.section-overview { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.section-overview li { display: grid; gap: 2px; padding: var(--s-3) var(--s-4); border: 1px solid var(--border); border-radius: var(--r-md); }
.section-overview span { color: var(--text-2); font-size: var(--fs-sm); }
.section-overview small { color: var(--text-3); white-space: pre-line; }
.tips { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; }
.paper { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: var(--s-6); align-items: start; }
.paper-question { padding: var(--s-6); display: grid; gap: var(--s-4); }
.paper-nav { padding: var(--s-4); display: grid; gap: var(--s-4); position: sticky; top: 80px; }
.paper-nav-head { display: grid; gap: 6px; }
.paper-nav-section { display: grid; gap: 6px; }
.q-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; }
.q-grid button { position: relative; height: 38px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); font: inherit; font-weight: 600; cursor: pointer; color: var(--text); }
.q-grid button.is-answered { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.q-grid button.is-current { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand); }
.q-grid button.is-flagged::after { content: ""; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--warning); }
.section-banner { display: grid; gap: 2px; padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); font-size: var(--fs-sm); }
.section-banner span { color: var(--text-2); white-space: pre-line; }
/* Parts inside a section (052): the student's banner, the navigator groups and the builder's part headers */
.part-banner { display: grid; gap: 2px; padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--brand-softer); border: 1px solid var(--brand-border); border-left: 4px solid var(--brand); font-size: var(--fs-sm); }
.part-banner span { color: var(--text-2); white-space: pre-line; }
.part-banner b, .part-banner u, .part-instr b, .part-instr u { font-weight: inherit; }
.part-banner b, .part-instr b { font-weight: 700; }
.part-banner u, .part-instr u { text-decoration: underline; text-underline-offset: 2px; }
.paper-nav-part { display: grid; gap: 6px; margin-top: 4px; }
.part-group { border-top: 1px solid var(--border); }
.part-head { display: flex; gap: var(--s-3); align-items: flex-start; justify-content: space-between; padding: var(--s-3) var(--s-4); background: var(--surface-2); flex-wrap: wrap; }
.part-head .grow { min-width: 0; flex: 1 1 220px; }
.part-instr { white-space: pre-line; margin-top: 2px; }
.part-empty { padding: var(--s-3) var(--s-4); margin: 0; }
.q-part { display: block; min-width: 0; }
.q-part .select { height: 32px; padding: 0 8px; font-size: var(--fs-sm); max-width: 170px; }
.q-head { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.q-label { font-weight: 700; color: var(--brand-text); }
.q-flag { margin-left: auto; }
.q-flag.is-on { color: var(--warning); }
.passage { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.passage summary { cursor: pointer; padding: var(--s-3) var(--s-4); font-weight: 600; }
.passage div { padding: 0 var(--s-4) var(--s-4); white-space: pre-wrap; line-height: 1.7; max-height: 45vh; overflow-y: auto; }
.q-prompt { font-size: var(--fs-md); line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.q-image-full { max-width: 100%; max-height: 60vh; justify-self: start; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--image-bg); }
.choices { display: grid; gap: var(--s-2); }
.choice-row { position: relative; display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); border: 1.5px solid var(--border); border-radius: var(--r-lg); cursor: pointer; transition: border-color .12s, background .12s; min-height: 52px; }
.choice-row:hover { border-color: var(--brand-border); background: var(--brand-softer); }
.choice-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice-row:has(input:focus-visible) { box-shadow: var(--ring); }
.choice-key { width: 32px; height: 32px; border-radius: var(--r-full); display: grid; place-items: center; font-weight: 700; background: var(--n-100); color: var(--text-2); flex: none; }
.choice-text { flex: 1; overflow-wrap: anywhere; white-space: pre-wrap; }
.choice-row.is-selected { border-color: var(--brand); background: var(--brand-softer); }
.choice-row.is-selected .choice-key { background: var(--brand); color: var(--brand-ink); }
.theory-answer { min-height: 220px; font-size: var(--fs-base); line-height: 1.6; resize: vertical; }
.paper-footer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; gap: var(--s-3); padding: var(--s-3) var(--s-4) calc(var(--s-3) + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); }
.paper-nav-toggle { display: none; }
.score-big { font-size: 44px; font-weight: 800; color: var(--brand-text); display: grid; justify-items: center; line-height: 1.1; }
.score-big small { font-size: var(--fs-sm); font-weight: 500; color: var(--text-3); }
@media (max-width: 860px) {
  .paper { grid-template-columns: minmax(0, 1fr); }
  .paper-nav { display: none; position: fixed; left: var(--s-3); right: var(--s-3); bottom: 76px; top: auto; z-index: 25; max-height: 60vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
  .paper.nav-open .paper-nav { display: grid; }
  .paper-nav-toggle { display: inline-flex; }
  .paper-footer .btn { flex: 1; justify-content: center; }
  .paper-footer .paper-nav-toggle { flex: 1.3; }
}
@media (max-width: 640px) {
  .exam-bar { padding: var(--s-2) var(--s-3); gap: var(--s-2); }
  .exam-bar-brand .brand-logo { display: none; }
  .save-state { font-size: 0; }
  .save-state .icon { width: 18px; height: 18px; }
  .save-state.is-bad { font-size: var(--fs-xs); }
  .exam-main { padding: var(--s-4) var(--s-3) 96px; }
  .paper-question { padding: var(--s-4); }
  .timer { font-size: var(--fs-md); min-width: 60px; padding: 4px 8px; }
}
@media (max-width: 640px) {
  .paper-footer { gap: var(--s-2); padding-left: var(--s-3); padding-right: var(--s-3); }
  .paper-footer .btn { min-width: 0; padding-left: var(--s-3); padding-right: var(--s-3); white-space: nowrap; }
  .symbol-bar { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
  .symbol-bar button { flex: none; }
}

/* ---------------------------------------------------------------------------
   Theory marking and results (Phase 6b)
   --------------------------------------------------------------------------- */
.grade-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: var(--s-6); align-items: start; }
.grade-students { padding: 0; position: sticky; top: 80px; max-height: calc(100vh - 110px); overflow-y: auto; }
.grade-students-head { display: grid; gap: 6px; padding: var(--s-4); border-bottom: 1px solid var(--border); }
.grade-students ul { list-style: none; margin: 0; padding: var(--s-2); display: grid; gap: 2px; }
.grade-students button { width: 100%; display: flex; align-items: center; gap: var(--s-2); text-align: left; padding: var(--s-2) var(--s-3); border: 0; border-radius: var(--r-md); background: none; font: inherit; color: var(--text); cursor: pointer; }
.grade-students button:hover { background: var(--n-100); }
.grade-students button.is-current { background: var(--brand-softer); box-shadow: inset 3px 0 0 var(--brand); }
.grade-students .grow { flex: 1; min-width: 0; display: grid; }
.grade-students small { color: var(--text-3); font-size: var(--fs-xs); }
.mark-item { display: grid; gap: var(--s-2); padding: var(--s-4); border: 1px solid var(--border); border-radius: var(--r-lg); }
.answer-box { white-space: pre-wrap; overflow-wrap: anywhere; padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); line-height: 1.6; max-height: 360px; overflow-y: auto; }
.answer-box.is-empty { color: var(--text-3); font-style: italic; }
.mark-form .mark-input { width: 90px; }
.over-answer { color: var(--info); margin: 0; }
.breakdown-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.breakdown-list li { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3); border-radius: var(--r-md); border: 1px solid var(--border); }
.breakdown-list li > div { display: grid; gap: 2px; min-width: 0; }
.bd-mark { width: 24px; height: 24px; border-radius: var(--r-full); display: grid; place-items: center; flex: none; }
.breakdown-list li.is-right .bd-mark { background: var(--success-soft); color: var(--success); }
.breakdown-list li.is-wrong .bd-mark { background: var(--danger-soft); color: var(--danger); }
div.stat-chip { cursor: default; }
@media (max-width: 900px) {
  .grade-layout { grid-template-columns: minmax(0, 1fr); }
  .grade-students { position: static; max-height: 260px; }
}
@media (max-width: 720px) {
  .results-table td.num[data-label] { display: flex; justify-content: flex-end; align-items: baseline; gap: 2px; }
  .results-table td.num[data-label]::before { content: attr(data-label); color: var(--text-3); font-size: var(--fs-sm); margin-right: auto; }
  /* text cells that need their label on phones (opt in with .labelled) */
  .results-table td.labelled[data-label]::before { content: attr(data-label) ": "; color: var(--text-3); font-size: var(--fs-sm); }
}

/* ---------------------------------------------------------------------------
   Results (Phase 7a)
   --------------------------------------------------------------------------- */
.subject-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--s-2); }
.subject-chip { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); border: 1px solid var(--border); border-radius: var(--r-lg); color: var(--text); text-decoration: none; }
.subject-chip:hover { border-color: var(--brand-border); background: var(--brand-softer); }
.subject-chip .grow { flex: 1; min-width: 0; display: grid; }
.subject-chip small { color: var(--text-3); font-size: var(--fs-xs); }
.score-grid td.score-cell { position: relative; }
.score-input { width: 72px; text-align: right; padding-left: 6px; padding-right: 8px; font-variant-numeric: tabular-nums; }
.score-input.is-invalid { border-color: var(--danger); box-shadow: var(--ring-danger); }
.exam-flag { position: absolute; top: 2px; right: 4px; font-size: 9px; padding: 0 4px; }
.exam-flag::before { display: none; }
.rating-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.rating-list li { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.rating-list .grow { flex: 1; min-width: 160px; }
.rating-buttons { display: inline-flex; gap: 4px; }
.rating-buttons button { min-width: 38px; height: 36px; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); font: inherit; font-weight: 700; cursor: pointer; color: var(--text-2); }
.rating-buttons button:hover:not(:disabled) { border-color: var(--brand-border); }
.rating-buttons button:disabled { cursor: not-allowed; opacity: .7; }
.suggestions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip { border: 1px dashed var(--border-strong); background: var(--surface-2); border-radius: var(--r-full); padding: 3px 10px; font: inherit; font-size: var(--fs-xs); color: var(--text-2); cursor: pointer; text-align: left; }
.chip:hover { border-style: solid; border-color: var(--brand-border); color: var(--brand-text); }
textarea.is-saved { border-color: var(--success); transition: border-color .3s; }
.chip-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip-list li { display: inline-flex; align-items: center; gap: 2px; padding: 2px 4px 2px 12px; border: 1px solid var(--border); border-radius: var(--r-full); background: var(--surface); }
.chip-list li:last-child { border: 0; padding: 0; background: none; }
.template-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.template-list li { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border: 1px solid var(--border); border-radius: var(--r-md); flex-wrap: wrap; }
.template-list .grow { flex: 1; min-width: 200px; display: grid; gap: 2px; }
.bands-table .input { padding-top: 6px; padding-bottom: 6px; }
.card.is-off { opacity: .6; }
.broadsheet td small.grade { display: block; font-size: var(--fs-xs); color: var(--text-3); font-weight: 600; }
.broadsheet td.has-blank { background: var(--warning-soft); }
.broadsheet tfoot td { border-top: 2px solid var(--border); }
.plain-list { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; }
.blanks-box summary { cursor: pointer; }
@media (max-width: 640px) {
  .score-grid th, .score-grid td { padding-left: 4px; padding-right: 4px; }
  .score-grid th:first-child, .score-grid td:first-child { padding-left: var(--s-3); }
  .score-grid .cell-sub { display: none; }
  .score-grid .cell-main { font-size: var(--fs-sm); }
  .score-input { width: 52px; padding-left: 4px; padding-right: 6px; }
  .score-grid th small { display: none; }
}

/* ---------------------------------------------------------------------------
   Report cards (Phase 7b): printed A4 portrait, one .rc per page
   --------------------------------------------------------------------------- */
.rc-sheets { padding: var(--s-6) var(--s-4); display: grid; gap: var(--s-6); justify-items: center; }
.rc-notice { max-width: 820px; margin: var(--s-4) auto 0; padding: 10px 14px; border-radius: var(--r-md, 8px); background: var(--warning-soft); border: 1px solid var(--warning-border); color: var(--warning); font-size: var(--fs-sm); }
.rc { position: relative; overflow: hidden; width: 100%; max-width: 820px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 32px 36px; color: var(--text); font-size: 13px; line-height: 1.45; }
.rc-draft { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.rc-draft span { transform: rotate(-24deg); font-size: 110px; font-weight: 800; letter-spacing: .12em; color: var(--watermark); }
.rc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 14px; border-bottom: 3px solid var(--brand); }
.rc-school { display: flex; gap: 14px; align-items: center; min-width: 0; }
.rc-school img, .rc-school .brand-logo { width: 60px; height: 60px; flex: none; object-fit: contain; border-radius: 10px; font-size: 20px; }
.rc-school-name { font-size: 20px; font-weight: 750; color: var(--brand-text); line-height: 1.2; }
.rc-sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.rc-motto { font-style: italic; color: var(--text-2); font-size: 12px; margin-top: 2px; }
.rc-title { text-align: right; flex: none; }
.rc-title-main { font-size: 18px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.rc-note { margin: 10px 0 0; color: var(--text-2); font-size: 12px; }
.rc-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 16px; margin: 16px 0; padding: 12px 14px; background: var(--brand-softer); border-radius: 10px; }
.rc-facts dt { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.rc-facts dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.rc-table-wrap { overflow-x: auto; }
.rc-table { width: 100%; border-collapse: collapse; }
.rc-table th, .rc-table td { border: 1px solid var(--border-strong, #cbd5e1); padding: 5px 6px; text-align: left; vertical-align: top; }
.rc-table th { background: var(--surface-2, #f1f5f9); font-size: 11px; font-weight: 650; line-height: 1.2; }
.rc-table th small { display: block; font-weight: 400; color: var(--text-3); }
.rc-table .num { text-align: center; font-variant-numeric: tabular-nums; }
.rc-subject { font-weight: 600; }
.rc-summary { display: flex; flex-wrap: wrap; gap: 8px 28px; justify-content: flex-end; margin-top: 8px; font-size: 14px; }
.rc-ratings { margin-top: 18px; }
.rc h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; margin: 0 0 8px; color: var(--brand-text); }
.rc-domains { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.rc-domain td:last-child { width: 64px; }
.rc-remark { font-size: 12px; color: var(--text-2); }
.rc-key { margin: 6px 0 0; font-size: 11.5px; color: var(--text-2); }
.rc-comments { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.rc-comment { border: 1px solid var(--border-strong, #cbd5e1); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; min-height: 110px; }
.rc-comment-label { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
.rc-comment p { margin: 4px 0 8px; flex: 1; }
.rc-sign { border-top: 1px dotted var(--text-3); padding-top: 2px; font-size: 10.5px; color: var(--text-3); width: 55%; }
.rc-foot { margin-top: 16px; font-size: 11px; color: var(--text-3); line-height: 1.6; }
@media (max-width: 640px) {
  .rc-sheets { padding: var(--s-3) 0; }
  .rc { padding: 18px 16px; border-radius: 0; border-left: 0; border-right: 0; }
  .rc-head { flex-direction: column; gap: 10px; }
  .rc-title { text-align: left; }
  .rc-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rc-domains, .rc-comments { grid-template-columns: 1fr; }
}
@media print {
  @page { size: A4 portrait; margin: 10mm; }
  .rc-sheets { padding: 0; display: block; }
  .rc-notice { display: none; }
  .rc { max-width: none; border: 0; border-radius: 0; padding: 0; font-size: 11.5px; break-after: page; page-break-after: always; }
  .rc:last-child { break-after: auto; page-break-after: auto; }
  .rc-facts, .rc-table th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rc-table tr, .rc-comment, .rc-domain { break-inside: avoid; }
}
.report-icon { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: var(--r-md); background: var(--brand-softer); color: var(--brand-text); }
@media (max-width: 640px) {
  .list-row:has(.report-icon) { flex-wrap: wrap; }
  .list-row:has(.report-icon) .grow { flex-basis: calc(100% - 48px); }
  .list-row:has(.report-icon) > div:last-child { margin-left: 48px; }
}

/* ---------------------------------------------------------------------------
   School context (admins with several schools, platform staff inside a school)
   --------------------------------------------------------------------------- */
.school-strip { position: sticky; top: var(--topbar-h); z-index: 29; display: flex; align-items: center; gap: var(--s-2); padding: 8px var(--s-8); background: var(--brand-soft); border-bottom: 1px solid var(--brand-border); color: var(--text); font-size: var(--fs-sm); }
.school-strip .icon { color: var(--brand-text); }
.school-strip strong { font-weight: 700; color: var(--brand-text); }
.school-strip span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.school-notice { position: relative; padding-right: 48px; margin-bottom: var(--s-6); }
.school-notice .icon-btn { position: absolute; top: 6px; right: 6px; }
.context-school { display: flex; align-items: center; gap: 6px; margin-top: var(--s-2); padding: 6px 10px; border-radius: var(--r-md); background: var(--brand-softer); color: var(--brand-text); font-size: var(--fs-sm); }
.context-school .icon { width: 16px; height: 16px; flex: none; }
@media (max-width: 1024px) { .school-strip { padding: 6px var(--s-4); } }

/* ---------------------------------------------------------------------------
   Product tour (ucx-tour.js)
   --------------------------------------------------------------------------- */
.tour { position: fixed; inset: 0; z-index: 1000; }
.tour-shade { position: absolute; inset: 0; background: transparent; }
.tour-shade.is-dim { background: var(--overlay-strong); }
.tour-spot { position: fixed; border-radius: 10px; box-shadow: 0 0 0 9999px var(--overlay-strong), 0 0 0 3px var(--brand); pointer-events: none; transition: top .2s, left .2s, width .2s, height .2s; }
.tour-pop { position: fixed; width: min(360px, calc(100vw - 24px)); background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); padding: var(--s-5); outline: none; transition: top .2s, left .2s; }
.tour-pop--center { top: 50% !important; left: 50% !important; transform: translate(-50%, -50%); }
.tour-pop h2 { font-size: var(--fs-lg); margin: var(--s-2) 0 var(--s-2); }
.tour-pop p { color: var(--text-2); margin: 0; line-height: 1.55; }
.tour-hint { margin-top: var(--s-3) !important; padding: 8px 10px; border-radius: var(--r-md); background: var(--brand-softer); color: var(--brand-text) !important; font-size: var(--fs-sm); }
.tour-meta { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); font-size: var(--fs-xs); color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.tour-actions { display: flex; align-items: center; gap: var(--s-2); margin-top: var(--s-5); }
.tour-actions .grow { flex: 1; }
.tour-pop--sheet { top: auto !important; left: 0 !important; right: 0; bottom: 0; width: auto; transform: none; border-radius: var(--r-lg) var(--r-lg) 0 0; padding-bottom: calc(var(--s-5) + env(safe-area-inset-bottom, 0px)); }
@media (prefers-reduced-motion: reduce) { .tour-spot, .tour-pop { transition: none; } }

/* ---------------------------------------------------------------------------
   Error pages (page_error(): in the app shell, or standalone before sign-in)
   --------------------------------------------------------------------------- */
.error-card { max-width: 560px; margin: var(--s-10, 40px) auto; padding: var(--s-8); text-align: center; display: grid; justify-items: center; gap: var(--s-2); }
.error-card h1 { font-size: var(--fs-2xl, 1.5rem); margin: 0; }
.error-card p { color: var(--text-2); margin: 0 0 var(--s-2); max-width: 42ch; line-height: 1.55; }
.error-code { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.error-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; justify-content: center; margin-top: var(--s-2); }
.page-error-standalone { background: var(--bg); min-height: 100vh; }

/* The public legal pages (privacy.php, terms.php; 2026-10-22) and the Privacy · Terms line under the sign-in card */
.page-legal { background: var(--bg); min-height: 100vh; }
.legal { max-width: 820px; margin: 0 auto; padding: var(--s-6) var(--s-4) var(--s-8); }
.legal-brand { display: flex; align-items: center; gap: var(--s-2); font-weight: 700; font-size: var(--fs-lg); }
.legal-nav { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s-2) var(--s-4); margin: var(--s-4) 0; font-size: var(--fs-sm); }
.legal-nav a { display: inline-flex; align-items: center; gap: 4px; }
.legal-text { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-6); line-height: 1.6; overflow-wrap: anywhere; }
.legal-text h1 { font-size: var(--fs-2xl); margin: 0 0 var(--s-1); }
.legal-text h2 { font-size: var(--fs-lg); margin: var(--s-8) 0 var(--s-2); }
.legal-text p, .legal-text ul { margin: var(--s-3) 0; }
.legal-text ul { padding-left: var(--s-6); }
.legal-text li { margin: var(--s-1) 0; }
.legal-text .table-wrap { margin: var(--s-3) 0; }
.legal-text .table td, .legal-text .table th { vertical-align: top; overflow-wrap: normal; }
.legal-text code { font-size: 0.92em; padding: 1px 5px; border-radius: 4px; background: var(--n-100); }
.legal-updated { color: var(--text-3); font-size: var(--fs-sm); margin-top: 0; }
.accept-terms { display: flex; align-items: flex-start; font-weight: 400; }   /* the sign-up tick box: its sentence wraps on narrow phones */
.accept-terms input { margin-top: 3px; flex: none; }
.accept-terms span { min-width: 0; }
.legal-links { margin-top: var(--s-6); text-align: center; font-size: var(--fs-sm); color: var(--text-3); }
@media (max-width: 640px) { .legal-text { padding: var(--s-4); } .legal-text .table th, .legal-text .table td { padding: var(--s-2); } }
.error-standalone { padding: var(--s-8) var(--s-4); max-width: 640px; margin: 0 auto; }
.error-brand { display: flex; align-items: center; gap: var(--s-2); font-weight: 700; font-size: var(--fs-lg); justify-content: center; }
@media (max-width: 640px) { .error-card { margin: var(--s-6) auto; padding: var(--s-6) var(--s-4); } }

/* Referral share link (Phase 9a) */
.share-link { display: inline-block; max-width: 100%; overflow-wrap: anywhere; padding: 6px 10px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); font-size: var(--fs-sm); }

/* Referral terms (Phase 9b): the gate that can't be dismissed, and terms text wherever it's shown */
.terms-gate { margin: auto; width: min(760px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); padding: 0; border: 0; border-radius: var(--r-xl); background: var(--surface); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; }
.terms-gate:not([open]) { display: none; }
.terms-gate::backdrop { background: var(--overlay-max); }
.terms-gate-head { padding: var(--s-6) var(--s-6) var(--s-3); border-bottom: 1px solid var(--border); }
.terms-gate-head h1 { font-size: var(--fs-xl); margin-top: var(--s-1); }
.terms-gate-head p { margin-top: var(--s-2); }
.terms-gate-changes { padding: var(--s-3) var(--s-6) 0; }
.terms-gate-body { flex: 1 1 auto; min-height: 120px; overflow-y: auto; padding: var(--s-4) var(--s-6); }
.terms-gate-body:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--ring); }
.terms-gate-foot { display: grid; gap: var(--s-3); padding: var(--s-4) var(--s-6) var(--s-6); border-top: 1px solid var(--border); background: var(--surface-2, var(--bg)); }
.terms-gate-agree { align-items: flex-start; font-weight: 500; }
.terms-gate-agree input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--brand); flex: none; }
.terms-gate-actions { display: flex; justify-content: flex-end; gap: var(--s-2); flex-wrap: wrap; }
@media (max-width: 640px) {
  .terms-gate { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .terms-gate-head, .terms-gate-body, .terms-gate-foot { padding-left: var(--s-4); padding-right: var(--s-4); }
  .terms-gate-changes { padding-left: var(--s-4); padding-right: var(--s-4); }
  .terms-gate-foot { padding-bottom: calc(var(--s-4) + env(safe-area-inset-bottom, 0px)); }
  .terms-gate-actions { flex-direction: column-reverse; }
  .terms-gate-actions .btn { width: 100%; }
}
.terms-text { line-height: 1.6; color: var(--text-2); }
/* 9c: the terms in the bank step, opened on demand, and a tick box whose label wraps. */
.terms-box { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); padding: var(--s-3) var(--s-4); }
.terms-box summary { cursor: pointer; font-weight: 600; color: var(--brand-text); }
.terms-box .terms-text { max-height: 22rem; overflow: auto; padding-right: var(--s-2); }
.check--wrap { align-items: flex-start; }
.check--wrap input { margin-top: 3px; flex: none; }
.referrer-entry { margin-top: var(--s-6); padding-top: var(--s-4); border-top: 1px solid var(--border); }
.nowrap { white-space: nowrap; }
.switch-strip .btn { margin-left: auto; }
.earn-steps { margin: 0 0 var(--s-5); padding-left: 1.2rem; display: grid; gap: var(--s-2); }
.form-stack { display: grid; gap: var(--s-4); }
.form-stack > .btn { justify-self: start; }
/* Development-only technical reason under an error message (never sent in production) */
.dev-reason { margin-top: var(--s-2); padding-top: var(--s-2); border-top: 1px dashed currentColor; font-size: var(--fs-xs); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }

/* Searchable picker (bank list): an input with a scrolling list under it; options are big enough to tap */
.combo-box { position: relative; }
.combo-list { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: var(--s-1) 0; list-style: none;
  max-height: min(50vh, 20rem); overflow-y: auto; background: var(--surface); border: 1px solid var(--control-border); border-radius: var(--r-md); box-shadow: var(--shadow-pop); }
.combo-list [role=option] { padding: 10px var(--s-3); min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--text); }
.combo-list [role=option]:hover, .combo-list [role=option].is-active { background: var(--brand-soft); }
.combo-list [role=option][aria-selected=true] { font-weight: 600; color: var(--brand-text); }
.combo-empty { padding: 10px var(--s-3); color: var(--text-2); font-size: var(--fs-sm); }

/* Marking guide (markers only): above the answers on phones, beside them on wide screens */
.mark-with-guide { display: grid; gap: var(--s-3); }
.guide-box { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); padding: var(--s-3) var(--s-4); }
.guide-box summary { cursor: pointer; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: var(--s-2); }
.guide-box .icon { color: var(--brand-text); }
.guide-text { white-space: pre-wrap; margin-top: var(--s-2); font-size: var(--fs-sm); color: var(--text-2); max-height: 26rem; overflow: auto; }
@media (min-width: 960px) {
  .mark-with-guide { grid-template-columns: minmax(0, 1fr) minmax(240px, 36%); align-items: start; }
  .mark-with-guide > .guide-box { order: 2; position: sticky; top: calc(var(--topbar-h) + var(--s-4)); }
}
.terms-text h3 { font-size: var(--fs-md, 16px); color: var(--text); margin: var(--s-5) 0 var(--s-2); }
.terms-text h3:first-child { margin-top: 0; }
.terms-text p { margin: 0 0 var(--s-3); }
.terms-text ul { margin: 0 0 var(--s-3); padding-left: 1.25em; }
.terms-text li { margin: var(--s-1) 0; }
.terms-editor { width: 100%; min-height: 420px; font-family: var(--font-mono, ui-monospace, monospace); font-size: 13px; line-height: 1.55; }
.agreement-meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px var(--s-4); margin-top: var(--s-6); padding: var(--s-4); border: 1px solid var(--border); border-radius: var(--r-md); font-size: 14px; }
.agreement-meta dt { color: var(--text-3); }
.agreement-meta dd { margin: 0; word-break: break-word; }
@media (max-width: 640px) { .agreement-meta { grid-template-columns: 1fr; } .agreement-meta dd { margin-bottom: var(--s-2); } }

/* A button that reads as a link (audit log: click a person, school or record to filter by it) */
.link-btn { appearance: none; background: none; border: 0; padding: 0; margin: 0; font: inherit; color: var(--brand-text, var(--brand)); cursor: pointer; text-align: left; }
.link-btn:hover { text-decoration: underline; }
.link-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); border-radius: 4px; }
/* A table column that should keep a readable width (the table scrolls inside its card instead of squeezing it) */
@media (min-width: 721px) { .col-wide { min-width: 13rem; } }
/* Grid items may shrink below their content (long words wrap) instead of widening the grid past its container
   (found in the platform school drawer on phones; the same fix as .stack above). */
.grid > * { min-width: 0; }
.drawer-content > * { min-width: 0; }   /* the drawer body is a grid: same reason */

/* A school's own sign-in page (auth/login.php?school=CODE, where its installed app opens) */
.auth-school { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
.auth-school img { width: 56px; height: 56px; border-radius: 12px; background: var(--image-bg); flex: none; }
.auth-school div { display: grid; min-width: 0; }
.auth-school strong { font-size: var(--fs-lg); overflow-wrap: anywhere; }
.auth-school small { color: var(--text-3); }
.ios-steps { margin: var(--s-3) 0 0; padding-left: 1.3em; display: grid; gap: var(--s-2); }
.ios-steps strong { display: inline; }

/* The exam camera (032) */
.camera-readonly { display: flex; gap: var(--s-2); align-items: flex-start; margin: 0; color: var(--text-2); font-size: var(--fs-sm); }
.camera-choices { display: grid; gap: var(--s-2); }
.camera-choice { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3); border: 1px solid var(--border); border-radius: var(--r-md); cursor: pointer; }
.camera-choice:has(input:checked) { border-color: var(--brand); background: var(--brand-softer); }
.camera-choice input { margin-top: 3px; accent-color: var(--brand); flex: none; }
.camera-choice span { display: grid; gap: 2px; min-width: 0; }
.camera-choice small { color: var(--text-2); }
.cam-gate { display: grid; gap: var(--s-3); }
.cam-notice ul { margin: 6px 0 0; padding-left: 1.1em; display: grid; gap: 4px; }
.cam-notice p { margin: 4px 0 0; }
.cam-preview { position: relative; width: min(100%, 320px); aspect-ratio: 4 / 3; border-radius: var(--r-md); overflow: hidden; background: var(--n-900); border: 1px solid var(--border); }
.cam-preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.cam-preview .badge { position: absolute; left: 8px; bottom: 8px; }
.cam-steps { margin: 6px 0; padding-left: 1.3em; display: grid; gap: 4px; }
.cam-steps strong, .cam-notice strong + p strong { display: inline; }
/* While writing (032 part 2): a small self-view tile in the exam bar, and a banner when the camera stops */
.cam-tile { position: relative; flex: none; width: 44px; height: 33px; border-radius: var(--r-sm); overflow: hidden; background: var(--n-900); border: 1px solid var(--border); }
.cam-tile video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.cam-tile-dot { position: absolute; right: 3px; top: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 2px var(--surface); }
.cam-tile.is-off video { opacity: .25; }
.cam-tile.is-off .cam-tile-dot { background: var(--danger); }
.cam-banner { position: sticky; top: var(--exam-bar-h, 57px); z-index: 19; padding: var(--s-3) var(--s-6); background: var(--warning-soft); border-bottom: 1px solid var(--warning-border); color: var(--warning-text); }
.cam-banner-inner { display: flex; align-items: center; gap: var(--s-3); max-width: 1100px; margin: 0 auto; }
.cam-banner-inner > .icon { flex: none; }
.cam-banner-text { display: grid; gap: 2px; flex: 1; min-width: 0; }
.cam-banner-text span { font-size: var(--fs-sm); }
.cam-banner-inner .btn { flex: none; }
.cam-banner-help { max-width: 1100px; margin: var(--s-2) auto 0; }
.cam-banner-help .cam-steps strong { display: inline; }
@media (max-width: 640px) {
  .cam-banner { padding: var(--s-2) var(--s-3); top: var(--exam-bar-h, 49px); }
  .cam-banner-inner { flex-wrap: wrap; }
  .cam-banner-inner .btn { width: 100%; }
  .cam-tile { width: 36px; height: 27px; }
}
/* Live monitoring (032 part 2): the latest picture and the pictures drawer */
.cam-thumb { display: inline-block; width: 48px; height: 36px; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--border); background: var(--n-100); padding: 0; cursor: pointer; vertical-align: middle; }
.cam-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-off { color: var(--danger-text); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--s-3); }
.photo-grid figure { margin: 0; display: grid; gap: 4px; }
.photo-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--n-100); }
.photo-grid figcaption { font-size: var(--fs-xs); color: var(--text-2); }

/* ---------------------------------------------------------------- Announcements (036) */
.ann .card-body { display: grid; gap: var(--s-3); }
.ann--pinned { border-color: var(--brand-border); }
.ann--new { box-shadow: inset 3px 0 0 var(--info); }
.ann-head { display: flex; gap: var(--s-3); align-items: flex-start; }
.ann-head .grow { min-width: 0; }
.ann-icon { flex: none; width: 36px; height: 36px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.ann-title { font-size: var(--fs-lg); line-height: 1.3; margin: 0; overflow-wrap: anywhere; }
.ann-meta { color: var(--text-2); font-size: var(--fs-sm); margin-top: 2px; overflow-wrap: anywhere; }
.ann-badges { display: flex; gap: var(--s-1); flex-wrap: wrap; justify-content: flex-end; }
.ann-badges .badge .icon { width: 12px; height: 12px; margin-right: 2px; }
.ann-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.ann-image { display: block; max-width: 100%; max-height: 420px; width: auto; height: auto; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--image-bg); }
.ann-image-pick:empty { display: none; }
.ann-image-pick .ann-image { max-height: 200px; margin-bottom: var(--s-2); }
.ann-reads { display: flex; gap: var(--s-2); align-items: center; color: var(--text-2); font-size: var(--fs-sm); }
.ann-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: var(--s-3); }
.ann-home-row { color: inherit; text-decoration: none; }
.ann-home-row:hover { text-decoration: none; background: var(--surface-2); }
.pann-school-list { max-height: 260px; overflow: auto; }
@media (max-width: 640px) {
  .ann-head { flex-wrap: wrap; }
  .ann-badges { width: 100%; justify-content: flex-start; order: 3; }
}

/* Attendance (040) */
.input--sm { height: 34px; padding: 0 var(--s-2); }
.input.is-saved { border-color: var(--success); transition: border-color .3s; }

/* ID cards (041): photo thumbnails on the ID cards page */
.idc-thumb { width: 40px; height: 48px; border-radius: var(--r-sm); object-fit: cover; flex: none; background: var(--surface-2); border: 1px solid var(--border); }
.idc-thumb--empty { display: grid; place-items: center; color: var(--text-3); }

/* Skill library (043): the class drawer's skills, grouped by heading */
.skill-group { border: 0; padding: 0; margin: 0 0 var(--s-3); min-width: 0; }
.skill-group legend { padding: 0; float: left; }
.skill-group .check-list { clear: both; margin-top: var(--s-1); max-height: none; }
.preset-level { border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-3); }

/* The exam access code (047): the code on the staff card, and the field the examiner types into on a student's device */
.exam-code { font-size: 2rem; font-weight: 700; letter-spacing: .12em; color: var(--text); white-space: nowrap; }
.exam-code-input { font-size: 1.5rem; letter-spacing: .4em; text-align: center; max-width: 16rem; }

/* Contact us (047): a small tab on the right edge of school staff pages, and the drawer's options */
.contact-tab { position: fixed; right: 0; top: 50%; transform: translateY(-50%); z-index: 40; width: 36px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: var(--r-md) 0 0 var(--r-md); background: var(--brand); color: var(--brand-ink); box-shadow: var(--shadow-md); cursor: pointer; padding: 0; }
.contact-tab:hover { filter: brightness(1.08); }
.contact-tab:focus-visible { outline: 3px solid var(--focus, var(--brand)); outline-offset: 2px; }
.contact-options { display: grid; gap: var(--s-3); }
.contact-option { display: flex; gap: var(--s-3); align-items: flex-start; width: 100%; padding: var(--s-4); min-height: 44px; text-align: left;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); color: var(--text); text-decoration: none; cursor: pointer; font: inherit; }
.contact-option:hover { border-color: var(--brand); }
.contact-option strong { display: block; }
.contact-option small { display: block; color: var(--text-2); margin-top: 2px; overflow-wrap: anywhere; }
.contact-option .icon { flex: none; margin-top: 2px; color: var(--brand); }
@media print { .contact-tab { display: none; } }

/* 049: a student not activated for the current term (results, report sheets, ID cards, fees): the lock label and its row */
.lock-badge { white-space: normal; height: auto; min-height: 22px; border-radius: var(--r-sm); padding: 2px 8px; line-height: 1.3; }
.lock-badge::before { display: none; }
.lock-badge .icon { width: 13px; height: 13px; flex: none; }
.lock-row { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
tr.is-locked .cell-main { color: var(--text-2); }
.bank-pick-all { padding: var(--s-2) var(--s-4); margin: var(--s-3) 0 var(--s-2); }   /* the bank picker's "Select all" row */

/* Bold and underline buttons above a text field (rich-text.js): "__word__" underline, "**word**" bold */
.format-bar { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; flex-wrap: wrap; }
.format-btn { min-width: 30px; height: 30px; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); font: inherit; font-size: 14px; cursor: pointer; color: var(--text); }
.format-btn:hover { background: var(--brand-softer); border-color: var(--brand-border); }
.format-hint { margin-left: 6px; font-size: var(--fs-xs, 12px); color: var(--text-3); }
.q-prompt b, .q-text b, .choice-text b, .passage b, .section-banner b, .q-options b, .q-snippet b { font-weight: 700; }
.q-prompt u, .q-text u, .choice-text u, .passage u, .section-banner u, .q-options u, .q-snippet u { text-decoration: underline; text-underline-offset: 2px; }

/* ==========================================================================
   Auth pages, friendlier look. Every page that uses auth_layout_start() gets .auth--friendly (sign-in, forgot and reset
   password, sign-up, referrer pages, invitation, e-mail confirmation ...); the sign-in page also has .auth--login for its
   role buttons and school card. Same fields and behaviour as before; only the look changes. Inter and the blue stay.
   Calm type: nothing above 700. 700 = the page heading, the brand name and the main button; 600 = role labels, the school
   name and small links; 400/500 = everything else.
   ========================================================================== */
.auth--friendly .auth-panel::after { display: none; }
.auth--friendly .auth-panel { position: sticky; top: 0; height: 100vh; align-self: start; }   /* the panel always fills the screen, so its tiles are all in view */
.auth--friendly .auth-panel-inner { z-index: 2; }
.auth--friendly .auth-logo, .auth--friendly .auth-mobile-logo { font-weight: 700; }
.auth--friendly .auth-pitch { max-width: 480px; }
.auth--friendly .auth-pitch h2 { font-size: clamp(1.75rem, 2.8vw, 2.25rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.auth-subline { margin: var(--s-3) 0 0; color: rgb(255 255 255 / .9); font-size: 1rem; font-weight: 400; line-height: 1.5; max-width: 26em; }
.auth--friendly .auth-pitch ul { margin-top: 28px; gap: var(--s-4); }
.auth--friendly .auth-pitch li { align-items: center; font-size: 0.9375rem; font-weight: 500; line-height: 1.4; }
.auth--friendly .auth-pitch li .icon { flex: none; width: 30px; height: 30px; margin: 0; padding: 6px; border-radius: 50%; background: rgb(255 255 255 / .16); }
.auth--friendly .auth-pitch li:nth-child(1) .icon { color: #fde047; }
.auth--friendly .auth-pitch li:nth-child(2) .icon { color: #4ade80; }
.auth--friendly .auth-pitch li:nth-child(3) .icon { color: #f9a8d4; }
.auth--friendly .auth-panel-foot { font-weight: 400; }

/* Floating tiles: decoration only (aria-hidden, never takes a tap), slow CSS motion */
.auth-tiles { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }
.tile { position: absolute; display: grid; place-items: center; font-weight: 700; letter-spacing: -0.01em; user-select: none;
  animation: tile-float 8s ease-in-out infinite; animation-delay: var(--d, 0s); }
@keyframes tile-float { 0%, 100% { transform: translateY(0) rotate(var(--r, 0deg)); } 50% { transform: translateY(-14px) rotate(calc(var(--r, 0deg) + 3deg)); } }
@keyframes tile-spin { to { transform: rotate(360deg); } }
.tile--abc, .tile--123, .tile--aplus, .tile--pi { width: 58px; height: 58px; border-radius: 16px; font-size: 1.1rem; box-shadow: 0 12px 26px -10px rgb(0 0 0 / .45); }
.tile--abc { background: #fde047; color: #713f12; --r: -9deg; }
.tile--123 { background: #f9a8d4; color: #831843; --r: 8deg; --d: -2s; }
.tile--aplus { background: #4ade80; color: #14532d; --r: -5deg; --d: -4s; }
.tile--pi { background: #fff; color: #1d4ed8; border-radius: 50%; font-size: 1.45rem; --r: 6deg; --d: -6s; }
.tile--star { width: 30px; height: 30px; fill: #fde047; animation: tile-spin 16s linear infinite; }
.tile--wave { width: 110px; height: 22px; fill: none; stroke: rgb(255 255 255 / .6); stroke-width: 3; stroke-linecap: round; --d: -3s; }
.tile--dot { width: 12px; height: 12px; border-radius: 50%; background: rgb(255 255 255 / .5); --d: -1s; }
.tile--dot2 { background: #f9a8d4; width: 9px; height: 9px; --d: -5s; }
.tile--dot3 { background: #4ade80; width: 14px; height: 14px; --d: -2.5s; }
.tile--dot4 { background: #fde047; width: 8px; height: 8px; --d: -4.5s; }
.auth-panel .tile--abc { top: 8%; right: 9%; }
.auth-panel .tile--pi { top: 24%; right: 31%; }
.auth-panel .tile--123 { bottom: 24%; right: 8%; }
.auth-panel .tile--aplus { bottom: 9%; right: 32%; }
.auth-panel .tile--star { top: 15%; left: 12%; }
.auth-panel .tile--wave { bottom: 13%; left: 9%; }
.auth-panel .tile--dot1 { top: 38%; right: 10%; }
.auth-panel .tile--dot2 { top: 6%; left: 40%; }
.auth-panel .tile--dot3 { bottom: 42%; right: 7%; }
.auth-panel .tile--dot4 { bottom: 6%; left: 46%; }

/* The right side */
.auth--friendly .auth-main { background: var(--surface); }
.auth--friendly .auth-card { max-width: 440px; position: relative; isolation: isolate; }
.auth-card-tiles { display: none; }          /* the phone's faded tiles behind the heading (every page but the sign-in page, which has its own .login-hero) */
.login-hero { position: relative; isolation: isolate; }
.login-hero > .auth-tiles { display: none; }
.login-hero > :not(.auth-tiles) { position: relative; z-index: 1; }
.auth--friendly .auth-card h1 { font-size: 1.875rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.auth--friendly .auth-card .lead { font-size: 0.9375rem; font-weight: 400; line-height: 1.5; margin-top: var(--s-2); }
.auth--friendly .auth-card h2 { font-weight: 700; }
.auth--friendly .field-label { font-size: 0.875rem; font-weight: 500; }
.auth--friendly .field-hint, .auth--friendly .field-error { font-weight: 400; }
.auth--friendly .auth-foot { font-weight: 400; }
.auth--friendly .auth-card a.small, .auth--friendly .auth-foot a, .auth--friendly .legal-links a { font-weight: 600; }
.auth--friendly .check { font-weight: 500; }
.auth--login .auth-school, .auth-portal { display: flex; align-items: center; border-radius: 16px; border: 2px solid var(--border); padding: var(--s-3) var(--s-4); gap: var(--s-4); background: var(--surface); }
.auth--login .auth-school img { border-radius: 50%; }
.auth-portal > div { display: grid; min-width: 0; }
.auth-portal small { color: var(--text-3); }
.auth-portal-icon { flex: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: #1e3a8a; color: #fff; }
.auth-portal-icon .icon { width: 24px; height: 24px; }
.auth--login .auth-school strong, .auth-portal strong { font-size: 0.9375rem; font-weight: 600; }
.auth--login .auth-school small, .auth-portal small { font-size: 0.8125rem; font-weight: 400; }

/* Who are you: three big icon buttons (sign-in page) */
.auth--login .role-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 0; background: none; border: 0; border-radius: 0; }
.auth--login .role-tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 92px; min-width: 0; padding: 12px 6px;
  border: 2px solid var(--border-strong); border-radius: 16px; background: var(--surface); color: var(--text-2); box-shadow: none;
  font-size: 0.8125rem; font-weight: 600; line-height: 1.2; text-align: center; white-space: normal; transition: border-color .15s, background-color .15s, transform .15s; }
.auth--login .role-tabs button .icon { width: 24px; height: 24px; color: var(--text-3); }
.auth--login .role-tabs button:hover:not([aria-selected="true"]) { border-color: var(--control-border-hover); transform: translateY(-1px); }
.auth--login .role-tabs button[aria-selected="true"] { border-color: var(--brand); background: var(--brand-softer); color: var(--text); box-shadow: none; }
.auth--login .role-tabs button[aria-selected="true"] .icon { color: var(--brand); }
.auth--login .role-tabs button:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 32%, transparent); }
.auth--friendly .segmented:not(.role-tabs) { padding: 4px; border-radius: 14px; }
.auth--friendly .segmented:not(.role-tabs) button { min-height: 44px; border-radius: 11px; font-weight: 500; }

/* Fields and buttons */
.auth--friendly .input, .auth--friendly .select { height: 52px; padding: 0 var(--s-4); border-width: 2px; border-radius: 14px; font-size: 16px; font-weight: 400; box-shadow: none; }
.auth--friendly .input-group .input { padding-right: 56px; }
.auth--friendly .input-group .input-addon { right: 6px; }
.auth--friendly .input:focus, .auth--friendly .select:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 32%, transparent); }
.auth--friendly .field.has-error .input:focus { box-shadow: var(--ring-danger); }
.auth--friendly .auth-card .btn { min-height: 44px; border-radius: 14px; font-weight: 600; }
.auth--friendly .auth-card .btn-lg { height: 56px; border-radius: 16px; font-size: 16px; font-weight: 600; gap: var(--s-2); }
.auth--friendly .auth-card .btn-primary.btn-lg { box-shadow: 0 10px 22px -8px color-mix(in srgb, var(--brand) 60%, transparent); transition: transform .15s, box-shadow .15s, background-color .15s, border-color .15s; }
.auth--friendly .auth-card .btn-primary.btn-lg:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 14px 26px -8px color-mix(in srgb, var(--brand) 65%, transparent); }
.auth--friendly .btn-signin .icon { width: 20px; height: 20px; }
.auth--friendly .auth-card .btn-google { height: 52px; border-radius: 14px; border-width: 2px; font-size: 16px; }
.auth--friendly .auth-card .btn:focus-visible, .auth--friendly .check input:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 32%, transparent); }

/* Between a phone and a desktop: keep the two panels, a little narrower */
@media (min-width: 641px) and (max-width: 860px) {
  .auth--friendly { grid-template-columns: minmax(280px, 38%) 1fr; }
  .auth--friendly .auth-panel { display: block; }
  .auth--friendly .auth-mobile-logo { display: none; }
  .auth--friendly .auth-main { justify-content: center; padding: var(--s-8) var(--s-5); }
  .auth--friendly .auth-panel-inner { padding: var(--s-8) var(--s-6); }
  .auth--friendly .auth-pitch h2 { font-size: 1.625rem; }
  .auth--friendly .tile--abc, .auth--friendly .tile--123, .auth--friendly .tile--aplus, .auth--friendly .tile--pi { width: 46px; height: 46px; font-size: .9rem; }
  .auth--friendly .tile--pi { font-size: 1.2rem; }
}

/* A phone: no blue hero, white page, the tiles faded behind the heading */
@media (max-width: 640px) {
  .auth--friendly .auth-main { padding: var(--s-5) var(--s-4) var(--s-10); }
  .auth--friendly .auth-mobile-logo { margin-bottom: var(--s-5); }
  .auth--friendly .auth-card h1 { font-size: 1.625rem; }
  .auth--login .role-tabs { gap: 8px; }
  .auth--login .role-tabs button { min-height: 84px; }
  .login-hero > .auth-tiles { display: block; inset: auto -6px -8px auto; width: 62%; height: 150px; opacity: .5; z-index: 0; }
  .auth-card-tiles { display: block; position: absolute; inset: -12px -6px auto auto; width: 62%; height: 124px; opacity: .45; z-index: -1; pointer-events: none; }
  .auth-card-tiles .tile--wave { display: none; }
  .auth-card-tiles .auth-tiles, .login-hero .auth-tiles { position: absolute; inset: 0; }
  .auth--friendly .auth-card .tile--abc, .auth--friendly .auth-card .tile--123, .auth--friendly .auth-card .tile--aplus, .auth--friendly .auth-card .tile--pi { width: 34px; height: 34px; border-radius: 10px; font-size: .7rem; box-shadow: 0 6px 14px -8px rgb(0 0 0 / .4); }
  .auth--friendly .auth-card .tile--pi { font-size: .95rem; border-radius: 50%; background: #dbeafe; color: #1d4ed8; }
  .auth-card .tile--abc { top: 6%; right: 6%; }
  .auth-card .tile--123 { top: 48%; right: 30%; }
  .auth-card .tile--aplus { top: 28%; right: 0%; }
  .auth-card .tile--pi { top: 2%; right: 40%; }
  .auth-card .tile--star { top: 58%; right: 8%; width: 22px; height: 22px; }
  .auth-card .tile--wave { top: 78%; right: 40%; width: 80px; height: 16px; stroke: #93c5fd; }
  .auth-card .tile--dot1 { top: 44%; right: 52%; background: #93c5fd; }
  .auth-card .tile--dot2 { top: 14%; right: 62%; }
  .auth-card .tile--dot3 { top: 70%; right: 24%; }
  .auth-card .tile--dot4 { top: 38%; right: 70%; }
}
@media (prefers-reduced-motion: reduce) {
  .tile { animation: none; }
  .auth--friendly .auth-card .btn-primary.btn-lg, .auth--login .role-tabs button { transition: none; }
  .auth--friendly .auth-card .btn-primary.btn-lg:hover:not(:disabled), .auth--login .role-tabs button:hover:not([aria-selected="true"]) { transform: none; }
}

/* Proposal agents (platform screen, 053) */
.pa-card { margin: 0 0 var(--s-4); }
.pa-card--off { opacity: .8; }
.pa-row { display: flex; gap: var(--s-5); align-items: flex-start; }
.pa-qr { flex: none; width: 132px; height: 132px; background: #fff; border: 1px solid var(--border); border-radius: var(--r-lg); padding: 6px; }
.pa-qr svg { display: block; width: 100%; height: 100%; }
.pa-main { min-width: 0; flex: 1; }
.pa-main h2, .pa-main h3 { margin: 0; font-size: var(--fs-lg); font-weight: 700; overflow-wrap: anywhere; }
.pa-head { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; margin-bottom: var(--s-2); }
.pa-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s-3); margin: 0 0 var(--s-3); }
.pa-facts dt { font-size: var(--fs-xs); color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.pa-facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.pa-link { margin: var(--s-2) 0 var(--s-3); }
.pa-url { display: block; padding: 6px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.pa-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.pa-list-title { font-size: var(--fs-lg); font-weight: 700; margin: var(--s-6) 0 var(--s-3); }
@media (max-width: 560px) { .pa-row { flex-direction: column; } .pa-qr { width: 120px; height: 120px; } }
.pa-cards { margin-top: var(--s-2); padding-top: var(--s-3); border-top: 1px dashed var(--border); align-items: center; }
.pa-cards-label { font-size: var(--fs-xs); color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin-right: var(--s-1); }
.pa-contacts { list-style: none; margin: 0 0 var(--s-3); padding: 0; display: grid; gap: var(--s-2); }
.pa-contact { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); padding: var(--s-3); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface-2); }
.pa-contact--off { opacity: .75; }
.pa-contact-n { flex: none; width: 28px; height: 28px; border-radius: var(--r-full); display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-text); font-weight: 700; font-size: var(--fs-sm); }
.pa-contact-main { flex: 1 1 200px; min-width: 0; }
.pa-contact-main .pa-head { margin-bottom: 0; }
.pa-contact-main p { margin: 2px 0 0; overflow-wrap: anywhere; }

/* The demo school (055): the banner on every demo screen */
.demo-banner { display: flex; align-items: center; gap: var(--s-2); justify-content: center; padding: 8px var(--s-4); background: var(--warning-soft); color: var(--warning-text); border-bottom: 1px solid var(--warning-border); font-size: var(--fs-sm); font-weight: 600; text-align: center; }
.demo-banner .icon { flex: none; }
#demo p a, #demo .pa-facts dd { overflow-wrap: anywhere; }
