/* Exam Lab design tokens and shared components (same look as the approved prototypes). Fonts are served locally so the
   site works on a closed university network. */
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap; src: url("../fonts/ibm-plex-sans-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap; src: url("../fonts/ibm-plex-sans-500.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-display: swap; src: url("../fonts/ibm-plex-sans-600.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 700; font-display: swap; src: url("../fonts/ibm-plex-sans-700.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-display: swap; src: url("../fonts/jetbrains-mono-400.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 500; font-display: swap; src: url("../fonts/jetbrains-mono-500.woff2") format("woff2"); }

:root {
  --bg: #f3f5f7; --panel: #ffffff; --panel-2: #f8f9fb; --sunken: #eef1f4;
  --ink: #101820; --ink-2: #3a4652; --muted: #6a7682; --line: #e2e6ea; --line-strong: #cad1d8;
  --accent: #0b7a70; --accent-hover: #09675f; --accent-soft: #e0f1ee; --accent-ink: #ffffff;
  --ok: #157046; --ok-soft: #e2f3e9; --warn: #9e5a06; --warn-soft: #fbeedb; --bad: #c0311e; --bad-soft: #fbe3df; --bad-ink: #ffffff;
  --canvas: #ffffff;
  --shadow-sm: 0 1px 2px rgba(16, 24, 32, .08); --shadow-lg: 0 12px 40px rgba(16, 24, 32, .18);
  --ed-bg: #ffffff; --ed-gutter: #fbfcfd; --ed-num: #a6b0ba; --ed-num-active: #3a4652; --ed-active: #f4f7f9; --ed-sel: #cfe8e4;
  --ed-cursor: #101820; --ed-match: #d8efe9; --ed-err-line: rgba(192, 49, 30, .07); --ed-warn-line: rgba(158, 90, 6, .07);
  --t-tag: #116329; --t-punc: #6e7781; --t-attr: #6f42c1; --t-str: #0a3069; --t-com: #6e7781; --t-prop: #0550ae;
  --t-atom: #953800; --t-num: #0550ae; --t-kw: #cf222e; --t-sel: #8250df; --t-id: #953800;
  --ui: "IBM Plex Sans", "Segoe UI", system-ui, Tahoma, Arial, sans-serif;
  --mono: "JetBrains Mono", Consolas, "Courier New", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0e12; --panel: #10161c; --panel-2: #141b22; --sunken: #0c1116; --ink: #e6edf3; --ink-2: #b9c4ce; --muted: #8494a2;
    --line: #212b35; --line-strong: #2e3a46; --accent: #2fb3a5; --accent-hover: #4cc6b8; --accent-soft: #0f2c29; --accent-ink: #041f1b;
    --ok: #43bf80; --ok-soft: #0f281b; --warn: #e2a347; --warn-soft: #2d220f; --bad: #f2735f; --bad-soft: #311613; --bad-ink: #2a0b06;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
    --ed-bg: #0d1318; --ed-gutter: #0d1318; --ed-num: #46535f; --ed-num-active: #b9c4ce; --ed-active: #131b22; --ed-sel: #1d3a36;
    --ed-cursor: #e6edf3; --ed-match: #1d3a36; --ed-err-line: rgba(242, 115, 95, .09); --ed-warn-line: rgba(226, 163, 71, .08);
    --t-tag: #7ee787; --t-punc: #8b949e; --t-attr: #d2a8ff; --t-str: #a5d6ff; --t-com: #8b949e; --t-prop: #79c0ff;
    --t-atom: #ffa657; --t-num: #79c0ff; --t-kw: #ff7b72; --t-sel: #d2a8ff; --t-id: #ffa657;
    color-scheme: dark;
  }
}

html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--ui); font-size: 14px; line-height: 1.45; }
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
a { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
code { font-family: var(--mono); font-size: .88em; padding: 0 4px; border-radius: 4px; background: var(--sunken); color: var(--ink); }
kbd { font-family: var(--mono); font-size: 10.5px; padding: 0 4px; border-radius: 4px; border: 1px solid currentColor; opacity: .7; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 7px;
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink); font-size: 13px; font-weight: 500; white-space: nowrap;
  text-decoration: none; transition: background .12s, border-color .12s; }
.btn:hover:not(:disabled) { background: var(--panel-2); border-color: var(--muted); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.lg { height: 40px; padding: 0 18px; font-size: 14px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover:not(:disabled) { background: var(--sunken); border-color: transparent; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: var(--bad-ink); font-weight: 600; }
.btn.danger:hover:not(:disabled) { filter: brightness(1.07); background: var(--bad); }
.btn.danger-ghost { background: transparent; border-color: transparent; color: var(--bad); }
.btn.danger-ghost:hover:not(:disabled) { background: var(--bad-soft); }
.btn.block { width: 100%; }
.icon-btn { width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--muted); }
.icon-btn:hover:not(:disabled) { background: var(--sunken); color: var(--ink); }
.linkish { border: 0; background: none; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; font-size: 12px; padding: 0; }

.seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--sunken); border: 1px solid var(--line); }
.seg button { height: 26px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 12.5px;
  display: inline-flex; align-items: center; gap: 6px; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }
.seg.icons button { padding: 0 7px; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 1px 9px; border-radius: 99px; white-space: nowrap; }
.pill svg { width: 12px; height: 12px; }
.pill.draft, .pill.new, .pill.st-new { background: var(--sunken); color: var(--ink-2); }
.pill.draft { border: 1px dashed var(--line-strong); }
.pill.live, .pill.info { background: var(--accent-soft); color: var(--accent); }
.pill.ok, .pill.st-saved { background: var(--ok-soft); color: var(--ok); }
.pill.warn, .pill.st-dirty { background: var(--warn-soft); color: var(--warn); }
.pill.bad, .pill.st-pending { background: var(--bad-soft); color: var(--bad); }

.input { width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel);
  color: var(--ink); font: inherit; font-size: 13.5px; }
textarea.input { height: auto; min-height: 96px; padding: 9px 10px; line-height: 1.6; resize: vertical; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.invalid { border-color: var(--bad); }
.field { display: grid; gap: 6px; min-width: 0; }
.field + .field { margin-top: 14px; }
.field > label, .flabel { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.err { font-size: 12px; color: var(--bad); }
.hint { font-size: 12px; color: var(--muted); }
.label-caps { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.eyebrow { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 28px; padding: 0 11px; border-radius: 99px; border: 1px solid var(--line-strong); background: var(--panel); font-size: 12.5px; color: var(--ink-2); }
.chip:hover:not(:disabled) { border-color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.switch { appearance: none; width: 36px; height: 20px; border-radius: 99px; background: var(--line-strong); position: relative; flex: none; cursor: pointer; transition: background .15s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--panel); box-shadow: var(--shadow-sm); transition: transform .15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(16px); }

/* simple page frame used by lists, login, monitor, grade */
.page { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; }
.topbar { display: flex; align-items: center; gap: 16px; min-height: 56px; padding-block: 8px; padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px));
  background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; text-decoration: none; color: inherit; }
.logo { width: 32px; height: 32px; border-radius: 8px; background: var(--ink); color: var(--panel); display: grid; place-items: center; font: 600 12px var(--mono); flex: none; }
.brand strong { display: block; font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-end { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; }
.who { display: flex; align-items: center; gap: 8px; }
.who strong { display: block; font-size: 13px; font-weight: 600; line-height: 1.25; white-space: nowrap; }
.who small { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; }
.container { width: 100%; max-width: 1080px; margin: 0 auto; padding-block: 24px 64px; padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)); }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 2px 0 0; font-size: 24px; letter-spacing: -.015em; }
.page-head .tools { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.card-pad { padding: 18px 20px; }
.card + .card { margin-top: 14px; }
.card h2 { margin: 0 0 4px; font-size: 15px; }
.card p { margin: 0 0 12px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.flash { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
.flash li { padding: 10px 14px; border-radius: 9px; font-size: 13.5px; }
.flash .success { background: var(--ok-soft); color: var(--ok); }
.flash .error { background: var(--bad-soft); color: var(--bad); }
.flash .info, .flash .warning { background: var(--warn-soft); color: var(--warn); }

.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--panel-2); }
.tbl .r { text-align: right; }

.toast { position: fixed; bottom: 44px; left: 50%; transform: translate(-50%, 12px); opacity: 0; pointer-events: none; display: inline-flex; align-items: center;
  gap: 8px; padding: 9px 14px; border-radius: 9px; background: var(--ink); color: var(--panel); font-size: 13px; box-shadow: var(--shadow-lg);
  transition: opacity .2s, transform .2s; z-index: 300; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); color: var(--bad-ink); }

.modal { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px; background: rgba(6, 10, 14, .55); }
.sheet { width: min(520px, 100%); max-height: 100%; display: flex; flex-direction: column; background: var(--panel); border-radius: 14px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--line); overflow: hidden; }
.sheet.wide { width: min(680px, 100%); }
.sheet-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 12px; }
.sheet-head h2 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.sheet-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.sheet-head .icon-btn { margin-inline-start: auto; }
.sheet-body { padding: 4px 20px 16px; overflow: auto; }
.sheet-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--panel-2); flex-wrap: wrap; }
.checklist { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.checklist li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); font-size: 13px; line-height: 1.5; }
.checklist li:first-child { border-top: 0; }
.checklist .ok { color: var(--ok); }
.checklist .bad { color: var(--bad); }
.checklist .warn { color: var(--warn); }
.checklist small { display: block; color: var(--muted); font-size: 12px; }

/* CodeMirror theme shared by every editor */
.cm-s-exam.CodeMirror { background: var(--ed-bg); color: var(--ink); font-family: var(--mono); font-size: var(--ed-size, 14px); line-height: 1.65; font-variant-ligatures: none; }
.cm-s-exam .CodeMirror-lines { padding: 10px 0 40px; }
.cm-s-exam pre.CodeMirror-line, .cm-s-exam pre.CodeMirror-line-like { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
.cm-s-exam .CodeMirror-gutters { background: var(--ed-gutter); border-right: 1px solid var(--line); }
.cm-s-exam .CodeMirror-linenumber { color: var(--ed-num); padding: 0 10px 0 6px; min-width: 26px; }
.cm-s-exam .CodeMirror-activeline-gutter .CodeMirror-linenumber { color: var(--ed-num-active); }
.cm-s-exam .CodeMirror-activeline-background { background: var(--ed-active); }
.cm-s-exam .CodeMirror-cursor { border-left: 2px solid var(--ed-cursor); }
.cm-s-exam .CodeMirror-selected, .cm-s-exam.CodeMirror-focused .CodeMirror-selected { background: var(--ed-sel); }
.cm-s-exam .CodeMirror-line::selection, .cm-s-exam .CodeMirror-line > span::selection, .cm-s-exam .CodeMirror-line > span > span::selection { background: var(--ed-sel); }
.cm-s-exam .CodeMirror-gutter-filler, .cm-s-exam .CodeMirror-scrollbar-filler { background: var(--ed-bg); }
.cm-s-exam span.cm-tag { color: var(--t-tag); }
.cm-s-exam span.cm-tag.cm-bracket, .cm-s-exam span.cm-bracket { color: var(--t-punc); }
.cm-s-exam span.cm-attribute { color: var(--t-attr); }
.cm-s-exam span.cm-string, .cm-s-exam span.cm-string-2 { color: var(--t-str); }
.cm-s-exam span.cm-comment { color: var(--t-com); font-style: italic; }
.cm-s-exam span.cm-property { color: var(--t-prop); }
.cm-s-exam span.cm-atom, .cm-s-exam span.cm-variable-2, .cm-s-exam span.cm-variable-3, .cm-s-exam span.cm-type { color: var(--t-atom); }
.cm-s-exam span.cm-number { color: var(--t-num); }
.cm-s-exam span.cm-keyword, .cm-s-exam span.cm-def { color: var(--t-kw); }
.cm-s-exam span.cm-qualifier { color: var(--t-sel); }
.cm-s-exam span.cm-builtin { color: var(--t-id); }
.cm-s-exam span.cm-meta { color: var(--t-punc); }
.cm-s-exam span.cm-error { color: inherit; text-decoration: underline wavy var(--bad); text-underline-offset: 3px; }
.cm-s-exam span.CodeMirror-matchingbracket { color: inherit !important; background: var(--ed-match); outline: 1px solid var(--accent); }
.cm-s-exam .CodeMirror-matchingtag { background: var(--ed-match); }
.cm-problems { width: 16px; }
.pm { display: block; width: 8px; height: 8px; border-radius: 50%; margin: 7px 0 0 5px; cursor: help; }
.pm.error { background: var(--bad); }
.pm.warn { background: var(--warn); border-radius: 1px; transform: rotate(45deg) scale(.85); }
.ln-error { background: var(--ed-err-line); }
.ln-warn { background: var(--ed-warn-line); }
.CodeMirror-hints { font-family: var(--mono); font-size: 12.5px; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow-lg); padding: 4px; z-index: 250; }
.CodeMirror-hint { color: var(--ink); padding: 3px 10px; border-radius: 5px; }
li.CodeMirror-hint-active { background: var(--accent); color: var(--accent-ink); }
.fi { width: 9px; height: 9px; border-radius: 2px; flex: none; display: inline-block; }
.fi.html { background: #e4703a; }
.fi.css { background: #3a7be4; }
.fi.img { background: #8a5cd6; }
.tchip { font: 600 10.5px var(--ui); min-width: 18px; height: 17px; padding: 0 5px; border-radius: 99px; display: inline-grid; place-items: center; }
.tchip.err { background: var(--bad-soft); color: var(--bad); }
.tchip.warn { background: var(--warn-soft); color: var(--warn); }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 0 12px; border: 0; background: transparent; border-bottom: 2px solid transparent; color: var(--muted); font: 12.5px var(--mono); white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
