:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #eef2f0;
  --text: #17201c;
  --muted: #5d6b64;
  --border: #dce3df;
  --brand: #1f6f4a;          /* evergreen */
  --brand-ink: #ffffff;
  --brand-soft: #e3f1ea;
  --good: #2e7d32;
  --good-soft: #e5f4e6;
  --warn: #b26a00;
  --warn-soft: #fff3df;
  --bad: #c62828;
  --bad-soft: #fdeaea;
  --focus: #2563eb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 4px 16px rgba(16, 24, 20, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412;
    --surface: #171e1b;
    --surface-2: #1f2824;
    --text: #e6ece9;
    --muted: #93a39b;
    --border: #2b3632;
    --brand: #3fa877;
    --brand-ink: #0b1310;
    --brand-soft: #1b3229;
    --good: #5cc46a;
    --good-soft: #1a2e1d;
    --warn: #f0a83a;
    --warn-soft: #33281a;
    --bad: #ef6b6b;
    --bad-soft: #3a1d1d;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 1rem; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .85em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 24px; padding-bottom: 32px; }

/* 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; justify-content: space-between; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { background: var(--brand); color: var(--brand-ink); border-radius: 8px; padding: 3px 7px; font-size: .85rem; letter-spacing: .5px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav a { color: var(--muted); padding: 8px 12px; border-radius: 8px; font-weight: 500; }
nav a:hover { background: var(--surface-2); text-decoration: none; }
nav a.active { color: var(--text); background: var(--surface-2); }
.nav-form { display: inline-flex; align-items: center; gap: 4px; margin: 0 0 0 8px; }
.login { max-width: 460px; margin: 48px auto; text-align: center; }
.login .btn { display: inline-flex; align-items: center; gap: 10px; margin-top: 8px; }
.login-error { color: var(--bad); }

.footer { color: var(--muted); font-size: .85rem; padding-bottom: 32px; }

/* building blocks */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h1, .card-head h2 { margin: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card { margin-top: 20px; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; margin: 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .06em; font-size: .75rem; color: var(--muted); font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--brand); }
.btn.ghost { border-color: transparent; }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 2px 6px; border-radius: 6px; }
.link-btn.on { color: var(--warn); background: var(--warn-soft); }

select, input[type=search] {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px; min-width: 0;
}
.action select { flex: 1 1 140px; }

.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .8rem; font-weight: 600; }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chips { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.chips.filter a.chip:hover { text-decoration: none; color: var(--text); }
.chips.filter a.chip.active { background: var(--brand); color: var(--brand-ink); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.badge.pass { background: var(--good-soft); color: var(--good); }
.badge.fail { background: var(--bad-soft); color: var(--bad); }

.meter { display: inline-block; vertical-align: middle; width: calc(100% - 52px); height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.meter-fill { height: 100%; border-radius: 99px; background: var(--brand); }
.meter-fill.good { background: var(--good); }
.meter-fill.warn { background: var(--warn); }
.meter-fill.bad { background: var(--bad); }
.meter-label { display: inline-block; width: 44px; text-align: right; font-variant-numeric: tabular-nums; font-size: .9rem; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--border); }
td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-scroll { overflow-x: auto; }
.cat-table td:nth-child(2) { width: 42%; }

/* dashboard */
.hero { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 24px; flex-wrap: wrap; }
.hero > div:first-child { flex: 1 1 420px; }
.hero p { max-width: 62ch; margin: 0; }
.readiness { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 20px; }
.readiness-value { font-size: 2.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.readiness-value small { font-size: 1.1rem; }
.readiness.good .readiness-value { color: var(--good); }
.readiness.warn .readiness-value { color: var(--warn); }
.readiness-label { font-weight: 600; font-size: .9rem; line-height: 1.3; }
.readiness-label .muted { font-weight: 400; font-size: .8rem; }

.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 20px; }
.action { display: flex; flex-direction: column; margin: 0; }
.action p { flex: 1; }
.action .btn { align-self: flex-start; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 20px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.tile-value { font-size: 1.8rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.tile-value .muted, .tile-value small { font-size: 1rem; font-weight: 600; }
.tile-label { color: var(--muted); font-size: .85rem; }

.trend { position: relative; height: 180px; display: flex; align-items: flex-end; gap: 8px; padding-top: 8px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.trend-pass { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--muted); opacity: .6; }
.trend-pass span { position: absolute; right: 0; top: -20px; font-size: .72rem; color: var(--muted); }
.trend-bar { flex: 1; max-width: 48px; border-radius: 6px 6px 0 0; position: relative; min-height: 4px; }
.trend-bar.pass { background: var(--good); }
.trend-bar.fail { background: var(--bad); }
.trend-bar span { position: absolute; top: -20px; left: 0; right: 0; text-align: center; font-size: .75rem; color: var(--muted); }

/* exam */
.exam-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.exam-head-right { display: flex; gap: 12px; align-items: center; }
.progress-text { font-size: 1.1rem; font-weight: 700; }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; margin: 12px 0 20px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--brand); width: 0; transition: width .25s ease; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.1rem; padding: 6px 12px; border-radius: 8px; background: var(--surface-2); }
.timer.low { background: var(--bad-soft); color: var(--bad); }

.exam-body { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 20px; align-items: start; }
.question-card { margin: 0; min-height: 420px; display: flex; flex-direction: column; }
.q-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: .85rem; margin-bottom: 12px; }
.q-meta .link-btn { margin-left: auto; }
.q-prompt { font-size: 1.3rem; font-weight: 650; margin-bottom: 18px; }
.q-sign:empty { display: none; }
.q-sign { margin-bottom: 12px; }
.q-sign.small svg { width: 72px; height: 72px; }
.q-sign.small svg[viewBox="0 0 160 100"] { width: 128px; height: 80px; }
.q-sign svg[viewBox="0 0 160 100"] { border-radius: 8px; }
.q-sign .flash { animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

.choices { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 10px; }
.choice {
  width: 100%; display: flex; gap: 12px; align-items: center; text-align: left;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text);
  padding: 12px 14px; border-radius: 12px; font: inherit; cursor: pointer;
}
button.choice:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-soft); }
.choice:disabled { cursor: default; }
.choice-key {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--surface-2); font-weight: 700; font-size: .85rem; color: var(--muted);
}
.choice.selected { border-color: var(--brand); background: var(--brand-soft); }
.choice.selected .choice-key { background: var(--brand); color: var(--brand-ink); }
.choice.correct { border-color: var(--good); background: var(--good-soft); }
.choice.correct .choice-key { background: var(--good); color: #fff; }
.choice.incorrect { border-color: var(--bad); background: var(--bad-soft); }
.choice.incorrect .choice-key { background: var(--bad); color: #fff; }
.choices.static .choice { cursor: default; padding: 8px 12px; }
.choice .your { margin-left: auto; font-size: .78rem; color: var(--muted); white-space: nowrap; }

.feedback { border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; }
.feedback.ok { background: var(--good-soft); }
.feedback.ok strong { color: var(--good); }
.feedback.wrong { background: var(--bad-soft); }
.feedback.wrong strong { color: var(--bad); }

.q-nav { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.kbd-hint { font-size: .78rem; text-align: center; }

.palette-card { margin: 0; position: sticky; top: 80px; }
.palette { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 12px; }
.pal {
  aspect-ratio: 1; border: 1.5px solid var(--border); border-radius: 8px; background: var(--surface);
  color: var(--text); font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; position: relative; padding: 0;
}
.pal.answered { background: var(--brand-soft); border-color: var(--brand); }
.pal.right { background: var(--good-soft); border-color: var(--good); }
.pal.wrong { background: var(--bad-soft); border-color: var(--bad); }
.pal.flagged::after { content: ""; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.pal.current { outline: 2px solid var(--text); outline-offset: 1px; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: .78rem; color: var(--muted); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; border: 1.5px solid var(--border); }
.sw.answered { background: var(--brand-soft); border-color: var(--brand); }
.sw.flagged { background: var(--warn); border-color: var(--warn); border-radius: 50%; }
.sw.wrong { background: var(--bad-soft); border-color: var(--bad); }

.dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 24px; max-width: 420px; width: calc(100% - 32px); }
.dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* results */
.result-hero { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; border-left: 6px solid var(--bad); }
.result-hero.pass { border-left-color: var(--good); }
.result-hero > div:last-child { flex: 1 1 320px; }
.result-hero h1 { font-size: 2rem; }
.result-hero form { display: inline; }
.score-ring {
  --c: var(--bad);
  width: 140px; height: 140px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto;
  background: conic-gradient(var(--c) calc(var(--pct) * 1%), var(--surface-2) 0);
}
.result-hero.pass .score-ring { --c: var(--good); }
.score-ring > div { width: 112px; height: 112px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; grid-auto-flow: column; align-content: center; }
.score-ring strong { font-size: 2.2rem; }
.score-ring span { color: var(--muted); font-weight: 600; }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 24px; }
.cat-cell-head { display: flex; justify-content: space-between; font-size: .9rem; margin-bottom: 4px; gap: 8px; }
.cat-cell .meter { width: 100%; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg-btn { border: 0; background: none; font: inherit; font-weight: 600; font-size: .88rem; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.review-list, .bank-list { list-style: none; padding: 0; margin: 0; }
.review { padding: 18px 0; border-top: 1px solid var(--border); }
.review:first-child { border-top: 0; }
.review h3 { font-size: 1.05rem; }
.explain { background: var(--surface-2); border-radius: 10px; padding: 10px 14px; margin: 0 0 6px; font-size: .95rem; }
.answer-meta { font-size: .8rem; margin: 0; }

/* bank */
.search { width: min(360px, 100%); }
.inline-start { margin-bottom: 16px; }
.bank-item { padding: 16px 18px; margin-bottom: 12px; }
.bank-item h3 { margin: 0 0 8px; }
.bank-item details summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: .9rem; }
.bank-item details[open] summary { margin-bottom: 10px; }

/* cheat sheet */
.cs-sub { margin: 0; }
.cs-tools { margin: 0; flex-wrap: nowrap; }
.cs-nav { flex-wrap: nowrap; overflow-x: auto; background: var(--bg); padding: 10px 0; margin-bottom: 8px; scrollbar-width: thin; }
.cs-nav .chip { white-space: nowrap; }
@media (min-width: 901px) { .cs-nav { position: sticky; top: 61px; z-index: 5; } }
.cs-nav a.chip:hover { color: var(--text); text-decoration: none; }
.cs-grid { columns: 2 460px; column-gap: 20px; }
.cs-section { break-inside: avoid; scroll-margin-top: 130px; display: inline-block; width: 100%; }
.cs-section .card-head h2 { font-size: 1.1rem; }
.btn.small { padding: 6px 10px; font-size: .85rem; }
.cs-facts { margin: 0 0 8px; }
.cs-fact { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
.cs-fact dt { color: var(--muted); }
.cs-fact dd { margin: 0; font-weight: 600; }
.cs-sec { font-weight: 400; font-size: .75rem; color: var(--muted); white-space: nowrap; }
.cs-table { margin-top: 14px; }
.cs-table h3 { font-size: .9rem; color: var(--brand); margin-bottom: 4px; }
.cs-table table { font-size: .9rem; }
.cs-table th, .cs-table td { padding: 6px 8px; }
.cs-table tbody th { text-transform: none; letter-spacing: 0; font-size: .9rem; color: var(--text); width: 40%; }
.cs-source { font-size: .8rem; }
.cs-diagram { display: block; margin-bottom: 4px; }
.cs-diagram svg { width: 96px; height: 60px; border-radius: 6px; display: block; }
.cs-note { font-size: .82rem; color: var(--muted); margin: 6px 0 0; }

@media print {
  .topbar, .footer, .cs-tools, .cs-nav, .cs-section form { display: none !important; }
  body { background: #fff; color: #000; font-size: 11px; }
  .card { box-shadow: none; padding: 10px; margin-bottom: 8px; border-color: #bbb; }
  .cs-grid { columns: 2; }
}

@media (max-width: 900px) {
  .actions { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .exam-body { grid-template-columns: 1fr; }
  .palette-card { position: static; }
  .palette { grid-template-columns: repeat(10, 1fr); }
}
@media (max-width: 520px) {
  h1 { font-size: 1.4rem; }
  .q-prompt { font-size: 1.12rem; }
  .palette { grid-template-columns: repeat(8, 1fr); }
  .kbd-hint { display: none; }
  .tile-value { font-size: 1.4rem; }
  .attempts th:nth-child(5), .attempts td:nth-child(5) { display: none; }
}
