/* CPA Proctor: Choice Plus Academy black and gold. Dark only, by design. */
:root {
  --bg: #0a0907;          /* near-black, warm */
  --bg2: #14110c;
  --bg3: #1f1a12;
  --line: #3a3022;
  --fg: #f4ecdc;          /* warm off-white */
  --muted: #b5a68b;
  --gold: #e2bd78;        /* logo gold */
  --gold-deep: #a57c3c;   /* bronze, from the lion mark */
  --accent: var(--gold);
  --accent-fg: #17110a;
  --ok: #5fd08e;
  --bad: #ff6159;
  --warn: #ff9a3d;        /* orange, kept distinct from gold */
  --ug: #b9a0ff;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
#app { min-height: 100%; }
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 .5rem; line-height: 1.2; }
h2 { font-size: 1.3rem; margin: 0 0 .5rem; }
h3 { font-size: 1.05rem; margin: 0 0 .5rem; }
h4 { margin: 0 0 .4rem; }
p { margin: .4rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.err { color: var(--bad); min-height: 0; margin: .4rem 0; }
.err:empty, .ok-text:empty { display: none; }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }
.bad { color: var(--bad); font-weight: 600; }
.note { background: var(--bg3); border-left: 3px solid var(--accent); padding: .5rem .75rem; border-radius: 6px; }
.mt { margin-top: 2rem; }
.grow { flex: 1; }
.row { display: flex; gap: .6rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.head-row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.head-row h1 { margin: 0; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; }
.foot { margin-top: 1.25rem; text-align: center; }

label { display: block; font-weight: 600; font-size: .9rem; margin: .8rem 0 .3rem; }
label.check, label.inline { display: inline-flex; gap: .4rem; align-items: center; font-weight: 500; margin: .4rem 1rem .4rem 0; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: .55rem .7rem;
}
input[type=checkbox] { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
textarea { resize: vertical; }
.w-sm { width: 5.5rem; }
.w-md { width: 12rem; }
.code-input { font-family: var(--mono); font-size: 1.6rem; letter-spacing: .25em; text-transform: uppercase; text-align: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600;
  padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--line); background: var(--bg3); color: var(--fg);
  cursor: pointer; text-decoration: none; white-space: nowrap; min-height: 2.5rem;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.primary.danger, .btn.danger:not(.ghost) { background: transparent; border-color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.sm { padding: .25rem .6rem; min-height: 2rem; font-size: .85rem; }
.btn.block { width: 100%; margin-top: 1rem; }
.btn.big { font-size: 1.15rem; padding: .85rem 1.5rem; }

.center { min-height: 100%; display: grid; place-items: center; padding: 1.5rem; }
.panel { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.5rem; }
.panel.narrow { width: 100%; max-width: 30rem; }
.center > .panel { width: 100%; max-width: 40rem; }
.center > .panel.narrow { max-width: 30rem; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--bg3); border: 1px solid var(--line); white-space: nowrap; }
.s-running, .st-ACTIVE { color: var(--ok); border-color: var(--ok); }
.s-lobby, .st-LOBBY, .st-PRECHECK { color: var(--warn); border-color: var(--warn); }
.s-ended, .st-SUBMITTED { color: var(--muted); }
.badge.st-SUSPENDED { background: var(--bad); color: #fff; border-color: var(--bad); }

.tbl { width: 100%; border-collapse: collapse; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tbl th, .tbl td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--bg3); }
.tbl td.actions { display: flex; gap: .4rem; justify-content: flex-end; flex-wrap: wrap; }
.tbl tr.detail td { background: var(--bg); }
.ans { padding-left: 1.4rem; margin: 0; }
.ans li { margin-bottom: .6rem; padding-left: .3rem; border-left: 3px solid var(--line); }
.ans li.ok { border-color: var(--ok); }
.ans li.no { border-color: var(--bad); }
.ans li.ug { border-color: var(--ug); }
.viol { padding-left: 1.2rem; margin: 0; }
.al-hard { color: var(--bad); }
.al-soft { color: var(--warn); }
.al-disconnect { color: var(--muted); }

dialog.dlg { background: var(--bg2); color: var(--fg); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; width: min(32rem, 92vw); }
dialog.dlg::backdrop { background: rgba(0, 0, 0, .6); }
dialog .row { justify-content: flex-end; margin-top: 1rem; }

/* ---------- brand ---------- */
.logo { flex: none; display: inline-block; }
img.logo { object-fit: contain; border-radius: 6px; }
.logo.sm { width: 2rem; height: 2rem; }
.logo.lg { width: 7.5rem; height: 7.5rem; border-radius: 14px; }
.mono-mark {
  display: inline-grid; place-items: center; font-weight: 900; letter-spacing: .04em; color: var(--accent-fg);
  background: linear-gradient(145deg, var(--gold), var(--gold-deep)); border-radius: 50%;
}
.mono-mark.sm { font-size: .62rem; }
.mono-mark.lg { font-size: 2rem; border-radius: 50%; box-shadow: 0 0 0 4px var(--bg2), 0 0 0 6px var(--gold-deep); }
.brandmark { display: inline-flex; align-items: center; gap: .55rem; }
.brand-name { font-weight: 800; color: var(--gold); letter-spacing: .02em; }
.hero { text-align: center; margin-bottom: 1rem; }
.hero .logo { margin: 0 auto .75rem; display: block; }
.hero .mono-mark { display: grid; }
.hero h1 { color: var(--gold); margin-bottom: .1rem; letter-spacing: .02em; }
.school { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .18em; }
.panel { border-top: 3px solid var(--gold-deep); }
.btn.primary:hover:not(:disabled) { background: #edcd8e; border-color: #edcd8e; }
::selection { background: var(--gold-deep); color: #fff; }

/* ---------- teacher ---------- */
.t-nav { display: flex; gap: 1rem; align-items: center; padding: .6rem 1.25rem; border-bottom: 2px solid var(--gold-deep); background: #000; position: sticky; top: 0; z-index: 5; }
.t-nav a { text-decoration: none; color: var(--fg); }
.t-nav .brand { font-weight: 800; }
.t-main { max-width: 72rem; margin: 0 auto; padding: 1.5rem; }
.t-main.wide { max-width: none; }
.qlist { display: grid; gap: 1rem; margin: 1rem 0; }
.qcard .head-row { margin-bottom: .5rem; }
.qcard select { width: auto; }

.live-head { display: grid; grid-template-columns: 1fr auto auto; gap: 1.5rem; align-items: center; margin-bottom: 1rem; }
.code-box { text-align: center; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem 1.25rem; }
.join-code { font-size: 2.6rem; font-weight: 800; letter-spacing: .15em; line-height: 1.1; }
.big-timer { font-size: 2.2rem; font-weight: 700; min-width: 8rem; text-align: right; }
.big-timer.warn, .x-timer.warn { color: var(--bad); }
.counts { color: var(--muted); font-size: .9rem; }
.conn.bad { color: var(--bad); font-weight: 600; }
.toolbar { margin-bottom: 1rem; }
.live-body { display: grid; grid-template-columns: 1fr 20rem; gap: 1rem; align-items: start; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr)); gap: .6rem; }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .75rem; display: flex; flex-direction: column; gap: .35rem; }
.card.st-SUSPENDED { border: 2px solid var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--bg2)); }
.card.st-SUBMITTED { opacity: .65; }
.card.offline { border-style: dashed; }
.card.flash { animation: flash 1s ease-in-out 3; }
@keyframes flash { 50% { box-shadow: 0 0 0 4px var(--bad); } }
.c-top { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.c-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-mid { display: flex; gap: .75rem; font-size: .9rem; }
.c-score { margin-left: auto; font-weight: 700; }
.c-info { color: var(--muted); min-height: 1.1em; }
.st-SUSPENDED .c-info { color: var(--bad); font-weight: 600; }
.c-btns { display: flex; gap: .3rem; flex-wrap: wrap; }
.dots { display: flex; flex-wrap: wrap; gap: 2px; }
.dots i { width: 9px; height: 9px; border-radius: 2px; background: var(--bg3); border: 1px solid var(--line); }
.dots i.d1 { background: var(--ok); border-color: var(--ok); }
.dots i.d2 { background: var(--bad); border-color: var(--bad); }
.dots i.d3 { background: var(--ug); border-color: var(--ug); }
.dots i.cur { outline: 2px solid var(--fg); outline-offset: 1px; }
.alerts-panel { position: sticky; top: 4rem; max-height: calc(100vh - 6rem); overflow: auto; padding: 1rem; }
.alerts { list-style: none; margin: 0; padding: 0; font-size: .88rem; }
.alerts li { padding: .3rem 0; border-bottom: 1px solid var(--line); }
@media (max-width: 900px) {
  .live-body, .live-head { grid-template-columns: 1fr; }
  .big-timer { text-align: left; }
}

/* ---------- student exam ---------- */
body.student { overflow: hidden; }
.exam { height: 100vh; display: flex; flex-direction: column; }
.x-bar { display: flex; gap: 1rem; align-items: center; padding: .6rem 1.25rem; background: #000; border-bottom: 2px solid var(--gold-deep); min-height: 3.5rem; }
.x-title { font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.x-progress { font-family: var(--mono); color: var(--muted); }
.x-saved { color: var(--ok); font-size: .85rem; }
.x-saved.busy { color: var(--warn); }
.x-timer { font-family: var(--mono); font-size: 1.4rem; font-weight: 700; min-width: 5rem; text-align: right; }
.x-stage { flex: 1; overflow: auto; position: relative; user-select: none; -webkit-user-select: none; }
.x-stage textarea { user-select: text; -webkit-user-select: text; }
.overlay { position: fixed; inset: 3.5rem 0 0 0; background: var(--bg); display: grid; place-items: center; z-index: 50; padding: 1.5rem; }
.overlay-card { max-width: 34rem; text-align: center; }
.overlay-card .reason { font-size: 1.25rem; font-weight: 700; color: var(--bad); }
.overlay-card .btn { margin-top: 1rem; }
.big-icon { font-size: 3rem; line-height: 1; margin-bottom: .5rem; }
.big-icon.ok { color: var(--ok); }
.score { font-size: 1.4rem; font-weight: 700; }
.spinner { width: 2.2rem; height: 2.2rem; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 1rem; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner, .card.flash { animation: none; } }
.checks { list-style: none; padding: 0; margin: 1rem 0; }
.checks li { display: flex; gap: .75rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.checks .mark { font-weight: 800; width: 1.2rem; }
.checks li.ok .mark { color: var(--ok); }
.checks li.bad .mark { color: var(--bad); }
.recheck { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin: -.25rem 0 1rem; }
.rules { font-size: .92rem; color: var(--muted); }
.q-wrap { max-width: 50rem; margin: 0 auto; padding: 2rem 1.5rem 3rem; }
.q-num { color: var(--muted); font-weight: 600; margin-bottom: .5rem; }
.q-prompt { font-size: 1.3rem; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: 1.5rem; }
.opts { display: grid; gap: .6rem; }
.opts.tf { grid-template-columns: 1fr 1fr; }
.opt {
  display: flex; gap: .9rem; align-items: center; text-align: left; font: inherit; font-size: 1.05rem; color: var(--fg);
  background: var(--bg2); border: 2px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; cursor: pointer; width: 100%;
}
.opt:hover { border-color: var(--accent); }
.opt.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--bg2)); }
.opt-key { flex: none; width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--bg3); }
.opt.sel .opt-key { background: var(--accent); color: var(--accent-fg); }
.opt-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.short { font-size: 1.1rem; }
.q-nav { display: flex; justify-content: space-between; margin-top: 2rem; }
.strip { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: 1.5rem; }
.pip { width: 2.2rem; height: 2.2rem; border-radius: 6px; border: 1px solid var(--line); background: var(--bg2); color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer; }
.pip.done { background: var(--bg3); color: var(--fg); border-color: var(--ok); }
.pip.cur { outline: 2px solid var(--accent); color: var(--fg); }
.modal { position: absolute; inset: 0; background: rgba(0, 0, 0, .7); display: grid; place-items: center; padding: 1rem; z-index: 10; }
.modal .row { justify-content: flex-end; margin-top: 1rem; }

/* harness */
.hlog { list-style: none; padding: 0; max-height: 60vh; overflow: auto; }
.hlog .bad { color: var(--bad); }
.hlog .warn { color: var(--warn); }
.hlog .ok { color: var(--ok); }
td.bad { color: var(--bad); }
td.warn { color: var(--warn); }

/* playground (dev only) */
.card.you { box-shadow: 0 0 0 2px var(--accent); }
.pg-setup { max-width: 38rem; }
.pg-setup input[type=range] { padding: 0; accent-color: var(--accent); }
.pg-two { display: grid; grid-template-columns: 1fr auto; gap: 1rem; }
.pg-notes { padding-left: 1.1rem; margin: 1.25rem 0 0; }
.pg-notes li { margin-bottom: .35rem; }
body.pg { overflow: hidden; }
.pg-app { height: 100vh; display: flex; flex-direction: column; }
.pg-bar { background: #000; border-bottom: 2px solid var(--gold-deep); padding: .5rem 1rem; display: grid; gap: .4rem; }
.pg-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.pg-row label.check { margin: 0 .5rem 0 0; font-size: .85rem; }
.pg-brand { font-size: 1.05rem; }
.pg-sep { width: 1px; height: 1.4rem; background: var(--line); margin: 0 .25rem; }
.pg-trig { width: auto; padding: .25rem .5rem; font-size: .85rem; }
.seg { display: inline-flex; }
.seg .btn { border-radius: 0; margin-left: -1px; }
.seg .btn:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.seg .btn:last-child { border-radius: 0 8px 8px 0; }
.seg .btn[aria-pressed=true] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.pg-toast { opacity: 0; transition: opacity .2s; color: var(--ok); font-weight: 600; }
.pg-toast.on { opacity: 1; }
.pg-toast.bad { color: var(--bad); }
.pg-guide summary { cursor: pointer; font-size: .85rem; color: var(--muted); width: fit-content; }
.pg-guide ol { margin: .4rem 0 .2rem; padding-left: 1.3rem; font-size: .88rem; display: grid; gap: .15rem; }
.pg-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .75rem; padding: .75rem; }
body[data-view=student] .pg-teacher, body[data-view=teacher] .pg-student { display: none; }
body[data-view=student] .pg-main, body[data-view=teacher] .pg-main { grid-template-columns: minmax(0, 1fr); }
.pg-pane { display: flex; flex-direction: column; min-height: 0; gap: .4rem; }
.pg-label { display: flex; gap: .5rem; align-items: center; font-size: .85rem; font-weight: 600; }
.pg-tag { background: var(--accent); color: var(--accent-fg); border-radius: 4px; padding: 0 .45rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
.pg-tag.t { background: var(--fg); color: var(--bg); }
/* transform makes the student's fixed overlay stay inside the pane */
.pg-screen, .pg-frame { flex: 1; min-height: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); overflow: hidden; }
.pg-screen { position: relative; transform: translateZ(0); }
.pg-screen .exam { height: 100%; }
.pg-frame { width: 100%; display: block; }
html:fullscreen .pg-bar, html:fullscreen .pg-teacher, html:fullscreen .pg-label { display: none; }
html:fullscreen .pg-main { padding: 0; grid-template-columns: minmax(0, 1fr); }
html:fullscreen .pg-screen { position: fixed; inset: 0; border: 0; border-radius: 0; z-index: 100; }
@media (max-width: 900px) {
  .pg-main { grid-template-columns: minmax(0, 1fr); grid-auto-rows: minmax(0, 1fr); }
}

@media print {
  body.student { display: none !important; }
}
