:root {
  color-scheme: dark;
  --bg: #000;
  --panel: #101012;
  --edge: #29292c;
  --text: #f5f5f7;
  --muted: #96969d;
  --blue: #0a84ff;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
main {
  max-width: 590px;
  margin: 0 auto;
  padding: 20px 20px calc(100px + env(safe-area-inset-bottom));
}
button,
input {
  font: inherit;
}
button {
  color: inherit;
  background: #111;
  border: 1px solid var(--edge);
  border-radius: 10px;
  padding: 12px 15px;
  min-height: 44px;
  cursor: pointer;
}
button:active {
  opacity: 0.7;
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button:focus-visible,
input:focus-visible {
  outline: 2px solid #7aafff;
  outline-offset: 3px;
}
button.primary,
#startPractice {
  background: var(--text);
  color: #080808;
  border-color: transparent;
}
p,
small {
  color: var(--muted);
  line-height: 1.6;
}
input {
  width: 100%;
  background: #0b0b0c;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 14px;
  color: var(--text);
}
#gate {
  max-width: 390px;
  margin: 15vh auto 0;
}
#gate button {
  width: 100%;
}
#error,
#feedback {
  min-height: 1.5em;
  font-size: 13px;
}
#syncStatus {
  font-size: 12px;
  margin: 10px 0;
}
#syncStatus:empty {
  display: none;
}
/* Curriculum list */
.levelGroup {
  padding: 0;
  margin: 20px 0 34px;
}
.levelHeading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--edge);
}
.levelHeading h3 {
  font-size: 12px;
  font-weight: 550;
  color: var(--muted);
  margin: 0;
}
.levelHeading > span {
  font-size: 11px;
  color: var(--muted);
}
#lessonList button {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 12px;
  padding: 21px 0;
  border: 0;
  border-bottom: 1px solid var(--edge);
  border-radius: 0;
  text-align: left;
  background: transparent;
  font-size: 16px;
}
.lessonName {
  flex: 1;
}
.lessonCount {
  font-size: 11px;
  white-space: nowrap;
}
.chevronGlyph {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-top: 1px solid #777;
  border-right: 1px solid #777;
  transform: rotate(45deg);
  margin: 0 4px;
}
.reviewDue {
  width: 100%;
  text-align: left;
  font-size: 13px;
}
/* Lesson reader */
.lessonSticky {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.94);
  backdrop-filter: blur(16px);
  padding: 10px 0;
  border-bottom: 1px solid var(--edge);
}
.lessonTitleToggle {
  flex: 1;
  text-align: left;
  font-size: 17px;
  font-weight: 550;
  border: 0;
  background: none;
  padding: 8px 0;
}
.collapseLesson {
  width: 44px;
  background: none;
  border: 0;
}
.collapseLesson .chevronGlyph {
  transform: rotate(-45deg);
}
.readingsection {
  padding: 22px 0;
}
h4 {
  font-size: 19px;
  font-weight: 550;
  letter-spacing: -0.025em;
  margin: 0 0 15px;
}
.sectionSummary {
  font-size: 14px;
  line-height: 1.75;
}
.inlineLabel {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #898990;
  margin: 22px 0 10px;
}
.formsTable {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.formsTable td {
  width: 50%;
  padding: 6px 0;
  vertical-align: middle;
  font-size: 13px;
  color: #a6a6ad;
  overflow-wrap: anywhere;
}
.formsTable td:first-child {
  padding-right: 14px;
}
.formAudio {
  border: 0;
  background: none;
  text-align: left;
  padding: 5px 0;
  font-size: 15px;
  color: var(--text);
}
.inlineSentences {
  margin: 0;
  padding: 0;
}
.exampleEntry {
  margin: 16px 0 22px;
}
.inlineExampleTop {
  display: flex;
  align-items: center;
  gap: 12px;
}
.inlineExampleTop strong {
  flex: 1;
  font-weight: 500;
  font-size: 16px;
  line-height: 1.6;
  min-width: 0;
}
.spokenChunk {
  display: inline;
  padding: 0;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-decoration: underline dashed #555;
  text-underline-offset: 4px;
}
.exampleAudio {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: #999;
}
.inlineEnglish {
  font-size: 13px;
  color: #b3b3bb;
  margin: 4px 0;
}
.inlineUsage,
.inlineNote {
  font-size: 12px;
  line-height: 1.75;
  color: #93939a;
}
.inlineNote {
  margin: 15px 0;
}
.dialogueSection {
  margin: 28px 0;
}
.dialogueSection h3 {
  font-size: 18px;
}
.dialogueLine {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 18px 0;
}
.dialogueSpeaker {
  color: #777;
  font-size: 11px;
}
.dialogueText {
  flex: 1;
  min-width: 0;
}
.dialogueRussian {
  font-size: 16px;
  line-height: 1.6;
}
.dialogueEnglish,
.dialogueNotes {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
}
#startPractice {
  width: 100%;
  margin: 20px 0;
}
/* Practice */
#practiceControls {
  display: flex;
  gap: 24px;
  border-bottom: 1px solid var(--edge);
  margin: 8px 0;
}
#practiceControls button {
  border: 0;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  background: none;
  padding: 10px 0;
  color: var(--muted);
  font-size: 14px;
}
#practiceControls button.active {
  color: var(--text);
  border-bottom-color: var(--text);
}
#practiceArea {
  padding: 12px 0 18px;
}
.practiceHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
#counter {
  font-size: 11px;
}
.readAgain {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 11px;
  padding: 8px 0;
}
.phraseProgress {
  height: 2px;
  background: var(--edge);
  margin: 14px 0 20px;
}
.phraseProgress span {
  display: block;
  height: 100%;
  background: var(--text);
}
#russian {
  font-size: clamp(28px, 7vw, 44px);
  font-weight: 550;
  letter-spacing: -0.035em;
  line-height: 1.25;
  text-align: center;
  margin: 40px 0 18px;
  overflow-wrap: anywhere;
}
#phonetic,
#english,
#explanation {
  text-align: center;
}
#phonetic {
  font-size: 14px;
}
#english {
  font-size: 16px;
  color: var(--text);
  min-height: 26px;
}
#explanation {
  font-size: 12px;
  min-height: 28px;
}
#recallBox {
  margin: 24px 0;
}
#answer {
  text-align: center;
}
#check {
  margin-top: 8px;
}
#feedback {
  text-align: center;
}
.audioControls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  margin: 30px 0 18px;
}
.audioControls button {
  background: none;
  border: 0;
  padding: 10px;
  color: #b2b2b8;
  font-size: 14px;
  min-width: 54px;
}
.audioControls #listen {
  background: var(--text);
  color: #050505;
  border-radius: 50%;
  width: 72px;
  height: 72px;
  font-size: 26px;
  padding: 0;
}
#reveal {
  display: block;
  margin: auto;
  background: none;
  border: 0;
  font-size: 13px;
  color: #bbb;
}
.row {
  display: flex;
  gap: 9px;
  margin-top: 24px;
}
.row button {
  flex: 1;
  font-size: 13px;
}
/* Anna conversation */
.chatView {
  margin: 0 -20px;
  background: #000;
}
.chatHeader {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 14px 52px 16px;
  background: #080809;
  border-bottom: 1px solid #222226;
  text-align: center;
}
.chatAvatar {
  width: 58px;
  height: 58px;
  object-fit: cover;
  object-position: center 42%;
  border-radius: 50%;
  border: 1px solid #38383d;
}
.chatHeader strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
}
.chatHeader small {
  display: block;
  font-size: 11px;
  color: #8e8e93;
  margin-top: 2px;
}
#chatRestart {
  position: absolute;
  right: 12px;
  top: 14px;
  background: none;
  border: 0;
  font-size: 23px;
  padding: 4px;
  width: 44px;
  height: 44px;
  color: #a3a3aa;
}
.chatThread {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 26vh;
  max-height: 45dvh;
  overflow-y: auto;
  padding: 22px 16px 16px;
  scroll-behavior: smooth;
}
.chatBubble {
  position: relative;
  max-width: 86%;
  font-size: 16px;
  line-height: 1.4;
  letter-spacing: -0.012em;
  padding: 10px 14px;
  border-radius: 19px;
  overflow-wrap: anywhere;
}
.chatBubble.anna {
  align-self: flex-start;
  background: #29292d;
  color: #f7f7f8;
  border-bottom-left-radius: 5px;
  padding-right: 52px;
}
.chatBubble.me {
  align-self: flex-end;
  background: var(--blue);
  color: white;
  border-bottom-right-radius: 5px;
}
.chatAudio {
  position: absolute;
  right: 3px;
  bottom: 2px;
  width: 44px;
  height: 44px;
  padding: 0;
  background: none;
  border: 0;
  color: #c4c4cb;
}
.chatAnswers {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 13px 16px 20px;
  border-top: 1px solid #242428;
  background: #101012;
}
.chatProgress {
  font-size: 11px;
  color: var(--muted);
}
.chatHint {
  background: none;
  border: 0;
  color: var(--blue);
  font-size: 12px;
  padding: 6px 0;
}
.chatChoice {
  width: 100%;
  min-height: 47px;
  padding: 12px 15px;
  border-radius: 18px;
  border: 1px solid #37373c;
  background: #242428;
  color: #f7f7f8;
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.chatChoice.incorrect {
  border-color: #aa6262;
}
.chatFeedback {
  font-size: 12px;
  color: #b8b8c0;
  margin: 4px 0;
  line-height: 1.6;
}
.chatFeedback:empty {
  display: none;
}
/* Navigation and status */
.bottomNav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
  border-top: 1px solid #222225;
  background: rgba(10, 10, 11, 0.96);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.bottomNav button {
  border: 0;
  background: none;
  flex: 1;
  max-width: 184px;
  min-height: 54px;
  padding: 5px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #8e8e96;
  border-radius: 8px;
}
.bottomNav button[aria-current="page"] {
  color: #f5f5f7;
}
.navLabel {
  font-size: 10px;
  font-weight: 500;
  line-height: 14px;
  letter-spacing: 0.01em;
}
.bottomNav button[aria-current="page"] .navLabel {
  font-weight: 600;
}
.navIcon {
  display: block;
  width: 23px;
  height: 23px;
  flex-shrink: 0;
}
.navOutline {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.navFilled {
  display: none;
  fill: currentColor;
}
.bottomNav button[aria-current="page"] .navOutline {
  display: none;
}
.bottomNav button[aria-current="page"] .navFilled {
  display: block;
}
@media (hover: hover) {
  .bottomNav button:hover {
    color: #d4d4d8;
  }
}
.reviewHome h2 {
  font-size: 30px;
  font-weight: 550;
}
.reviewHome p {
  font-size: 14px;
}
.reviewExplanation {
  margin-top: 25px;
}
#audioStatus {
  position: fixed;
  bottom: calc(78px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 16px;
  background: #252525;
  border-radius: 12px;
  max-width: 90vw;
  width: max-content;
  z-index: 100;
  font-size: 12px;
}
@media (min-width: 600px) {
  .chatView {
    margin: 0;
    border: 1px solid #242428;
    border-radius: 18px;
    overflow: hidden;
  }
}
@media (max-width: 400px) {
  main {
    padding-left: 16px;
    padding-right: 16px;
  }
  .chatView {
    margin-left: -16px;
    margin-right: -16px;
  }
  #lessonList button {
    font-size: 15px;
    gap: 8px;
  }
  .lessonCount {
    font-size: 10px;
  }
  .chatBubble {
    font-size: 15px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
[hidden] {
  display: none !important;
}
.stagingNotice {
  font-size: 11px;
  text-align: center;
  color: #999;
  margin: 8px 12px;
}
.chatChoiceRow {
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.chatChoiceRow .chatChoice {
  flex: 1;
  width: auto;
  min-width: 0;
  text-align: left;
}
.chatChoiceAudio {
  flex: 0 0 46px;
  width: 46px;
  min-height: 47px;
  padding: 0;
  border-radius: 16px;
  border: 1px solid #37373c;
  background: #242428;
  color: #c4c4cb;
}
.chatChoiceAudio:hover {
  color: white;
  background: #34343a;
}
/* Revealed translations remain readable after the hint button is disabled. */
.chatHint:disabled {
  opacity: 1;
  color: #b8b8c0;
  cursor: default;
}
/* Chat uses a viewport-sized column, like a messaging app. The reply composer
   stays against the tab bar; only the transcript scrolls as it grows. */
:root {
  --tab-bar-height: 67px;
}
.chatView {
  position: fixed;
  top: 0;
  bottom: calc(var(--tab-bar-height) + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 550px);
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-bottom: 0;
  border-radius: 0;
}
body:has(.stagingNotice) .chatView {
  top: 36px;
}
.chatHeader {
  flex: 0 0 auto;
}
.chatThread {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 18px;
}
.chatAnswers {
  flex: 0 0 auto;
  max-height: 60%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 12px;
}
.bottomNav {
  min-height: calc(var(--tab-bar-height) + env(safe-area-inset-bottom));
}
@media (min-width: 600px) {
  .chatView {
    border-radius: 16px 16px 0 0;
  }
}
@media (max-height: 600px) {
  .chatHeader {
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .chatAvatar {
    width: 38px;
    height: 38px;
  }
  .chatAnswers {
    gap: 5px;
    padding-top: 8px;
  }
  .chatHint {
    min-height: 32px;
  }
}

/* Shared pronunciation affordance and feedback, without layout movement. */
:is(.spokenChunk, .formAudio) {
  text-decoration: underline dotted #64646c;
  text-underline-offset: 5px;
  cursor: pointer;
}
:is(.spokenChunk, .formAudio, .exampleAudio, .audioControls button, #repeatAudio) {
  position: relative;
  transition: color .15s ease, background-color .15s ease;
}
:is(.spokenChunk, .formAudio, .exampleAudio, .audioControls button, #repeatAudio):active {
  background-color: #ffffff12;
}
:is(.spokenChunk, .formAudio, .exampleAudio, .audioControls button, #repeatAudio)[data-audio-state="loading"] {
  color: #a9cfff;
  background-image: linear-gradient(100deg, transparent 20%, #8ebfff20 50%, transparent 80%);
  background-size: 220% 100%;
  animation: pronunciation-shimmer 1.4s ease-in-out infinite;
}
:is(.spokenChunk, .formAudio, .exampleAudio, .audioControls button, #repeatAudio)[data-audio-state="playing"] {
  color: #8ebfff;
  text-decoration-color: #8ebfff;
  background-color: #8ebfff0d;
}
@keyframes pronunciation-shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}
@media (prefers-reduced-motion: reduce) {
  [data-audio-state="loading"] { animation: none !important; }
}

/* Rounded text-audio hit areas remain the same size in every playback state. */
.spokenChunk {
  display: inline-block;
  padding: 2px 4px;
  margin: 1px 0;
  border-radius: 6px;
  vertical-align: baseline;
  max-width: 100%;
  box-sizing: border-box;
  white-space: normal;
}
.formAudio { padding: 5px 7px; border-radius: 7px; max-width: 100%; }
.spokenChunk, .formAudio {
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  background-clip: padding-box;
}
.spokenChunk:focus-visible, .formAudio:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 1px #7aafff;
}

.referenceTabs { display: flex; padding: 4px; gap: 4px; border-radius: 12px; background: #171719; }
.referenceTabs button { flex: 1; border: 0; background: transparent; color: #929299; }
.referenceTabs button[aria-selected="true"] { color: #fff; background: #303034; }
.referenceNote { color: #96969e; font-size: 13px; line-height: 1.6; margin: 18px 0; }
.referenceGrid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 9px; }
.referenceCard { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 14px 6px; background: #151517; border-radius: 12px; min-width: 0; }
.referenceCard strong { font-size: 25px; font-weight: 500; }
.referenceCard span { font-size: 13px; }
.referenceCard small { color: #9797a0; font-size: 10px; line-height: 1.4; }
.referenceCard[data-audio-state="loading"] { color: #a9cfff; background-image: linear-gradient(100deg,transparent 20%,#8ebfff20 50%,transparent 80%); background-size:220% 100%; animation:pronunciation-shimmer 1.4s ease-in-out infinite; }
.referenceCard[data-audio-state="playing"] { color: #8ebfff; border-color: #456483; }
@media (min-width: 500px) { .referenceGrid { grid-template-columns: repeat(4,minmax(0,1fr)); } }
