/* ExamAI — one stylesheet. Light is the default; dark is chosen via [data-theme="dark"]. */
:root {
  --font: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --bg: #f4f6fb; --bg-grad-a: #e8ecff; --bg-grad-b: #e4f6f1; --bg-grad-c: #fff0e4;
  --surface: #ffffff; --surface-2: #f6f7fb; --line: #e2e6f0; --line-strong: #cdd3e3;
  --ink: #161a2b; --ink-2: #4a5170; --ink-3: #5f6683;
  --accent: #4f46e5; --accent-strong: #4038c4; --accent-soft: #eceafe; --on-accent: #ffffff;
  --ok: #0f7a4d; --ok-soft: #e0f5ea; --warn: #a15c07; --warn-soft: #fff1d6; --bad: #c0262d; --bad-soft: #fde8e8;
  --info: #1d63c9; --info-soft: #e3eefc;
  --shadow: 0 1px 2px rgba(22,26,43,.05), 0 8px 24px rgba(22,26,43,.07);
  --shadow-lg: 0 20px 60px rgba(22,26,43,.18);
  --radius: 14px; --radius-sm: 9px; --focus: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0f1220; --bg-grad-a: #171a33; --bg-grad-b: #0f2623; --bg-grad-c: #261a14;
  --surface: #181c2e; --surface-2: #1f2438; --line: #2b3150; --line-strong: #3a4266;
  --ink: #eceffa; --ink-2: #b3bad6; --ink-3: #8189a8;
  --accent: #8b86ff; --accent-strong: #a6a2ff; --accent-soft: #24244d; --on-accent: #12122b;
  --ok: #4ad394; --ok-soft: #12352a; --warn: #f2b44d; --warn-soft: #3a2c10; --bad: #ff7b80; --bad-soft: #3d1b1f;
  --info: #7db2ff; --info-soft: #172b4b;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  --shadow-lg: 0 20px 60px rgba(0,0,0,.6);
  color-scheme: dark;
}
[data-role="teacher"] { --accent: #08825f; --accent-strong: #06704f; --accent-soft: #dff5ec; --violet: #7c3aed; --violet-soft: #efe8ff; }
[data-role="admin"] { --accent: #c2410c; --accent-strong: #9f3409; --accent-soft: #ffe8da; }
[data-theme="dark"] [data-role="teacher"] { --accent: #34d399; --accent-strong: #6ee7b7; --accent-soft: #11332a; --on-accent: #06251b; --violet: #b79bff; --violet-soft: #2a2150; }
[data-theme="dark"] [data-role="admin"] { --accent: #ff9556; --accent-strong: #ffb487; --accent-soft: #3b2214; --on-accent: #2b1204; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg);
  background-image: radial-gradient(900px 500px at 8% -10%, var(--bg-grad-a), transparent 60%),
    radial-gradient(800px 480px at 100% 0%, var(--bg-grad-b), transparent 55%),
    radial-gradient(700px 500px at 50% 120%, var(--bg-grad-c), transparent 60%);
  background-attachment: fixed; min-height: 100vh;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0; }
a { color: var(--accent-strong); text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.muted { color: var(--ink-2); } .small { font-size: .85rem; } .tiny { font-size: .78rem; color: var(--ink-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; } .spread { justify-content: space-between; }
.stack { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); } .grow { flex: 1; min-width: 0; }
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; cursor: pointer;
  padding: .62rem 1.05rem; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font-weight: 600; transition: background .15s, transform .05s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; } .btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 30%, transparent); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.danger { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.btn.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: .38rem .7rem; font-size: .86rem; } .btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; box-shadow: none; }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after { content: ""; position: absolute; width: 1.1em; height: 1.1em; border-radius: 50%; border: 2px solid var(--on-accent); border-right-color: transparent; animation: spin .7s linear infinite; }
.btn:not(.primary).loading::after { border-color: var(--ink-2); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition: none !important; } }

/* ---------- forms ---------- */
.field { display: grid; gap: .35rem; }
.field > label, .label { font-weight: 600; font-size: .9rem; }
.field .hint { font-size: .8rem; color: var(--ink-3); }
.input, select.input, textarea.input {
  width: 100%; padding: .65rem .8rem; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
textarea.input { min-height: 5.5rem; resize: vertical; }
.input:hover { border-color: var(--ink-3); } .input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.field.invalid .input { border-color: var(--bad); }
.field .error { color: var(--bad); font-size: .83rem; display: none; } .field.invalid .error { display: block; }
.pw { position: relative; } .pw .input { padding-right: 2.8rem; }
.pw .toggle { position: absolute; right: .3rem; top: 50%; transform: translateY(-50%); border: 0; background: none; cursor: pointer; padding: .45rem; color: var(--ink-3); border-radius: 8px; }
.pw .toggle:hover { color: var(--ink); background: var(--surface-2); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; align-items: start; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.switch { display: flex; align-items: flex-start; gap: .8rem; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); cursor: pointer; }
.switch input { appearance: none; flex: none; width: 2.5rem; height: 1.4rem; border-radius: 99px; background: var(--line-strong); position: relative; cursor: pointer; transition: background .15s; margin: .1rem 0 0; }
.switch input::after { content: ""; position: absolute; top: .15rem; left: .15rem; width: 1.1rem; height: 1.1rem; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked { background: var(--accent); } .switch input:checked::after { transform: translateX(1.1rem); }
.switch b { display: block; font-size: .92rem; } .switch span { font-size: .82rem; color: var(--ink-2); }
.check { display: flex; gap: .6rem; align-items: center; } .check input { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }

/* ---------- cards, badges, tables ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.card.flat { box-shadow: none; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: 1rem; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .6rem; border-radius: 99px; font-size: .78rem; font-weight: 700; background: var(--surface-2); color: var(--ink-2); }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); } .badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent-strong); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .75rem .9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; color: var(--ink-3); font-weight: 700; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; } tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.avatar { width: 2.4rem; height: 2.4rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .85rem; background: var(--accent-soft); color: var(--accent-strong); flex: none; }
.avatar.sm { width: 2rem; height: 2rem; font-size: .75rem; }
.tabs { display: inline-flex; gap: .25rem; padding: .25rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; flex-wrap: wrap; }
.tab { border: 0; background: none; cursor: pointer; padding: .45rem .9rem; border-radius: 9px; font-weight: 600; color: var(--ink-2); display: inline-flex; gap: .4rem; align-items: center; }
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.tab .count { font-size: .75rem; background: var(--accent-soft); color: var(--accent-strong); border-radius: 99px; padding: 0 .45rem; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--ink-2); display: grid; gap: .5rem; justify-items: center; }
.empty .icon { width: 2.2rem; height: 2.2rem; color: var(--ink-3); }
.banner { display: flex; gap: .7rem; align-items: flex-start; padding: .8rem 1rem; border-radius: var(--radius-sm); font-size: .9rem; }
.banner.info { background: var(--info-soft); color: var(--info); } .banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); } .banner.ok { background: var(--ok-soft); color: var(--ok); }

/* ---------- stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); gap: 1rem; }
.stat { display: flex; gap: .9rem; align-items: center; padding: 1.1rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.stat .glyph { width: 2.9rem; height: 2.9rem; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--tint-bg); color: var(--tint); }
.stat .glyph .icon { width: 1.4rem; height: 1.4rem; }
.stat .num { font-size: 1.8rem; font-weight: 800; line-height: 1; } .stat .lbl { color: var(--ink-2); font-size: .85rem; margin-top: .2rem; }
.tint-amber { --tint: var(--warn); --tint-bg: var(--warn-soft); } .tint-blue { --tint: var(--info); --tint-bg: var(--info-soft); }
.tint-green { --tint: var(--ok); --tint-bg: var(--ok-soft); } .tint-accent { --tint: var(--accent-strong); --tint-bg: var(--accent-soft); }

/* ---------- toasts & modals ---------- */
.toasts { position: fixed; top: .9rem; left: 50%; transform: translateX(-50%); z-index: 200; width: min(560px, calc(100vw - 2rem)); pointer-events: none; height: calc(var(--h, 0px) + var(--n, 0) * 10px); transition: height .2s; }
.toast { position: absolute; left: 0; right: 0; top: 0; transform-origin: top center; z-index: calc(20 - var(--i, 0)); pointer-events: none; display: flex; gap: .8rem; align-items: center; padding: .95rem 1.1rem .95rem 1rem; border-radius: 14px; border: 1px solid var(--toast-line); background: var(--toast-bg); color: var(--toast-ink); box-shadow: 0 14px 30px -14px rgba(16, 24, 40, .35); animation: toast-in .25s ease backwards;
  transform: translateY(calc(var(--i, 0) * 10px)) scale(calc(1 - var(--i, 0) * .045)); opacity: calc(1 - var(--i, 0) * .16); transition: transform .25s, opacity .25s; }
.toast[style*="--i: 0"] { pointer-events: auto; }
.toasts .toast:not([style*="--i: 0"]) { height: var(--h); overflow: hidden; }
.toasts .toast:not([style*="--i: 0"]):not([style*="--i: 1"]):not([style*="--i: 2"]) { opacity: 0; }
.toasts.stacked .toast[style*="--i: 0"] { cursor: pointer; }
.toasts.expanded { height: auto; display: grid; gap: .6rem; }
.toasts.expanded .toast { position: relative; transform: none; opacity: 1; height: auto; overflow: visible; pointer-events: auto; order: calc(0 - var(--i, 0)); animation: none; }
.toast.leaving { opacity: 0 !important; transform: translateY(-8px) !important; transition: opacity .18s, transform .18s; pointer-events: none !important; }
.toast.ok   { --toast-bg: #e9f9ef; --toast-line: #c4ebd3; --toast-ink: #11663f; }
.toast.warn { --toast-bg: #fff8dd; --toast-line: #f4e3a6; --toast-ink: #a35a05; }
.toast.bad  { --toast-bg: #fdeeee; --toast-line: #f6c9c9; --toast-ink: #a8232a; }
.toast.info { --toast-bg: #eaf1fe; --toast-line: #c9dbf8; --toast-ink: #1d4fa8; }
[data-theme="dark"] .toast.ok   { --toast-bg: #12352a; --toast-line: #1f5a44; --toast-ink: #7be0b0; }
[data-theme="dark"] .toast.warn { --toast-bg: #3a2c10; --toast-line: #5e4719; --toast-ink: #f6c46a; }
[data-theme="dark"] .toast.bad  { --toast-bg: #3d1b1f; --toast-line: #64292f; --toast-ink: #ff9a9e; }
[data-theme="dark"] .toast.info { --toast-bg: #172b4b; --toast-line: #28487c; --toast-ink: #9cc3ff; }
.toast-ic { flex: none; display: grid; place-items: center; } .toast-ic svg { width: 26px; height: 26px; }
.toast-body { display: grid; gap: .1rem; min-width: 0; overflow-wrap: anywhere; } .toast-body b { font-weight: 650; } .toast-body span { font-weight: 450; }
.toast-x { position: absolute; top: -8px; left: -8px; width: 24px; height: 24px; padding: 0; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--toast-line); background: var(--surface); color: var(--toast-ink); cursor: pointer; box-shadow: 0 2px 6px rgba(22,26,43,.12); }
.toast-x svg { width: 12px; height: 12px; } .toast-x:hover { background: var(--toast-bg); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@media (max-width: 520px) { .toasts { top: .6rem; width: calc(100vw - 1.4rem); } .toast { font-size: .92rem; } .toast-x { left: -4px; top: -6px; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } .toast.leaving { transition: none; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.overlay { position: fixed; inset: 0; background: rgba(10,12,24,.55); display: grid; place-items: center; padding: 1rem; z-index: 90; overflow-y: auto; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 2rem); overflow-y: auto; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 1.4rem; display: grid; gap: 1rem; }
.modal.wide { width: min(760px, 100%); }
.modal-foot { display: flex; justify-content: flex-end; gap: .6rem; flex-wrap: wrap; }

/* ---------- landing & auth ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 1rem clamp(1rem, 4vw, 2.5rem); }
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.15rem; color: var(--ink); } .brand:hover { text-decoration: none; }
.brand .mark { width: 2.2rem; height: 2.2rem; border-radius: 11px; display: grid; place-items: center; background: linear-gradient(135deg, #4f46e5, #0f766e 60%, #ea580c); color: #fff; }
.hero { max-width: 1060px; margin: 0 auto; padding: 2rem clamp(1rem, 4vw, 2.5rem) 4rem; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); max-width: 16ch; }
.hero .lead { font-size: 1.1rem; color: var(--ink-2); max-width: 54ch; margin-top: 1rem; }
.roles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 1.2rem; margin-top: 2.2rem; }
.role-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 1.4rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .9rem; border-top: 5px solid var(--accent); }
.role-card > .stack { margin-top: auto; }
.role-card .glyph { width: 3rem; height: 3rem; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-strong); }
.role-card .glyph .icon { width: 1.5rem; height: 1.5rem; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 1rem; margin-top: 2.5rem; counter-reset: s; }
.steps li { list-style: none; background: color-mix(in srgb, var(--surface) 70%, transparent); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1rem 1rem 3.2rem; position: relative; }
.steps li::before { counter-increment: s; content: counter(s); position: absolute; left: 1rem; top: 1rem; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.steps { padding: 0; }

.auth-wrap { min-height: calc(100vh - 4.5rem); display: grid; place-items: center; padding: 1rem clamp(1rem, 4vw, 2rem) 3rem; }
.auth-card { width: min(520px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg); overflow: hidden; }
.auth-card.wide { width: min(640px, 100%); }
.auth-band { background: linear-gradient(120deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #ec4899)); color: var(--on-accent); padding: 1.4rem 1.6rem; }
.auth-band h1 { font-size: 1.5rem; } .auth-band p { opacity: .92; margin-top: .3rem; }
.auth-body { padding: 1.6rem; display: grid; gap: 1.1rem; }
.auth-foot { padding: 1rem 1.6rem; border-top: 1px solid var(--line); background: var(--surface-2); font-size: .9rem; display: flex; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.waiting { text-align: center; padding: 2.2rem 1.6rem; display: grid; gap: 1rem; justify-items: center; }
.waiting .big { width: 4.2rem; height: 4.2rem; border-radius: 50%; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); }
.waiting .big .icon { width: 2rem; height: 2rem; }
.timeline { text-align: left; display: grid; gap: .7rem; width: 100%; margin: 0; padding: 0; list-style: none; }
.timeline li { display: flex; gap: .7rem; align-items: center; padding: .7rem .9rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.timeline li.done { background: var(--ok-soft); border-color: transparent; }

/* ---------- theme popover ---------- */
.theme-wrap { position: relative; }
.popover { position: absolute; right: 0; top: calc(100% + .4rem); min-width: 190px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: .35rem; z-index: 60; }
.popover button { display: flex; width: 100%; gap: .6rem; align-items: center; border: 0; background: none; padding: .55rem .7rem; border-radius: 8px; cursor: pointer; text-align: left; }
.popover button:hover { background: var(--surface-2); } .popover button[aria-checked="true"] { color: var(--accent-strong); font-weight: 700; }
.popover .tick { margin-left: auto; }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 1.1rem .9rem; display: flex; flex-direction: column; gap: 1.2rem; position: sticky; top: 0; height: 100vh; }
.side nav { display: grid; gap: .25rem; }
.nav-link { display: flex; align-items: center; gap: .7rem; padding: .65rem .8rem; border-radius: 10px; color: var(--ink-2); font-weight: 600; }
.nav-link:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); }
.nav-link .pill { margin-left: auto; background: var(--accent); color: var(--on-accent); font-size: .72rem; border-radius: 99px; padding: 0 .5rem; }
.side .me { margin-top: auto; display: flex; gap: .6rem; align-items: center; padding: .6rem; border: 1px solid var(--line); border-radius: 12px; }
.main { padding: 1.4rem clamp(1rem, 3vw, 2.2rem) 3rem; min-width: 0; }
.main-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.menu-btn { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; z-index: 80; transform: translateX(-102%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .side.open { transform: none; } .menu-btn { display: inline-flex; }
}
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.2rem; align-items: start; }
@media (max-width: 980px) { .two-col { grid-template-columns: 1fr; } }
.two-col > * { min-width: 0; }
.list { display: grid; gap: .6rem; margin: 0; padding: 0; list-style: none; }
.list li { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.toolbar { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.search { position: relative; flex: 1; min-width: min(200px, 100%); } .search .icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.search .input { padding-left: 2.4rem; }
.test-card { display: grid; gap: .6rem; padding: 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); border-left: 5px solid var(--accent); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 1rem; }
.meta { display: flex; gap: .9rem; flex-wrap: wrap; color: var(--ink-2); font-size: .85rem; } .meta span { display: inline-flex; gap: .3rem; align-items: center; }
.stepper { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; margin-bottom: 1.2rem; }
.stepper button { display: flex; gap: .6rem; align-items: center; padding: .7rem .8rem; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; text-align: left; }
.stepper .n { width: 1.7rem; height: 1.7rem; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: .82rem; flex: none; }
.stepper button[aria-current="step"] { border-color: var(--accent); background: var(--accent-soft); } .stepper button[aria-current="step"] .n { background: var(--accent); color: var(--on-accent); }
.stepper button.done .n { background: var(--ok-soft); color: var(--ok); }
@media (max-width: 720px) { .stepper { grid-template-columns: 1fr 1fr; } }
.q-item { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .9rem 1rem; display: grid; gap: .5rem; background: var(--surface); }
.q-item .opt { display: flex; gap: .5rem; align-items: center; font-size: .9rem; color: var(--ink-2); } .q-item .opt.right { color: var(--ok); font-weight: 600; }
.option-row { display: grid; grid-template-columns: auto 1fr auto; gap: .6rem; align-items: center; }
.page-loading { display: grid; place-items: center; min-height: 40vh; color: var(--ink-3); }
.spinner { width: 1.8rem; height: 1.8rem; border-radius: 50%; border: 3px solid var(--line-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.notfound { min-height: 80vh; display: grid; place-items: center; text-align: center; gap: 1rem; align-content: center; }

/* =====================================================================================================
   Teacher segment. Everything below only affects pages under /teacher (body[data-role="teacher"]) or
   uses class names that only the teacher views create.
   ===================================================================================================== */
[data-role="teacher"] .avatar, [data-role="student"] .avatar { background: var(--accent); color: var(--on-accent); }
[data-role="teacher"] .nav-link, [data-role="student"] .nav-link { position: relative; transition: background .15s, color .15s; }
.sections { gap: 0 !important; }
.nav-section { display: grid; gap: .25rem; } .nav-section + .nav-section { margin-top: 1.2rem; }
.nav-heading { font-size: .72rem; letter-spacing: .09em; text-transform: uppercase; font-weight: 700; color: var(--ink-3); padding: 0 .8rem .3rem; }
[data-role="teacher"] .nav-link[aria-current="page"]::before, [data-role="student"] .nav-link[aria-current="page"]::before { content: ""; position: absolute; left: -.9rem; top: 18%; bottom: 18%; width: 4px; border-radius: 0 4px 4px 0; background: var(--accent); }
.portal-brand .mark { background: var(--accent); border-radius: 50%; width: 2.4rem; height: 2.4rem; }
.portal-brand em { font-style: normal; color: var(--accent); }
.portal-card { margin-top: auto; padding: .9rem 1rem; border-radius: 14px; border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line)); background: linear-gradient(160deg, var(--accent-soft), var(--surface)); display: grid; gap: .15rem; font-size: .82rem; color: var(--ink-2); }
.portal-card b { color: var(--ink); font-size: .92rem; }
.portal-main .main-top { margin-bottom: 1.2rem; padding-bottom: .9rem; border-bottom: 1px solid var(--line); }
.top-actions { margin-left: auto; gap: .4rem; flex-wrap: nowrap; }
.btn.icon-only { padding: .5rem; border-color: transparent; background: transparent; } .btn.icon-only:hover { background: var(--surface-2); }
.profile-chip { display: flex; gap: .6rem; align-items: center; border: 0; background: transparent; cursor: pointer; padding: .25rem .5rem; border-radius: 12px; transition: background .15s; }
.profile-chip:hover { background: var(--surface-2); }
.profile-chip .who { display: grid; text-align: left; line-height: 1.2; } .profile-chip .who b { font-size: .88rem; } .profile-chip .who small { font-size: .72rem; color: var(--ink-3); }
@media (max-width: 560px) { .profile-chip .who { display: none; } }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.3rem; }
.page-head h1 { font-size: 1.95rem; font-weight: 700; } .page-head p { color: var(--ink-2); margin-top: .25rem; }
.eyebrow { font-size: .74rem; letter-spacing: .09em; text-transform: uppercase; font-weight: 700; color: var(--accent); }
.btn.lg { padding: .8rem 1.2rem; font-size: 1rem; }
.btn.primary .icon, .btn .icon { width: 1.1em; height: 1.1em; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.1rem; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } } @media (max-width: 520px) { .kpis { grid-template-columns: 1fr; } }
.kpi { display: grid; grid-template-columns: 1fr auto; gap: .1rem .8rem; padding: 1.1rem 1.2rem; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); transition: box-shadow .15s, transform .15s; }
.kpi:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.kpi .k-label { color: var(--ink-2); } .kpi .glyph { grid-row: 1 / span 2; grid-column: 2; width: 2.7rem; height: 2.7rem; border-radius: 13px; display: grid; place-items: center; background: var(--tint-bg); color: var(--tint); }
.kpi .k-num { font-size: 2rem; font-weight: 700; line-height: 1.15; } .kpi .k-sub { grid-column: 1 / -1; font-size: .78rem; color: var(--ink-3); margin-top: .35rem; }
.tint-violet { --tint: var(--violet); --tint-bg: var(--violet-soft); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 1.1rem; align-items: start; }
@media (max-width: 980px) { .dash-grid { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 1.2rem 1.3rem; }
.panel > h2, .panel .p-head h2 { font-size: 1.1rem; font-weight: 600; } .panel .sub { color: var(--ink-2); font-size: .88rem; margin-top: .15rem; }
.p-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .8rem; margin-bottom: 1rem; flex-wrap: wrap; }
.chip-live { display: inline-flex; gap: .35rem; align-items: center; background: var(--info-soft); color: var(--info); border-radius: 99px; padding: .15rem .65rem; font-size: .75rem; font-weight: 600; }
.empty-tile { display: grid; justify-items: center; text-align: center; gap: .45rem; padding: 2.6rem 1rem; border: 1px solid var(--line); border-radius: 18px; color: var(--ink-2); }
.empty-tile.dashed { border: 1.5px dashed var(--line-strong); } .empty-tile.plain { border: 0; }
.empty-tile .tile { width: 3.4rem; height: 3.4rem; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); box-shadow: 0 0 28px color-mix(in srgb, var(--accent) 22%, transparent); margin-bottom: .3rem; }
.empty-tile .tile .icon { width: 1.5rem; height: 1.5rem; } .empty-tile b { color: var(--ink); font-size: 1rem; } .empty-tile p { font-size: .88rem; max-width: 34ch; }
.empty-tile .row { justify-content: center; margin-top: .5rem; }
.open-item { display: grid; gap: .55rem; border: 1px solid var(--line); border-radius: 13px; padding: .75rem .9rem; transition: border-color .15s, background .15s; color: var(--ink); }
.open-item:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); background: var(--surface-2); text-decoration: none; }
.open-item .t { display: flex; justify-content: space-between; gap: .6rem; font-weight: 600; font-size: .9rem; } .open-item .t span:last-child { color: var(--accent); font-size: .82rem; white-space: nowrap; }
.bar { height: 6px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .3s; }
.rows { display: grid; gap: .7rem; }
.sub-row { display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding: .6rem .8rem; border-radius: 12px; border: 1px solid var(--line); font-size: .9rem; }

.tests-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.search.narrow { flex: 0 1 300px; min-width: min(200px, 100%); } .search.wide { flex: 0 1 430px; }
.tgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr)); gap: 1rem; }
.tcard { position: relative; display: grid; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; transition: box-shadow .15s, transform .15s, border-color .15s; }
.tcard:hover { box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); transform: translateY(-2px); }
.tcard-body { padding: 1.05rem 1.2rem 1rem; display: grid; gap: .5rem; }
.tcard .top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.tcard-title { font-size: 1.12rem; font-weight: 600; color: var(--ink); transition: color .15s; word-break: break-word; }
.tcard-title:hover { text-decoration: none; } .tcard:hover .tcard-title { color: var(--accent); }
.tcard-title::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.tcard .topic { color: var(--ink-2); font-size: .88rem; }
.tcard .meta { font-size: .8rem; margin-top: .1rem; }
.tcard .submitted { display: flex; justify-content: space-between; font-size: .8rem; color: var(--ink-2); margin-top: .35rem; } .tcard .submitted span:first-child { display: inline-flex; gap: .3rem; align-items: center; }
.tcard .foot { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .7rem 1.2rem; border-top: 1px solid var(--line); font-size: .82rem; color: var(--ink-2); }
.link-results { position: relative; z-index: 1; display: inline-flex; gap: .35rem; align-items: center; font-weight: 600; color: var(--ink); } .link-results:hover { color: var(--accent); text-decoration: none; }
.pill-status { display: inline-flex; align-items: center; gap: .35rem; padding: .14rem .6rem; border-radius: 99px; font-size: .74rem; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.pill-status::before { content: ""; width: .42rem; height: .42rem; border-radius: 50%; background: currentColor; }
.pill-status.published { background: var(--ok-soft); color: var(--ok); } .pill-status.closed { background: var(--warn-soft); color: var(--warn); }

.filters { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; }
.filters select.input { width: auto; min-width: 9.5rem; padding: .55rem .8rem; }
.scards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr)); gap: .9rem; }
.scard { display: flex; gap: .8rem; align-items: center; border: 1px solid var(--line); border-radius: 14px; padding: .9rem 1rem; background: var(--surface); transition: box-shadow .15s, border-color .15s; min-width: 0; }
.scard:hover { box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.scard .avatar, .srow .avatar { width: 2.6rem; height: 2.6rem; } .scard .t { min-width: 0; } .scard b { display: block; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tb-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.tb-head h1 { font-size: 1.95rem; font-weight: 700; word-break: break-word; } .tb-head .meta-line { color: var(--ink-2); font-size: .9rem; margin-top: .2rem; }
.tb-head .eyebrow { display: flex; gap: .5rem; align-items: center; }
.tb-actions { display: flex; gap: .5rem; align-items: center; }
[data-role="teacher"] .stepper { gap: .7rem; margin-bottom: 1rem; }
[data-role="teacher"] .stepper button { border-radius: 14px; padding: .7rem .9rem; transition: border-color .15s, background .15s; }
[data-role="teacher"] .stepper button:hover:not(:disabled) { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
[data-role="teacher"] .stepper button:disabled { opacity: .55; cursor: not-allowed; }
[data-role="teacher"] .stepper button.done .n { background: var(--accent); color: var(--on-accent); }
.subtabs { margin-bottom: 1.1rem; }
.details-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 1.2rem; align-items: start; }
@media (max-width: 980px) { .details-grid { grid-template-columns: 1fr; } }
.details-grid .panel .sub { margin-bottom: 1rem; } .form-stack { display: grid; gap: 1rem; }
.rule { display: flex; gap: .8rem; align-items: center; border: 1px solid var(--line); border-radius: 14px; padding: .8rem .9rem; transition: border-color .15s, background .15s; cursor: pointer; }
.rule:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); background: var(--surface-2); }
.rule .rglyph { width: 2.2rem; height: 2.2rem; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.rule .rtext { flex: 1; min-width: 0; } .rule .rtext b { display: block; font-size: .92rem; } .rule .rtext span { font-size: .8rem; color: var(--ink-2); }
.tgl { appearance: none; -webkit-appearance: none; flex: none; width: 2.6rem; height: 1.5rem; border-radius: 99px; background: var(--line-strong); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.tgl::after { content: ""; position: absolute; top: .17rem; left: .17rem; width: 1.16rem; height: 1.16rem; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.tgl:checked { background: var(--accent); } .tgl:checked::after { transform: translateX(1.1rem); } .tgl:disabled { opacity: .5; cursor: not-allowed; } .tgl:focus-visible { box-shadow: var(--focus); }
.fine { display: flex; gap: .4rem; justify-content: center; align-items: center; color: var(--ink-3); font-size: .8rem; text-align: center; }
.step-nav { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; margin-top: 1.2rem; }

.q-layout { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 1.1rem; align-items: start; }
@media (max-width: 900px) { .q-layout { grid-template-columns: 1fr; } .q-aside { order: -1; } }
.q-aside { display: grid; gap: 1rem; } .q-aside .btn { width: 100%; }
.q-list { display: grid; gap: .8rem; }
.sel-bar { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; padding: .65rem .9rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); font-size: .9rem; }
.sel-bar b { color: var(--accent-strong); }
.qcard { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .9rem; padding: 1rem 1.1rem; border: 1.5px solid var(--line); border-radius: 18px; background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s; }
.qcard:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.qcard.on { border-color: var(--accent); background: linear-gradient(180deg, color-mix(in srgb, var(--accent-soft) 90%, #fff), color-mix(in srgb, var(--accent-soft) 38%, var(--surface))); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent), 0 10px 24px color-mix(in srgb, var(--accent) 14%, transparent), inset 0 1px 0 rgba(255,255,255,.65); }
.pick { width: 1.65rem; height: 1.65rem; border-radius: 50%; border: 2px solid var(--line-strong); display: grid; place-items: center; color: transparent; background: var(--surface); cursor: pointer; padding: 0; transition: background .15s, border-color .15s; flex: none; margin-top: .1rem; }
.pick .icon { width: .95rem; height: .95rem; } .pick:hover { border-color: var(--accent); }
.qcard.on .pick { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.qbody { display: grid; gap: .6rem; min-width: 0; }
.qtop { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; }
.qtags { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.qbadge { display: inline-flex; gap: .3rem; align-items: center; font-size: .72rem; font-weight: 600; padding: .12rem .55rem; border-radius: 99px; background: var(--accent-soft); color: var(--accent-strong); }
.qbadge.Easy { background: var(--ok-soft); color: var(--ok); } .qbadge.Medium { background: var(--warn-soft); color: var(--warn); } .qbadge.Hard { background: var(--bad-soft); color: var(--bad); }
.qbadge.ai { background: var(--info-soft); color: var(--info); } .qbadge .icon { width: .85em; height: .85em; }
.qmarks { font-size: .78rem; color: var(--ink-2); white-space: nowrap; display: inline-flex; gap: .4rem; align-items: center; }
.qtext { font-weight: 500; word-break: break-word; }
.qopts { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; } @media (max-width: 640px) { .qopts { grid-template-columns: 1fr; } }
.qopt { display: flex; gap: .5rem; align-items: flex-start; border: 1px solid var(--line); border-radius: 11px; padding: .5rem .7rem; font-size: .88rem; color: var(--ink-2); background: color-mix(in srgb, var(--surface) 70%, transparent); word-break: break-word; }
.qopt b { color: var(--ink-3); } .qopt .tick { margin-left: auto; color: var(--ok); }
.qopt.right { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 40%, transparent); color: var(--ink); }
.qmodel { font-size: .85rem; color: var(--ink-2); }
.qactions { display: flex; gap: .2rem; }
.sum-row { display: flex; justify-content: space-between; padding: .45rem 0; font-size: .9rem; } .sum-row + .sum-row { border-top: 1px solid var(--line); } .sum-row b:last-child { font-weight: 700; }

[data-role="teacher"] .modal { border-radius: 20px; } [data-role="teacher"] .modal h2 { display: flex; align-items: center; gap: .6rem; font-size: 1.1rem; font-weight: 600; }
.mi { width: 2rem; height: 2rem; border-radius: 10px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; flex: none; }
.qm-top { display: grid; grid-template-columns: 1.7fr 1fr .8fr .8fr; gap: .8rem; align-items: start; } @media (max-width: 640px) { .qm-top { grid-template-columns: 1fr 1fr; } }
.opt-edit { display: flex; align-items: center; gap: .7rem; border: 1px solid var(--line); border-radius: 12px; padding: .35rem .6rem; background: var(--surface); transition: border-color .15s, background .15s; }
.opt-edit.right { border-color: color-mix(in srgb, var(--ok) 55%, transparent); background: var(--ok-soft); }
.opt-edit .letter { font-size: .78rem; font-weight: 700; color: var(--ink-3); width: 1rem; }
.opt-edit input.plain { flex: 1; min-width: 0; border: 0; background: transparent; padding: .45rem .2rem; outline: none; }
.rpick { width: 1.4rem; height: 1.4rem; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--surface); display: grid; place-items: center; cursor: pointer; padding: 0; color: transparent; flex: none; }
.rpick .icon { width: .8rem; height: .8rem; } .opt-edit.right .rpick { border-color: var(--ok); color: var(--ok); background: transparent; }
.count-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; } @media (max-width: 520px) { .count-grid { grid-template-columns: 1fr; } }
.count-box { display: flex; justify-content: space-between; align-items: center; gap: .6rem; border: 1px solid var(--line); border-radius: 14px; padding: .55rem .8rem; }
.stepper-ctl { display: inline-flex; align-items: center; gap: .55rem; } .stepper-ctl output { min-width: 1.4rem; text-align: center; font-weight: 600; }
.step-btn { width: 1.7rem; height: 1.7rem; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); display: grid; place-items: center; cursor: pointer; padding: 0; transition: background .15s, border-color .15s; }
.step-btn:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); } .step-btn:disabled { opacity: .4; cursor: not-allowed; } .step-btn .icon { width: .9rem; height: .9rem; }

.assign-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.1rem; align-items: start; } @media (max-width: 900px) { .assign-grid { grid-template-columns: 1fr; } }
.all-bar { display: flex; justify-content: space-between; align-items: center; gap: .6rem; background: var(--surface-2); border-radius: 12px; padding: .5rem .8rem; }
.all-bar label { display: flex; gap: .6rem; align-items: center; cursor: pointer; font-size: .9rem; }
.srows { display: grid; gap: .1rem; max-height: 27rem; overflow-y: auto; margin-top: .4rem; }
.srow { display: flex; gap: .75rem; align-items: center; padding: .55rem .5rem; border-radius: 12px; cursor: pointer; transition: background .15s; min-width: 0; } .srow:hover { background: var(--surface-2); }
.srow input[type=checkbox], .all-bar input[type=checkbox] { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); flex: none; }
.srow .t { min-width: 0; flex: 1; } .srow .t b { display: block; font-size: .92rem; }
.count-chip { display: inline-flex; background: var(--accent-soft); color: var(--accent-strong); border-radius: 99px; padding: 0 .55rem; font-size: .8rem; font-weight: 600; margin-left: .4rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: .8rem; }
.fact { border: 1px solid var(--line); border-radius: 14px; padding: .75rem .9rem; } .fact small { display: block; color: var(--ink-3); font-size: .75rem; } .fact b { font-size: 1.05rem; }
.publish-actions { display: flex; justify-content: space-between; gap: .8rem; flex-wrap: wrap; align-items: center; }
.publish-actions .right { display: flex; gap: .6rem; flex-wrap: wrap; }

/* Admin overview cards are links to the matching list: rich hover, never underlined */
a.stat.clickable, a.stat.clickable:hover, a.stat.clickable:focus-visible, a.stat.clickable * { text-decoration: none !important; }
a.stat.clickable { position: relative; overflow: hidden; isolation: isolate; color: inherit; cursor: pointer; transition: transform .22s cubic-bezier(.2,.8,.2,1), box-shadow .22s, border-color .22s; }
a.stat.clickable::before { content: ""; position: absolute; inset: 0; z-index: -1; opacity: 0; transition: opacity .25s;
  background: radial-gradient(120% 120% at 0% 0%, color-mix(in srgb, var(--tint) 16%, transparent), transparent 65%); }
a.stat.clickable::after { content: ""; position: absolute; left: 0; bottom: 0; height: 4px; width: 100%; background: var(--tint); transform: scaleX(0); transform-origin: left; transition: transform .3s cubic-bezier(.2,.8,.2,1); }
a.stat.clickable:hover, a.stat.clickable:focus-visible { transform: translateY(-5px); border-color: color-mix(in srgb, var(--tint) 55%, var(--line)); box-shadow: 0 18px 36px -14px color-mix(in srgb, var(--tint) 45%, transparent), var(--shadow); }
a.stat.clickable:hover::before, a.stat.clickable:focus-visible::before { opacity: 1; }
a.stat.clickable:hover::after, a.stat.clickable:focus-visible::after { transform: scaleX(1); }
a.stat.clickable:active { transform: translateY(-2px); }
a.stat.clickable:focus-visible { outline: none; box-shadow: var(--focus), var(--shadow); }
.stat .glyph { background: linear-gradient(145deg, var(--tint-bg), color-mix(in srgb, var(--tint) 20%, var(--tint-bg)));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tint) 25%, transparent), 0 4px 10px -4px color-mix(in srgb, var(--tint) 40%, transparent);
  transition: transform .25s cubic-bezier(.3,1.4,.5,1), background .2s, color .2s, box-shadow .2s; }
.stat .glyph .icon { stroke-width: 1.7; } .stat .glyph .icon path { fill: currentColor; fill-opacity: .14; }
a.stat.clickable:hover .glyph, a.stat.clickable:focus-visible .glyph { background: var(--tint); color: var(--surface); transform: scale(1.1) rotate(-6deg); box-shadow: 0 8px 18px -6px color-mix(in srgb, var(--tint) 70%, transparent); }
.stat .go { margin-left: auto; width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; flex: none; border: 1px solid var(--line-strong); color: var(--ink-3); background: var(--surface);
  transition: transform .25s cubic-bezier(.3,1.4,.5,1), background .2s, color .2s, border-color .2s; }
.stat .go .icon { width: 1rem; height: 1rem; stroke-width: 2.2; }
a.stat.clickable:hover .go, a.stat.clickable:focus-visible .go { background: var(--tint); border-color: var(--tint); color: var(--surface); transform: translateX(3px) scale(1.08); }
.back-row { margin-bottom: .9rem; } .back-row .btn { padding: .45rem .95rem; border-radius: 999px; }

/* Welcome banner (teacher and admin dashboards): same layout as the student portal's greeting banner. */
.cm-banner { --b1: #0a4f8a; --b2: #0b7fc9; --b3: #0b95bd; display: flex; align-items: center; justify-content: space-between; gap: 1.2rem; flex-wrap: wrap;
  padding: 1.7rem 2.1rem; border-radius: 22px; color: #fff; margin-bottom: 1.2rem; position: relative; overflow: hidden;
  background: linear-gradient(110deg, var(--b1), var(--b2) 55%, var(--b3)); box-shadow: 0 14px 34px color-mix(in srgb, var(--b2) 28%, transparent); }
.cm-banner::after { content: ""; position: absolute; width: 340px; height: 340px; right: -90px; top: -150px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.16), transparent 68%); pointer-events: none; }
.cm-banner > * { position: relative; z-index: 1; }
.cm-banner .eyebrow-t { font-size: .9rem; opacity: .92; }
.cm-banner h2 { color: #fff; font-size: clamp(1.8rem, 4vw, 2.5rem); margin: .1rem 0 .35rem; line-height: 1.15; }
.cm-banner p { margin: 0; color: rgba(255,255,255,.92); font-size: 1rem; }
.cm-banner .btn { background: #fff; color: var(--b1); border-color: #fff; font-weight: 700; padding: .75rem 1.3rem; border-radius: 12px; box-shadow: 0 6px 18px rgba(0,0,0,.16); }
.cm-banner .btn:hover { background: #f4f7f9; transform: translateY(-1px); text-decoration: none; }
.cm-banner .btn .icon { color: var(--b2); }
@media (max-width: 560px) { .cm-banner { padding: 1.3rem 1.2rem; } .cm-banner .btn { width: 100%; justify-content: center; } }
/* ---------- one shell for every role: nav groups, header chip (shared with teacher.css, which only adds teacher details) ---------- */
.nav-group { display: grid; gap: .2rem; } .nav-group + .nav-group { margin-top: .9rem; }
.nav-title { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 0 .8rem .35rem; }
.portal-card p { font-size: .82rem; color: var(--ink-2); } .portal-card b { display: block; margin-bottom: .2rem; }
.user-chip { display: flex; align-items: center; gap: .6rem; border: 0; background: none; cursor: pointer; padding: .25rem .4rem; border-radius: 999px; text-align: left; transition: background .15s; }
.user-chip:hover { background: var(--accent-soft); }
.user-chip .who { display: grid; line-height: 1.2; } .user-chip small { color: var(--ink-3); font-size: .75rem; }
.user-chip .caret { width: 1rem; height: 1rem; color: var(--ink-3); transition: transform .2s; } .user-chip[aria-expanded="true"] .caret { transform: rotate(180deg); }
@media (max-width: 560px) { .user-chip .who { display: none; } }

/* ---------- banners follow the role colour: teacher green, admin orange (student keeps its own welcome banner) ---------- */
[data-role="teacher"] .cm-banner { --b1: #055a3f; --b2: #0a8f6a; --b3: #12b886; }
[data-role="admin"] .cm-banner { --b1: #9a3412; --b2: #c2410c; --b3: #ea7a2b; }
[data-role="teacher"] .cm-banner .btn { color: #055a3f; } [data-role="admin"] .cm-banner .btn { color: #9a3412; }
.round { border-radius: 999px; }

/* Student banner uses the shared banner component (its default blue matches the student accent). */
[data-role="student"] .cm-banner .btn { color: #0a4f8a; } [data-role="student"] .stats { margin-bottom: 1.4rem; }
.back-row .btn, .btn.round { border-radius: 999px; }

.logo-img { width: 2.25rem; height: 2.25rem; border-radius: 11px; display: block; box-shadow: 0 6px 14px -6px rgba(11, 120, 196, .55); transition: transform .25s; } .brand:hover .logo-img { transform: rotate(-6deg) scale(1.06); }

/* ---------- hover and motion: the student pages behave exactly like the teacher and administrator pages ---------- */
.nav-link { transition: transform .15s, background .15s, color .15s; } .nav-link:hover { transform: translateX(2px); }
.scard2 { transition: transform .2s, box-shadow .2s, border-color .2s; } .scard2:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: var(--shadow-lg); } .scard2:hover h3 { color: var(--accent-strong); }
.res-row { transition: transform .2s, box-shadow .2s, border-color .2s, background .2s; } .res-row:hover { transform: translateX(4px); border-color: var(--accent); background: var(--accent-soft); box-shadow: -4px 0 0 0 var(--accent), 0 10px 22px -14px color-mix(in srgb, var(--accent) 60%, transparent); }
.hist { transition: transform .2s, box-shadow .2s, border-color .2s; } .hist:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: 0 10px 22px -14px color-mix(in srgb, var(--accent) 60%, transparent); }
.mini-stat, .kv, .panel, .res-tile, .qr { transition: transform .2s, box-shadow .2s, border-color .2s; }
.mini-stat:hover, .kv:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: 0 10px 22px -14px color-mix(in srgb, var(--accent) 60%, transparent); }
.res-tile:hover { transform: translateY(-3px); } .qr:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.popover button { transition: background .15s, padding-left .15s, color .15s; } .popover button:hover { background: var(--accent-soft); color: var(--accent-strong); padding-left: 1rem; }
.pct-tile { transition: transform .2s; } .res-row:hover .pct-tile { transform: scale(1.08) rotate(-3deg); }
.practice-card, .marks-box { transition: box-shadow .2s, border-color .2s; } .practice-card:hover { box-shadow: var(--shadow-lg); }
.ans-opt, .seg-btn, .chip, .step-btn { transition: transform .15s, border-color .15s, background .15s; } .ans-opt:hover, .seg-btn:hover, .chip:hover { transform: translateY(-1px); }
.btn { transition: background .15s, transform .12s, box-shadow .15s, border-color .15s; } .btn:not(:disabled):hover { box-shadow: 0 8px 18px -10px color-mix(in srgb, var(--accent) 55%, transparent); }
@media (prefers-reduced-motion: reduce) { .nav-link:hover, .scard2:hover, .res-row:hover, .hist:hover, .mini-stat:hover, .kv:hover, .res-tile:hover { transform: none; } }

/* ---------- small screens: phones and tablets ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
img, video, canvas, svg { max-width: 100%; }
@media (max-width: 640px) {
  .input, select.input, textarea.input { font-size: 16px; }              /* stops iPhones zooming in when a field is tapped */
  .table-wrap table { min-width: 560px; }                                /* wide tables scroll sideways inside their box instead of squeezing */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .table-wrap td, .table-wrap th { padding-left: .7rem; padding-right: .7rem; }
}
@media (pointer: coarse) {                                              /* touch screens: comfortable tap targets */
  .btn, .pill-tab, .nav-link, .seg-btn { min-height: 2.75rem; }
  .btn.sm { min-height: 2.4rem; }
}
.modal > .row.spread:first-child { flex-wrap: nowrap; align-items: flex-start; }
.modal > .row.spread:first-child h2 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.modal > .row.spread:first-child .btn { flex: none; }
@supports (height: 100dvh) { .modal { max-height: calc(100dvh - 2rem); } }     /* phone browser toolbars don't cut the dialog off */

/* =====================================================================================================
   Phones: side drawer, tables as cards, nothing wider than the screen
   ===================================================================================================== */
.side-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; } .side-close { display: none; }
.scrim { display: none; }
@media (max-width: 860px) {
  body.nav-open { overflow: hidden; }
  .side { width: min(300px, 84vw); padding: 1rem 1rem 1.2rem; gap: 1rem; overflow-y: auto; border-right: 0; border-radius: 0 22px 22px 0; box-shadow: 0 0 0 1px var(--line), 0 24px 60px -12px rgba(16, 24, 40, .45); }
  .side-head { padding-bottom: .9rem; border-bottom: 1px solid var(--line); } .side-close { display: inline-flex; }
  .side .nav-link { padding: .8rem .9rem; font-size: 1rem; } .side .nav-link .icon { width: 1.25rem; height: 1.25rem; }
  .side .nav-link[aria-current="page"]::before { display: none; }
  .side .nav-heading, .side .nav-title { padding-left: .9rem; }
  .side .portal-card { margin-top: auto; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 70; background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .scrim.open { opacity: 1; pointer-events: auto; }
  /* If anything ever sticks out sideways, a phone browser zooms the whole page out and leaves an empty strip on the right. Never allow that. */
  html, body { overflow-x: hidden; max-width: 100%; }
  .res-row:hover, .scard2:hover, .hist:hover { transform: none; box-shadow: none; }      /* a tap leaves :hover on; don't slide the row sideways */
  .shell, .main { max-width: 100vw; } .shell { grid-template-columns: minmax(0, 1fr); } .main { padding-left: 1rem; padding-right: 1rem; overflow-x: clip; }
  .main > *, .main-top > *, .tp-dash-grid > *, .tp-panel, .res-two > *, .rv-grid > * { min-width: 0; }
}
@media (max-width: 720px) {
  /* every table becomes a list of cards; the first cell is the card's heading */
  .table-wrap { border: 0; overflow: visible; background: none; max-width: 100%; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; min-width: 0; }
  .table-wrap thead { display: none; }
  .table-wrap tbody tr { display: grid; gap: .45rem; padding: .85rem .95rem; margin: 0 0 .7rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
  .table-wrap td { display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding: 0; border: 0; text-align: right; font-size: .92rem; }
  .table-wrap td::before { content: attr(data-label); flex: none; color: var(--ink-3); font-size: .78rem; font-weight: 650; text-align: left; }
  .table-wrap td:first-child { display: block; text-align: left; padding-bottom: .45rem; border-bottom: 1px solid var(--line); } .table-wrap td:first-child::before { display: none; }
  .table-wrap td[data-label="Actions"] { display: flex; justify-content: flex-start; flex-wrap: wrap; padding-top: .45rem; border-top: 1px solid var(--line); } .table-wrap td[data-label="Actions"]::before { display: none; }
  .table-wrap td[data-label="Actions"] .row { width: 100%; } .table-wrap td[data-label="Actions"] .btn { flex: 1; justify-content: center; }
}
@media (max-width: 560px) {
  .theme-label { display: none; }
  .pub-head .btn { padding-left: .8rem; padding-right: .8rem; }
}

/* Keyboard users: a link that jumps past the side menu. Visible only while focused. */
.skip-link { position: absolute; left: .75rem; top: -3rem; z-index: 1000; background: var(--accent); color: #fff; padding: .55rem 1rem; border-radius: 999px; font-weight: 600; text-decoration: none; transition: top .15s; }
.skip-link:focus { top: .75rem; }
.main:focus { outline: none; }
/* People who ask their device for less motion get none of the slide, fade and pulse effects. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* Very narrow screens (split windows, small phones): nothing may be wider than its box. */
.field, .grid-2 > *, .grid-3 > *, .tp-form-stack > *, .tp-pick > *, .pf-row > *, .sug-panel > * { min-width: 0; }
.input, select.input, textarea.input, .search input { max-width: 100%; min-width: 0; }
.tp-pick b, .tp-pick small, .pf-row b, .pf-row small { overflow-wrap: anywhere; }
.tp-pick { flex-wrap: wrap; }