:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --panel: #ffffff;
  --panel-soft: #f1f5f4;
  --text: #18211f;
  --muted: #5d6b66;
  --border: #ccd6d2;
  --accent: #236b5a;
  --accent-strong: #174d40;
  --accent-soft: #dcece7;
  --good: #24754d;
  --good-soft: #e1f3e9;
  --warn: #a05a16;
  --warn-soft: #fff1dc;
  --bad: #a33d3d;
  --bad-soft: #f9e5e5;
  --shadow: 0 16px 38px rgb(24 33 31 / 0.1);
  --radius: 8px;
  --focus: #d48723;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121715;
  --panel: #1a211f;
  --panel-soft: #202b28;
  --text: #f2f4f0;
  --muted: #b7c3bd;
  --border: #34423d;
  --accent: #7cc7b0;
  --accent-strong: #a9decd;
  --accent-soft: #203a34;
  --good: #86d4a7;
  --good-soft: #183427;
  --warn: #f2bd70;
  --warn-soft: #3a2a18;
  --bad: #f0a0a0;
  --bad-soft: #3a2020;
  --shadow: 0 18px 42px rgb(0 0 0 / 0.28);
  --focus: #f0bd64;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgb(255 255 255 / 0.44), rgb(255 255 255 / 0) 260px),
    var(--bg);
  font-size: 16px;
  line-height: 1.5;
}

button,
select {
  font: inherit;
}

button {
  min-height: 44px;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 20;
  padding: 10px 14px;
  color: var(--text);
  background: var(--panel);
  border: 2px solid var(--focus);
  border-radius: var(--radius);
  transform: translateY(-140%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  width: min(100%, 980px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 16px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
}

h2 {
  margin: 0 0 10px;
  font-size: 21px;
  line-height: 1.3;
}

h3 {
  margin: 0 0 8px;
  font-size: 17px;
  line-height: 1.3;
}

p {
  margin: 0;
}

.main-card {
  min-height: calc(100vh - 102px);
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.icon-button,
.button,
.choice-button,
.path-button,
.segmented button {
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.icon-button {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  font-size: 22px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 14px;
  font-weight: 750;
  text-decoration: none;
}

.button.primary {
  color: #fff;
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

[data-theme="dark"] .button.primary {
  color: #10201b;
  background: var(--accent-strong);
}

.button.ghost {
  background: transparent;
}

.button:disabled,
.choice-button:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

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

.intro {
  display: grid;
  gap: 18px;
}

.intro-copy {
  color: var(--muted);
  max-width: 62ch;
}

.path-grid {
  display: grid;
  gap: 12px;
}

.path-button {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 92px;
  padding: 16px;
  text-align: left;
}

.path-button strong {
  font-size: 18px;
}

.path-button span {
  color: var(--muted);
}

.setup-grid {
  display: grid;
  gap: 14px;
  padding: 14px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.field label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.segmented button {
  padding: 10px 8px;
  font-weight: 800;
}

.segmented button[aria-pressed="true"] {
  color: #fff;
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

[data-theme="dark"] .segmented button[aria-pressed="true"] {
  color: #10201b;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 10px;
  color: var(--muted);
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 750;
}

.progress-shell {
  overflow: hidden;
  height: 10px;
  margin: 12px 0 20px;
  background: var(--panel-soft);
  border-radius: 999px;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 160ms ease;
}

.question-text {
  margin-bottom: 16px;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.35;
}

.choices {
  display: grid;
  gap: 10px;
}

.choice-button {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 12px;
  text-align: left;
}

.choice-letter {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-weight: 900;
}

.choice-button.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.choice-button.correct {
  background: var(--good-soft);
  border-color: var(--good);
}

.choice-button.wrong {
  background: var(--bad-soft);
  border-color: var(--bad);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.feedback-card,
.lesson-card,
.summary-card {
  display: grid;
  gap: 14px;
}

.status {
  padding: 12px;
  border-radius: var(--radius);
  font-weight: 800;
}

.status.good {
  color: var(--good);
  background: var(--good-soft);
}

.status.warn {
  color: var(--warn);
  background: var(--warn-soft);
}

.explain-grid {
  display: grid;
  gap: 10px;
}

.explain-item {
  padding: 13px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.explain-item h3 {
  color: var(--accent-strong);
}

.stats-grid,
.concept-grid {
  display: grid;
  gap: 10px;
}

.stat {
  padding: 14px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat strong {
  display: block;
  font-size: 26px;
  line-height: 1.1;
}

.review-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.review-list li {
  padding: 12px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.meter {
  overflow: hidden;
  height: 9px;
  margin-top: 8px;
  background: var(--border);
  border-radius: 999px;
}

.meter span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.print-only {
  display: none;
}

@media (min-width: 720px) {
  .app-shell {
    padding: 24px;
  }

  .main-card {
    padding: 24px;
  }

  .path-grid,
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .setup-grid {
    grid-template-columns: 1fr 1fr auto;
    align-items: end;
  }

  .concept-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .actions,
  .skip-link {
    display: none !important;
  }

  .app-shell,
  .main-card {
    width: 100%;
    min-height: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .print-only {
    display: block;
  }
}
