:root {
  --bg: #f3efe6;
  --bg-2: #fffdf8;
  --ink: #161d24;
  --muted: #5c656d;
  --line: #e2dbcf;
  --accent: #e04e28;
  --accent-soft: #fde6df;
  --accent-ink: #fff;
  --teal: #1c6b62;
  --teal-soft: #dceeed;
  --ok: #157a4b;
  --ok-soft: #d9f0e5;
  --warn: #a15c12;
  --warn-soft: #f8ead3;
  --danger: #b42318;
  --danger-soft: #f8dbd8;
  --shadow: 0 1px 2px rgba(22, 29, 36, 0.05), 0 10px 28px rgba(22, 29, 36, 0.06);
  --radius: 18px;
  --radius-sm: 12px;
  --font-ui: "Outfit", system-ui, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-text: "Source Serif 4", Georgia, "Times New Roman", serif;
  --nav-h: 64px;
  --bottom-nav: 72px;
  --max: 1120px;
  --focus: 0 0 0 3px var(--bg-2), 0 0 0 6px var(--accent);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

[hidden] {
  display: none !important;
}

img,
svg {
  max-width: 100%;
  display: block;
}

a {
  color: var(--teal);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--accent);
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -40px;
  z-index: 80;
  background: var(--ink);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
}

.skip-link:focus {
  top: 12px;
}

.wrap {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: 16px;
  box-sizing: border-box;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.brand:hover {
  color: inherit;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text small {
  font-weight: 400;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.nav-desktop {
  display: none;
  gap: 6px;
}

.nav-desktop a {
  color: var(--ink);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
}

.nav-desktop a:hover,
.nav-desktop a[aria-current="page"] {
  background: var(--bg-2);
}

.nav-desktop a[aria-current="page"] {
  box-shadow: inset 0 0 0 1px var(--line);
}

.bottom-nav {
  position: fixed;
  inset: auto 0 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}

.bottom-nav a {
  color: var(--muted);
  text-decoration: none;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  padding: 8px 4px;
  border-radius: 12px;
}

.bottom-nav a svg {
  width: 22px;
  height: 22px;
  margin: 0 auto 2px;
}

.bottom-nav a[aria-current="page"],
.bottom-nav a:hover {
  color: var(--ink);
  background: var(--bg);
}

main {
  padding: 24px 0 120px;
}

.hero {
  display: grid;
  gap: 20px;
  padding: 12px 0 8px;
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal);
}

.kicker.pending {
  color: var(--warn);
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0 0 0.4em;
}

h1 {
  font-size: clamp(2rem, 6vw, 3.4rem);
}

h2 {
  font-size: clamp(1.4rem, 3vw, 1.85rem);
}

h3 {
  font-size: 1.2rem;
}

.lede {
  font-family: var(--font-text);
  font-size: 1.15rem;
  color: var(--muted);
  max-width: 38rem;
  margin: 0;
}

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

.btn {
  appearance: none;
  border: 0;
  background: var(--ink);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
}

.btn:hover {
  color: #fff;
  background: #000;
}

.btn-accent {
  background: var(--accent);
}

.btn-accent:hover {
  background: #c94320;
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.btn-ghost:hover {
  background: var(--bg-2);
  color: var(--ink);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

.panel {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.notice {
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 25%, var(--line));
  color: var(--ink);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 14px;
}

.notice strong {
  display: block;
  margin-bottom: 2px;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: 36px 0 16px;
}

.section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.topic-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.topic-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
}

.topic-card:hover {
  color: inherit;
  border-color: color-mix(in srgb, var(--ink) 18%, var(--line));
  transform: translateY(-1px);
}

.topic-index {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--teal-soft);
  color: var(--teal);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 600;
}

.topic-card h3 {
  margin: 0 0 2px;
  font-size: 1.15rem;
}

.topic-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  margin-top: 6px;
}

.ring {
  width: 48px;
  height: 48px;
}

.ring circle {
  fill: none;
  stroke-width: 5;
}

.ring .track {
  stroke: var(--line);
}

.ring .value {
  stroke: var(--teal);
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

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

.stat {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.stat span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat strong {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 4vw, 2rem);
  letter-spacing: -0.03em;
  font-weight: 600;
}

.empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
}

.empty h3 {
  color: var(--ink);
}

.lesson {
  display: grid;
  gap: 16px;
}

.lesson-header {
  padding-bottom: 8px;
  min-width: 0;
}

.lesson-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  min-width: 0;
}

.lesson-header-copy {
  min-width: 0;
  flex: 1;
}

.prose {
  font-family: var(--font-text);
  font-size: 1.05rem;
  line-height: 1.7;
}

.prose p {
  margin: 0 0 0.9em;
}

.example,
.mistake {
  border-radius: var(--radius);
  padding: 18px;
  border: 1px solid var(--line);
  background: var(--bg-2);
}

.example {
  border-left: 4px solid var(--teal);
}

.mistake {
  border-left: 4px solid var(--accent);
}

.example h3,
.mistake h3 {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  letter-spacing: 0;
  margin-bottom: 8px;
}

.steps {
  margin: 0;
  padding-left: 1.15em;
}

.steps li {
  margin: 0.35em 0;
}

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.tabs button {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.tabs button[aria-selected="true"] {
  background: var(--ink);
  color: #fff;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink);
  font: inherit;
  font-weight: 550;
  font-size: 14px;
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 44px;
}

.chip[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.chip small {
  display: block;
  font-size: 11px;
  font-weight: 500;
  opacity: 0.72;
}

.quiz-shell {
  max-width: 720px;
  margin: 0 auto;
}

.progress-bar {
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0 20px;
}

.progress-bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.25s ease;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.question-type {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  font-weight: 700;
  color: var(--teal);
}

.options {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.option {
  appearance: none;
  width: 100%;
  text-align: left;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
  min-height: 52px;
}

.option:hover {
  border-color: color-mix(in srgb, var(--ink) 20%, var(--line));
}

.option[aria-checked="true"] {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.option.is-correct {
  background: var(--ok-soft);
  border-color: var(--ok);
}

.option.is-wrong {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.input,
textarea.input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg-2);
  border-radius: 14px;
  padding: 14px 16px;
  font: inherit;
  font-size: 1rem;
  color: inherit;
  margin: 16px 0;
}

textarea.input {
  min-height: 160px;
  resize: vertical;
  font-family: var(--font-text);
}

.feedback {
  border-radius: var(--radius);
  padding: 16px;
  margin: 8px 0 16px;
}

.feedback.ok {
  background: var(--ok-soft);
}

.feedback.bad {
  background: var(--danger-soft);
}

.feedback.neutral {
  background: var(--teal-soft);
}

.mark-list {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.mark-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.mark-item input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
}

.results-score {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 8vw, 4.2rem);
  letter-spacing: -0.04em;
  line-height: 1;
}

.breakdown {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.bar-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  font-size: 14px;
}

.bar {
  grid-column: 1 / -1;
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  background: var(--teal);
}

.chart {
  width: 100%;
  height: 180px;
}

.chart path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart .area {
  stroke: none;
  fill: color-mix(in srgb, var(--accent) 16%, transparent);
}

.chart .axis {
  stroke: var(--line);
  stroke-width: 1;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

footer.site-foot {
  color: var(--muted);
  font-size: 13px;
  padding: 8px 0 24px;
}

@media (min-width: 800px) {
  .nav-desktop {
    display: flex;
  }

  .bottom-nav {
    display: none;
  }

  main {
    padding-bottom: 64px;
  }

  .hero {
    grid-template-columns: 1.2fr 0.8fr;
    align-items: end;
    gap: 32px;
    padding: 28px 0 12px;
  }

  .topic-grid {
    grid-template-columns: 1fr 1fr;
  }

  .growth-row {
    gap: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .topic-card:hover,
  .progress-bar > span {
    transition: none;
    transform: none;
  }
}


.jump-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 12px;
}

.jump-nav a {
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--bg-2);
  box-shadow: inset 0 0 0 1px var(--line);
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}

.jump-nav a:hover {
  background: var(--teal-soft);
  color: var(--teal);
}

.sources {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
}

.sources summary {
  cursor: pointer;
  font-weight: 650;
  font-size: 14px;
}

.sources .prose {
  margin-top: 10px;
  font-size: 0.95rem;
}

.lesson-section h2 {
  margin-top: 0;
}

.prose ul,
.prose ol {
  margin: 0 0 0.9em;
  padding-left: 1.25em;
}

.prose li {
  margin: 0.28em 0;
}

.prose pre {
  background: #161d24;
  color: #f6f1e9;
  border-radius: 12px;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.45;
  margin: 0 0 1em;
}

.prose code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.prose pre code {
  font-size: inherit;
  background: none;
  padding: 0;
  color: inherit;
}

.prose :not(pre) > code {
  background: color-mix(in srgb, var(--ink) 6%, var(--bg-2));
  padding: 0.1em 0.35em;
  border-radius: 6px;
}

.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.25em 0;
}

.examples-block .prose h3,
.mistakes-block .prose h3 {
  font-family: var(--font-ui);
  font-size: 1rem;
  letter-spacing: 0;
  margin: 1.1em 0 0.4em;
}

.mistakes-block {
  border-left: 4px solid var(--accent);
}

@media (min-width: 800px) {
  .jump-nav {
    position: sticky;
    top: calc(var(--nav-h) + 8px);
    z-index: 20;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(10px);
    padding: 6px 0;
  }
}


html, body {
  max-width: 100%;
  overflow-x: hidden;
}

.wrap,
.panel,
.prose,
.lede,
.topic-card,
.quiz-shell,
.lesson-header,
.lesson,
main {
  max-width: 100%;
  min-width: 0;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.jump-nav {
  max-width: 100%;
  min-width: 0;
}

.jump-nav a {
  max-width: 100%;
  flex: 0 1 auto;
}

.unit-meta {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
  max-width: 42rem;
}

.chip-list,
.options,
.option {
  max-width: 100%;
  overflow-wrap: break-word;
}
