:root {
  --bg: #f4efe6;
  --bg-deep: #ebe4d6;
  --surface: #fbf7f0;
  --surface-2: #f3ece0;
  --ink: #1c1712;
  --ink-soft: #3d342b;
  --muted: #6e6256;
  --line: rgba(28, 23, 18, 0.12);
  --line-strong: rgba(28, 23, 18, 0.22);
  --accent: #7a2e24;
  --accent-2: #9a4a28;
  --gold: #b08a4a;
  --gold-soft: rgba(176, 138, 74, 0.16);
  --ok: #2f5d3a;
  --ok-soft: rgba(47, 93, 58, 0.12);
  --bad: #8b2c22;
  --bad-soft: rgba(139, 44, 34, 0.1);
  --shadow: 0 1px 2px rgba(28, 23, 18, 0.04), 0 18px 40px rgba(28, 23, 18, 0.06);
  --radius: 14px;
  --serif: "Cormorant Garamond", "Palatino Linotype", Palatino, "Times New Roman", serif;
  --sans: "Source Sans 3", "Source Sans Pro", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --max: 1120px;
  --ease: 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; color-scheme: light only; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(176, 138, 74, 0.14), transparent 50%),
    radial-gradient(900px 400px at 100% 0%, rgba(122, 46, 36, 0.08), transparent 46%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

.wrap { width: min(var(--max), calc(100% - 40px)); margin: 0 auto; position: relative; z-index: 1; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 0;
}
.brand { display: flex; flex-direction: column; gap: 1px; text-decoration: none; color: inherit; }
.brand-kicker {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}
.brand-name {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.brand-name em { font-style: italic; font-weight: 500; color: var(--accent-2); }

nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
}
.nav-btn:hover { color: var(--ink); background: var(--gold-soft); }
.nav-btn.is-active { color: var(--accent); background: var(--gold-soft); font-weight: 600; }
.nav-btn:focus-visible, button:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hero { padding: 56px 0 28px; }
.hero-grid {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 36px;
  align-items: end;
}
.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 12px;
}
h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(42px, 6vw, 72px);
  line-height: 0.95;
  letter-spacing: -0.03em;
  margin: 0 0 16px;
}
h1 span { display: block; font-style: italic; color: var(--accent-2); font-size: 0.62em; }
.lede { max-width: 52ch; color: var(--ink-soft); margin: 0; font-size: 18px; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stat b {
  display: block;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
  line-height: 1;
}
.stat span { font-size: 12px; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }

.view { display: none; padding: 8px 0 80px; }
.view.is-on { display: block; }
[hidden], .is-hidden { display: none !important; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 22px;
}
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.chip, .btn, select {
  font-family: var(--sans);
  font-size: 13.5px;
}
.chip {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease), color var(--ease);
}
.chip.is-on, .chip:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--bg);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  letter-spacing: 0.03em;
}
.btn.ghost { background: transparent; color: var(--ink); }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

select {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 12px;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.book-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  color: inherit;
  width: 100%;
  transition: transform var(--ease), border-color var(--ease);
}
.book-card:hover { transform: translateY(-2px); border-color: var(--gold); }
.book-card .roman {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--accent);
}
.book-card h3 {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 500;
  margin: 6px 0 8px;
  letter-spacing: -0.02em;
}
.book-card p { margin: 0; color: var(--muted); font-size: 15px; }

.guide {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  padding: 28px;
  box-shadow: var(--shadow);
}
.guide h2 {
  font-family: var(--serif);
  font-size: clamp(32px, 4vw, 46px);
  font-weight: 500;
  margin: 4px 0 10px;
}
.thesis {
  font-family: var(--serif);
  font-size: 22px;
  font-style: italic;
  color: var(--ink-soft);
  margin: 0 0 22px;
  max-width: 62ch;
}
.guide ol { margin: 0 0 24px; padding-left: 20px; }
.guide li { margin: 0 0 10px; }
.quotes { display: grid; gap: 10px; }
blockquote {
  margin: 0;
  padding: 14px 16px;
  background: var(--gold-soft);
  border-left: 2px solid var(--gold);
  font-family: var(--serif);
  font-size: 20px;
  font-style: italic;
}
blockquote cite {
  display: block;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 11px;
  font-style: normal;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.terms {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.term {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.term h3 { margin: 0 0 2px; font-family: var(--serif); font-size: 24px; font-weight: 600; }
.term .el { font-family: var(--serif); font-style: italic; color: var(--accent-2); font-size: 15px; }
.term p { margin: 8px 0 0; color: var(--ink-soft); font-size: 15px; }

.deck-meta { color: var(--muted); font-size: 14px; }
.stage { perspective: 1400px; margin: 10px auto 18px; max-width: 720px; }
.card {
  position: relative;
  min-height: 340px;
  transform-style: preserve-3d;
  transition: transform 560ms cubic-bezier(0.2, 0.75, 0.2, 1);
  cursor: pointer;
}
.card.is-flipped { transform: rotateY(180deg); }
.face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 36px 36px 28px;
  display: flex;
  flex-direction: column;
}
.face.back { transform: rotateY(180deg); background: #221c17; color: #f6efe4; }
.face.back .tag { color: #d9b56a; }
.tag {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}
.prompt {
  font-family: var(--serif);
  font-size: clamp(26px, 3.4vw, 36px);
  line-height: 1.2;
  margin: 18px 0 auto;
  letter-spacing: -0.02em;
}
.hint { margin-top: auto; color: var(--muted); font-size: 13px; }
.face.back .hint { color: rgba(246, 239, 228, 0.55); }
.face.back .prompt { font-size: clamp(20px, 2.4vw, 26px); line-height: 1.35; }

.card-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}
.progress-track {
  height: 4px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
  max-width: 720px;
  margin: 0 auto 28px;
}
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width var(--ease); }

.known {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}
.known .btn { min-width: 140px; }
.known .miss { background: transparent; color: var(--accent); border-color: var(--accent); }

.quiz-shell { max-width: 760px; margin: 0 auto; }
.q-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; color: var(--muted); font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; }
.q-prompt {
  font-family: var(--serif);
  font-size: clamp(26px, 3vw, 34px);
  line-height: 1.2;
  margin: 0 0 20px;
}
.choices { display: grid; gap: 8px; }
.choice {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  font-size: 16px;
  color: var(--ink);
  transition: border-color var(--ease), background var(--ease);
}
.choice:hover { border-color: var(--gold); }
.choice.is-picked { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.choice.is-right { background: var(--ok-soft); border-color: var(--ok); }
.choice.is-wrong { background: var(--bad-soft); border-color: var(--bad); }
.explain {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--surface-2);
  border-radius: 12px;
  color: var(--ink-soft);
  display: none;
}
.explain.is-on { display: block; }
.quiz-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }

.score {
  text-align: center;
  padding: 40px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.score h2 { font-family: var(--serif); font-size: 48px; margin: 0 0 8px; }
.score p { color: var(--muted); }
.missed { margin-top: 24px; text-align: left; }
.missed h3 { font-family: var(--serif); font-size: 24px; margin: 0 0 10px; }
.missed li { margin: 0 0 10px; }

.progress-page { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.panel h3 { font-family: var(--serif); font-size: 26px; margin: 0 0 10px; }
.bar-list { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 72px 1fr 40px; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.bar { height: 8px; background: var(--bg-deep); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0; }

.site-footer {
  border-top: 1px solid var(--line);
  padding: 22px 0 36px;
  color: var(--muted);
  font-size: 13px;
}
.site-footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

@media (max-width: 800px) {
  .hero-grid, .book-grid, .terms, .progress-page { grid-template-columns: 1fr; }
  .header-inner { flex-direction: column; align-items: flex-start; }
  nav { width: 100%; overflow-x: auto; }
  .face { padding: 24px 20px; }
  .card { min-height: 300px; }
  .wrap { width: min(var(--max), calc(100% - 28px)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .card { transition: none; }
}
