/* KhmerMath Exams — interface v2.
   One design layer on top of app.css / interface.css: tokens, buttons, cards, tables, the teacher shell (sidebar, header,
   user menu, phone bottom bar) and the student pages (login, home, exam). Papers, report cards and printing keep their own CSS. */
@media screen {
  :root {
    --ink: #1f2433; --muted: #646b7d; --line: #e8e3d8;
    --bg: #f1effb; --card: #fff;
    --brand: #6b63e0; --brand-dark: #5249c6; --brand-soft: #efedff;
    --navy: #2b2a5c; --navy-2: #3a3978;
    --good: #1c9a74; --good-soft: #e1f5ec; --bad: #d9454f; --bad-soft: #fdeceb;
    --warn: #b7791f; --warn-soft: #fff1d6; --accent: #f2a53b;
    --radius: 18px;
    --shadow: 0 1px 2px rgba(60, 44, 20, .05), 0 8px 24px rgba(60, 44, 20, .07);
    --shadow-lg: 0 18px 50px rgba(40, 30, 15, .22);
    --ring: 0 0 0 4px rgba(107, 99, 224, .2);
    --brand-grad: linear-gradient(135deg, #6d65e2 0%, #5249c6 100%);
  }
  body { background: var(--bg); color: var(--ink); line-height: 1.75; }
  h1, h2 { line-height: 1.6; letter-spacing: -.005em; }
  h2 { font-size: 20px; }
  ::selection { background: #cddcff; }

  /* ---------- controls ---------- */
  #dashboard-content:focus { outline: none; }
  button, .btn { background: var(--brand-grad); color: #fff; border-radius: 14px; min-height: 44px; padding: 9px 20px; font-weight: 600; letter-spacing: .005em; box-shadow: 0 1px 2px rgba(40, 30, 90, .12), 0 6px 14px rgba(107, 99, 224, .22); transition: background .15s, box-shadow .15s, transform .08s, border-color .15s; }
  button:hover, .btn:hover { background: var(--brand-grad); box-shadow: 0 2px 4px rgba(40, 30, 90, .14), 0 10px 20px rgba(107, 99, 224, .3); text-decoration: none; }
  button:active, .btn:active { transform: translateY(1px) scale(.995); }
  button.secondary, .btn.secondary { background: #fff; color: var(--brand-dark); border: 1.5px solid #cfd9f0; box-shadow: none; }
  button.secondary:hover, .btn.secondary:hover { background: var(--brand-soft); border-color: #b2c3ee; box-shadow: none; }
  button.danger { background: #fff; color: var(--bad); border: 1.5px solid #f2c3c7; box-shadow: none; }
  button.danger:hover { background: var(--bad-soft); box-shadow: none; }
  button.good, .btn.good { background: var(--good); box-shadow: 0 1px 2px rgba(40, 30, 15, .12), 0 4px 12px rgba(15, 157, 108, .25); }
  button.good:hover { background: #0b8459; }
  button.ghost { background: transparent; color: var(--muted); border: 0; box-shadow: none; }
  button:disabled { opacity: .5; box-shadow: none; }
  .btn-sm { min-height: 36px; padding: 6px 13px; font-size: 13.5px; border-radius: 10px; }
  .btn-block { width: 100%; min-height: 48px; font-size: 16px; }
  :where(a, button, input, select, textarea, summary):focus-visible { outline: 3px solid rgba(107, 99, 224, .5); outline-offset: 2px; }

  input[type=text], input[type=password], input[type=number], input[type=datetime-local], input[type=date], input[type=time], textarea, select {
    border: 1.5px solid #dcd6c8; border-radius: 12px; padding: 11px 14px; background: #fff; min-height: 44px;
  }
  input:hover, textarea:hover, select:hover { border-color: #c3bcab; }
  input:focus, textarea:focus, select:focus { border-color: var(--brand); box-shadow: var(--ring); }
  ::placeholder { color: #98a3b8; }
  label { color: #3c4a63; font-weight: 600; font-size: 13.5px; }

  /* ---------- cards, lists, tables, badges ---------- */
  .card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
  .card > h2:first-child, .card > .row:first-child > h2 { margin-top: 0; }
  .list-item { padding: 14px 0; }
  .empty-card { border: 1.5px dashed #c9d4ea; border-radius: var(--radius); background: #fbf9f4; padding: 36px 20px; }
  .empty-icon { font-size: 40px; }
  table { font-size: 14px; }
  th { background: #f6f2ea; color: #4a5872; font-weight: 700; font-size: 13px; border-bottom: 1.5px solid var(--line); }
  td, th { padding: 12px 14px; }
  tbody tr:hover { background: #f9f6ef; }
  .badge, .chip { border-radius: 99px; padding: 3px 11px; font-weight: 600; }
  .badge.open, .badge.ready, .chip-open { background: var(--good-soft); color: #0b7a54; }
  .badge.warn, .badge.upcoming, .chip-soon { background: var(--warn-soft); color: #946014; }
  .badge.draft, .badge.closed, .chip-closed, .chip-plain { background: #f1effb; color: #3e3a63; border: 1px solid #e2def5; }
  .chip-med { background: #e8f0fe; color: #1e40af; border: 1px solid #c7d9fb; }
  .chip-hard { background: #fdeceb; color: #b4232c; border: 1px solid #f7c8cb; }
  .chip-brand { background: var(--brand-soft); color: var(--brand-dark); border: 1px solid #d4cffa; font-weight: 700; }
  .chip-id { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-weight: 700; color: #1e40af; background: #eff6ff; border: 1px solid #bfdbfe; }
  .error { border-radius: 12px; }
  .notice { border-radius: 12px; }
  .callout { border-radius: 12px; }
  .muted { color: var(--muted); }
  .eyebrow { color: var(--brand); font-size: 12px; font-weight: 700; letter-spacing: .06em; }
  .stat-tile { background: var(--brand-soft); border-radius: 14px; }

  /* modals */
  .modal-back { background: rgba(40, 30, 15, .55); backdrop-filter: blur(5px); animation: ui2fade .18s ease; }
  .modal-box { border-radius: 22px; padding: 28px 24px; box-shadow: var(--shadow-lg); animation: ui2pop .22s cubic-bezier(.2, .9, .3, 1.15); }
  @keyframes ui2fade { from { opacity: 0; } }
  @keyframes ui2pop { from { opacity: 0; transform: translateY(10px) scale(.97); } }

  /* ---------- brand ---------- */
  .site-brand { gap: 12px; color: var(--ink); }
  .brand-symbol { width: 42px; height: 42px; border-radius: 13px; background: var(--brand-grad); box-shadow: 0 8px 18px rgba(107, 99, 224, .35); font: 600 26px Georgia, serif; }
  .brand-caption { color: var(--muted); }

  /* ---------- teacher shell ---------- */
  body.teacher-body { background: var(--bg); }
  .teacher-navigation { background: linear-gradient(180deg, var(--brand) 0%, var(--brand-dark) 100%); border: 0; margin: 0; padding: 16px 12px 12px; gap: 2px; width: 220px; box-shadow: none; overflow-x: hidden; }
  .teacher-navigation .site-brand { display: none; }
  .nav-caption { font-size: 11px; color: rgba(255, 255, 255, .7); text-transform: none; letter-spacing: 0; font-weight: 700; margin: 8px 8px 2px; text-align: left; }
  .teacher-navigation button { flex-direction: row; justify-content: flex-start; align-items: center; gap: 10px; color: #fff; border-radius: 14px; padding: 8px 10px; min-height: 44px; font-size: 14px; font-weight: 600; line-height: 1.35; text-align: left; box-shadow: none; background: transparent; border: 0; }
  .teacher-navigation button span { display: block; min-width: 0; }
  .teacher-navigation button:hover { background: rgba(255, 255, 255, .14); color: #fff; box-shadow: none; }
  .teacher-navigation button.active { background: rgba(255, 255, 255, .22); color: #fff; font-weight: 800; box-shadow: none; }
  .teacher-navigation button .ui-icon { width: 22px; height: 22px; opacity: 1; stroke-width: 1.8; flex: none; }
  .nav-home { color: rgba(255, 255, 255, .8); margin: 8px 0 0; padding-top: 0; text-align: center; font-size: 12px; }
  .nav-home:hover { color: #fff; text-decoration: none; }
  .nav-art { margin-top: auto; padding: 8px 4px 0; }
  .nav-art svg { width: auto; max-width: 100%; height: 72px; display: block; margin: 0 auto; }

  #view-dashboard { margin: 0 auto; padding: 0 28px 48px; max-width: 1560px; }
  .frame-logo { display: none; }
  .dh-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; }
  .dashboard-header { position: sticky; top: 0; z-index: 30; margin: 0 -28px 22px; padding: 14px 28px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); align-items: center; flex-wrap: wrap; }
  .dashboard-header .eyebrow { margin: 0; font-size: 11.5px; }
  .dashboard-header h1 { font-size: 24px; margin: 0; line-height: 1.5; color: var(--ink); }
  .dashboard-header .muted { font-size: 12.5px; }
  .dashboard-actions { gap: 10px; align-items: center; flex-wrap: nowrap; }
  .dashboard-actions .help-link { min-height: 40px; background: #fff; }
  .mode-switch {
    display: flex; align-items: center; gap: 8px;
    min-height: 40px; padding: 4px 12px 4px 6px;
    border-radius: 99px; background: #fff; color: var(--ink);
    border: 1.5px solid var(--line); box-shadow: none;
    font-weight: 700; font-size: 13px; cursor: pointer;
  }
  .mode-switch:hover { border-color: #b2c3ee; box-shadow: var(--shadow); }
  .mode-switch.on { background: var(--navy); color: #fff; border-color: var(--navy); }
  .mode-switch-track {
    width: 36px; height: 20px; border-radius: 99px;
    background: #d7dce8; position: relative; flex: none;
  }
  .mode-switch.on .mode-switch-track { background: #8b84f0; }
  .mode-switch-knob {
    position: absolute; top: 2px; left: 2px;
    width: 16px; height: 16px; border-radius: 50%; background: #fff;
    transition: transform .18s ease; box-shadow: 0 1px 3px rgba(0,0,0,.2);
  }
  .mode-switch.on .mode-switch-knob { transform: translateX(16px); }
  .teach-stage { overflow: hidden; overflow: clip; }   /* clip, not hidden: position:sticky inside (the question-bank lesson list) keeps working */
  #dashboard-content.magictime { animation-duration: .85s; animation-fill-mode: both; transform-origin: 50% 40%; }
  #dashboard-content.vanishIn { animation-name: vanishIn; }
  #dashboard-content.vanishOut { animation-name: vanishOut; }
  @keyframes vanishIn {
    0% { opacity: 0; transform-origin: 50% 50%; transform: scale(2, 2); filter: blur(90px); }
    100% { opacity: 1; transform-origin: 50% 50%; transform: scale(1, 1); filter: blur(0); }
  }
  @keyframes vanishOut {
    0% { opacity: 1; transform-origin: 50% 50%; transform: scale(1, 1); filter: blur(0); }
    100% { opacity: 0; transform-origin: 50% 50%; transform: scale(2, 2); filter: blur(20px); }
  }
  @media (prefers-reduced-motion: reduce) {
    #dashboard-content.magictime { animation: none; }
  }
  .teach-back {
    min-height: 40px; padding: 6px 12px; border-radius: 99px;
    background: #fff; border: 1.5px solid var(--line); font-weight: 700; font-size: 13px;
  }
  body.teach-mode {
    background:
      radial-gradient(900px 420px at 0% 0%, rgba(107, 99, 224, .14), transparent 60%),
      var(--bg);
    color: #1c2433;
  }
  body.teach-mode .dashboard-header {
    background: rgba(255, 252, 247, .9);
    border-bottom-color: rgba(28, 36, 51, .08);
  }
  body.teach-mode .dashboard-header h1 { color: #1c2433; }
  body.teach-mode .dashboard-header .eyebrow { color: var(--brand); }
  body.teach-mode .dashboard-header .muted { color: #5c677a; }
  body.teach-mode .teach-back {
    background: #fff; color: #1c2433;
    border-color: rgba(28, 36, 51, .12);
  }
  body.teach-mode .teacher-navigation,
  body.teach-mode .nav-toggle,
  body.teach-mode .bottom-bar,
  body.teach-mode .sheet-scrim { display: none; }
  body.teach-mode #view-dashboard { margin: 0 auto; max-width: 1120px; background: transparent; box-shadow: none; border-radius: 0; min-height: 0; }
  body.teach-mode #teach-stage { display: block; }
  body.teach-mode .frame-logo { display: none; }
  body.teach-mode.teach-tool .teach-home { display: none; }
  .teach-home { max-width: 1040px; margin: 0 auto; padding-bottom: 40px; }
  .teach-hero {
    display: flex; align-items: center; justify-content: space-between; gap: 20px;
    margin: 4px 0 16px; padding: 22px 24px;
    border-radius: 24px; color: #fff; overflow: hidden; position: relative;
    background: linear-gradient(120deg, #172033 0%, var(--brand) 72%);
    box-shadow: 0 16px 36px rgba(23, 32, 51, .18);
  }
  .teach-hero::after {
    content: ''; position: absolute; right: -40px; top: -50px; width: 220px; height: 220px;
    border-radius: 50%; background: rgba(255, 255, 255, .12);
  }
  .teach-hero-copy { position: relative; z-index: 1; }
  .teach-kicker {
    margin: 0 0 6px; font-size: 12px; font-weight: 800; letter-spacing: .12em;
    text-transform: uppercase; color: rgba(255, 255, 255, .72);
  }
  .teach-hero h2 { margin: 0; font-size: 34px; line-height: 1.25; color: #fff; }
  .teach-hero-meta { margin: 8px 0 0; font-size: 15px; color: rgba(255, 255, 255, .82); }
  .teach-hero-mark {
    position: relative; z-index: 1; flex: none;
    width: 92px; height: 92px; border-radius: 28px;
    display: grid; place-items: center;
    background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .22);
    font-size: 40px; font-weight: 800; letter-spacing: -.03em;
  }
  .teach-sec { display: flex; align-items: baseline; gap: 10px; margin: 8px 0 14px; }
  .teach-h { margin: 0; font-size: 18px; color: #1c2433; }
  .teach-rail { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 12px; margin-bottom: 8px; }
  .teach-rail .teach-class { min-width: 168px; min-height: 92px; flex: 0 0 auto; }
  .teach-desk { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .8fr); gap: 14px; align-items: start; margin-bottom: 22px; }
  .teach-loading { margin: 0; padding: 28px; border-radius: 20px; background: #fff; color: #5c677a; }
  .teach-sec-n {
    min-width: 28px; height: 22px; padding: 0 8px; border-radius: 99px;
    display: inline-grid; place-items: center;
    background: rgba(255, 255, 255, .12); color: #c9d6ff; font-size: 12px; font-weight: 800;
  }
  .teach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 32px; }
  .teach-class {
    display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
    text-align: left; min-height: 92px; padding: 14px 14px;
    background: #fff; color: #1c2433;
    border: 1.5px solid rgba(28, 36, 51, .08); border-radius: 18px;
    box-shadow: none; cursor: pointer;
  }
  body.teach-mode button.teach-class:hover { background: #fff; border-color: #b9c8ee; color: #1c2433; transform: translateY(-2px); }
  .teach-class.on {
    background: #1c2433; color: #fff; border-color: #1c2433;
    box-shadow: 0 10px 24px rgba(28, 36, 51, .18);
  }
  body.teach-mode button.teach-class.on:hover { background: #1c2433; color: #fff; }
  .teach-class b { font-size: 20px; color: inherit; line-height: 1.3; }
  .teach-grade {
    font-size: 11.5px; font-weight: 800; letter-spacing: .04em;
    padding: 3px 9px; border-radius: 99px;
    background: #e7eefc; color: var(--brand);
  }
  .teach-class.on .teach-grade { background: rgba(255,255,255,.16); color: #fff; }
  .teach-count { font-size: 13.5px; opacity: .72; }
  .teach-class-go { font-size: 12.5px; font-weight: 800; color: var(--brand); }
  .teach-class.on .teach-class-go { color: #ffd56a; }
  .teach-count strong { font-size: 22px; font-weight: 800; opacity: 1; margin-right: 4px; }
  .teach-tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; }
  .teach-tile {
    display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
    text-align: left; min-height: 132px; padding: 16px 14px;
    background: #fff; color: #1c2433;
    border: 1.5px solid rgba(28, 36, 51, .08); border-radius: 18px;
    box-shadow: none; cursor: pointer;
  }
  body.teach-mode button.teach-tile:hover { background: #fff; color: #1c2433; transform: translateY(-2px); box-shadow: 0 10px 24px rgba(28, 36, 51, .08); }
  .teach-ic {
    width: 48px; height: 48px; border-radius: 16px; margin-bottom: 6px;
    display: grid; place-items: center; font-size: 24px; line-height: 1;
  }
  .teach-tile b { font-size: 16px; }
  .teach-tile-d { font-size: 12.5px; line-height: 1.45; color: #5c677a; }
  .t-spin .teach-ic { background: linear-gradient(135deg, #ffd56a, #f2a53b); }
  .t-cards .teach-ic { background: linear-gradient(135deg, #c4b5fd, #7c5cff); }
  .t-qwheel .teach-ic { background: transparent; }
  .t-boat .teach-ic { background: linear-gradient(135deg, #7ec8ff, var(--brand)); }
  .t-live .teach-ic { background: linear-gradient(135deg, #ffb4a8, #e25a4a); }
  .t-bingo .teach-ic { background: linear-gradient(135deg, #b8f28a, #5aa832); }
  .t-spin:hover { border-color: #f2a53b; }
  .t-cards:hover { border-color: #7c5cff; }
  .t-qwheel:hover { border-color: #1c9a74; }
  .t-boat:hover { border-color: #6ea0ff; }
  .t-live:hover { border-color: #e25a4a; }
  .t-bingo:hover { border-color: #5aa832; }
  .teach-empty {
    display: grid; place-items: center; gap: 8px; text-align: center;
    padding: 56px 24px; border-radius: 24px; color: #1c2433;
    background: #fff; border: 1px dashed rgba(28, 36, 51, .2);
  }
  .teach-empty-ic { font-size: 42px; }
  .teach-empty b { font-size: 20px; }
  .teach-empty p { margin: 0; color: #5c677a; }
  @keyframes teachRise {
    from { opacity: 0; transform: translateY(14px) scale(.98); }
    to { opacity: 1; transform: none; }
  }
  @media (prefers-reduced-motion: reduce) {
    .teach-class, .teach-tile { animation: none; }
  }
  button.wheel-hub {
    background: radial-gradient(circle at 35% 30%, #6ea0ff, var(--brand) 55%, var(--navy)); color: #fff;
  }
  button.wheel-hub:hover { background: radial-gradient(circle at 35% 30%, #8eb4ff, #3d6cf0 55%, #243056); }
  button.wheel-part { background: transparent; color: inherit; box-shadow: none; }
  button.wheel-part:hover { background: rgba(255, 255, 255, .14); box-shadow: none; }
  button.wheel-part.on, button.wheel-part.on:hover { background: #fff; color: var(--navy); box-shadow: var(--shadow); }
  body.teach-mode button.att-period { background: #f3efe6; color: #1c2433; box-shadow: none; }
  body.teach-mode button.att-period.on, body.teach-mode button.att-period.on:hover { background: #1c2433; color: #fff; }
  body.teach-mode button.att-m { background: #f3efe6; color: #1c2433; box-shadow: none; }
  body.teach-mode button.att-m.on.att-ok, body.teach-mode button.att-m.on.att-ok:hover { background: #1c9a74; color: #fff; }
  body.teach-mode button.att-m.on.att-A, body.teach-mode button.att-m.on.att-A:hover { background: #d9454f; color: #fff; }
  body.teach-mode button.att-m.on.att-L, body.teach-mode button.att-m.on.att-L:hover { background: #b7791f; color: #fff; }
  body.teach-mode button.teach-lesson { background: #fff; color: #1c2433; box-shadow: none; border: 1px solid rgba(28,36,51,.08); }
  body.teach-mode button.teach-lesson:hover { background: var(--bg); color: #1c2433; }
  body.teach-mode button.slide-open, body.teach-mode button.slide-open:hover {
    background: linear-gradient(135deg, var(--brand), #1c2433); color: #fff; border: 0;
  }
  body.teach-mode .wheel-part { color: #dbe4ff; }
  body.teach-mode button.wheel-fs-x { background: rgba(20, 24, 40, .78); color: #fff; }
  body.teach-mode .wheel-layout .card {
    background: rgba(255, 255, 255, .08); color: #e8edff;
    border-color: rgba(255, 255, 255, .12);
  }
  body.teach-mode .wheel-layout h3,
  body.teach-mode .wheel-layout label { color: #e8edff; }
  body.teach-mode .wheel-chip { background: rgba(255, 255, 255, .1); color: #fff; }
  body.teach-mode .wheel-last { background: rgba(91, 134, 255, .22); border-color: #6ea0ff; color: #c9d6ff; }
  body.teach-mode .wheel-last b { color: #fff; }
  body.teach-mode .wheel-stage:fullscreen { background: #101628; }
  .user-menu { position: relative; }
  .user-chip { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 12px 4px 5px; border-radius: 99px; background: #fff; color: var(--ink); border: 1.5px solid var(--line); box-shadow: none; font-weight: 600; font-size: 14px; }
  .user-chip:hover { background: #fff; border-color: #b2c3ee; box-shadow: var(--shadow); }
  .avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; background: linear-gradient(135deg, #5b86ff, var(--brand)); color: #fff; font-weight: 800; font-size: 15px; flex: none; }
  .user-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .caret { color: var(--muted); font-size: 12px; }
  .user-pop { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 8px; box-shadow: var(--shadow-lg); animation: ui2pop .16s ease; z-index: 40; }
  .user-pop .menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; text-align: left; background: transparent; color: var(--ink); border: 0; box-shadow: none; border-radius: 10px; font-weight: 500; font-size: 14.5px; }
  .user-pop .menu-item:hover { background: var(--brand-soft); color: var(--brand-dark); box-shadow: none; }
  .user-pop .menu-item.danger { color: var(--bad); }
  .user-pop .menu-item.danger:hover { background: var(--bad-soft); }
  .user-pop .menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }

  /* the free-trial notice is one slim bar; the plans open only on request */
  .up-card { background: #fff; color: var(--ink); border: 1px solid #f0dca4; border-left: 5px solid var(--accent); border-radius: 16px; box-shadow: var(--shadow); margin-bottom: 20px; overflow: hidden; }
  .up-top { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; padding: 10px 14px 10px 16px; }
  .up-tag { background: #fff4d9; color: #8a5a0d; border: 0; font-weight: 700; padding: 5px 13px; }
  .up-use { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; flex: 1; min-width: 0; }
  .up-use .u { background: #f3efe6; color: #43506a; border-radius: 99px; padding: 3px 11px; font-size: 12.5px; font-weight: 600; }
  .up-use .u.full { background: #ffe9c2; color: #8a5a0d; border: 0; }
  .up-note { flex: 1; color: var(--muted); font-size: 14px; }
  .up-toggle { background: linear-gradient(135deg, #3b6cf0, #2147b8); margin-left: auto; }
  .up-more { display: none; border-top: 1px solid var(--line); background: linear-gradient(180deg, #f9f6ef, #fff 30%); padding-bottom: 6px; }
  .up-card.open .up-more { display: block; animation: ui2fade .25s ease; }
  .up-head { padding: 18px 22px 0; text-align: center; }
  .up-head h2 { margin: 0; color: var(--navy); }
  .up-head p { margin: 4px 0 0; color: var(--muted); }
  .up-perks { color: var(--ink); max-width: 900px; margin: 0 auto; }
  .up-perks div::before { content: '✓ '; color: var(--good); font-weight: 800; }
  .up-plans { background: transparent; padding: 18px 18px 8px; border-radius: 0; }

  #dashboard-content > div > .card:first-child { margin-top: 0; }
  .tests-head-top h2, #dashboard-content h2 { color: var(--navy); }
  .tests-head { border-radius: 22px; }
  .test-list { gap: 14px; }
  .filter-pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 99px; padding: 6px 14px; font-weight: 600; font-size: 13.5px; box-shadow: none; min-height: 38px; background: #fff; color: var(--navy); border: 1.5px solid var(--line); }
  .filter-pill .pill-n { display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--brand-soft); color: var(--brand-dark); font-size: 11.5px; font-weight: 700; }
  .filter-pill.is-empty { background: #f8f7fc; color: var(--muted); border-style: dashed; border-color: #dcd7ee; opacity: .78; }
  .filter-pill.is-empty .pill-n { background: #ece9f6; color: var(--muted); }
  .filter-pill:hover { background: var(--brand-soft); color: var(--brand-dark); border-color: #c4bff0; opacity: 1; box-shadow: none; }
  .filter-pill.on, .filter-pill.on:hover { background: var(--brand-grad); color: #fff; border-color: transparent; border-style: solid; opacity: 1; box-shadow: 0 6px 16px rgba(107, 99, 224, .28); }
  .filter-pill.on .pill-n { background: rgba(255, 255, 255, .24); color: #fff; }
  .test-card { border: 1px solid #e7eef8; border-left: 0; border-radius: 20px; padding: 16px 18px; background: #fff; position: relative; box-shadow: 0 8px 24px rgba(47, 91, 180, .06); }
  .test-card.is-draft { background: #fff; }
  .test-card:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(47, 91, 180, .12); border-color: #d5e2f7; }
  .test-card .test-icon { width: 52px; height: 52px; border-radius: 16px; background: #e8f8ef; font-size: 26px; }
  .test-card.is-draft .test-icon { background: #eef2fb; }
  .test-card.has-open-menu, .test-card:has(.menu-pop) { z-index: 50; }
  .test-icon { background: var(--brand-soft); border-radius: 14px; }
  .test-title { color: var(--navy); }
  .icon-btn { border-radius: 12px; background: #fff; box-shadow: none; border: 1.5px solid var(--line); }
  .icon-btn .preview-ico { width: 26px; height: 26px; display: block; }
  .btn-primary-sm { display: inline-flex; align-items: center; gap: 6px; }
  .edit-ico { width: 18px; height: 18px; flex: none; display: block; }
  .bank-view-btn { display: inline-flex; align-items: center; gap: 6px; }
  .bank-view-ico { width: 22px; height: 22px; flex: none; display: block; }
  .dice-ico { width: 1.35em; height: 1.35em; vertical-align: -0.28em; display: inline-block; flex: none; }
  .eye-ico { width: 1.15em; height: 1.15em; vertical-align: -0.22em; display: inline-block; flex: none; }
  .lg-eye .eye-ico, .pw-eye .eye-ico, .pw-eye .pw-eye-ico { width: 22px; height: 22px; vertical-align: 0; }
  .lg-eye[aria-pressed="true"] .pw-eye-ico, .pw-eye.is-off .pw-eye-ico { opacity: .45; }
  .teach-ic .dice-ico { width: 34px; height: 34px; vertical-align: 0; }
  .icon-btn:hover { background: var(--brand-soft); box-shadow: none; }
  .menu-wrap.is-open, .menu-wrap:has(.menu-pop) { z-index: 60; }
  .menu-pop { border-radius: 16px; box-shadow: 0 16px 38px rgba(15, 27, 61, .22), 0 4px 12px rgba(15, 27, 61, .08); padding: 8px; z-index: var(--z-pop); }
  .menu-item { border-radius: 10px; min-height: 40px; box-shadow: none; background: transparent; color: var(--ink); border: 0; }
  .menu-item:hover { background: var(--brand-soft); color: var(--brand-dark); box-shadow: none; }
  .bank-item, .new-test-row { border-radius: 14px; }
  .bank-item:hover { border-color: #b2c3ee; background: #fafcff; }
  .bank-bar {
    position: sticky;
    top: 76px;
    z-index: 8;
    border-radius: 10px;
    padding: 6px 8px;
    gap: 6px;
    font-size: 12.5px;
  }
  @media (max-width: 800px) {
    .bank-bar { top: 56px; }
  }
  #dashboard-content .bank-side {
    position: sticky;
    top: 76px;
    z-index: 5;
    align-self: start;
    max-height: calc(100dvh - 92px);
    overflow: auto;
  }
  @media (max-width: 1100px) {
    #dashboard-content .bank-side { position: static; max-height: none; overflow: visible; }
  }
  .lesson-btn { border-radius: 12px; box-shadow: none; min-height: 40px; background: transparent; color: var(--ink); border: 0; }
  .lesson-btn.on { background: var(--brand); color: #fff; }
  .lesson-node { display: flex; flex-direction: column; }
  .lesson-subsections { margin-left: 10px; padding-left: 8px; border-left: 2px solid #cbd5e1; margin-top: 3px; margin-bottom: 5px; display: flex; flex-direction: column; gap: 2px; }
  .sub-btn { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; width: 100%; text-align: left; background: #f8fafc; color: #334155; border: 1px solid #e2e8f0; border-radius: 8px; padding: 5px 8px; font-size: 12.5px; cursor: pointer; transition: all .15s ease; box-shadow: none; min-height: 30px; }
  .sub-btn:hover { background: var(--brand-soft); border-color: #bfdbfe; color: var(--brand-dark); box-shadow: none; }
  .sub-btn.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
  .sub-btn .sub-name { flex: 1; min-width: 0; line-height: 1.35; }
  .sub-btn .sub-n { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: #e2e8f0; color: #475569; flex-shrink: 0; }
  .sub-btn.on .sub-n { background: rgba(255, 255, 255, 0.28); color: #fff; }
  .pin-chip { background: var(--navy); border-radius: 10px; }
  .dropzone { border-radius: 16px; background: #f9f6ef; border-color: #c4d2f2; }
  .dropzone:hover, .dropzone.dragover { background: var(--brand-soft); border-color: var(--brand); }

  /* ---------- sign-in screens ---------- */
  .auth-screen { background: radial-gradient(900px 500px at 0% 0%, var(--brand-soft) 0%, transparent 60%), radial-gradient(800px 500px at 100% 100%, #d9f4e8 0%, transparent 55%), var(--bg); padding: 28px 18px; }
  .auth-card { max-width: 440px; border: 1px solid var(--line); border-top: 0; border-radius: 24px; padding: 34px 30px 28px; box-shadow: var(--shadow-lg); position: relative; overflow: hidden; }
  .auth-card::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 6px; background: linear-gradient(90deg, var(--brand), #0f9d6c); }
  .auth-card .site-brand { margin-bottom: 22px; }
  .auth-card h1, .auth-card h2 { font-size: 24px; color: var(--navy); }
  .auth-card .auth-eyebrow { color: var(--brand); font-weight: 700; font-size: 12.5px; }
  .auth-card label { color: #3c4a63; }
  .auth-card #login-submit, .auth-card #setup-submit, .auth-card .btn-block { min-height: 50px; font-size: 16.5px; border-radius: 14px; }
  .big-input { font-size: 22px !important; letter-spacing: .08em; text-align: center; border-radius: 14px; min-height: 56px; }
  .auth-card .back-link { color: var(--muted); margin-top: 18px; }

  /* ---------- landing ---------- */
  .portal-page { border-top: 0; background: radial-gradient(1100px 560px at 85% -10%, var(--brand-soft) 0%, transparent 60%), radial-gradient(900px 500px at -10% 110%, #d9f4e8 0%, transparent 55%), var(--bg); }
  .portal-intro h1 { color: var(--navy); }
  .role-entry { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 22px 24px; margin-bottom: 14px; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s, border-color .15s; }
  .role-entry:last-of-type { border-bottom: 1px solid var(--line); }
  .role-entry:hover { background: #fff; transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: #b2c3ee; color: var(--ink); text-decoration: none; }
  .entry-number { display: none; }
  .entry-copy strong { color: var(--navy); font-size: 22px; }
  .entry-arrow { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-size: 20px; }
  .note-rule { background: var(--accent); }

  /* ---------- student: home ---------- */
  .topbar { background: linear-gradient(135deg, var(--navy) 0%, var(--brand-dark) 60%, var(--brand) 120%); box-shadow: 0 8px 28px rgba(40, 30, 15, .25); }
  .topbar-in { max-width: 820px; padding: 22px 18px; }
  .topbar-name { font-size: 22px; letter-spacing: -.005em; }
  .topbar-sub { opacity: .8; }
  #view-home .wrap { max-width: 820px; padding-top: 22px; }
  .section-title { font-size: 18px; color: var(--navy); margin: 26px 0 12px; display: flex; align-items: center; gap: 10px; }
  .section-title::before { content: ''; width: 5px; height: 20px; border-radius: 3px; background: var(--accent); }
  .exam-card, .score-card { border-radius: 18px; padding: 18px 20px; border: 1px solid var(--line); border-left: 5px solid #cbd5e8; box-shadow: var(--shadow); }
  .exam-card.is-open { border-left: 5px solid var(--good); box-shadow: 0 0 0 3px rgba(15, 157, 108, .12), var(--shadow); }
  .exam-title { color: var(--navy); font-size: 18px; }
  .pin-input { border-radius: 12px; }
  .score-big { color: var(--navy); }
  .year-card { border-radius: 18px; border-color: #cfdcf8; background: linear-gradient(160deg, #fff, #f1f6ff); }
  .year-sum-tile { border-radius: 16px; background: linear-gradient(135deg, var(--navy), var(--brand)); }
  .year-sum-tile.alt { background: linear-gradient(135deg, #0b6b49, #0f9d6c); }
  .year-step { border-radius: 14px; }

  /* ---------- student: exam ---------- */
  #view-test { background: var(--bg); min-height: 100vh; }
  .timer { background: rgba(255, 255, 255, .94); border-bottom: 1px solid var(--line); box-shadow: 0 4px 18px rgba(40, 30, 15, .07); padding: 12px 18px; }
  .timer-title { color: var(--navy); font-size: 17px; }
  .timer-clock { background: var(--navy); color: #fff; border-radius: 12px; padding: 5px 14px; font-size: 20px; letter-spacing: .03em; }
  .timer.low .timer-clock { background: var(--bad); color: #fff; }
  .progress { height: 8px; background: #e7e1d4; margin: 6px 0 12px; }
  .progress-fill { background: linear-gradient(90deg, var(--brand), #0f9d6c); }
  .reader-tools button { min-width: 44px; background: #fff; }
  .question-card { border-radius: 20px; padding: 26px; box-shadow: var(--shadow); border: 1px solid var(--line); }
  .writing-card { border-left: 6px solid var(--accent); }
  .q-count { color: var(--brand); font-size: 14px; letter-spacing: .01em; }
  .q-stem { color: var(--navy); font-weight: 500; }
  .radio-list { gap: 12px; }
  .radio-opt { border: 2px solid var(--line); border-radius: 16px; padding: 14px 16px; min-height: 64px; background: #fff; transition: border-color .12s, background .12s, transform .08s, box-shadow .12s; }
  .radio-opt:hover { border-color: #aebfe9; background: #f8faff; }
  .radio-opt:active { transform: scale(.995); }
  .radio-opt.selected { border-color: var(--brand); background: #eef3ff; box-shadow: 0 0 0 4px rgba(107, 99, 224, .13); }
  .radio-opt.selected::after { content: '✓'; margin-left: auto; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: #fff; font-weight: 800; font-size: 14px; flex: none; }
  .opt-letter { width: 38px; height: 38px; border-radius: 12px; background: #f0ece3; color: #4a5872; font-size: 16px; }
  .radio-opt.selected .opt-letter { background: var(--brand); color: #fff; }
  .question-nav { gap: 7px; }
  .question-nav button { width: 42px; height: 42px; min-width: 42px; min-height: 42px; border-radius: 12px; background: #fff; color: var(--ink); border: 1.5px solid #dcd6c8; box-shadow: none; font-weight: 700; }
  .question-nav button:hover { background: var(--brand-soft); box-shadow: none; }
  .question-nav button.answered { background: var(--good-soft); border-color: #86d9b9; color: #0b7a54; }
  .question-nav button.current { background: var(--brand); border-color: var(--brand); color: #fff; outline: none; box-shadow: 0 0 0 4px rgba(107, 99, 224, .2); }
  .question-nav button.writing { width: auto; padding: 0 10px; background: #fff3d6; border-color: #efce77; color: #8a5a0d; }
  .question-nav button.writing.current { background: #f5a623; color: #fff; border-color: #f5a623; }
  .flag-btn { border-radius: 10px; box-shadow: none; min-height: 36px; background: #fff; color: var(--muted); border: 1.5px solid var(--line); }
  .save-status { border-radius: 99px; }
  #submit-btn { min-height: 48px; padding-inline: 28px; border-radius: 14px; font-size: 16px; }

  @media (min-width: 1000px) {
    /* exam: question list on the left, the question on the right */
    #view-test > .wrap { max-width: 1120px; display: grid; grid-template-columns: 250px minmax(0, 1fr); column-gap: 24px; align-items: start; grid-template-areas: "tools tools" "prog prog" "nav main" "nav sub"; }
    #view-test .reader-tools { grid-area: tools; }
    #view-test .progress { grid-area: prog; }
    #view-test .question-nav { grid-area: nav; position: sticky; top: 92px; align-content: flex-start; max-height: calc(100vh - 120px); overflow: auto; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 18px; margin: 0; }
    #view-test #question-area { grid-area: main; }
    #view-test > .wrap > .row { grid-area: sub; justify-content: flex-start; }
    #view-test .question-nav button { width: 38px; height: 38px; min-width: 38px; min-height: 38px; font-size: 14px; }
  }
  @media (max-width: 999px) {
    /* phone / tablet: the list becomes one swipeable strip so the question stays in view */
    #view-test .question-nav { flex-wrap: nowrap; overflow-x: auto; padding: 4px 2px 10px; margin: 4px -2px 12px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    #view-test .question-nav::-webkit-scrollbar { display: none; }
    #view-test .question-nav button { flex: none; scroll-snap-align: center; }
    #view-test .question-card { padding: 20px 18px; }
    #view-test > .wrap { padding-inline: 14px; }
  }

  /* Sidebar stays on screen, including the narrow preview. Only a very small phone uses the bottom bar. */
  @media (min-width: 400px) {
    body.teacher-body:not(.teach-mode) {
      background:
        radial-gradient(820px 420px at 0% -8%, #efe6ff 0%, transparent 58%),
        radial-gradient(720px 460px at 100% 0%, #e5efff 0%, transparent 52%),
        #f3f0fa;
    }
    body.teacher-body:not(.teach-mode) #view-dashboard {
      display: block;
      margin: 12px 12px 12px 212px;
      padding: 6px 18px 36px;
      max-width: none;
      min-height: calc(100vh - 24px);
      background: #f7f8fc;
      border-radius: 0 26px 26px 0;
      box-shadow: 0 18px 50px rgba(80, 60, 140, .08);
      transition: margin-left .28s cubic-bezier(.22, 1, .36, 1), border-radius .28s ease;
    }
    body.teacher-body.sidebar-collapsed:not(.teach-mode) #view-dashboard {
      margin-left: 12px;
      border-radius: 26px;
    }
    body.teacher-body:not(.teach-mode) #teach-stage { display: block; overflow: visible; }
    body.teacher-body:not(.teach-mode) .nav-toggle { display: none; }
    body.teacher-body:not(.teach-mode) .frame-logo { display: none; }
    body.teacher-body:not(.teach-mode) .dashboard-header {
      position: sticky;
      top: 0;
      z-index: 30;
      margin: 0;
      padding: 16px 8px 8px;
      background: transparent;
      border-bottom: 0;
      flex-direction: row;
      align-items: center;
    }
    body.teacher-body:not(.teach-mode) .dh-bar { flex: 1; }
    .dh-left {
      display: flex;
      align-items: center;
      gap: 12px;
      min-width: 0;
    }
    .sidebar-toggle-btn {
      width: 40px;
      height: 40px;
      min-height: 40px !important;
      padding: 0 !important;
      border-radius: 12px !important;
      background: #ffffff !important;
      color: var(--navy) !important;
      border: 1.5px solid #e2def5 !important;
      box-shadow: 0 2px 8px rgba(80, 60, 140, .06) !important;
      display: inline-grid;
      place-items: center;
      flex: none;
      cursor: pointer;
    }
    .sidebar-toggle-btn:hover {
      background: var(--brand-soft) !important;
      color: var(--brand-dark) !important;
      border-color: var(--brand) !important;
    }
    .sidebar-toggle-btn .sb-chevron {
      transform-origin: 13.5px 12px;
      transition: transform .25s ease;
    }
    body.sidebar-collapsed .sidebar-toggle-btn .sb-chevron {
      transform: rotate(180deg);
    }
    body.teach-mode .sidebar-toggle-btn,
    body.test-mode .sidebar-toggle-btn {
      display: none;
    }
    .sidebar-edge-tab {
      position: fixed;
      left: 0;
      top: 96px;
      z-index: 45;
      display: inline-flex;
      align-items: center;
      gap: 4px;
      min-height: 40px !important;
      padding: 6px 12px 6px 8px !important;
      border-radius: 0 999px 999px 0 !important;
      background: var(--brand-grad) !important;
      color: #ffffff !important;
      border: 0 !important;
      box-shadow: 0 8px 20px rgba(82, 73, 198, .32) !important;
      font-size: 13px !important;
      font-weight: 700 !important;
      transform: translateX(-110%);
      opacity: 0;
      pointer-events: none;
      transition: transform .26s cubic-bezier(.22, 1, .36, 1), opacity .2s ease;
    }
    body.teacher-body.sidebar-collapsed:not(.teach-mode):not(.test-mode) .sidebar-edge-tab {
      transform: translateX(0);
      opacity: 1;
      pointer-events: auto;
    }
    body.teacher-body:not(.teach-mode) #dashboard-content { min-width: 0; }
    body.teacher-body:not(.teach-mode) .teacher-navigation {
      position: fixed;
      left: 12px;
      top: 12px;
      bottom: 12px;
      z-index: var(--z-nav);
      display: flex;
      flex-direction: column;
      width: 200px;
      height: calc(100vh - 24px);
      margin: 0;
      padding: 18px 12px 14px;
      gap: 2px;
      background: #fff;
      border-right: 1px solid #eef0f6;
      border-radius: 26px 0 0 26px;
      box-shadow: none;
      overflow-x: hidden;
      overflow-y: auto;
      scrollbar-width: thin;
      scrollbar-color: #c5cbe0 transparent;
      transition: transform .28s cubic-bezier(.22, 1, .36, 1), opacity .22s ease;
    }
    body.teacher-body.sidebar-collapsed:not(.teach-mode) .teacher-navigation {
      transform: translateX(calc(-100% - 20px));
      opacity: 0;
      pointer-events: none;
    }
    body.teacher-body:not(.teach-mode) .teacher-navigation::-webkit-scrollbar { width: 8px; }
    body.teacher-body:not(.teach-mode) .teacher-navigation::-webkit-scrollbar-track { background: transparent; margin: 12px 0; }
    body.teacher-body:not(.teach-mode) .teacher-navigation::-webkit-scrollbar-thumb {
      background: #c5cbe0;
      border-radius: 99px;
      border: 2px solid #fff;
    }
    .nav-brand-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 6px;
      margin: 2px 4px 14px 6px;
    }
    body.teacher-body:not(.teach-mode) .teacher-navigation .site-brand {
      display: flex;
      color: var(--navy);
      margin: 0;
      min-width: 0;
      flex: 1;
    }
    body.teacher-body:not(.teach-mode) .teacher-navigation button.sidebar-hide-btn {
      width: 32px;
      height: 32px;
      min-height: 32px;
      padding: 0;
      border-radius: 10px;
      justify-content: center;
      flex: none;
      color: #64748b;
      background: #f8fafc;
      border: 1px solid #e2e8f0;
    }
    body.teacher-body:not(.teach-mode) .teacher-navigation button.sidebar-hide-btn:hover {
      background: var(--brand-soft);
      color: var(--brand-dark);
      border-color: #c7d2fe;
    }
    body.teacher-body:not(.teach-mode) .teacher-navigation .brand-caption { color: #8b95a8; }
    body.teacher-body:not(.teach-mode) .nav-caption {
      display: block;
      color: #8b95a8;
      margin: 14px 12px 4px;
      text-align: left;
      font-size: 11px;
    }
    body.teacher-body:not(.teach-mode) .nav-art { display: none; }
    body.teacher-body:not(.teach-mode) .nav-home {
      display: block;
      margin-top: auto;
      padding: 12px 12px 4px;
      color: #64748b;
      text-align: left;
    }
    body.teacher-body:not(.teach-mode) .teacher-navigation button {
      width: 100%;
      max-width: none;
      min-height: 42px;
      flex-direction: row;
      justify-content: flex-start;
      align-items: center;
      gap: 10px;
      padding: 7px 10px;
      border-radius: 12px;
      background: transparent;
      color: #334155;
      border: 0;
      box-shadow: none;
      font-size: 14px;
      font-weight: 600;
      text-align: left;
      line-height: 1.35;
    }
    body.teacher-body:not(.teach-mode) .teacher-navigation button:hover {
      transform: none;
      background: #f4f7fb;
      color: #1e293b;
      box-shadow: none;
    }
    body.teacher-body:not(.teach-mode) .teacher-navigation button.active {
      background: #f1f0ff;
      color: #4338ca;
      border-color: transparent;
      box-shadow: none;
      font-weight: 700;
    }
    body.teacher-body:not(.teach-mode) .teacher-navigation button .ui-icon {
      width: 20px;
      height: 20px;
      padding: 0;
      border-radius: 0;
      background: transparent;
      color: #8b93a7;
      stroke: currentColor;
    }
    body.teacher-body:not(.teach-mode) .teacher-navigation button.active .ui-icon { color: #5b4dff; }
    body.teacher-body:not(.teach-mode) #dashboard-content .card {
      border-radius: 22px;
      border-color: #eef0f6;
      box-shadow: 0 10px 28px rgba(70, 80, 140, .05);
    }
    #tab-classes > .card .list-item {
      border: 1px solid #e6eef8;
      border-radius: 16px;
      padding: 14px 16px;
      margin: 10px 0;
      background: #f8fbff;
    }
    #tab-classes > .card .list-item:last-child { border-bottom: 1px solid #e6eef8; }
  }
  .frame-logo-mark {
    width: 40px; height: 40px; border-radius: 13px;
    display: grid; place-items: center;
    background: var(--brand-grad);
    color: #fff; font: 700 22px Georgia, serif;
    box-shadow: 0 8px 18px rgba(107, 99, 224, .35);
  }
  .frame-logo-name { font-size: 20px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; color: var(--brand); }
  .frame-logo-name span { color: var(--navy); }

  /* ---------- phone: bottom bar + menu sheet ---------- */
  .bottom-bar, .sheet-scrim { display: none; }
  @media (max-width: 399px) {
    body.teacher-body { padding-bottom: 78px; }
    #view-dashboard { margin: 0; padding: 0 14px 40px; }
    .dashboard-header { margin: 0 -14px 14px; padding: 10px 14px; flex-direction: row; align-items: center; gap: 10px; }
    .dashboard-header h1 { font-size: 19px; }
    .dashboard-header .eyebrow, .dashboard-header .muted { display: none; }
    .dashboard-actions { max-width: none; }
    .dashboard-actions .help-link span { display: none; }
    .dashboard-actions .help-link { padding: 6px 11px; }
    .user-name, .caret { display: none; }
    .user-chip { padding: 3px; }
    .mode-switch-label { display: none; }
    .mode-switch { padding: 4px 6px; min-height: 36px; }
    body.teach-mode { padding-bottom: 12px; }
    body.teach-mode #view-dashboard { margin: 0; padding: 0 14px 40px; }
    .teach-desk { grid-template-columns: 1fr; }
    .teach-hero { padding: 22px 20px; }
    .teach-hero h2 { font-size: 26px; }
    .teach-hero-mark { width: 68px; height: 68px; font-size: 30px; border-radius: 20px; }
    .nav-toggle { display: none; }
    .bottom-bar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; background: rgba(255, 255, 255, .97); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 24px rgba(40, 30, 15, .08); }
    .bottom-bar[hidden] { display: none; }
    .bottom-bar button { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 54px; padding: 6px 2px; border-radius: 14px; background: transparent; color: var(--muted); font-size: 11.5px; font-weight: 600; border: 0; box-shadow: none; line-height: 1.3; }
    .bottom-bar button:hover { background: transparent; box-shadow: none; }
    .bottom-bar button .ui-icon { width: 24px; height: 24px; }
    .bottom-bar button.on { color: var(--brand); background: var(--brand-soft); }
    .teacher-navigation { display: none; position: fixed; left: 10px; right: 10px; bottom: 84px; top: auto; width: auto; max-height: 72vh; height: auto; border-radius: 22px; padding: 14px 12px 12px; z-index: 70; background: #fff; box-shadow: var(--shadow-lg); border: 1px solid var(--line); overflow: auto; margin: 0; gap: 4px; }
    .teacher-navigation.is-open { display: grid; grid-template-columns: 1fr 1fr; animation: ui2pop .2s ease; }
    .teacher-navigation .site-brand, .nav-brand-row, .sidebar-toggle-btn, .sidebar-edge-tab, .nav-art { display: none; }
    .nav-caption { grid-column: 1 / -1; color: var(--muted); margin: 8px 8px 2px; text-align: left; }
    .teacher-navigation button { flex-direction: row; justify-content: flex-start; text-align: left; color: var(--ink); background: #f5f7fc; border-radius: 14px; padding: 10px 12px; font-size: 13.5px; min-height: 52px; gap: 10px; }
    .teacher-navigation button .ui-icon { width: 20px; height: 20px; }
    .teacher-navigation button:hover { background: var(--brand-soft); color: var(--brand-dark); }
    .teacher-navigation button.active { background: var(--brand-soft); color: var(--brand-dark); box-shadow: inset 0 0 0 2px rgba(107, 99, 224, .4); }
    .nav-home { grid-column: 1 / -1; color: var(--muted); margin: 6px 8px 0; }
    .sheet-scrim { position: fixed; inset: 0; z-index: 65; background: rgba(40, 30, 15, .35); }
    body.sheet-open .sheet-scrim { display: block; }
    .up-top { padding: 10px 12px; }
    .up-toggle { width: 100%; }
    .test-card { padding: 14px; }
  }
  @media (max-width: 600px) {
    .auth-card { padding: 28px 22px 24px; border-radius: 22px; }
    .card { padding: 16px; border-radius: 14px; }
    .topbar-in { padding: 18px 16px; }
    .exam-card, .score-card { padding: 16px; }
    .question-card { border-radius: 16px; }
    .radio-opt { padding: 12px 14px; min-height: 60px; }
    .timer { padding: 10px 14px; }
    .timer-clock { font-size: 18px; padding: 4px 10px; }
  }

  @media (max-width: 999px) {
    /* previous / next stay within thumb reach while reading a long question */
    #view-test #question-area > .row:last-child { position: sticky; bottom: 0; z-index: 4; margin: 10px -14px 0 !important; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(180deg, rgba(243, 245, 250, 0), var(--bg) 30%); justify-content: space-between; }
    #view-test #question-area > .row:last-child button { min-height: 50px; padding-inline: 22px; font-size: 16px; }
    .up-use { display: none; }
    .up-card.open .up-use { display: flex; }
  }

  .topbar-who { display: flex; align-items: center; gap: 14px; min-width: 0; }
  .topbar-avatar { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; background: rgba(255, 255, 255, .18); border: 1.5px solid rgba(255, 255, 255, .35); font-weight: 800; font-size: 22px; flex: none; }
  .year-card > summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
  .year-card > summary::-webkit-details-marker { display: none; }
  .year-card > summary::after { content: '▾'; color: var(--brand); margin-left: auto; transition: transform .15s; }
  .year-card:not([open]) > summary::after { transform: rotate(-90deg); }
  .year-card[open] > summary { margin-bottom: 12px; }
  .year-sum-tile.is-empty, .year-sum-tile.alt.is-empty { background: #ece7dc; color: var(--muted); }

  body .pw-wrap button.pw-eye { box-shadow: none; background: transparent; background-image: none; min-height: 36px; padding: 0; border: 0; color: var(--muted); }
  body .pw-wrap button.pw-eye:hover { background: var(--brand-soft); background-image: none; box-shadow: none; }

  .nav-caption { color: var(--muted); }
  /* landing: a quiet maths motif behind the headline */
  .portal-intro { position: relative; }
  .portal-intro::before { content: '∑  π  √  ÷'; position: absolute; left: -10px; top: -78px; font: 700 64px Georgia, serif; letter-spacing: .15em; color: rgba(107, 99, 224, .09); pointer-events: none; white-space: nowrap; }
  .portal-intro h1 { background: linear-gradient(120deg, var(--navy) 30%, var(--brand) 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
  @media (max-width: 600px) { .portal-intro::before { font-size: 40px; top: -48px; } }

  /* math keyboard: the basic keys, then a drawer of more symbols in tabs */
  .mathbar { border-radius: 14px; background: #f3efe7; border-color: var(--line); padding: 8px; gap: 6px; }
  .mk { border-radius: 10px; min-height: 38px; background: #fff; box-shadow: 0 1px 2px rgba(40, 30, 15, .08); border-color: #dde4f2; }
  .mk:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); box-shadow: 0 2px 6px rgba(107, 99, 224, .18); }
  .mk-morebtn { margin-left: auto; font-weight: 700; color: var(--brand-dark); padding-inline: 14px; }
  .mk-morebtn.on { background: var(--brand); color: #fff; border-color: var(--brand); }
  .mk-more { flex-basis: 100%; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px; margin-top: 4px; }
  .mk-more[hidden] { display: none; }
  .mk-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
  .mk-tab { min-height: 34px; padding: 4px 13px; border-radius: 99px; background: #f3efe7; color: #4a5872; border: 1.5px solid transparent; box-shadow: none; font-size: 13.5px; font-weight: 600; }
  .mk-tab:hover { background: var(--brand-soft); box-shadow: none; }
  .mk-tab.on { background: var(--brand); color: #fff; }
  .mk-grid { display: flex; flex-wrap: wrap; gap: 6px; max-height: 190px; overflow: auto; }
  .mk-tex { min-width: 46px; height: 44px; padding: 0 10px; font-size: 15px; }
  .mk-tex .katex { font-size: 1.05em; }

  @media (max-width: 700px) {
    /* lists of exams / sessions: text on top, buttons underneath at full width */
    #dashboard-content .list-item { flex-direction: column; align-items: stretch; gap: 10px; }
    #dashboard-content .list-item > .row, #dashboard-content .list-item > div:last-child:not(:first-child) { justify-content: flex-start; flex-wrap: wrap; }
    #dashboard-content .list-item button { flex: 1 1 auto; }
  }

  /* ---------- student hub: lessons, formulas, PISA, games ---------- */
  .hub { margin-top: 8px; }
  .hub-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
  .hub-tile { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 18px 18px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; overflow: hidden; }
  .hub-tile::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 5px; background: var(--tone, var(--brand)); }
  .hub-tile.blue { --tone: var(--brand); --soft: #eceffd; } .hub-tile.teal { --tone: #1c9a74; --soft: #e1f5ec; }
  .hub-tile.amber { --tone: #f2a53b; --soft: #fff1d6; } .hub-tile.violet { --tone: #8a63d2; --soft: #f0eafb; } .hub-tile.rose { --tone: #d6577a; --soft: #fdeaf0; }
  .hub-ico { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; font-size: 26px; background: var(--soft, var(--brand-soft)); }
  .hub-t { font-weight: 700; font-size: 17px; color: var(--navy); line-height: 1.5; margin-top: 4px; }
  .hub-d { color: var(--muted); font-size: 14px; line-height: 1.65; flex: 1; }
  .hub-a { margin-top: 8px; }
  .hub-a .btn { width: 100%; text-align: center; background: var(--tone); border-color: var(--tone); box-shadow: none; }
  .hub-tile.soon { opacity: .75; background: #fbf9f4; }
  .game-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .game-tile { position: relative; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; text-align: left; min-height: 210px; padding: 0; border-radius: 20px; overflow: hidden; background: var(--navy); color: #fff; border: 0; box-shadow: var(--shadow); isolation: isolate; }
  .game-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; transition: transform .35s; }
  .game-tile::after { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(29, 37, 64, 0) 5%, rgba(29, 37, 64, .93) 82%); }
  .game-tile:hover img { transform: scale(1.06); }
  .game-tile:hover { box-shadow: var(--shadow-lg); }
  .game-ico { position: absolute; top: 12px; left: 14px; font-size: 26px; background: rgba(255, 255, 255, .9); width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; }
  .game-name { text-shadow: 0 1px 6px rgba(0,0,0,.45); font-size: 20px; font-weight: 800; padding: 0 16px; line-height: 1.5; }
  .game-desc { font-size: 13px; opacity: .88; padding: 0 16px; line-height: 1.55; }
  .game-go { margin: 10px 16px 14px; background: var(--accent); color: #3a2200; font-weight: 800; font-size: 14px; border-radius: 99px; padding: 4px 16px; }
  @media (max-width: 700px) { .game-grid { grid-template-columns: 1fr; } .game-tile { min-height: 150px; } }

  /* game launcher */
  .gm-box { text-align: left; max-width: 480px; }
  .gm-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
  .gm-ico { width: 52px; height: 52px; border-radius: 18px; display: grid; place-items: center; font-size: 28px; background: var(--brand-soft); flex: none; }
  .gm-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: #f3efe6; border-radius: 16px; padding: 5px; margin-bottom: 14px; }
  .gm-seg button, .gm-chips button { box-shadow: none; background: transparent; color: #4a5872; border: 0; min-height: 44px; border-radius: 12px; font-size: 15px; }
  .gm-seg button.on { background: #fff; color: var(--brand-dark); box-shadow: 0 1px 4px rgba(40, 30, 15, .15); }
  .gm-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0; font-weight: 600; color: var(--ink); }
  .gm-chips { display: flex; gap: 6px; }
  .gm-chips button { min-width: 46px; background: #fff; border: 1.5px solid var(--line); }
  .gm-chips button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
  .gm-names { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
  @media (max-width: 480px) { .gm-names { grid-template-columns: 1fr; } }

  @media (min-width: 701px) { .hub-grid { grid-template-columns: repeat(3, 1fr); } }

  @media (max-width: 700px) {
    .hub-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .hub-tile { padding: 14px 12px 12px; border-radius: 18px; }
    .hub-ico { width: 40px; height: 40px; font-size: 22px; border-radius: 13px; }
    .hub-t { font-size: 15px; }
    .hub-d { font-size: 12.5px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
    .hub-a .btn { font-size: 13px; padding: 8px 6px; min-height: 40px; }
  }

  /* ---------- phone: dialogs and edit forms ---------- */
  @media (max-width: 700px) {
    .modal-back { padding: 0; }
    .modal-box { border-radius: 22px 22px 0 0; padding: 20px 16px calc(16px + env(safe-area-inset-bottom)); max-width: none; }
    .modal-box[style*="margin:20px auto"] { margin: 12px 0 0 !important; width: 100%; min-height: 60vh; }
    .modal-box h2 { font-size: 19px; }
    .modal-box select, .modal-box input[type=text], .modal-box input[type=number], .modal-box input[type=date], .modal-box textarea { width: 100% !important; }
    .modal-box > .row:not(:last-child), .modal-box > div > .row:not(:last-child) { flex-direction: column; align-items: stretch; gap: 4px; }
    .modal-box .row > div, .modal-box .row > label { width: 100%; min-width: 0; flex: none; }
    .modal-box label { margin-top: 14px; }
    .modal-box label:has(> input[type=checkbox]) { display: flex; gap: 12px; align-items: center; min-height: 48px; padding: 8px 12px; border-radius: 14px; background: #f6f2ea; font-weight: 600; margin-top: 12px; }
    .modal-box label:has(> input[type=checkbox])[style*="a52a2a"] { background: #fdeceb; }
    .modal-box input[type=checkbox] { width: 22px; height: 22px; flex: none; accent-color: var(--brand); }
    .modal-box > .row:last-child { position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom)); z-index: 3; margin: 18px -16px calc(-16px - env(safe-area-inset-bottom)) !important; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -8px 20px rgba(40, 30, 15, .06); justify-content: stretch; }
    .modal-box > .row:last-child button { flex: 1; min-height: 48px; }
    .mathbar { gap: 5px; padding: 6px; }
    .mk { min-width: 40px; height: 40px; }
    .mk-morebtn { margin-left: 0; flex-basis: 100%; }
  }

  input[type=file] { width: 100%; padding: 8px; border: 1.5px dashed #cfc7b4; border-radius: 12px; background: #faf7f0; font-family: inherit; font-size: 14px; color: var(--muted); }
  input[type=file]::file-selector-button { margin-right: 12px; border: 0; border-radius: 10px; background: var(--brand); color: #fff; padding: 9px 16px; font-weight: 600; font-family: inherit; cursor: pointer; }
  input[type=file]::file-selector-button:hover { background: var(--brand-dark); }
  .modal-box input[type=text] { margin-bottom: 6px; }

  .gm-lessons { margin: 14px 0 4px; }
  .gm-chips.wrap { flex-wrap: wrap; max-height: 190px; overflow: auto; padding: 2px; }
  .gm-lessons .gm-chips button { display: flex; flex-direction: column; align-items: flex-start; text-align: left; min-height: 44px; padding: 5px 12px; line-height: 1.35; font-size: 14px; }
  .gm-lessons .gm-chips button small { font-size: 11.5px; font-weight: 500; opacity: .8; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .gm-lessons .gm-chips button.on small { opacity: .95; }
  .gm-box { max-height: 92vh; overflow: auto; }

  /* ---------- in-page reader (lessons, formulas, PISA practice) ---------- */
  #view-reader { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; background: #fff; }
  #view-reader[hidden] { display: none; }
  .rd-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top)); background: linear-gradient(135deg, var(--navy), #2d4aa8); color: #fff; box-shadow: 0 4px 16px rgba(40, 30, 15, .2); flex: none; }
  .rd-bar button { min-height: 40px; box-shadow: none; }
  .rd-back { background: rgba(255, 255, 255, .16); border: 1.5px solid rgba(255, 255, 255, .4); color: #fff; }
  .rd-back:hover { background: rgba(255, 255, 255, .28); box-shadow: none; }
  button.rd-home { background: transparent; background-image: none; color: #fff; border: 1.5px solid rgba(255, 255, 255, .4); width: 44px; padding: 0; font-size: 20px; box-shadow: none; }
  .rd-title { flex: 1; min-width: 0; font-weight: 700; font-size: 16px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .rd-wrap { position: relative; flex: 1; min-height: 0; }
  .rd-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
  .rd-loading { position: absolute; left: 0; right: 0; top: 0; z-index: 2; padding: 6px 12px; text-align: center; font-size: 13px; font-weight: 600; color: #7a5a14; background: #fff4d6; border-bottom: 1px solid #f1d28a; pointer-events: none; }
  .rd-loading[hidden] { display: none; }

  /* geometric constructions picker */
  #view-construct { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; background: var(--bg); }
  #view-construct[hidden] { display: none; }
  .ct-body { flex: 1; overflow: auto; padding: 16px 14px 40px; max-width: 820px; width: 100%; margin: 0 auto; -webkit-overflow-scrolling: touch; }
  .ct-wait { text-align: center; color: var(--muted); padding: 40px 0; }
  .ct-lesson { background: #fff; border: 1px solid var(--line); border-radius: 18px; margin-bottom: 10px; box-shadow: var(--shadow); overflow: hidden; }
  .ct-lesson > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px; padding: 14px 16px; font-size: 15.5px; color: var(--navy); }
  .ct-lesson > summary::-webkit-details-marker { display: none; }
  .ct-lesson > summary::after { content: '▾'; color: var(--brand); margin-left: 10px; transition: transform .15s; }
  .ct-lesson:not([open]) > summary::after { transform: rotate(-90deg); }
  .ct-lt { color: var(--muted); font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ct-n { margin-left: auto; font-size: 12.5px; background: var(--brand-soft); color: var(--brand-dark); border-radius: 99px; padding: 2px 10px; font-weight: 700; white-space: nowrap; }
  .ct-lesson > summary b + .ct-n { margin-left: auto; }
  .ct-list { border-top: 1px solid var(--line); }
  .ct-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: transparent; color: var(--ink); border: 0; border-bottom: 1px solid #f0ece2; border-radius: 0; box-shadow: none; padding: 12px 16px; min-height: 52px; font-weight: 500; font-size: 15px; line-height: 1.55; }
  .ct-item:last-child { border-bottom: 0; }
  .ct-item:hover { background: #f8f6ff; box-shadow: none; }
  .ct-t { flex: 1; min-width: 0; }
  .ct-go { color: var(--brand); font-weight: 800; }
  .ct-gen { border-style: dashed; }

  /* exercise-book download panel (question bank) */
  .ex-lhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
  .ex-lhead .on { background: var(--brand); color: #fff; border-color: var(--brand); }
  .ex-lessons { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px; max-height: 260px; overflow: auto; padding: 4px; margin-top: 6px; border: 1px solid var(--line); border-radius: 14px; background: #faf7f0; }
  .ex-l { display: flex; align-items: center; gap: 8px; text-align: left; min-height: 44px; padding: 6px 10px; border-radius: 12px; background: #fff; color: var(--ink); border: 1.5px solid var(--line); box-shadow: none; font-weight: 500; font-size: 13.5px; line-height: 1.35; }
  .ex-l b { flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: #efeae0; font-size: 13px; }
  .ex-l .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .ex-l small { flex: none; color: var(--muted); font-size: 11.5px; }
  .ex-l.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }
  .ex-l.on b { background: var(--brand); color: #fff; }
  .ex-l.empty { opacity: .45; }
  .ex-l:hover { box-shadow: none; border-color: #b2c3ee; }
  .ex-chips { display: flex; gap: 6px; flex-wrap: wrap; }
  .ex-chips button { box-shadow: none; background: #fff; color: #4a5872; border: 1.5px solid var(--line); min-height: 40px; border-radius: 99px; padding: 6px 16px; font-size: 14px; }
  .ex-chips button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
  .ex-chk { display: flex; align-items: center; gap: 10px; margin-top: 12px; color: var(--ink); }
  .ex-sum { margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: var(--brand-soft); color: var(--brand-dark); line-height: 1.7; }
  .ex-sum.none { background: #fdeceb; color: #8f1d1d; }
  .ex-actions { justify-content: flex-end; margin-top: 16px; gap: 8px; }
}


/* ---------- Question Viewer Modal (Mobile & Desktop Responsive) ---------- */
.modal-box:has(.question-viewer) {
  padding: 0;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  background: #ffffff;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
}

.question-viewer {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 90vh;
  overflow: hidden;
  text-align: left;
}

/* 1. Header (Fixed Top) */
.qv-header {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px 12px;
  background: #ffffff;
  border-bottom: 1px solid #f1f5f9;
  z-index: 10;
  gap: 10px;
}
.qv-title-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.qv-title-text {
  font-size: 17.5px;
  font-weight: 700;
  color: var(--ink, #0f172a);
}
.qv-id-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 700;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1.5px solid #bfdbfe;
  border-radius: 999px;
  font-size: 13px;
  padding: 3px 10px;
  cursor: pointer;
  transition: all .15s ease;
  flex: none;
}
.qv-id-badge:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}
.qv-copy-icon {
  font-size: 11px;
  opacity: 0.85;
}

/* Carousel Navigation */
.qv-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 2px 6px;
}
.qv-nav-arrow {
  background: transparent;
  border: none;
  font-size: 12px;
  font-weight: 800;
  color: #2563eb;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 999px;
  min-height: 0;
  line-height: 1;
  transition: all 0.15s;
}
.qv-nav-arrow:hover:not(:disabled) {
  background: #e0e7ff;
}
.qv-nav-arrow:disabled {
  color: #cbd5e1;
  cursor: not-allowed;
}
.qv-nav-counter {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  padding: 0 4px;
  white-space: nowrap;
}

.qv-close-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: #475569;
  flex: none;
  padding: 0;
  transition: all .15s ease;
}
.qv-close-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* 2. Scrollable Body */
.qv-scroll-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  -webkit-overflow-scrolling: touch;
}

.qv-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
}
.qv-crumb-grade {
  color: #1d4ed8;
  background: #eff6ff;
  border-radius: 6px;
  padding: 2px 8px;
}
.qv-crumb-sep {
  color: #94a3b8;
}
.qv-crumb-lesson {
  color: #334155;
}
.qv-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* Stem Card */
.qv-stem-card {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid #e2e8f0;
  border-left: 4.5px solid #2563eb;
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.qv-stem-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.qv-stem-lbl {
  font-weight: 700;
  font-size: 13.5px;
  color: #1e40af;
}
.qv-copy-stem-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 11.5px;
  color: #475569;
  padding: 3px 8px;
  cursor: pointer;
  font-weight: 600;
  min-height: 0;
  transition: all 0.15s;
}
.qv-copy-stem-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}
.qv-stem-text {
  font-size: 16px;
  line-height: 1.75;
  font-weight: 600;
  color: #0f172a;
  word-break: break-word;
}

/* Image Card */
.qv-img-card {
  text-align: center;
  padding: 12px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}
.qv-img {
  max-height: 280px;
  max-width: 100%;
  object-fit: contain;
  display: inline-block;
  border-radius: 8px;
}
.qv-img-toolbar {
  margin-top: 10px;
  font-size: 12px;
  display: flex;
  justify-content: center;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.qv-img-key {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  color: #64748b;
  font-weight: 600;
}
.qv-img-zoom-link {
  color: #2563eb;
  text-decoration: none;
  font-weight: 600;
  font-size: 12px;
}

/* Choices Card */
.qv-choices-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.qv-choices-title {
  font-weight: 700;
  font-size: 14px;
  color: #475569;
}
.qv-choice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  transition: all 0.15s ease;
}
.qv-choice.is-correct {
  background: #f0fdf4;
  border-color: #22c55e;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.1);
}
.qv-choice.is-alt {
  background: #f0f9ff;
  border-color: #38bdf8;
}
.qv-letter {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  background: #f1f5f9;
  color: #334155;
  flex: none;
}
.qv-letter.is-correct {
  background: #16a34a;
  color: #ffffff;
  font-size: 14px;
}
.qv-letter.is-alt {
  background: #0284c7;
  color: #ffffff;
}
.qv-choice-text {
  flex: 1;
  min-width: 0;
  font-size: 15.5px;
  line-height: 1.55;
  color: #1e293b;
  word-break: break-word;
}
.qv-choice.is-correct .qv-choice-text {
  font-weight: 600;
  color: #15803d;
}
.qv-choice.is-alt .qv-choice-text {
  font-weight: 600;
  color: #0369a1;
}
.qv-choice-tag {
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 10px;
  flex: none;
}
.qv-choice-tag.correct {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}
.qv-choice-tag.alt {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

/* Solution / Explanation Card */
.qv-sol-card {
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.qv-sol-card.mcq {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 60%);
  border: 1px solid #fde68a;
  border-left: 5px solid #f59e0b;
}
.qv-sol-card.writing {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 60%);
  border: 1px solid #bfdbfe;
  border-left: 5px solid #3b82f6;
}
.qv-sol-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.qv-sol-icon {
  font-size: 18px;
}
.qv-sol-title {
  font-size: 14px;
  font-weight: 700;
  color: #92400e;
}
.qv-sol-card.writing .qv-sol-title {
  color: #1e40af;
}
.qv-sol-content {
  font-size: 14.5px;
  line-height: 1.7;
  color: #78350f;
  white-space: pre-line;
  word-break: break-word;
}
.qv-sol-card.writing .qv-sol-content {
  color: #1e3a8a;
}

/* 3. Fixed Footer Actions */
.qv-footer-actions {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 12px 18px calc(14px + env(safe-area-inset-bottom));
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.05);
  z-index: 10;
}
.qv-btn-edit {
  background: var(--brand);
  color: #ffffff;
  border: none;
  font-weight: 700;
  border-radius: 10px;
}
.qv-btn-copy, .qv-btn-close {
  font-weight: 600;
  border-radius: 10px;
}

@media (max-width: 640px) {
  .modal-box:has(.question-viewer) {
    border-radius: 22px 22px 0 0;
    margin: 8px 0 0 !important;
    max-height: 92vh;
    width: 100%;
    max-width: none;
  }
  .qv-header {
    padding: 12px 14px 10px;
  }
  .qv-title-text {
    font-size: 16px;
  }
  .qv-scroll-body {
    padding: 12px 14px 20px;
    gap: 12px;
  }
  .qv-footer-actions {
    padding: 10px 14px calc(14px + env(safe-area-inset-bottom));
    gap: 6px;
  }
  .qv-footer-actions button {
    flex: 1;
    min-height: 44px;
    font-size: 13.5px;
    padding: 6px;
    white-space: nowrap;
  }
  .qv-footer-actions .qv-btn-edit {
    flex: 1.25;
  }
  .qv-choice {
    flex-wrap: wrap;
    gap: 8px;
  }
  .qv-choice-tag {
    margin-left: 36px;
  }
}


/* ---------- Creating Test Loading Animation («កំពុងបង្កើតតេស្ត...») ---------- */
@keyframes kmSpin { to { transform: rotate(360deg); } }
@keyframes kmBarSlide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(240%); }
}
.km-spin-ico {
  animation: kmSpin .75s linear infinite;
  vertical-align: -0.22em;
  flex: none;
}
button.is-busy, .btn.is-busy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: .92 !important;
  cursor: progress;
}
.creating-test-scrim {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(31, 36, 51, .42);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 20px;
  animation: ui2fade .16s ease;
}
.creating-test-card {
  background: #ffffff;
  border: 1px solid #e2def5;
  border-radius: 24px;
  padding: 26px 28px 22px;
  min-width: min(360px, 90vw);
  max-width: 420px;
  box-shadow: 0 22px 60px rgba(43, 42, 92, .25);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  animation: ui2pop .22s cubic-bezier(.2, .9, .3, 1.15);
}
.creating-test-ring {
  width: 68px;
  height: 68px;
  border-radius: 22px;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1.5px #d6d1fb;
}
.creating-test-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.65;
}
.creating-test-sub {
  font-size: 13.5px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.65;
}
.creating-test-bar {
  width: 100%;
  height: 6px;
  border-radius: 99px;
  background: #ece9f8;
  overflow: hidden;
  margin-top: 2px;
}
.creating-test-bar-fill {
  width: 45%;
  height: 100%;
  border-radius: 99px;
  background: var(--brand-grad);
  animation: kmBarSlide 1.1s ease-in-out infinite;
}

/* ---------- Random Test Generator Card (🎲 បង្កើតតេស្តចៃដន្យពីធនាគារ) ---------- */
details.bank-gen {
  padding: 0;
  overflow: hidden;
  border: 1.5px solid #e2def5;
  background: linear-gradient(180deg, #ffffff 0%, #faf9ff 100%);
  transition: border-color .18s ease, box-shadow .18s ease;
}
details.bank-gen:hover {
  border-color: #c5bef2;
}
details.bank-gen[open] {
  border-color: var(--brand);
  box-shadow: 0 12px 32px rgba(107, 99, 224, .12);
}
.bank-gen-sum {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
}
.bank-gen-sum::-webkit-details-marker { display: none; }
.bank-gen-ic {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--brand-soft);
  border: 1px solid #dad5fa;
  display: grid;
  place-items: center;
  flex: none;
}
.bank-gen-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.bank-gen-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--navy);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}
.bank-gen-sub {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}
.bank-gen-total-pill {
  background: var(--brand-soft);
  color: var(--brand-dark);
  border: 1px solid #d4cffa;
  border-radius: 99px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 700;
  flex: none;
}
.bank-gen-chev {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #f3f1fb;
  color: var(--brand-dark);
  display: grid;
  place-items: center;
  font-size: 15px;
  transition: transform .2s ease, background .15s ease;
  flex: none;
}
details.bank-gen[open] .bank-gen-chev {
  transform: rotate(180deg);
  background: var(--brand);
  color: #fff;
}
.bank-gen-body {
  padding: 18px 20px 20px;
  border-top: 1px solid #ebe8f7;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.bank-gen-top {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(220px, 1fr);
  gap: 14px;
  align-items: end;
}
.bank-gen-field label {
  display: block;
  margin: 0 0 6px;
}
.bank-gen-levels {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.bank-gen-lvl {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1.5px solid #e6e3f4;
  background: #faf9fe;
  margin: 0;
}
.bank-gen-lvl-name {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.bank-gen-lvl-name::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
}
.bank-gen-lvl.lvl-easy { background: #f2fbf7; border-color: #c6ebd9; }
.bank-gen-lvl.lvl-easy .bank-gen-lvl-name { color: #0b7a54; }
.bank-gen-lvl.lvl-easy .bank-gen-lvl-name::before { background: #1c9a74; }
.bank-gen-lvl.lvl-med { background: #f4f7ff; border-color: #d0defb; }
.bank-gen-lvl.lvl-med .bank-gen-lvl-name { color: #1e40af; }
.bank-gen-lvl.lvl-med .bank-gen-lvl-name::before { background: #3b82f6; }
.bank-gen-lvl.lvl-hard { background: #fff5f5; border-color: #f9d0d3; }
.bank-gen-lvl.lvl-hard .bank-gen-lvl-name { color: #b4232c; }
.bank-gen-lvl.lvl-hard .bank-gen-lvl-name::before { background: #d9454f; }
.bank-gen-lvl.lvl-pisa { background: #fffaf0; border-color: #f6e0b5; }
.bank-gen-lvl.lvl-pisa .bank-gen-lvl-name { color: #946014; }
.bank-gen-lvl.lvl-pisa .bank-gen-lvl-name::before { background: #f2a53b; }
.bank-gen-num {
  width: 100% !important;
  text-align: center;
  font-weight: 700;
  font-size: 16px;
  min-height: 40px !important;
  padding: 6px 10px !important;
}
.bank-gen-hint {
  font-size: 13px;
  color: var(--muted);
  background: #f7f6fc;
  border: 1px dashed #d8d3f0;
  border-radius: 12px;
  padding: 10px 14px;
}
.bank-gen-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid #f0eef9;
}
.bank-gen-submit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-inline: 22px;
}
@media (max-width: 720px) {
  .bank-gen-top { grid-template-columns: 1fr; }
  .bank-gen-levels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bank-gen-sub { display: none; }
  .bank-gen-submit { width: 100%; justify-content: center; }
}

/* ---------- Test Builder Redesign (#tab-tests) ---------- */
.tb-header-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px 24px;
  border: 1px solid #e2def5;
}
.tb-top-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.tb-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}
.tb-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.tb-title {
  margin: 0 !important;
  font-size: 22px;
  color: var(--navy);
  font-weight: 800;
}
.tb-subtitle {
  font-size: 13.5px;
}
.tb-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid #eeecf8;
  margin: 0;
}
.tb-tool-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.tb-add-top {
  font-weight: 700;
}
.schedule-top {
  background: var(--brand-grad);
  color: #fff;
  border: 0;
  font-weight: 700;
}
.tb-questions-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  border: 1px solid #e2def5;
}
.tb-qhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.tb-qhead-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.tb-qhead-title {
  margin: 0;
  font-size: 18px;
  color: var(--navy);
  font-weight: 800;
}
.tb-qsummary-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.tb-qhead-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.tb-meta-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-radius: 14px;
  background: #f8f7fd;
  border: 1px solid #ece9f8;
}
.tb-balance-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.tb-drag-hint {
  font-size: 12.5px;
}
#tab-tests .tb-qcard {
  padding: 18px 20px;
  border-radius: 18px;
  border: 1.5px solid #e6e3f4;
  background: #ffffff;
  margin-top: 4px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
#tab-tests .tb-qcard:hover {
  border-color: #c9c3f2;
  box-shadow: 0 8px 24px rgba(107, 99, 224, .08);
}
.tb-qcard-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f2f0fa;
}
.tb-qcard-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.tb-qcard-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tb-qstem {
  font-size: 16px;
  font-weight: 600;
  color: var(--navy);
  margin: 6px 0 12px;
  line-height: 1.75;
}
#tab-tests .tb-opt-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}
#tab-tests .tb-opt-grid .radio-opt {
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 13px;
  border-width: 1.5px;
}
#tab-tests .tb-opt-grid .opt-letter {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: 14px;
  background: #f1effb;
  color: var(--navy);
  font-weight: 700;
  display: inline-grid;
  place-items: center;
  flex: none;
}
#tab-tests .tb-opt-grid .radio-opt.selected {
  border-color: var(--good);
  background: #f0fbf6;
  box-shadow: 0 0 0 3px rgba(28, 154, 116, .12);
}
#tab-tests .tb-opt-grid .radio-opt.selected .opt-letter {
  background: var(--good);
  color: #fff;
}
#tab-tests .tb-opt-grid .radio-opt.selected::after {
  background: var(--good);
  width: 24px;
  height: 24px;
  font-size: 13px;
}
.tb-qcard-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #eae7f6;
}
.tb-points-edit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f8f7fd;
  padding: 4px 10px;
  border-radius: 10px;
  border: 1px solid #e6e3f4;
}
.tb-points-inp {
  width: 76px !important;
  min-height: 32px !important;
  padding: 3px 8px !important;
  text-align: center;
  font-weight: 700;
}
@media (max-width: 720px) {
  #tab-tests .tb-opt-grid { grid-template-columns: 1fr; }
  .tb-tool-group { width: 100%; }
  .tb-tool-group > button { flex: 1 1 calc(50% - 8px); min-width: 0; padding: 10px 8px; font-size: 14px; }
  .tb-tool-primary > button.tb-add-top,
  .tb-tool-primary > button.schedule-top { flex: 1 1 100%; }
  .tb-add-fab { position: fixed; right: 14px; bottom: 16px; z-index: 40; background: var(--brand-grad); color: #fff; border: 0; font-weight: 700; border-radius: 99px; padding: 12px 18px; box-shadow: 0 8px 22px rgba(107, 99, 224, .38); }
  .question-card input[type=number] { width: 96px; }
}

/* question-bank pager, and what a phone does not need: downloads (PDF / Word) are for the computer */
.bank-pager { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; margin: 10px 0; }
.bank-pager button { min-width: 38px; }
@media (max-width: 720px) { body.teacher-body .no-phone { display: none; } }

/* question bank scope: «ថ្នាក់ខ្ញុំ / គ្រប់ថ្នាក់» and the teacher's own classes */
.scope-pill { font-weight: 700; }
.class-chip.on { background: var(--brand); color: #fff; }
.class-chip:hover { border-color: var(--brand); }

/* «ថែមសំណួរពីធនាគារ» footer: always at the bottom of the screen, cancel on the left, add on the right */
.bp-foot { position: sticky; bottom: 0; z-index: 5; background: #fff; margin: 12px -4px 0; padding: 10px 4px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.bp-count { font-size: 14px; margin-bottom: 8px; }
.bp-btns { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.bp-btns button { flex: 1 1 0; min-height: 44px; }
@media (min-width: 721px) { .bp-btns { justify-content: flex-end; } .bp-btns button { flex: 0 0 auto; min-width: 140px; } }

/* drag handle of a question in the test editor */
.qdrag { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; margin-right: 4px; border-radius: 8px; background: #f1effb; color: #5b548a; font-size: 18px; line-height: 1; cursor: grab; touch-action: none; user-select: none; vertical-align: middle; }
.qdrag:hover { background: var(--brand-soft); color: var(--brand-dark); }
.question-card.dragging { box-shadow: 0 10px 28px rgba(107, 99, 224, .28); outline: 2px solid var(--brand); background: var(--brand-soft); position: relative; z-index: 3; }
.question-card.dragging .qdrag { cursor: grabbing; }

/* ---------- Schedule Exam Tab (#tab-schedule) ---------- */
.sch-form-card,
.sch-list-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  border: 1px solid #e2def5;
}
.sch-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.sch-card-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}
.sch-card-ic {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--brand-soft);
  border: 1px solid #d8d3fa;
  display: grid;
  place-items: center;
  font-size: 20px;
  flex: none;
}
.sch-section {
  background: #faf9fe;
  border: 1.5px solid #e8e5f6;
  border-radius: 16px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sch-sec-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2px;
}
.sch-step-num {
  width: 26px;
  height: 26px;
  border-radius: 99px;
  background: var(--brand-grad);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex: none;
}
.sch-sec-title {
  font-size: 15.5px;
  color: var(--navy);
  font-weight: 800;
}
.sch-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.sch-class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  width: 100%;
}
.sch-class-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1.5px solid #e2def5;
  border-radius: 12px;
  padding: 10px 12px;
  background: #ffffff;
  cursor: pointer;
  margin: 0;
  font-weight: 700;
  color: var(--navy);
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.sch-class-opt:hover {
  border-color: #c2bbf0;
  background: #f6f4ff;
}
.sch-class-opt input {
  width: 18px;
  height: 18px;
  margin: 0;
  flex: none;
  accent-color: var(--brand);
}
.sch-class-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sch-class-count {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  background: #f1effb;
  color: var(--brand-dark);
  flex: none;
}
.sch-class-opt:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: 0 0 0 3px rgba(107, 99, 224, .12);
}
.sch-class-opt:has(input:checked) .sch-class-count {
  background: var(--brand);
  color: #fff;
}
.sch-empty-classes {
  background: #ffffff;
  border: 1.5px dashed #ccc5f2;
  border-radius: 14px;
  padding: 14px 16px;
}
.sch-empty-classes-msg {
  display: flex;
  align-items: center;
  gap: 12px;
}
.sch-empty-ic {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--brand-soft);
  display: grid;
  place-items: center;
  font-size: 20px;
  flex: none;
}
.time-shortcuts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin: 2px 0 4px;
  width: 100%;
}
button.time-pill {
  width: 100%;
  justify-content: center;
  border-radius: 12px;
  padding: 6px 10px;
  min-height: 38px;
  font-size: 13px;
  font-weight: 700;
  background: #ffffff;
  color: var(--navy);
  border: 1.5px solid #dfdcf2;
  box-shadow: none;
}
button.time-pill:hover {
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-color: #c2bbf0;
  box-shadow: none;
}
button.time-pill.on,
button.time-pill.on:hover {
  background: var(--brand-grad);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 6px 14px rgba(107, 99, 224, .25);
}
.sch-datetime-grid {
  display: grid;
  grid-template-columns: minmax(170px, 1.3fr) minmax(140px, 1fr) minmax(140px, 1fr) minmax(110px, .8fr);
  gap: 12px;
  align-items: end;
}
.sch-dt-field label {
  display: block;
  margin: 0 0 6px;
}
.sch-dt-field input {
  width: 100%;
  margin: 0;
}
.sch-time-inp {
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 15px;
}
.sch-dur-inp {
  font-weight: 700;
  text-align: center;
  font-size: 15px;
}
.sch-bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 14px;
}
.sch-viol-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
  transition: opacity .15s ease;
}
.sch-maxv-inp {
  width: 74px !important;
  min-height: 38px !important;
  padding: 4px 8px !important;
  text-align: center;
  font-weight: 700;
}
.sch-pin-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sch-pin-inp {
  flex: 1;
  font-weight: 800;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 4px;
  font-size: 20px;
  text-align: center;
  color: var(--navy);
  background: #ffffff !important;
  border: 1.5px solid #d4cffa !important;
}
.sch-pin-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
}
.sch-submit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid #ece9f8;
}
.sch-submit-btn {
  min-height: 48px;
  padding-inline: 28px;
  font-size: 16px;
  font-weight: 700;
}
.sch-session-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px 18px;
  border-radius: 16px;
  border: 1.5px solid #e6e3f4;
  border-left: 5px solid #c5bef2;
  background: #ffffff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.sch-session-card:hover {
  box-shadow: 0 8px 22px rgba(107, 99, 224, .08);
}
.sch-session-card.is-open {
  border-left-color: var(--good);
  background: linear-gradient(90deg, #f4fcf8 0%, #ffffff 35%);
}
.sch-session-card.is-upcoming {
  border-left-color: var(--accent);
}
.sch-session-title {
  font-size: 16px;
  color: var(--navy);
}
.sch-session-meta {
  font-size: 13.5px;
  margin-top: 6px;
}
.sch-session-pin-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
@media (max-width: 820px) {
  .sch-datetime-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sch-bottom-grid { grid-template-columns: 1fr; }
  .sch-submit-btn { width: 100%; }
}
@media (max-width: 520px) {
  .sch-datetime-grid { grid-template-columns: 1fr; }
}
body.teach-mode .sheet-scrim { display: none; }

/* ---------- Test Mode Switch & Full-Stage Exam Proctor Command Center ---------- */
.test-mode-switch .tm-switch-lbl {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.tm-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 3px rgba(28, 154, 116, .22);
  animation: tmPulseDot 1.6s ease-in-out infinite;
}
@keyframes tmPulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.22); opacity: .75; }
}
.test-mode-switch.has-live:not(.on) {
  border-color: #86efac;
  background: #f0fdf4;
}
.test-mode-switch.on {
  background: var(--navy);
  color: #ffffff;
  border-color: var(--navy);
  box-shadow: 0 4px 12px rgba(43, 42, 92, .22);
}
.test-mode-switch.on .mode-switch-track {
  background: var(--good);
}

body.test-mode {
  background: var(--bg) !important;
  padding-bottom: 0 !important;
}
body.test-mode .dashboard-header,
body.test-mode .teacher-navigation,
body.test-mode .sidebar-toggle-btn,
body.test-mode .sidebar-edge-tab,
body.test-mode .nav-toggle,
body.test-mode .bottom-bar,
body.test-mode .sheet-scrim,
body.test-mode .up-card {
  display: none !important;
}
body.test-mode #view-dashboard {
  margin: 0 !important;
  padding: 0 !important;
  max-width: none !important;
  min-height: 100vh !important;
  background: transparent !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
body.test-mode #teach-stage {
  display: block !important;
  overflow: visible !important;
}

#view-dashboard.tm-magictime {
  animation-duration: .72s;
  animation-fill-mode: both;
  transform-origin: 50% 42%;
}
#view-dashboard.tm-vanishIn {
  animation-name: vanishIn;
}
#view-dashboard.tm-vanishOut {
  animation-name: vanishOut;
}

/* Single-Row Solid Navy Top Bar (matching /teach/) */
.tm-stage {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.tm-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: nowrap;
  padding: 10px clamp(16px, 2.5vw, 36px);
  background: var(--navy);
  color: #ffffff;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  box-shadow: 0 2px 12px rgba(29, 37, 64, .2);
}
.tm-top-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 2px 6px 2px 2px !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  color: #ffffff !important;
  text-align: left;
  cursor: pointer;
  flex: none;
}
.tm-top-brand:hover {
  opacity: .92;
}
.tm-top-brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 800;
  color: #ffffff;
  background: var(--brand);
}
.tm-top-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.tm-top-brand-text b {
  font-size: 17px;
  color: #ffffff;
}
.tm-top-brand-text small {
  font-size: 12px;
  color: #b8c2e6;
}
.tm-top-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  min-width: 0;
}
.tm-top-clock {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  color: #ffffff;
  white-space: nowrap;
}
.tm-top-clock b {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
.tm-top-clock span {
  font-size: 13px;
  color: #b8c2e6;
}
.tm-top-exam-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--navy-2);
  border: 1px solid rgba(255, 255, 255, .14);
  font-size: 13px;
  white-space: nowrap;
}
.tm-top-exam-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  flex: none;
}
.tm-top-exam-pill.is-upcoming .tm-top-exam-dot {
  background: #f59e0b;
}
.tm-top-exam-pill.is-closed .tm-top-exam-dot {
  background: #94a3b8;
}
.tm-top-countdown-lbl {
  color: #cbd5e1;
  font-weight: 600;
}
.tm-top-countdown {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 15.5px;
  font-weight: 800;
  color: #86efac;
  letter-spacing: .4px;
}
.tm-top-exam-pill.is-closed .tm-top-countdown {
  color: #e2e8f0;
  font-family: inherit;
  font-size: 13.5px;
}
button.tm-top-pin-badge {
  min-height: 26px !important;
  padding: 2px 10px !important;
  border-radius: 999px !important;
  background: #fde047 !important;
  color: #1e1b4b !important;
  border: 0 !important;
  box-shadow: none !important;
  font-size: 12.5px !important;
  font-weight: 800 !important;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  cursor: pointer;
}
button.tm-top-pin-badge:hover {
  background: #fef08a !important;
}
.tm-top-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  flex: none;
}
.tm-top-btn,
.tm-top-icon-btn {
  min-height: 38px !important;
  padding: 5px 13px !important;
  border-radius: 10px !important;
  background: var(--navy-2) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, .14) !important;
  box-shadow: none !important;
  font-size: 13.5px !important;
  font-weight: 700 !important;
  white-space: nowrap;
}
.tm-top-btn:hover,
.tm-top-icon-btn:hover {
  background: #484692 !important;
}
.tm-top-btn.is-launch {
  background: var(--brand) !important;
  border-color: rgba(255, 255, 255, .2) !important;
}
.tm-top-btn.is-launch:hover {
  background: var(--brand-dark) !important;
}
.tm-top-btn.is-exit {
  background: rgba(255, 255, 255, .1) !important;
}
.tm-top-btn.is-exit:hover {
  background: var(--bad) !important;
  border-color: var(--bad) !important;
}

@media (max-width: 980px) {
  .tm-topbar {
    flex-wrap: wrap;
  }
}

.tm-wrap {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 16px clamp(14px, 2.2vw, 32px) 48px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 1. Unified Exam Command Card */
.tm-command-card {
  padding: 0 !important;
  border-radius: 16px !important;
  border: 1px solid var(--line) !important;
  background: #ffffff !important;
  box-shadow: var(--shadow) !important;
  overflow: hidden;
}
.tm-session-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 16px;
  background: #f8f7fc;
  border-bottom: 1px solid var(--line);
}
button.tm-sess-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px !important;
  padding: 4px 12px !important;
  border-radius: 9px !important;
  background: #ffffff !important;
  color: var(--ink) !important;
  border: 1px solid var(--line) !important;
  box-shadow: none !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  white-space: nowrap;
  flex: none;
}
button.tm-sess-tab:hover {
  border-color: var(--brand) !important;
  background: var(--brand-soft) !important;
}
button.tm-sess-tab.on {
  background: var(--navy) !important;
  color: #ffffff !important;
  border-color: var(--navy) !important;
}
.tm-sess-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  flex: none;
}
.tm-sess-dot.is-open { background: #22c55e; }
.tm-sess-dot.is-upcoming { background: #f59e0b; }
.tm-sess-name {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tm-sess-count {
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  background: rgba(39, 42, 69, .08);
}
button.tm-sess-tab.on .tm-sess-count {
  background: rgba(255, 255, 255, .18);
  color: #ffffff;
}

.tm-cmd-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 18px;
}
.tm-cmd-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 260px;
  flex: 1;
}
.tm-cmd-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.tm-phase-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}
.tm-phase-tag .tm-phase-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #64748b;
}
.tm-phase-tag.is-open {
  background: var(--good-soft);
  color: #0b7a54;
  border-color: #a7f3d0;
}
.tm-phase-tag.is-open .tm-phase-dot {
  background: var(--good);
}
.tm-phase-tag.is-upcoming {
  background: var(--warn-soft);
  color: #78350f;
  border-color: #fde68a;
}
.tm-phase-tag.is-upcoming .tm-phase-dot {
  background: var(--accent);
}
.tm-spec-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #f8f7fc;
  color: var(--ink);
  border: 1px solid var(--line);
}
.tm-spec-chip.is-class {
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-color: #d5d0f8;
}
.tm-spec-chip.is-writing {
  background: #eff6ff;
  color: #1e3a8a;
  border-color: #bfdbfe;
}
.tm-cmd-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.45;
}
.tm-cmd-controls {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.tm-cmd-btn {
  min-height: 36px !important;
  padding: 5px 12px !important;
  border-radius: 9px !important;
  font-size: 13px !important;
  font-weight: 700 !important;
}
.tm-cmd-btn.on {
  background: var(--brand-soft) !important;
  border-color: var(--brand) !important;
  color: var(--brand-dark) !important;
}
.tm-cmd-btn.is-reopen {
  background: var(--good-soft) !important;
  color: #0b7a54 !important;
  border-color: #86efac !important;
}

.tm-cmd-ticker {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 18px;
  background: #faf9fe;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.tm-ticker-head {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--navy);
  flex: none;
}
.tm-ticker-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  animation: tmPulseDot 1.5s infinite;
}
.tm-ticker-pulse.is-off {
  background: #94a3b8;
  animation: none;
}
.tm-ticker-items {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  flex: 1;
}
.tm-ticker-chip {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
}
.tm-ticker-chip.is-bad {
  background: var(--bad-soft);
  color: #991b1b;
}
.tm-ticker-chip.is-warn,
.tm-ticker-chip.is-away {
  background: var(--warn-soft);
  color: #78350f;
}
.tm-ticker-chip.is-good {
  background: var(--good-soft);
  color: #0b7a54;
}
.tm-ticker-chip.is-mcq {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

/* 2. Clean Typographic Filter & KPI Strip (like /teach/ Attendance .stats) */
.tm-stats-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}
button.tm-stat-box {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  padding: 11px 14px !important;
  border-radius: 14px !important;
  background: #ffffff !important;
  color: var(--ink) !important;
  border: 1.5px solid var(--line) !important;
  box-shadow: var(--shadow) !important;
  text-align: left;
  min-height: 70px !important;
  transition: border-color .15s ease, background .15s ease, transform .12s ease;
}
button.tm-stat-box:hover {
  border-color: #c7c1ec !important;
  transform: translateY(-1px);
}
button.tm-stat-box.on {
  border-color: var(--brand) !important;
  background: var(--brand-soft) !important;
  box-shadow: 0 0 0 2px rgba(107, 99, 224, .18) !important;
}
button.tm-stat-box.has-urgent:not(.on) {
  background: #fff8f8 !important;
  border-color: #fca5a5 !important;
}
button.tm-stat-box.has-away:not(.on) {
  background: #fffdf5 !important;
  border-color: #fcd34d !important;
}
.tm-stat-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
}
.tm-stat-num {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  color: var(--navy);
}
.tm-stat-box.is-live .tm-stat-num { color: var(--good); }
.tm-stat-box.is-mcq-done .tm-stat-num { color: var(--brand-dark); }
.tm-stat-box.is-alert .tm-stat-num { color: var(--bad); }
.tm-stat-box.is-away .tm-stat-num { color: var(--warn); }
.tm-stat-box.is-writing .tm-stat-num { color: #1d4ed8; }
.tm-stat-lbl {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.4;
}
.tm-stat-sub {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.45;
}

@media (max-width: 1180px) {
  .tm-stats-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 640px) {
  .tm-stats-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.tm-loading-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 20px;
  font-weight: 700;
  color: var(--navy);
}
.tm-empty-hero {
  text-align: center;
  padding: 42px 24px !important;
}

/* Expandable Test Paper & Live Question Stats Drawer */
.tm-paper-drawer {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.tm-paper-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid var(--line);
  font-weight: 700;
}
.tm-paper-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.tm-q-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 12px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 4px;
}
.tm-q-card {
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #faf9fe;
}
.tm-q-card.is-writing {
  background: #f8fbff;
  border-color: #dbeafe;
}
.tm-q-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.tm-q-num {
  font-weight: 800;
  color: var(--navy);
  font-size: 14px;
}
.tm-q-stat-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.tm-q-stem {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 10px;
  line-height: 1.75;
}
.tm-q-img {
  max-height: 120px;
  border-radius: 8px;
  margin-bottom: 8px;
  display: block;
}
.tm-q-opts {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tm-q-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid var(--line);
  font-size: 13.5px;
}
.tm-q-opt.is-correct {
  background: #f0fdf4;
  border-color: #86efac;
}
.tm-q-opt-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.tm-q-opt-letter {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--navy);
  font-weight: 800;
  font-size: 12.5px;
  display: inline-grid;
  place-items: center;
  flex: none;
}
.tm-q-opt.is-correct .tm-q-opt-letter {
  background: var(--good);
  color: #ffffff;
}
.tm-q-correct-tag {
  font-size: 11.5px;
  font-weight: 700;
  color: #0b7a54;
  margin-left: 4px;
}
.tm-q-opt-stat {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  flex: none;
}
.tm-q-opt-bar {
  width: 56px;
  height: 6px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}
.tm-q-opt-bar i {
  display: block;
  height: 100%;
  background: var(--brand);
}
.tm-q-opt.is-correct .tm-q-opt-bar i {
  background: var(--good);
}
.tm-q-rubric {
  padding: 8px 12px;
  border-radius: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  font-size: 13px;
  color: #1e3a8a;
}

/* Live Student × Question Matrix Table */
.tm-matrix-table th,
.tm-matrix-table td {
  padding: 8px 10px;
  text-align: center;
  font-size: 13px;
}
.tm-matrix-table th:first-child,
.tm-matrix-table td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: #ffffff;
  z-index: 2;
}
.tm-m-cell {
  font-weight: 800;
  min-width: 30px;
}
.tm-m-cell.is-correct {
  background: #f0fdf4;
  color: #0b7a54;
}
.tm-m-cell.is-wrong {
  background: #fef2f2;
  color: #b91c1c;
}
.tm-m-cell.is-answered {
  background: #eff6ff;
  color: #1d4ed8;
}

/* 3. Compact Search, Sort & Segmented View Toolbar */
.tm-int-select {
  min-height: 36px !important;
  padding: 5px 12px !important;
  font-size: 13px !important;
  font-weight: 600;
  border-radius: 9px !important;
  width: auto !important;
  margin: 0 !important;
}
.tm-btn-unlock-all {
  min-height: 36px !important;
  padding: 5px 14px !important;
  font-size: 13px !important;
  font-weight: 800 !important;
  border-radius: 9px !important;
  background: var(--good) !important;
  color: #ffffff !important;
  border: 1px solid var(--good) !important;
  box-shadow: none !important;
}
.tm-btn-unlock-all:hover {
  background: #147a5c !important;
}

.tm-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.tm-toolbar-left,
.tm-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.tm-search-inp {
  min-height: 38px !important;
  padding: 6px 13px !important;
  border-radius: 10px !important;
  border: 1px solid var(--line) !important;
  background: #ffffff !important;
  min-width: 240px;
  font-size: 13.5px;
  margin: 0 !important;
}
.tm-search-inp:focus {
  border-color: var(--brand) !important;
}
.tm-sort-sel {
  min-height: 38px !important;
  padding: 6px 12px !important;
  border-radius: 10px !important;
  border: 1px solid var(--line) !important;
  background: #ffffff !important;
  font-size: 13px !important;
  font-weight: 600;
  width: auto !important;
  margin: 0 !important;
}
.tm-idle-filter-btn.on {
  background: var(--brand-soft) !important;
  border-color: var(--brand) !important;
  color: var(--brand-dark) !important;
}
.tm-seg-switch {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border-radius: 10px;
  background: #e5e2f2;
}
.tm-seg-switch button {
  min-height: 32px !important;
  padding: 4px 12px !important;
  border-radius: 8px !important;
  background: transparent !important;
  color: var(--muted) !important;
  border: 0 !important;
  box-shadow: none !important;
  font-size: 13px !important;
  font-weight: 700 !important;
}
.tm-seg-switch button:hover {
  color: var(--navy) !important;
}
.tm-seg-switch button.on {
  background: #ffffff !important;
  color: var(--navy) !important;
  box-shadow: 0 1px 2px rgba(39, 42, 69, .08) !important;
}

/* Live sync indicator + sound toggle */
.tm-sync-btn {
  display: inline-flex !important;
  align-items: center;
  gap: 7px;
  min-height: 34px !important;
  padding: 4px 12px !important;
  border-radius: 99px !important;
  background: #ffffff !important;
  color: var(--muted) !important;
  border: 1px solid var(--line) !important;
  box-shadow: none !important;
  font-size: 12.5px !important;
  font-weight: 600 !important;
  line-height: 1.7;
}
.tm-sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  flex: none;
}
.tm-sync-btn.is-on .tm-sync-dot { animation: tmPulseDot 1.6s ease-in-out infinite; }
.tm-sync-btn.is-paused { color: var(--warn) !important; border-color: #f0d9a8 !important; background: var(--warn-soft) !important; }
.tm-sync-btn.is-paused .tm-sync-dot { background: var(--warn); }
.tm-sound-btn.on { border-color: var(--brand) !important; color: var(--brand-dark) !important; }

/* Non-blocking proctor alerts (corner toasts) */
.tm-alert-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(380px, calc(100vw - 36px));
}
.tm-alert-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 0;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(31, 36, 51, .16);
  overflow: hidden;
  animation: tmRise .25s ease both;
}
.tm-alert-bar { align-self: stretch; width: 5px; flex: none; background: var(--warn); }
.tm-alert-toast.is-bad .tm-alert-bar { background: var(--bad); }
.tm-alert-body { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.7; }
.tm-alert-body strong { font-size: 13.5px; color: var(--ink); }
.tm-alert-body span { font-size: 12.5px; color: var(--muted); }
.tm-alert-view {
  min-height: 32px !important;
  padding: 3px 12px !important;
  border-radius: 8px !important;
  font-size: 12.5px !important;
  background: var(--navy) !important;
  box-shadow: none !important;
}
.tm-alert-close {
  min-height: 32px !important;
  width: 32px;
  padding: 0 !important;
  background: transparent !important;
  color: var(--muted) !important;
  box-shadow: none !important;
  border: 0 !important;
}
.tm-student-grid.no-anim .tm-student-card { animation: none; }

/* 4. Student Proctor Grid & Cards (Clean Editorial Layout, No Gradients) */
@keyframes tmRise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.tm-student-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px;
}
.tm-student-card {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 5px solid #cbd5e1;
  box-shadow: var(--shadow);
  animation: tmRise .3s calc(var(--i, 0) * 30ms) ease both;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.tm-student-card.is-live {
  border-left-color: var(--good);
}
.tm-student-card.is-mcq-done {
  border-left-color: var(--brand);
}
.tm-student-card.is-locked {
  border-color: #fca5a5;
  border-left: 5px solid var(--bad);
  background: #fffafa;
}
.tm-student-card.is-cheating {
  border-color: #fcd34d;
  border-left: 5px solid var(--warn);
}
.tm-student-card.is-away {
  border-left-color: #ea580c;
}
.tm-student-card.is-done {
  border-left-color: #0d9488;
}
.tm-student-card.is-done-warn {
  border-left-color: var(--warn);
}

.tm-st-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.tm-conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}
.tm-conn-dot.is-on {
  background: var(--good);
}
.tm-conn-dot.is-off {
  background: #ea580c;
}
.tm-conn-dot.is-idle {
  background: #cbd5e1;
}
.tm-st-name {
  font-size: 15.5px;
  font-weight: 800;
  color: var(--navy);
}
.tm-st-id {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 5px;
  background: #f1f5f9;
  color: #334155;
}
.tm-st-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.tm-st-sublabel {
  font-weight: 600;
  color: #475569;
}

.tm-st-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.tm-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.tm-st-badge.is-live {
  background: var(--good-soft);
  color: #0b7a54;
}
.tm-st-badge.is-mcq-done {
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.tm-st-badge.is-locked {
  background: var(--bad-soft);
  color: #991b1b;
}
.tm-st-badge.is-cheating,
.tm-st-badge.is-away,
.tm-st-badge.is-done-warn {
  background: var(--warn-soft);
  color: #78350f;
}
.tm-st-badge.is-done {
  background: #ccfbf1;
  color: #115e59;
}
.tm-st-badge.is-idle {
  background: #f1f5f9;
  color: #475569;
}

.tm-st-lock-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 11px;
  border-radius: 9px;
  background: var(--bad-soft);
  border: 1px solid #fca5a5;
  color: #7f1d1d;
  font-size: 12.5px;
}
.tm-unlock-inline-btn {
  min-height: 30px !important;
  padding: 3px 10px !important;
  font-size: 12px !important;
  font-weight: 800 !important;
  border-radius: 7px !important;
  background: var(--good) !important;
  color: #ffffff !important;
  box-shadow: none !important;
  flex: none;
}
.tm-st-away-banner {
  padding: 6px 10px;
  border-radius: 9px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-size: 12px;
  font-weight: 700;
}

/* MCQ Progress & Per-Question Squares inside Student Card */
.tm-st-prog-block {
  padding: 9px 11px;
  border-radius: 10px;
  background: #faf9fe;
  border: 1px solid var(--line);
}
.tm-st-prog-block.is-complete {
  background: #f5f3ff;
  border-color: #dcd7f8;
}
.tm-st-prog-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
}
.tm-st-prog-lbl {
  font-weight: 700;
  color: var(--navy);
}
.tm-st-prog-val {
  font-size: 12.5px;
  color: var(--brand-dark);
}
.tm-st-prog-val.is-graded {
  color: #0b7a54;
}
.tm-st-prog-val.is-pending {
  color: #9a3412;
}
.tm-st-bar {
  height: 6px;
  border-radius: 999px;
  background: #e6e3f5;
  overflow: hidden;
  margin-top: 5px;
}
.tm-st-bar i {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
  transition: width .25s ease;
}
.tm-st-bar i.is-full {
  background: var(--good);
}
.tm-st-q-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 7px;
}
.tm-q-bubbles {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.tm-qb {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  background: #ffffff;
  color: #64748b;
  border: 1px solid #cbd5e1;
}
.tm-qb.is-correct {
  background: var(--good-soft);
  color: #0b7a54;
  border-color: #86efac;
}
.tm-qb.is-wrong {
  background: var(--bad-soft);
  color: #991b1b;
  border-color: #fca5a5;
}
.tm-qb.is-answered {
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-color: #c7c1f5;
}
.tm-st-score-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.tm-st-score-chip {
  font-weight: 700;
  color: var(--navy);
}
.tm-st-total-chip {
  color: #0b7a54;
  background: var(--good-soft);
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11.5px;
}

/* Compact Single-Row Writing Grading Bar */
.tm-st-writing-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 7px 10px;
  border-radius: 9px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  font-size: 12.5px;
}
.tm-st-writing-info {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tm-st-writing-btns {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.tm-st-writing-btns button {
  min-height: 28px !important;
  padding: 2px 9px !important;
  font-size: 11.5px !important;
  border-radius: 7px !important;
}

/* Anti-cheating Telemetry Row */
.tm-st-telemetry {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.tm-tele-pill {
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  background: #f1f5f9;
  color: #475569;
}
.tm-tele-pill.is-warn {
  background: var(--warn-soft);
  color: #78350f;
}
.tm-tele-pill.is-bad {
  background: var(--bad-soft);
  color: #991b1b;
}
.tm-tele-log-btn {
  min-height: 26px !important;
  padding: 2px 9px !important;
  font-size: 11.5px !important;
  font-weight: 700 !important;
  border-radius: 6px !important;
  background: var(--brand-soft) !important;
  color: var(--brand-dark) !important;
  border: 1px solid #d5d0f8 !important;
  box-shadow: none !important;
  margin-left: auto;
}

/* Proctor Actions Footer inside Student Card */
.tm-st-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  margin-top: auto;
}
.tm-act-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 31px !important;
  padding: 3px 10px !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  border-radius: 8px !important;
  background: #ffffff !important;
  color: var(--navy) !important;
  border: 1px solid #d5d0ec !important;
  box-shadow: none !important;
  cursor: pointer;
}
.tm-act-btn:hover {
  background: var(--brand-soft) !important;
  border-color: var(--brand) !important;
}
.tm-act-btn.is-unlock {
  background: var(--good) !important;
  color: #ffffff !important;
  border-color: var(--good) !important;
}
.tm-act-btn.is-lock {
  background: #fff1f2 !important;
  color: #9f1239 !important;
  border-color: #fecdd3 !important;
}
.tm-act-btn.is-reset {
  background: #eff6ff !important;
  color: #1e40af !important;
  border-color: #bfdbfe !important;
}
.tm-act-btn.is-warn {
  background: #fffbeb !important;
  color: #92400e !important;
  border-color: #fde68a !important;
}

/* Reset Student Modal */
.tm-reset-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tm-reset-opt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: #faf9fe;
  cursor: pointer;
}
.tm-reset-opt input {
  width: 18px;
  height: 18px;
  margin-top: 4px;
  accent-color: var(--brand);
}
.tm-reset-opt.on {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.tm-reset-opt.is-danger-opt.on {
  border-color: var(--bad);
  background: var(--bad-soft);
}
.tm-reset-opt-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.tm-reset-opt-body strong {
  font-size: 14px;
  color: var(--navy);
}
.tm-reset-opt-body span {
  font-size: 12.5px;
}
.tm-reset-extra-box {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

/* Quick Launch Exam Modal — Clean Solid Layout */
.tm-ql-modal {
  text-align: left !important;
  max-width: 580px !important;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px 26px !important;
}
.tm-ql-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.tm-ql-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.tm-ql-close {
  width: 40px;
  height: 40px;
  min-height: 40px !important;
  padding: 0 !important;
  border-radius: 10px !important;
  display: grid;
  place-items: center;
  flex: none;
}
.tm-ql-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}
.tm-ql-label {
  margin: 0 !important;
  font-weight: 800;
  color: var(--navy);
  font-size: 14px;
}
.tm-ql-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.tm-ql-class-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important;
  width: 100%;
}
.tm-ql-select {
  width: 100% !important;
  min-height: 46px !important;
  margin: 0 !important;
}
.tm-ql-two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
  width: 100%;
}
.tm-ql-dur-inp {
  width: 100% !important;
  min-height: 46px !important;
  text-align: center;
  font-weight: 800;
  font-size: 18px;
  color: var(--navy);
  margin: 0 !important;
}
.tm-ql-pin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
  width: 100%;
}
.tm-ql-pin-inp {
  width: 100% !important;
  max-width: none !important;
  min-height: 46px !important;
  margin: 0 !important;
}
.tm-ql-pin-btn {
  min-height: 46px !important;
  padding: 0 14px !important;
  border-radius: 10px !important;
  font-weight: 700 !important;
  white-space: nowrap;
  margin: 0 !important;
}
.tm-ql-presets {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}
.tm-reset-presets {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  margin-top: 8px;
}
button.tm-dur-pill {
  width: 100%;
  min-height: 38px !important;
  padding: 5px 4px !important;
  border-radius: 9px !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  text-align: center;
  justify-content: center;
  background: #ffffff !important;
  color: var(--navy) !important;
  border: 1.5px solid var(--line) !important;
  box-shadow: none !important;
}
button.tm-dur-pill:hover {
  background: var(--brand-soft) !important;
  border-color: var(--brand) !important;
  color: var(--brand-dark) !important;
}
button.tm-dur-pill.on,
button.tm-dur-pill.on:hover {
  background: var(--brand) !important;
  color: #ffffff !important;
  border-color: var(--brand) !important;
  box-shadow: none !important;
}
.tm-ql-foot {
  display: grid;
  grid-template-columns: 1fr 1.85fr;
  gap: 12px;
  width: 100%;
  padding-top: 14px;
  margin-top: 4px;
  border-top: 1px solid var(--line);
}
.tm-ql-cancel-btn,
.tm-ql-launch-btn {
  width: 100%;
  min-height: 46px !important;
  font-size: 15px !important;
  font-weight: 800 !important;
  border-radius: 12px !important;
  justify-content: center;
}
@media (max-width: 560px) {
  .tm-ql-two-col {
    grid-template-columns: 1fr;
  }
  .tm-ql-presets {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .tm-reset-presets {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .tm-ql-foot {
    grid-template-columns: 1fr;
  }
}

/* Classroom Projector Screen Modal (Solid Navy, No Gradients) */
.tm-proj-box {
  width: min(920px, 94vw);
  background: var(--navy);
  color: #ffffff;
  border-radius: 22px;
  padding: 30px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .4);
}
.tm-proj-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.tm-proj-badge {
  background: rgba(34, 197, 94, .18);
  color: #86efac;
  border: 1px solid rgba(134, 239, 172, .35);
  padding: 4px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 13.5px;
}
.tm-proj-title {
  margin: 0 0 6px;
  font-size: 30px;
  font-weight: 800;
  color: #ffffff;
}
.tm-proj-sub {
  font-size: 15.5px;
  color: #c7d2fe;
  margin-bottom: 22px;
}
.tm-proj-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.tm-proj-card {
  background: var(--navy-2);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 16px;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}
.tm-proj-label {
  font-size: 14.5px;
  font-weight: 700;
  color: #c7d2fe;
  margin-bottom: 8px;
}
.tm-proj-pin-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.tm-proj-pin {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 56px;
  font-weight: 900;
  letter-spacing: 8px;
  color: #fde047;
  line-height: 1.15;
  cursor: pointer;
  user-select: none;
  padding: 2px 12px;
  border-radius: 10px;
}
.tm-proj-pin.is-masked {
  color: rgba(253, 224, 71, .55);
  letter-spacing: 12px;
}
.tm-proj-pin-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 5px 16px;
  border-radius: 999px;
  background: rgba(253, 224, 71, .16);
  border: 1px solid rgba(253, 224, 71, .5);
  color: #fef08a;
  font-size: 13.5px;
  font-weight: 800;
  line-height: 1.7;
  cursor: pointer;
}
.tm-proj-pin-toggle:hover {
  background: rgba(253, 224, 71, .26);
}
.tm-proj-pin-toggle.is-shown {
  background: rgba(255, 255, 255, .14);
  border-color: rgba(255, 255, 255, .3);
  color: #ffffff;
}
.tm-proj-timer {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 52px;
  font-weight: 900;
  color: #86efac;
  line-height: 1.25;
}
.tm-proj-hint {
  font-size: 14px;
  color: #e0e7ff;
  margin-top: 8px;
}
.tm-proj-qr-wrap {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, .14);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: left;
}
.tm-proj-qr-box {
  background: #ffffff;
  padding: 10px;
  border-radius: 12px;
  flex-shrink: 0;
  box-sizing: border-box;
}
.tm-proj-qr-caption {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 210px;
}
.tm-proj-qr-caption strong {
  font-size: 14.5px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.7;
}
.tm-proj-qr-caption span {
  font-size: 12.5px;
  color: #c7d2fe;
  line-height: 1.7;
}
.tm-proj-stats-row {
  margin-top: auto;
  padding-top: 16px;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.tm-proj-stat {
  background: rgba(15, 23, 42, .3);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 12px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.tm-proj-stat b {
  font-size: 24px;
  font-weight: 900;
  color: #ffffff;
  line-height: 1.2;
}
.tm-proj-stat.is-live b {
  color: #86efac;
}
.tm-proj-stat.is-done b {
  color: #fde047;
}
.tm-proj-stat span {
  font-size: 12px;
  font-weight: 700;
  color: #cbd5e1;
  line-height: 1.7;
}

.tm-table-wrap {
  overflow-x: auto;
  padding: 0 !important;
}

@media (max-width: 760px) {
  .tm-q-list {
    grid-template-columns: 1fr;
  }
  .tm-proj-grid {
    grid-template-columns: 1fr;
  }
}

/* Student home: one quiet column. Exams and results first, learning as a list. */
body.student-body { line-height: 1.7; }
body.student-body .topbar { background: #2b2a5c; box-shadow: none; }
body.student-body .topbar-in { padding: 16px 18px; }
body.student-body .topbar-avatar { width: 40px; height: 40px; border-radius: 50%; font-size: 18px; background: rgba(255, 255, 255, .14); border-color: transparent; }
body.student-body .auth-screen { background: var(--bg); }
body.student-body .auth-card { box-shadow: none; border-top: 1px solid var(--line); }
body.student-body .auth-card::before { background: #6b63e0; }
body.student-body #view-home .wrap { padding-top: 8px; }
body.student-body .section-title { font-weight: 500; gap: 0; }
body.student-body .section-title::before { display: none; }
body.student-body .stu-empty { margin: 0 0 8px; color: var(--muted); }
body.student-body #view-home .exam-card { border-left: 1px solid var(--line); border-radius: 12px; box-shadow: none; }
body.student-body #view-home .exam-card.is-open { border-color: #1c9a74; box-shadow: none; }
body.student-body .stu-links,
body.student-body .stu-results,
body.student-body .stu-hw .stu-links { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
body.student-body button.stu-link,
body.student-body button.stu-link:hover,
body.student-body button.stu-link:active {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  width: 100%; min-height: 52px; padding: 10px 14px; margin: 0;
  background: #fff; background-image: none; color: var(--ink);
  border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  box-shadow: none; transform: none; font-weight: 500; text-align: left;
}
body.student-body button.stu-link:last-child { border-bottom: 0; }
body.student-body button.stu-link:hover { background: #f6f5fb; }
body.student-body button.stu-link:disabled,
body.student-body button.stu-link:disabled:hover { color: var(--muted); background: #fff; cursor: default; }
body.student-body .stu-link-name { min-width: 0; }
body.student-body .stu-link-note { color: var(--muted); flex: none; font-size: 14px; font-weight: 500; }
body.student-body .stu-result {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 16px;
  padding: 12px 14px; border-bottom: 1px solid var(--line); align-items: center;
}
body.student-body .stu-result:last-child { border-bottom: 0; }
body.student-body .stu-result-title { font-weight: 500; }
body.student-body .stu-result-meta { color: var(--muted); font-size: 14px; }
body.student-body .stu-result-score { text-align: right; font-weight: 500; line-height: 1.3; }
body.student-body .stu-result-score b { display: block; font-size: 18px; }
body.student-body .stu-result-score.is-wait { color: var(--muted); font-size: 14px; }
body.student-body .stu-result-actions { grid-column: 1 / -1; display: flex; gap: 16px; }
body.student-body .stu-result-actions a { color: #2c2a6e; font-weight: 600; text-decoration: none; }
body.student-body .stu-fold {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  margin: 18px 0; padding: 0 14px 4px;
}
body.student-body .stu-fold > summary {
  cursor: pointer; list-style: none; min-height: 52px;
  display: flex; align-items: center; font-weight: 500;
}
body.student-body .stu-fold > summary::-webkit-details-marker { display: none; }
body.student-body .stu-fold > summary::after { content: '▸'; margin-left: auto; color: var(--muted); }
body.student-body .stu-fold[open] > summary::after { content: '▾'; }
body.student-body .stu-fold .stu-links { border: 0; border-radius: 0; border-top: 1px solid var(--line); }
body.student-body .stu-live { padding: 12px 0 10px; }
body.student-body .stu-live-label { font-weight: 500; margin-bottom: 8px; }
body.student-body .stu-live-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
body.student-body .stu-live-row input { max-width: 180px; }
body.student-body .stu-progress { margin-top: 4px; }
body.student-body .stu-progress-line { margin: -4px 0 8px; }
body.student-body .stu-topics-label { font-weight: 500; margin: 8px 0 2px; }
body.student-body .stu-more { display: inline-block; margin-top: 8px; color: #2c2a6e; font-weight: 600; }
body.student-body .year-card { background: #fff; border-radius: 12px; box-shadow: none; }
body.student-body .year-sum-tile { background: #2b2a5c; }
body.student-body .year-sum-tile.alt { background: #1c9a74; }
body.student-body .stu-hw { margin-top: 4px; }
body.student-body .stu-hw > div { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--line); }
