/* Edvora Campus Exams — UI styles */
:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f9fafc;
  --ink: #161d2f;
  --ink-2: #3a4358;
  --muted: #697287;
  --line: #e2e5ee;
  --line-2: #eef0f5;
  --primary: #2f55d4;
  --primary-2: #2445b3;
  --primary-soft: #eaf0ff;
  --teal: #0e9594;
  --teal-soft: #e3f6f5;
  --success: #1c8f55;
  --success-soft: #e5f6ec;
  --warn: #b86e00;
  --warn-soft: #fff3dc;
  --danger: #c93c3c;
  --danger-soft: #fdeaea;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(22, 29, 47, .06), 0 2px 8px rgba(22, 29, 47, .05);
  --shadow-lg: 0 10px 40px rgba(22, 29, 47, .18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .8em; }
img { max-width: 100%; }
code, kbd { font-family: var(--mono); font-size: .88em; }
kbd { background: var(--surface-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 .35em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.tiny { font-size: .78rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.stack > * + * { margin-top: .75rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.grow { flex: 1 1 auto; min-width: 0; }
.mt { margin-top: 1rem; }
.mt-s { margin-top: .5rem; }
.mb { margin-bottom: 1rem; }
.mb-0 { margin-bottom: 0; }

/* --- top bar --- */
.topbar { background: #121a33; color: #fff; position: sticky; top: 0; z-index: 30; }
.topbar-inner { max-width: 1320px; margin: 0 auto; display: flex; align-items: center; gap: 1.2rem; padding: 0 1rem; height: 56px; }
.brand { display: flex; align-items: center; gap: .55rem; color: #fff; font-weight: 700; white-space: nowrap; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; background: linear-gradient(135deg, #4d7cff, #14b8a6); display: grid; place-items: center; font-size: 15px; font-weight: 800; }
.brand small { font-weight: 500; opacity: .7; }
.nav { display: flex; gap: .15rem; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: #c9d1ea; padding: .45rem .7rem; border-radius: 7px; white-space: nowrap; font-size: .93rem; display: flex; align-items: center; gap: .35rem; }
.nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); text-decoration: none; }
.nav a.active { color: #fff; background: rgba(255, 255, 255, .14); }
.nav .count { background: #f59e0b; color: #1b1400; font-size: .72rem; font-weight: 700; border-radius: 99px; padding: 0 .45rem; line-height: 1.5; }
.account { display: flex; align-items: center; gap: .5rem; }
.account a, .account button { color: #c9d1ea; font-size: .88rem; background: none; border: 0; cursor: pointer; padding: .3rem .4rem; font-family: inherit; }
.account a:hover, .account button:hover { color: #fff; }
@media (max-width: 760px) {
  .topbar-inner { flex-wrap: wrap; height: auto; padding: .5rem .75rem .35rem; gap: .35rem .8rem; }
  .brand small { display: none; }
  .nav { order: 3; flex-basis: 100%; }
  .account { margin-left: auto; }
}

/* --- page --- */
.page { max-width: 1320px; margin: 0 auto; padding: 1.4rem 1rem 3rem; }
.page.narrow { max-width: 860px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin-top: .2rem; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: .35rem; }
.crumbs a { color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.2rem; }
.card.flush { padding: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .85rem 1.2rem; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 1.1rem 1.2rem; }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.four { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid > *, .split > *, .builder > *, .seat-layout > *, .review-layout > *, .editor-grid > * { min-width: 0; }
.grid.side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); align-items: start; }
.grid.side-wide { grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr); align-items: start; }
@media (max-width: 900px) { .grid.side, .grid.side-wide { grid-template-columns: minmax(0, 1fr); } }

.stat { padding: 1rem 1.1rem; }
.stat .num { font-size: 1.8rem; font-weight: 700; letter-spacing: -.02em; }
.stat .label { color: var(--muted); font-size: .88rem; }

/* --- buttons --- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600; font-size: .92rem;
  padding: .52rem .95rem; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; line-height: 1.2;
  background: var(--primary); color: #fff; text-decoration: none; transition: background .12s, border-color .12s, box-shadow .12s; white-space: nowrap; }
.btn:hover { background: var(--primary-2); text-decoration: none; }
.btn:focus-visible { outline: 3px solid rgba(47, 85, 212, .35); outline-offset: 1px; }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { background: var(--surface-2); border-color: #cfd4e0; }
.btn.ghost { background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--line-2); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #ad2f2f; }
.btn.danger-ghost { background: transparent; color: var(--danger); }
.btn.danger-ghost:hover { background: var(--danger-soft); }
.btn.teal { background: var(--teal); }
.btn.teal:hover { background: #0b7c7b; }
.btn.sm { padding: .34rem .65rem; font-size: .84rem; }
.btn.xs { padding: .18rem .45rem; font-size: .78rem; font-weight: 600; }
.btn.lg { padding: .8rem 1.3rem; font-size: 1.02rem; }
.btn.block { width: 100%; }
.icon-btn { background: none; border: 0; cursor: pointer; color: var(--muted); padding: .25rem .35rem; border-radius: 6px; font-size: .95rem; line-height: 1; }
.icon-btn:hover { background: var(--line-2); color: var(--ink); }

/* --- forms --- */
label { font-weight: 600; font-size: .88rem; color: var(--ink-2); display: block; margin-bottom: .3rem; }
.field { margin-bottom: .9rem; }
.field .hint { font-size: .8rem; color: var(--muted); margin-top: .25rem; font-weight: 400; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date], select, textarea {
  width: 100%; font: inherit; font-size: .95rem; color: var(--ink); background: #fff; border: 1px solid #d3d8e3; border-radius: var(--radius-sm);
  padding: .52rem .7rem; transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 85, 212, .15); }
textarea { min-height: 90px; resize: vertical; }
input.inline, select.inline { width: auto; }
input.title-input { font-size: 1.45rem; font-weight: 700; background: transparent; border-color: transparent;
  padding: .15rem .35rem; margin-left: -.35rem; max-width: 720px; }
input.title-input:hover { border-color: var(--line); background: var(--surface); }
input.title-input:focus { background: var(--surface); }
input.num { width: 5.5rem; }
.check { display: flex; gap: .55rem; align-items: flex-start; font-weight: 500; cursor: pointer; }
.check input { margin-top: .22rem; width: 16px; height: 16px; accent-color: var(--primary); }
.form-row { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* --- alerts / badges --- */
.flash-wrap { max-width: 1320px; margin: 0 auto; padding: 1rem 1rem 0; }
.alert { border-radius: var(--radius-sm); padding: .7rem .9rem; border: 1px solid; font-size: .93rem; margin-bottom: .6rem; }
.alert.success { background: var(--success-soft); border-color: #bfe6cf; color: #145c38; }
.alert.error { background: var(--danger-soft); border-color: #f3c3c3; color: #8f2424; }
.alert.info { background: var(--primary-soft); border-color: #cdd9ff; color: #203b99; }
.alert.warn { background: var(--warn-soft); border-color: #f5d9a3; color: #7a4a00; }
.badge { display: inline-flex; align-items: center; gap: .25rem; font-size: .74rem; font-weight: 700; border-radius: 99px; padding: .1rem .5rem;
  background: var(--line-2); color: var(--ink-2); white-space: nowrap; letter-spacing: .01em; }
.badge.blue { background: var(--primary-soft); color: var(--primary-2); }
.badge.teal { background: var(--teal-soft); color: #0a6e6d; }
.badge.green { background: var(--success-soft); color: #146b40; }
.badge.warn { background: var(--warn-soft); color: #8a5300; }
.badge.red { background: var(--danger-soft); color: #9e2c2c; }
.badge.dark { background: #1f2740; color: #fff; }

/* --- tables --- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700;
  padding: .6rem .8rem; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
table.data td { padding: .6rem .8rem; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--surface-2); }
table.data td.actions { text-align: right; white-space: nowrap; }

.empty { text-align: center; padding: 2.2rem 1rem; color: var(--muted); }
.empty .big { font-size: 2rem; margin-bottom: .3rem; }
.empty h3 { color: var(--ink); }

/* --- tabs --- */
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; overflow-y: hidden; }
.tabs a, .tabs button { padding: .6rem .9rem; color: var(--muted); font-weight: 600; border: 0; background: none; font: inherit; font-weight: 600;
  border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; }
.tabs a:hover, .tabs button:hover { color: var(--ink); text-decoration: none; }
.tabs .active { color: var(--primary); border-bottom-color: var(--primary); }

/* --- modal --- */
dialog.modal { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); color: var(--ink); }
dialog.modal.wide { width: min(860px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(14, 20, 38, .45); }
dialog.modal[open] { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
dialog.modal[open] > form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.modal-head { padding: 1rem 1.2rem .4rem; display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; }
.modal-body { padding: .4rem 1.2rem 1rem; overflow: auto; flex: 1 1 auto; min-height: 0; }
.modal-foot { padding: .8rem 1.2rem; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; background: var(--surface-2); border-radius: 0 0 14px 14px; }

/* --- toast --- */
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .5rem; align-items: center; pointer-events: none; }
.toast { background: #1b2238; color: #fff; padding: .6rem 1rem; border-radius: 9px; box-shadow: var(--shadow-lg); font-size: .92rem; pointer-events: auto; max-width: min(520px, calc(100vw - 32px)); animation: toast-in .18s ease-out; }
.toast.error { background: #a33030; }
.toast.success { background: #177346; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* --- auth --- */
.auth-wrap { min-height: calc(100vh - 56px); display: grid; place-items: center; padding: 2rem 1rem; }
.auth-card { width: min(430px, 100%); }
.auth-card h1 { font-size: 1.45rem; }
.auth-hero { text-align: center; margin-bottom: 1.3rem; }
.auth-hero .brand-mark { width: 46px; height: 46px; border-radius: 12px; font-size: 24px; margin: 0 auto .7rem; color: #fff; }

/* --- rich text (question previews) --- */
.rt p, .rt .rt-p, .rt .rt-li { margin: 0 0 .35em; }
.rt .rt-li { position: relative; }
.rt .rt-label { position: absolute; margin-left: -1.4em; width: 1.2em; text-align: right; color: var(--ink-2); }
.rt .rt-img { max-width: 100%; height: auto; display: inline-block; vertical-align: middle; border-radius: 4px; }
.rt .rt-math { display: inline-block; }
.rt .rt-small { font-size: .82em; }
.rt .rt-large { font-size: 1.25em; }
.rt .rt-huge { font-size: 1.6em; }
.rt sub, .rt sup { font-size: .72em; }
.math-error { color: var(--danger); font-family: var(--mono); font-size: .85em; }

/* --- question cards --- */
.qlist { display: flex; flex-direction: column; gap: .6rem; }
.qcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .95rem; display: flex; gap: .75rem; }
.qcard.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(47, 85, 212, .15); }
.qcard.used { background: #fffaf0; border-color: #f1d8a8; }
.qcard .handle { cursor: grab; color: #a3aabb; padding-top: .1rem; user-select: none; font-size: 1.05rem; }
.qcard .qnum { font-weight: 800; min-width: 1.8rem; height: 1.8rem; display: grid; place-items: center; background: #1f2740; color: #fff; border-radius: 6px; font-size: .88rem; }
.qcard .qbody { flex: 1; min-width: 0; }
.qcard .qmeta { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; margin-bottom: .35rem; }
.qcard .qactions { display: flex; gap: .15rem; align-items: flex-start; flex-shrink: 0; }
.choices-preview { list-style: none; padding: 0; margin: .4rem 0 0; display: grid; gap: .15rem .9rem; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); font-size: .93rem; }
.choices-preview li { display: flex; gap: .35rem; }
.choices-preview li b { color: var(--muted); }
.choices-preview li.correct { color: var(--success); font-weight: 600; }
.choices-preview li.correct b { color: var(--success); }
.key-preview { font-size: .88rem; color: var(--success); margin-top: .35rem; }
.sortable-ghost { opacity: .4; }
.sortable-chosen { box-shadow: var(--shadow-lg); }

/* --- bank layout --- */
.split { display: grid; grid-template-columns: 300px 1fr; gap: 1rem; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.tree { font-size: .92rem; }
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree .t-course > .t-row { font-weight: 700; }
.tree .t-unit { padding-left: .9rem; }
.tree .t-lesson { padding-left: 1.8rem; }
.tree .t-row { display: flex; align-items: center; gap: .3rem; padding: .32rem .45rem; border-radius: 6px; cursor: pointer; }
.tree .t-row:hover { background: var(--line-2); }
.tree .t-row.active { background: var(--primary-soft); color: var(--primary-2); }
.tree .t-row .t-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree .t-row .t-count { font-size: .75rem; color: var(--muted); }
.tree .t-row .t-tools { display: none; gap: .05rem; }
.tree .t-row:hover .t-tools, .tree .t-row.active .t-tools { display: flex; }
.tree .t-add { color: var(--primary); font-size: .85rem; padding: .25rem .45rem .25rem 1.8rem; cursor: pointer; display: block; }
.tree .t-add.unit { padding-left: .9rem; }
.tree .t-caret { width: 1rem; color: var(--muted); font-size: .7rem; transition: transform .12s; display: inline-block; }
.tree .collapsed .t-caret { transform: rotate(-90deg); }
.tree .collapsed > ul { display: none; }
.sticky { position: sticky; top: 72px; }
@media (max-width: 900px) { .sticky { position: static; } }

/* --- editor --- */
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1rem; align-items: start; }
@media (max-width: 980px) { .editor-grid { grid-template-columns: 1fr; } }
.type-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
@media (max-width: 600px) { .type-picker { grid-template-columns: repeat(2, 1fr); } }
.type-picker label { margin: 0; border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: .6rem .7rem; cursor: pointer; font-weight: 600; background: #fff; display: flex; gap: .45rem; align-items: center; }
.type-picker label:hover { border-color: #c5cbd9; }
.type-picker input { position: absolute; opacity: 0; pointer-events: none; }
.type-picker label:focus-within { outline: 3px solid rgba(47, 85, 212, .3); }
.type-picker label.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-2); }
.type-picker .ti { font-size: 1.1rem; }
.rich { background: #fff; border-radius: var(--radius-sm); }
.rich .ql-toolbar.ql-snow { border: 1px solid #d3d8e3; border-radius: var(--radius-sm) var(--radius-sm) 0 0; padding: 5px 6px; background: var(--surface-2); font-family: var(--font); }
.rich .ql-container.ql-snow { border: 1px solid #d3d8e3; border-top: 0; border-radius: 0 0 var(--radius-sm) var(--radius-sm); font-family: var(--font); font-size: 15px; }
.rich .ql-editor { min-height: 110px; line-height: 1.55; }
.rich.compact .ql-editor { min-height: 38px; padding: 8px 10px; }
.rich .ql-editor img { max-width: 100%; cursor: pointer; }
.rich .ql-editor img.ql-math-img { cursor: pointer; vertical-align: middle; }
.rich .ql-editor .ql-eq { cursor: pointer; }
.rich .ql-editor .ql-eq.bad { color: var(--danger); font-family: var(--mono); font-size: .85em; }
.ql-snow .ql-toolbar button.ql-math-btn, .ql-snow .ql-toolbar button.ql-math-btn { width: auto; padding: 0 6px; font-weight: 700; font-family: Georgia, serif; font-style: italic; color: #444; }
.ql-snow .ql-toolbar button.ql-math-btn:hover { color: var(--primary); }
.rich:focus-within .ql-toolbar.ql-snow, .rich:focus-within .ql-container.ql-snow { border-color: var(--primary); }
.choice-row { display: flex; gap: .6rem; align-items: flex-start; margin-bottom: .55rem; }
.choice-row .correct-pick { display: flex; flex-direction: column; align-items: center; gap: .1rem; padding-top: .45rem; min-width: 2.4rem; }
.choice-row .correct-pick input { width: 18px; height: 18px; accent-color: var(--success); margin: 0; cursor: pointer; }
.choice-row .letter { font-weight: 800; color: var(--muted); font-size: .8rem; }
.choice-row.is-correct .rich .ql-container.ql-snow, .choice-row.is-correct .rich .ql-toolbar.ql-snow { border-color: #9fd8b8; }
.choice-row.is-correct .letter { color: var(--success); }
.choice-row .rich { flex: 1; min-width: 0; }
.tf-pick { display: flex; gap: .6rem; }
.tf-pick label { flex: 1; border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: .8rem; cursor: pointer; text-align: center; font-size: 1rem; background: #fff; }
.tf-pick label.on { border-color: var(--success); background: var(--success-soft); color: #146b40; }
.tf-pick input { display: none; }
.height-preview { border: 1.5px solid #9aa3b5; border-radius: 3px; background: repeating-linear-gradient(#fff, #fff 17px, #eef0f5 17px, #eef0f5 18px); margin-top: .4rem; max-height: 260px; }
.scrap-preview { border: 1.5px dashed #b7bdcb; border-radius: 6px; margin-top: .4rem; max-height: 260px; display: flex; align-items: flex-start; padding: 3px 6px; font-size: .7rem; color: var(--muted); }
.math-dialog .palette { display: flex; flex-wrap: wrap; gap: .3rem; margin: .5rem 0 .8rem; }
.math-dialog .palette button { font: inherit; font-size: .88rem; border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: .25rem .5rem; cursor: pointer; min-width: 2.2rem; }
.math-dialog .palette button:hover { border-color: var(--primary); color: var(--primary); }
.math-preview { min-height: 72px; border: 1px solid var(--line); border-radius: var(--radius-sm); display: grid; place-items: center; padding: .8rem; background: var(--surface-2); font-size: 30px; }
.math-preview img { max-width: 100%; }
.img-tools { position: absolute; z-index: 20; background: #1b2238; border-radius: 8px; padding: .25rem; display: flex; gap: .2rem; box-shadow: var(--shadow-lg); }
.img-tools button { background: none; border: 0; color: #fff; font: inherit; font-size: .8rem; padding: .25rem .5rem; border-radius: 5px; cursor: pointer; }
.img-tools button:hover { background: rgba(255, 255, 255, .15); }

/* --- builder --- */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 1rem; align-items: start; }
@media (max-width: 1080px) { .builder { grid-template-columns: 1fr; } }
.builder .panel { max-height: calc(100vh - 150px); overflow: auto; }
@media (max-width: 1080px) { .builder .panel { max-height: none; } }
.selectors { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; }
@media (max-width: 900px) { .selectors { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.selectors label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.used-flag { font-size: .8rem; color: #8a5300; margin-top: .35rem; }
.lock-banner { display: flex; gap: .8rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.total-bar { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: .7rem 1rem; display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; border-radius: 0 0 var(--radius) var(--radius); }
.pts-input { width: 4.2rem; padding: .2rem .4rem; font-size: .88rem; text-align: right; }

/* --- seating --- */
.seat-layout { display: grid; grid-template-columns: 240px 1fr; gap: 1rem; align-items: start; }
@media (max-width: 820px) { .seat-layout { grid-template-columns: 1fr; } }
.seat-pool { min-height: 120px; max-height: 60vh; overflow: auto; display: flex; flex-direction: column; gap: .3rem; padding: .5rem; background: var(--surface-2); border: 1px dashed var(--line); border-radius: var(--radius-sm); }
.front { text-align: center; font-size: .75rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); border: 1px solid var(--line); background: var(--surface-2); border-radius: 6px; padding: .3rem; margin-bottom: .7rem; }
.seat-grid-wrap { overflow-x: auto; padding-bottom: .5rem; }
.seat-grid { display: grid; gap: .45rem; min-width: max-content; }
.seat { width: 112px; height: 62px; border: 1.5px dashed #cdd2de; border-radius: 9px; background: #fff; display: flex; align-items: stretch; justify-content: stretch; position: relative; }
.seat .seat-label { position: absolute; top: 2px; right: 6px; font-size: .64rem; color: #a0a7b8; pointer-events: none; }
.seat.drop-hover { border-color: var(--primary); background: var(--primary-soft); }
.seat .vtag { position: absolute; bottom: 2px; right: 5px; font-size: .64rem; font-weight: 800; color: #fff; border-radius: 4px; padding: 0 .3rem; pointer-events: none; }
.chip { background: #fff; border: 1px solid var(--line); border-radius: 7px; padding: .35rem .55rem; font-size: .84rem; cursor: grab; user-select: none; box-shadow: 0 1px 1px rgba(0, 0, 0, .04); line-height: 1.25; }
.seat .chip { flex: 1; margin: 3px; display: flex; align-items: center; justify-content: center; text-align: center; border-color: #cfd8f6; background: #f4f7ff; font-weight: 600; overflow: hidden; word-break: break-word; }
.v0 { background: #2f55d4; } .v1 { background: #0e9594; } .v2 { background: #b86e00; } .v3 { background: #9b3fc8; }
.v4 { background: #c93c3c; } .v5 { background: #3f7d20; } .v6 { background: #6b6f80; } .v7 { background: #1f2740; }

/* --- scan --- */
.dropzone { border: 2px dashed #c3c9d8; border-radius: 12px; padding: 2.2rem 1rem; text-align: center; background: var(--surface-2); cursor: pointer; transition: border-color .12s, background .12s; }
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone .big { font-size: 2.2rem; }
.progress { height: 8px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--primary), var(--teal)); width: 0; transition: width .3s; }
.page-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .8rem; }
.page-thumb { border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; overflow: hidden; display: flex; flex-direction: column; }
.page-thumb img { width: 100%; aspect-ratio: 8.5 / 11; object-fit: cover; object-position: top; background: var(--line-2); cursor: zoom-in; display: block; }
.page-thumb .meta { padding: .5rem .6rem; font-size: .84rem; }
.phone-qr { width: 132px; height: 132px; background: #fff; padding: 6px; border: 1px solid var(--line); border-radius: 8px; }
.phone-qr svg { width: 100%; height: 100%; }

/* camera page */
.camera-page { max-width: 560px; margin: 0 auto; padding: 1rem .9rem 6rem; }
.snap-btn { width: 100%; padding: 1.1rem; font-size: 1.15rem; border-radius: 14px; }
.snap-list { display: flex; flex-direction: column; gap: .55rem; margin-top: 1rem; }
.snap-item { display: flex; gap: .7rem; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: .55rem; }
.snap-item img { width: 54px; height: 70px; object-fit: cover; border-radius: 5px; background: var(--line-2); flex-shrink: 0; }
.snap-item .who { font-weight: 700; }
.snap-item.ok { border-color: #bfe6cf; }
.snap-item.bad { border-color: #f3c3c3; background: #fffafa; }
.snap-item .state { margin-left: auto; font-size: 1.3rem; }
.spinner { width: 20px; height: 20px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.tips { font-size: .88rem; color: var(--ink-2); padding-left: 1.1rem; margin: .5rem 0 0; }
.tips li { margin-bottom: .2rem; }

/* --- review --- */
.review-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 900px) { .review-layout { grid-template-columns: 1fr; } }
.review-card .crop { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; display: block; image-rendering: auto; }
.review-card .crop-wrap { background: var(--surface-2); border-radius: 10px; padding: .6rem; }
.score-buttons { display: flex; flex-wrap: wrap; gap: .35rem; }
.score-buttons .btn { min-width: 3rem; }
.score-buttons .btn.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.qfilter { display: flex; flex-direction: column; gap: .15rem; }
.qfilter button { text-align: left; font: inherit; background: none; border: 0; padding: .45rem .6rem; border-radius: 7px; cursor: pointer; display: flex; justify-content: space-between; gap: .5rem; color: var(--ink-2); font-size: .9rem; }
.qfilter button:hover { background: var(--line-2); }
.qfilter button.active { background: var(--primary-soft); color: var(--primary-2); font-weight: 700; }
.key-box { background: var(--success-soft); border: 1px solid #bfe6cf; border-radius: 8px; padding: .6rem .8rem; font-size: .92rem; white-space: pre-wrap; }
.option-picks { display: flex; flex-direction: column; gap: .35rem; }
.option-picks label { font-weight: 500; border: 1.5px solid var(--line); border-radius: 8px; padding: .45rem .6rem; cursor: pointer; display: flex; gap: .5rem; align-items: center; margin: 0; }
.option-picks label.on { border-color: var(--primary); background: var(--primary-soft); }
.option-picks .pl { font-size: .72rem; font-weight: 800; color: #fff; background: #6b6f80; border-radius: 4px; padding: .05rem .35rem; }

/* --- results --- */
.gradebook { font-size: .86rem; }
.gradebook th.q { text-align: center; min-width: 2.6rem; }
.gradebook td.cell { text-align: center; padding: .4rem .3rem; }
.cell-ok { color: var(--success); font-weight: 700; }
.cell-no { color: var(--danger); font-weight: 700; }
.cell-part { color: var(--warn); font-weight: 700; }
.cell-review { background: var(--warn-soft); color: #8a5300; font-weight: 700; border-radius: 5px; padding: .05rem .3rem; font-size: .75rem; }
.cell-none { color: #b4bac7; }
.bar { height: 6px; background: var(--line-2); border-radius: 99px; overflow: hidden; min-width: 60px; }
.bar > div { height: 100%; background: var(--teal); }
.dist { display: flex; gap: .25rem; flex-wrap: wrap; }
.dist span { font-size: .74rem; background: var(--line-2); border-radius: 4px; padding: 0 .35rem; }
.dist span.key { background: var(--success-soft); color: #146b40; font-weight: 700; }
.scan-page-img { width: 100%; border: 1px solid var(--line); border-radius: 8px; }
.response-crop { max-width: 100%; max-height: 180px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }

/* --- dashboard --- */
.steps { list-style: none; padding: 0; margin: 0; }
.steps li { display: flex; gap: .7rem; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--line-2); }
.steps li:last-child { border-bottom: 0; }
.steps .dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #cfd4e0; display: grid; place-items: center; font-size: .75rem; font-weight: 800; color: var(--muted); flex-shrink: 0; }
.steps li.done .dot { background: var(--success); border-color: var(--success); color: #fff; }
.steps li.done a { color: var(--muted); text-decoration: line-through; }
.steps li.next { background: var(--primary-soft); margin: 0 -.6rem; padding-left: .6rem; padding-right: .6rem; border-radius: 8px; border-bottom-color: transparent; }
.steps li.next .dot { border-color: var(--primary); color: var(--primary); }
.setup .steps a { font-weight: 600; }

.lightbox { position: fixed; inset: 0; background: rgba(10, 14, 26, .82); z-index: 90; display: grid; place-items: center; padding: 1rem; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; background: #fff; }

@media print { .topbar, .no-print { display: none !important; } body { background: #fff; } }

/* --- fill in the blank --- */
.rt-blank { display: inline-block; min-width: 3.4em; padding: 0 .4em; border-bottom: 1.5px solid var(--ink-2); text-align: center;
  font-size: .75em; font-weight: 700; color: var(--muted); line-height: 1.5; vertical-align: baseline; }
.rich .ql-editor .ql-blank { display: inline-block; min-width: 3.4em; border-bottom: 2px solid var(--primary); background: var(--primary-soft);
  border-radius: 4px 4px 0 0; text-align: center; font-size: .8em; font-weight: 800; color: var(--primary-2); margin: 0 .1em; cursor: default; }
.rich.no-blanks .ql-toolbar button.ql-blank { display: none; }
.ql-snow .ql-toolbar button.ql-blank { width: auto; padding: 0 6px; color: var(--primary-2); }

/* --- code blocks --- */
.rt-code { background: #f6f7f9; border: 1px solid var(--line); border-radius: 7px; padding: .6rem .8rem; margin: .35rem 0 .5rem;
  font-family: var(--mono); font-size: .84rem; line-height: 1.45; overflow-x: auto; white-space: pre; }
.rt-code code { font-family: inherit; }
/* Beat Quill's dark code theme (same specificity, loaded later) */
.rich.ql-snow .ql-editor .ql-code-block-container, .rich .ql-snow .ql-editor .ql-code-block-container {
  background: #f6f7f9; color: var(--ink); border: 1px solid var(--line); border-radius: 7px; padding: 1.9rem .7rem .5rem;
  font-family: var(--mono); font-size: .85rem; position: relative; margin: .3rem 0; }
.rich .ql-code-block-container select.ql-ui { position: absolute; top: 5px; right: 5px; left: auto; width: auto; font-size: .75rem;
  padding: .1rem 1.4rem .1rem .4rem; border: 1px solid var(--line); border-radius: 5px; background-color: #fff; color: var(--ink); height: auto; }

/* --- choice feedback --- */
.choice-feedback { margin-top: .3rem; font-size: .85rem !important; padding: .35rem .55rem !important; background: #fffdf6 !important; }
.fb-note { background: #fff5f5; border-left: 3px solid var(--danger); padding: .4rem .6rem; border-radius: 0 6px 6px 0; font-size: .9rem; color: #7c2020; margin-top: .4rem; }
.fb-note.teacher { background: var(--primary-soft); border-left-color: var(--primary); color: #1f3a8f; }

/* --- stats badge --- */
.badge.stat-good { background: var(--success-soft); color: #146b40; }
.badge.stat-mid { background: var(--warn-soft); color: #8a5300; }
.badge.stat-low { background: var(--danger-soft); color: #9e2c2c; }

/* --- switches --- */
.switch { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; font-weight: 600; font-size: .9rem; margin: 0; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 99px; background: #cfd4e0; position: relative; cursor: pointer; transition: background .15s; margin: 0; flex-shrink: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--success); }
.switch input:checked::after { left: 19px; }

/* --- student area --- */
.exam-q { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: .9rem 1rem; }
.exam-q + .exam-q { margin-top: .7rem; }
.exam-q .head { display: flex; justify-content: space-between; gap: .6rem; align-items: flex-start; margin-bottom: .4rem; }
.exam-q .result { font-weight: 800; white-space: nowrap; }
.exam-q.is-right { border-left: 4px solid var(--success); }
.exam-q.is-wrong { border-left: 4px solid var(--danger); }
.exam-q.is-partial { border-left: 4px solid var(--warn); }
.exam-q.is-pending, .exam-q.is-missing { border-left: 4px solid #b4bac7; }
.opt-list { list-style: none; padding: 0; margin: .4rem 0 0; display: flex; flex-direction: column; gap: .2rem; }
.opt-list li { display: flex; gap: .45rem; align-items: baseline; padding: .2rem .45rem; border-radius: 6px; }
.opt-list li b { color: var(--muted); min-width: 1.2em; }
.opt-list li.picked { background: var(--danger-soft); }
.opt-list li.key { background: var(--success-soft); }
.opt-list li.picked.key { background: var(--success-soft); outline: 2px solid #9fd8b8; }
.opt-list li .tag { margin-left: auto; font-size: .72rem; font-weight: 800; color: var(--muted); white-space: nowrap; }
.regrade-box { background: var(--surface-2); border: 1px dashed var(--line); border-radius: 8px; padding: .6rem .7rem; margin-top: .6rem; font-size: .9rem; }
.code-input { font-family: var(--mono); letter-spacing: .12em; text-transform: uppercase; font-size: 1.2rem !important; text-align: center; }

/* --- scan progress (phone) --- */
.progress-groups { display: flex; flex-direction: column; gap: .7rem; margin-top: .6rem; }
.progress-groups h3 { font-size: .88rem; margin: 0 0 .3rem; display: flex; justify-content: space-between; }
.stu-chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.stu-chip { font-size: .82rem; border-radius: 99px; padding: .2rem .6rem; border: 1px solid var(--line); background: #fff; }
.stu-chip.done { background: var(--success-soft); border-color: #bfe6cf; color: #146b40; }
.stu-chip.partial { background: var(--warn-soft); border-color: #f5d9a3; color: #7a4a00; }
.stu-chip.todo { color: var(--ink-2); }
