/* ExamDesk — design tokens, layout and components. Mobile-first; adapts to tablet and desktop. */
:root {
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #f8f9fb; --ink: #18202c; --ink-2: #3a4556; --muted: #5d6878;
  --line: #e1e5eb; --line-2: #cfd5de; --accent: #1f4e8c; --accent-hover: #183f72; --accent-soft: #e9eff8; --on-accent: #fff;
  --ok: #1d7446; --ok-soft: #e6f4ec; --warn: #9a5b00; --warn-soft: #fdf3e2; --danger: #b3261e; --danger-soft: #fcecea;
  --info: #1b659c; --info-soft: #e7f1f9; --violet: #6a3d9a; --violet-soft: #f1ebf8; --pen: #b3261e; --pen-soft: #fdf3f2;
  --answer-ink: #0d2a57; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16); --radius: 10px; --radius-sm: 7px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-paper: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --topbar-h: 58px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b; --surface: #171d26; --surface-2: #1c2330; --ink: #e7ebf1; --ink-2: #c3cad5; --muted: #95a0b0;
    --line: #2a3340; --line-2: #3a4555; --accent: #6d9be0; --accent-hover: #86acea; --accent-soft: #1d2a3d; --on-accent: #0b1220;
    --ok: #5cc48a; --ok-soft: #15291f; --warn: #e2a64a; --warn-soft: #2d2413; --danger: #f07d74; --danger-soft: #331a19;
    --info: #6fb2e6; --info-soft: #152535; --violet: #b595e0; --violet-soft: #251c33; --pen: #f28b82; --pen-soft: #2a1a1a;
    --answer-ink: #b9d0f5; --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5); color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.icon-xl { width: 40px; height: 40px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .block { display: block; } .nowrap { white-space: nowrap; }
.text-danger { color: var(--danger); } .text-warn { color: var(--warn); }
.center { text-align: center; } .pre { white-space: pre-wrap; }
.show-sm { display: none; }

/* ------------------------------------------------------------ buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: 600 14px/1.2 var(--font); cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s; text-decoration: none !important; }
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-ghost { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn-sm { min-height: 32px; padding: 5px 11px; font-size: 13px; }
.btn-lg { min-height: 48px; padding: 10px 26px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-dashed { width: 100%; border-style: dashed; background: transparent; color: var(--muted); }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid currentColor; border-color: var(--muted) transparent var(--muted) transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn-primary.is-busy::after { border-color: #fff transparent #fff transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--ink-2); cursor: pointer; position: relative; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }
.link-btn { border: 0; background: none; color: var(--accent); font: inherit; padding: 0; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.btn-group { display: inline-flex; gap: 2px; align-items: center; }
.push { margin-left: auto; }

input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 9px 11px; width: 100%; min-height: 40px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input:disabled, textarea:disabled, select:disabled { background: var(--surface-2); color: var(--ink-2); }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); flex: none; margin: 0; }
textarea { resize: vertical; line-height: 1.55; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.span-2 { grid-column: 1 / -1; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row-end { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.row-center { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.row-wrap { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-wrap input { flex: 1; min-width: 160px; }
.switch { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 14px; padding: 4px 0; }
.switch.small { font-size: 13px; align-items: center; }
.form-error { color: var(--danger); background: var(--danger-soft); padding: 9px 12px; border-radius: var(--radius-sm); font-size: 14px; }
.link { font-weight: 500; } .link.center { display: block; }

/* ------------------------------------------------------------ badges, notices */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); text-transform: none; }
.badge-neutral { background: var(--surface-2); color: var(--ink-2); }
.badge-muted { background: transparent; color: var(--muted); }
.badge-info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-violet { background: var(--violet-soft); color: var(--violet); border-color: transparent; }
.badge-ok-soft { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.badge-ok { background: var(--ok); color: #fff; border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
@media (prefers-color-scheme: dark) { .badge-ok { color: #0b1a12; } }
.notice { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 11px 14px; border-radius: var(--radius-sm); margin: 0 0 16px; font-size: 14px; background: var(--info-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--info) 25%, transparent); }
.notice.block { display: block; margin: 12px 0 0; }
.notice.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.notice.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.notice .icon { color: var(--muted); }

/* ------------------------------------------------------------ shell */
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 14px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; font-size: 16px; text-decoration: none !important; flex: none; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--on-accent); font-weight: 800; }
.brand-logo { height: 34px; width: auto; flex: none; }
.auth-logo { display: block; width: 132px; height: auto; margin: 4px auto 18px; }
.auth-brand h1 { letter-spacing: .18em; text-transform: uppercase; font-size: 1rem; font-weight: 600; color: var(--ink-2); }
@media (prefers-color-scheme: dark) { .brand-logo, .auth-logo { filter: invert(1); } }
.brand-mark.lg { width: 48px; height: 48px; border-radius: 12px; font-size: 22px; margin: 0 auto 12px; }
.mainnav { display: flex; gap: 2px; margin-left: 18px; overflow-x: auto; }
.mainnav a { padding: 8px 12px; border-radius: var(--radius-sm); color: var(--ink-2); font-weight: 500; font-size: 14.5px; white-space: nowrap; text-decoration: none; }
.mainnav a:hover { background: var(--surface-2); color: var(--ink); }
.mainnav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.bell .dot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; background: var(--danger); border-radius: 50%; border: 2px solid var(--surface); }
.user-chip { white-space: nowrap; display: flex; align-items: center; gap: 8px; border: 0; background: none; cursor: pointer; padding: 4px 8px 4px 4px; border-radius: 999px; color: var(--ink); font: 500 14px var(--font); }
.user-chip:hover { background: var(--surface-2); }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; flex: none; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.nav-toggle { display: none; }
#main { min-height: calc(100vh - var(--topbar-h)); }
.page { max-width: 1200px; margin: 0 auto; padding: 28px 24px 64px; }
.page.narrow { max-width: 880px; } .page.wide { max-width: 1480px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.loading { padding: 60px 0; text-align: center; color: var(--muted); }
.chips { display: flex; gap: 8px; align-items: center; margin-top: 8px; text-transform: capitalize; }

/* popovers */
.popover { position: absolute; z-index: 60; width: min(360px, calc(100vw - 16px)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; }
.pop-head { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.pop-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 11px 16px; border: 0; background: none; color: var(--ink); font: 14px var(--font); cursor: pointer; text-align: left; text-decoration: none !important; }
.pop-item:hover { background: var(--surface-2); }
.pop-title { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.notif-list { max-height: 420px; overflow-y: auto; }
.notif { display: flex; flex-direction: column; gap: 2px; padding: 11px 16px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none !important; }
.notif:hover { background: var(--surface-2); }
.notif.unread { background: var(--accent-soft); }
.notif-title { font-weight: 600; font-size: 14px; } .notif-body { font-size: 13px; color: var(--ink-2); } .notif-time { font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------ cards, stats, lists, tables */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow); }
.card-title { margin-bottom: 14px; font-size: 1.05rem; }
.card-title-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-title-row .card-title { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-grid.six { grid-template-columns: repeat(6, 1fr); }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--ink); text-decoration: none !important; border-top: 3px solid var(--line-2); }
a.stat:hover { border-color: var(--line-2); transform: translateY(-1px); }
.stat-num { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat-info { border-top-color: var(--info); } .stat-warn { border-top-color: var(--warn); } .stat-violet { border-top-color: var(--violet); }
.stat-ok-soft, .stat-ok { border-top-color: var(--ok); } .stat-neutral { border-top-color: var(--line-2); }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); text-align: center; }
.mini-stats strong { display: block; font-size: 20px; } .mini-stats span { font-size: 12px; color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.link-row { cursor: pointer; margin: 0 -10px; padding: 11px 10px; border-radius: var(--radius-sm); }
.link-row:hover { background: var(--surface-2); }
.inline-input { flex: 1; min-height: 34px; padding: 5px 9px; }
.deflist { display: grid; grid-template-columns: 170px 1fr; gap: 8px 16px; margin: 0; }
.deflist dt { color: var(--muted); font-size: 14px; } .deflist dd { margin: 0; font-weight: 500; }
.empty { text-align: center; padding: 38px 16px; color: var(--muted); }
.empty.small { padding: 22px 12px; font-size: 14px; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.empty .btn { margin-top: 10px; } .empty .icon-xl { color: var(--muted); margin-bottom: 8px; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .table-wrap { box-shadow: none; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table.compact td { padding: 8px 12px; font-size: 13px; }
.row-link { cursor: pointer; } .row-link:hover td { background: var(--surface-2); }
tr.inactive td { opacity: .55; }
.cell-actions { text-align: right; white-space: nowrap; } .cell-actions .btn + .btn { margin-left: 4px; }
.cell-bar { min-width: 160px; } .cell-bar .bar { display: inline-block; width: 100px; vertical-align: middle; margin-right: 8px; }
.details-cell { max-width: 360px; word-break: break-word; color: var(--ink-2); }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.bar span { display: block; height: 100%; background: var(--accent); }
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; }
.toolbar input[type=search] { max-width: 340px; }
.toolbar select { width: auto; max-width: 220px; }
.toolbar.wrap { flex-wrap: wrap; }
.date-filter { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.date-filter input { width: auto; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab { border: 0; background: none; padding: 10px 14px; font: 600 14px var(--font); color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab .count { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 99px; background: var(--surface-2); font-size: 12px; margin-left: 4px; }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.progress span { display: block; height: 100%; background: var(--ok); transition: width .3s; }

/* ------------------------------------------------------------ modal, toast */
.modal-backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(12, 18, 28, .45); display: grid; place-items: center; padding: 16px; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(520px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); }
.modal-wide { width: min(880px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 1.1rem; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.dialog-msg { margin: 0 0 12px; }
.lightbox { display: grid; place-items: center; background: var(--surface-2); border-radius: var(--radius-sm); }
.lightbox img { max-width: 100%; max-height: 75vh; }
#toasts { position: fixed; z-index: 100; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(460px, calc(100vw - 24px)); }
.toast { padding: 11px 16px; border-radius: var(--radius-sm); background: #1b2330; color: #fff; font-size: 14px; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: auto; }
.toast.show { opacity: 1; transform: none; }
.toast-error { background: var(--danger); } .toast-warn { background: #7a4a00; }

/* ------------------------------------------------------------ auth */
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 32px 28px; box-shadow: var(--shadow-lg); }
.auth-brand { text-align: center; margin-bottom: 22px; } .auth-brand h1 { font-size: 1.35rem; } .auth-brand p { margin: 4px 0 0; }
.auth-h { font-size: 1.3rem; margin-bottom: 6px; } .auth-card > p { margin: 0 0 18px; }
.auth-card.wide { width: min(560px, 100%); }
.install-link { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 14px; font-weight: 500; }
.install { display: flex; flex-direction: column; gap: 14px; }
.install .auth-logo { width: 110px; margin-bottom: 4px; }
.install-title { text-align: center; font-size: 1.35rem; }
.install > p { margin: 0; }
.install-steps { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 14px; }
.install-steps summary { cursor: pointer; padding: 12px 0; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.install-steps ol { margin: 0 0 14px; padding-left: 22px; } .install-steps li { margin: 6px 0; }
.install-qr { display: flex; gap: 16px; align-items: center; padding: 14px; background: var(--surface-2); border-radius: var(--radius-sm); }
.install-qr img { background: #fff; border-radius: 6px; padding: 4px; flex: none; }
.install-qr p { margin: 4px 0; }
.auth-foot { color: var(--muted); font-size: 12px; margin-top: 18px; }

/* ------------------------------------------------------------ exam cards */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.exam-card { display: flex; flex-direction: column; gap: 10px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--ink); text-decoration: none !important; transition: .12s; }
.exam-card:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.exam-card h3 { font-size: 1.05rem; }
.exam-card-top { display: flex; justify-content: space-between; align-items: center; }
.exam-card .btn { align-self: flex-start; margin-top: 4px; }

/* ------------------------------------------------------------ exam paper */
.paper { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 34px 40px; }
.paper-head { margin-bottom: 8px; }
.paper-title { font-family: var(--font-paper); font-size: 1.9rem; font-weight: 700; }
.paper-sub { color: var(--muted); margin: 6px 0 0; font-size: 1.05rem; }
.instructions { margin: 20px 0 8px; padding: 14px 16px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface-2); }
.instructions-label { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.intro-facts { display: flex; gap: 28px; flex-wrap: wrap; margin: 18px 0 0; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.intro-facts div { display: flex; flex-direction: column; } .intro-facts strong { font-size: 1.1rem; }
.intro-notes { margin: 18px 0; padding-left: 20px; color: var(--ink-2); } .intro-notes li { margin: 6px 0; }
.section-head { margin: 34px 0 6px; padding-bottom: 8px; border-bottom: 2px solid var(--accent); }
.section-head h2 { font-family: var(--font-paper); font-size: 1.35rem; color: var(--accent); }
.section-instr { margin: 6px 0 0; color: var(--ink-2); white-space: pre-wrap; }
.section-crumb { font-size: 13px; color: var(--accent); font-weight: 600; margin-bottom: 14px; }
.question { padding: 24px 0 26px; border-bottom: 1px solid var(--line); }
.question:last-of-type { border-bottom: 0; }
.qpane .question { padding-top: 6px; border: 0; }
.q-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.q-label { font-size: 1rem; font-weight: 700; }
.q-meta { display: flex; gap: 10px; align-items: center; }
.q-points { font-size: 13px; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.q-text { font-family: var(--font-paper); font-size: 1.12rem; line-height: 1.6; white-space: pre-wrap; }
.q-images { display: flex; flex-direction: column; gap: 14px; margin: 16px 0 4px; }
.q-images figure { margin: 0; }
.q-images img { max-width: 100%; height: auto; max-height: 480px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.q-images figcaption { font-size: 13px; color: var(--muted); margin-top: 4px; }
.img-btn { border: 0; padding: 0; background: none; cursor: zoom-in; display: block; max-width: 100%; }
.answer-label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 6px; }
.answer-input { font-family: var(--font); font-size: 16px; line-height: 1.65; color: var(--answer-ink); padding: 14px 16px; min-height: 180px;
  background-image: linear-gradient(transparent calc(1.65em + 13px), var(--line) 0); background-size: 100% 1.65em; background-attachment: local; }
.answer-foot { display: flex; justify-content: flex-end; margin-top: 6px; min-height: 18px; }
.answer-ro { margin-top: 16px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 12px 16px; }
.answer-ro .answer-label { margin: 0 0 6px; }
.answer-text { white-space: pre-wrap; color: var(--answer-ink); line-height: 1.65; overflow-wrap: anywhere; }
.empty-answer { color: var(--muted); font-style: italic; }
.correction-ro { margin-top: 12px; border-left: 3px solid var(--pen); background: var(--pen-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 11px 16px; }
.correction-ro.general { margin: 22px 0 8px; border: 1px solid color-mix(in srgb, var(--pen) 35%, transparent); border-left-width: 3px; }
.correction-label { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--pen); margin-bottom: 4px; }
.correction-label .badge { text-transform: none; letter-spacing: 0; }
.correction-text { color: var(--pen); white-space: pre-wrap; line-height: 1.6; overflow-wrap: anywhere; }
.result-bar { display: flex; flex-wrap: wrap; gap: 14px 28px; align-items: center; margin-top: 18px; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.result-bar > div { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.result-bar .score { font-size: 1.25rem; color: var(--accent); }
.result-actions { flex-direction: row !important; flex-wrap: wrap; gap: 8px !important; margin-left: auto; }
.success { text-align: center; padding: 48px 32px; }
.success-icon { display: inline-grid; place-items: center; width: 76px; height: 76px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); margin-bottom: 14px; }
.success h1 { margin-bottom: 10px; }

/* ------------------------------------------------------------ exam-taking mode */
body.exam-focus .mainnav, body.exam-focus .nav-toggle { visibility: hidden; }
.exam-shell { display: flex; flex-direction: column; min-height: calc(100vh - var(--topbar-h)); }
.preview-banner { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 8px 16px; background: var(--warn-soft); color: var(--warn); font-weight: 600; font-size: 14px; }
.exam-bar { position: sticky; top: var(--topbar-h); z-index: 20; display: flex; align-items: center; gap: 16px; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.exam-bar-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.exam-bar-title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-status { font-size: 13px; white-space: nowrap; }
.save-status > span { display: inline-flex; align-items: center; gap: 6px; }
.save-ok { color: var(--ok); } .save-warn { color: var(--warn); } .save-danger { color: var(--danger); } .save-muted { color: var(--muted); }
.exam-body { flex: 1; display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 24px; max-width: 1180px; width: 100%; margin: 0 auto; padding: 24px 24px 100px; align-items: start; }
.qnav { position: sticky; top: calc(var(--topbar-h) + 76px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; max-height: calc(100vh - var(--topbar-h) - 170px); overflow-y: auto; }
.qnav-head { font-size: 13px; color: var(--muted); margin-bottom: 12px; } .qnav-head strong { color: var(--ink); }
.qnav-head .progress { margin-top: 6px; }
.qnav-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.qnav-section { width: 100%; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 8px 0 0; }
.qnav-intro { width: 100%; text-align: left; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink-2); font: 500 13px var(--font); cursor: pointer; }
.qnav-btn { position: relative; width: 40px; height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); font: 600 14px var(--font); cursor: pointer; }
.qnav-btn i { position: absolute; top: 1px; right: 4px; font-style: normal; color: var(--warn); font-size: 12px; }
.qnav-btn.done { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 45%, transparent); color: var(--ok); }
.qnav-btn.current, .qnav-intro.current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); color: var(--accent); }
.qpane .paper { min-height: 420px; }
.exam-foot { position: sticky; bottom: 0; z-index: 20; display: flex; justify-content: center; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(6px); border-top: 1px solid var(--line); }
.exam-foot .btn { min-width: 150px; }

/* ------------------------------------------------------------ correction */
.corr-edit { margin-top: 14px; padding: 14px 16px; border-left: 3px solid var(--pen); background: var(--pen-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; display: flex; flex-direction: column; gap: 10px; }
.corr-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--pen); display: block; }
.corr-edit textarea, .general-edit textarea { color: var(--pen); background: var(--surface); }
.corr-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg-btn { border: 0; border-right: 1px solid var(--line-2); background: none; padding: 8px 12px; font: 600 13px var(--font); color: var(--ink-2); cursor: pointer; min-height: 38px; }
.seg-btn:last-child { border-right: 0; }
.seg-btn:hover { background: var(--surface-2); }
.seg-ok.on { background: var(--ok); color: #fff; } .seg-warn.on { background: var(--warn); color: #fff; } .seg-danger.on { background: var(--danger); color: #fff; }
.pts-input { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); font-weight: 600; }
.pts-input input { width: 84px; text-align: right; font-weight: 700; color: var(--ink); }
.pts-input.small input { width: 64px; min-height: 34px; padding: 5px 8px; }
.pts-input input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.general-edit { margin-top: 26px; }
.general-edit textarea { margin-top: 8px; }
.corr-bar { position: sticky; bottom: 0; z-index: 20; margin-top: 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; box-shadow: 0 -4px 16px rgba(16, 24, 40, .08); }
.corr-bar-info { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.corr-bar-info strong { font-variant-numeric: tabular-nums; }
.corr-bar-actions { display: flex; gap: 8px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0 10px 16px; border-left: 2px solid var(--line); position: relative; font-size: 14px; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 15px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.tl-head { color: var(--muted); font-size: 13px; }
del { color: var(--danger); } ins { color: var(--ok); text-decoration: none; }

/* ------------------------------------------------------------ editor */
.sticky-head { position: sticky; top: var(--topbar-h); z-index: 15; background: var(--bg); padding: 10px 0; margin-top: -10px; }
.editor-cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
.with-pages .editor-cols { grid-template-columns: minmax(0, 1fr) minmax(320px, 440px); }
.section-edit-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.section-title-input { font-size: 1.15rem; font-weight: 700; color: var(--accent); }
.section-instr-input { margin-bottom: 14px; font-size: 14px; min-height: 38px; }
.section-none { margin-bottom: 10px; }
.q-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
.q-edit { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; }
.q-edit-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.num-input { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; color: var(--muted); }
.num-input input { width: 58px; min-height: 34px; padding: 5px 8px; font-weight: 700; }
.select-inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.select-inline select, .move-select { width: auto; min-height: 34px; padding: 4px 8px; font-size: 13px; }
.q-text-input { font-family: var(--font-paper); font-size: 1.05rem; background: var(--surface); }
.q-img-row { display: flex; gap: 10px; flex-wrap: wrap; }
.thumb { position: relative; width: 150px; margin: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; display: flex; flex-direction: column; }
.thumb img { width: 100%; height: 100px; object-fit: contain; background: #fff; display: block; }
.thumb-actions { display: flex; justify-content: center; border-top: 1px solid var(--line); }
.thumb-actions .icon-btn { width: 30px; height: 30px; }
.caption-input { border: 0; border-top: 1px solid var(--line); border-radius: 0; min-height: 32px; font-size: 12px; padding: 5px 8px; }
.add-img { align-items: center; justify-content: center; gap: 4px; min-height: 100px; border-style: dashed; color: var(--muted); cursor: pointer; font-size: 13px; }
.add-img:hover { color: var(--accent); border-color: var(--accent); }
.pages-panel { position: sticky; top: calc(var(--topbar-h) + 70px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.pages-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.pages-scroll { max-height: calc(100vh - var(--topbar-h) - 140px); overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 14px; background: var(--surface-2); }
.pages-scroll figure { margin: 0; } .pages-scroll img { width: 100%; border: 1px solid var(--line); box-shadow: var(--shadow); background: #fff; }
.pages-scroll figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; text-align: center; }
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 34px 16px; border: 2px dashed var(--line-2); border-radius: var(--radius); cursor: pointer; color: var(--ink-2); text-align: center; position: relative; }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone.over, .dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dz-file { font-weight: 600; color: var(--accent); }
.assign-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; }
.check-list { display: flex; flex-direction: column; max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); margin: 8px 0; }
.check-list.short { max-height: 170px; margin: 0; }
.check-row { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.check-row:last-child { border-bottom: 0; } .check-row:hover { background: var(--surface-2); }
.check-row > span { display: flex; flex-direction: column; }
.profile-head { display: flex; gap: 16px; align-items: center; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .stat-grid.six { grid-template-columns: repeat(3, 1fr); }
  .with-pages .editor-cols { grid-template-columns: minmax(0, 1fr); }
  .pages-panel { position: static; } .pages-scroll { max-height: 520px; }
}
@media (max-width: 900px) {
  .nav-toggle { display: inline-grid; }
  .mainnav { position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: 270px; margin: 0; flex-direction: column; padding: 12px; gap: 2px; background: var(--surface);
    border-right: 1px solid var(--line); transform: translateX(-100%); transition: transform .2s; z-index: 40; }
  #shell.nav-open .mainnav { transform: none; box-shadow: var(--shadow-lg); }
  .mainnav a { padding: 12px 14px; font-size: 15px; }
  .user-chip-name { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .exam-body { grid-template-columns: 1fr; padding: 14px 12px 110px; gap: 14px; }
  .qnav { position: static; max-height: none; padding: 10px 12px; }
  .qnav-grid { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .qnav-section { display: none; } .qnav-intro { width: auto; flex: none; }
  .qnav-btn { flex: none; }
  .assign-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .topbar { padding: 0 10px; gap: 8px; }
  .brand-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .page { padding: 18px 14px 56px; }
  h1 { font-size: 1.35rem; }
  .page-actions { width: 100%; } .page-actions .btn { flex: 1; }
  .stat-grid, .stat-grid.four, .stat-grid.six { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 12px 14px; } .stat-num { font-size: 22px; }
  .card { padding: 16px; border-radius: var(--radius-sm); }
  .form-grid { grid-template-columns: 1fr; }
  .deflist { grid-template-columns: 1fr; gap: 2px; } .deflist dd { margin-bottom: 8px; }
  .toolbar { flex-wrap: wrap; } .toolbar input[type=search], .toolbar select { max-width: none; flex: 1 1 140px; }
  .paper { padding: 20px 16px; border-radius: var(--radius-sm); }
  .paper-title { font-size: 1.45rem; }
  .q-text { font-size: 1.05rem; }
  .exam-bar { padding: 8px 12px; gap: 10px; flex-wrap: wrap; }
  .exam-bar .btn { min-height: 36px; padding: 6px 12px; }
  .save-status { order: 3; width: 100%; }
  .exam-foot { gap: 6px; padding-left: 8px; padding-right: 8px; }
  .exam-foot .btn { min-width: 0; flex: 1; font-size: 14px; padding: 8px 6px; }
  .hide-sm { display: none; } .show-sm { display: inline; }
  .answer-input { font-size: 16px; min-height: 220px; }
  .result-actions { margin-left: 0; width: 100%; }
  .corr-controls { flex-direction: column; align-items: stretch; }
  .seg { width: 100%; } .seg-btn { flex: 1; padding: 8px 4px; }
  .corr-bar { margin-left: -14px; margin-right: -14px; border-radius: 0; }
  .corr-bar-actions { width: 100%; } .corr-bar-actions .btn { flex: 1; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal { max-height: 92vh; border-radius: 16px 16px 0 0; }
  .thumb { width: calc(50% - 5px); }
  /* tables become stacked cards */
  .table-wrap { border: 0; background: none; box-shadow: none; overflow: visible; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 10px; padding: 8px 12px; box-shadow: var(--shadow); }
  .table td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; flex: none; }
  .table td:first-child { display: block; text-align: left; font-size: 15px; padding-bottom: 6px; }
  .table td:first-child::before { display: none; }
  .cell-actions { justify-content: flex-end !important; }
  .cell-actions:empty { display: none !important; }
}
@media print {
  .topbar, .exam-bar, .exam-foot, .corr-bar, .qnav, .back, .result-actions { display: none !important; }
  body { background: #fff; } .paper { border: 0; box-shadow: none; }
}

/* ------------------------------------------------------------ AI correction */
.ai-card { border-top: 3px solid var(--violet); }
.ai-card .card-title-row { flex-wrap: wrap; }
.ai-card .field { margin-top: 12px; }
.materials { margin: 4px 0 8px; } .materials .list-row { padding: 6px 0; }
.upload-btn { align-self: flex-start; cursor: pointer; }
.notes-field { display: flex; flex-direction: column; gap: 4px; }
.notes-field > span { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; font-weight: 600; color: var(--violet); }
.notes-field em { font-weight: 400; color: var(--muted); font-style: normal; }
.notes-field textarea { background: var(--violet-soft); border-color: color-mix(in srgb, var(--violet) 30%, var(--line-2)); font-size: 14px; }
.marking-notes { margin-top: 12px; border: 1px dashed color-mix(in srgb, var(--violet) 45%, var(--line-2)); border-radius: var(--radius-sm); padding: 0 12px; background: var(--violet-soft); }
.marking-notes summary { cursor: pointer; padding: 8px 0; font-size: 13px; font-weight: 600; color: var(--violet); display: flex; gap: 6px; align-items: center; }
.marking-notes .pre { padding-bottom: 10px; font-size: 14px; }
.ai-suggestion { font-size: 13px; padding: 7px 10px; border-radius: var(--radius-sm); background: var(--violet-soft); color: var(--ink-2); display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; }
.ai-suggestion .icon { color: var(--violet); align-self: center; }
.corr-label .badge { margin-left: 8px; text-transform: none; letter-spacing: 0; }
.ai-banner { flex-wrap: nowrap; align-items: center; }
.ai-banner > span:not(.spinner) { flex: 1; }
@media (max-width: 640px) { .ai-banner { flex-wrap: wrap; } }
.ai-banner .btn { margin-left: auto; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--info); border-right-color: transparent; animation: spin .8s linear infinite; flex: none; }
.name-box { margin-top: 18px; padding: 16px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface-2); }
.name-box input { font-size: 17px; min-height: 46px; }
.name-box .row-end { margin-top: 10px; }
.add-img em { font-size: 11px; font-style: normal; }
.provider-choice { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.provider-choice input[type=radio] { width: 18px; height: 18px; min-height: 0; margin-top: 2px; accent-color: var(--accent); flex: none; }
/* The admin menu has 8 items: use the menu button on medium screens too so nothing is cut off. */
@media (max-width: 1100px) {
  .nav-toggle { display: inline-grid; }
  .mainnav { position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: 270px; margin: 0; flex-direction: column; padding: 12px; gap: 2px;
    background: var(--surface); border-right: 1px solid var(--line); transform: translateX(-100%); transition: transform .2s; z-index: 40; }
  #shell.nav-open .mainnav { transform: none; box-shadow: var(--shadow-lg); }
  .mainnav a { padding: 12px 14px; font-size: 15px; }
}

/* ------------------------------------------------------------ exam recording */
.rec-box { display: flex; gap: 16px; align-items: flex-start; margin-top: 18px; padding: 16px; border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--line-2)); border-radius: var(--radius); background: var(--danger-soft); }
.rec-preview { flex: none; width: 200px; }
.rec-preview video { width: 200px; height: 150px; background: #111; border-radius: var(--radius-sm); object-fit: cover; transform: scaleX(-1); display: block; }
.mic-meter { height: 6px; background: var(--line); border-radius: 99px; margin-top: 6px; overflow: hidden; }
.mic-meter span { display: block; height: 100%; width: 0; background: var(--ok); transition: width .1s; }
.rec-text { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.rec-text p { margin: 0; }
.rec-live { position: relative; flex: none; width: 72px; height: 54px; border-radius: 6px; overflow: hidden; background: #111; }
.rec-live video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.rec-dot { position: absolute; top: 4px; left: 4px; width: 8px; height: 8px; border-radius: 50%; background: #e5372d; animation: blink 1.2s infinite; }
.rec-label { position: absolute; top: 1px; left: 15px; font: 700 9px var(--font); color: #fff; letter-spacing: .05em; }
@keyframes blink { 50% { opacity: .25; } }
.spinner.inline { display: inline-block; vertical-align: -3px; margin-right: 6px; }
@media (max-width: 640px) { .rec-box { flex-direction: column; } .rec-preview, .rec-preview video { width: 100%; } .rec-live { width: 56px; height: 42px; } }
.flag-banner { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 40%, transparent); align-items: flex-start; flex-wrap: nowrap; }
.flag-banner .icon { color: var(--danger); margin-top: 2px; }
.flag-banner ul { margin: 4px 0 6px; padding-left: 18px; }
.rec-panel { margin: 0 0 16px; border: 1px solid var(--line-2); border-radius: var(--radius); padding: 0 16px; }
.rec-panel > summary { cursor: pointer; padding: 12px 0; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.rec-panel video { width: 100%; max-height: 420px; background: #000; border-radius: var(--radius-sm); }
.rec-h { font-size: .95rem; margin: 14px 0 6px; }
.rec-events .list-row { justify-content: flex-start; gap: 12px; padding: 7px 0; }
.rec-events .link-btn { font-variant-numeric: tabular-nums; min-width: 64px; text-align: left; }
.ev-strong span:not(.muted) { font-weight: 600; color: var(--danger); }
.rec-parts { margin-bottom: 6px; }
.exam-card.locked { opacity: .55; cursor: not-allowed; box-shadow: none; }
.exam-card.locked:hover { border-color: var(--line); box-shadow: none; }
.exam-card.current { border-color: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }

/* ==================================================================================================
   SAILS THEME: warm ivory, near-black ink and cognac leather, with Playfair Display headings,
   in the style of sailsrestaurants.com. Restaurant photography is used on the key screens.
   ================================================================================================== */
@font-face { font-family: "Playfair Display"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/static/fonts/PlayfairDisplay-Regular-latin.woff2") format("woff2"); }
@font-face { font-family: "Playfair Display"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("/static/fonts/PlayfairDisplay-Italic-latin.woff2") format("woff2"); }

:root {
  --bg: #f5f1ea; --surface: #ffffff; --surface-2: #faf7f2; --ink: #1c1a17; --ink-2: #3b3631; --muted: #736b62;
  --line: #e8e1d6; --line-2: #d8cfc1; --accent: #8a4a2b; --accent-hover: #6e3a21; --accent-soft: #f5ebe3; --on-accent: #fff;
  --gold: #b3905a; --btn: #1c1a17; --btn-hover: #8a4a2b; --on-btn: #faf7f2;
  --font-display: "Playfair Display", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-paper: "Playfair Display", "Iowan Old Style", Georgia, serif;
  --shadow: 0 1px 2px rgba(40, 28, 16, .05), 0 2px 8px rgba(40, 28, 16, .04);
  --shadow-lg: 0 18px 48px rgba(40, 28, 16, .18); --radius: 12px; --radius-sm: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14120f; --surface: #1c1916; --surface-2: #221e1a; --ink: #f1ebe2; --ink-2: #d4ccc0; --muted: #a39a8e;
    --line: #2e2923; --line-2: #3d362e; --accent: #d49a74; --accent-hover: #e3b08e; --accent-soft: #2c211b; --on-accent: #1c1a17;
    --gold: #c9a56e; --btn: #f1ebe2; --btn-hover: #d49a74; --on-btn: #1c1a17;
  }
}
body { letter-spacing: .005em; }
h1, h2, .paper-title, .section-head h2, .card-title, .auth-h, .empty-title, .install-title { font-family: var(--font-display); font-weight: 600; letter-spacing: .005em; }
h1 { font-size: 2rem; font-weight: 500; }
.card-title { font-size: 1.2rem; font-weight: 500; }
.eyebrow { font-size: 11.5px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--accent); }

/* buttons: understated ink, cognac on hover */
.btn { border-radius: 999px; padding: 8px 18px; font-weight: 600; letter-spacing: .01em; }
.btn-sm { padding: 5px 13px; }
.btn-primary { background: var(--btn); border-color: var(--btn); color: var(--on-btn); }
.btn-primary:hover { background: var(--btn-hover); border-color: var(--btn-hover); color: #fff; }
.btn-primary.is-busy::after { border-color: var(--on-btn) transparent var(--on-btn) transparent; }
.btn:focus-visible { outline-color: var(--accent); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
input[type=checkbox], .provider-choice input[type=radio] { accent-color: var(--accent); }

/* top bar */
.topbar { background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); height: 64px; }
:root { --topbar-h: 64px; }
.brand { gap: 12px; }
.brand-logo { height: 38px; }
.brand-name { font-family: var(--font-display); font-weight: 500; font-size: 18px; letter-spacing: .02em; }
.mainnav { margin-left: 26px; gap: 4px; }
.mainnav a { font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); border-radius: 0; padding: 10px 10px; border-bottom: 2px solid transparent; }
.mainnav a:hover { background: none; color: var(--accent); }
.mainnav a.active { background: none; color: var(--ink); border-bottom-color: var(--accent); }
.avatar { background: var(--accent-soft); color: var(--accent); font-family: var(--font-display); }
@media (max-width: 1100px) { .mainnav a { border-bottom: 0; border-left: 2px solid transparent; font-size: 13px; } .mainnav a.active { border-left-color: var(--accent); background: var(--accent-soft); } }

/* surfaces */
.card, .table-wrap, .stat, .exam-card, .paper { border-color: var(--line); box-shadow: var(--shadow); }
.card { padding: 22px 24px; }
.page { padding-top: 34px; }
.page-head { margin-bottom: 26px; }
.table th { background: var(--surface-2); letter-spacing: .12em; font-size: 11px; }
.row-link:hover td { background: var(--accent-soft); }
.stat { border-top-width: 0; border-left: 3px solid var(--line-2); }
.stat-num { font-family: var(--font-display); font-weight: 500; font-size: 32px; }
.stat-info { border-left-color: var(--info); } .stat-warn { border-left-color: var(--warn); } .stat-violet { border-left-color: var(--violet); }
.stat-ok, .stat-ok-soft { border-left-color: var(--ok); } .stat-neutral { border-left-color: var(--line-2); }
.badge { border-radius: 999px; }
.section-head { border-bottom-color: var(--accent); }
.section-head h2, .section-title-input { color: var(--accent); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.notice { border-radius: var(--radius-sm); }
.link, a { color: var(--accent); }

/* ---------------- photo heroes */
.hero { position: relative; overflow: hidden; border-radius: 16px; min-height: 230px; padding: 34px 38px; margin-bottom: 26px;
  display: flex; flex-direction: column; justify-content: flex-end; color: #fff; background: #2a241e center / cover no-repeat; box-shadow: var(--shadow); }
.hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, rgba(20,16,12,.82) 0%, rgba(20,16,12,.55) 45%, rgba(20,16,12,.1) 100%); }
.hero > * { position: relative; }
.hero .eyebrow { color: #e8c9a8; }
.hero h1 { color: #fff; font-size: 2.35rem; margin: 6px 0 6px; }
.hero p { margin: 0; color: rgba(255,255,255,.86); max-width: 560px; }
.hero .page-actions { margin-top: 18px; }
.hero .btn { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.5); color: #fff; }
.hero .btn:hover { background: rgba(255,255,255,.22); }
.hero .btn-primary { background: #faf7f2; border-color: #faf7f2; color: #1c1a17; }
.hero .btn-primary:hover { background: #fff; color: var(--accent); }
.hero-bar { background-image: url("/static/brand/photos/bar.jpg"); }
.hero-kitchen { background-image: url("/static/brand/photos/kitchen-team.jpg"); background-position: center 30%; }
.hero-exterior { background-image: url("/static/brand/photos/exterior-sunset.jpg"); background-position: center 60%; }
.hero-private { background-image: url("/static/brand/photos/private-dining.jpg"); }
.hero-open-kitchen { background-image: url("/static/brand/photos/open-kitchen.jpg"); }
.hero-dining { background-image: url("/static/brand/photos/dining-room.jpg"); }
.hero.slim { min-height: 150px; padding: 26px 30px; }
.hero.slim h1 { font-size: 1.9rem; }
.hero.tall { min-height: 300px; }

/* ---------------- sign-in: split screen with the dining room */
.auth-split { min-height: 100vh; display: grid; grid-template-columns: 1.15fr 1fr; background: var(--bg); }
.auth-photo { position: relative; background: #2a241e url("/static/brand/photos/dining-room.jpg") center / cover no-repeat; }
.auth-photo.exterior { background-image: url("/static/brand/photos/exterior-evening.jpg"); }
.auth-photo::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(20,16,12,.05) 40%, rgba(20,16,12,.78) 100%); }
.auth-caption { position: absolute; left: 44px; right: 44px; bottom: 40px; z-index: 1; color: #fff; }
.auth-caption .eyebrow { color: #e8c9a8; }
.auth-caption h2 { font-family: var(--font-display); font-weight: 500; font-size: 2.2rem; margin: 8px 0 6px; color: #fff; }
.auth-caption p { margin: 0; color: rgba(255,255,255,.85); }
.auth-side { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-side .auth-card { box-shadow: none; border: 0; background: transparent; padding: 10px 6px; }
.auth-side .auth-card.wide { width: min(560px, 100%); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 28px; }
.auth-brand h1 { font-family: var(--font-display); letter-spacing: .28em; font-weight: 500; font-size: 1.05rem; color: var(--ink-2); }
.auth-logo { width: 150px; }
@media (prefers-color-scheme: dark) { .auth-logo, .brand-logo { filter: invert(1); } }
@media (max-width: 900px) {
  .auth-split { grid-template-columns: 1fr; grid-template-rows: 240px auto; }
  .auth-caption { left: 22px; right: 22px; bottom: 20px; } .auth-caption h2 { font-size: 1.6rem; }
  .auth-side { padding: 24px 18px 40px; }
}

/* ---------------- exam taking & paper */
.paper { border-radius: 14px; }
.paper-title { font-weight: 500; font-size: 2.1rem; }
.q-text { font-family: var(--font-display); font-size: 1.14rem; line-height: 1.55; }
.q-label { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; }
.qnav-btn.done { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); color: var(--accent); }
.qnav-btn.current, .qnav-intro.current { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); color: var(--ink); }
.progress span { background: var(--accent); }
.exam-bar { background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px); }
.exam-bar-title strong { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; }
.exam-card { border-radius: 14px; overflow: hidden; padding: 0; gap: 0; }
.exam-card > * { margin-left: 20px; margin-right: 20px; }
.exam-card-photo { margin: 0 !important; height: 110px; background: #2a241e center / cover no-repeat; }
.exam-card-photo.p0 { background-image: url("/static/brand/photos/dining-room.jpg"); }
.exam-card-photo.p1 { background-image: url("/static/brand/photos/bar.jpg"); }
.exam-card-photo.p2 { background-image: url("/static/brand/photos/cocktails.jpg"); }
.exam-card-photo.p3 { background-image: url("/static/brand/photos/private-dining.jpg"); }
.exam-card-photo.p4 { background-image: url("/static/brand/photos/open-kitchen.jpg"); }
.exam-card-photo.p5 { background-image: url("/static/brand/photos/olive-oil.jpg"); }
.exam-card .exam-card-top { margin-top: 14px; }
.exam-card h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; margin-top: 8px; margin-bottom: 8px; }
.exam-card .progress, .exam-card .muted, .exam-card .small { margin-bottom: 6px; }
.exam-card .btn { margin: 8px 20px 20px; }
.exam-card.locked .muted { margin-bottom: 20px; }
.exam-card:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }

/* ---------------- submitted */
.success { padding: 0 0 40px; overflow: hidden; }
.success-photo { height: 220px; background: #2a241e url("/static/brand/photos/cocktails.jpg") center / cover no-repeat; margin-bottom: 28px; }
.success-icon { background: var(--accent-soft); color: var(--accent); }
.success h1 { font-family: var(--font-display); font-weight: 500; }
.success p { padding: 0 24px; }

/* ---------------- corrector & admin finishing touches */
.corr-bar { border-radius: 14px 14px 0 0; }
.flag-banner strong, .ai-card .card-title { font-family: var(--font-display); }
.ai-card { border-top: 0; border-left: 3px solid var(--gold); }
.empty-title { font-weight: 500; font-size: 1.2rem; }

/* ---------------- luxury refinements (in the spirit of Hermès / Four Seasons): restraint, hairlines,
   light serif display type, letter-spaced capitals, crisp rectangular controls, generous white space */
:root { --radius: 4px; --radius-sm: 3px; --shadow: 0 1px 0 rgba(40, 28, 16, .03); }
h1 { font-weight: 400; font-size: 2.25rem; letter-spacing: .005em; }
.page-head h1 { font-weight: 400; }
.page-head p.muted { font-size: 15px; }
.card-title, .empty-title { font-weight: 400; }
.card, .table-wrap, .stat, .paper, .exam-card, .modal, .auth-side .auth-card.wide { border-radius: var(--radius); }
.card { padding: 26px 28px; margin-bottom: 24px; }
.page { padding: 42px 32px 80px; }
.grid-2 { gap: 24px; }
.stat-grid { gap: 16px; }
.stat { padding: 20px 22px; }
.stat-label { text-transform: uppercase; letter-spacing: .14em; font-size: 11px; font-weight: 600; }
.stat-num { font-weight: 400; font-size: 34px; }
.btn { border-radius: 2px; min-height: 42px; padding: 9px 22px; }
.btn-sm { min-height: 34px; padding: 5px 14px; }
.btn-primary, .hero .btn { text-transform: uppercase; letter-spacing: .14em; font-size: 12px; font-weight: 600; }
.btn-primary.btn-lg { font-size: 12.5px; padding: 12px 30px; }
input, select, textarea { border-radius: 2px; }
.badge { border-radius: 2px; letter-spacing: .04em; }
.hero { border-radius: 4px; min-height: 260px; padding: 44px 48px; }
.hero h1 { font-weight: 400; font-size: 2.6rem; }
.hero.slim { min-height: 170px; }
.paper { border-radius: 4px; padding: 44px 52px; }
.paper-title { font-weight: 400; font-size: 2.3rem; }
.q-label { font-weight: 500; letter-spacing: .01em; }
.exam-card { border-radius: 4px; }
.exam-card h3 { font-weight: 500; }
.modal { border-radius: 4px; }
.table th { font-weight: 600; }
.qnav, .pages-panel, .rec-panel, .marking-notes, .q-edit, .check-list, .install-steps, .name-box, .rec-box { border-radius: 4px; }
.qnav-btn { border-radius: 2px; }
.toast { border-radius: 2px; }
.auth-caption h2 { font-weight: 400; font-size: 2.5rem; }
@media (max-width: 640px) {
  .page { padding: 22px 16px 60px; } h1 { font-size: 1.7rem; }
  .hero { padding: 26px 22px; min-height: 200px; } .hero h1 { font-size: 1.9rem; }
  .paper { padding: 22px 18px; } .paper-title { font-size: 1.6rem; }
}
.paper.success { padding: 0 0 44px; }
.paper.success h1 { font-weight: 400; font-size: 2.1rem; }
@media (max-width: 1100px) {
  .mainnav { margin-left: 0; height: calc(100vh - var(--topbar-h)); padding-top: 18px; background: var(--surface); }
}
.brand-short { display: none; font-family: var(--font-display); font-size: 18px; }
@media (max-width: 480px) { .brand-name { display: none; } .brand-short { display: inline; } }
.rec-box { background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--accent); }
.rec-text strong { font-family: var(--font-display); font-weight: 500; font-size: 1.08rem; display: flex; gap: 8px; align-items: center; }
.name-box { background: var(--surface-2); border-color: var(--line); }
.intro-facts .muted.small, .result-bar .muted.small { text-transform: uppercase; letter-spacing: .12em; font-size: 10.5px; font-weight: 600; }
.intro-facts strong { font-family: var(--font-display); font-weight: 500; font-size: 1.3rem; }
.instructions { background: var(--surface-2); border-color: var(--line); }
.instructions-label, .answer-label, .answer-ro .answer-label { letter-spacing: .14em; }
.flag-banner { border-left: 3px solid var(--danger); }

/* ---------------- full-screen lock, screen sharing step, camera + screen player */
.lock-overlay { position: fixed; inset: 0; z-index: 90; background: rgba(20, 16, 12, .94); display: grid; place-items: center; padding: 20px; }
.lock-card { max-width: 440px; text-align: center; color: #f1ebe2; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.lock-card h2 { font-family: var(--font-display); font-weight: 400; font-size: 2rem; color: #fff; margin: 0; }
.lock-card p { margin: 0 0 8px; color: rgba(255,255,255,.8); }
.lock-icon { color: #e8c9a8; }
.lock-card .btn-primary { background: #faf7f2; border-color: #faf7f2; color: #1c1a17; }
.screen-step { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.rec-videos { display: grid; grid-template-columns: 1fr; gap: 10px; }
.rec-videos.two { grid-template-columns: 1.6fr 1fr; }
.rec-videos figure { margin: 0; }
.rec-videos figcaption { font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.rec-videos video { width: 100%; background: #000; border-radius: var(--radius-sm); max-height: 420px; }
@media (max-width: 800px) { .rec-videos.two { grid-template-columns: 1fr; } }
.lock-overlay { background: #14100c; }

/* ---------------- marking methods */
.marking-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.marking-option { display: flex; gap: 10px; align-items: flex-start; padding: 14px; border: 1px solid var(--line-2); border-radius: var(--radius); cursor: pointer; background: var(--surface); }
.marking-option.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: var(--accent-soft); }
.marking-option input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; min-height: 0; flex: none; }
.marking-option span { display: flex; flex-direction: column; gap: 3px; }
.marking-option strong { font-family: var(--font-display); font-weight: 500; font-size: 1.05rem; }
.marking-option em { font-style: normal; font-size: 13px; color: var(--muted); }
@media (max-width: 800px) { .marking-options { grid-template-columns: 1fr; } }
.mistake-ctl { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mistake-label { font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); }
.autofail { display: flex; gap: 8px; align-items: center; font-size: 13.5px; padding: 6px 10px; border: 1px dashed var(--line-2); border-radius: var(--radius-sm); cursor: pointer; color: var(--ink-2); align-self: flex-start; }
.autofail input { accent-color: var(--danger); width: 16px; height: 16px; min-height: 0; }
.autofail.on { border: 1px solid var(--danger); background: var(--danger-soft); color: var(--danger); }
#liveresult .badge { margin-left: 4px; }
.it-steps { margin-top: 16px; border: 1px solid var(--line); border-radius: var(--radius); padding: 0 16px; background: var(--surface-2); }
.it-steps summary { cursor: pointer; padding: 12px 0; font-weight: 600; }
.it-steps ol { margin: 0 0 14px; padding-left: 20px; font-size: 14px; } .it-steps li { margin: 6px 0; }

/* Admin: change an exam's corrector from the correction page */
.inline-select { min-height: 32px; padding: 4px 8px; font: inherit; font-weight: 600; max-width: 100%; }

/* PDF conversion with instructions */
.hidden-while-converting { display: none; }
.import-notes { margin: 6px 0 4px; padding-left: 1.2em; display: grid; gap: 2px; }
.pre { white-space: pre-wrap; margin: 6px 0 0; }
.unused-pics { display: grid; gap: 8px; padding: 12px 0 4px; border-top: 1px solid var(--line); margin-top: 8px; }
.unused-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.unused-grid figure { margin: 0; display: grid; gap: 4px; }
.unused-grid img { width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--surface-2); border: 1px solid var(--line); }

/* Invitation / sign-in link to copy */
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .85rem; }
