/* ---------- Tokens ---------- */
:root {
  color-scheme: light;

  /* Warm paper palette */
  --paper:      #f4ede0;
  --paper-2:    #efe6d3;
  --paper-3:    #e9dec7;
  --surface:    #fbf7ee;
  --surface-2:  #f7f1e3;
  --ink:        #221c14;
  --ink-soft:   #4a3f33;
  --muted:      #8a7e6e;
  --muted-2:    #b3a896;
  --line:       rgba(34, 28, 20, 0.10);
  --line-2:     rgba(34, 28, 20, 0.06);

  /* Accents — used sparingly */
  --leaf:   #4a7355;   /* confident / cenozoic */
  --ocean:  #3c6b7a;   /* primary */
  --clay:   #b25a36;   /* mesozoic */
  --gold:   #c08a2c;   /* learning */
  --rose:   #b25067;   /* review */

  --shadow-sm: 0 1px 0 rgba(34,28,20,0.04), 0 2px 6px rgba(34,28,20,0.04);
  --shadow-md: 0 1px 0 rgba(34,28,20,0.04), 0 12px 28px -12px rgba(34,28,20,0.18);
  --shadow-lg: 0 1px 0 rgba(34,28,20,0.04), 0 24px 60px -22px rgba(34,28,20,0.28);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 24px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background: var(--paper);
  background-image:
    /* paper grain */
    radial-gradient(circle at 20% 10%, rgba(255,255,255,0.5), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(178,90,54,0.05), transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(60,107,122,0.04), transparent 60%);
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: rgba(74,115,85,0.22); }

h1, h2, h3, h4 {
  font-family: "Fraunces", "Iowan Old Style", "Georgia", serif;
  font-weight: 500;
  font-variation-settings: "opsz" 60, "SOFT" 30;
  letter-spacing: -0.012em;
  color: var(--ink);
}

/* ---------- Shell ---------- */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  gap: 22px;
  padding: 26px 22px;
  color: var(--ink-soft);
  background:
    linear-gradient(180deg, var(--paper-2), var(--paper-3));
  border-right: 1px solid var(--line);
}

.brand {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  color: var(--clay);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}
.brand-mark svg { width: 30px; height: 30px; }

.brand-text { display: grid; gap: 1px; }

.course-kicker,
.eyebrow,
.panel-label,
.section-label,
.stat-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.brand h1 {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.1;
  font-variation-settings: "opsz" 30, "SOFT" 20;
}

/* Tabs */
.view-tabs { display: grid; gap: 2px; }

.view-tab {
  width: 100%;
  padding: 9px 12px;
  text-align: left;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  font-size: 0.92rem;
  font-weight: 500;
  transition: background 140ms ease, color 140ms ease;
}

.view-tab:hover,
.view-tab:focus-visible {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.5);
  outline: none;
}

.view-tab.active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

/* Mastery panel */
.sidebar-panel {
  margin-top: auto;
  display: grid;
  gap: 14px;
  padding: 18px 18px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}

.sidebar-panel .panel-label { color: var(--muted); }

.ring-meter {
  --progress: 0;
  position: relative;
  width: 132px;
  height: 132px;
  margin: 4px auto 2px;
  display: grid;
  place-items: center;
}

.ring-svg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--paper-3);
  stroke-width: 6;
}

.ring-fill {
  fill: none;
  stroke: var(--leaf);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 326.7;
  stroke-dashoffset: calc(326.7 - (326.7 * var(--progress)));
  transition: stroke-dashoffset 600ms cubic-bezier(.2,.8,.2,1);
}

.ring-meter span {
  font-family: "Fraunces", serif;
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.mode-breakdown {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.78rem;
  color: var(--muted);
}

.mode-breakdown li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 10px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
}

.mode-breakdown strong {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0;
}

.sidebar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ghost-button {
  min-height: 34px;
  padding: 6px 10px;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 0.85rem;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.ghost-button:hover,
.ghost-button:focus-visible {
  color: var(--ink);
  background: var(--surface);
  border-color: rgba(34,28,20,0.16);
  outline: none;
}

.ghost-button.danger { color: var(--rose); }
.ghost-button.danger:hover { background: rgba(178,80,103,0.07); }

.sidebar-footer {
  margin: -4px 0 0;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  color: var(--muted-2);
  font-size: 0.72rem;
  font-style: italic;
  font-family: "Fraunces", serif;
  text-align: center;
  letter-spacing: 0.02em;
}

/* ---------- Workspace ---------- */
.workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 40px 18px;
  background:
    linear-gradient(180deg, rgba(244,237,224,0.92), rgba(244,237,224,0.78));
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  border-bottom: 1px solid var(--line-2);
}

.topbar h2 {
  margin: 2px 0 0;
  font-size: clamp(1.7rem, 2.4vw, 2.4rem);
  line-height: 1.05;
  font-variation-settings: "opsz" 90, "SOFT" 40;
}

.eyebrow { color: var(--clay); }

.topbar-tools { display: flex; align-items: center; gap: 10px; }

.search-box {
  display: grid;
  grid-template-columns: 16px minmax(160px, 280px);
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 14px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.search-box svg { width: 16px; height: 16px; }
.search-box:focus-within {
  border-color: var(--ocean);
  box-shadow: 0 0 0 4px rgba(60,107,122,0.10);
}
.search-box input {
  width: 100%;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--ink);
  font-size: 0.92rem;
}
.search-box input::placeholder { color: var(--muted-2); }

/* ---------- View root ---------- */
.view-root {
  width: min(1200px, 100%);
  padding: 26px clamp(20px, 4vw, 40px) 56px;
}

/* ---------- Cards / surfaces ---------- */
.study-map,
.meter-panel,
.topic-card,
.prompt-card,
.practice-panel,
.topic-list,
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.empty-state {
  background: transparent;
}

/* ---------- Hero (overview) ---------- */
.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) 320px;
  gap: 18px;
  align-items: stretch;
  margin-bottom: 26px;
}

.study-map {
  position: relative;
  overflow: hidden;
  padding: 28px 30px;
  background:
    radial-gradient(circle at 100% 0%, rgba(178,90,54,0.06), transparent 50%),
    radial-gradient(circle at 0% 100%, rgba(74,115,85,0.06), transparent 50%),
    var(--surface);
}

/* Subtle whimsy: faint ammonite watermark */
.study-map::after {
  content: "";
  position: absolute;
  right: -30px; bottom: -30px;
  width: 220px; height: 220px;
  color: var(--clay);
  opacity: 0.06;
  background: currentColor;
  -webkit-mask: url("assets/ammonite.svg") no-repeat center / contain;
          mask: url("assets/ammonite.svg") no-repeat center / contain;
  pointer-events: none;
}

.study-map h3,
.meter-panel h3 {
  margin: 6px 0 8px;
  font-size: 1.6rem;
  line-height: 1.15;
  font-variation-settings: "opsz" 40, "SOFT" 30;
}

.study-map p {
  max-width: 56ch;
  margin: 0 0 22px;
  color: var(--ink-soft);
  font-size: 0.97rem;
}

.era-lane { display: grid; gap: 12px; }

.era-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
  gap: 14px;
}

.era-label {
  font-family: "Fraunces", serif;
  font-size: 0.92rem;
  font-weight: 500;
  font-style: italic;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}

.topic-track {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
}

.track-topic {
  position: relative;
  padding: 5px 10px 5px 18px;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  transition: transform 140ms ease;
}
.track-topic::before {
  content: "";
  position: absolute;
  left: 8px; top: 50%;
  width: 6px; height: 6px;
  margin-top: -3px;
  border-radius: 50%;
  background: var(--ocean);
}
.track-topic.mesozoic::before { background: var(--clay); }
.track-topic.cenozoic::before { background: var(--leaf); }
.track-topic:hover { transform: translateY(-1px); }

/* Meter (overview right) */
.meter-panel {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 24px;
}

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

.stat-card {
  padding: 14px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  box-shadow: none;
  border-radius: var(--r-md);
}

.stat-number {
  display: block;
  margin-bottom: 2px;
  font-family: "Fraunces", serif;
  font-size: 1.6rem;
  font-weight: 500;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.stat-label { font-size: 0.65rem; }

.status-legend { display: grid; gap: 7px; }

.legend-row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 10px;
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.legend-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.6);
}
.legend-dot.new       { background: var(--muted-2); }
.legend-dot.learning  { background: var(--gold); }
.legend-dot.review    { background: var(--rose); }
.legend-dot.confident { background: var(--leaf); }

.legend-row strong {
  font-family: "Fraunces", serif;
  font-weight: 500;
  color: var(--ink);
}

/* ---------- Section heading ---------- */
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 28px 0 14px;
}

.section-heading h3 {
  margin: 4px 0 0;
  font-size: 1.32rem;
  font-variation-settings: "opsz" 40;
}

.section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
}

/* ---------- Topic grid ---------- */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.topic-card {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 20px 20px 18px;
  text-align: left;
  cursor: pointer;
  transition: transform 180ms cubic-bezier(.2,.8,.2,1), box-shadow 180ms ease, border-color 180ms ease;
}

.topic-card:hover,
.topic-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: rgba(34,28,20,0.16);
  outline: none;
}

.topic-card .topic-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.topic-card h4 {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.25;
  font-weight: 500;
  font-variation-settings: "opsz" 30;
  color: var(--ink);
}

.era-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  font-family: "Fraunces", serif;
  font-style: italic;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--leaf);
  background: rgba(74,115,85,0.08);
  border-radius: 999px;
}
.era-pill::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--leaf);
}
.era-pill.mesozoic { color: var(--clay); background: rgba(178,90,54,0.08); }
.era-pill.mesozoic::before { background: var(--clay); }

.drill-topic-link {
  width: fit-content;
  border: 0;
  cursor: pointer;
  transition: background 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}
.drill-topic-link:hover {
  background: rgba(74,115,85,0.14);
  transform: translateY(-1px);
}
.drill-topic-link.mesozoic:hover { background: rgba(178,90,54,0.14); }
.drill-topic-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(60,107,122,0.18);
}

.focus-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: 999px;
}

.queue-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  color: var(--muted);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: lowercase;
  background: var(--surface-2);
  border-radius: 999px;
}

.progress-line {
  width: 100%;
  height: 4px;
  overflow: hidden;
  background: var(--paper-3);
  border-radius: 999px;
}

.progress-line span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--leaf), var(--ocean));
  border-radius: inherit;
  transition: width 500ms cubic-bezier(.2,.8,.2,1);
}

.topic-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

.topic-footer strong {
  font-family: "Fraunces", serif;
  font-weight: 500;
  color: var(--ink);
}

/* ---------- Learn ---------- */
.learn-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.topic-list {
  position: sticky; top: 110px;
  display: grid;
  gap: 2px;
  max-height: calc(100vh - 140px);
  overflow: auto;
  padding: 10px;
}

.topic-list-button {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 10px 12px;
  color: var(--muted);
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  transition: background 140ms ease, color 140ms ease;
}

.topic-list-button:hover,
.topic-list-button:focus-visible {
  color: var(--ink);
  background: var(--surface-2);
  outline: none;
}

.topic-list-button.active {
  color: var(--ink);
  background: var(--surface-2);
  box-shadow: inset 3px 0 0 var(--clay);
}

.topic-list-button strong {
  display: block;
  font-family: "Fraunces", serif;
  font-weight: 500;
  font-size: 0.97rem;
  line-height: 1.25;
  color: inherit;
}

.topic-list-button span {
  font-size: 0.76rem;
  color: var(--muted);
}

/* Topic header — quiet, parchment, no dark gradient */
.topic-header {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 28px 30px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.5), rgba(255,255,255,0)),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.topic-header-main {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.reveal-all-button {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-soft);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: background 140ms ease, color 140ms ease, transform 140ms ease;
}
.reveal-all-button:hover {
  color: var(--ink);
  background: var(--paper-2);
  transform: translateY(-1px);
}

.topic-header::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--leaf);
  border-radius: var(--r-lg) 0 0 var(--r-lg);
}
.topic-header.mesozoic::before { background: var(--clay); }

.topic-header::after {
  content: "";
  position: absolute;
  right: -20px; bottom: -30px;
  width: 160px; height: 160px;
  color: var(--leaf);
  opacity: 0.08;
  background: currentColor;
  -webkit-mask: url("assets/fern.svg") no-repeat center / contain;
          mask: url("assets/fern.svg") no-repeat center / contain;
  pointer-events: none;
}
.topic-header.mesozoic::after {
  color: var(--clay);
  -webkit-mask-image: url("assets/ammonite.svg");
          mask-image: url("assets/ammonite.svg");
  opacity: 0.09;
}

.topic-header .section-label { color: var(--clay); }
.topic-header.cenozoic .section-label { color: var(--leaf); }

.topic-header h3 {
  margin: 0;
  font-size: clamp(1.7rem, 2.6vw, 2.4rem);
  line-height: 1.06;
  font-variation-settings: "opsz" 90, "SOFT" 50;
}

.focus-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

.focus-pill {
  font-family: "Fraunces", serif;
  font-style: italic;
  color: var(--ink-soft);
  background: var(--surface-2);
  border-color: var(--line-2);
}

/* Prompt cards — calm, with status as a quiet dot */
.prompt-stack { display: grid; gap: 12px; }

.prompt-card {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 22px 24px;
  border-radius: var(--r-md);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.prompt-card::before {
  content: "";
  position: absolute;
  left: 14px; top: 26px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--muted-2);
  box-shadow: 0 0 0 3px var(--surface);
}
.prompt-card.review::before    { background: var(--rose); }
.prompt-card.learning::before  { background: var(--gold); }
.prompt-card.confident::before { background: var(--leaf); }

.prompt-card { padding-left: 32px; }

.prompt-card:hover { box-shadow: var(--shadow-md); }

.prompt-text {
  margin: 0;
  font-family: "Fraunces", serif;
  font-weight: 500;
  font-size: 1.18rem;
  line-height: 1.4;
  color: var(--ink);
  font-variation-settings: "opsz" 30;
}

.prompt-subitems {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0 0 0 18px;
  color: var(--ink-soft);
  font-size: 0.94rem;
}
.prompt-subitems li::marker { color: var(--clay); }

/* Answer key — collapsed teaser + revealed structured answer (native <details>) */
.answer-key {
  display: grid;
  gap: 10px;
  padding: 14px 18px 16px;
  border: 1px solid rgba(60,107,122,0.18);
  border-left: 3px solid var(--ocean);
  border-radius: var(--r-md);
  background: linear-gradient(180deg, rgba(60,107,122,0.06), rgba(60,107,122,0.015));
}

.answer-eyebrow {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ocean);
}

.answer-body {
  display: grid;
  gap: 10px;
  color: var(--ink);
}

.answer-summary {
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: 1.02rem;
  font-style: italic;
  line-height: 1.45;
  color: var(--ink-soft);
}

.answer-points {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
  font-size: 0.94rem;
  line-height: 1.5;
}
.answer-points li::marker { color: var(--ocean); }

.answer-details {
  margin: 4px 0 0;
  padding: 12px 14px;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink-soft);
  background: rgba(255,255,255,0.55);
  border-left: 2px solid rgba(60,107,122,0.30);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

/* Status row — quiet segmented control */
.status-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.status-buttons {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: 999px;
}

.status-button {
  min-height: 30px;
  padding: 5px 14px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  transition: color 140ms ease, background 180ms ease;
}

.status-button:hover { color: var(--ink); }

.status-button.active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.status-button.active[data-status="review"]    { color: var(--rose); }
.status-button.active[data-status="learning"]  { color: var(--gold); }
.status-button.active[data-status="confident"] { color: var(--leaf); }

.quiet-button {
  min-height: 32px;
  padding: 6px 12px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  font-size: 0.82rem;
  transition: color 140ms ease, background 140ms ease;
}
.quiet-button:hover { color: var(--ink); background: var(--surface-2); }

.primary-button {
  min-height: 38px;
  padding: 8px 18px;
  color: #fbf7ee;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow-sm);
  transition: transform 140ms ease, background 140ms ease;
}
.primary-button:hover {
  background: #2d251c;
  transform: translateY(-1px);
}
.primary-button:focus-visible { outline: 3px solid rgba(60,107,122,0.30); outline-offset: 2px; }

/* ---------- Practice ---------- */
.mode-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 18px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}

.chip-button {
  min-height: 32px;
  padding: 6px 14px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 500;
  transition: color 140ms ease, background 140ms ease;
}

.chip-button:hover { color: var(--ink); background: var(--surface-2); }

.chip-button.active {
  color: var(--ink);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
}

.practice-shell {
  display: grid;
  gap: 18px;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
}

.practice-panel {
  display: grid;
  gap: clamp(18px, 2.4vw, 24px);
  padding: clamp(20px, 3vw, 32px);
  min-width: 0;
}

.practice-kicker {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.practice-kicker h3 {
  margin: 2px 0 0;
  font-size: 1.05rem;
  color: var(--ink-soft);
  font-style: italic;
  font-weight: 500;
}

.practice-question {
  position: relative;
  display: grid;
  place-items: start;
  padding: clamp(22px, 3vw, 34px) clamp(22px, 3.4vw, 38px);
  background:
    radial-gradient(circle at 100% 0%, rgba(60,107,122,0.05), transparent 40%),
    var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
}

.practice-question::before {
  content: "“";
  position: absolute;
  top: -10px; left: 16px;
  font-family: "Fraunces", serif;
  font-size: 4rem;
  line-height: 1;
  color: var(--clay);
  opacity: 0.35;
}

.practice-question p {
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: clamp(1.25rem, 1.6vw + 0.4rem, 1.7rem);
  line-height: 1.3;
  font-weight: 500;
  font-variation-settings: "opsz" 60, "SOFT" 40;
}

.practice-question ul {
  margin: 14px 0 0;
  padding-left: 22px;
  color: var(--ink-soft);
  line-height: 1.55;
  font-size: 0.95rem;
}
.practice-question li::marker { color: var(--clay); }

.practice-choices { gap: 10px; }

.practice-no-mcq {
  margin: 0;
  padding: 14px 16px;
  font-size: 0.92rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
}

.practice-feedback {
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-2);
  background: var(--surface-2);
}
.practice-feedback.right {
  border-color: rgba(74,115,85,0.32);
  background: rgba(74,115,85,0.07);
}
.practice-feedback.wrong {
  border-color: rgba(178,80,103,0.28);
  background: rgba(178,80,103,0.06);
}
.practice-feedback-tag {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.practice-feedback.right .practice-feedback-tag { color: var(--leaf); }
.practice-feedback.wrong .practice-feedback-tag { color: var(--rose); }
.practice-feedback .answer-points {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink-soft);
}
.practice-feedback .answer-points li::marker { color: var(--clay); }
.practice-feedback .answer-details {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
  line-height: 1.55;
}

.practice-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.practice-tools-side,
.practice-tools-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- Flash cards ---------- */
.flash-shell {
  display: grid;
  gap: 18px;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.flash-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.flash-card {
  position: relative;
  display: block;
  width: 100%;
  min-height: clamp(280px, 38vh, 380px);
  padding: 0;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
  perspective: 1400px;
  -webkit-tap-highlight-color: transparent;
}

.flash-card:focus-visible { outline: none; }
.flash-card:focus-visible .flash-face {
  box-shadow: 0 0 0 3px rgba(60,107,122,0.30), var(--shadow-md);
}

.flash-face {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: clamp(22px, 3vw, 32px) clamp(24px, 3.4vw, 36px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: transform 520ms cubic-bezier(.2,.8,.2,1), box-shadow 200ms ease;
  overflow: hidden;
}

.flash-face-front {
  background:
    radial-gradient(circle at 100% 0%, rgba(178,90,54,0.07), transparent 45%),
    var(--surface);
}

.flash-face-back {
  transform: rotateY(180deg);
  background:
    radial-gradient(circle at 0% 100%, rgba(60,107,122,0.08), transparent 45%),
    var(--surface);
}

.flash-card.is-flipped .flash-face-front { transform: rotateY(-180deg); }
.flash-card.is-flipped .flash-face-back  { transform: rotateY(0deg); }

.flash-card.verdict-got .flash-face       { border-color: rgba(74,115,85,0.45); }
.flash-card.verdict-review .flash-face    { border-color: rgba(178,80,103,0.40); }

.flash-eyebrow {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--clay);
}
.flash-face-back .flash-eyebrow { color: var(--ocean); }

.flash-question {
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: clamp(1.3rem, 1.6vw + 0.4rem, 1.75rem);
  line-height: 1.3;
  font-weight: 500;
  font-variation-settings: "opsz" 60, "SOFT" 40;
  color: var(--ink);
}

.flash-bullets {
  margin: 0;
  padding-left: 22px;
  display: grid;
  gap: 4px;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink-soft);
}
.flash-bullets li::marker { color: var(--clay); }

.flash-summary {
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: 1.1rem;
  font-style: italic;
  line-height: 1.4;
  color: var(--ink);
}

.flash-face-back .answer-points { font-size: 0.9rem; }
.flash-face-back .answer-points li::marker { color: var(--ocean); }

.flash-hint {
  margin-top: auto;
  align-self: end;
  justify-self: end;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.flash-tools {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}

.flash-tools-side,
.flash-tools-nav {
  display: flex;
  gap: 8px;
}

.flash-tools-rate {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.flash-tools-rate .rate-review.active {
  color: var(--rose);
  border-color: rgba(178,80,103,0.45);
  background: rgba(178,80,103,0.08);
}
.flash-tools-rate .rate-got.active {
  background: var(--leaf);
  border-color: var(--leaf);
}

@media (max-width: 720px) {
  .flash-tools {
    grid-template-columns: 1fr;
  }
  .flash-tools-side,
  .flash-tools-nav,
  .flash-tools-rate {
    justify-content: center;
    flex-wrap: wrap;
  }
}

/* ---------- Weak list ---------- */
.weak-list { display: grid; gap: 12px; }

/* ---------- Empty state ---------- */
.empty-state {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 320px;
  padding: 36px;
  text-align: center;
  color: var(--muted);
}

.empty-state svg {
  width: 64px; height: 64px;
  color: var(--clay);
  opacity: 0.55;
}

.empty-state h3 {
  margin: 4px 0 0;
  font-size: 1.2rem;
  font-style: italic;
  color: var(--ink);
  font-weight: 500;
}

.empty-state p { margin: 0; max-width: 320px; }

/* ---------- Drills ---------- */
.drills-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 4px 16px;
  color: var(--ink-soft);
}
.drills-intro p { margin: 0; max-width: 60ch; font-size: 0.95rem; }
.drills-progress {
  flex: 0 0 auto;
  font-family: "Fraunces", serif;
  font-style: italic;
  color: var(--ink-soft);
}
.drills-progress strong { color: var(--leaf); font-weight: 500; }

.drill-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.drill-card {
  display: grid;
  gap: 14px;
  padding: 22px 24px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}
.drill-card.complete {
  border-color: rgba(74,115,85,0.32);
  box-shadow: 0 1px 0 rgba(34,28,20,0.04), 0 12px 28px -16px rgba(74,115,85,0.32);
}

.drill-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.drill-header h4 {
  margin: 6px 0 0;
  font-family: "Fraunces", serif;
  font-weight: 500;
  font-size: 1.18rem;
  font-variation-settings: "opsz" 30;
}

.drill-type-pill {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ocean);
  padding: 3px 8px;
  background: rgba(60,107,122,0.08);
  border-radius: 999px;
}
.drill-type-pill[data-type="match"]  { color: var(--ocean); background: rgba(60,107,122,0.08); }
.drill-type-pill[data-type="order"]  { color: var(--clay);  background: rgba(178,90,54,0.08); }
.drill-type-pill[data-type="choose"] { color: var(--leaf);  background: rgba(74,115,85,0.10); }

.drill-instruction,
.drill-question {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.94rem;
}
.drill-question {
  font-family: "Fraunces", serif;
  font-style: italic;
  font-size: 1.04rem;
  color: var(--ink);
}

.drill-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 2px;
  padding-top: 10px;
  border-top: 1px dashed var(--line-2);
  font-size: 0.82rem;
  color: var(--muted);
}
.drill-done {
  color: var(--leaf);
  font-weight: 600;
  font-family: "Fraunces", serif;
  font-style: italic;
}

/* Match */
.match-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.match-col { display: grid; gap: 8px; }

.match-item {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 46px;
  padding: 10px 14px;
  text-align: left;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  font-size: 0.92rem;
  line-height: 1.3;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}
.match-item:hover:not(:disabled):not(.matched) {
  background: var(--surface);
  border-color: rgba(34,28,20,0.16);
  transform: translateY(-1px);
}
.match-item.selected {
  background: var(--surface);
  border-color: var(--ocean);
  box-shadow: 0 0 0 3px rgba(60,107,122,0.16);
}
.match-item.matched {
  color: var(--leaf);
  background: rgba(74,115,85,0.08);
  border-color: rgba(74,115,85,0.28);
  cursor: default;
  text-decoration: line-through;
  text-decoration-color: rgba(74,115,85,0.42);
  text-decoration-thickness: 1px;
}
.match-item.matched::after {
  content: "✓";
  margin-left: auto;
  padding-left: 12px;
  color: var(--leaf);
  font-weight: 600;
}
.match-item.wrong {
  animation: shake 320ms cubic-bezier(.36,.07,.19,.97) both;
  background: rgba(178,80,103,0.10);
  border-color: rgba(178,80,103,0.32);
  color: var(--rose);
}

@keyframes shake {
  10%, 90%  { transform: translateX(-2px); }
  20%, 80%  { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60%  { transform: translateX(5px); }
}

/* Order */
.order-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}
.order-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  transition: background 160ms ease, border-color 160ms ease;
}
.order-index {
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  font-family: "Fraunces", serif;
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 50%;
}
.order-label { font-size: 0.95rem; color: var(--ink); }
.order-controls { display: inline-flex; gap: 4px; }
.order-arrow {
  width: 28px; height: 28px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  font-size: 0.85rem;
  transition: color 140ms ease, background 140ms ease;
}
.order-arrow:hover:not(:disabled) {
  color: var(--ink);
  background: var(--paper-2);
}
.order-arrow:disabled { opacity: 0.35; cursor: not-allowed; }

.order-item.correct {
  background: rgba(74,115,85,0.08);
  border-color: rgba(74,115,85,0.28);
}
.order-item.correct .order-index {
  color: var(--leaf);
  background: var(--surface);
  border-color: rgba(74,115,85,0.32);
}
.order-item.wrong {
  background: rgba(178,80,103,0.06);
  border-color: rgba(178,80,103,0.22);
}

.drill-actions { display: flex; justify-content: flex-end; }

/* Choose */
.choose-list { display: grid; gap: 8px; }

.choose-option {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  text-align: left;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  font-size: 0.95rem;
  line-height: 1.35;
  transition: background 160ms ease, border-color 160ms ease, transform 140ms ease;
}
.choose-option:hover:not(:disabled) {
  background: var(--surface);
  border-color: rgba(34,28,20,0.16);
  transform: translateY(-1px);
}
.choose-mark {
  display: grid;
  place-items: center;
  width: 22px; height: 22px;
  font-family: "Fraunces", serif;
  font-size: 0.95rem;
  border-radius: 50%;
  background: transparent;
}
.choose-option.correct {
  color: var(--leaf);
  background: rgba(74,115,85,0.10);
  border-color: rgba(74,115,85,0.32);
}
.choose-option.correct .choose-mark { background: var(--leaf); color: #fbf7ee; }
.choose-option.wrong {
  color: var(--rose);
  background: rgba(178,80,103,0.10);
  border-color: rgba(178,80,103,0.32);
}
.choose-option.wrong.flash-wrong {
  animation: shake 320ms cubic-bezier(.36,.07,.19,.97) both;
}
.choose-option.wrong .choose-mark { background: var(--rose); color: #fbf7ee; }

.choose-explain {
  margin: 4px 0 0;
  padding: 12px 14px;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink-soft);
  background: rgba(60,107,122,0.05);
  border-left: 2px solid rgba(60,107,122,0.30);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

.hidden { display: none !important; }

/* ---------- Scrollbar polish ---------- */
.topic-list::-webkit-scrollbar { width: 8px; }
.topic-list::-webkit-scrollbar-thumb {
  background: rgba(34,28,20,0.10);
  border-radius: 999px;
}
.topic-list::-webkit-scrollbar-track { background: transparent; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 1fr; }

  .sidebar {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "tabs"
      "actions";
    gap: 16px;
    padding: 16px 20px;
  }
  .brand { grid-area: brand; }
  .view-tabs {
    grid-area: tabs;
    grid-template-columns: repeat(5, 1fr);
  }

  .drill-grid { grid-template-columns: 1fr; }
  .drills-intro { flex-direction: column; align-items: flex-start; gap: 8px; }
  .view-tab { text-align: center; padding: 8px 6px; }
  .sidebar-panel, .sidebar-footer { display: none; }
  .sidebar-actions {
    grid-area: actions;
    grid-template-columns: auto auto;
    justify-content: end;
  }

  .topbar { position: static; padding: 18px 24px; }
  .view-root { padding: 22px 24px 56px; }

  .hero-panel,
  .learn-layout,
  .practice-shell { grid-template-columns: 1fr; }

  .topic-list {
    position: static;
    max-height: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(220px, 1fr);
    overflow-x: auto;
  }

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

@media (max-width: 720px) {
  .view-root, .topbar { padding-left: 18px; padding-right: 18px; }
  .topbar { align-items: stretch; flex-direction: column; }
  .search-box { grid-template-columns: 16px 1fr; }
  .topic-grid, .stat-grid { grid-template-columns: 1fr; }
  .view-tabs { grid-template-columns: repeat(2, 1fr); }
  .era-row { grid-template-columns: 1fr; }
  .practice-kicker, .status-row, .practice-tools, .section-heading {
    align-items: stretch;
    flex-direction: column;
  }
}

/* ---------- Print ---------- */
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .mode-strip, .status-row { display: none !important; }
  .app-shell, .learn-layout, .practice-shell { display: block; }
  .view-root { width: 100%; padding: 0; }
  .topic-header, .prompt-card, .topic-card {
    box-shadow: none;
    break-inside: avoid;
  }
}

/* ---------- Tiny entrance polish ---------- */
/* Only fires when the view actually changes (.entering toggled in render()). */
@media (prefers-reduced-motion: no-preference) {
  .view-root.entering > * {
    animation: rise 320ms cubic-bezier(.2,.8,.2,1) both;
  }
  @keyframes rise {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
  }
}
