:root {
  --ink: #1f2523;
  --muted: #68726e;
  --paper: #f6f2eb;
  --panel: rgba(255, 252, 246, 0.95);
  --line: rgba(43, 51, 48, 0.18);
  --green: #103f34;
  --green-2: #195544;
  --red: #ad352d;
  --cream: #fffaf1;
  --blue: #405869;
  --gold: #b8873b;
  --shadow: 0 22px 60px rgba(21, 25, 24, 0.18);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(64, 88, 105, 0.55);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  background:
    linear-gradient(90deg, rgba(16, 63, 52, 0.04), transparent 36%),
    var(--paper);
}

.lesson-rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(86vw, 310px);
  z-index: 20;
  transform: translateX(-102%);
  transition: transform 180ms ease;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(0, 0, 0, 0.16)),
    var(--green);
  color: #fffaf1;
  min-height: 100vh;
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.show-rail .lesson-rail {
  transform: translateX(0);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 0 10px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.brand-mark {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 46px;
  line-height: 1;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.lesson-link small,
.title-block span,
.pattern-item small,
.piece-row small {
  color: rgba(255, 250, 241, 0.72);
}

.lesson-list {
  display: grid;
  gap: 8px;
}

.settings-copy {
  padding: 0 10px;
  color: rgba(255, 250, 241, 0.78);
  line-height: 1.45;
}

.settings-copy p {
  margin: 0;
}

.lesson-link {
  width: 100%;
  min-height: 74px;
  display: grid;
  grid-template-columns: 36px 1fr 18px;
  align-items: center;
  gap: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 10px;
  border-radius: 8px;
}

.lesson-link:hover,
.lesson-link.is-active {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
}

.lesson-link.is-locked {
  opacity: 0.58;
  cursor: not-allowed;
}

.lesson-link.is-locked:hover {
  background: transparent;
  border-color: transparent;
}

.lesson-link.is-active {
  box-shadow: inset 3px 0 0 #f6f2eb;
}

.lesson-number {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.45);
  font-weight: 700;
}

.lesson-link.is-active .lesson-number {
  background: #f6f2eb;
  color: var(--green);
}

.lesson-link strong {
  display: block;
  font-size: 0.94rem;
}

.lesson-link small {
  display: block;
  margin-top: 4px;
  line-height: 1.35;
}

.rail-footer {
  margin-top: auto;
  padding: 14px 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.voice-disclosure {
  margin: 12px 2px 0;
  color: rgba(255, 250, 241, 0.64);
  font-size: 0.78rem;
  line-height: 1.35;
}

.lesson-main {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(100vh, 1fr);
}

.topbar {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 5;
  height: 70px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 28px;
  background: linear-gradient(180deg, rgba(12, 17, 15, 0.68), rgba(12, 17, 15, 0));
  color: var(--cream);
  border-bottom: 0;
  backdrop-filter: none;
}

.title-block {
  flex: 1;
}

.title-block span {
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.title-block h1 {
  margin: 2px 0 0;
  font-size: clamp(1rem, 1.7vw, 1.25rem);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: 0;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.38);
}

.icon-button,
.ghost-button,
.primary-button,
.check-button,
.inline-action {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 246, 0.78);
  color: var(--ink);
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
}

.topbar .icon-button {
  background: rgba(255, 250, 241, 0.14);
  border-color: rgba(255, 250, 241, 0.24);
  color: var(--cream);
  backdrop-filter: blur(12px);
}

.topbar .menu-button {
  display: grid;
}

.icon-button.is-active {
  color: var(--green);
  border-color: rgba(16, 63, 52, 0.36);
  background: rgba(16, 63, 52, 0.08);
}

.stage {
  position: relative;
  min-height: 100vh;
  background-image:
    linear-gradient(180deg, rgba(15, 20, 18, 0.18), rgba(15, 20, 18, 0.62)),
    var(--scene-image);
  background-size: cover;
  background-position: center;
}

.stage-overlay {
  min-height: 100%;
  display: grid;
  align-content: end;
  gap: 18px;
  padding: 94px 28px 36px;
}

.surface-disclosure {
  justify-self: start;
  max-width: 820px;
  margin: -4px 0 0;
  color: rgba(255, 250, 241, 0.58);
  font-size: 0.74rem;
  line-height: 1;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.42);
}

.progress-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 930px;
  color: #fffaf1;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
  font-size: 0.9rem;
  font-weight: 700;
}

.beat-panel {
  max-width: 820px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.44);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(22px, 3.2vw, 38px);
}

.beat-copy {
  max-width: 760px;
  margin: 0 auto;
  text-align: center;
}

.scene-text {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.russian-line {
  margin: 16px 0 0;
  font-size: clamp(2rem, 4vw, 3.45rem);
  line-height: 1.05;
  font-family: Georgia, "Times New Roman", serif;
}

.beat-copy h2 {
  margin: 16px auto 0;
  max-width: 680px;
  font-size: clamp(1.25rem, 2.8vw, 2.15rem);
  line-height: 1.18;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: 0;
}

.moment-actions {
  display: grid;
  justify-items: center;
  gap: 14px;
  margin-top: 28px;
}

.moment-actions.is-answering {
  justify-items: stretch;
}

.moment-actions.is-complete,
.moment-actions.is-revealed {
  grid-template-columns: minmax(120px, 170px) minmax(180px, 240px);
  justify-content: center;
}

.moment-actions.is-production-repair {
  grid-template-columns: 1fr;
  justify-items: center;
}

.speak-row,
.quiet-row,
.type-row {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.type-row {
  max-width: 650px;
  width: min(100%, 650px);
  justify-self: center;
}

.record-button {
  min-height: 58px;
  min-width: 190px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 8px;
  border: 1px solid rgba(16, 63, 52, 0.18);
  background: var(--green);
  color: #fffaf1;
  box-shadow: 0 12px 24px rgba(16, 63, 52, 0.18);
  font-weight: 800;
}

.record-button.is-listening {
  animation: listenPulse 1.2s ease-in-out infinite;
}

@keyframes listenPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(16, 63, 52, 0.32), 0 12px 24px rgba(16, 63, 52, 0.18);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(16, 63, 52, 0.08), 0 12px 24px rgba(16, 63, 52, 0.18);
  }
}

.type-row input {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdfa;
  color: var(--ink);
  padding: 0 14px;
  font-size: 1.05rem;
}

.check-button,
.primary-button,
.listen-button,
.quiet-button,
.ghost-button {
  min-height: 46px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.listen-button {
  min-height: 62px;
  min-width: 210px;
  background: var(--green);
  color: var(--cream);
  border-color: rgba(16, 63, 52, 0.25);
  font-size: 1.02rem;
  font-weight: 800;
  box-shadow: 0 16px 36px rgba(16, 63, 52, 0.18);
}

.quiet-button {
  background: rgba(255, 252, 246, 0.58);
  color: var(--ink);
  border-color: var(--line);
  font-weight: 700;
}

.quiet-button:hover {
  background: rgba(16, 63, 52, 0.08);
  border-color: rgba(16, 63, 52, 0.25);
}

.check-button {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.check-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.primary-button:disabled {
  opacity: 0.48;
  cursor: default;
  background: rgba(16, 63, 52, 0.58);
  border-color: rgba(16, 63, 52, 0.2);
}

.progress-place {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
}

.feedback-line {
  min-height: 38px;
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
  flex-wrap: wrap;
}

.beat-panel.is-correct .feedback-line {
  color: var(--green);
}

.beat-panel.is-retry .feedback-line {
  color: var(--red);
}

.beat-panel.is-revealed .feedback-line {
  color: #6c5432;
}

.beat-panel.is-working .feedback-line {
  color: var(--blue);
}

.heard-text {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 0.95rem;
}

.hint-box {
  margin-top: 12px;
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  border-radius: 8px;
  background: rgba(184, 135, 59, 0.14);
  border: 1px solid rgba(184, 135, 59, 0.28);
  color: #614414;
}

.inline-action {
  min-height: 32px;
  padding: 0 10px;
  color: var(--green);
}

.primary-button {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  font-weight: 800;
}

.primary-button:hover,
.check-button:hover,
.listen-button:hover,
.record-button:hover {
  background: var(--green-2);
}

.ghost-button {
  width: 100%;
  background: transparent;
  color: #fffaf1;
  border-color: rgba(255, 255, 255, 0.24);
}

.noscript {
  padding: 40px;
}

.lucide {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }
}

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

  .topbar {
    padding: 0 14px;
  }

  .stage-overlay {
    align-content: center;
    padding: 84px 14px 24px;
  }

  .stage {
    min-height: 100vh;
    background-position: 66% center;
  }

  .progress-strip {
    display: grid;
    justify-items: start;
  }

  .beat-panel {
    padding: 16px;
  }

  .surface-disclosure {
    justify-self: center;
  }

  .scene-text {
    font-size: 0.95rem;
  }

  .russian-line {
    margin-top: 12px;
  }

  .beat-copy h2 {
    margin-top: 10px;
  }

  .moment-actions {
    margin-top: 20px;
  }

  .moment-actions.is-complete,
  .moment-actions.is-revealed,
  .speak-row,
  .type-row {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .quiet-row {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
  }

  .quiet-row .quiet-button {
    flex: 1 1 130px;
  }

  .listen-button,
  .record-button {
    width: 100%;
  }

  .check-button {
    width: 100%;
  }

  .primary-button {
    grid-column: 1 / -1;
  }

}

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