:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --ink: #1f1b16;
  --muted: #6b645b;
  --line: #e7e0d6;
  --accent: #c2410c;
  --accent-soft: #fff1e8;
  --persona: #f3efe8;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17140f;
    --surface: #211d17;
    --ink: #f3eee6;
    --muted: #a69d90;
    --line: #3a3328;
    --accent: #fb8a4c;
    --accent-soft: #3a2416;
    --persona: #2a251e;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 Inter, system-ui, sans-serif;
}

h1, h2, .brand { font-family: Fraunces, Georgia, serif; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.9rem; line-height: 1.2; margin: 0.25rem 0 0.75rem; }
h2 { font-size: 1.2rem; margin: 0 0 0.75rem; }
a { color: var(--accent); }
code { background: var(--accent-soft); padding: 0 4px; border-radius: 4px; }

.site-header {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 18px 16px; border-bottom: 1px solid var(--line);
  max-width: 760px; margin: 0 auto;
}
.brand { font-size: 1.5rem; color: var(--ink); text-decoration: none; }
.tagline, .muted, small { color: var(--muted); }

.page { max-width: 760px; margin: 0 auto; padding: 24px 16px 64px; }
.lede { color: var(--muted); margin-top: 0; }

.topic {
  display: inline-block; font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--accent);
}

.level-picker { display: flex; gap: 8px; margin: 16px 0 24px; }
.level-picker button {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 6px 16px; font-weight: 600; cursor: pointer;
}
.level-picker .selected { background: var(--accent); border-color: var(--accent); color: #fff; }
.level-picker { flex-wrap: wrap; align-items: center; }
.level-hint { font-size: 0.9rem; color: var(--muted); }

.site-nav { margin-left: auto; font-size: 0.95rem; display: flex; gap: 16px; flex-wrap: wrap; }
.recap-links { display: flex; gap: 20px; flex-wrap: wrap; }
.attribution { display: block; margin-top: 6px; font-size: 0.8rem; }

.level-options { border: 0; padding: 0; margin: 0 0 16px; display: grid; gap: 12px; }
.level-option {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  padding: 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); cursor: pointer;
}
.level-option span { display: grid; gap: 2px; }
.level-option.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.level-option input { accent-color: var(--accent); width: 18px; height: 18px; }
.level-code { font-size: 0.75rem; font-weight: 600; color: var(--accent); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.stories { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.stories a {
  display: grid; gap: 4px; padding: 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none;
}
.stories a:hover { border-color: var(--accent); }

.empty, .story-card, .recap-section {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
}
.story-card { margin-bottom: 20px; }
.story-card audio { width: 100%; margin: 8px 0 12px; }
.summary { font-size: 1.05rem; }
.source-link { font-size: 0.9rem; }

button.primary, .controls .talk {
  background: var(--accent); color: #fff; border: 0; border-radius: 999px;
  padding: 14px 24px; font-weight: 600; font-size: 1rem; cursor: pointer;
}
button:disabled { opacity: 0.55; cursor: default; }

button.danger {
  background: transparent; color: var(--accent); border: 1px solid var(--accent); border-radius: 999px;
  padding: 12px 20px; font-weight: 600; font-size: 1rem; cursor: pointer; margin-bottom: 16px;
}
.notice { background: var(--accent-soft); border-radius: var(--radius); padding: 12px 16px; margin: 0 0 16px; }
.usage { color: var(--muted); font-size: 0.9rem; margin: -4px 0 16px; }
.plain-list { padding-left: 20px; margin: 0 0 16px; }
.plain-list li { margin-bottom: 6px; }
.legal h2 { margin-top: 24px; }
.legal ul { padding-left: 20px; }
.site-footer { max-width: 760px; margin: 0 auto; padding: 0 16px 32px; font-size: 0.85rem; color: var(--muted); }

.sign-in { display: grid; gap: 12px; max-width: 360px; margin: 24px 0 12px; }
.sign-in a {
  display: block; text-align: center; text-decoration: none;
  background: var(--accent); color: #fff; border-radius: 999px; padding: 14px 24px; font-weight: 600;
}
button.secondary {
  background: transparent; border: 1px solid var(--line); color: var(--ink);
  border-radius: 999px; padding: 12px 20px; cursor: pointer;
}

.transcript { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 10px; }
.line { padding: 10px 14px; border-radius: var(--radius); max-width: 85%; display: flex; gap: 10px; align-items: baseline; }
.line.persona { background: var(--persona); }
.line.learner { background: var(--accent-soft); margin-left: auto; }
.score { font-size: 0.75rem; font-weight: 600; color: var(--accent); }

.controls {
  display: flex; gap: 12px; flex-wrap: wrap; position: sticky; bottom: 0;
  padding: 12px 0 16px; background: var(--bg);
}
.controls .talk {
  flex: 1; min-width: 200px; touch-action: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.controls .talk.active { box-shadow: 0 0 0 6px var(--accent-soft); }

/* Fundamentals help phrases: one row that scrolls sideways, above the talk button. */
.help-phrases {
  flex-basis: 100%; display: flex; gap: 8px; overflow-x: auto;
  list-style: none; margin: 0; padding: 0 0 4px; scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.help-phrases button {
  display: grid; gap: 2px; text-align: left; white-space: nowrap; cursor: pointer;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 14px; font-size: 0.9rem;
}
.help-phrases small { font-size: 0.75rem; }
.help-hint { color: var(--muted); font-size: 0.9rem; margin: 16px 0 8px; }

.language-select {
  width: 100%; max-width: 480px; margin: 0 0 16px; padding: 12px 14px; font: inherit;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.speed-setting {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center;
  max-width: 480px; margin: 0 0 16px;
}
.speed-setting input { width: 100%; accent-color: var(--accent); }
.speed-setting output { font-weight: 600; min-width: 3.2em; text-align: right; }
.speed-setting small { grid-column: 1 / -1; }
.status { color: var(--accent); }

.recap-section { margin-bottom: 16px; }
.scores { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.score-tile { display: grid; text-align: center; padding: 12px; background: var(--persona); border-radius: 10px; }
.score-tile span { font-family: Fraunces, Georgia, serif; font-size: 1.8rem; }
.chips { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { background: var(--accent-soft); border-radius: 999px; padding: 4px 12px; }
.corrections, .phrases { padding-left: 18px; display: grid; gap: 10px; }

#blazor-error-ui {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: #fde68a; color: #1f1b16; padding: 10px 16px;
}
