:root {
  --paper: #f4efe5;
  --paper-strong: #fffdf8;
  --ink: #18313a;
  --muted: #68777a;
  --line: rgba(24, 49, 58, 0.16);
  --saffron: #d79022;
  --saffron-deep: #9b5b08;
  --pomegranate: #bd4a3d;
  --pistachio: #708b5a;
  --turquoise: #176d75;
  --shadow: 0 24px 80px rgba(36, 46, 44, 0.14);
  --rail: 308px;
  --topbar: 72px;
  color-scheme: light;
}

[data-theme="dark"] {
  --paper: #13282d;
  --paper-strong: #1a3338;
  --ink: #f5efe2;
  --muted: #a6b8b7;
  --line: rgba(242, 233, 216, 0.16);
  --saffron: #e6a642;
  --saffron-deep: #f4c66f;
  --pomegranate: #e17b6e;
  --pistachio: #9ab381;
  --turquoise: #6bbcc0;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
  background: var(--paper);
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: "Manrope", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
button:focus-visible, a:focus-visible, canvas:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--saffron) 72%, white);
  outline-offset: 3px;
}

.fa-text {
  font-family: "Vazirmatn", Tahoma, sans-serif;
  direction: rtl;
  unicode-bidi: isolate;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--saffron-deep);
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  background: var(--paper);
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.loading-screen.is-hidden { opacity: 0; visibility: hidden; }
.loading-screen p { margin: 0; color: var(--muted); font-size: 0.82rem; }
.loading-mark, .brand-mark {
  display: grid;
  place-items: center;
  font-family: "Vazirmatn", sans-serif;
  color: white;
  background: var(--pomegranate);
  border-radius: 42% 58% 48% 52% / 55% 42% 58% 45%;
}
.loading-mark { width: 64px; height: 64px; font-size: 2rem; animation: breathe 1.3s ease-in-out infinite; }

.course-shell {
  min-height: 100svh;
}

.course-rail {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  width: var(--rail);
  flex-direction: column;
  padding: 24px 22px 20px;
  overflow: hidden;
  background: var(--paper-strong);
  border-right: 1px solid var(--line);
  transition: transform .32s cubic-bezier(.2,.75,.25,1), visibility .32s;
}

.brand-block {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  gap: 11px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark { width: 38px; height: 38px; font-size: 1.32rem; }
.brand > span:last-child { display: flex; align-items: baseline; font-size: 1.05rem; letter-spacing: -0.04em; }
.brand small { font-size: 0.72rem; font-weight: 500; color: var(--muted); letter-spacing: -0.02em; }

.rail-close { display: none !important; }

.rail-intro { padding: 47px 4px 28px; }
.rail-intro h1 {
  margin: 0;
  max-width: 220px;
  font-size: clamp(2.1rem, 3vw, 3rem);
  line-height: 0.98;
  letter-spacing: -0.07em;
}
.rail-intro > p:last-child {
  max-width: 235px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.65;
}

.rail-progress { padding: 0 4px 20px; }
.rail-progress > div:first-child {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.7rem;
}
.rail-progress #railProgressText { color: var(--ink); font-weight: 700; }
.progress-track {
  height: 3px;
  margin-top: 9px;
  overflow: hidden;
  background: var(--line);
  border-radius: 9px;
}
.progress-track i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--pomegranate);
  transition: width 0.45s cubic-bezier(.2, .75, .25, 1);
}

.page-list {
  margin: 0 -4px;
  padding: 0 4px 12px;
  overflow: auto;
  scrollbar-width: thin;
}

.page-group-label {
  margin: 18px 0 7px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.page-link {
  position: relative;
  display: grid;
  grid-template-columns: 28px 1fr 15px;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 36px;
  padding: 7px 8px;
  color: var(--muted);
  text-align: left;
  border: 0;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
.page-link:hover { color: var(--ink); transform: translateX(2px); }
.page-link.is-active { color: var(--ink); background: color-mix(in srgb, var(--saffron) 13%, transparent); }
.page-link .page-no { font-size: 0.66rem; font-variant-numeric: tabular-nums; }
.page-link .page-name { overflow: hidden; font-size: 0.72rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.page-link .page-state {
  width: 7px;
  height: 7px;
  justify-self: end;
  border: 1px solid var(--line);
  border-radius: 50%;
}
.page-link.is-complete .page-state { background: var(--pistachio); border-color: var(--pistachio); }

.rail-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 4px 0;
  border-top: 1px solid var(--line);
}
.rail-footer span { color: var(--muted); font-size: 0.52rem; text-align: right; }

.workspace {
  min-width: 0;
  margin-left: var(--rail);
  transition: margin-left .32s cubic-bezier(.2,.75,.25,1);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  height: var(--topbar);
  align-items: center;
  justify-content: space-between;
  padding: 0 34px;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.menu-button, .mobile-brand { display: none !important; }
.menu-button { align-content: center; gap: 5px; border: 0; }
.menu-button span { width: 17px; height: 1px; background: currentColor; }
.topbar-meta { display: flex; gap: 13px; align-items: baseline; }
.topbar-meta span { color: var(--muted); font-size: 0.68rem; letter-spacing: 0.11em; text-transform: uppercase; }
.topbar-meta strong { font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.topbar-actions { display: flex; gap: 9px; align-items: center; }
.word-deck-toggle-short { display: none; }

.icon-button, .soft-button, .text-button, .primary-button {
  border: 0;
  cursor: pointer;
}
.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
}
.icon-button:hover { border-color: var(--saffron); }
.soft-button {
  min-height: 38px;
  padding: 0 15px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 99px;
  font-size: 0.69rem;
  font-weight: 700;
}
.soft-button[aria-pressed="false"] { color: var(--muted); }
.text-button {
  padding: 0;
  color: var(--muted);
  background: transparent;
  font-size: 0.66rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.text-button:hover { color: var(--pomegranate); }

.scene {
  position: relative;
  isolation: isolate;
  display: flex;
  min-height: clamp(520px, calc(100svh - var(--topbar)), 760px);
  align-items: flex-end;
  overflow: hidden;
  background: #355a58;
}
.scene img {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transform: scale(1.015);
}
.scene.is-entering img { animation: sceneIn 0.8s cubic-bezier(.2,.7,.2,1) both; }
.scene-shade {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(90deg, rgba(12, 31, 34, 0.78) 0%, rgba(12, 31, 34, 0.43) 43%, rgba(12, 31, 34, 0.05) 75%), linear-gradient(0deg, rgba(12, 31, 34, 0.42), transparent 55%);
}
.scene-index {
  position: absolute;
  top: 24px;
  right: 30px;
  color: rgba(255,255,255,.8);
  font-size: clamp(4rem, 9vw, 8rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.08em;
  mix-blend-mode: soft-light;
}
.scene-copy {
  width: min(640px, 72%);
  padding: 58px clamp(34px, 6vw, 82px) 62px;
  color: white;
}
.scene.is-entering .scene-copy > * { animation: copyIn 0.55s cubic-bezier(.2,.7,.2,1) both; }
.scene.is-entering .scene-copy > *:nth-child(2) { animation-delay: .05s; }
.scene.is-entering .scene-copy > *:nth-child(3) { animation-delay: .1s; }
.scene.is-entering .scene-copy > *:nth-child(4) { animation-delay: .15s; }
.scene-kicker {
  margin: 0 0 13px;
  color: #f5c976;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.scene-copy h2 {
  margin: 0;
  max-width: 610px;
  font-size: clamp(3.2rem, 7vw, 6.8rem);
  line-height: 0.92;
  letter-spacing: -0.075em;
}
.scene-copy > p:not(.scene-kicker) {
  max-width: 510px;
  margin: 22px 0 28px;
  color: rgba(255,255,255,.84);
  font-size: clamp(.86rem, 1.2vw, 1rem);
  line-height: 1.7;
}
.primary-button {
  display: inline-flex;
  min-height: 48px;
  gap: 10px;
  align-items: center;
  padding: 0 21px;
  color: #18313a;
  background: #f5c976;
  border-radius: 99px;
  font-size: 0.73rem;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(0,0,0,.15);
  transition: transform .2s ease, background .2s ease;
}
.primary-button:hover { transform: translateY(-2px); background: white; }

.word-deck {
  min-height: calc(100svh - var(--topbar));
  padding: clamp(24px, 4vw, 48px) clamp(28px, 6vw, 84px) clamp(28px, 5vw, 58px);
  overflow: hidden;
  background: var(--paper);
}
.word-deck-inner {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: clamp(16px, 2.3vh, 24px);
  width: min(900px, 100%);
  min-height: calc(100svh - var(--topbar) - clamp(52px, 9vw, 106px));
  margin: 0 auto;
}
.word-deck-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.word-deck-heading .eyebrow { margin: 0; }
.word-deck-heading > p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: .08em;
}
.word-card {
  display: grid;
  min-height: 0;
  align-content: center;
  justify-items: center;
  margin: 0;
}
.word-card-image-wrap {
  width: min(100%, 820px);
  max-height: 54svh;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: var(--paper-strong);
  border-radius: clamp(20px, 3vw, 34px);
  box-shadow: var(--shadow);
}
.word-card-image-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.word-card-copy {
  display: grid;
  justify-items: center;
  gap: 3px;
  margin-top: clamp(14px, 2.2vh, 22px);
  text-align: center;
}
.word-card-fa {
  color: var(--pomegranate);
  font-size: clamp(2.7rem, 6vw, 4.8rem);
  font-weight: 600;
  line-height: 1.12;
}
.word-card-latin {
  color: var(--muted);
  font-size: clamp(.82rem, 1.3vw, 1rem);
  font-weight: 600;
  letter-spacing: .035em;
  transition: filter .2s ease, opacity .2s ease;
}
.word-card-translation {
  margin-top: 5px;
  color: var(--ink);
  font-size: clamp(1.05rem, 1.7vw, 1.3rem);
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.2;
}
.latin-hidden .word-card-latin { filter: blur(5px); opacity: .35; user-select: none; }
.word-card-listen { justify-self: center; }
.word-card-listen.is-playing { background: white; transform: translateY(-2px); }
.word-card-nav {
  display: grid;
  grid-template-columns: 1fr minmax(100px, 220px) 1fr;
  gap: clamp(16px, 4vw, 36px);
  align-items: center;
  width: 100%;
  padding-top: 4px;
}
.word-card-nav-button {
  display: flex;
  gap: 13px;
  align-items: center;
  padding: 0;
  color: var(--ink);
  text-align: left;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.word-card-nav-button.next { justify-content: flex-end; text-align: right; }
.word-card-nav-button > span:first-child,
.word-card-nav-button > span:last-child { font-size: 1.2rem; transition: transform .2s ease; }
.word-card-nav-button:not(:disabled):hover > span:first-child { transform: translateX(-3px); }
.word-card-nav-button.next:not(:disabled):hover > span:last-child { transform: translateX(3px); }
.word-card-nav-button span { display: grid; gap: 3px; }
.word-card-nav-button small {
  color: var(--muted);
  font-size: .56rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.word-card-nav-button b { font-size: .72rem; }
.word-card-nav-button:disabled { opacity: .25; cursor: default; }
.word-card-progress { height: 2px; overflow: hidden; background: var(--line); border-radius: 10px; }
.word-card-progress i { display: block; height: 100%; background: var(--pomegranate); transition: width .45s ease; }
.word-card.is-forward .word-card-image-wrap { animation: wordImageForward .48s cubic-bezier(.2,.75,.25,1) both; }
.word-card.is-backward .word-card-image-wrap { animation: wordImageBackward .48s cubic-bezier(.2,.75,.25,1) both; }
.word-card.is-forward .word-card-copy,
.word-card.is-backward .word-card-copy { animation: wordCopyIn .42s .08s cubic-bezier(.2,.75,.25,1) both; }

.lesson-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr);
  gap: clamp(46px, 7vw, 100px);
  max-width: 1240px;
  margin: 0 auto;
  padding: clamp(70px, 8vw, 120px) clamp(30px, 6vw, 84px);
}
.lesson-content > section + section { margin-top: 92px; }
.section-heading { display: grid; grid-template-columns: minmax(130px, .34fr) 1fr; gap: 28px; align-items: baseline; margin-bottom: 30px; }
.section-heading .eyebrow { margin: 0; }
.section-heading h3 { margin: 0; font-size: clamp(1.7rem, 3vw, 3.15rem); line-height: 1; letter-spacing: -0.055em; }
.section-heading.compact { display: block; margin-bottom: 18px; }
.section-heading.compact h3 { font-size: 1.6rem; }

.story-strip ol, .story-strip { margin: 0; }
.story-strip ol {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.story-strip li { position: relative; padding: 24px 18px 24px 0; font-size: .79rem; font-weight: 700; }
.story-strip li + li { padding-left: 24px; border-left: 1px solid var(--line); }
.story-strip li::before { content: attr(data-step); display: block; margin-bottom: 14px; color: var(--pomegranate); font-size: .62rem; }

.word-list { border-top: 1px solid var(--line); }
.word-row {
  display: grid;
  grid-template-columns: 54px minmax(90px, .5fr) minmax(100px, .6fr) 1fr 28px;
  gap: 18px;
  align-items: center;
  width: 100%;
  min-height: 77px;
  padding: 12px 4px;
  color: var(--ink);
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  transition: padding .2s ease, color .2s ease;
}
.word-row:hover { padding-left: 10px; color: var(--pomegranate); }
.word-row .sound-icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: var(--turquoise);
  border: 1px solid var(--line);
  border-radius: 50%;
}
.word-row .word-fa { font-family: "Vazirmatn", sans-serif; font-size: 1.65rem; text-align: right; direction: rtl; }
.word-row .word-latin { color: var(--muted); font-size: .75rem; }
.word-row .word-tr { font-size: .73rem; }
.word-row .word-arrow { color: var(--muted); font-size: 1rem; transition: transform .2s ease; }
.word-row:hover .word-arrow { transform: translateX(3px); }
.latin-hidden .word-latin, .latin-hidden .reading-latin, .latin-hidden #dockLatin { filter: blur(5px); opacity: .35; user-select: none; }

.letter-ribbon { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 24px; }
.letter-ribbon span {
  display: grid;
  min-width: 57px;
  height: 57px;
  place-items: center;
  color: var(--pomegranate);
  font-family: "Vazirmatn", sans-serif;
  font-size: 1.7rem;
  background: color-mix(in srgb, var(--pomegranate) 9%, var(--paper-strong));
  border-radius: 16px;
}
.reading-list { border-top: 1px solid var(--line); }
.reading-row {
  display: grid;
  grid-template-columns: 50px minmax(170px, 1fr) minmax(110px, .75fr);
  gap: 20px;
  align-items: center;
  width: 100%;
  min-height: 96px;
  padding: 14px 0;
  color: var(--ink);
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}
.reading-row .play-mini { display: grid; width: 38px; height: 38px; place-items: center; color: var(--pomegranate); border: 1px solid var(--line); border-radius: 50%; }
.reading-fa { font-family: "Vazirmatn", sans-serif; font-size: clamp(1.55rem, 2.7vw, 2.25rem); line-height: 1.6; text-align: right; direction: rtl; }
.reading-meta { display: grid; gap: 5px; }
.reading-latin { color: var(--saffron-deep); font-size: .72rem; }
.reading-tr { color: var(--muted); font-size: .7rem; }
.target-glyph { color: var(--pomegranate); background: transparent; font-weight: 700; }
.reading-row.is-playing .reading-fa { color: var(--pomegranate); }

.practice-column { min-width: 0; }
.trace-section, .challenge {
  padding: 30px 0;
  border-top: 1px solid var(--line);
}
.trace-section { position: static; }
.trace-section > p { margin: 0 0 18px; color: var(--muted); font-size: .72rem; line-height: 1.55; }
.trace-board {
  position: relative;
  overflow: hidden;
  aspect-ratio: 2 / 1;
  background-color: var(--paper-strong);
  background-image: repeating-linear-gradient(0deg, transparent 0, transparent 32%, color-mix(in srgb, var(--turquoise) 18%, transparent) 32.5%, transparent 33%);
  border-radius: 18px;
  box-shadow: inset 0 0 0 1px var(--line);
}
.trace-board canvas { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.trace-guide {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: color-mix(in srgb, var(--pomegranate) 24%, transparent);
  font-family: "Vazirmatn", sans-serif;
  font-size: clamp(3rem, 7vw, 5.6rem);
  letter-spacing: .18em;
  pointer-events: none;
}
.trace-actions { display: flex; justify-content: space-between; align-items: center; padding: 12px 3px 0; }
.trace-actions span { color: var(--muted); font-size: .62rem; }

.challenge { margin-top: 52px; }
.audio-prompt {
  display: flex;
  width: 100%;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  color: var(--turquoise);
  text-align: left;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: .73rem;
  font-weight: 700;
}
.audio-pulse {
  position: relative;
  width: 36px;
  height: 36px;
  border: 1px solid var(--turquoise);
  border-radius: 50%;
}
.audio-pulse::before, .audio-pulse::after { content: ""; position: absolute; top: 50%; height: 12px; width: 2px; background: currentColor; border-radius: 2px; transform: translateY(-50%); }
.audio-pulse::before { left: 14px; }
.audio-pulse::after { left: 20px; height: 18px; }
.challenge-prompt { margin: 12px 0 16px; font-size: .85rem; font-weight: 700; line-height: 1.55; }
.choice-list { display: grid; gap: 8px; }
.choice-button {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 54px;
  padding: 9px 14px;
  color: var(--ink);
  text-align: left;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 13px;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.choice-button:hover { border-color: var(--saffron); transform: translateX(2px); }
.choice-button .choice-fa { font-family: "Vazirmatn", sans-serif; font-size: 1.15rem; direction: rtl; }
.choice-button .choice-tr { color: var(--muted); font-size: .65rem; }
.choice-button.is-correct { color: var(--pistachio); border-color: var(--pistachio); background: color-mix(in srgb, var(--pistachio) 9%, transparent); }
.choice-button.is-wrong { color: var(--pomegranate); border-color: var(--pomegranate); }
.choice-button:disabled { cursor: default; }
.challenge-feedback { min-height: 22px; margin: 14px 0 0; color: var(--muted); font-size: .7rem; }
.challenge-feedback.is-success { color: var(--pistachio); font-weight: 700; }

.lesson-nav {
  display: grid;
  grid-template-columns: 1fr minmax(130px, 260px) 1fr;
  gap: 30px;
  align-items: center;
  max-width: 1240px;
  margin: 0 auto;
  padding: 36px clamp(30px, 6vw, 84px) 72px;
  border-top: 1px solid var(--line);
}
.nav-button {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  cursor: pointer;
}
.nav-button:last-child { justify-content: flex-end; text-align: right; }
.nav-button > span:first-child, .nav-button > span:last-child { font-size: 1.25rem; }
.nav-button span { display: grid; gap: 3px; }
.nav-button small { color: var(--muted); font-size: .58rem; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; }
.nav-button b { font-size: .72rem; }
.nav-button:disabled { opacity: .28; cursor: default; }
.page-position { height: 2px; overflow: hidden; background: var(--line); border-radius: 10px; }
.page-position i { display: block; width: 5%; height: 100%; background: var(--pomegranate); transition: width .45s ease; }

.audio-dock {
  position: fixed;
  z-index: 70;
  right: 26px;
  bottom: 24px;
  display: grid;
  grid-template-columns: 42px minmax(110px, 1fr) auto 38px;
  gap: 12px;
  align-items: center;
  min-width: min(390px, calc(100vw - 36px));
  padding: 10px 11px;
  color: white;
  background: #17353a;
  border-radius: 17px;
  box-shadow: var(--shadow);
  animation: dockIn .25s ease both;
}
.dock-orb { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 50%; background: var(--pomegranate); }
.dock-orb i { width: 8px; height: 16px; border-left: 2px solid white; border-right: 2px solid white; animation: equalize .7s ease-in-out infinite alternate; }
.dock-copy { display: grid; gap: 1px; }
.dock-copy strong { font-size: 1rem; }
.dock-copy span { color: rgba(255,255,255,.62); font-size: .6rem; }
.audio-dock .text-button { color: white; text-decoration: none; }
.audio-dock .icon-button { width: 36px; height: 36px; color: white; border-color: rgba(255,255,255,.18); font-size: .65rem; }

.toast {
  position: fixed;
  z-index: 90;
  left: 50%;
  bottom: 26px;
  padding: 11px 17px;
  color: white;
  background: #17353a;
  border-radius: 99px;
  box-shadow: var(--shadow);
  font-size: .7rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@keyframes sceneIn { from { opacity: .7; transform: scale(1.06); } to { opacity: 1; transform: scale(1.015); } }
@keyframes copyIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes dockIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes equalize { from { transform: scaleY(.55); } to { transform: scaleY(1); } }
@keyframes breathe { 50% { transform: scale(.92) rotate(-3deg); } }
@keyframes wordImageForward { from { opacity: .35; transform: translateX(24px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes wordImageBackward { from { opacity: .35; transform: translateX(-24px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes wordCopyIn { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }

@media (min-width: 821px) {
  .rail-close { display: grid !important; }
  .course-shell.rail-collapsed .course-rail {
    visibility: hidden;
    transform: translateX(-105%);
  }
  .course-shell.rail-collapsed .workspace { margin-left: 0; }
  .course-shell.rail-collapsed .menu-button { display: grid !important; }
}

@media (max-width: 1050px) {
  :root { --rail: 278px; }
  .lesson-grid { grid-template-columns: minmax(0, 1fr); }
  .practice-column { display: grid; grid-template-columns: 1fr 1fr; gap: 36px; }
  .trace-section { position: static; }
  .challenge { margin-top: 0; }
}

@media (max-width: 820px) {
  :root { --topbar: 62px; }
  .course-rail {
    width: min(330px, 88vw);
    transform: translateX(-105%);
    box-shadow: var(--shadow);
  }
  .course-rail.is-open { transform: translateX(0); }
  .rail-close { display: grid !important; }
  .rail-scrim { position: fixed; inset: 0; z-index: 35; background: rgba(5,20,23,.4); backdrop-filter: blur(3px); }
  .workspace { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .menu-button { display: grid !important; }
  .mobile-brand { display: inline !important; color: var(--ink); font-size: .78rem; text-decoration: none; letter-spacing: -.04em; }
  .topbar-meta span { display: none; }
  .soft-button { min-height: 34px; padding: 0 10px; font-size: .6rem; }
  .topbar-actions .icon-button { display: none; }
  .scene { min-height: calc(100svh - var(--topbar)); }
  .scene-copy { width: 85%; padding: 36px 24px 44px; }
  .scene-copy h2 { font-size: clamp(3.05rem, 15vw, 5.2rem); }
  .scene-copy > p:not(.scene-kicker) { font-size: .8rem; }
  .scene-index { right: 18px; top: 22px; font-size: 5.5rem; }
  .scene-shade { background: linear-gradient(0deg, rgba(10,29,32,.78) 0%, rgba(10,29,32,.18) 68%, rgba(10,29,32,.05)); }
  .lesson-grid { padding: 62px 22px; gap: 70px; }
  .lesson-content > section + section { margin-top: 68px; }
  .section-heading { display: block; }
  .section-heading .eyebrow { margin-bottom: 10px; }
  .word-row { grid-template-columns: 44px minmax(90px, .6fr) minmax(90px, .75fr) 22px; gap: 12px; }
  .word-row .word-tr { display: none; }
  .practice-column { grid-template-columns: 1fr; gap: 48px; }
  .story-strip li { padding-right: 10px; font-size: .68rem; }
  .story-strip li + li { padding-left: 12px; }
  .reading-row { grid-template-columns: 42px 1fr; }
  .reading-meta { grid-column: 2; margin-top: -14px; padding-bottom: 10px; }
  .lesson-nav { grid-template-columns: 1fr 70px 1fr; gap: 15px; padding: 30px 22px 96px; }
  .audio-dock { right: 18px; bottom: 16px; grid-template-columns: 40px 1fr auto 36px; }
  .word-deck-toggle-wide { display: none; }
  .word-deck-toggle-short { display: inline; }
  .word-deck { padding: 20px 22px 28px; }
  .word-deck-inner { display: block; min-height: 0; }
  .word-card { margin-top: 18px; }
  .word-card-image-wrap { max-height: 50svh; border-radius: 22px; }
  .word-card-listen { display: flex; width: max-content; margin: 18px auto 0; }
  .word-card-nav { grid-template-columns: 1fr 68px 1fr; gap: 14px; margin-top: 24px; }
}

@media (max-width: 480px) {
  .topbar-meta { display: none; }
  .scene-copy { width: 100%; }
  .scene-copy h2 { max-width: 340px; }
  .primary-button { min-height: 45px; }
  .lesson-grid { padding-inline: 18px; }
  .word-row { grid-template-columns: 40px minmax(90px, 1fr) minmax(80px, .8fr); }
  .word-row .word-arrow { display: none; }
  .letter-ribbon span { min-width: 50px; height: 50px; }
  .nav-button b { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .audio-dock { left: 12px; right: 12px; bottom: 12px; min-width: 0; }
  .word-deck { padding-inline: 16px; }
  .word-deck-inner { gap: 15px; }
  .word-card-fa { font-size: clamp(2.65rem, 15vw, 3.8rem); }
  .word-card-nav-button b { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

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