:root {
  color-scheme: light;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e1e5ee;
  --border-strong: #c9d0de;
  --text: #182033;
  --muted: #5d6679;
  --faint: #8a93a6;
  --primary: #2347c9;
  --primary-hover: #1b3aa8;
  --primary-soft: #eaefff;
  --success: #12704a;
  --success-soft: #e3f5ec;
  --warn: #8f5600;
  --warn-soft: #fff3d9;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --info: #1f5fa8;
  --info-soft: #e8f1fc;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.18);
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', Ubuntu, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 620; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0 0 10px; }
code, pre, .mono { font-family: var(--mono); font-size: 13px; }
pre { margin: 0; white-space: pre-wrap; word-break: break-word; }
.boot { padding: 80px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 22px;
  height: 56px; padding: 0 20px;
  background: #13204a; color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: #fff; letter-spacing: 0.2px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 7px;
  background: #3a63f0; font-family: var(--mono); font-size: 15px;
}
.brand small { display: block; font-weight: 450; font-size: 11px; opacity: 0.7; letter-spacing: 0; white-space: nowrap; }
.nav { display: flex; gap: 4px; }
.nav a { color: rgba(255, 255, 255, 0.78); padding: 7px 12px; border-radius: 6px; font-weight: 500; white-space: nowrap; }
.nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); text-decoration: none; }
.nav a.active { color: #fff; background: rgba(255, 255, 255, 0.14); }
.user-chip { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 13px; }
.user-chip .who { text-align: right; line-height: 1.2; }
.user-chip .who small { display: block; opacity: 0.65; }
.topbar .btn.ghost { color: #fff; border-color: rgba(255, 255, 255, 0.25); }
.topbar .btn.ghost:hover { background: rgba(255, 255, 255, 0.1); }

.page { max-width: 1240px; margin: 0 auto; padding: 24px 20px 60px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 7px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer;
  white-space: nowrap; transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-outline { color: var(--danger); border-color: #f0b8b3; }
.btn.danger-outline:hover { background: var(--danger-soft); }
.btn.ghost { background: transparent; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.lg { height: 42px; padding: 0 20px; font-size: 15px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-body { padding: 18px; }
.card + .card { margin-top: 16px; }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.stat .label { font-size: 12px; color: var(--muted); font-weight: 550; text-transform: uppercase; letter-spacing: 0.4px; }
.stat .value { font-size: 24px; font-weight: 680; margin-top: 2px; }
.stat.good .value { color: var(--success); }
.stat.warn .value { color: var(--warn); }
.stat.bad .value { color: var(--danger); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; background: var(--surface-2); white-space: nowrap; }
.table tbody tr:hover { background: #fafbfe; }
.table tbody tr:last-child td { border-bottom: none; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.clickable { cursor: pointer; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 11px;
  font-size: 12px; font-weight: 600; background: #eef0f5; color: #444d60; white-space: nowrap;
}
.badge.dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.green { background: var(--success-soft); color: var(--success); }
.badge.amber { background: var(--warn-soft); color: var(--warn); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.blue { background: var(--info-soft); color: var(--info); }
.badge.violet { background: #f0ebff; color: #5b3cc4; }
.badge.gray { background: #eef0f5; color: #5d6679; }
.verdict { font-family: var(--mono); font-size: 11.5px; font-weight: 700; letter-spacing: 0.3px; }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; grid-column: span 12; }
.field.half { grid-column: span 6; }
.field.third { grid-column: span 4; }
.field.quarter { grid-column: span 3; }
.field label, .label-text { font-size: 12.5px; font-weight: 600; color: #3b4458; }
.field .hint { font-size: 12px; color: var(--faint); }
input[type='text'], input[type='password'], input[type='number'], input[type='search'], input[type='datetime-local'], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 7px;
  background: #fff; color: var(--text); font: inherit;
}
textarea { resize: vertical; min-height: 70px; }
textarea.code, .mono-input { font-family: var(--mono); font-size: 13px; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b7c6fb; outline-offset: 0; border-color: var(--primary); }
/* Required fields: <label class="req"> shows a red asterisk; .req-note explains it ("* Required"). */
.req::after { content: ' *'; color: var(--danger); font-weight: 700; }
.req-note { font-size: 12px; color: var(--muted); font-weight: 500; }
.req-note::before { content: '* '; color: var(--danger); font-weight: 700; }
.check { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.check input { margin-top: 3px; }
.check small { display: block; color: var(--muted); }
.error-text { color: var(--danger); font-size: 13px; }

/* ---------- alerts ---------- */
.alert { padding: 11px 14px; border-radius: 7px; border: 1px solid; font-size: 13.5px; }
.alert.info { background: var(--info-soft); border-color: #c7dbf5; color: #173f6f; }
.alert.warn { background: var(--warn-soft); border-color: #f3d79b; color: #6b4100; }
.alert.danger { background: var(--danger-soft); border-color: #f3c0bb; color: #7a1a12; }
.alert.success { background: var(--success-soft); border-color: #b5e2cb; color: #0c4f34; }

/* ---------- toasts & modal ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 240px; max-width: 380px; padding: 11px 14px; border-radius: 8px; background: #1d2438; color: #fff;
  box-shadow: var(--shadow-lg); font-size: 13.5px; animation: toast-in 0.18s ease-out;
}
.toast.success { background: #0f5f3f; }
.toast.error { background: #9a1d14; }
.toast.warn { background: #7a4a00; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.modal-backdrop { position: fixed; inset: 0; z-index: 500; background: rgba(13, 20, 38, 0.55); display: grid; place-items: center; padding: 16px; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: #fff; border-radius: 10px; box-shadow: var(--shadow-lg); }
.modal.wide { width: min(820px, 100%); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); border-radius: 0 0 10px 10px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-side {
  background: linear-gradient(160deg, #13204a 0%, #1d3381 60%, #2347c9 100%); color: #fff; padding: 56px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.login-side h1 { font-size: 34px; font-weight: 720; margin: 26px 0 12px; line-height: 1.15; }
.login-side p { opacity: 0.82; font-size: 15px; max-width: 440px; }
.login-side ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.login-side li { display: flex; gap: 10px; align-items: flex-start; opacity: 0.92; }
.login-side li::before { content: '✓'; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: rgba(255, 255, 255, 0.16); font-size: 12px; flex: none; }
.code-deco { background: rgba(6, 12, 34, 0.45); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 10px; overflow: hidden; max-width: 460px; }
.code-deco-bar { display: flex; align-items: center; gap: 6px; padding: 9px 12px; background: rgba(255, 255, 255, 0.05); border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.code-deco-bar i { width: 10px; height: 10px; border-radius: 50%; background: rgba(255, 255, 255, 0.22); }
.code-deco-bar span { margin-left: 8px; font-family: var(--mono); font-size: 11.5px; opacity: 0.6; }
.code-deco pre { font-family: var(--mono); font-size: 12.5px; padding: 14px 16px; white-space: pre; color: #dfe6ff; }
.code-deco .t-type { color: #8fb4ff; }
.code-deco .t-kw { color: #c79bff; }
.code-deco .t-fn { color: #7fe0d0; }
.code-deco .t-str { color: #ffd08a; }
.code-deco .t-num { color: #ffab8a; }
.login-main { display: flex; flex-direction: column; min-height: 100vh; padding: 40px 24px 20px; }
.login-center { flex: 1; display: grid; place-items: center; }
.login-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.07); padding: 30px 32px 32px;
}
.login-card h2 { font-size: 22px; margin-bottom: 4px; }
.login-logo { text-align: center; padding-bottom: 20px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.login-logo img { width: 240px; max-width: 100%; height: auto; vertical-align: top; }
.pw-wrap { position: relative; }
.pw-wrap input { width: 100%; padding-right: 64px; }
.pw-toggle { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); border-color: transparent; color: var(--muted); }
.pw-toggle:hover { color: var(--text); }
.login-foot { text-align: center; font-size: 12.5px; color: var(--faint); padding-top: 24px; }

/* ---------- markdown-ish content ---------- */
.prose { font-size: 14.5px; line-height: 1.6; }
.prose p { margin: 0 0 10px; }
.prose ul { margin: 0 0 10px; padding-left: 20px; }
.prose li { margin-bottom: 4px; }
.prose code { background: #eef1f7; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.prose pre { background: #f3f5fa; border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; margin: 0 0 10px; }
.prose pre code { background: none; padding: 0; }

/* ---------- workspace (student coding screen) ---------- */
.ws { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
.ws-top { display: flex; align-items: center; gap: 16px; height: 54px; padding: 0 16px; background: #13204a; color: #fff; flex: none; }
.ws-title { font-weight: 650; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-title small { display: block; font-weight: 400; font-size: 11.5px; opacity: 0.7; }
.ws-top .spacer { flex: 1; }
.timer { font-family: var(--mono); font-size: 15px; font-weight: 700; padding: 5px 10px; border-radius: 6px; background: rgba(255, 255, 255, 0.1); }
.timer.low { background: #b42318; animation: pulse 1s infinite alternate; }
@keyframes pulse { to { background: #7d150d; } }
.save-state { font-size: 12.5px; opacity: 0.85; min-width: 110px; text-align: right; }
.save-state.err { color: #ffb4ab; opacity: 1; }
.warn-count { font-size: 12.5px; padding: 4px 9px; border-radius: 6px; background: rgba(255, 196, 0, 0.18); color: #ffd666; }
.prefix-chip { font-size: 12.5px; padding: 4px 9px; border-radius: 6px; background: rgba(255, 255, 255, 0.12); white-space: nowrap; }
.prefix-chip code { font-size: 13px; font-weight: 700; color: #9fd0ff; }
.btn.ghost-light { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.3); }
.btn.ghost-light:hover { background: rgba(255, 255, 255, 0.1); }
.ws-body { flex: 1; display: grid; grid-template-columns: 64px minmax(320px, 40%) 1fr; min-height: 0; }
.ws-rail { background: #fff; border-right: 1px solid var(--border); padding: 10px 8px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.q-pill {
  position: relative; width: 46px; height: 46px; border-radius: 9px; border: 1.5px solid var(--border-strong);
  background: #fff; font-weight: 700; font-size: 14px; cursor: pointer; color: var(--muted);
}
.q-pill:hover { border-color: var(--primary); color: var(--primary); }
.q-pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.q-pill .dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: transparent; }
.q-pill.started .dot { background: #e5a000; }
.q-pill.passed .dot { background: #18a058; }
.ws-question { overflow-y: auto; background: #fff; border-right: 1px solid var(--border); padding: 20px 22px 40px; user-select: none; -webkit-user-select: none; }
.ws-question h2 { font-size: 19px; margin: 6px 0 12px; }
.ws-question h4 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); margin: 18px 0 6px; }
.sample { border: 1px solid var(--border); border-radius: 7px; margin-top: 10px; overflow: hidden; }
.sample-head { padding: 6px 10px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 12px; font-weight: 600; color: var(--muted); }
.sample-grid { display: grid; grid-template-columns: 1fr 1fr; }
.sample-grid > div { padding: 8px 10px; min-width: 0; }
.sample-grid > div + div { border-left: 1px solid var(--border); }
.sample-grid .cap { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--faint); margin-bottom: 4px; }
.sample pre { font-size: 12.5px; max-height: 220px; overflow: auto; }
.ws-editor { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.editor-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: #fff; border-bottom: 1px solid var(--border); flex: none; }
.editor-bar .lang { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.editor-bar .hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
@media (max-width: 1180px) { .editor-bar .hint { display: none; } }
.editor-host { flex: 1; min-height: 0; position: relative; }
.editor-host .CodeMirror { position: absolute; inset: 0; height: auto; font-family: var(--mono); font-size: 14px; line-height: 1.55; }

/* ---------- unique answers (naming rule) ---------- */
.name-rule { border: 1px solid #c7dbf5; background: var(--info-soft); color: #173f6f; border-radius: 8px; padding: 12px 14px; margin: 0 0 16px; font-size: 13.5px; }
.name-rule p { margin: 6px 0 10px; }
.name-rule ul { margin: 10px 0 0; padding-left: 18px; display: grid; gap: 5px; }
.name-rule code { background: rgba(35, 71, 201, 0.08); padding: 1px 5px; border-radius: 4px; color: #142f8f; }
.name-rule-head { font-weight: 650; font-size: 14.5px; }
.name-rule code.prefix { font-size: 15px; font-weight: 700; }
.name-rule.compact { margin: 14px 0 0; display: grid; gap: 4px; }
.name-example { margin: 0; padding: 10px 12px; background: #13204a; color: #e6ecff; border-radius: 6px; font-size: 12.5px; line-height: 1.5; overflow-x: auto; white-space: pre; }
.name-check { flex: none; display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; border-top: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font-size: 13px; max-height: 30%; overflow-y: auto; }
.name-check .ic { flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--border); color: var(--muted); }
.name-check ul { margin: 4px 0 0; padding-left: 18px; }
.name-check code { font-size: 12.5px; }
.name-check.ok { background: var(--success-soft); color: var(--success); }
.name-check.ok .ic { background: var(--success); color: #fff; }
.name-check.bad { background: var(--danger-soft); color: #7a1a12; }
.name-check.bad .ic { background: var(--danger); color: #fff; }
.q-pill.names-bad { border-color: var(--danger); }
.q-pill.names-bad .dot { background: var(--danger); }

/* ---------- similarity check ---------- */
.sim-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sim-compare .code-box .CodeMirror { height: 60vh; }
.sim-line { background: #fff1c2; }
.modal.xwide { width: min(1240px, 100%); }
@media (max-width: 900px) { .sim-compare { grid-template-columns: 1fr; } }
.results { flex: none; max-height: 42%; overflow-y: auto; background: #fff; border-top: 1px solid var(--border); }
.results-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: #fff; }
.result-item { border-bottom: 1px solid var(--border); }
.result-item summary { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; list-style: none; }
.result-item summary::-webkit-details-marker { display: none; }
.result-item .io { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border-top: 1px solid var(--border); }
.result-item .io > div { padding: 8px 12px; min-width: 0; }
.result-item .io > div + div { border-left: 1px solid var(--border); }
.result-item .io pre { font-size: 12.5px; max-height: 200px; overflow: auto; }
.compile-out { margin: 10px 12px; padding: 10px 12px; background: #2a1416; color: #ffd9d4; border-radius: 6px; font-size: 12.5px; max-height: 260px; overflow: auto; }
.compile-out.warnings { background: #2b2410; color: #ffe8a3; }
.diff-line { background: #ffe1de; }

.overlay { position: fixed; inset: 0; z-index: 300; background: rgba(10, 16, 32, 0.82); display: grid; place-items: center; padding: 16px; }
.overlay .panel { width: min(600px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: #fff; border-radius: 12px; padding: 26px 28px; box-shadow: var(--shadow-lg); }
.overlay .panel h2 { font-size: 20px; margin-bottom: 8px; }
.rules { margin: 14px 0 18px; padding: 0; list-style: none; display: grid; gap: 9px; }
.rules li { display: flex; gap: 10px; align-items: flex-start; }
.rules li .ic { flex: none; width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-size: 13px; }
.banner { position: fixed; left: 50%; top: 64px; transform: translateX(-50%); z-index: 250; max-width: 90vw; }

/* ---------- assignment cards (student) ---------- */
.a-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.a-card { display: flex; flex-direction: column; gap: 10px; padding: 18px; }
.a-grid > .card + .card { margin-top: 0; }
.a-card .meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.a-card .foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 6px; }
.score-big { font-size: 26px; font-weight: 720; }
.score-big small { font-size: 14px; color: var(--muted); font-weight: 500; }

/* ---------- teacher misc ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 12px; background: #fff; border-radius: var(--radius) var(--radius) 0 0; }
.tabs button { border: none; background: none; padding: 11px 12px; font: inherit; font-weight: 550; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; margin-bottom: -1px; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs button .count { margin-left: 4px; font-size: 11.5px; background: #eef0f5; padding: 1px 6px; border-radius: 9px; }
.flag-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 10px; }
.flag-chip.high { background: var(--danger-soft); color: var(--danger); }
.flag-chip.medium { background: var(--warn-soft); color: var(--warn); }
.flag-chip.low { background: #eef0f5; color: var(--muted); }
.flag-chip.none { background: var(--success-soft); color: var(--success); }
.progress { height: 6px; border-radius: 3px; background: #e8ebf2; overflow: hidden; min-width: 60px; }
.progress > span { display: block; height: 100%; background: var(--primary); }
.bank-layout { display: grid; grid-template-columns: 250px 1fr; gap: 16px; align-items: start; }
.bank-list { padding: 8px; }
.bank-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 9px 10px; border: none; border-radius: 7px; background: none; font: inherit; text-align: left; cursor: pointer; color: var(--text); }
.bank-item:hover { background: var(--surface-2); }
.bank-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.bank-item .n { font-size: 12px; color: var(--muted); background: #eef0f5; padding: 1px 7px; border-radius: 9px; }
.bulk-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 16px; background: var(--primary-soft); border-bottom: 1px solid var(--border); }
@media (max-width: 900px) { .bank-layout { grid-template-columns: 1fr; } }
.q-pick { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.q-pick:last-child { border-bottom: none; }
.q-pick .t { flex: 1; min-width: 0; }
.q-pick .t small { display: block; color: var(--muted); }
.module-head { padding: 8px 12px; background: var(--surface-2); font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; border-bottom: 1px solid var(--border); }
.test-row { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.test-row + .test-row { margin-top: 10px; }
.test-row .test-head { display: flex; align-items: center; gap: 12px; padding: 7px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.test-row .test-cols { display: grid; grid-template-columns: 1fr 1fr; }
.test-row textarea { border: none; border-radius: 0; min-height: 90px; font-family: var(--mono); font-size: 12.5px; }
.test-row textarea + textarea { border-left: 1px solid var(--border); }
.test-row textarea:focus { outline-offset: -2px; }
.code-box { border: 1px solid var(--border-strong); border-radius: 7px; overflow: hidden; }
.code-box .CodeMirror { height: 300px; font-family: var(--mono); font-size: 13px; }
.code-box.tall .CodeMirror { height: 420px; }
.code-box.auto .CodeMirror { height: auto; max-height: 520px; }
.code-box.auto .CodeMirror-scroll { max-height: 520px; }
.timeline { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; }
.timeline li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.timeline li time { flex: none; width: 74px; color: var(--faint); font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 550; }
.split-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

@media (max-width: 900px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-side { display: none; }
  .login-main { padding: 28px 16px 16px; }
  .login-card { padding: 24px 20px 26px; }
  .ws-body { grid-template-columns: 56px 1fr; grid-template-rows: 45% 55%; }
  .ws-question { grid-column: 2; border-right: none; border-bottom: 1px solid var(--border); }
  .ws-editor { grid-column: 1 / -1; }
  .ws-rail { grid-row: 1; }
  .field.half, .field.third, .field.quarter { grid-column: span 12; }
  .split-2 { grid-template-columns: 1fr; }
}
/* The admin has six menu items; give the menu its own row before it gets squeezed. */
@media (max-width: 1180px) {
  .topbar { flex-wrap: wrap; height: auto; padding-top: 8px; gap: 6px 16px; }
  .topbar .nav { order: 3; width: 100%; overflow-x: auto; padding-bottom: 6px; }
}
@media (max-width: 640px) {
  .page { padding: 16px 16px 40px; }
  .topbar { padding: 0 16px; }
  .user-chip .who { display: none; }
  .sample-grid, .result-item .io, .test-row .test-cols { grid-template-columns: 1fr; }
  .sample-grid > div + div, .result-item .io > div + div { border-left: none; border-top: 1px solid var(--border); }
}
