:root {
  --bg: #f5f5f0; --card: #fff; --line: #d1d1c7; --line-soft: #e5e5dc;
  --ink: #2f3437; --muted: #6b7280; --accent: #5a7d7c; --accent-soft: #85b7b6;
  --ok: #588157; --ok-bg: #f0f8f0; --bad: #e76f51; --bad-bg: #fdf5f0; --warn: #b8860b;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.page { max-width: 980px; margin: 0 auto; padding: 24px 16px 60px; }
header.site { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.brand { color: var(--accent); text-decoration: none; font-size: 20px; }
nav { display: flex; gap: 14px; align-items: center; }
nav a { color: var(--accent); }
.card { background: var(--card); border: 1px solid var(--line); padding: 24px; }
h1 { font-weight: 400; color: var(--accent); font-size: 24px; margin: 0 0 8px; }
h2 { font-weight: 400; color: var(--accent); font-size: 18px; margin: 24px 0 12px; border-bottom: 1px solid var(--line-soft); padding-bottom: 6px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .caps { text-transform: uppercase; letter-spacing: .1em; font-size: 11px; }
.error { color: var(--bad); } .ok { color: var(--ok); } .warn { color: var(--warn); }
.inline { display: inline; }
button { font: inherit; cursor: pointer; }
button.link { background: none; border: none; color: var(--accent); padding: 0; text-decoration: underline; }
button:not(.link):not(.sym):not(.tool):not(.hate):not(.skip) { background: var(--accent-soft); color: #fff; border: none; padding: 8px 18px; }
button:not(.link):not(.sym):not(.tool):not(.hate):not(.skip):hover { background: var(--accent); }
button:disabled { background: #b3c8c8 !important; cursor: not-allowed; }
.stack { display: flex; flex-direction: column; gap: 14px; } .narrow { max-width: 380px; }
label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); }
input[type=text], input[type=password], input:not([type]), input[inputmode] { font: inherit; padding: 8px 10px; border: 1px solid var(--line); background: #fafaf5; color: var(--ink); }
input:focus, math-field:focus-within { outline: none; border-color: var(--accent-soft); }

.summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.chip { border: 1px solid var(--line); background: #fff; padding: 8px 10px; display: flex; flex-direction: column; }
.chip b { color: var(--accent); } .chip.overdue { border-color: var(--bad); background: var(--bad-bg); }

.layout { display: flex; gap: 24px; align-items: flex-start; }
.questions { flex: 1; min-width: 0; }
/* The typing guide stays in view and scrolls on its own, so its bottom rows are reachable
   without scrolling the problem list to the end. */
.cheatsheet { width: 150px; flex-shrink: 0; position: sticky; top: 16px; max-height: calc(100vh - 32px);
  overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }
.cheatsheet .row { display: flex; align-items: center; gap: 6px; margin: 8px 0; flex-wrap: wrap; }
.cheatsheet code { background: #f0f0e8; border: 1px solid var(--line); padding: 1px 5px; font-size: 12px; color: var(--accent); }
.cheatsheet math-field { font-size: 14px; border: 1px solid var(--line); background: #f8f8f3; padding: 0 4px; }
.cheatsheet .lim-help { border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 8px; }
.cheatsheet .lim-help ol { padding-left: 18px; margin: 4px 0; }
.cheatsheet .lim-help li { margin: 4px 0; }
.cheatsheet kbd { border: 1px solid var(--line); padding: 0 4px; font-size: 11px; }
@media (max-width: 760px) { .cheatsheet { display: none; } }

details.group { border: 1px solid var(--line); margin: 14px 0; }
details.group > summary { padding: 10px 12px; background: #f0f0e8; color: var(--accent); cursor: pointer; }
details.group > article { margin: 12px; }

article.question { border: 1px solid var(--line); background: #fafaf5; margin-bottom: 18px; }
article.question.overdue { border-color: #edcdc2; background: var(--bad-bg); }
article.question.solved { background: var(--ok-bg); }
article.question > header { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.booknum { color: var(--accent); font-size: 17px; }
.tag { font-size: 12px; background: var(--ok-bg); color: var(--ok); padding: 1px 6px; }
.prompt { padding: 10px 14px 0; margin: 0; color: var(--muted); }
.symbols { padding: 10px 14px 0; display: flex; gap: 6px; flex-wrap: wrap; }
button.sym { background: #fff; border: 1px solid var(--line); padding: 3px 10px; border-radius: 3px; }
button.sym:hover { border-color: var(--accent-soft); }
article.question math-field.answer, article.question input.answer { display: block; flex: 1; min-width: 0; min-height: 48px; font-size: 18px; border: 1px solid var(--line); background: #fff; padding: 6px 10px; }
.answer-row { display: flex; align-items: stretch; gap: 8px; margin: 12px 14px; }
.answer-tools { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
button.tool { background: #fff; border: 1px solid var(--line); color: var(--accent); padding: 2px 9px; font-size: 11px; border-radius: 3px; }
button.tool:hover { border-color: var(--accent-soft); }
button.tool.flash { background: var(--ok); border-color: var(--ok); color: #fff; }
/* No on-screen keyboard: students type on a real keyboard, and the toggle crowds the box. */
math-field::part(virtual-keyboard-toggle) { display: none; }
.answer-table { margin: 12px 14px; border-collapse: collapse; }
.answer-table th, .answer-table td { border: 1px solid var(--line); padding: 4px 6px; }
.answer-table th { background: #f0f0e8; font-weight: 500; }
.answer-table th math-field { font-size: 15px; background: transparent; }
.answer-table td math-field { min-width: 110px; min-height: 34px; font-size: 16px; background: #fff; border: 1px solid var(--line-soft); }
/* Grid questions: fixed row labels and given cells, a ✓/✗ beside each answer box. */
.answer-table.grid th.rowlabel { text-align: left; white-space: nowrap; }
.answer-table.grid th.rowlabel math-field { border: none; background: transparent; }
.answer-table.grid td.given math-field { background: transparent; border: none; }
.answer-table.grid td.cellbox { white-space: nowrap; }
.answer-table.grid td.cellbox math-field { display: inline-block; min-width: 170px; vertical-align: middle; }
.answer-table.grid .mark { display: inline-block; width: 1.4em; margin-left: 4px; font-weight: bold; }
.answer-table.grid td.good .mark { color: var(--ok); }
.answer-table.grid td.bad .mark { color: var(--bad); }
.answer-table.grid td.good math-field { border-color: var(--ok); }
.answer-table.grid td.bad math-field { border-color: var(--bad); }
article.question.note { border-style: dashed; }
.actions { padding: 10px 14px; border-top: 1px solid var(--line-soft); display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.feedback { font-size: 14px; }
article.question > p.ok { padding: 10px 14px; margin: 0; }
details.history { padding: 8px 14px 12px; border-top: 1px solid var(--line-soft); font-size: 14px; }
details.history summary { color: var(--accent); cursor: pointer; }
details.history ul { list-style: none; padding: 0; margin: 8px 0 0; }
details.history li { display: flex; gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--line-soft); }
details.history math-field { font-size: 15px; background: transparent; }
.dot { width: 12px; height: 12px; display: inline-block; flex-shrink: 0; }
.dot.good { background: var(--ok); } .dot.bad { background: var(--bad); }

/* admin */
table.data { border-collapse: collapse; width: 100%; font-size: 14px; }
table.data th, table.data td { border: 1px solid var(--line-soft); padding: 6px 8px; text-align: left; vertical-align: top; }
table.data th { background: #f0f0e8; font-weight: 500; }
pre.wrap { white-space: pre-wrap; word-break: break-word; background: #f8f8f3; padding: 8px; font-size: 12px; max-height: 260px; overflow: auto; }
.pill { font-size: 12px; padding: 1px 7px; border-radius: 10px; }
.pill.good { background: var(--ok-bg); color: var(--ok); } .pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.gray { background: #eee; color: var(--muted); }

/* ---- Blackboard theme (chosen 2026-09-15): overrides of the defaults above ---- */
:root {
  --bg: #000; --card: #111; --line: #2c2c2c; --line-soft: #222;
  --ink: #f2f2f2; --muted: #9a9a9a; --accent: #3b9ad6; --accent-soft: #0b6fa4;
  --ok: #3bb273; --ok-bg: #0f2a1c; --bad: #e04b4b; --bad-bg: #241111; --warn: #e0a91e;
}
.brand { color: #fff; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; font-size: 17px; }
.card { border-color: var(--line); }
h1 { color: #fff; } h2 { color: var(--warn); border-color: var(--line); }
button:not(.link):not(.sym):not(.tool):not(.hate):not(.skip) { background: #d42020; }
button:not(.link):not(.sym):not(.tool):not(.hate):not(.skip):hover { background: #ff3a3a; }
button:disabled { background: #444 !important; }
input[type=text], input[type=password], input:not([type]), input[inputmode] { background: #0a0a0a; color: #fff; }
.chip { background: #161616; } .chip b { color: var(--accent); }
.chip.overdue { border-color: var(--warn); background: #241d0a; }
details.group > summary { background: #1a1a1a; color: var(--accent); }
article.question { background: #161616; }
article.question.overdue { border-color: #5a2a2a; background: #1f1212; }
article.question.solved { background: #10201a; }
.booknum { color: var(--accent); }
.tag { background: var(--ok-bg); color: var(--ok); }
.prompt { color: #cfcfcf; }
button.sym { background: #1e1e1e; color: #fff; border-color: #333; }
article.question math-field.answer, article.question input.answer, .answer-table td math-field { background: #0a0a0a; color: #fff; }
.answer-table th { background: #1a1a1a; color: #fff; }
math-field { color: #fff; --caret-color: #fff; --selection-background-color: #0b6fa4; --contains-highlight-background-color: #1a2a33; }
.cheatsheet code { background: #1a1a1a; color: var(--warn); border-color: #333; }
.cheatsheet math-field { background: #0a0a0a; }
details.history summary { color: var(--accent); }
table.data th { background: #1a1a1a; } pre.wrap { background: #0a0a0a; }
.pill.gray { background: #222; }
button.hate { background: #2a2a2a; color: #8a8a8a; border: 1px solid #383838; padding: 3px 8px; font-size: 11px; }
button.hate:hover { background: #333; color: #b5b5b5; }
/* Skip: quiet like the hate button, but in the accent colour so it reads as an action. */
button.skip { background: #14202a; color: var(--accent); border: 1px solid #22394a; padding: 3px 8px; font-size: 11px; }
button.skip:hover:not(:disabled) { background: #1a2a36; }
button.skip:disabled { background: #1a1a1a !important; color: #555; border-color: #2a2a2a; }
.skip-confirm button { padding: 3px 10px !important; font-size: 12px; margin-left: 6px; }
article.question.skipped { background: #161b22; }
article.question > p.skipped { color: var(--accent); padding: 10px 14px; margin: 0; }

/* Submit All: pinned to the left edge, always reachable. */
.submit-all { position: fixed; left: 16px; top: 50%; transform: translateY(-50%); z-index: 30; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; max-width: 130px; }
.submit-all button { white-space: nowrap; }
.submit-all #submit-all-note { line-height: 1.3; }
@media (max-width: 1260px) { .submit-all { top: auto; bottom: 16px; transform: none; flex-direction: row; align-items: center; max-width: calc(100vw - 32px); background: var(--bg); padding: 6px 8px; border: 1px solid var(--line); } }

/* Word-answer boxes are plain text, not math: make that obvious at a glance. */
article.question input.answer.text { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 16px; border-style: dashed; }

/* Copy/Paste chips beside the answer box. */
button.tool { background: #1e1e1e; border-color: #333; color: var(--accent); }
button.tool:hover { background: #262626; }
button.tool.flash { background: var(--ok); border-color: var(--ok); color: #fff; }
