:root {
  --ink: #0f2e35;
  --teal: #1f6f6a;
  --mist: #e6f0ee;
  --amber: #f2a900;
  --sand: #fff4d6;
  --bg: #f7faf9;
  --surface: #ffffff;
  --text: #13262b;
  --muted: #55676b;
  --line: #d5e3e0;
  --good: #1b7a4b;
  --good-bg: #e3f4ea;
  --bad: #b23c26;
  --bad-bg: #fbe9e5;
  --focus: #f2a900;
  --btn: #0f2e35;
  --btn-text: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 46, 53, .06), 0 4px 16px rgba(15, 46, 53, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1c20; --surface: #12292f; --text: #e8f1ef; --muted: #9fb7b3; --line: #24434a;
    --mist: #173a40; --sand: #3a3115; --good: #6fd39c; --good-bg: #133626; --bad: #ff9a85; --bad-bg: #3d1d17;
    --shadow: none; --btn: #f2a900; --btn-text: #0f2e35; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1c20; --surface: #12292f; --text: #e8f1ef; --muted: #9fb7b3; --line: #24434a;
  --mist: #173a40; --sand: #3a3115; --good: #6fd39c; --good-bg: #133626; --bad: #ff9a85; --bad-bg: #3d1d17;
  --shadow: none; --btn: #f2a900; --btn-text: #0f2e35; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Calibri, Arial, sans-serif;
}
.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px; }
a { color: var(--teal); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.site-header { background: var(--ink); color: #fff; }
.header-inner { display: flex; align-items: center; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand small { display: block; color: #9fb7b3; font-size: 13px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--amber); color: var(--ink); flex: none; }

main { padding-top: 28px; padding-bottom: 40px; outline: none; }
main:focus, main:focus-visible { outline: none; }
h1 { font-size: clamp(26px, 5vw, 34px); line-height: 1.2; margin: 0 0 8px; }
h2 { font-size: 22px; margin: 0 0 8px; }
.lede { color: var(--muted); margin: 0 0 24px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin-bottom: 18px; }
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.mode h2 { display: flex; align-items: center; gap: 10px; }
.pill { display: inline-block; font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--sand); color: var(--text); }
.pill.teal { background: var(--mist); }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.btn {
  appearance: none; border: 2px solid var(--btn); background: var(--btn); color: var(--btn-text);
  font: inherit; font-weight: 600; padding: 10px 18px; border-radius: 10px; cursor: pointer; min-height: 44px;
}
.btn:hover { filter: brightness(1.15); }
.btn.secondary { background: transparent; color: var(--text); border-color: var(--line); }
.btn.accent { background: var(--amber); border-color: var(--amber); color: var(--ink); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.actions .spacer { flex: 1; }

label.field { display: block; margin-bottom: 14px; font-weight: 600; }
label.field input, select {
  display: block; width: 100%; margin-top: 6px; font: inherit; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); min-height: 44px;
}
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 5px; width: 18px; height: 18px; flex: none; }

.progress { height: 8px; background: var(--mist); border-radius: 999px; overflow: hidden; margin: 6px 0 18px; }
.progress > span { display: block; height: 100%; background: var(--amber); transition: width .2s; }
.qmeta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; color: var(--muted); font-size: 14px; }
.stem { font-size: 20px; font-weight: 600; margin: 10px 0 16px; }
.options { display: grid; gap: 10px; margin: 0; padding: 0; border: 0; }
.option {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 2px solid var(--line);
  border-radius: 12px; cursor: pointer; background: var(--surface);
}
.option:hover { border-color: var(--teal); }
.option input { margin-top: 4px; width: 20px; height: 20px; flex: none; accent-color: var(--teal); }
.option.correct { border-color: var(--good); background: var(--good-bg); }
.option.wrong { border-color: var(--bad); background: var(--bad-bg); }
.numeric { display: flex; gap: 10px; align-items: center; }
.numeric input { max-width: 180px; }

.feedback { margin-top: 16px; padding: 14px 16px; border-radius: 12px; }
.feedback.good { background: var(--good-bg); }
.feedback.bad { background: var(--bad-bg); }
.feedback strong { display: block; margin-bottom: 4px; }

.score { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.score .big { font-size: 56px; font-weight: 800; line-height: 1; }
.score .pass { color: var(--good); }
.score .fail { color: var(--bad); }
table.breakdown { width: 100%; border-collapse: collapse; font-size: 15px; }
table.breakdown th, table.breakdown td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.breakdown td.num { text-align: right; white-space: nowrap; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 20px; letter-spacing: .08em; background: var(--mist); padding: 4px 10px; border-radius: 8px; }
.navgrid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.navgrid button { min-width: 36px; min-height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.navgrid button.done { background: var(--mist); border-color: var(--teal); }
.navgrid button.current { outline: 2px solid var(--amber); }

.site-footer { color: var(--muted); font-size: 13px; padding-bottom: 32px; }
@media (max-width: 520px) {
  body { font-size: 16px; }
  .card { padding: 16px; }
  .stem { font-size: 18px; }
  .actions .btn { flex: 1 1 auto; }
}
.code { white-space: nowrap; display: inline-block; }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
