:root{
  --green:#107C41; --green-dark:#0B5A2F; --green-pale:#E7F3EC;
  --ink:#1B2A22; --muted:#5E6E65; --line:#D5DED8; --paper:#FAFBF9;
  --red:#C03221; --red-pale:#FBEAE7; --amber:#B7791F; --amber-pale:#FBF3E4;
}
*{box-sizing:border-box;margin:0;padding:0}
body{
  font-family:"Segoe UI",system-ui,-apple-system,sans-serif;color:var(--ink);
  background:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px),
    var(--paper);
  background-size:48px 28px,48px 28px,auto;background-attachment:fixed;
  min-height:100vh;
}
.wrap{max-width:760px;margin:0 auto;padding:32px 20px 80px}
.wrap.wide{max-width:960px}
.cellref{display:inline-block;font-family:Consolas,Menlo,monospace;font-size:.75rem;
  background:var(--green);color:#fff;padding:2px 8px;border-radius:3px;letter-spacing:.08em}
h1{font-size:1.55rem;font-weight:700;letter-spacing:-.01em;margin:10px 0 4px}
h3{font-size:1.05rem}
.qtitle{font-size:1.35rem;margin:12px 0 18px}
.card{background:#fff;border:1px solid var(--line);border-radius:10px;padding:22px;
  margin-bottom:18px;box-shadow:0 1px 3px rgba(27,42,34,.06)}
.card.center{text-align:center}
.card.lock{background:var(--red-pale);border-color:var(--red)}
.card.lock h2{color:var(--red);margin-bottom:8px}
label{display:block;font-size:.85rem;font-weight:600;margin-bottom:6px}
input[type=text],input[type=password],input[type=email],input[type=number],select{width:100%;
  padding:9px 12px;border:1px solid var(--line);border-radius:7px;font:inherit;font-size:.92rem;
  background:#fff;margin-bottom:14px;color:var(--ink)}
input:focus,select:focus{outline:2px solid var(--green);outline-offset:1px;border-color:var(--green)}
select{cursor:pointer}
button{font:inherit;font-size:.88rem;font-weight:600;border:1px solid transparent;border-radius:7px;
  cursor:pointer;padding:8px 15px;background:var(--green);color:#fff;line-height:1.25;
  transition:background .15s ease,border-color .15s ease,box-shadow .15s ease,transform .05s ease}
button:hover{background:var(--green-dark)}
button:active{transform:translateY(1px)}
button.secondary{background:#fff;color:var(--ink);border-color:var(--line)}
button.secondary:hover{background:var(--green-pale);border-color:var(--green)}
button.danger{background:var(--red)}
button.danger:hover{background:#9E2819}
button:disabled{opacity:.5;cursor:not-allowed}
button:disabled:active{transform:none}
button:focus-visible{outline:2px solid var(--green-dark);outline-offset:2px}
.row{display:flex;gap:10px;flex-wrap:wrap;align-items:center}
.row.spread{justify-content:space-between}
.hidden{display:none!important}
.small{font-size:.8rem;color:var(--muted)}
.err{font-size:.85rem;color:var(--red);margin-top:8px}
.badge{font-size:.72rem;font-weight:700;padding:3px 10px;border-radius:999px;vertical-align:middle;background:#EAEEEB;color:var(--muted)}
.badge.locked{background:var(--red-pale);color:var(--red)}
.badge.done{background:var(--green-pale);color:var(--green-dark)}
.badge.warn{background:var(--amber-pale);color:var(--amber)}
.badge.live{background:var(--green);color:#fff}
table{width:100%;border-collapse:collapse;font-size:.9rem}
th,td{text-align:left;padding:8px 10px;border-bottom:1px solid var(--line)}
th{font-size:.72rem;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);white-space:nowrap}
/* Wide rosters scroll horizontally INSIDE the card instead of overflowing it. */
.tablewrap{overflow-x:auto;-webkit-overflow-scrolling:touch;border-radius:8px}
.tablewrap>table{min-width:640px}
.tablewrap td, .tablewrap th{white-space:nowrap}
.tablewrap tbody tr:hover, .tablewrap tr:hover{background:var(--green-pale)}
.card{overflow:hidden}
.numcell{text-align:right;font-variant-numeric:tabular-nums}
.q-option{display:flex;gap:12px;align-items:flex-start;border:1px solid var(--line);
  border-radius:8px;padding:14px;margin-bottom:10px;cursor:pointer;background:#fff}
.q-option:hover{border-color:var(--green)}
.q-option.selected{border-color:var(--green);background:var(--green-pale)}
.q-option input{margin-top:3px}
.progress{height:6px;background:var(--line);border-radius:999px;overflow:hidden;margin-bottom:20px}
.progress>div{height:100%;background:var(--green);transition:width .3s;width:0%}
.notice{border-left:4px solid var(--amber);background:var(--amber-pale);
  padding:12px 14px;border-radius:0 6px 6px 0;font-size:.9rem;margin-bottom:16px}
.qedit{border:1px solid var(--line);border-radius:8px;padding:16px;margin-bottom:14px;background:#fff}
.qedit .row input[type=text]{margin-bottom:8px}
.score-big{font-size:3rem;font-weight:800;color:var(--green-dark)}
.pulse{width:16px;height:16px;border-radius:50%;background:var(--green);margin:0 auto 14px;
  animation:pulse 1.4s ease-in-out infinite}
@keyframes pulse{0%,100%{transform:scale(1);opacity:1}50%{transform:scale(1.6);opacity:.4}}
#overlay{position:fixed;inset:0;background:rgba(27,42,34,.74);z-index:1000;
  display:flex;align-items:center;justify-content:center;padding:20px}
#overlay.hidden{display:none}
@supports ((backdrop-filter:blur(3px)) or (-webkit-backdrop-filter:blur(3px))){
  #overlay{-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px)}
}
.ovpanel{background:#fff;border-radius:20px;max-width:420px;width:100%;overflow:hidden;
  text-align:center;box-shadow:0 26px 64px rgba(0,0,0,.40)}
.ovhead{background:var(--red);padding:26px 20px 38px;
  border-bottom-left-radius:50% 24px;border-bottom-right-radius:50% 24px}
.ovhead .ic{width:72px;height:72px;margin:0 auto;display:flex;align-items:center;justify-content:center}
.ovhead .ic svg{width:72px;height:72px;stroke:#fff;fill:none;stroke-width:6;stroke-linecap:round;stroke-linejoin:round}
.ovbody{padding:18px 30px 30px}
.ovbody h2{font-size:1.35rem;font-weight:700;color:var(--ink);margin:0 0 4px}
.count{font-size:4.4rem;font-weight:800;font-variant-numeric:tabular-nums;color:var(--red);line-height:1;margin:6px 0}
.ovbody .actions{margin-top:16px}
.ovbody .actions button{min-width:160px;border-radius:999px;padding:11px 22px;background:var(--red)}
.ovbody .actions button:hover{background:#9E2819}
/* Multi-monitor variant → amber header/number instead of red. */
#overlay.mon .ovhead{background:var(--amber)}
#overlay.mon .count{color:var(--amber)}
#overlay.mon .ovbody .actions button{background:var(--amber);color:#3a2a08}
#overlay.mon .ovbody .actions button:hover{background:#9c660f}
@media (prefers-reduced-motion: reduce){*{animation:none!important;transition:none!important}}
button.tab{background:#fff;color:var(--muted);border:1px solid var(--line);border-radius:999px;padding:7px 18px}
button.tab:hover{background:var(--green-pale);color:var(--ink)}
button.tab.active{background:var(--green);color:#fff;border-color:var(--green)}
.qfigure{max-width:100%;max-height:320px;border:1px solid var(--line);border-radius:8px;margin-bottom:16px;display:block}
button.typebtn{background:#fff;color:var(--muted);border:1px solid var(--line);border-radius:6px;padding:4px 10px;font-size:.78rem}
button.typebtn.active{background:var(--green);color:#fff;border-color:var(--green)}
.textanswer{width:100%;padding:12px;border:1px solid var(--line);border-radius:8px;font:inherit}
.textanswer:focus{outline:2px solid var(--green);border-color:var(--green)}
.rvq.ok{border-left:5px solid var(--green)}
.rvq.no{border-left:5px solid var(--red)}
.timer{font-family:Consolas,Menlo,monospace;font-weight:700;font-size:.95rem;background:var(--green-pale);color:var(--green-dark);padding:4px 12px;border-radius:999px}
.timer.urgent{background:var(--red-pale);color:var(--red);animation:blink 1s step-start infinite}
.timer.hidden{display:none}
@keyframes blink{50%{opacity:.45}}
@media (prefers-reduced-motion: reduce){.timer.urgent{animation:none}}
.ovbody p{color:var(--muted);font-size:.9rem;line-height:1.5;max-width:300px;margin:0 auto}
.warncount{font-size:.92rem;font-weight:600;color:var(--muted);margin:2px 0}
.ovconseq{font-size:.85rem;margin-top:8px;color:var(--muted)}
.ovconseq.final{color:var(--red);font-weight:700}
#overlay.mon .ovconseq.final{color:var(--amber)}
.conn{font-size:.8rem;font-weight:600;white-space:nowrap}
.conn.on{color:var(--green)}
.conn.off{color:var(--amber)}
.netbanner{position:fixed;top:0;left:0;right:0;z-index:1100;background:var(--amber);color:#3d2b06;font-size:.9rem;font-weight:600;text-align:center;padding:10px 16px}
.netbanner.hidden{display:none}

/* ---- Status / warning cards (blocked, denied, submitted, gates) ----
   Modern look: a coloured header with a downward-curved edge + big white icon,
   then a white body with title, message and a pill button. currentColor sets the
   accent (red / green / amber) for both the header and the primary button. */
.statuscard{max-width:400px;margin:48px auto;background:#fff;border-radius:20px;
  box-shadow:0 18px 46px rgba(27,42,34,.14);overflow:hidden;text-align:center;color:var(--green)}
.statuscard.err{color:var(--red)}
.statuscard.ok{color:var(--green)}
.statuscard.info{color:var(--amber)}
.statuscard .shead{background:currentColor;padding:30px 20px 42px;
  border-bottom-left-radius:50% 26px;border-bottom-right-radius:50% 26px}
.statuscard .ic{width:78px;height:78px;margin:0 auto;display:flex;align-items:center;justify-content:center;
  color:#fff;font-size:46px;font-weight:700;line-height:1}
.statuscard .ic svg{width:78px;height:78px;stroke:#fff;fill:none;stroke-width:6;
  stroke-linecap:round;stroke-linejoin:round}
.statuscard .sbody{padding:22px 30px 30px}
.statuscard h2{font-size:1.4rem;font-weight:700;color:var(--ink);margin:0 0 8px}
.statuscard p{color:var(--muted);font-size:.9rem;line-height:1.55;max-width:300px;margin:0 auto}
.statuscard p + p{margin-top:8px}
.statuscard .score-big{color:currentColor;margin:4px 0}
.statuscard .actions{margin-top:20px}
.statuscard .actions button{min-width:160px;border-radius:999px;padding:11px 22px}
.statuscard.err .actions button:not(.secondary){background:var(--red)}
.statuscard.err .actions button:not(.secondary):hover{background:#9E2819}
.statuscard.info .actions button:not(.secondary){background:var(--amber);color:#3a2a08}
.statuscard.info .actions button:not(.secondary):hover{background:#9c660f}

/* ---- Markdown-rendered content (question text + answer options) ----
   Scoped to .md so it never affects the rest of the UI. Source HTML is disabled
   in the renderer (markdown-it html:false), so this only styles safe elements. */
.md p{margin:0 0 8px}
.md p:last-child{margin-bottom:0}
.md code{font-family:Consolas,Menlo,monospace;background:#fff;border:1px solid var(--line);
  color:var(--green-dark);padding:1px 6px;border-radius:5px;font-size:.9em}
.md pre{background:#1B2A22;color:#EAF3EE;padding:12px 14px;border-radius:8px;overflow-x:auto;margin:8px 0}
.md pre code{background:none;border:none;color:inherit;padding:0}
.md ul,.md ol{margin:6px 0 6px 22px}
.md li{margin:2px 0}
.md blockquote{border-left:3px solid var(--line);padding-left:12px;color:var(--muted);margin:8px 0}
.md a{color:var(--green-dark);text-decoration:underline}
.md img{max-width:100%;border-radius:6px;margin:6px 0}
.md table{border-collapse:collapse;margin:8px 0;font-size:.92em;display:block;overflow-x:auto}
.md th,.md td{border:1px solid var(--line);padding:6px 10px;text-align:left}
.md th{background:var(--green-pale)}
.md h1,.md h2,.md h3,.md h4{margin:8px 0 6px;line-height:1.3}
.md hr{border:none;border-top:1px solid var(--line);margin:10px 0}

/* Live Markdown preview inside the teacher question editor. */
.mdprev:empty{display:none}
.mdprev{margin-top:10px;padding:12px 14px;border:1px dashed var(--line);border-radius:8px;background:var(--paper)}
.mdprev-h{font-size:.7rem;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);font-weight:700;margin-bottom:6px}
.mdprev-opt{margin:3px 0}
