:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f0efe9;
  --border: #dedcd3;
  --text: #1d1f1c;
  --muted: #62665e;
  --accent: #1f5f4a;
  --accent-ink: #ffffff;
  --accent-soft: #e2efe8;
  --ok: #1d7a46;
  --ok-soft: #e1f3e8;
  --bad: #b3261e;
  --bad-soft: #fbe7e5;
  --warn: #8a5a00;
  --warn-soft: #fbf0d9;
  --excel: #1d6f42;
  --sql: #2c5aa0;
  --reg: #7a3e9d;
  --code-bg: #f3f2ec;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.04);
  --radius: 10px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141614; --surface: #1c1f1c; --surface-2: #232723; --border: #343a34; --text: #e9ebe6; --muted: #a2a99f;
    --accent: #5fb892; --accent-ink: #0d1a14; --accent-soft: #1f3a2f; --ok: #6cc893; --ok-soft: #1c3526; --bad: #f08a80;
    --bad-soft: #3d1f1c; --warn: #e8b960; --warn-soft: #3a2f17; --excel: #6cc893; --sql: #85adf0; --reg: #c79be3; --code-bg: #171a17;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141614; --surface: #1c1f1c; --surface-2: #232723; --border: #343a34; --text: #e9ebe6; --muted: #a2a99f;
  --accent: #5fb892; --accent-ink: #0d1a14; --accent-soft: #1f3a2f; --ok: #6cc893; --ok-soft: #1c3526; --bad: #f08a80;
  --bad-soft: #3d1f1c; --warn: #e8b960; --warn-soft: #3a2f17; --excel: #6cc893; --sql: #85adf0; --reg: #c79be3; --code-bg: #171a17;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
code, pre, textarea.sql { font-family: var(--mono); font-size: 13px; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
main { padding-top: 24px; padding-bottom: 40px; outline: none; min-height: 70vh; }

/* top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; gap: 16px; min-height: 56px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; }
.brand svg { width: 28px; height: 28px; }
.brand svg rect { fill: var(--accent); }
.brand svg path { stroke: var(--accent-ink); stroke-width: 3; stroke-linecap: round; fill: none; }
.mainnav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.mainnav a { white-space: nowrap; color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-weight: 500; font-size: 14px; }
.mainnav a:hover { background: var(--surface-2); color: var(--text); }
.mainnav a.active { background: var(--accent-soft); color: var(--accent); }
.footer { color: var(--muted); font-size: 13px; padding-top: 16px; padding-bottom: 32px; border-top: 1px solid var(--border); }

/* building blocks */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.lead { font-size: 1.05rem; color: var(--muted); max-width: 70ch; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input[type=text], input[type=number], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-height: 38px; }
select { padding-right: 28px; }
textarea { width: 100%; resize: vertical; }
textarea.sql { min-height: 120px; background: var(--code-bg); line-height: 1.5; tab-size: 2; }
label.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }

.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.excel { color: var(--excel); background: color-mix(in srgb, var(--excel) 12%, transparent); }
.chip.sql { color: var(--sql); background: color-mix(in srgb, var(--sql) 12%, transparent); }
.chip.reg { color: var(--reg); background: color-mix(in srgb, var(--reg) 12%, transparent); }
.chip.ok { color: var(--ok); background: var(--ok-soft); }
.chip.bad { color: var(--bad); background: var(--bad-soft); }
.chip.warn { color: var(--warn); background: var(--warn-soft); }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border); display: inline-block; flex: none; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }

.feedback { border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.feedback.ok { background: var(--ok-soft); color: var(--ok); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }
.feedback.info { background: var(--surface-2); color: var(--text); }
.feedback strong { font-weight: 700; }

pre.code { background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-word; margin: 0; }

/* home */
.hero { padding: 8px 0 20px; }
.hero h1 { font-size: 2rem; max-width: 22ch; }
.format { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.format .card h2 { display: flex; align-items: center; gap: 8px; }
.format ul { margin: .25rem 0 1rem; padding-left: 1.1rem; }
.promise { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: 12px 16px; border-radius: 0 var(--radius) var(--radius) 0; }

/* lists */
.list { display: grid; gap: 8px; }
.list-item { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); }
.list-item:hover { border-color: var(--accent); }
.list-item .title { font-weight: 500; }
.list-item .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.exam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.exam-card { display: block; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-decoration: none; }
.exam-card:hover { border-color: var(--accent); }
.exam-card .id { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.exam-card h3 { margin: 4px 0 8px; font-size: 15px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin: 12px 0 16px; }

/* exam */
.exam-layout { display: grid; grid-template-columns: 260px 1fr; gap: 18px; align-items: start; }
.sidebar { position: sticky; top: 72px; display: grid; gap: 14px; }
.timer { text-align: center; }
.timer .clock { font-family: var(--mono); font-size: 2.2rem; font-weight: 500; letter-spacing: .02em; }
.timer .clock.low { color: var(--warn); }
.timer .clock.over { color: var(--bad); }
.timer .sub { font-size: 13px; color: var(--muted); }
.qnav { display: grid; gap: 6px; }
.qnav button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.qnav button.active { border-color: var(--accent); background: var(--accent-soft); }
.qnav .n { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.files a { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; font-size: 14px; border-bottom: 1px dashed var(--border); word-break: break-all; }
.files a:last-child { border-bottom: 0; }
.files a .small { white-space: nowrap; }

.question .prompt { font-size: 1.05rem; font-weight: 500; margin: 8px 0 14px; }
.answer-row { display: flex; gap: 8px; flex-wrap: wrap; }
.answer-row input { flex: 1 1 220px; }
.result-wrap { max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th, table.data td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
table.data th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.schema { font-size: 13px; }
.schema details { border-bottom: 1px solid var(--border); padding: 4px 0; }
.schema summary { cursor: pointer; font-family: var(--mono); }
.schema .cols { color: var(--muted); font-family: var(--mono); padding: 4px 0 4px 14px; }
.kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--border); border-bottom-width: 2px; padding: 0 5px; border-radius: 4px; color: var(--muted); }

/* interpretation */
table.coef { border-collapse: collapse; font-size: 14px; min-width: 320px; }
table.coef th, table.coef td { padding: 6px 12px; border-bottom: 1px solid var(--border); text-align: left; }
table.coef td.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.equation { font-family: var(--mono); font-size: 13px; background: var(--code-bg); padding: 8px 10px; border-radius: 8px; overflow-x: auto; }
.points label { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; font-size: 14px; }

/* progress */
.stat { padding: 14px; }
.stat .v { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 13px; }
.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
table.topics { width: 100%; border-collapse: collapse; font-size: 14px; }
table.topics td, table.topics th { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: left; }
table.topics td.num { text-align: right; font-variant-numeric: tabular-nums; }

.hidden { display: none !important; }
.loading { color: var(--muted); font-size: 14px; }

@media (max-width: 820px) {
  .exam-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .hero h1 { font-size: 1.6rem; }
  .mainnav { margin-left: 0; width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 6px; }
  .list-item { grid-template-columns: auto 1fr; }
  .list-item > :last-child { grid-column: 2; }
}

/* reconciliation feedback */
ul.recon { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; color: var(--text); }
ul.recon li { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 14px; }
ul.recon .mark { font-weight: 700; width: 1em; }
ul.recon li.ok .mark { color: var(--ok); }
ul.recon li.bad .mark { color: var(--bad); }
ul.recon li span:last-child { color: var(--muted); }
.feedback .hint { margin-top: 8px; padding: 8px 10px; border-radius: 6px; background: var(--warn-soft); color: var(--text); }
.feedback .hint strong { color: var(--warn); }
.dot.saved { background: var(--sql); }
