:root {
  --ink: #18201f;
  --muted: #68706e;
  --paper: #f4f5f0;
  --panel: #ffffff;
  --line: #d9ded8;
  --green: #176d5b;
  --green-dark: #0d493e;
  --yellow: #eab84b;
  --red: #b74f48;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: Arial, Helvetica, sans-serif; line-height: 1.5; }
button, input, select { font: inherit; }
button, select, label { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.app-header { position: sticky; z-index: 10; top: 0; display: flex; align-items: center; justify-content: space-between; min-height: 70px; padding: 10px clamp(20px, 5vw, 72px); background: rgba(244,245,240,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); }
.brand { display: inline-flex; gap: 11px; align-items: center; color: inherit; text-decoration: none; }
.brand-mark, .mini-mark { display: grid; place-items: center; flex: 0 0 auto; width: 40px; height: 40px; color: white; background: var(--green); border-radius: 7px; font-size: .74rem; font-weight: 800; }
.brand > span:last-child { display: flex; flex-direction: column; }
.brand strong { font-size: .95rem; }
.brand small { color: var(--muted); font-size: .65rem; font-weight: 700; text-transform: uppercase; }
nav { display: flex; align-items: center; gap: 8px; }
.nav-link { padding: 8px 11px; color: var(--muted); background: none; border: 0; font-weight: 700; text-decoration: none; cursor: pointer; }
.nav-link:hover, .nav-link.is-active { color: var(--green-dark); }

.setup-view { width: min(1160px, calc(100% - 40px)); margin: 0 auto; padding: 58px 0 72px; }
.setup-heading { max-width: 720px; margin-bottom: 38px; }
.eyebrow { margin: 0 0 10px; color: var(--green); font-size: .72rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1, h2 { font-family: "Source Serif 4", Georgia, serif; }
.setup-heading h1 { margin: 0; font-size: clamp(2.25rem, 5vw, 4.5rem); line-height: 1; letter-spacing: 0; }
.setup-heading > p:last-child { max-width: 620px; margin: 18px 0 0; color: var(--muted); font-size: 1.04rem; }
.setup-layout { max-width: 760px; }
.practice-builder { min-width: 0; }
fieldset { margin: 0 0 34px; padding: 0; border: 0; }
legend { width: 100%; margin-bottom: 15px; font-size: 1rem; font-weight: 800; }
legend > span { display: inline-grid; place-items: center; width: 25px; height: 25px; margin-right: 8px; color: white; background: var(--green); border-radius: 50%; font-size: .72rem; }
.choice-grid { display: grid; gap: 10px; }
.division-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice-card, .type-card { position: relative; display: flex; align-items: center; min-height: 78px; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 7px; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.choice-card:has(input:checked), .type-card:has(input:checked) { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.choice-card input, .type-card input { position: absolute; opacity: 0; pointer-events: none; }
.choice-copy, .type-card > span:nth-child(3) { display: flex; flex-direction: column; min-width: 0; }
.choice-copy small, .type-card small { margin-top: 3px; color: var(--muted); font-size: .78rem; }
.choice-check, .box-check { display: none; place-items: center; margin-left: auto; width: 22px; height: 22px; color: white; background: var(--green); border-radius: 50%; font-size: .72rem; font-weight: 800; }
input:checked ~ .choice-check, input:checked ~ .box-check { display: grid; }
.choice-card.is-unavailable { color: #7b817f; background: #eceeea; cursor: not-allowed; }
.coming-soon { margin-left: auto; padding: 4px 7px; color: #6e736f; background: #dfe2dd; border-radius: 4px; font-size: .64rem; font-weight: 800; text-transform: uppercase; }
.select-label { display: block; margin-bottom: 6px; color: var(--muted); font-size: .75rem; font-weight: 700; }
.select-wrap { position: relative; }
.select-wrap select { width: 100%; height: 50px; padding: 0 45px 0 14px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; font-weight: 700; appearance: none; }
.select-wrap > span { position: absolute; right: 16px; top: 11px; pointer-events: none; }
.event-note { display: flex; gap: 13px; margin-top: 11px; padding: 13px 15px; color: var(--green-dark); background: #e7f0eb; border-left: 3px solid var(--green); }
.event-note p { margin: 2px 0 0; color: #52645f; font-size: .78rem; }
.bolt { font-size: 1.3rem; font-weight: 800; }
.field-hint { margin: -11px 0 12px 34px; color: var(--muted); font-size: .75rem; }
.type-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.loading-copy { color: var(--muted); font-size: .78rem; }
.category-counts { display: grid; gap: 10px; }
.category-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 13px; align-items: center; min-height: 72px; padding: 13px 15px; background: white; border: 1px solid var(--line); border-radius: 6px; }
.category-row > span:nth-child(2) { display: flex; flex-direction: column; }
.category-row strong { font-size: .82rem; }
.category-row small { color: var(--muted); font-size: .7rem; }
.topic-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.topic-chip { position: relative; cursor: pointer; }
.topic-chip input { position: absolute; opacity: 0; }
.topic-chip span { display: inline-flex; align-items: center; min-height: 38px; padding: 0 12px; color: var(--muted); background: white; border: 1px solid var(--line); border-radius: 5px; font-size: .75rem; font-weight: 700; }
.topic-chip input:checked + span { color: var(--green-dark); background: #e7f0eb; border-color: var(--green); }
.type-card { gap: 11px; min-height: 96px; padding: 13px; }
.type-icon { display: grid; place-items: center; flex: 0 0 auto; width: 31px; height: 31px; color: var(--green-dark); background: #e7f0eb; border-radius: 5px; font-weight: 800; }
.type-card strong { font-size: .8rem; }
.type-card small { font-size: .68rem; }
.type-card .box-check { position: absolute; top: 7px; right: 7px; width: 17px; height: 17px; border-radius: 4px; }
.form-error, .answer-error { min-height: 20px; margin: 7px 0 0; color: var(--red); font-size: .78rem; font-weight: 700; }
.session-options { border-top: 1px solid var(--line); padding-top: 25px; }
.option-row, .toggle-row { display: flex; align-items: center; justify-content: space-between; min-height: 54px; border-bottom: 1px solid var(--line); }
.option-row label, .toggle-row strong { font-size: .85rem; }
.toggle-row > span:first-child { display: flex; flex-direction: column; }
.toggle-row small { color: var(--muted); font-size: .7rem; }
.stepper { display: flex; height: 34px; overflow: hidden; background: white; border: 1px solid var(--line); border-radius: 5px; }
.stepper button { width: 34px; border: 0; background: white; cursor: pointer; }
.stepper input { width: 38px; padding: 0; text-align: center; border: 0; border-inline: 1px solid var(--line); appearance: textfield; }
.stepper input::-webkit-inner-spin-button { appearance: none; }
.toggle-row { position: relative; cursor: pointer; }
.toggle-row input { position: absolute; opacity: 0; }
.toggle { position: relative; width: 40px; height: 23px; background: #aeb6b2; border-radius: 20px; transition: background .15s; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; background: white; border-radius: 50%; transition: transform .15s; }
.toggle-row input:checked + .toggle { background: var(--green); }
.toggle-row input:checked + .toggle::after { transform: translateX(17px); }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; gap: 12px; min-height: 48px; padding: 0 20px; border-radius: 6px; font-weight: 800; cursor: pointer; }
.primary-button { color: white; background: var(--green-dark); border: 1px solid var(--green-dark); }
.primary-button:hover { background: var(--green); }
.practice-builder > .primary-button { width: 100%; }
.secondary-button { color: var(--green-dark); background: white; border: 1px solid var(--line); }


.quiz-view { min-height: 100vh; background: #eef1ec; }
.quiz-view .quiz-toolbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 74px; padding: 10px clamp(18px, 4vw, 60px); background: white; }
.icon-button { width: 36px; height: 36px; padding: 0; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 5px; font-size: 1.4rem; cursor: pointer; }
.quiz-identity { display: flex; align-items: center; gap: 10px; }
.mini-mark { width: 35px; height: 35px; }
.quiz-identity div { display: flex; flex-direction: column; }
.quiz-identity small { color: var(--muted); font-size: .65rem; }
.quiz-meta { display: flex; justify-content: flex-end; gap: 20px; color: var(--muted); font-size: .75rem; font-weight: 700; }
.timer { min-width: 45px; color: var(--green-dark); font-variant-numeric: tabular-nums; }
.progress-track { height: 4px; background: #d9dfda; }
.progress-track span { display: block; height: 100%; background: var(--yellow); transition: width .25s; }
.question-panel { width: min(760px, calc(100% - 36px)); margin: 58px auto; padding: clamp(25px, 5vw, 52px); background: white; border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 18px 55px rgba(24,32,31,.08); }
.question-topline { display: flex; justify-content: space-between; color: var(--green); font-size: .67rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.question-history-nav { min-height: 38px; margin-top: 12px; }
.question-history-nav .secondary-button { min-height: 36px; padding: 0 12px; font-size: .78rem; }
.question-panel h2 { margin: 20px 0 26px; font-family: Arial, Helvetica, sans-serif; font-size: 1.08rem; font-weight: 400; line-height: 1.55; }
sup, sub { font-size: .7em; line-height: 0; }
.answer-options { display: grid; gap: 10px; }
.answer-option { position: relative; display: flex; gap: 12px; align-items: center; min-height: 52px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 5px; cursor: pointer; }
.answer-option:has(input:checked) { border-color: var(--green); background: #f0f6f2; }
.answer-option input { position: absolute; opacity: 0; }
.option-letter { display: grid; place-items: center; width: 27px; height: 27px; background: #edf0ec; border-radius: 4px; font-size: .72rem; font-weight: 800; }
.text-answer { width: 100%; min-height: 50px; padding: 12px 14px; color: var(--ink); background: #fbfcfa; border: 1px solid var(--line); border-radius: 5px; outline: 0; }
.text-answer:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,109,91,.1); }
.answer-button { margin-top: 8px; }
.feedback { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--line); }
.feedback-heading { display: flex; gap: 9px; align-items: center; }
.feedback-heading span { display: grid; place-items: center; width: 25px; height: 25px; color: white; background: var(--green); border-radius: 50%; font-weight: 800; }
.feedback.is-wrong .feedback-heading span { background: var(--red); }
.feedback p { color: var(--muted); }
.feedback .submitted-answer { margin-bottom: -6px; color: var(--ink); font-size: .82rem; font-weight: 700; }

.results-view { display: grid; place-items: center; min-height: calc(100vh - 70px); padding: 40px 18px; }
.results-panel { width: min(650px, 100%); text-align: center; }
.score-ring { display: grid; place-items: center; width: 140px; height: 140px; margin: 10px auto 26px; background: conic-gradient(var(--green) var(--score), #dce2dd 0); border-radius: 50%; }
.score-ring::before { content: ""; grid-area: 1/1; width: 108px; height: 108px; background: var(--paper); border-radius: 50%; }
.score-ring span { z-index: 1; grid-area: 1/1; font-family: "Source Serif 4", Georgia, serif; font-size: 2rem; font-weight: 700; }
.results-panel h1 { margin: 0; font-size: clamp(2.1rem, 6vw, 3.8rem); }
.results-panel > p:not(.eyebrow) { color: var(--muted); }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 34px 0; border-block: 1px solid var(--line); }
.result-stats div { display: flex; flex-direction: column; padding: 17px 8px; }
.result-stats div + div { border-left: 1px solid var(--line); }
.result-stats strong { font-size: 1.05rem; }.result-stats span { color: var(--muted); font-size: .7rem; }
.results-actions { display: flex; justify-content: center; gap: 10px; }

@media (max-width: 820px) {
  .type-grid { grid-template-columns: 1fr; }
  .type-card { min-height: 70px; }
}

@media (max-width: 560px) {
  .app-header { min-height: 62px; padding-inline: 14px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand small { display: none; }
  .nav-link { padding: 7px; font-size: .78rem; }
  .setup-view { width: min(100% - 28px, 1160px); padding-top: 36px; }
  .division-grid { grid-template-columns: 1fr; }
  .quiz-view .quiz-toolbar { grid-template-columns: auto 1fr auto; gap: 10px; padding-inline: 12px; }
  .quiz-identity { justify-self: center; }.quiz-meta > span:first-child { display: none; }
  .question-panel { margin-block: 25px; padding: 24px 18px; }
  .category-row { grid-template-columns: auto 1fr; }
  .category-row .stepper { grid-column: 1 / -1; justify-self: end; }
  .result-stats strong { font-size: .88rem; }
  .results-actions { flex-direction: column; }
}
