:root {
  /* Light theme only. `color-scheme: light` also forces the native controls
     (checkbox, radio, select, search box, scrollbar) to render light even when
     Windows itself is set to dark mode. */
  color-scheme: light;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #dfe3e8;
  --text: #1c2128;
  --muted: #656d76;
  --accent: #0969da;
  --accent-soft: #ddf4ff;
  --ok: #1a7f37;
  --ok-soft: #dafbe1;
  --warn: #9a6700;
  --warn-soft: #fff8c5;
  --bad: #cf222e;
  --bad-soft: #ffebe9;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(27, 31, 36, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#app { max-width: 1080px; margin: 0 auto; padding: 0 20px 64px; }

/* ---------- nav ---------- */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; padding: 18px 0 22px;
}
.nav__brand { display: flex; flex-direction: column; line-height: 1.2; }
.nav__brand strong { font-size: 18px; letter-spacing: .3px; }
.nav__links { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px; }
.nav__link {
  padding: 7px 14px; border-radius: 7px; text-decoration: none;
  color: var(--muted); font-weight: 600; font-size: 14px;
}
.nav__link:hover { color: var(--text); }
.nav__link.is-active { background: var(--accent); color: #fff; }

/* ---------- layout blocks ---------- */
.screen { display: flex; flex-direction: column; gap: 16px; }
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.panel__title { margin: 0 0 8px; font-size: 17px; }
.panel__lead { margin: 0 0 16px; color: var(--muted); }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.empty { color: var(--muted); text-align: center; padding: 28px 0; margin: 0; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.row--actions { margin-top: 6px; }
.row--nav { justify-content: space-between; }
.row--filters { margin-top: 12px; }

/* ---------- controls ---------- */
.btn {
  appearance: none; cursor: pointer; font: inherit; font-weight: 600; font-size: 14px;
  padding: 9px 16px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  text-decoration: none; display: inline-block; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover:not(:disabled) { filter: brightness(1.08); color: #fff; }
.btn--ghost { background: transparent; color: var(--muted); }
.btn--on { border-color: var(--warn); color: var(--warn); background: var(--warn-soft); }
.btn--sm { padding: 5px 10px; font-size: 13px; }

.select, .input {
  font: inherit; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.input { flex: 1; min-width: 180px; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab {
  appearance: none; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600;
  padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: transparent; color: var(--muted);
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------- question card ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.card__meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.chip {
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--border); color: var(--muted);
}
.chip--index { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip--domain { background: transparent; }
.chip--flag { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.chip--button { cursor: pointer; font-family: inherit; }
.chip--button:hover { color: var(--text); }
.chip--on { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }

.card__question { margin: 0 0 16px; font-size: 17px; line-height: 1.45; font-weight: 600; }
.card__options { display: flex; flex-direction: column; gap: 8px; }

.option {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; background: var(--surface);
}
.option:hover { border-color: var(--accent); }
.option__input { margin: 3px 0 0; accent-color: var(--accent); flex: none; }
.option__letter { font-weight: 700; color: var(--muted); flex: none; width: 16px; }
.option__text { flex: 1; }
.option--picked { border-color: var(--accent); background: var(--accent-soft); }
.option--correct { border-color: var(--ok); background: var(--ok-soft); }
.option--correct .option__letter { color: var(--ok); }
.option--wrong { border-color: var(--bad); background: var(--bad-soft); }
.option--wrong .option__letter { color: var(--bad); }
.option:has(.option__input:disabled):not(.option--correct):not(.option--wrong):not(.option--picked) { opacity: .6; cursor: default; }

.explain {
  margin-top: 16px; padding: 14px 16px;
  border-left: 3px solid var(--accent); background: var(--bg); border-radius: 0 8px 8px 0;
}
.explain__answer { font-weight: 700; color: var(--ok); margin-bottom: 6px; }
.explain__text { margin: 0; }
.explain__note { margin: 8px 0 0; font-size: 13px; color: var(--warn); }

.verdict { padding: 12px 16px; border-radius: 8px; font-weight: 700; }
.verdict.is-correct { background: var(--ok-soft); color: var(--ok); }
.verdict.is-partial { background: var(--warn-soft); color: var(--warn); }
.verdict.is-wrong { background: var(--bad-soft); color: var(--bad); }

.stat { margin: 0; font-size: 13px; }

/* ---------- exam ---------- */
.examhead {
  display: flex; align-items: center; gap: 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px;
}
.examhead__stat { display: flex; flex-direction: column; line-height: 1.2; flex: none; }
.examhead__stat span { font-size: 12px; color: var(--muted); }
.progress { flex: 1; height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.progress__bar { height: 100%; background: var(--accent); transition: width .2s; }

.examgrid { display: grid; grid-template-columns: 1fr 240px; gap: 16px; align-items: start; }
.examgrid > div { display: flex; flex-direction: column; gap: 12px; }

.sidebar {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; position: sticky; top: 16px;
}
.sidebar__title { margin: 0 0 12px; font-size: 14px; }
.palette { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.palette__cell {
  appearance: none; cursor: pointer; font: inherit; font-size: 12px; font-weight: 600;
  aspect-ratio: 1; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg); color: var(--muted);
}
.palette__cell:hover { border-color: var(--accent); }
.palette__cell.is-answered { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.palette__cell.is-flagged { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.palette__cell.is-current { outline: 2px solid var(--text); outline-offset: 1px; }

.legend { list-style: none; margin: 14px 0; padding: 0; font-size: 12px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.dot { width: 12px; height: 12px; border-radius: 4px; border: 1px solid var(--border); background: var(--bg); flex: none; }
.dot.is-answered { background: var(--accent-soft); border-color: var(--accent); }
.dot.is-flagged { background: var(--warn-soft); border-color: var(--warn); }

/* ---------- result ---------- */
.result__score { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.result__percent { font-size: 46px; font-weight: 800; line-height: 1; }
.result__percent.is-pass { color: var(--ok); }
.result__percent.is-fail { color: var(--bad); }
.result__badge { font-weight: 800; padding: 6px 14px; border-radius: 999px; letter-spacing: 1px; }
.result__badge.is-pass { background: var(--ok-soft); color: var(--ok); }
.result__badge.is-fail { background: var(--bad-soft); color: var(--bad); }
.result__meta { margin-left: auto; text-align: right; }
.result__strict {
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 14px;
}
.reviewlist { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }

.bars { display: flex; flex-direction: column; gap: 12px; }
.bar__head { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; margin-bottom: 5px; }
.bar__label { font-weight: 600; }
.bar__value { color: var(--ok); font-weight: 600; }
.bar__value.is-weak { color: var(--bad); }
.bar__track { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.bar__fill { height: 100%; background: var(--ok); }
.bar__fill.is-weak { background: var(--bad); }

/* ---------- history ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat-tile {
  display: flex; flex-direction: column; gap: 2px; padding: 14px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; font-size: 12px; color: var(--muted);
}
.stat-tile__value { font-size: 22px; font-weight: 700; color: var(--text); }

.table, .plan { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 12px; }
.table th, .table td, .plan th, .plan td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
.table th, .plan th { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); white-space: nowrap; }
.plan td:last-child, .plan th:last-child { text-align: right; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.badge { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.badge.is-pass, .badge.is-mastered { background: var(--ok-soft); color: var(--ok); }
.badge.is-fail, .badge.is-weak { background: var(--bad-soft); color: var(--bad); }
.badge.is-shaky { background: var(--warn-soft); color: var(--warn); }
.badge.is-good { background: var(--accent-soft); color: var(--accent); }
.badge.is-unseen { background: var(--bg); color: var(--muted); }

/* ---------- review ---------- */
.stat-tile__value.is-ok { color: var(--ok); }
.stat-tile__value.is-bad { color: var(--bad); }
.stat-tile__value.is-warn { color: var(--warn); }

.cell-question {
  max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.screen--review .row--nav { justify-content: space-between; align-items: center; }

@media (max-width: 860px) {
  .examgrid { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .palette { grid-template-columns: repeat(10, 1fr); }
  .result__meta { margin-left: 0; text-align: left; width: 100%; }
}
