/* === Enact Course — Brand-aligned design system === */
/* Per BRAND_FRAMEWORK.md: Paper ground, Carbon text, Signal as the single accent.
   Geist for display + UI, Geist Mono for operational moments.
   Dark mode is a setting, not the identity. Lead with white. */

:root {
  /* Brand palette (locked per BRAND_FRAMEWORK.md §"Color system") */
  --paper:    #FFFFFF;
  --mist:     #F7F7F5;
  --graphite: #737373;
  --carbon:   #0A0A0A;
  --signal:   #FFB800;
  --eclipse:  #000000;

  /* Operational derivatives (kept restrained — restraint IS the brand) */
  --line:        #E8E8E5;        /* hairline borders on Paper */
  --line-strong: #C8C8C5;        /* sidebar dividers */
  --carbon-soft: #2A2A2A;        /* slightly-softer near-black for nested headings */
  --signal-tint: rgba(255, 184, 0, 0.12);  /* Signal as background tint, used once per surface */

  /* Type stack — per BRAND_FRAMEWORK.md fallback chain. NO Inter. */
  --display: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono:    "Geist Mono", "JetBrains Mono", "SF Mono", ui-monospace, Menlo, monospace;

  --radius:    4px;     /* Tight, not rounded-friendly */
  --radius-lg: 8px;
  --shadow:        0 1px 0 var(--line);
  --shadow-strong: 0 4px 24px rgba(10, 10, 10, 0.06);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.55;
  color: var(--carbon);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'ss01', 'ss03', 'cv11';  /* Geist character variants if available */
}

/* === Layout === */

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--mist);
  border-right: 1px solid var(--line);
  padding: 28px 22px;
  overflow-y: auto;
  z-index: 10;
}

.main {
  padding: 32px 64px 120px;
  max-width: 880px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .main { padding: 24px 20px 80px; }
}

/* === Brand / Sidebar === */

.brand {
  display: block;
  margin-bottom: 4px;
  text-decoration: none;
}

.brand img {
  /* Approved primary lockup (480×120 viewBox) — height 36px keeps width ~144px,
     comfortably above the 120px minimum-width spec from logo README. */
  display: block;
  height: 36px;
  width: auto;
}

.brand-tag {
  font-size: 11px;
  color: var(--graphite);
  margin: 8px 0 32px 0;
  font-family: var(--mono);
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.nav-section-label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--graphite);
  margin-bottom: 12px;
  font-weight: 500;
}

.nav {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav a {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 10px;
  color: var(--carbon-soft);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.45;
  border-left: 2px solid transparent;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}

.nav a:hover {
  background: var(--paper);
  color: var(--carbon);
}

.nav a.active {
  background: var(--paper);
  border-left-color: var(--signal);
  color: var(--carbon);
  font-weight: 500;
}

.nav .num {
  display: inline-block;
  width: 22px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--graphite);
  font-variant-numeric: tabular-nums;
  font-weight: 400;
}

.nav a.active .num { color: var(--carbon); }

.nav-action {
  display: block;
  margin-top: 20px;
  padding: 11px 14px;
  background: var(--carbon);
  color: var(--paper);
  text-decoration: none;
  font-family: var(--display);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  letter-spacing: -0.005em;
  border: 1px solid var(--carbon);
  transition: background 0.1s;
}

.nav-action:hover { background: var(--carbon-soft); }

.nav-action.secondary {
  background: var(--paper);
  color: var(--carbon);
  border: 1px solid var(--line-strong);
  margin-top: 8px;
}

.nav-action.secondary:hover { border-color: var(--carbon); }

/* === Top bar === */

.topbar {
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 12px 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 8;
}

.topbar-title {
  font-size: 13px;
  color: var(--graphite);
  font-family: var(--mono);
  letter-spacing: 0.01em;
}

.topbar-title strong {
  color: var(--carbon);
  font-weight: 500;
  font-family: var(--display);
}

.topbar-actions { display: flex; gap: 8px; align-items: center; }

@media (max-width: 900px) { .topbar { padding: 12px 20px; } }

/* === Hero === */

.hero {
  margin-bottom: 56px;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--line);
  /* Subtle Mist-ground atmosphere per brand v2 update */
  background: radial-gradient(ellipse at top right, var(--mist) 0%, transparent 50%);
  margin-left: -64px;
  margin-right: -64px;
  padding: 48px 64px 40px;
}

@media (max-width: 900px) {
  .hero { margin-left: -20px; margin-right: -20px; padding: 32px 20px 28px; }
}

.hero h1 {
  font-family: var(--display);
  font-size: 44px;
  line-height: 1.05;
  letter-spacing: -0.055em;
  margin: 0 0 14px;
  font-weight: 700;
  color: var(--carbon);
}

.hero .subtitle {
  font-size: 18px;
  color: var(--carbon-soft);
  line-height: 1.5;
  margin: 0 0 28px;
  max-width: 640px;
  letter-spacing: -0.005em;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--graphite);
  letter-spacing: 0.01em;
}

.meta-row strong {
  color: var(--carbon);
  font-weight: 500;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--graphite);
  padding: 4px 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
}

.meta-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--signal);
  display: inline-block;
}

/* === Modules === */

.module {
  margin-top: 72px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
}

.module:first-of-type {
  margin-top: 0;
  border-top: 0;
  padding-top: 0;
}

.module-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 6px;
}

.module-num {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--graphite);
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

.module-readtime {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--graphite);
  letter-spacing: 0.02em;
}

.module h2 {
  font-family: var(--display);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.04em;
  margin: 4px 0 24px;
  line-height: 1.15;
  color: var(--carbon);
}

.module h3 {
  font-family: var(--display);
  font-size: 17px;
  font-weight: 600;
  margin: 32px 0 12px;
  color: var(--carbon);
  letter-spacing: -0.015em;
}

.module h4 {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  margin: 24px 0 8px;
  color: var(--graphite);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.module p {
  margin: 0 0 14px;
  color: var(--carbon-soft);
}

.module ul, .module ol {
  padding-left: 22px;
  margin: 0 0 16px;
  color: var(--carbon-soft);
}

.module li { margin-bottom: 6px; }
.module li::marker { color: var(--graphite); }

.module a {
  color: var(--carbon);
  text-decoration: none;
  border-bottom: 1px solid var(--line-strong);
  transition: border-color 0.1s;
}

.module a:hover { border-color: var(--carbon); }

.module strong {
  color: var(--carbon);
  font-weight: 600;
}

.module em {
  font-style: italic;
  color: var(--carbon);
}

/* Pull-quote (verbatim citation) — Mist surface, Signal accent rule */
.quote {
  background: var(--mist);
  border-left: 2px solid var(--signal);
  padding: 16px 20px;
  margin: 20px 0;
  font-family: var(--display);
  font-style: italic;
  color: var(--carbon);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.005em;
}

.quote .src {
  display: block;
  margin-top: 10px;
  font-style: normal;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--graphite);
  letter-spacing: 0.02em;
}

/* Misconception callout — restrained, no error-red, just Mist with strikethrough mark */
.misconception {
  background: var(--mist);
  padding: 12px 16px 12px 32px;
  margin: 6px 0;
  font-size: 14px;
  position: relative;
  color: var(--carbon-soft);
  border-left: 1px solid var(--line-strong);
}

.misconception::before {
  content: '×';
  position: absolute;
  left: 14px;
  top: 11px;
  color: var(--graphite);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
}

.misconception strong { color: var(--carbon); }

.misconception em {
  color: var(--carbon);
  font-style: normal;
  font-weight: 500;
  border-bottom: 2px solid var(--signal);
  padding-bottom: 1px;
}

/* Findings card */
.finding {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 16px 20px;
  margin: 20px 0;
}

.finding-title {
  font-family: var(--mono);
  font-weight: 500;
  color: var(--graphite);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

/* Tables */
.module table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 14px;
  border: 1px solid var(--line);
}

.module th {
  background: var(--mist);
  color: var(--carbon);
  font-family: var(--display);
  font-weight: 600;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  letter-spacing: -0.005em;
}

.module td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--carbon-soft);
  vertical-align: top;
}

.module tr:last-child td { border-bottom: 0; }
.module td strong { color: var(--carbon); }

/* Code — Geist Mono earns its place */
code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--mist);
  border: 1px solid var(--line);
  padding: 1.5px 6px;
  color: var(--carbon);
  letter-spacing: 0.01em;
}

pre {
  background: var(--mist);
  border: 1px solid var(--line);
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.55;
  margin: 18px 0;
}

pre code {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--carbon);
  font-size: 13px;
}

/* Sources block — operational, mono */
.sources {
  margin-top: 32px;
  padding: 14px 18px;
  background: var(--mist);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--graphite);
  letter-spacing: 0.01em;
  line-height: 1.55;
}

.sources strong {
  color: var(--carbon);
  font-family: var(--display);
  font-weight: 500;
  font-size: 13px;
  display: block;
  margin-bottom: 4px;
  letter-spacing: -0.005em;
}

/* === Quiz === */

.quiz-question {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 24px 28px;
  margin: 20px 0;
  transition: border-color 0.15s;
}

.quiz-question.answered { border-color: var(--carbon); }

.quiz-q-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}

.quiz-q-num {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--graphite);
  font-variant-numeric: tabular-nums;
  min-width: 32px;
  letter-spacing: 0.02em;
}

.quiz-q-module {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--graphite);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.quiz-q-difficulty {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--graphite);
  padding: 2px 8px;
  border: 1px solid var(--line);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.quiz-q-difficulty.hard {
  background: var(--signal-tint);
  border-color: var(--signal);
  color: var(--carbon);
}

.quiz-q-text {
  font-family: var(--display);
  font-size: 16px;
  line-height: 1.5;
  margin-bottom: 16px;
  color: var(--carbon);
  letter-spacing: -0.005em;
}

.quiz-input {
  width: 100%;
  min-height: 100px;
  padding: 12px 14px;
  font-family: var(--display);
  font-size: 14px;
  line-height: 1.55;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  color: var(--carbon);
  resize: vertical;
}

.quiz-input:focus {
  outline: none;
  border-color: var(--carbon);
  box-shadow: 0 0 0 2px var(--signal-tint);
}

.quiz-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--carbon);
  font-family: var(--display);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  letter-spacing: -0.005em;
}

.btn:hover { border-color: var(--carbon); }

.btn-primary {
  background: var(--carbon);
  border-color: var(--carbon);
  color: var(--paper);
}

.btn-primary:hover {
  background: var(--carbon-soft);
  border-color: var(--carbon-soft);
}

.btn-signal {
  background: var(--signal);
  border-color: var(--signal);
  color: var(--carbon);
  font-weight: 600;
}

.btn-signal:hover {
  background: var(--carbon);
  border-color: var(--carbon);
  color: var(--paper);
}

.quiz-answer {
  display: none;
  margin-top: 18px;
  padding: 16px 18px;
  background: var(--mist);
  border-left: 2px solid var(--signal);
  font-size: 14px;
  line-height: 1.6;
  color: var(--carbon-soft);
}

.quiz-answer.shown { display: block; }

.quiz-answer-label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--graphite);
  font-weight: 500;
  margin-bottom: 6px;
}

.quiz-answer strong { color: var(--carbon); }
.quiz-answer code { background: var(--paper); }

.quiz-rate {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.quiz-rate-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--graphite);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.quiz-rate-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.quiz-rate-buttons .btn {
  flex: 1;
  min-width: 110px;
  justify-content: center;
}

.quiz-rate-buttons .btn.selected {
  background: var(--signal);
  border-color: var(--signal);
  color: var(--carbon);
  font-weight: 600;
}

/* Quiz progress / results */

.quiz-progress {
  position: sticky;
  top: 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 18px 22px;
  margin-bottom: 28px;
  z-index: 5;
}

.quiz-progress-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--graphite);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.quiz-progress-stat strong {
  font-family: var(--display);
  font-size: 18px;
  color: var(--carbon);
  font-weight: 600;
  margin-right: 4px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.quiz-bar {
  height: 4px;
  background: var(--line);
  overflow: hidden;
}

.quiz-bar-fill {
  height: 100%;
  background: var(--signal);
  width: 0%;
  transition: width 0.3s ease-out;
}

.quiz-results {
  background: var(--paper);
  border: 1px solid var(--carbon);
  padding: 36px 40px;
  margin: 32px 0;
  box-shadow: var(--shadow-strong);
}

.quiz-results h2 {
  font-family: var(--display);
  font-size: 28px;
  margin: 0 0 8px;
  letter-spacing: -0.04em;
  font-weight: 700;
  color: var(--carbon);
}

.quiz-results .score {
  font-family: var(--display);
  font-size: 64px;
  font-weight: 700;
  color: var(--carbon);
  line-height: 1;
  margin: 20px 0 6px;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
}

.quiz-results .score-suffix {
  font-family: var(--mono);
  font-size: 18px;
  color: var(--graphite);
  font-weight: 400;
  letter-spacing: 0.02em;
}

.quiz-results .score-label {
  font-family: var(--mono);
  color: var(--graphite);
  margin-bottom: 28px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.quiz-results .verdict {
  font-family: var(--display);
  font-size: 16px;
  padding: 18px 22px;
  border-left: 2px solid var(--signal);
  background: var(--mist);
  margin: 20px 0;
  line-height: 1.55;
  color: var(--carbon);
  letter-spacing: -0.005em;
}

.results-breakdown { margin-top: 32px; font-size: 14px; }

.results-breakdown h3 {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--graphite);
  margin: 28px 0 12px;
  font-weight: 500;
}

.results-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--carbon-soft);
}

.results-row:last-child { border-bottom: 0; }
.results-row strong { color: var(--carbon); font-family: var(--mono); font-weight: 500; }

/* === Driver.js custom styling — match brand === */

.driver-popover {
  background: var(--paper);
  color: var(--carbon);
  border: 1px solid var(--carbon);
  border-radius: 0;
  box-shadow: var(--shadow-strong);
  font-family: var(--display);
}

.driver-popover-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 16px;
  color: var(--carbon);
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.driver-popover-description {
  color: var(--carbon-soft);
  line-height: 1.55;
  font-size: 14px;
  letter-spacing: -0.005em;
}

.driver-popover-progress-text {
  font-family: var(--mono);
  color: var(--graphite);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.driver-popover-footer button {
  background: var(--paper);
  border: 1px solid var(--line-strong);
  color: var(--carbon);
  font-family: var(--display);
  font-weight: 500;
  text-shadow: none;
  border-radius: 0;
  padding: 6px 14px;
  font-size: 13px;
  letter-spacing: -0.005em;
}

.driver-popover-next-btn,
.driver-popover-done-btn {
  background: var(--carbon) !important;
  color: var(--paper) !important;
  border-color: var(--carbon) !important;
}

.driver-popover-arrow { border-color: var(--carbon); }

/* Tour highlight — Signal accent on the spotlighted element */
.driver-active-element {
  box-shadow: 0 0 0 2px var(--signal), 0 0 0 5px var(--signal-tint);
}

/* Cosmo intentionally absent until the freelance illustrator delivers the final character.
   Per BRAND_FRAMEWORK.md §"Application principles": "Cosmo is small or absent."
   Every cosmo-exploration SVG in design/assets/cosmo-explorations/ is marked
   "EXPLORATORY MOCKUP — not final character." No CSS-improvised stand-in. */

/* === Listen button (per module) === */

.listen-btn {
  margin-left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--graphite);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  cursor: pointer;
  transition: color 0.1s, border-color 0.1s, background 0.1s;
}

.listen-btn:hover { color: var(--carbon); border-color: var(--carbon); }

.listen-btn.is-active {
  color: var(--carbon);
  border-color: var(--carbon);
  background: var(--mist);
}

.listen-btn .listen-icon {
  font-size: 9px;
  line-height: 1;
  font-family: var(--display);
  color: var(--graphite);
}

.listen-btn.is-active .listen-icon { color: var(--signal); }

/* === Audio player (bottom-sticky) === */

.audio-player {
  position: fixed;
  bottom: 0;
  left: 280px;            /* matches sidebar width */
  right: 0;
  z-index: 20;
  background: var(--paper);
  border-top: 1px solid var(--line-strong);
  padding: 14px 64px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  box-shadow: 0 -8px 24px rgba(10, 10, 10, 0.06);
}

.audio-player[hidden] { display: none; }

@media (max-width: 900px) {
  .audio-player { left: 0; padding: 12px 16px; gap: 12px; }
}

.ap-main {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.ap-row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
}

.ap-section-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--graphite);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.ap-section-label .signal-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--signal);
  margin-right: 8px;
  vertical-align: middle;
  /* Subtle pulse — the activation moment in audio form */
  animation: ap-pulse 1.4s ease-in-out infinite;
}

.ap-section-label.is-paused .signal-dot { animation: none; opacity: 0.4; }

@keyframes ap-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.ap-seek {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--line);
  outline: none;
  border-radius: 0;
  cursor: pointer;
}

.ap-seek::-webkit-slider-runnable-track {
  height: 4px;
  background: linear-gradient(to right, var(--carbon) var(--seek-fill, 0%), var(--line) var(--seek-fill, 0%));
}

.ap-seek::-moz-range-track {
  height: 4px;
  background: linear-gradient(to right, var(--carbon) var(--seek-fill, 0%), var(--line) var(--seek-fill, 0%));
}

.ap-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--signal);
  cursor: grab;
  margin-top: -5px;
  border: 1px solid var(--carbon);
}

.ap-seek::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--signal);
  cursor: grab;
  border: 1px solid var(--carbon);
  border-radius: 0;
}

.ap-seek:active::-webkit-slider-thumb { cursor: grabbing; }
.ap-seek:active::-moz-range-thumb { cursor: grabbing; }

.ap-time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--graphite);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 88px;
  text-align: right;
}

.ap-controls {
  display: flex;
  gap: 6px;
  align-items: center;
}

.ap-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  color: var(--carbon);
  cursor: pointer;
  font-family: var(--display);
  font-size: 13px;
  font-weight: 500;
  padding: 0;
  transition: border-color 0.1s, background 0.1s, color 0.1s;
}

.ap-btn:hover { border-color: var(--carbon); }

.ap-btn-sm { width: 30px; height: 30px; }

.ap-btn.primary {
  background: var(--carbon);
  color: var(--paper);
  border-color: var(--carbon);
}

.ap-btn.primary:hover { background: var(--carbon-soft); }

/* === Player icons (CSS-drawn, no font icons needed) === */

.ap-btn span[class^="icon-"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* play triangle */
.icon-play {
  width: 0;
  height: 0;
  border-left: 8px solid currentColor;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  margin-left: 2px;
}

/* pause = two bars */
.icon-pause { gap: 3px; }
.icon-pause::before, .icon-pause::after {
  content: '';
  display: block;
  width: 3px;
  height: 12px;
  background: currentColor;
}

/* stop = solid square */
.icon-stop {
  width: 10px;
  height: 10px;
  background: currentColor;
}

/* close × */
.icon-close::before {
  content: '×';
  font-size: 18px;
  line-height: 1;
  font-weight: 400;
}

/* prev module = ⏮  (bar + reverse triangle) */
.icon-prev {
  width: 12px;
  height: 10px;
  position: relative;
}
.icon-prev::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 2px;
  height: 10px;
  background: currentColor;
}
.icon-prev::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  width: 0;
  height: 0;
  border-right: 8px solid currentColor;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}

/* next module = ⏭  (forward triangle + bar) */
.icon-next {
  width: 12px;
  height: 10px;
  position: relative;
}
.icon-next::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  border-left: 8px solid currentColor;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}
.icon-next::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  width: 2px;
  height: 10px;
  background: currentColor;
}

/* back/forward 10s — text labels in mono */
.icon-back10::before {
  content: '«10';
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
}
.icon-fwd10::before {
  content: '10»';
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
}

/* === Side panel: voice picker + close === */

.ap-side {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ap-voice-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ap-voice-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--graphite);
  font-weight: 500;
}

.ap-voice {
  font-family: var(--display);
  font-size: 12px;
  font-weight: 500;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  color: var(--carbon);
  padding: 5px 24px 5px 10px;
  cursor: pointer;
  letter-spacing: -0.005em;
  max-width: 200px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%230A0A0A' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 10px;
}

.ap-voice:hover { border-color: var(--carbon); }
.ap-voice:focus { outline: none; border-color: var(--carbon); box-shadow: 0 0 0 2px var(--signal-tint); }
.ap-voice:disabled { color: var(--graphite); cursor: not-allowed; }

.audio-player .err {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--graphite);
  letter-spacing: 0.02em;
  line-height: 1.5;
}

@media (max-width: 700px) {
  .audio-player {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .ap-side {
    justify-content: space-between;
    border-top: 1px solid var(--line);
    padding-top: 12px;
  }
  .ap-voice { max-width: 160px; }
  .ap-controls { justify-content: center; flex-wrap: wrap; }
}

/* Bottom padding when player is visible — so content isn't covered */
body.player-active .main { padding-bottom: 220px; }
@media (max-width: 700px) { body.player-active .main { padding-bottom: 280px; } }

/* === Reader word highlighting (TTS karaoke) === */
/* Each word in a being-read section is wrapped in <span class="rw">.
   .active is toggled on the current word as Cosmo reads.
   Distinct from hotspots: stronger Signal background, no underline. */

.rw {
  /* Base — invisible. The wrap has no visual effect until .active. */
}

.rw.active {
  background: rgba(255, 184, 0, 0.32);
  padding: 1px 1px 0 1px;
  margin: -1px -1px 0 -1px; /* negate padding so layout doesn't shift */
  border-radius: 1px;
  /* Slight transition softens the rapid word-by-word jumps */
  transition: background 0.08s linear;
}

/* User-disable: word highlighting off but Listen still works */
body.reader-highlight-off .rw.active {
  background: transparent;
  padding: 0;
  margin: 0;
}

/* Highlight toggle button in audio player */
.ap-btn[data-ap="highlight-toggle"] .icon-highlight {
  position: relative;
  display: inline-block;
  width: 14px;
  height: 12px;
}

.ap-btn[data-ap="highlight-toggle"] .icon-highlight::before {
  content: 'Aa';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: -1px;
  line-height: 1;
  border-bottom: 2px solid var(--graphite);
  padding-bottom: 0;
}

.ap-btn[data-ap="highlight-toggle"].is-on {
  background: var(--signal);
  border-color: var(--carbon);
  color: var(--carbon);
}

.ap-btn[data-ap="highlight-toggle"].is-on .icon-highlight::before {
  border-bottom-color: var(--carbon);
}

/* Chrome-only hint: points to browser-native "Listen to this page" */
.ap-chrome-hint {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.4;
  color: var(--graphite);
  max-width: 220px;
  padding: 6px 10px;
  background: var(--mist);
  border: 1px solid var(--carbon);
  border-radius: 2px;
}
.ap-chrome-hint strong {
  color: var(--carbon);
  font-weight: 600;
}
@media (max-width: 700px) { .ap-chrome-hint { display: none; } }

/* === Test-mark hotspots === */
/* Quiz-anchored passages. Visible only when body.hotspots-on.
   Off by default. Toggle persists in localStorage. */

.hotspot {
  position: relative;
  /* No visual change when hotspots are off — content reads exactly as before */
}

body.hotspots-on .hotspot {
  background: var(--signal-tint);
  box-shadow: 0 -1px 0 var(--signal) inset;
  padding: 0 2px;
  border-radius: 1px;
  transition: background 0.15s;
}

body.hotspots-on .hotspot:hover { background: rgba(255, 184, 0, 0.22); }

.hotspot-badge {
  /* Always rendered in the DOM (so JS can wire tooltips), but only visible when hotspots-on */
  display: none;
  margin-left: 4px;
  padding: 1px 6px 1px 5px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--carbon);
  background: var(--signal);
  border: 1px solid var(--carbon);
  vertical-align: super;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s;
}

body.hotspots-on .hotspot-badge { display: inline-flex; align-items: center; gap: 3px; }

.hotspot-badge:hover { background: var(--carbon); color: var(--signal); }

.hotspot-badge .star { font-size: 9px; line-height: 1; }

/* Tooltip — positioned absolute relative to the badge's nearest .hotspot ancestor */
.hotspot-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  z-index: 30;
  width: 320px;
  max-width: 90vw;
  background: var(--carbon);
  color: var(--paper);
  padding: 12px 14px;
  border-left: 2px solid var(--signal);
  font-family: var(--display);
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  box-shadow: var(--shadow-strong);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s, transform 0.12s;
}

.hotspot-tooltip-q {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--signal);
  margin-bottom: 6px;
}

.hotspot-tooltip-action {
  display: block;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--graphite);
  text-transform: uppercase;
}

.hotspot-badge:hover + .hotspot-tooltip,
.hotspot-badge:focus + .hotspot-tooltip {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Toggle button in topbar */
.btn-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  color: var(--graphite);
  cursor: pointer;
  transition: color 0.1s, border-color 0.1s, background 0.1s;
}

.btn-toggle:hover { color: var(--carbon); border-color: var(--carbon); }

.btn-toggle.is-on {
  background: var(--signal);
  border-color: var(--carbon);
  color: var(--carbon);
  font-weight: 600;
}

.btn-toggle .toggle-dot {
  width: 6px;
  height: 6px;
  background: var(--graphite);
  display: inline-block;
}

.btn-toggle.is-on .toggle-dot { background: var(--carbon); }

/* Responsive: tighten badge on mobile so it doesn't overflow lines */
@media (max-width: 600px) {
  .hotspot-tooltip { width: 240px; }
}

/* === Misc utility === */

.score-pill {
  background: var(--carbon);
  color: var(--paper);
  padding: 4px 10px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.score-pill .signal { color: var(--signal); }

.dim { color: var(--graphite); }
.mono { font-family: var(--mono); font-size: 0.92em; letter-spacing: 0.01em; }
.center { text-align: center; }
.mt-large { margin-top: 56px; }

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

::selection {
  background: var(--signal);
  color: var(--carbon);
}

/* Print — keep it readable */
@media print {
  .sidebar, .topbar, .cosmo, .nav-action { display: none; }
  .main { padding: 0; max-width: 100%; }
  body { background: var(--paper); color: var(--carbon); }
}
