:root {
  --violet: #6c4ce0;
  --violet-dark: #5238b8;
  --teal: #16b4a8;
  --coral: #ff7a59;
  --amber: #f0b429;
  --amber-dark: #c98f0a;
  --bg: #f7f6fc;
  --card: #ffffff;
  --text: #1a1a2e;
  --muted: #5c5c7a;
  --border: #e8e6f2;
  --success: #16b4a8;
  --error: #e85d5d;
  --tap: 44px;
  --radius: 14px;
  --shadow: 0 4px 20px rgba(108, 76, 224, 0.08);
  /* Max lesson column width on desktop; .app only reaches this when the viewport is wider than the cap + padding */
  --lesson-column-max: 1000px;
  /* ~20px — learner-tuned subheading size (goals label, intros, supporting header copy) */
  --font-size-subhead: 1.25rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app {
  max-width: 100%;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
  min-height: 100dvh;
}

@media (min-width: 768px) {
  .app {
    max-width: var(--lesson-column-max);
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}

.progress-dock {
  position: sticky;
  top: 0;
  z-index: 30;
  margin: -0.25rem 0 0.75rem;
  padding: 0.65rem 0.85rem 0.75rem;
  background: linear-gradient(135deg, #ebe6ff 0%, #e0f7f5 100%);
  backdrop-filter: blur(8px);
  border: 2px solid rgba(108, 76, 224, 0.35);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(108, 76, 224, 0.14);
}

.progress-dock--kickoff {
  padding: 1.1rem 1rem 1.15rem;
  border-width: 3px;
  border-color: var(--violet);
  box-shadow: 0 8px 28px rgba(108, 76, 224, 0.28);
  background: linear-gradient(135deg, #e8e0ff 0%, #d4f5f0 50%, #fff8e8 100%);
}

.progress-kickoff-title {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--violet-dark);
  text-align: center;
}

.progress-kickoff-hint {
  margin: 0 0 0.85rem;
  font-size: 0.92rem;
  color: var(--text);
  text-align: center;
  line-height: 1.45;
}

.btn-kickoff {
  display: block;
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
  min-height: var(--tap);
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--violet) 0%, var(--violet-dark) 100%);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(108, 76, 224, 0.35);
  touch-action: manipulation;
}

.btn-kickoff:hover {
  filter: brightness(1.05);
}

.app.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.loading-msg {
  color: var(--muted);
}

/* Header */
.lesson-header {
  margin-bottom: 1.25rem;
}

/* legacy: progress moved to .progress-dock */
.progress-sticky {
  display: none;
}

.progress-label {
  font-size: 0.9rem;
  color: var(--text);
  margin: 0 0 0.45rem;
  font-weight: 700;
  line-height: 1.35;
}

.progress-label .progress-count {
  color: #3d3566;
}

.progress-label .progress-sep {
  color: rgba(108, 76, 224, 0.55);
  font-weight: 600;
}

.progress-label .progress-next {
  color: var(--violet-dark);
}

.progress-label .progress-next strong {
  color: #1a6b64;
  font-size: 1.02em;
  font-weight: 800;
}

.progress-wrap {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(108, 76, 224, 0.2);
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(26, 26, 46, 0.08);
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--violet) 0%, var(--violet-dark) 45%, var(--teal) 100%);
  width: 0%;
  transition: width 0.3s ease;
  box-shadow: 0 0 8px rgba(108, 76, 224, 0.45);
}

.hero-img {
  width: 100%;
  border-radius: var(--radius);
  display: block;
  margin: 0.75rem 0;
  box-shadow: var(--shadow);
}

.lesson-meta {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--violet);
  margin: 0 0 0.25rem;
  letter-spacing: 0.02em;
}

.lesson-title-block {
  margin-bottom: 0.75rem;
}

.lesson-title-block .lesson-title {
  font-size: 40px;
  margin: 0 0 0.35rem;
  line-height: 1.2;
  font-weight: 800;
  color: var(--text);
}

.lesson-position {
  margin: 0;
  font-size: 30px;
  font-weight: 800;
  color: var(--violet-dark);
  letter-spacing: 0.03em;
}

h1 {
  font-size: clamp(1.55rem, 5vw, 2.15rem);
  margin: 0 0 0.5rem;
  line-height: 1.2;
}

.level-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.45rem;
  margin-left: 0.35rem;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 6px;
  background: #e8faf8;
  color: #0d6b63;
  vertical-align: middle;
}

.section-intro {
  font-size: 0.88rem;
  color: var(--muted);
  margin: -0.35rem 0 0.85rem;
}

.subtitle {
  color: var(--muted);
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
}

.subtitle.goal-callout {
  margin: 0 0 0.85rem;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  background: linear-gradient(135deg, #f3f0ff 0%, #eef8f7 100%);
  border: 1px solid rgba(108, 76, 224, 0.22);
  color: var(--text);
  font-size: var(--font-size-subhead);
  font-weight: 700;
  line-height: 1.5;
}

.lesson-goals-block {
  margin: 0 0 1rem;
  padding: 0.75rem 0.95rem 0.85rem;
  border-radius: 10px;
  background: #faf9fe;
  border: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(108, 76, 224, 0.06);
}

.lesson-goals-heading {
  margin: 0 0 0.5rem;
  font-size: 20px;
  font-weight: 800;
  color: var(--violet-dark);
  letter-spacing: 0.01em;
}

.intro-welcome {
  margin: 0 0 0.85rem;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
}

.seo-helper-line {
  margin: 0 0 0.65rem;
  font-size: 14px;
  line-height: 1.5;
  color: var(--violet-dark);
  font-weight: 700;
}

.seo-helper-line a {
  color: var(--teal-dark);
  font-weight: 700;
  text-decoration-thickness: 2px;
}

.seo-helper-line a:hover,
.seo-helper-line a:focus-visible {
  color: var(--violet-dark);
}

.overview {
  font-size: 15px;
  line-height: 1.55;
}

.lesson-goals-block .goals {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text);
  font-size: 15px;
}

.goals li {
  margin-bottom: 0.4rem;
  font-weight: 700;
  line-height: 1.45;
  color: var(--text);
}

/* Sections */
.section {
  position: relative;
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem 1rem 1.1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.section-corner-icon {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  width: 48px;
  height: 48px;
  object-fit: contain;
  pointer-events: none;
}

.section-head {
  text-align: center;
  margin-bottom: 1rem;
  padding: 0.35rem 0.5rem 0 3.75rem;
}

.section h2,
.section-title-lg {
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
  color: var(--violet-dark);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-head .section-title-lg {
  justify-content: center;
  margin-bottom: 0.35rem;
}

.section-title-lg {
  font-size: clamp(2rem, 7.5vw, 3rem);
  line-height: 1.15;
}

.section-title-text {
  display: block;
  font-size: 35px;
  font-weight: 800;
  color: var(--violet-dark);
  text-align: center;
  letter-spacing: -0.01em;
}

.section-intro-line {
  margin: 0 0 0.75rem;
  font-size: var(--font-size-subhead);
  font-weight: 600;
  color: var(--muted);
  line-height: 1.45;
  text-align: center;
  max-width: 36rem;
  margin-left: auto;
  margin-right: auto;
}

.gist-prompt {
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  background: #f3f0ff;
  border: 1px solid rgba(108, 76, 224, 0.25);
  font-size: var(--font-size-subhead);
  line-height: 1.45;
  color: var(--text);
}

.gist-prompt--compact {
  margin: 0 0 0.65rem;
  width: 100%;
  font-size: var(--font-size-subhead);
  text-align: center;
}

.speak-coaching {
  margin-top: 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  background: #fff8e8;
  border: 1px solid rgba(201, 143, 10, 0.35);
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text);
}

.scene-intro {
  margin-top: 1rem;
}

.section-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

/* Chunk cards */
.chunk-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem;
  margin-bottom: 0.75rem;
}

.chunk-card:last-child {
  margin-bottom: 0;
}

.chunk-card > .chunk-zh,
.chunk-card > .chunk-pinyin,
.chunk-card > .chunk-en {
  text-align: center;
}

.chunk-card > .audio-row {
  justify-content: center;
}

.chunk-zh {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

.chunk-card > .chunk-zh {
  font-size: 30px;
  line-height: 1.35;
}

.chunk-pinyin {
  color: var(--teal);
  font-size: var(--font-size-subhead);
  margin: 0.15rem 0 0.35rem;
}

.chunk-en {
  color: var(--muted);
  font-size: var(--font-size-subhead);
  margin: 0 0 0.5rem;
}

.chunk-meta {
  font-size: 0.85rem;
  color: var(--text);
  margin: 0.5rem 0;
}

.audio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.btn-audio {
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0.5rem 0.85rem;
  border: none;
  border-radius: 10px;
  background: var(--violet);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  touch-action: manipulation;
}

.btn-audio.slow {
  background: var(--teal);
}

.btn-audio img {
  width: 20px;
  height: 20px;
}

.btn-audio:active {
  transform: scale(0.97);
}

.btn-audio-icon {
  width: 48px;
  height: 48px;
  border: 2px solid #4a32b0;
  border-radius: 50%;
  background: linear-gradient(180deg, #7d65e8 0%, #6248e0 48%, #5238b8 100%);
  box-shadow: 0 4px 14px rgba(82, 56, 184, 0.38);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  padding: 0;
  transition:
    background 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.1s ease;
}

.btn-audio-icon--compact {
  width: 42px;
  height: 42px;
}

.btn-audio-icon--compact .audio-glyph-svg {
  width: 24px;
  height: 24px;
}

.btn-audio-icon:hover {
  background: linear-gradient(180deg, #8a74ec 0%, #6c54e4 48%, #5c42c4 100%);
  box-shadow: 0 5px 16px rgba(82, 56, 184, 0.45);
}

.btn-audio-icon.slow {
  border-color: var(--amber-dark);
  background: linear-gradient(180deg, #f5c84a 0%, var(--amber) 48%, #d9a01e 100%);
  box-shadow: 0 4px 14px rgba(201, 143, 10, 0.38);
}

.btn-audio-icon.slow:hover {
  background: linear-gradient(180deg, #fad55a 0%, #f2bc38 48%, #c98f0a 100%);
  box-shadow: 0 5px 16px rgba(201, 143, 10, 0.45);
}

/* White play / ½× glyphs inside colored circle buttons */
.audio-glyph-svg {
  width: 30px;
  height: 30px;
  display: block;
  color: #fff;
  pointer-events: none;
}

.audio-glyph-svg path {
  fill: #fff;
}

.btn-audio-pill .audio-glyph-svg {
  width: 22px;
  height: 22px;
}

.btn-audio-pill--slow {
  background: var(--amber);
  color: #1a1a2e;
}

.btn-audio-pill--slow .audio-glyph-svg {
  color: #fff;
}

.btn-svg-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: block;
  color: #fff;
}

.match-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.match-header h3 {
  margin: 0;
}

.pinyin-toggle {
  font-size: 20px;
  color: var(--violet-dark);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.match-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.match-pinyin {
  font-size: 0.75rem;
  color: var(--teal);
  font-weight: 600;
}

.match-pinyin.is-hidden {
  display: none;
}

.match-zh {
  display: block;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.35;
}

.btn-audio-icon:active {
  transform: translateY(1px);
  box-shadow: 0 2px 8px rgba(82, 56, 184, 0.32);
}

.btn-audio-icon.slow:active {
  box-shadow: 0 2px 8px rgba(201, 143, 10, 0.32);
}

.btn-audio-pill {
  min-height: var(--tap);
  padding: 0.45rem 0.9rem;
  border: none;
  border-radius: 999px;
  background: var(--violet);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  touch-action: manipulation;
}

.btn-audio-pill img {
  width: 18px;
  height: 18px;
  filter: brightness(0) invert(1);
}

.dialogue-play-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, #fff0e8 0%, #ffe4d6 100%);
  border: 2px solid #e8a88a;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(255, 122, 89, 0.18);
}

.dialogue-play-row .audio-row {
  justify-content: center;
}

.dialogue-play-label {
  font-weight: 800;
  font-size: var(--font-size-subhead);
  color: #b84a2e;
  width: 100%;
}

.dialogue-play-row .btn-audio-pill:not(.btn-audio-pill--slow) {
  background: var(--violet);
  color: #fff;
}

.dialogue-play-row .btn-audio-pill:not(.btn-audio-pill--slow) img {
  filter: brightness(0) invert(1);
}

.dialogue-play-row .btn-audio-pill--slow {
  background: var(--amber);
  color: #1a1a2e;
}

.dialogue-play-row .btn-audio-pill--slow img {
  filter: none;
}

.examples-toggle {
  background: linear-gradient(135deg, #f3f0ff 0%, #eef8f7 100%);
  border: 1px solid rgba(108, 76, 224, 0.28);
  border-radius: 10px;
  color: var(--violet-dark);
  font-weight: 700;
  font-size: 20px;
  padding: 0.5rem 0.95rem;
  cursor: pointer;
  min-height: var(--tap);
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  box-shadow: 0 2px 8px rgba(108, 76, 224, 0.1);
}

.examples-toggle:hover {
  background: linear-gradient(135deg, #ebe6ff 0%, #e4f5f3 100%);
  border-color: rgba(108, 76, 224, 0.4);
}

.examples-toggle .chevron {
  font-size: 0.75em;
}

.examples-panel {
  display: none;
  margin-top: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: linear-gradient(135deg, #f3f0ff 0%, #eef8f7 100%);
  border: 1px solid #e4dff8;
}

.examples-panel.open {
  display: block;
}

.examples {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem 1rem;
}

.example-line {
  font-size: 0.9rem;
  padding: 0.5rem 0.55rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.example-line .example-en {
  color: var(--muted);
  font-size: 0.85rem;
}

.example-line .zh {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.4;
}

/* Dialogue */
.scene-desc {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  background: #f8f7fc;
  border: 1px solid var(--border);
  font-size: var(--font-size-subhead);
  line-height: 1.55;
  color: var(--text);
}

.scene-img {
  width: 100%;
  border-radius: 12px;
  margin-bottom: 0.75rem;
}

.dialogue-thread {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.25rem;
}

.dialogue-line {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  max-width: 88%;
}

.dialogue-line--left {
  align-self: flex-start;
  flex-direction: row;
}

.dialogue-line--right {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.dialogue-line .avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 3px solid var(--border);
  box-shadow: 0 4px 14px rgba(108, 76, 224, 0.12);
}

.bubble {
  flex: 1;
  min-width: 0;
  padding: 0.65rem 0.75rem;
  border-radius: 14px;
  text-align: left;
}

.dialogue-line--left .bubble {
  background: #f0ecff;
  border: 1px solid #e4dff8;
}

.dialogue-line--right .bubble {
  background: #e8f8f6;
  border: 1px solid #ccefe9;
}

.speaker {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--violet);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Practice */
.practice-section-head {
  position: relative;
  margin-bottom: 0.75rem;
}

.practice-section-head .section-corner-icon {
  top: 0;
  left: 0;
}

.practice-section-head-main {
  padding-left: 0;
}

.practice-section-head .section-head {
  margin-bottom: 0.65rem;
  padding-left: 3.75rem;
}

.practice-section-head .pinyin-toggle {
  display: flex;
  justify-content: center;
  margin: 0 auto;
}

.practice-section-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem 1.25rem;
  margin: 0 auto;
}

.quiz-sfx-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 2px solid var(--violet-dark);
  border-radius: 999px;
  background: #fff;
  color: var(--violet-dark);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.quiz-sfx-toggle:hover {
  background: #f3f0ff;
}

.quiz-sfx-toggle.is-off {
  opacity: 0.55;
  border-color: #9a8fc0;
  color: #6b5f8f;
}

.quiz-sfx-toggle .btn-svg-icon {
  width: 1.35rem;
  height: 1.35rem;
}

.practice-pinyin.is-hidden {
  display: none;
}

/* Each quiz / fill-in / match activity is its own tinted card */
#practice > .practice-block {
  margin-bottom: 1rem;
  padding: 1rem 1rem 1.15rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #faf9fe;
  box-shadow: 0 2px 10px rgba(108, 76, 224, 0.06);
}

.practice-block-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem 0.75rem;
  align-items: start;
  margin-bottom: 0.75rem;
}

.practice-block-head .audio-row {
  margin: 0;
  justify-content: flex-end;
}

.practice-block-head h3 {
  margin: 0;
}

.practice-block--with-audio {
  padding-top: 0.85rem;
}

#practice > .practice-block:last-child {
  margin-bottom: 0;
}

/* Rotate violet / mint / coral / amber so blocks are easy to scan */
#practice > .practice-block:nth-of-type(4n + 2) {
  background: linear-gradient(165deg, #f5f1ff 0%, #faf8ff 55%, #fff 100%);
  border-color: #ddd4f5;
}

#practice > .practice-block:nth-of-type(4n + 3) {
  background: linear-gradient(165deg, #ecf9f6 0%, #f6fcfb 55%, #fff 100%);
  border-color: #c5ebe4;
}

#practice > .practice-block:nth-of-type(4n + 4) {
  background: linear-gradient(165deg, #fff0ec 0%, #fff8f6 55%, #fff 100%);
  border-color: #ffd4c8;
}

#practice > .practice-block:nth-of-type(4n + 5) {
  background: linear-gradient(165deg, #fff8e6 0%, #fffcf3 55%, #fff 100%);
  border-color: #f5e0a8;
}

#practice .practice-block h3,
#practice .practice-block .match-header h3 {
  font-size: var(--font-size-subhead);
  font-weight: 700;
  line-height: 1.45;
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.85rem 0.65rem 0.95rem;
  color: var(--violet-dark);
  background: rgba(255, 255, 255, 0.72);
  border-left: 4px solid var(--violet);
  border-radius: 0 10px 10px 0;
  box-shadow: 0 1px 4px rgba(108, 76, 224, 0.07);
}

#practice .practice-block:nth-of-type(4n + 2) h3,
#practice .practice-block:nth-of-type(4n + 2) .match-header h3 {
  border-left-color: var(--violet);
}

#practice .practice-block:nth-of-type(4n + 3) h3,
#practice .practice-block:nth-of-type(4n + 3) .match-header h3 {
  border-left-color: var(--teal);
}

#practice .practice-block:nth-of-type(4n + 4) h3,
#practice .practice-block:nth-of-type(4n + 4) .match-header h3 {
  border-left-color: var(--coral);
}

#practice .practice-block:nth-of-type(4n + 5) h3,
#practice .practice-block:nth-of-type(4n + 5) .match-header h3 {
  border-left-color: var(--amber-dark);
}

#practice .practice-block .match-header {
  margin-bottom: 0.5rem;
}

#practice .practice-block .match-header h3 {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

#practice .practice-block .fill-sentence {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
  padding: 0.5rem 0.65rem;
  background: rgba(255, 255, 255, 0.65);
  border-radius: 8px;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.choice-btn {
  min-height: var(--tap);
  text-align: left;
  padding: 0.65rem 0.85rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  font-size: 0.95rem;
  cursor: pointer;
  touch-action: manipulation;
}

.choice-btn strong {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.35;
}

.choice-btn.selected {
  border-color: var(--violet);
  background: #f0ecff;
}

.choice-btn.correct {
  border-color: #0a9e4f;
  background: #b8f5d0;
  color: #064d2a;
  box-shadow: inset 0 0 0 1px rgba(10, 158, 79, 0.25);
}

.choice-btn.wrong {
  border-color: #d93030;
  background: #ffc8c8;
  color: #6b1212;
  box-shadow: inset 0 0 0 1px rgba(217, 48, 48, 0.2);
}

.feedback.ok {
  background: #b8f5d0;
  color: #064d2a;
  border: 1px solid #0a9e4f;
}

.feedback.bad {
  background: #ffc8c8;
  color: #6b1212;
  border: 1px solid #d93030;
}

.feedback.neutral {
  background: #f0f4ff;
  color: var(--text);
  border: 1px solid var(--border);
}

.fill-input {
  width: 100%;
  min-height: var(--tap);
  font-size: 1.1rem;
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  margin: 0.5rem 0;
}

.match-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

@media (max-width: 400px) {
  .match-grid {
    grid-template-columns: 1fr;
  }
}

.match-item {
  min-height: var(--tap);
  padding: 0.5rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  font-size: 0.85rem;
  cursor: pointer;
  touch-action: manipulation;
  text-align: center;
}

.match-item.selected {
  border-color: var(--violet);
  background: #f0ecff;
}

.match-item.matched {
  opacity: 0.5;
  pointer-events: none;
}

.match-item.correct-pair {
  border-color: #0a9e4f;
  background: #b8f5d0;
}

.feedback {
  font-size: 0.9rem;
  margin-top: 0.5rem;
  padding: 0.5rem;
  border-radius: 8px;
}


.feedback.pop {
  animation: feedback-pop 0.35s ease;
}

@keyframes feedback-pop {
  0% {
    transform: scale(0.96);
    opacity: 0.6;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.chunk-tip {
  background: #fff8e6;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border-left: 3px solid var(--coral);
}

.fill-sentence {
  font-size: 1.3rem;
  font-weight: 600;
}

.privacy-notice {
  font-size: 0.8rem;
  color: var(--muted);
  background: #f0f4ff;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  margin-bottom: 0.75rem;
}

.speak-row--speech .privacy-details,
.speak-row--main .privacy-details {
  position: relative;
  display: inline-flex;
  align-self: center;
}

.privacy-details {
  position: relative;
  display: inline-flex;
}

.privacy-details summary {
  list-style: none;
}

.privacy-details summary::-webkit-details-marker {
  display: none;
}

.btn-privacy-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  touch-action: manipulation;
}

.btn-privacy-info:hover {
  color: var(--violet-dark);
}

.privacy-info-svg {
  width: 18px;
  height: 18px;
  display: block;
}

.privacy-popover-body {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.35rem);
  z-index: 20;
  width: min(280px, 85vw);
  margin: 0;
  padding: 0.6rem 0.75rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

/* Speak */
#speak .section-intro {
  text-align: center;
}

.speak-prompt {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 0.85rem;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.speak-prompt .speak-target.chunk-zh {
  font-size: clamp(1.85rem, 5.5vw, 2.25rem);
  font-weight: 700;
  margin: 0.35rem 0;
  line-height: 1.3;
}

/* Dialogue bubbles: main line already uses .chunk-zh (1.5rem) — leave as-is */
.dialogue-line .bubble .chunk-zh {
  font-size: 1.45rem;
}

.speak-audio-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0.35rem 0 0.65rem;
}

.speak-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.speak-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.speak-row--audio .audio-row {
  justify-content: center;
}

.btn-speak-action {
  min-height: var(--tap);
  padding: 0.5rem 0.85rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  touch-action: manipulation;
  white-space: nowrap;
}

.btn-mic {
  border: none;
  background: #e8590a;
  color: #fff;
  font-weight: 700;
  box-shadow: none;
}

.btn-mic:hover {
  background: #cf4d08;
}

.btn-mic.listening,
.btn-record.listening {
  background: var(--error);
  color: #fff;
}

.btn-record,
.btn-playback {
  border: 2px solid var(--teal);
  background: #fff;
  color: var(--teal);
}

.btn-playback:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-speak-action.btn-secondary {
  border: 2px solid var(--violet);
  background: transparent;
  color: var(--violet);
  min-width: 4.5rem;
}

.btn-mic .btn-svg-icon,
.btn-record .btn-svg-icon {
  width: 18px;
  height: 18px;
  color: currentColor;
}

.heard {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0.5rem 0;
  min-height: 1.25rem;
}

.heard-pinyin {
  display: inline;
  font-size: 0.92em;
  color: var(--muted);
  font-style: italic;
}

/* Lesson nav */
.lesson-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 1rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
}

.lesson-nav-status {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--violet-dark);
  flex: 1;
  text-align: center;
  min-width: 6rem;
  padding: 0.35rem 0.65rem;
  background: #f0ecff;
  border-radius: 999px;
}

.btn-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0.5rem 0.95rem;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  touch-action: manipulation;
  border: 2px solid transparent;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    color 0.15s ease;
}

.btn-nav:focus-visible {
  outline: 3px solid rgba(108, 76, 224, 0.45);
  outline-offset: 2px;
}

/* Previous — secondary (active link on lesson 2+) */
.btn-nav-prev {
  background: #fff;
  color: var(--violet-dark);
  border-color: #c9bff5;
  box-shadow: 0 1px 4px rgba(108, 76, 224, 0.1);
}

.btn-nav-prev:hover {
  background: #f5f2ff;
  border-color: var(--violet);
  color: var(--violet);
}

/* Next — same outline style as Previous */
.btn-nav-next,
.btn-nav-next.btn-nav-warn {
  background: #fff;
  color: var(--violet-dark);
  border-color: #c9bff5;
  box-shadow: 0 1px 4px rgba(108, 76, 224, 0.1);
}

.btn-nav-next:hover,
.btn-nav-next.btn-nav-warn:hover {
  background: #f5f2ff;
  border-color: var(--violet);
  color: var(--violet);
}

/* Unavailable prev (lesson 1) or next (last lesson) */
.btn-nav.btn-nav-disabled {
  background: #e8e6f0;
  color: #7a7894;
  border: 2px dashed #cac7d8;
  box-shadow: none;
  cursor: default;
  pointer-events: none;
  font-weight: 600;
}

.lesson-nav-note {
  font-size: 0.8rem;
  color: var(--muted);
  margin: -0.5rem 0 1rem;
}

/* Footer */
.footer {
  text-align: center;
  padding: 0.5rem 0 1.5rem;
}

.footer-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.footer-panel .lesson-nav {
  border-top: none;
  padding-top: 0;
  margin-bottom: 0.85rem;
}

.lesson-nav-dev-note {
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.75rem;
  font-size: 0.82rem;
  line-height: 1.45;
  text-align: left;
  color: #5c4510;
  background: #fff8e6;
  border: 1px solid #e8c96a;
  border-radius: 10px;
}

.lesson-nav-dev-note code {
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.7);
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
}

.tags-heading {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--violet-dark);
  margin: 0 0 0.5rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.65rem;
  margin: 0 0 1rem;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  background: #f5f2ff;
  border: 1px solid #d9cffb;
  color: var(--violet-dark);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}

.footer-link:hover {
  background: #ebe6ff;
  border-color: var(--violet);
  color: var(--violet);
}

.tag {
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
  background: #f0ecff;
  color: var(--violet-dark);
  border-radius: 999px;
  font-weight: 600;
}

.btn-reset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0.5rem 1rem;
  border: 2px solid #e8a0a0;
  border-radius: 10px;
  background: #fff5f5;
  color: #b42323;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.btn-reset:hover {
  background: #ffebeb;
  border-color: var(--error);
  color: #8f1c1c;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Desktop readability (round 2) */
@media (min-width: 768px) {
  .lesson-title-block .lesson-title {
    font-size: 40px;
  }

  .lesson-position {
    font-size: 30px;
    color: var(--violet-dark);
  }

  .section-corner-icon {
    width: 60px;
    height: 60px;
  }

  .section-head {
    padding: 0.5rem 1rem 0 4.75rem;
  }

  .practice-section-head .section-head {
    padding-left: 4.75rem;
  }

  .section-title-lg {
    font-size: clamp(2.5rem, 4.2vw, 3.75rem);
  }

  .scene-desc {
    padding: 0.9rem 1.1rem;
  }

  .dialogue-thread {
    gap: 1.1rem;
  }

  .dialogue-line {
    max-width: 100%;
    gap: 1rem;
  }

  .dialogue-line .avatar {
    width: 150px;
    height: 150px;
    border-width: 3px;
  }

  .dialogue-line .bubble {
    padding: 0.85rem 1rem;
  }

  .dialogue-line .bubble .chunk-zh {
    font-size: 1.12em;
  }

  .chunk-card > .chunk-zh {
    font-size: 30px;
  }

  .heard {
    font-size: var(--font-size-subhead);
  }
}
