:root {
  --bg: #f6f7f9; --fg: #1b1f24; --muted: #4a5360; --card: #ffffff; --border: #c9ced6;
  --accent: #0b5cad; --accent-fg: #ffffff; --ok: #146c2e; --bad: #a4161a; --warn: #7a4b00; --focus: #f2b600;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171b; --fg: #eef1f4; --muted: #b6bfca; --card: #1d2228; --border: #3a434e;
    --accent: #69a9ff; --accent-fg: #0b1220; --ok: #6fd38b; --bad: #ff8a8a; --warn: #ffc76b; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--fg); }
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
main:focus { outline: none; }
h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
.topbar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--border); }
.whoami { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin: 0 0 16px; }
.narrow { max-width: 420px; }
label { display: block; font-weight: 600; margin: .5rem 0 .25rem; }
input, select, textarea { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--muted); border-radius: 6px; background: var(--card); color: var(--fg); min-height: 44px; }
button { font: inherit; min-height: 44px; padding: 8px 16px; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-fg); cursor: pointer; margin-top: .5rem; }
button.secondary { background: transparent; color: var(--accent); }
button:disabled { opacity: .6; cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; background: var(--card); padding: 8px; z-index: 10; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hint { color: var(--muted); margin: .25rem 0 .75rem; }
.status { min-height: 1.5em; }
.msg { min-height: 1.5em; font-weight: 600; }
.msg.error, .error { color: var(--bad); }
.msg.ok { color: var(--ok); }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline input { flex: 1 1 240px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px 16px; align-items: end; }
.section-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.key-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.key-list li { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; }
.key-list input[type=file] { width: auto; min-height: 0; border: 0; padding: 0; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor; font-size: .875rem; font-weight: 600; }
.badge.ok { color: var(--ok); } .badge.bad { color: var(--bad); } .badge.warn { color: var(--warn); } .badge.muted { color: var(--muted); }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; }
.meta dt { font-weight: 600; } .meta dd { margin: 0; overflow-wrap: anywhere; }
.responses { padding-left: 1.25rem; }
.responses li { margin: 0 0 12px; }
.prompt { white-space: pre-wrap; font-family: inherit; margin: 0 0 .25rem; }
pre.prompt { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--bg); padding: 8px; border-radius: 6px; overflow-x: auto; }
.local-score { margin: 8px 0; font-weight: 600; }
.exports a { display: inline-block; margin: 4px 16px 4px 0; color: var(--accent); }
fieldset { border: 1px solid var(--border); border-radius: 6px; margin: 0 0 16px; padding: 12px; }
legend { font-weight: 600; padding: 0 4px; }
.option { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; }
.option input { width: 22px; height: 22px; min-height: 0; margin-top: 2px; flex: none; }
.option label { font-weight: 400; margin: 0; }
.timer { font-weight: 700; }
.sticky { position: sticky; top: 0; background: var(--bg); padding: 8px 0; z-index: 2; }
dialog { border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--fg); max-width: 92vw; }
@media (max-width: 600px) { .meta { grid-template-columns: 1fr; } th, td { padding: 6px 4px; } }
/* Phone widths: nothing may push the page wider than the viewport. */
.key-list li > span { min-width: 0; max-width: 100%; }
.key-list input[type=file] { max-width: 100%; }
.card, .responses li, .meta dd, .table-wrap { min-width: 0; max-width: 100%; }
pre.prompt, .prompt { white-space: pre-wrap; overflow-wrap: anywhere; }
small { overflow-wrap: anywhere; }
.key-list { grid-template-columns: minmax(0, 1fr); }
.table-wrap { position: relative; }

/* Admin: local grading of written items and defect logs */
.gradebox { border: 1px solid var(--border); border-radius: 6px; padding: .6rem .8rem; margin: .5rem 0; }
.levelrow { display: grid; grid-template-columns: auto 1fr; gap: .4rem .6rem; align-items: start; margin: .3rem 0; font-weight: normal; }
.log-table { font-size: .85rem; }
.log-table td { white-space: pre-wrap; vertical-align: top; }
