:root {
  color-scheme: light;
  --green: #006b57;
  --green-dark: #073d32;
  --green-deep: #004f41;
  --mint: #ddece5;
  --paper: #f7f4ec;
  --surface: #fbf9f3;
  --white: #fffefa;
  --sand: #efe3be;
  --gold: #b89a43;
  --ink: #18231f;
  --muted: #5e6864;
  --line: #d7d4c9;
  --line-strong: #b8c2bd;
  --incorrect: #93443e;
  --incorrect-bg: #f6e9e5;
  --focus: #0c6555;
  --radius: 16px;
  --shadow: 0 1px 2px rgb(24 39 35 / 6%);
  --content: 780px;
  font-family: Inter, "Inter Tight", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background: var(--paper);
  font-size: 16px;
  line-height: 1.62;
}

button, input { font: inherit; }

button { touch-action: manipulation; }

button, label { -webkit-tap-highlight-color: transparent; }

.skip-link {
  position: fixed;
  z-index: 20;
  top: 8px;
  left: 8px;
  transform: translateY(-160%);
  padding: 10px 14px;
  border-radius: 8px;
  color: white;
  background: var(--green-dark);
}

.skip-link:focus { transform: none; }

.site-header {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(100% - 32px, 1060px);
  min-height: 72px;
  margin: 0 auto;
  border-bottom: 1px solid rgb(0 107 87 / 55%);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--green-deep);
  font-size: 1.25rem;
  font-weight: 780;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-mark { width: 25px; height: 29px; }

.header-context {
  max-width: 48%;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

main { min-height: calc(100dvh - 72px); }

.page {
  width: min(100% - 32px, var(--content));
  margin: 0 auto;
  padding: 32px 0 max(48px, env(safe-area-inset-bottom));
}

.start-page { --content: 1060px; }

h1, h2, h3, p { margin-top: 0; }

h1, h2, h3 {
  line-height: 1.16;
  letter-spacing: -0.018em;
}

h1 { margin-bottom: 16px; font-size: clamp(2.2rem, 7vw, 4rem); }
h2 { margin-bottom: 12px; font-size: clamp(1.65rem, 6vw, 2.5rem); }
h3 { margin-bottom: 6px; font-size: 1.08rem; }

.eyebrow {
  margin-bottom: 10px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 780;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.muted { color: var(--muted); }

.intro-grid { display: grid; gap: 32px; }

.hero {
  position: relative;
  overflow: hidden;
  padding: 34px 24px 38px;
  border: 1px solid var(--line);
  border-radius: 2px 2px var(--radius) var(--radius);
  background: var(--surface);
}

.hero::before,
.hero::after {
  position: absolute;
  z-index: 0;
  right: -60px;
  content: "";
  transform: rotate(38deg);
}

.hero::before { top: -82px; width: 150px; height: 210px; background: var(--green); }
.hero::after { right: -88px; bottom: -104px; width: 170px; height: 225px; background: #8b9143; }
.hero > * { position: relative; z-index: 1; }

.hero h1 { max-width: min(720px, 78%); letter-spacing: -0.024em; }
.hero h1 span { display: block; color: var(--green); font-size: 0.42em; line-height: 1.1; }

.pack-pill {
  display: inline-flex;
  margin: 4px 0 28px;
  padding: 10px 16px;
  border-radius: 999px;
  color: white;
  background: var(--green);
  font-weight: 750;
}

.hero-rule { width: 92px; height: 4px; margin: 0 0 22px; background: var(--gold); }

.descriptor { margin: 0; font-size: 1.02rem; line-height: 1.65; white-space: pre-line; }
.descriptor strong { font-weight: 760; }

.how-it-works,
.setup-card,
.question-card,
.explanation-card,
.score-card,
.guidance-card,
.topic-summary,
.review-summary {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.history-summary {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.history-summary h2 { margin: 0; font-size: 1.35rem; }
.history-summary p { margin: 0; color: var(--muted); font-size: 0.88rem; }
.history-score { display: flex; align-items: baseline; gap: 10px; color: var(--green); }
.history-score strong { font-size: 1.65rem; }
.history-score span { font-weight: 800; }

.how-it-works { padding: 24px; }
.how-list { display: grid; gap: 10px; margin: 20px 0 0; padding: 0; list-style: none; }
.how-list li { display: grid; grid-template-columns: 42px 1fr; gap: 12px; align-items: center; padding: 14px; border-radius: 12px; background: #f2efe7; }
.step-number { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 50%; color: white; background: var(--green); font-weight: 800; }
.how-list strong { display: block; }
.how-list span:last-child { color: var(--muted); font-size: 0.9rem; }

.setup-card { padding: 24px; }
.section-rule { height: 1px; margin: 18px 0 22px; background: var(--green); opacity: 0.72; }

fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { margin-bottom: 12px; font-weight: 760; }

.segment-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.segment input, .count-pills input, .topic-grid input, .answer-option input { position: absolute; opacity: 0; pointer-events: none; }
.segment label, .count-pills label {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--green-dark);
  background: var(--white);
  cursor: pointer;
  font-weight: 700;
  text-align: center;
}
.segment input:checked + label, .count-pills input:checked + label { border-color: var(--green); color: white; background: var(--green); }
.segment input:focus-visible + label, .count-pills input:focus-visible + label, .topic-grid input:focus-visible + label, .answer-option input:focus-visible + label { outline: 3px solid rgb(12 101 85 / 32%); outline-offset: 2px; }

.count-pills { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.count-pills label { min-width: 0; }

.setup-section { margin-top: 22px; }
.topic-grid { display: grid; gap: 8px; }
.topic-grid label {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  cursor: pointer;
}
.topic-grid label::before { width: 18px; height: 18px; flex: 0 0 auto; border: 1px solid var(--line-strong); border-radius: 4px; content: ""; }
.topic-grid input:checked + label { border-color: var(--green); background: var(--mint); }
.topic-grid input:checked + label::before { border-color: var(--green); background: var(--green); box-shadow: inset 0 0 0 4px var(--mint); }

.button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 760;
  text-decoration: none;
}
.button:focus-visible, .text-button:focus-visible { outline: 3px solid rgb(12 101 85 / 35%); outline-offset: 3px; }
.button-primary { color: white; background: var(--green); }
.button-primary:hover { background: var(--green-deep); }
.button-secondary { border-color: var(--green); color: var(--green); background: transparent; }
.button-quiet { border-color: var(--line); color: var(--ink); background: var(--white); }
.button-danger { border-color: #bd8f89; color: #742e2a; background: var(--incorrect-bg); }
.button[disabled] { cursor: not-allowed; opacity: 0.45; }
.button-wide { width: 100%; }

.start-actions { display: grid; gap: 10px; margin-top: 24px; }
.save-note { margin: 12px 0 0; color: var(--muted); font-size: 0.8rem; }
.disclaimer { margin: 18px 0 0; color: var(--muted); font-size: 0.78rem; line-height: 1.45; }
.review-statement { margin: 14px 0 0; color: var(--green-dark); font-size: 0.78rem; font-weight: 700; }

.restore-banner {
  display: grid;
  gap: 14px;
  margin-bottom: 20px;
  padding: 16px;
  border: 1px solid var(--gold);
  border-radius: 12px;
  background: var(--sand);
}
.restore-banner p { margin: 0; }
.restore-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.progress-shell { margin-bottom: 20px; }
.progress-line { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.progress-line strong { font-size: 0.98rem; }
.progress-line span { color: var(--muted); font-size: 0.82rem; }
.progress-track { overflow: hidden; height: 7px; border-radius: 999px; background: #deddd4; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--green); transition: width 180ms ease-out; }
.save-status { display: flex; align-items: center; justify-content: flex-end; gap: 7px; margin: 8px 0 0; color: var(--muted); font-size: 0.76rem; }
.save-status span { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }

.question-card { padding: 20px; }
.question-meta { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.question-number { display: grid; width: 44px; height: 44px; place-items: center; border-radius: 10px; color: white; background: var(--green); font-weight: 800; }
.topic-pill { overflow: hidden; padding: 7px 12px; border-radius: 999px; color: var(--green-deep); background: var(--mint); font-size: 0.76rem; font-weight: 760; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.difficulty { color: #776224; font-size: 0.78rem; font-weight: 760; }
.question-text { max-width: 68ch; margin: 26px 0 22px; font-size: clamp(1.18rem, 4.2vw, 1.5rem); font-weight: 720; line-height: 1.48; letter-spacing: -0.006em; }

.answers { display: grid; gap: 10px; }
.answer-option label {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 12px;
  min-height: 56px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--white);
  cursor: pointer;
  transition: border-color 120ms ease-out, background-color 120ms ease-out;
}
.answer-key { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid var(--line-strong); border-radius: 8px; background: white; font-size: 0.82rem; font-weight: 800; }
.answer-copy { min-width: 0; overflow-wrap: anywhere; line-height: 1.55; letter-spacing: 0.002em; }
.answer-state { display: block; margin-top: 2px; color: var(--muted); font-size: 0.76rem; font-weight: 760; }
.answer-option input:checked + label { border: 2px solid var(--green); padding: 11px 13px; background: var(--mint); }
.answer-option input:checked + label .answer-key { border-color: var(--green); color: white; background: var(--green); }
.answer-option.is-correct label { border: 2px solid var(--green); padding: 11px 13px; background: #e4f0ea; }
.answer-option.is-correct .answer-key { border-color: var(--green); color: white; background: var(--green); }
.answer-option.is-incorrect label { border: 2px solid var(--incorrect); padding: 11px 13px; background: var(--incorrect-bg); }
.answer-option.is-incorrect .answer-key { border-color: var(--incorrect); color: white; background: var(--incorrect); }
.answer-option input:disabled + label { cursor: default; }

.action-bar {
  position: sticky;
  z-index: 4;
  bottom: 0;
  display: grid;
  gap: 10px;
  margin: 18px -16px 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid rgb(215 212 201 / 85%);
  background: rgb(247 244 236 / 96%);
}
.navigation-actions { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; }
.text-button { min-height: 44px; padding: 8px 10px; border: 0; color: var(--green); background: transparent; cursor: pointer; font-weight: 700; }
.session-utilities { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; margin-top: 10px; }
.session-utilities .text-button { color: var(--muted); font-size: 0.86rem; }

.feedback-heading { display: flex; align-items: center; gap: 10px; margin: 22px 0 12px; color: var(--green-dark); }
.feedback-heading.incorrect { color: var(--incorrect); }
.feedback-icon { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 50%; color: white; background: currentColor; }
.feedback-icon span { color: white; font-weight: 800; line-height: 1; }

.explanation-card { margin-top: 14px; padding: 20px; }
.explanation-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.answer-label { color: var(--green-dark); font-size: 1.1rem; font-weight: 800; }
.explanation-card p:last-child { margin-bottom: 0; }

.results-heading { margin-bottom: 24px; }
.results-grid { display: grid; gap: 14px; }
.score-card { overflow: hidden; }
.score-card h2 { margin: 0; padding: 16px 20px; color: white; background: var(--green); font-size: 1.25rem; letter-spacing: -0.02em; }
.score-body { display: grid; gap: 12px; padding: 20px; }
.score-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; color: var(--muted); }
.score-row strong { color: var(--ink); font-size: 1.35rem; }
.score-row.primary strong { color: var(--green); font-size: 2rem; }
.guidance-card { padding: 20px; border-color: var(--gold); background: var(--sand); }
.guidance-card h3 { margin-bottom: 12px; font-size: 1.2rem; }
.guidance-result { margin-bottom: 10px; color: var(--green-dark); font-size: 1.08rem; font-weight: 800; }
.guidance-card .disclaimer { padding-top: 12px; border-top: 1px solid rgb(184 154 67 / 55%); color: #67572e; }

.weakest-card,
.comparison-card {
  display: grid;
  gap: 20px;
  padding: 22px;
  border: 1px solid var(--green);
  border-radius: var(--radius);
  background: var(--surface);
}
.weakest-card { border-left-width: 5px; }
.weakest-card h2 { margin-bottom: 8px; color: var(--green-dark); }
.weakest-reason { margin-bottom: 8px; font-size: 1.02rem; }
.comparison-card { border-color: var(--line); }
.comparison-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.comparison-grid > div { display: flex; min-width: 0; flex-direction: column; padding: 14px 10px; border-radius: 10px; background: #f1eee5; text-align: center; }
.comparison-grid span { color: var(--muted); font-size: 0.76rem; }
.comparison-grid strong { color: var(--green-dark); font-size: 1.3rem; }
.comparison-grid small { color: var(--muted); font-size: 0.72rem; }
.comparison-grid .improvement { background: var(--mint); }

.results-section { margin-top: 24px; }
.topic-summary, .review-summary { padding: 20px; }
.topic-row { display: grid; gap: 8px; padding: 14px 0; border-top: 1px solid var(--line); }
.topic-row:first-of-type { border-top: 0; }
.topic-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.topic-line strong { overflow-wrap: anywhere; }
.topic-line span { flex: 0 0 auto; color: var(--muted); font-size: 0.82rem; }
.topic-status { color: var(--green-dark); font-size: 0.82rem; font-weight: 800; }
.topic-detail { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 0.8rem; }
.topic-bar { height: 7px; overflow: hidden; border-radius: 999px; background: #e0ded4; }
.topic-bar span { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.topic-row.priority .topic-bar span { background: var(--gold); }
.topic-row.priority .topic-status { color: #75601e; }

.review-buttons, .result-actions { display: grid; gap: 10px; margin-top: 16px; }
.empty-note { margin: 0; color: var(--muted); }
.results-footer { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--green); }

.review-answer-grid { display: grid; gap: 10px; }
.review-answer { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
.review-answer.incorrect { border-color: #bd8f89; background: var(--incorrect-bg); }
.review-answer.correct { border-color: var(--green); background: #e4f0ea; }
.review-label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 0.78rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.review-answer strong { display: inline-grid; width: 34px; height: 34px; place-items: center; margin-right: 8px; border-radius: 8px; color: white; background: var(--green-dark); }
.review-answer.incorrect strong { background: var(--incorrect); }
.review-answer p { display: inline; margin: 0; }
.review-navigation { display: grid; gap: 10px; margin-top: 18px; }

.confirm-dialog { width: min(calc(100% - 32px), 470px); padding: 0; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: var(--surface); box-shadow: 0 16px 50px rgb(7 61 50 / 20%); }
.confirm-dialog::backdrop { background: rgb(7 61 50 / 42%); }
.confirm-dialog form { padding: 24px; }
.dialog-actions { display: grid; gap: 10px; margin-top: 22px; }

.announcer { position: fixed; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

@media (min-width: 600px) {
  .site-header, .page { width: min(100% - 64px, var(--content)); }
  .page { padding-top: 44px; }
  .hero, .how-it-works, .setup-card, .question-card, .explanation-card, .score-card, .guidance-card, .topic-summary, .review-summary { padding-left: 28px; padding-right: 28px; }
  .segment-grid { grid-template-columns: repeat(3, 1fr); }
  .topic-grid { grid-template-columns: repeat(2, 1fr); }
  .start-actions, .dialog-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .action-bar { grid-template-columns: minmax(0, 1fr) minmax(360px, auto); align-items: center; margin-right: 0; margin-left: 0; padding-right: 0; padding-left: 0; border-top: 0; }
  .action-bar > .text-button { grid-column: 1; grid-row: 1; justify-self: start; }
  .navigation-actions { grid-column: 2; grid-row: 1; }
  .results-grid { grid-template-columns: 1fr 1fr; }
  .review-buttons, .result-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .weakest-card { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .review-answer-grid, .review-navigation { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 900px) {
  .site-header { min-height: 84px; }
  main { min-height: calc(100dvh - 84px); }
  .intro-grid { grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr); align-items: start; }
  .hero { min-height: 550px; display: flex; flex-direction: column; justify-content: center; padding: 54px; }
  .how-it-works { grid-column: 1; padding: 32px; }
  .setup-card { grid-column: 2; grid-row: 1 / span 2; position: sticky; top: 24px; padding: 32px; }
  .question-card { padding: 30px; }
  .explanation-card { padding: 26px 30px; }
  .history-summary { grid-template-columns: minmax(0, 1fr) auto; align-items: center; padding: 24px 28px; }
  .history-summary p { grid-column: 1 / -1; }
}

@media (max-width: 359px) {
  .site-header, .page { width: min(100% - 24px, var(--content)); }
  .site-header { min-height: 64px; }
  .brand { font-size: 1.08rem; }
  .brand-mark { width: 22px; height: 25px; }
  .header-context { font-size: 0.72rem; }
  .page { padding-top: 24px; }
  .hero, .how-it-works, .setup-card, .question-card, .explanation-card, .topic-summary, .review-summary { padding-right: 16px; padding-left: 16px; }
  .count-pills { grid-template-columns: repeat(2, 1fr); }
  .question-meta { grid-template-columns: auto minmax(0, 1fr); }
  .difficulty { grid-column: 2; justify-self: end; margin-top: -6px; }
  .topic-pill { white-space: normal; }
  .comparison-grid { grid-template-columns: 1fr; }
  .topic-detail { align-items: flex-start; flex-direction: column; gap: 2px; }
  .hero h1 { max-width: 100%; padding-right: 36px; }
  .navigation-actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; }
}
