/* Whiteboard palette: marker-blue ink on clean paper, one highlighter accent. */
:root {
  --ink: #18324F;
  --ink-2: #2B4A70;
  --paper: #F5F7FA;
  --surface: #FFFFFF;
  --line: #D8E0EA;
  --muted: #5A6A7E;
  --mark: #FFD84D;
  --mark-deep: #F2C200;
  --ok: #1E7F52;
  --ok-bg: #E4F4EC;
  --bad: #B83A26;
  --bad-bg: #FBEAE6;
  --radius-s: 6px;
  --radius-m: 10px;
  --font: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --display: "Bricolage Grotesque", "Atkinson Hyperlegible", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
}
a { color: var(--ink-2); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--mark-deep); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0 0 .4em; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 700; }
h2 { font-size: 1.45rem; font-weight: 650; }
h3 { font-size: 1.12rem; font-weight: 650; }
p { margin: 0 0 1em; }
small, .muted { color: var(--muted); }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 620px; }

/* ---- top bar */
.topbar { background: var(--ink); color: #fff; }
.topbar .wrap { display: flex; align-items: center; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { color: #fff; text-decoration: none; font-family: var(--display); font-weight: 650; font-size: 1.1rem; }
.brand:hover { color: #fff; }
.topbar nav { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.topbar nav a, .topbar nav button {
  color: #DCE6F2; text-decoration: none; padding: 6px 12px; border-radius: var(--radius-s);
  background: none; border: 0; font: inherit; font-size: .95rem; cursor: pointer;
}
.topbar nav a:hover, .topbar nav button:hover { background: rgba(255,255,255,.1); color: #fff; }
.topbar nav .join-link { background: var(--mark); color: var(--ink); font-weight: 700; }
.topbar nav .join-link:hover { background: var(--mark-deep); color: var(--ink); }

main { padding: 32px 0 64px; }
.page-head { margin-bottom: 28px; }
.page-head p { color: var(--muted); max-width: 60ch; }
.crumb { font-size: .95rem; margin-bottom: 6px; display: inline-block; }

/* ---- flash & alerts */
.flash { padding: 12px 16px; border-radius: var(--radius-s); margin-bottom: 14px; border-left: 5px solid; }
.flash.ok { background: var(--ok-bg); border-color: var(--ok); }
.flash.error { background: var(--bad-bg); border-color: var(--bad); }
.notice { background: #FFF6CF; border-left: 5px solid var(--mark-deep); padding: 12px 16px; border-radius: var(--radius-s); margin-bottom: 18px; }

/* ---- buttons & forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; font-size: .98rem; line-height: 1;
  padding: 12px 18px; border-radius: var(--radius-s); border: 2px solid var(--ink);
  background: var(--ink); color: #fff; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--ink-2); border-color: var(--ink-2); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: #E8EEF6; color: var(--ink); }
.btn.mark { background: var(--mark); border-color: var(--mark); color: var(--ink); }
.btn.mark:hover { background: var(--mark-deep); border-color: var(--mark-deep); }
.btn.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.small { padding: 7px 11px; font-size: .88rem; border-width: 1.5px; }
.btn.big { padding: 16px 26px; font-size: 1.1rem; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--ink-2); text-decoration: underline; cursor: pointer; }

label { display: block; font-weight: 700; margin: 0 0 6px; }
.field { margin-bottom: 16px; }
.field .hint { font-weight: 400; color: var(--muted); font-size: .9rem; display: block; margin-top: 4px; }
input[type=text], input[type=password], input[type=datetime-local], input[type=number], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 2px solid var(--line); border-radius: var(--radius-s); padding: 11px 12px;
}
input:focus, select:focus, textarea:focus { border-color: var(--ink-2); outline: none; box-shadow: 0 0 0 3px rgba(255,216,77,.6); }
input[type=file] { font: inherit; max-width: 100%; }
textarea { min-height: 140px; resize: vertical; }
textarea.code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .95rem; min-height: 320px; line-height: 1.5; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > .field { flex: 1 1 200px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.check input { width: 18px; height: 18px; }

/* ---- surfaces */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 22px; margin-bottom: 22px; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
details.panel summary { cursor: pointer; font-weight: 700; font-family: var(--display); font-size: 1.1rem; }
details.panel[open] summary { margin-bottom: 14px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } }

/* ---- home: join strip (the one loud element) */
.join-strip {
  background: var(--mark); border-radius: var(--radius-m); padding: 22px 24px;
  display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; margin-bottom: 36px;
}
.join-strip h2 { margin: 0 0 4px; }
.join-strip p { margin: 0; }
.join-strip > * { min-width: 0; }
.join-strip form { display: flex; gap: 10px; min-width: 0; }
.join-strip .btn { flex: 0 0 auto; }
.join-strip input { width: 190px; font-family: var(--display); font-size: 1.5rem; letter-spacing: .12em; text-align: center; border-color: var(--ink); }
@media (max-width: 640px) { .join-strip { grid-template-columns: 1fr; } .join-strip form { width: 100%; } .join-strip input { flex: 1 1 auto; width: auto; min-width: 0; } }

/* ---- course list */
.course-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.course-row {
  display: grid; grid-template-columns: 8px 1fr auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; text-decoration: none; color: var(--ink);
}
.course-row:hover { border-color: var(--ink-2); color: var(--ink); }
.course-row .bar { background: var(--c); }
.course-row .body { padding: 18px 20px; }
.course-row .code { font-family: var(--display); font-weight: 700; color: var(--c); font-size: .95rem; }
.course-row .name { font-family: var(--display); font-size: 1.3rem; font-weight: 650; display: block; margin: 2px 0 4px; }
.course-row .meta { color: var(--muted); font-size: .93rem; }
.course-row .go { align-self: center; padding: 0 22px; font-weight: 700; color: var(--ink-2); }
.badge { display: inline-block; font-size: .8rem; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: #E8EEF6; color: var(--ink); vertical-align: middle; }
.badge.open { background: var(--ok-bg); color: var(--ok); }
.badge.closed { background: #ECEFF3; color: var(--muted); }
.badge.late { background: var(--bad-bg); color: var(--bad); }
.badge.live { background: var(--mark); color: var(--ink); }

/* ---- course page */
.course-hero { border-top: 8px solid var(--c); background: var(--surface); border-radius: 0 0 var(--radius-m) var(--radius-m); padding: 24px 24px 20px; margin-bottom: 28px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.course-hero .code { font-family: var(--display); font-weight: 700; color: var(--c); }
.section-block { margin-bottom: 26px; }
.section-block h3 { padding-bottom: 6px; border-bottom: 2px solid var(--line); }
.file-list { list-style: none; margin: 0; padding: 0; }
.file-list li { display: flex; align-items: center; gap: 14px; padding: 10px 4px; border-bottom: 1px solid #EDF1F6; }
.file-list li:last-child { border-bottom: 0; }
.ftype { flex: 0 0 auto; width: 52px; text-align: center; font-size: .72rem; font-weight: 700; padding: 5px 0; border-radius: 5px; background: #E8EEF6; color: var(--ink-2); }
.ftype.pdf { background: #FBE3DF; color: #A1321F; }
.ftype.slides { background: #FDEBD9; color: #A4520F; }
.ftype.doc { background: #E1EBFB; color: #2349A1; }
.ftype.sheet { background: #DFF3E6; color: #1E6E43; }
.ftype.zip { background: #EEE6F8; color: #5B3B97; }
.ftype.code { background: #E3F2F3; color: #13646B; }
.ftype.image { background: #FBE6F0; color: #973265; }
.file-list .fname { flex: 1; min-width: 0; }
.file-list .fname a { font-weight: 700; text-decoration: none; color: var(--ink); overflow-wrap: anywhere; }
.file-list .fname a:hover { text-decoration: underline; }
.file-list .fmeta { display: block; color: var(--muted); font-size: .86rem; }
.file-list .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.task-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.task { border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px 18px; background: var(--surface); display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.task .tbody { flex: 1 1 260px; }
.task .kind { font-size: .88rem; color: var(--muted); }
.task .ttitle { font-weight: 700; font-size: 1.08rem; display: block; }
.task.closed { opacity: .7; }
.empty { color: var(--muted); padding: 18px; border: 2px dashed var(--line); border-radius: var(--radius-m); text-align: center; }

/* ---- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid #E6EBF1; vertical-align: top; }
th { font-weight: 700; color: var(--muted); font-size: .86rem; border-bottom: 2px solid var(--line); white-space: nowrap; }
tr:hover td { background: #F9FBFD; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- receipt */
.receipt { border: 2px solid var(--ok); background: var(--ok-bg); border-radius: var(--radius-m); padding: 22px; }
.receipt dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 14px 0 0; }
.receipt dt { font-weight: 700; }
.receipt dd { margin: 0; overflow-wrap: anywhere; }

/* ---- teacher dashboard */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches label { margin: 0; }
.swatches input { position: absolute; opacity: 0; }
.swatches span { display: block; width: 30px; height: 30px; border-radius: 50%; background: var(--c); border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.swatches input:checked + span { box-shadow: 0 0 0 3px var(--ink); }
.swatches input:focus-visible + span { outline: 3px solid var(--mark-deep); outline-offset: 2px; }
.stack > * + * { margin-top: 10px; }
.inline-form { display: inline; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.copyline { display: flex; gap: 8px; }
.copyline input { font-size: .92rem; }

/* question preview */
.q-preview { list-style: none; margin: 0; padding: 0; counter-reset: q; }
.q-preview > li { counter-increment: q; border-bottom: 1px solid #E6EBF1; padding: 14px 0 14px 44px; position: relative; }
.q-preview > li::before { content: counter(q); position: absolute; left: 0; top: 14px; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: #fff; font-weight: 700; display: grid; place-items: center; font-size: .9rem; }
.q-preview .qtext { font-weight: 700; }
.q-preview .opts { list-style: none; padding: 0; margin: 6px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 4px 16px; }
.q-preview .opts li.correct { color: var(--ok); font-weight: 700; }
.q-preview .opts li.correct::after { content: " ✓"; }
.format-help { font-size: .93rem; }
.format-help pre { background: #F0F4F9; border-radius: var(--radius-s); padding: 12px 14px; overflow-x: auto; font-size: .88rem; line-height: 1.5; }

/* ================= LIVE: presenter + student play (projector-friendly ink theme) */
body.live { background: var(--ink); color: #fff; }
body.live .topbar { background: #11253C; }
body.live a { color: #CFE0F5; }
.stage { min-height: calc(100vh - 60px); display: flex; flex-direction: column; padding: 26px 0 30px; }
.stage .wrap { width: 100%; max-width: 1200px; }
.stage-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; color: #B9CBE0; }
.stage-top strong { color: #fff; }
.lobby { display: grid; grid-template-columns: 1.2fr 1fr; gap: 40px; align-items: center; }
@media (max-width: 860px) { .lobby { grid-template-columns: 1fr; } }
.lobby .how { font-size: 1.4rem; line-height: 1.4; }
.lobby .how b { color: var(--mark); }
.bigcode { font-family: var(--display); font-weight: 800; font-size: clamp(3.5rem, 11vw, 8rem); letter-spacing: .08em; line-height: 1; background: var(--mark); color: var(--ink); display: inline-block; padding: 14px 26px 18px; border-radius: 14px; margin: 10px 0 14px; }
.qr { background: #fff; padding: 16px; border-radius: 14px; width: min(320px, 100%); justify-self: center; }
.qr svg { width: 100%; height: auto; display: block; }
.names { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.names span { background: rgba(255,255,255,.12); padding: 5px 12px; border-radius: 99px; font-size: 1rem; animation: pop .35s ease-out; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .names span { animation: none; } }

.qhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 26px; }
.qhead .qtext { font-family: var(--display); font-size: clamp(1.7rem, 3.6vw, 3rem); font-weight: 700; line-height: 1.15; }
.timer { flex: 0 0 auto; width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-size: 2.4rem; font-weight: 800; background: rgba(255,255,255,.1); border: 5px solid var(--mark); }
.timer.low { border-color: #FF6B57; color: #FFB4A8; }
.answered { color: #B9CBE0; font-size: 1.15rem; }
.answered b { color: #fff; font-size: 1.5rem; }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .options { grid-template-columns: 1fr; } }
.opt { position: relative; overflow: hidden; border-radius: 12px; background: var(--oc); color: #fff; padding: 20px 22px; display: flex; gap: 16px; align-items: center; font-size: clamp(1.1rem, 2vw, 1.6rem); font-weight: 700; min-height: 84px; border: 0; font-family: var(--font); text-align: left; width: 100%; }
.opt .shape { font-size: 1.5em; line-height: 1; flex: 0 0 auto; }
.opt .otext { flex: 1; position: relative; z-index: 1; overflow-wrap: anywhere; }
.opt .count { position: relative; z-index: 1; font-family: var(--display); font-size: 1.4em; }
.opt .fill { position: absolute; inset: 0 auto 0 0; background: rgba(255,255,255,.22); width: 0; transition: width .5s ease-out; }
.opt.dim { opacity: .35; }
.opt.right { outline: 5px solid #fff; outline-offset: -5px; }
.opt.right .count::before { content: "✓ "; }

.cloud { min-height: 320px; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 22px; padding: 26px; background: rgba(255,255,255,.06); border-radius: 14px; }
.cloud span { font-family: var(--display); font-weight: 700; line-height: 1.1; }

.board { list-style: none; padding: 0; margin: 0 auto; max-width: 760px; display: grid; gap: 10px; }
.board li { display: grid; grid-template-columns: 56px 1fr auto; align-items: center; background: rgba(255,255,255,.08); border-radius: 10px; padding: 12px 18px; font-size: 1.3rem; }
.board li .rk { font-family: var(--display); font-weight: 800; font-size: 1.5rem; color: var(--mark); }
.board li .pts { font-family: var(--display); font-weight: 700; font-variant-numeric: tabular-nums; }
.board li:first-child { background: var(--mark); color: var(--ink); }
.board li:first-child .rk { color: var(--ink); }
.controls { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: auto; padding-top: 28px; }
.controls .btn { border-color: #fff; }
.controls .btn.ghost { color: #fff; }
.controls .btn.ghost:hover { background: rgba(255,255,255,.12); }
.center { text-align: center; }
.huge { font-family: var(--display); font-size: clamp(2rem, 5vw, 3.6rem); font-weight: 800; line-height: 1.1; margin: 0 0 12px; }

/* student play */
.play { max-width: 560px; margin: 0 auto; padding: 22px 16px 40px; min-height: calc(100vh - 60px); display: flex; flex-direction: column; }
.play .who { color: #B9CBE0; display: flex; justify-content: space-between; margin-bottom: 18px; }
.play .ptext { font-family: var(--display); font-size: 1.5rem; font-weight: 700; margin-bottom: 18px; line-height: 1.2; }
.play .options { grid-template-columns: 1fr; }
.play .opt { min-height: 66px; font-size: 1.12rem; cursor: pointer; }
.play .opt:active { transform: scale(.98); }
.play .opt.chosen { outline: 5px solid #fff; outline-offset: -5px; }
.verdict { border-radius: 14px; padding: 26px; text-align: center; margin: 10px 0 18px; }
.verdict.good { background: #1E7F52; }
.verdict.bad { background: #A8402F; }
.verdict.neutral { background: rgba(255,255,255,.1); }
.verdict .big { font-family: var(--display); font-size: 2rem; font-weight: 800; display: block; }
.play input[type=text] { font-size: 1.2rem; }
.wait { margin: auto 0; text-align: center; color: #DCE6F2; font-size: 1.2rem; }
.dots::after { content: ""; animation: dots 1.5s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.mywords { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.mywords span { background: rgba(255,255,255,.14); border-radius: 99px; padding: 4px 12px; }
.err { color: #FFB4A8; min-height: 1.5em; margin-top: 8px; }

footer.site { color: var(--muted); font-size: .88rem; padding: 26px 0 40px; border-top: 1px solid var(--line); }
body.live footer.site { display: none; }

@media (max-width: 560px) {
  body { font-size: 16px; }
  .panel { padding: 16px; }
  .course-row .go { display: none; }
  .course-row { grid-template-columns: 8px 1fr; }
  .file-list li { flex-wrap: wrap; }
  .file-list .actions { width: 100%; justify-content: flex-start; padding-left: 66px; }
  .topbar .wrap { min-height: 52px; padding-top: 8px; padding-bottom: 8px; }
  body.live .topbar nav { display: none; }
}
