:root {
  --canvas: #efe6d6;
  --raised: #fbf6ec;
  --ink: #1c1612;
  --muted: #554c44;
  --faint: #7a7066;
  --line: #d9cdb8;
  --margin: #c4493a;
  --brand: #9d2d1f;
  --on-brand: #fff7f2;
  --ok: #1b5a40;
  --ok-bg: #e4f0e8;
  --bad: #9d2d1f;
  --bad-bg: #f8e7e2;
  --info: #243e5c;
  --radius: 2px;
  --font: "Be Vietnam Pro", "Segoe UI", sans-serif;
  --num: "Fraunces", "Palatino Linotype", Palatino, serif;
  --top: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
}
img { max-width: 100%; height: auto; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--raised);
  padding: 8px 12px;
  z-index: 50;
}
.skip:focus { top: 12px; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: var(--top);
  padding: 10px 28px;
  background: var(--raised);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex: 0 0 auto;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  background: var(--brand);
  color: var(--on-brand);
  font-family: var(--num);
  font-size: 16px;
  font-weight: 620;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 14px; font-weight: 600; }
.brand-text small { color: var(--muted); font-size: 12px; }
.crumb-nav { display: flex; gap: 16px; }
.crumb-nav a {
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 1px solid transparent;
  padding: 4px 0;
}
.crumb-nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--brand);
}
.top-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.search { position: relative; width: min(340px, 36vw); }
.search input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.search input::placeholder { color: var(--faint); }
.hits {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: min(440px, 80vw);
  max-height: 380px;
  overflow: auto;
  background: var(--raised);
  border: 1px solid var(--ink);
  z-index: 30;
}
.hit {
  display: block;
  width: 100%;
  text-align: left;
  text-decoration: none;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
}
.hit:hover, .hit:focus-visible { background: #fff; }
.hit b { display: block; font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.hit span { display: block; color: var(--muted); font-size: 13px; line-height: 1.4; }
.hits .empty { padding: 12px; color: var(--muted); font-size: 14px; }

.mode {
  display: flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  flex: 0 0 auto;
}
.mode button {
  height: 38px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.mode button + button { border-left: 1px solid var(--line); }
.mode button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--raised);
}

.wrap { width: min(1120px, calc(100% - 48px)); margin: 0 auto; padding: 28px 0 64px; }

.dash-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}
.kicker {
  margin: 0 0 6px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}
h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.lede { margin: 8px 0 0; max-width: 62ch; color: var(--muted); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius);
  border: 1px solid var(--ink);
  background: transparent;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.quiet { border-color: transparent; color: var(--muted); font-weight: 500; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.gloss {
  position: fixed;
  z-index: 40;
  width: min(360px, calc(100vw - 16px));
  padding: 12px;
  background: var(--raised);
  border: 1px solid var(--ink);
}
.gloss[hidden] { display: none; }
.gloss-term { margin: 0 0 8px; font-weight: 600; }
.gloss-body { margin: 8px 0 0; font-size: 14.5px; line-height: 1.6; }
.gloss .btn { height: 32px; }

.mark {
  margin-top: 12px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
}
.mark-error { margin: 10px 0 0; color: var(--bad); font-weight: 600; }
.mark-wait { margin: 10px 0 0; color: var(--muted); }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0 0 28px;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}
.metrics li { padding: 14px 16px 12px 0; }
.metrics li + li { padding-left: 16px; border-left: 1px solid var(--line); }
.metrics b {
  display: block;
  font-family: var(--num);
  font-size: 34px;
  font-weight: 520;
  line-height: 1;
  letter-spacing: -0.03em;
}
.metrics span { color: var(--muted); font-size: 13px; }

.section-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}
.ledger { border-top: 1px solid var(--line); }
.row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 92px;
  gap: 12px;
  align-items: center;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}
.row:hover { background: rgba(255, 255, 255, .45); }
.row .num {
  font-family: var(--num);
  font-size: 26px;
  font-weight: 520;
  letter-spacing: -0.03em;
  line-height: 1;
}
.row h2 { margin: 0; font-size: 16px; font-weight: 600; }
.row p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.mix { color: var(--muted); font-size: 13px; text-align: right; }
.prog { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 12px; color: var(--muted); }
.redo {
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand);
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.bar { width: 84px; height: 3px; background: var(--line); }
.bar i { display: block; height: 100%; background: var(--ok); width: 0; }

.day-head { margin-bottom: 18px; }
.trail { margin: 0 0 8px; color: var(--faint); font-size: 13px; }
.trail a { color: var(--muted); }
.day-title {
  display: flex;
  align-items: baseline;
  gap: 14px;
}
.day-title .num {
  font-family: var(--num);
  font-size: 32px;
  font-weight: 520;
  letter-spacing: -0.03em;
  color: var(--brand);
  line-height: 1;
}
.day-title h1 { font-size: 28px; }
.topic { margin: 4px 0 0; color: var(--muted); }
.day-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  font-size: 13px;
  color: var(--muted);
}
.chip[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--raised);
}
.view-count { margin-left: auto; color: var(--faint); font-size: 13px; }

.split {
  display: grid;
  grid-template-columns: 212px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.qside {
  position: sticky;
  top: calc(var(--top) + 12px);
}
.qnav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  max-height: calc(100vh - var(--top) - 128px);
  overflow: auto;
  align-content: start;
}
.qgroup {
  grid-column: 1 / -1;
  margin: 12px 0 0;
  font-size: 11px;
  color: var(--faint);
}
.qgroup:first-child { margin-top: 0; }
.origin {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}
.qsubmit { width: 100%; margin-top: 10px; }
.qscore { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.qnav button {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  font-size: 12px;
  font-weight: 400;
}
.qnav button.is-done {
  font-weight: 700;
}
.qnav button[aria-current="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--raised);
}
.qnav button.is-correct { border-bottom: 2px solid var(--ok); }
.qnav button.is-wrong { border-bottom: 2px solid var(--bad); }
.qnav button.is-open { border-bottom: 2px solid var(--info); }
.legend {
  grid-column: 1 / -1;
  margin-top: 8px;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.4;
}

.sheet {
  scroll-margin-top: calc(var(--top) + 12px);
  background: var(--raised);
  border: 1px solid var(--line);
  border-left: 3px solid var(--margin);
  padding: 26px 32px 28px 28px;
  min-height: 520px;
}
.q-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: baseline;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
}
.q-meta .id { font-weight: 600; color: var(--ink); letter-spacing: .02em; }
.tag.hard { color: var(--brand); font-weight: 600; }
.q-pos { margin-left: auto; }
.figure {
  width: fit-content;
  max-width: 100%;
  margin: 0 0 16px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 8px;
}
.figure img { display: block; max-height: 380px; margin: 0 auto; object-fit: contain; }
.figure figcaption { margin-top: 6px; color: var(--faint); font-size: 12px; }
.prompt {
  margin: 0 0 18px;
  font-size: 17px;
  line-height: 1.65;
  max-width: 68ch;
}
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  width: 100%;
  text-align: left;
  padding: 12px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  line-height: 1.5;
  cursor: pointer;
  user-select: text;
  -webkit-user-select: text;
}
.prompt, .reveal, .why, .why-body, .mark, .essay, .origin {
  user-select: text;
  -webkit-user-select: text;
}
.choice kbd {
  font-family: var(--num);
  font-size: 18px;
  font-weight: 520;
  line-height: 1.3;
}
.choice[aria-checked="true"] { border-color: var(--ink); background: #fff; }
.choice.is-correct { border-color: var(--ok); background: var(--ok-bg); }
.choice.is-wrong { border-color: var(--bad); background: var(--bad-bg); }
.choice:disabled { cursor: default; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.reveal { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); max-width: 68ch; }
.verdict { margin: 0 0 14px; font-weight: 600; }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--bad); }
.reveal h2 { margin: 16px 0 6px; font-size: 15px; font-weight: 600; }
.reveal p { margin: 0 0 8px; }
.why-label { margin: 0 0 8px; font-size: 13px; font-weight: 600; }
.why-body { margin: 0; font-size: 15.5px; line-height: 1.75; }
.why-opts { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.why-opts li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 10px; align-items: start; }
.why-opts span { font-family: var(--num); font-size: 16px; line-height: 1.5; color: var(--muted); }
.why-opts p { margin: 0; font-size: 14.5px; line-height: 1.6; color: var(--muted); }
.slide-src { margin: 14px 0 0; color: var(--faint); font-size: 13px; }
.essay {
  width: 100%;
  min-height: 140px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  resize: vertical;
  line-height: 1.55;
}
.keys { margin: 18px 0 0; color: var(--faint); font-size: 12px; }

.exam-bar {
  position: sticky;
  bottom: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding: 12px 16px;
  background: var(--ink);
  color: var(--raised);
}
.exam-bar p { margin: 0; font-size: 14px; }
.exam-bar .btn.primary { background: var(--raised); border-color: var(--raised); color: var(--ink); }

.pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.pager a { text-decoration: none; font-size: 14px; }
.pager small { display: block; color: var(--faint); font-size: 12px; }
.empty-filter { padding: 28px 8px; color: var(--muted); }

@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px 12px; }
  .crumb-nav { margin-left: auto; }
  .top-tools { flex: 1 0 100%; width: 100%; margin-left: 0; flex-wrap: wrap; }
  .search { flex: 1 1 100%; width: 100%; }
  .mode { width: 100%; }
  .mode button { flex: 1; }
  .hits { width: 100%; }
  .sheet { min-height: 0; }
  .exam-bar { position: static; }
  .wrap { width: min(1120px, calc(100% - 28px)); }
  .dash-head { flex-direction: column; align-items: flex-start; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metrics li:nth-child(odd) { padding-left: 0; border-left: 0; }
  .metrics li:nth-child(3),
  .metrics li:nth-child(4) { border-top: 1px solid var(--line); }
  .row { grid-template-columns: 48px minmax(0, 1fr); }
  .prog { grid-column: 2; text-align: left; align-items: flex-start; }
  .split { grid-template-columns: 1fr; }
  .qside { position: static; }
  .qnav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
    max-height: none;
  }
  .qnav.is-summary {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    max-height: 280px;
    overflow: auto;
  }
  .qnav button { flex: 0 0 36px; }
  .qnav.is-summary button { flex: none; }
  .legend { display: none; }
  .sheet { padding: 18px 16px 20px; }
  h1, .day-title h1 { font-size: 26px; }
  .view-count { margin-left: 0; width: 100%; }
}

.site-foot {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}
.foot-inner {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
  padding: 18px 0 28px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.site-foot a { color: var(--ink); text-decoration: none; }
.site-foot nav { display: flex; gap: 16px; }
.guide { max-width: 68ch; }
.guide h2 { margin: 28px 0 8px; font-size: 18px; }
.guide ul { margin: 8px 0 0; padding-left: 18px; }
.guide li { margin: 6px 0; }
.guide .guide-days { list-style: none; padding: 0; margin-top: 12px; border-top: 1px solid var(--line); }
.guide-days a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}

@media (max-width: 860px) {
  .foot-inner { width: min(1120px, calc(100% - 28px)); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
