/*
 * The study app. Dark ground, the same mint, blue, and coral as the site:
 * mint for done and recalled, coral for missed, blue for structure, amber for
 * where you are now. Reading text is 18px with generous line height and a
 * measure of about 75 characters, because lessons are long and the eye needs
 * to find the next line; the space beside the text holds the lesson outline
 * and the tutor, not emptiness. Callout boxes and bold key terms give a page
 * something to land on. Amber is also the colour of levels and achievements,
 * violet of Rested XP and Sneak peek. Motion is short and never blocks input:
 * a card flips in a third of a second and slides in and out, XP floats up and
 * fades, a toast slides in for a quest or an achievement. Progress should feel
 * physical without making anyone wait. prefers-reduced-motion turns it off.
 */

:root {
  color-scheme: dark;
  --bg: #07080c;
  --bg-raised: #0d1017;
  --bg-card: #12161f;
  --line: rgba(226, 232, 244, 0.1);
  --line-strong: rgba(226, 232, 244, 0.2);
  --text: #eef1f7;
  --text-2: #b4bccb;
  --text-3: #79829a;
  --mint: #6ef2c0;
  --mint-soft: rgba(110, 242, 192, 0.12);
  --blue: #7aa2ff;
  --blue-soft: rgba(122, 162, 255, 0.13);
  --coral: #ff8073;
  --coral-soft: rgba(255, 128, 115, 0.13);
  --amber: #ffc46b;
  --amber-soft: rgba(255, 196, 107, 0.13);
  --violet: #c4a7ff;
  --violet-soft: rgba(196, 167, 255, 0.12);
  --sans: "IBM Plex Sans", "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", monospace;
  --radius: 14px;
  --radius-small: 9px;
  --topbar-h: 60px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code,
pre {
  font-family: var(--mono);
  font-size: 0.9em;
}

pre {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  padding: 12px 14px;
  overflow-x: auto;
}

code {
  background: rgba(226, 232, 244, 0.07);
  padding: 1px 5px;
  border-radius: 4px;
}

pre code {
  background: none;
  padding: 0;
}

h1,
h2,
h3 {
  line-height: 1.25;
  font-weight: 600;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 2.1rem;
}

h2 {
  font-size: 1.4rem;
  margin-top: 36px;
}

h3 {
  font-size: 1.1rem;
}

p {
  margin: 0 0 14px;
}

.skip {
  position: absolute;
  left: -999px;
}

.skip:focus {
  left: 12px;
  top: 12px;
  background: var(--bg-card);
  padding: 8px 12px;
  z-index: 20;
}

/* shell */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  background: rgba(7, 8, 12, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.brand:hover {
  text-decoration: none;
}

.brand-s,
.brand-dot {
  color: var(--mint);
}

#nav {
  display: flex;
  gap: 2px;
  flex-wrap: nowrap;
  overflow-x: auto;
}

#nav a {
  color: var(--text-2);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.94rem;
  white-space: nowrap;
}

#nav a:hover {
  text-decoration: none;
  background: rgba(226, 232, 244, 0.06);
  color: var(--text);
}

#nav a.is-current {
  background: var(--blue-soft);
  color: var(--text);
}

.due-badge {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--mint);
  color: #05281c;
  font-size: 0.74rem;
  font-weight: 700;
  text-align: center;
  line-height: 20px;
}

main {
  padding: 32px 28px 96px;
}

.page-wide {
  max-width: 1180px;
  margin: 0 auto;
}

.page-narrow,
.review,
.review-empty,
.quiz,
.quiz-result,
.explain,
.stats,
.settings,
.cards-browser {
  max-width: 860px;
  margin: 0 auto;
}

.loading,
.muted {
  color: var(--text-2);
}

.small {
  font-size: 0.88rem;
}

.lede {
  font-size: 1.15rem;
  color: var(--text-2);
  max-width: 70ch;
}

.error {
  color: var(--coral);
  background: var(--coral-soft);
  border: 1px solid rgba(255, 128, 115, 0.3);
  padding: 10px 14px;
  border-radius: var(--radius-small);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-3);
  margin-bottom: 8px;
}

.eyebrow a {
  color: var(--text-3);
}

.button,
button.button {
  display: inline-block;
  appearance: none;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}

.button:hover {
  text-decoration: none;
  border-color: var(--text-3);
}

.button.primary {
  background: var(--mint);
  color: #05281c;
  border-color: var(--mint);
  font-weight: 600;
}

.button.primary:hover {
  filter: brightness(1.06);
}

.button:disabled,
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.link {
  appearance: none;
  background: none;
  border: none;
  color: var(--blue);
  font: inherit;
  cursor: pointer;
  padding: 0;
}

button.link:hover {
  text-decoration: underline;
}

.chip {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--bg-card);
  color: var(--text-2);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
}

.chip.is-selected,
.chip:hover {
  color: var(--text);
  border-color: var(--blue);
  text-decoration: none;
}

.next-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 14px 0;
}

ul.plain {
  list-style: none;
  padding: 0;
}

ul.plain li {
  padding: 4px 0;
}

/* prose: lesson text, card faces, explanations */

.prose {
  font-size: 1.06rem;
  line-height: 1.75;
}

.prose p,
.prose ul,
.prose ol,
.prose table,
.prose blockquote,
.prose pre {
  margin: 0 0 18px;
}

.prose ul,
.prose ol {
  padding-left: 1.4em;
}

.prose li {
  margin-bottom: 8px;
}

.prose li > p {
  margin: 8px 0;
}

.prose strong {
  color: #fff;
  font-weight: 600;
}

.prose h3,
.prose h4,
.prose h5 {
  margin: 26px 0 10px;
  font-size: 1.08rem;
  font-weight: 600;
}

.prose blockquote {
  border-left: 3px solid var(--blue);
  margin-left: 0;
  padding: 2px 0 2px 16px;
  color: var(--text-2);
}

.prose table,
table.data {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.95rem;
  line-height: 1.5;
}

.prose th,
.prose td,
table.data th,
table.data td {
  border-bottom: 1px solid var(--line);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}

.prose th,
table.data th {
  color: var(--text-2);
  font-weight: 600;
  background: rgba(226, 232, 244, 0.03);
}

.prose hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 26px 0;
}

.math-inline .katex {
  font-size: 1.04em;
}

.math-display {
  overflow-x: auto;
  overflow-y: hidden;
  margin: 6px 0 20px;
  padding: 14px 10px;
  text-align: center;
  background: rgba(226, 232, 244, 0.03);
  border-radius: var(--radius-small);
}

.math code {
  color: var(--amber);
}

.math[data-rendered="1"] code {
  display: none;
}

/* callouts */

.callout {
  margin: 4px 0 22px;
  padding: 14px 18px 4px;
  border-radius: var(--radius-small);
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  background: var(--blue-soft);
}

.callout .callout-title {
  margin: 0 0 6px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--blue);
}

.callout p,
.callout ul,
.callout ol,
.callout table {
  margin-bottom: 10px;
}

.callout-key {
  border-left-color: var(--mint);
  background: var(--mint-soft);
}

.callout-key .callout-title {
  color: var(--mint);
}

.callout-key p {
  font-weight: 500;
}

.callout-why {
  border-left-color: var(--violet);
  background: var(--violet-soft);
}

.callout-why .callout-title {
  color: var(--violet);
}

.callout-mistake {
  border-left-color: var(--coral);
  background: var(--coral-soft);
}

.callout-mistake .callout-title {
  color: var(--coral);
}

.callout-try,
.callout-note {
  border-left-color: var(--amber);
  background: var(--amber-soft);
}

.callout-try .callout-title,
.callout-note .callout-title {
  color: var(--amber);
}

/* today */

.hero {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  align-items: flex-start;
  margin-bottom: 30px;
}

.hero h1 {
  font-size: 2.1rem;
  margin-bottom: 8px;
}

.hero-short {
  margin-bottom: 8px;
}

.goal {
  text-align: center;
  flex: none;
}

.goal-ring {
  width: 116px;
  height: 116px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(
    var(--mint) calc(var(--fraction) * 360deg),
    rgba(226, 232, 244, 0.08) 0
  );
  position: relative;
}

.goal-ring::before {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: var(--bg);
}

.goal-ring span {
  position: relative;
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.1;
}

.goal-ring small {
  display: block;
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-2);
}

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

.plan-step {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 20px 18px;
  display: flex;
  flex-direction: column;
  min-height: 220px;
}

.plan-step.is-done {
  opacity: 0.68;
}

.plan-step.plan-extra {
  grid-column: 1 / -1;
  min-height: 0;
}

.plan-step .button {
  margin-top: auto;
  align-self: flex-start;
}

.plan-kicker {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 600;
  color: var(--blue);
  margin-bottom: 6px;
}

.plan-step h3 {
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.plan-big {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.plan-stage {
  color: var(--amber);
  font-weight: 500;
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-top: 40px;
}

.section-title-row h2 {
  margin: 0 0 12px;
}

.module-bars {
  display: grid;
  gap: 4px;
}

.module-bar {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) 3fr 52px;
  gap: 16px;
  align-items: center;
  color: var(--text-2);
  font-size: 0.94rem;
  padding: 5px 0;
}

.module-bar:hover {
  text-decoration: none;
  color: var(--text);
}

.bar {
  position: relative;
  display: block;
  height: 8px;
  border-radius: 999px;
  background: rgba(226, 232, 244, 0.08);
  overflow: hidden;
}

.bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--mint);
  border-radius: 999px;
}

.bar-ready {
  position: absolute;
  inset: 0 auto 0 0;
  background: rgba(122, 162, 255, 0.35);
  border-radius: 999px;
}

.module-bar-count {
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
  text-align: right;
}

.legend {
  margin-top: 10px;
}

.legend-swatch {
  display: inline-block;
  width: 12px;
  height: 8px;
  border-radius: 4px;
  margin: 0 4px 0 10px;
}

.legend-swatch:first-child {
  margin-left: 0;
}

.legend-done {
  background: var(--mint);
}

.legend-ready {
  background: rgba(122, 162, 255, 0.5);
}

.content-problems {
  margin-top: 20px;
  color: var(--amber);
  font-size: 0.9rem;
}

/* course map */

.path-module {
  margin-top: 30px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  scroll-margin-top: calc(var(--topbar-h) + 16px);
}

.path-module header h2 {
  margin-top: 0;
}

.path-lessons {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  gap: 2px;
}

.path-lesson a,
.path-lesson > div {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 12px;
  align-items: baseline;
  padding: 9px 12px;
  border-radius: var(--radius-small);
  color: var(--text);
}

.path-lesson a:hover {
  background: rgba(226, 232, 244, 0.05);
  text-decoration: none;
}

.path-lesson.is-locked > div,
.path-lesson.is-unwritten > div {
  color: var(--text-3);
}

.path-lesson-meta {
  font-size: 0.84rem;
  color: var(--text-3);
  white-space: nowrap;
}

.path-lesson .small {
  padding: 0 12px 6px 38px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-3);
  display: inline-block;
  position: relative;
  top: -1px;
}

.status-learned {
  background: var(--mint);
}

.status-in_progress,
.status-read {
  background: var(--amber);
}

.status-available {
  background: var(--blue);
}

.status-unwritten {
  background: transparent;
  border: 1px dashed var(--text-3);
}

/* lesson page */

.lesson-page {
  display: grid;
  grid-template-columns: 230px minmax(0, 800px);
  justify-content: center;
  gap: 48px;
  max-width: 1560px;
  margin: 0 auto;
}

.lesson-page.tutor-open {
  grid-template-columns: 210px minmax(0, 760px) minmax(340px, 430px);
  gap: 36px;
}

.lesson-outline {
  position: sticky;
  top: calc(var(--topbar-h) + 24px);
  align-self: start;
  max-height: calc(100vh - var(--topbar-h) - 48px);
  overflow-y: auto;
  font-size: 0.9rem;
}

.outline-title {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 600;
  color: var(--text-3);
}

.outline-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 1px solid var(--line);
}

.outline-item {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 2px;
  padding: 6px 0 6px 10px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  line-height: 1.35;
  color: var(--text-3);
}

.outline-item a {
  color: var(--text-2);
}

.outline-item.is-done .outline-mark {
  color: var(--mint);
}

.outline-item.is-current {
  border-left-color: var(--amber);
}

.outline-item.is-current .outline-mark,
.outline-item.is-current a {
  color: var(--amber);
  font-weight: 600;
}

.outline-item.is-locked {
  opacity: 0.7;
}

.outline-end a {
  color: var(--blue);
}

.lesson-main {
  min-width: 0;
}

.lesson-head {
  margin-bottom: 28px;
}

.lesson-head h1 {
  font-size: 2.2rem;
}

.lesson-meta {
  color: var(--text-2);
  font-size: 0.95rem;
}

.stepper {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 18px 0 0;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-3);
  font-size: 0.9rem;
}

.step-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(226, 232, 244, 0.07);
}

.step.is-done {
  color: var(--text-2);
}

.step.is-done .step-dot {
  background: var(--mint-soft);
  color: var(--mint);
}

.step.is-current {
  color: var(--text);
  border-color: rgba(255, 196, 107, 0.55);
  background: var(--amber-soft);
}

.step.is-current .step-dot {
  background: var(--amber);
  color: #2b1d04;
}

.step-detail {
  color: var(--amber);
  margin-left: 4px;
}

.intro-card,
.stage-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 18px;
}

.intro-card h2 {
  margin-top: 0;
  font-size: 1.15rem;
}

.objectives li,
.stage-list li {
  margin-bottom: 8px;
}

.stage-hint {
  color: var(--text-2);
}

.skip-row {
  margin: 18px 0 0;
}

.pretest-result {
  background: var(--blue-soft);
  border-radius: var(--radius-small);
  padding: 12px 16px;
}

.lesson-section {
  margin-top: 48px;
  scroll-margin-top: calc(var(--topbar-h) + 20px);
  border-radius: var(--radius);
}

/* A "reread section N" link lands here: a ring that fades, so the eye finds the spot. */
.lesson-section.is-highlighted {
  outline: 2px solid transparent;
  outline-offset: 14px;
  animation: section-highlight 2.6s ease-out;
}

@keyframes section-highlight {
  0%,
  35% {
    outline-color: var(--amber);
    background: rgba(255, 196, 107, 0.04);
    box-shadow: 0 0 0 14px rgba(255, 196, 107, 0.04);
  }

  100% {
    outline-color: transparent;
    background: transparent;
    box-shadow: 0 0 0 14px transparent;
  }
}

.peeked-note {
  margin: 0 0 8px;
  color: var(--violet);
  font-size: 0.88rem;
}

.lesson-section:first-child {
  margin-top: 0;
}

.section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.5rem;
}

.section-number {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 0.9rem;
  font-weight: 700;
}

.lesson-section.is-current .section-number {
  background: var(--amber);
  color: #2b1d04;
}

.lesson-figure {
  margin: 8px 0 22px;
  padding: 16px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.lesson-figure svg {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

.lesson-figure figcaption {
  font-size: 0.9rem;
  color: var(--text-2);
  margin-top: 10px;
}

.ask-row {
  margin: -4px 0 14px;
  font-size: 0.9rem;
}

.check {
  margin-top: 8px;
  padding: 20px 22px;
  background: var(--bg-card);
  border: 1px solid rgba(255, 196, 107, 0.35);
  border-radius: var(--radius);
}

.check-title {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 700;
  color: var(--amber);
  margin-bottom: 10px;
}

.check.is-done {
  padding: 9px 16px;
  background: none;
  border: 1px dashed var(--line-strong);
  color: var(--text-3);
  font-size: 0.9rem;
}

.check-mark {
  color: var(--mint);
  font-weight: 700;
  margin-right: 4px;
}

.locked-note {
  margin-top: 26px;
  padding: 14px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-small);
  color: var(--text-2);
}

.locked-note:empty {
  display: none;
}

.lesson-end {
  margin-top: 44px;
  scroll-margin-top: calc(var(--topbar-h) + 20px);
}

.next-card {
  padding: 22px 24px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 196, 107, 0.4);
  background: var(--amber-soft);
}

.next-card.is-done {
  border-color: rgba(110, 242, 192, 0.35);
  background: var(--mint-soft);
}

.next-title {
  font-size: 1.15rem;
  font-weight: 600;
}

.end-block {
  margin-top: 36px;
  padding-top: 8px;
}

.end-sllim {
  padding: 4px 22px 8px;
  border: 1px solid rgba(110, 242, 192, 0.25);
  border-radius: var(--radius);
  background: rgba(110, 242, 192, 0.05);
}

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

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

.term dt {
  font-weight: 600;
  margin-bottom: 4px;
}

.term dd {
  margin: 0;
  color: var(--text-2);
  font-size: 0.95rem;
}

.term dd p {
  margin: 0;
}

.references li {
  margin-bottom: 12px;
}

/* tutor */

.tutor-side {
  position: sticky;
  top: calc(var(--topbar-h) + 16px);
  align-self: start;
  height: calc(100vh - var(--topbar-h) - 32px);
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.tutor-side-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}

.tutor-side-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
}

.tutor-side-body .tutor {
  flex: 1;
  min-height: 0;
}

.tutor {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tutor-status {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-3);
}

.tutor-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
  padding-right: 4px;
}

.tutor-page .tutor-messages {
  max-height: 58vh;
  min-height: 160px;
}

.tutor-empty {
  color: var(--text-3);
  font-size: 0.92rem;
}

.tutor-message {
  padding: 10px 14px;
  border-radius: var(--radius);
}

.tutor-message .prose {
  font-size: 0.97rem;
  line-height: 1.65;
}

.tutor-message .prose table {
  display: block;
  overflow-x: auto;
  font-size: 0.88rem;
}

.tutor-message .prose td,
.tutor-message .prose th {
  min-width: 120px;
}

.tutor-message .prose p:last-child,
.tutor-message .prose ul:last-child,
.tutor-message .prose ol:last-child {
  margin-bottom: 0;
}

.tutor-user {
  background: var(--blue-soft);
  align-self: flex-end;
  max-width: 88%;
}

.tutor-assistant {
  background: var(--bg-raised);
  border: 1px solid var(--line);
}

.tutor-assistant.is-streaming::after {
  content: "▍";
  color: var(--mint);
  animation: blink 1s steps(2) infinite;
}

@keyframes blink {
  to {
    visibility: hidden;
  }
}

.tutor-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tutor-form textarea,
.explain-input,
.question-input,
.settings-form input,
.settings-form select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-small);
  padding: 10px 12px;
}

.tutor-form textarea:focus,
.explain-input:focus,
.question-input:focus {
  outline: 2px solid var(--blue);
  border-color: transparent;
}

.tutor-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.ask-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 8;
  appearance: none;
  font: inherit;
  font-weight: 600;
  padding: 12px 20px;
  border-radius: 999px;
  border: 1px solid var(--blue);
  color: var(--text);
  background: #18213a;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  cursor: pointer;
}

.ask-fab:hover {
  background: #1e2a4a;
}

body.tutor-sheet-open .ask-fab {
  display: none;
}

/* question */

.question-stem {
  font-size: 1.06rem;
}

.question-stem p:last-child {
  margin-bottom: 0;
}

.mcq-options {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.mcq-option,
.tf-option,
.confidence-option {
  appearance: none;
  font: inherit;
  text-align: left;
  padding: 11px 15px;
  border-radius: var(--radius-small);
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  line-height: 1.5;
}

.mcq-option:hover,
.tf-option:hover,
.confidence-option:hover {
  border-color: var(--blue);
}

.mcq-option.is-selected,
.tf-option.is-selected,
.confidence-option.is-selected {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.tf-option.is-correct,
.mcq-option.is-correct {
  border-color: var(--mint);
  background: var(--mint-soft);
}

.tf-option.is-wrong,
.mcq-option.is-wrong {
  border-color: var(--coral);
  background: var(--coral-soft);
}

.mcq-option p {
  margin: 0;
}

.tf-options {
  display: flex;
  gap: 8px;
  margin: 14px 0;
}

.tf-option {
  flex: 1;
  text-align: center;
}

.numeric-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 14px 0;
}

.numeric-row .question-input {
  max-width: 240px;
  margin: 0;
}

.question-input {
  margin: 14px 0;
}

.confidence {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 6px 0 14px;
}

.confidence-label {
  font-size: 0.88rem;
  color: var(--text-2);
  margin-right: 4px;
}

.confidence-option {
  padding: 5px 12px;
  font-size: 0.86rem;
  border-radius: 999px;
}

.question-actions {
  margin-top: 8px;
}

.verdict {
  margin-top: 14px;
  padding: 16px 18px;
  border-radius: var(--radius-small);
  border: 1px solid var(--line);
  scroll-margin-bottom: 24px;
}

.verdict-correct {
  border-color: rgba(110, 242, 192, 0.4);
  background: var(--mint-soft);
}

.verdict-wrong {
  border-color: rgba(255, 128, 115, 0.4);
  background: var(--coral-soft);
}

.verdict-title {
  font-weight: 600;
  margin-bottom: 6px;
}

.verdict-explanation p:last-child {
  margin-bottom: 0;
}

/* daily recall */

.review {
  max-width: 760px;
}

.review-progress {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.review-progress-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.review-mode {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-2);
}

.streak {
  color: var(--amber);
  font-weight: 600;
}

/*
 * The card is one surface, and the controls sit directly under it, centred,
 * in a bar of fixed height, so Show answer, the four grades, and Next card all
 * land in the same place and the page does not jump when the card flips.
 */

.flash {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 340px;
  padding: 20px 30px 30px;
  border-radius: 20px;
  border: 1px solid var(--line-strong);
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(122, 162, 255, 0.09), transparent 60%),
    radial-gradient(120% 80% at 100% 100%, rgba(110, 242, 192, 0.06), transparent 60%),
    var(--bg-card);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 24px 60px -24px rgba(0, 0, 0, 0.7);
}

.card-meta-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 18px;
  font-size: 0.8rem;
  color: var(--text-3);
}

.card-meta-line a {
  color: var(--text-3);
}

.flash-face {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.flash-front {
  font-size: 1.28rem;
  line-height: 1.5;
  text-align: center;
  transition:
    font-size 200ms ease,
    color 200ms ease;
}

.flash.is-revealed .flash-front {
  font-size: 1.06rem;
  color: var(--text-2);
}

.flash-back {
  padding-top: 18px;
  border-top: 1px dashed var(--line-strong);
  font-size: 1.12rem;
  text-align: center;
}

.flash-front > :last-child,
.flash-back > :last-child {
  margin-bottom: 0;
}

.flash-back ul,
.flash-back ol {
  display: inline-block;
  text-align: left;
}

.hint {
  color: var(--text-3);
  font-size: 0.88rem;
}

.card-enter {
  animation: card-enter 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.flash.is-flipping {
  animation: flash-flip 320ms ease-in-out;
}

.flash.card-leave {
  animation: card-leave 180ms ease-in forwards;
}

@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes card-leave {
  to {
    opacity: 0;
    transform: translateX(-40px) rotate(-1.5deg);
  }
}

/* The back is swapped in at the midpoint, when the card is edge-on. */
@keyframes flash-flip {
  0% {
    transform: perspective(1200px) rotateY(0deg);
  }

  50% {
    transform: perspective(1200px) rotateY(90deg);
  }

  100% {
    transform: perspective(1200px) rotateY(0deg);
  }
}

.flash-controls {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 10px;
  min-height: 92px;
  margin-top: 16px;
}

.flash-controls .reveal,
.berserk-next {
  min-width: 260px;
  padding: 13px 22px;
  font-size: 1rem;
}

kbd {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.7em;
  font-weight: 500;
  line-height: 1.5;
  padding: 0 6px;
  border-radius: 5px;
  border: 1px solid currentColor;
  opacity: 0.55;
  vertical-align: 0.1em;
}

.grade-row {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  animation: card-enter 200ms ease-out;
}

.grade {
  appearance: none;
  font: inherit;
  display: grid;
  justify-items: center;
  gap: 1px;
  padding: 10px 6px 9px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  border-top: 3px solid var(--grade-color);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease;
}

.grade-again {
  --grade-color: var(--coral);
  --grade-soft: var(--coral-soft);
}

.grade-hard {
  --grade-color: var(--amber);
  --grade-soft: var(--amber-soft);
}

.grade-good {
  --grade-color: var(--blue);
  --grade-soft: var(--blue-soft);
}

.grade-easy {
  --grade-color: var(--mint);
  --grade-soft: var(--mint-soft);
}

.grade:hover:not(:disabled) {
  transform: translateY(-2px);
  background: var(--grade-soft);
  border-color: var(--grade-color);
}

.grade.is-chosen,
.grade.is-chosen:disabled {
  opacity: 1;
  background: var(--grade-soft);
  border-color: var(--grade-color);
}

.grade-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.grade-legend-line {
  font-size: 0.74rem;
  color: var(--text-3);
}

.grade-when {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--grade-color);
  font-variant-numeric: tabular-nums;
}

/* Berserk recall: coral, because it is the hard mode. */

.flash-berserk {
  border-color: rgba(255, 128, 115, 0.35);
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(255, 128, 115, 0.1), transparent 60%),
    radial-gradient(120% 80% at 100% 100%, rgba(255, 196, 107, 0.07), transparent 60%),
    var(--bg-card);
}

.berserk-input {
  width: 100%;
  resize: vertical;
  font: inherit;
  font-size: 1.02rem;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--text);
}

.berserk-input:focus {
  outline: none;
  border-color: var(--coral);
  box-shadow: 0 0 0 3px var(--coral-soft);
}

.berserk-input:disabled {
  opacity: 0.75;
  cursor: default;
}

.berserk-actions {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

/* Room for the chip, one line of feedback, and the next date, so Next card does not jump when the verdict lands. */
.berserk-verdict {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: flex-start;
  justify-content: center;
  min-height: 84px;
  gap: 8px 12px;
  text-align: center;
  animation: card-enter 220ms ease-out;
}

.verdict-chip {
  display: inline-flex;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  font-weight: 600;
  font-size: 0.9rem;
}

.verdict-chip.is-pending {
  color: var(--text-2);
  animation: pulse 1.2s ease-in-out infinite;
}

.verdict-chip.is-right {
  color: var(--mint);
  border-color: var(--mint);
  background: var(--mint-soft);
}

.verdict-chip.is-partial {
  color: var(--amber);
  border-color: var(--amber);
  background: var(--amber-soft);
}

.verdict-chip.is-wrong {
  color: var(--coral);
  border-color: var(--coral);
  background: var(--coral-soft);
}

.verdict-feedback {
  flex-basis: 100%;
  color: var(--text-2);
  font-size: 0.95rem;
}

@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}

.result-list {
  list-style: none;
  padding: 0;
  margin: 18px 0;
  display: grid;
  gap: 8px;
}

.result-list li {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-small);
  background: var(--bg-card);
  border: 1px solid var(--line);
}

.result-mark {
  font-weight: 700;
  text-align: center;
  color: var(--text-3);
}

.result-list .is-right .result-mark {
  color: var(--mint);
}

.result-list .is-partial .result-mark {
  color: var(--amber);
}

.result-list .is-wrong .result-mark {
  color: var(--coral);
}

/* choosing a mode */

.review-choose {
  max-width: 860px;
  margin: 0 auto;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.mode-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 24px;
  border-radius: 20px;
  border: 1px solid var(--line-strong);
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(122, 162, 255, 0.1), transparent 60%), var(--bg-card);
  color: var(--text);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.mode-card:hover {
  text-decoration: none;
  transform: translateY(-3px);
  border-color: var(--blue);
  box-shadow: 0 18px 40px -20px rgba(122, 162, 255, 0.45);
}

.mode-card h2 {
  margin: 4px 0 0;
  font-size: 1.3rem;
}

.mode-card p {
  margin: 0;
  color: var(--text-2);
}

.mode-card .mode-xp {
  margin-top: auto;
  padding-top: 10px;
  font-size: 0.88rem;
  color: var(--mint);
}

.mode-icon {
  font-size: 2rem;
  line-height: 1;
}

.mode-berserk {
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(255, 128, 115, 0.13), transparent 60%), var(--bg-card);
}

.mode-berserk:hover {
  border-color: var(--coral);
  box-shadow: 0 18px 40px -20px rgba(255, 128, 115, 0.5);
}

.mode-card.is-disabled {
  opacity: 0.6;
}

.mode-card.is-disabled:hover {
  transform: none;
  box-shadow: none;
}

.grade-chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.88rem;
  border: 1px solid var(--line-strong);
}

.grade-chip.grade-again {
  border-color: var(--coral);
  color: var(--coral);
}

.grade-chip.grade-hard {
  border-color: var(--amber);
  color: var(--amber);
}

.grade-chip.grade-good {
  border-color: var(--blue);
  color: var(--blue);
}

.grade-chip.grade-easy {
  border-color: var(--mint);
  color: var(--mint);
}

.keys {
  margin: 14px 0 0;
  text-align: center;
  color: var(--text-3);
  font-size: 0.86rem;
}

.cloze {
  font-size: 1.15rem;
}

.cloze-blank {
  display: inline-block;
  min-width: 70px;
  padding: 0 8px;
  border-bottom: 2px solid var(--amber);
  color: var(--amber);
  text-align: center;
}

.cloze-answer {
  color: var(--mint);
  font-weight: 600;
}

.quiz-result h1 {
  font-size: 2.6rem;
}

.quiz-result.is-passed h1 {
  color: var(--mint);
}

.quiz-result.is-failed h1 {
  color: var(--coral);
}

.verdict-line {
  font-size: 1.12rem;
}

/* teach it back */

.explain-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.explain-prompt {
  font-size: 1.4rem;
}

.explain-prompt p {
  margin: 0;
}

.explain-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.rubric-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 6px 0;
}

.rubric-item input {
  margin-top: 6px;
}

.rubric-item p {
  margin: 0;
}

.rubric-result {
  list-style: none;
  padding: 0;
}

.rubric-result li {
  display: flex;
  gap: 10px;
  padding: 6px 0;
}

.rubric-result p {
  margin: 0;
}

.rubric-result .mark {
  width: 22px;
  flex: none;
  font-weight: 700;
}

.is-covered .mark {
  color: var(--mint);
}

.is-missing .mark {
  color: var(--coral);
}

.explain-graded {
  margin-top: 20px;
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-card);
}

.explain-graded.is-passed h2 {
  color: var(--mint);
  margin-top: 0;
}

.explain-graded.is-failed h2 {
  color: var(--amber);
  margin-top: 0;
}

.feedback {
  padding: 12px 16px;
  background: var(--bg-raised);
  border-radius: var(--radius-small);
}

.model-answer {
  margin: 12px 0;
}

.model-answer summary {
  cursor: pointer;
  color: var(--blue);
}

.explain-history details {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

/* how it works */

.guide h1 {
  font-size: 2.3rem;
}

.guide-figure {
  margin: 24px 0 8px;
  padding: 20px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.guide-figure svg {
  width: 100%;
  height: auto;
  display: block;
}

.day-steps li {
  margin-bottom: 10px;
  line-height: 1.6;
}

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

.part {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.part h3 {
  color: var(--mint);
  margin-bottom: 8px;
}

.part p {
  margin-bottom: 8px;
}

.part-why {
  color: var(--text-2);
  font-size: 0.94rem;
}

/* progress */

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 16px 0 8px;
}

.tile {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: grid;
  gap: 4px;
}

.tile-value {
  font-size: 1.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tile-label {
  color: var(--text-2);
  font-size: 0.88rem;
}

.forecast {
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  gap: 6px;
  height: 160px;
  align-items: end;
}

.forecast-col {
  display: grid;
  grid-template-rows: 1fr auto auto;
  height: 100%;
  align-items: end;
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-3);
}

.forecast-bar {
  display: block;
  background: var(--blue);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  align-self: end;
}

.forecast-count {
  color: var(--text-2);
}

.calendar {
  display: grid;
  grid-template-columns: repeat(28, 1fr);
  gap: 4px;
}

.cal-day {
  aspect-ratio: 1;
  border-radius: 3px;
  background: rgba(226, 232, 244, 0.06);
}

.cal-day.level-1 {
  background: rgba(110, 242, 192, 0.3);
}

.cal-day.level-2 {
  background: rgba(110, 242, 192, 0.5);
}

.cal-day.level-3 {
  background: rgba(110, 242, 192, 0.75);
}

.cal-day.level-4 {
  background: var(--mint);
}

table.data td.neg {
  color: var(--coral);
}

table.data td.pos {
  color: var(--mint);
}

/* settings */

.settings-form {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.settings-form label {
  display: grid;
  gap: 6px;
}

.settings-form label .small {
  display: block;
}

.settings-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* card browser */

.card-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 10px;
}

.card-row {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
}

.card-row.is-suspended {
  opacity: 0.5;
}

.card-row .prose p:last-child {
  margin-bottom: 0;
}

.card-back {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  color: var(--text-2);
}

.card-meta {
  margin-top: 8px;
}

/* player bar, XP pop, toasts */

.player {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(226, 232, 244, 0.03);
  color: var(--text-2);
  font-size: 0.82rem;
  white-space: nowrap;
}

.player:empty {
  display: none;
}

.player:hover {
  text-decoration: none;
  color: var(--text);
  border-color: var(--line-strong);
}

.player-level {
  padding: 1px 9px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  font-weight: 700;
}

.player-bar {
  position: relative;
  width: 84px;
  height: 6px;
  border-radius: 999px;
  background: rgba(226, 232, 244, 0.1);
  overflow: hidden;
}

.player-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--amber), var(--mint));
  transition: width 600ms ease;
}

.player-rested {
  color: var(--violet);
  font-weight: 600;
}

.xp-pop {
  position: fixed;
  left: 50%;
  bottom: 36px;
  z-index: 30;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid rgba(110, 242, 192, 0.45);
  background: rgba(13, 16, 23, 0.94);
  box-shadow: 0 10px 30px -10px rgba(110, 242, 192, 0.45);
  pointer-events: none;
  transform: translateX(-50%);
  animation: xp-pop 1.9s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.xp-amount {
  color: var(--mint);
  font-weight: 700;
  font-size: 1.08rem;
  font-variant-numeric: tabular-nums;
}

.xp-note {
  color: var(--violet);
  font-size: 0.8rem;
}

.xp-pop.is-zero {
  border-color: var(--line-strong);
  box-shadow: none;
}

.xp-pop.is-zero .xp-amount,
.xp-pop.is-zero .xp-note {
  color: var(--text-3);
}

@keyframes xp-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, 12px) scale(0.9);
  }

  12% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1.06);
  }

  20% {
    transform: translate(-50%, 0) scale(1);
  }

  75% {
    opacity: 1;
    transform: translate(-50%, -10px);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -26px);
  }
}

.toasts {
  position: fixed;
  top: calc(var(--topbar-h) + 14px);
  right: 18px;
  z-index: 30;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: rgba(18, 22, 31, 0.97);
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.8);
  pointer-events: auto;
  animation: toast-in 320ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.toast.is-leaving {
  animation: toast-out 380ms ease-in forwards;
}

.toast-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--mint-soft);
  color: var(--mint);
  font-size: 1.4rem;
}

.toast-text {
  display: grid;
  gap: 1px;
  font-size: 0.86rem;
  line-height: 1.35;
  color: var(--text-2);
}

.toast-text strong {
  color: var(--text);
  font-size: 0.92rem;
}

.toast-xp {
  color: var(--mint);
  font-weight: 700;
  font-size: 0.86rem;
  white-space: nowrap;
}

.toast-achievement {
  border-color: rgba(255, 196, 107, 0.55);
  box-shadow:
    0 0 0 1px rgba(255, 196, 107, 0.15),
    0 18px 46px -14px rgba(255, 196, 107, 0.4);
}

.toast-achievement .toast-icon {
  background: var(--amber-soft);
  animation: achievement-shine 900ms ease-out;
}

.toast-achievement strong {
  color: var(--amber);
}

.toast-level {
  border-color: rgba(196, 167, 255, 0.55);
}

.toast-level .toast-icon {
  background: var(--violet-soft);
  color: var(--violet);
}

.toast-level strong {
  color: var(--violet);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(30px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateX(30px);
  }
}

@keyframes achievement-shine {
  0% {
    transform: scale(0.6) rotate(-12deg);
  }

  60% {
    transform: scale(1.15) rotate(4deg);
  }

  100% {
    transform: none;
  }
}

/* today: rested, quests, and things to do with spare time */

.rested-line {
  margin: 0 0 6px;
  color: var(--violet);
}

.rested-line.muted {
  color: var(--text-3);
}

.today-extras {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
  gap: 18px;
  margin-top: 32px;
}

.quests-card,
.play-card {
  padding: 20px 22px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--bg-raised);
}

.quests-card h2,
.play-card h2 {
  margin-top: 0;
  font-size: 1.15rem;
}

.quest-list {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  display: grid;
  gap: 10px;
}

.quest {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-card);
}

.quest-check {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  color: #05281c;
  font-size: 0.78rem;
  font-weight: 700;
}

.quest.is-done {
  border-color: rgba(110, 242, 192, 0.3);
}

.quest.is-done .quest-check {
  background: var(--mint);
  border-color: var(--mint);
  animation: achievement-shine 500ms ease-out;
}

.quest-body {
  display: grid;
  gap: 6px;
}

.quest-body .bar {
  height: 5px;
}

.quest-title {
  font-size: 0.92rem;
  line-height: 1.35;
}

.quest.is-done .quest-title {
  color: var(--text-2);
}

.quest-count {
  color: var(--text-3);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.quest-xp {
  color: var(--amber);
  font-size: 0.8rem;
  font-weight: 600;
}

.play-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.play-tile {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 2px 12px;
  align-content: start;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--text);
  transition:
    transform 140ms ease,
    border-color 140ms ease;
}

.play-tile:hover {
  text-decoration: none;
  transform: translateY(-2px);
  border-color: var(--tile-accent, var(--blue));
}

.tile-icon {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--tile-soft, var(--blue-soft));
  font-size: 1.4rem;
}

.tile-title {
  font-weight: 600;
  font-size: 0.94rem;
  line-height: 1.3;
}

.tile-note {
  color: var(--text-2);
  font-size: 0.82rem;
  line-height: 1.4;
}

.tile-repair {
  --tile-accent: var(--coral);
  --tile-soft: var(--coral-soft);
}

.tile-peek {
  --tile-accent: var(--violet);
  --tile-soft: var(--violet-soft);
}

.tile-practice {
  --tile-accent: var(--mint);
  --tile-soft: var(--mint-soft);
}

/* course map: three stars a lesson, for read, mastered, taught back */

.stars {
  margin-right: 6px;
  color: var(--amber);
  font-size: 0.82rem;
  letter-spacing: 1px;
}

.stars-empty {
  color: rgba(226, 232, 244, 0.18);
}

/* quiz: intro, cooldown, card, result */

.quiz-progress {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.quiz-progress .eyebrow {
  margin: 0;
}

.quiz-card,
.peek-card {
  padding: 24px 26px;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: var(--bg-card);
  box-shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.7);
}

.cooldown-card {
  margin: 20px 0;
  padding: 18px 22px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 196, 107, 0.3);
  background: var(--amber-soft);
}

.cooldown-title {
  margin-bottom: 6px;
  color: var(--amber);
  font-weight: 600;
}

.quiz-start-row {
  margin-top: 20px;
}

.score-ring {
  --fraction: 0;
  --ring: var(--mint);
  display: grid;
  place-items: center;
  width: 148px;
  height: 148px;
  margin: 8px 0 18px;
  border-radius: 50%;
  background:
    radial-gradient(closest-side, var(--bg) 79%, transparent 80%),
    conic-gradient(var(--ring) calc(var(--fraction) * 360deg), rgba(226, 232, 244, 0.08) 0deg);
  animation: card-enter 500ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.score-ring.is-failed {
  --ring: var(--coral);
}

.score-ring span {
  display: grid;
  text-align: center;
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.1;
}

.score-ring small {
  color: var(--text-3);
  font-size: 0.8rem;
  font-weight: 500;
}

.xp-line {
  color: var(--mint);
  font-weight: 600;
  font-size: 1.05rem;
}

.missed {
  margin-top: 28px;
}

.missed-list {
  display: grid;
  gap: 12px;
  padding-left: 22px;
}

.missed-list li {
  padding: 12px 14px;
  border-radius: var(--radius-small);
  border: 1px solid var(--line);
  border-left: 3px solid var(--coral);
  background: var(--bg-card);
}

.missed-stem {
  margin-bottom: 4px;
}

.missed-answer {
  color: var(--text-2);
}

.section-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.88rem;
}

/* repair */

.readiness {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin: 14px 0 18px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-card);
}

.readiness-label {
  font-weight: 600;
  font-size: 0.9rem;
}

.readiness-value {
  color: var(--mint);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.readiness .bar-fill {
  transition: width 500ms ease;
}

.repair-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 14px;
}

.repair-item {
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  border-left: 3px solid var(--coral);
  background: var(--bg-card);
  transition: border-color 300ms ease;
}

.repair-item.is-repaired {
  border-left-color: var(--mint);
}

.repair-stem > :last-child {
  margin-bottom: 0;
}

.repair-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.button.small-button,
button.small-button {
  padding: 7px 14px;
  font-size: 0.86rem;
}

.repaired-mark {
  color: var(--mint);
  font-weight: 600;
}

.repair-host:not(:empty) {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line-strong);
}

/* sneak peek: violet, because it is a look ahead */

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

.peek-head .eyebrow {
  margin: 0;
}

.peek-dots {
  display: flex;
  gap: 6px;
}

.peek-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(226, 232, 244, 0.12);
  transition:
    background 200ms ease,
    transform 200ms ease;
}

.peek-dot.is-done {
  background: var(--violet);
}

.peek-dot.is-current {
  background: transparent;
  box-shadow: 0 0 0 2px var(--violet);
  transform: scale(1.15);
}

.peek-from {
  margin: 14px 0;
  color: var(--text-2);
}

.peek-card {
  margin-bottom: 14px;
  border-color: rgba(196, 167, 255, 0.35);
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(196, 167, 255, 0.1), transparent 60%), var(--bg-card);
}

/* teach it back: pick one listener */

.teach-choices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.teach-choice {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: var(--bg-card);
  color: var(--text);
  transition:
    transform 140ms ease,
    border-color 140ms ease;
}

.teach-choice:hover {
  text-decoration: none;
  transform: translateY(-2px);
  border-color: var(--violet);
}

.teach-to {
  color: var(--text-3);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.teach-choice strong {
  font-size: 1.05rem;
}

.teach-prompt {
  color: var(--text-2);
  font-size: 0.88rem;
}

.teach-prompt p {
  margin: 4px 0 0;
}

.teach-best {
  margin-top: auto;
  padding-top: 6px;
  color: var(--mint);
  font-size: 0.8rem;
}

.teach-best.is-low {
  color: var(--amber);
}

/* progress: the player card and achievements */

.player-card {
  margin-bottom: 28px;
  padding: 22px 24px;
  border-radius: 20px;
  border: 1px solid var(--line-strong);
  background:
    radial-gradient(120% 90% at 0% 0%, rgba(255, 196, 107, 0.09), transparent 60%), var(--bg-card);
}

.player-head {
  display: flex;
  align-items: center;
  gap: 20px;
}

.player-head h1 {
  margin-bottom: 4px;
  font-size: 1.7rem;
}

.player-head p {
  margin-bottom: 4px;
}

.level-badge {
  flex: none;
  display: grid;
  place-content: center;
  width: 88px;
  height: 88px;
  border-radius: 24px;
  border: 1px solid rgba(255, 196, 107, 0.5);
  background: linear-gradient(145deg, rgba(255, 196, 107, 0.25), rgba(110, 242, 192, 0.12));
  box-shadow: 0 10px 30px -12px rgba(255, 196, 107, 0.5);
  text-align: center;
}

.level-badge span {
  color: var(--amber);
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
}

.level-badge small {
  color: var(--text-2);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.player-info {
  flex: 1;
  min-width: 0;
}

.big-bar {
  height: 12px;
  margin: 8px 0;
}

.big-bar .bar-fill {
  background: linear-gradient(90deg, var(--amber), var(--mint));
}

.xp-days {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  align-items: end;
  gap: 4px;
  height: 70px;
  margin-top: 18px;
}

.xp-day {
  display: flex;
  align-items: flex-end;
  height: 100%;
  border-radius: 4px;
  background: rgba(226, 232, 244, 0.04);
}

.xp-day-bar {
  display: block;
  width: 100%;
  min-height: 3px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--mint), rgba(110, 242, 192, 0.35));
}

.achievement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
}

.achievement {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  opacity: 0.55;
}

.achievement.is-unlocked {
  opacity: 1;
  border-color: rgba(255, 196, 107, 0.4);
  background:
    radial-gradient(120% 90% at 0% 0%, rgba(255, 196, 107, 0.1), transparent 60%), var(--bg-card);
}

.achievement-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(226, 232, 244, 0.06);
  font-size: 1.4rem;
  filter: grayscale(1);
}

.achievement.is-unlocked .achievement-icon {
  background: var(--amber-soft);
  filter: none;
}

.achievement-text {
  display: grid;
  color: var(--text-2);
  font-size: 0.84rem;
  line-height: 1.35;
}

.achievement-text strong {
  color: var(--text);
  font-size: 0.92rem;
}

.achievement.is-unlocked .achievement-text strong {
  color: var(--amber);
}

.achievement-xp {
  color: var(--text-3);
  font-size: 0.78rem;
  white-space: nowrap;
}

/* mistake review: the miss on the left, the passage that teaches it on the right */

.mistake-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 14px 0 6px;
}

.mistake-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 14px;
}

.mistake-focus {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
  gap: 18px;
}

.mistake-card,
.mistake-passage {
  padding: 22px 24px;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: var(--bg-card);
}

.mistake-card {
  border-top: 3px solid var(--coral);
}

.mistake-passage {
  position: sticky;
  top: calc(var(--topbar-h) + 16px);
  border-top: 3px solid var(--blue);
  background:
    radial-gradient(120% 70% at 100% 0%, rgba(122, 162, 255, 0.08), transparent 60%), var(--bg-card);
}

.mistake-passage h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 1.15rem;
}

.passage-body {
  max-height: calc(100vh - var(--topbar-h) - 220px);
  min-height: 160px;
  overflow-y: auto;
  padding-right: 6px;
  font-size: 0.98rem;
}

.passage-link {
  display: inline-block;
  margin-top: 12px;
  font-size: 0.9rem;
}

.mistake-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin: 0 0 14px;
  color: var(--text-3);
  font-size: 0.82rem;
}

.mistake-meta a {
  color: var(--text-2);
}

.source-chip {
  padding: 1px 9px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--text-2);
  font-weight: 600;
}

.source-quiz,
.source-mixed,
.source-repair {
  border-color: rgba(255, 128, 115, 0.5);
  color: var(--coral);
}

.source-recall,
.source-berserk {
  border-color: rgba(110, 242, 192, 0.45);
  color: var(--mint);
}

.source-pretest,
.source-peek {
  border-color: rgba(196, 167, 255, 0.5);
  color: var(--violet);
}

.source-check,
.source-review {
  border-color: rgba(255, 196, 107, 0.5);
  color: var(--amber);
}

.mistake-label {
  margin: 0 0 4px;
  color: var(--text-3);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mistake-stem {
  font-size: 1.08rem;
}

.mistake-stem > :last-child,
.mistake-back > :last-child,
.mistake-explanation > :last-child {
  margin-bottom: 0;
}

.mistake-back {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-small);
  background: var(--mint-soft);
}

.mistake-options {
  list-style: none;
  display: grid;
  gap: 6px;
  margin: 14px 0;
  padding: 0;
}

.mistake-options li {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-small);
  border: 1px solid var(--line);
  color: var(--text-2);
}

.mistake-options li.is-correct {
  border-color: var(--mint);
  background: var(--mint-soft);
  color: var(--text);
}

.mistake-options li.is-given {
  border-color: var(--coral);
  background: var(--coral-soft);
  color: var(--text);
}

.option-mark {
  font-weight: 700;
}

.is-correct .option-mark {
  color: var(--mint);
}

.is-given .option-mark {
  color: var(--coral);
}

.mistake-answers {
  display: grid;
  gap: 6px;
  margin: 14px 0;
}

.mistake-given,
.mistake-correct {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 0 0 10px;
  padding: 8px 12px;
  border-radius: var(--radius-small);
}

.mistake-given {
  background: var(--coral-soft);
}

.mistake-correct {
  background: var(--mint-soft);
}

.mistake-given span,
.mistake-correct span:first-child {
  color: var(--text-3);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mistake-explanation {
  margin: 0 0 16px;
  color: var(--text-2);
}

.mistake-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 6px 0 8px;
}

.mistake-retry-host:not(:empty) {
  margin-top: 14px;
  padding-top: 16px;
  border-top: 1px dashed var(--line-strong);
}

.tile-mistakes {
  --tile-accent: var(--coral);
  --tile-soft: var(--coral-soft);
}

/* narrower screens */

@media (max-width: 1180px) {
  .lesson-page.tutor-open {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 400px);
  }

  .lesson-page.tutor-open .lesson-outline {
    display: none;
  }
}

@media (max-width: 1000px) {
  .lesson-page,
  .lesson-page.tutor-open {
    grid-template-columns: minmax(0, 1fr);
    max-width: 820px;
  }

  .lesson-outline {
    display: none;
  }

  .tutor-side {
    position: fixed;
    top: var(--topbar-h);
    right: 0;
    bottom: 0;
    width: min(440px, 100vw);
    height: auto;
    z-index: 12;
    border-radius: 0;
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.5);
  }

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

  .plan-step {
    min-height: 0;
  }

  .part-grid,
  .terms,
  .today-extras,
  .mistake-focus {
    grid-template-columns: 1fr;
  }

  .mistake-passage {
    position: static;
  }

  .passage-body {
    max-height: 420px;
  }
}

@media (max-width: 760px) {
  main {
    padding: 20px 16px 96px;
  }

  .topbar {
    padding: 0 12px;
  }

  .brand {
    display: none;
  }

  .hero {
    flex-direction: column;
  }

  h1,
  .lesson-head h1,
  .hero h1 {
    font-size: 1.7rem;
  }

  .module-bar {
    grid-template-columns: 1fr auto;
  }

  .module-bar .bar {
    grid-column: 1 / -1;
  }

  .forecast {
    grid-template-columns: repeat(7, 1fr);
    height: auto;
  }

  .forecast-col {
    height: 80px;
  }

  .calendar {
    grid-template-columns: repeat(14, 1fr);
  }

  .flash {
    min-height: 300px;
    padding: 18px 18px 22px;
  }

  .flash-front {
    font-size: 1.15rem;
  }

  .grade-row {
    gap: 6px;
  }

  .grade kbd,
  .player-bar {
    display: none;
  }

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

  .player-head {
    align-items: flex-start;
  }

  .level-badge {
    width: 64px;
    height: 64px;
    border-radius: 18px;
  }

  .level-badge span {
    font-size: 1.6rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tutor-assistant.is-streaming::after,
  .card-enter,
  .flash.is-flipping,
  .flash.card-leave,
  .grade-row,
  .berserk-verdict,
  .verdict-chip.is-pending,
  .xp-pop,
  .toast,
  .toast.is-leaving,
  .toast-achievement .toast-icon,
  .quest.is-done .quest-check,
  .score-ring {
    animation: none;
  }

  .lesson-section.is-highlighted {
    animation: none;
    outline-color: var(--amber);
  }

  .grade,
  .mode-card,
  .play-tile,
  .teach-choice,
  .player-fill {
    transition: none;
  }
}

/* Sign-in page, served by serve.ts only when the server requires a password. */
.login {
  max-width: 360px;
  margin: 14vh auto 0;
  padding: 0 20px;
}

.login form {
  display: grid;
  gap: 14px;
  margin-top: 28px;
}

.login label {
  display: grid;
  gap: 6px;
  color: var(--text-2);
}

.login input {
  font: inherit;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px 12px;
}

.login button {
  font: inherit;
  font-weight: 500;
  color: var(--bg);
  background: var(--mint);
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
}
