/* ============================================
   Dictado Babbel — Sistema visual
   Variante A (safe/polished) + Variante B (bold)
   Curso 2do (teal/amber) vs Curso 4to (violet/indigo)
============================================ */

:root {
  /* tipografía */
  --font-ui: "Nunito", "Avenir Next", system-ui, sans-serif;
  --font-display: "Baloo 2", "Nunito", system-ui, sans-serif;
  --font-hand: "Caveat", "Patrick Hand", cursive;

  /* escala */
  --text-scale: 1;

  /* base */
  --ink: #1d2436;
  --ink-soft: #4a5670;
  --ink-mute: #8a93a6;
  --ink-line: #d8deea;
  --ink-wash: #f4f7fb;

  /* variante A — safe */
  --a-bg: #fff8ee;
  --a-bg-2: #fef1e0;
  --a-panel: #ffffff;
  --a-line: #f2e6d3;
  --a-primary: #ff8a3d;     /* coral naranja */
  --a-primary-ink: #7a3a0e;
  --a-success: #2ec27e;
  --a-success-soft: #e6f7ee;
  --a-warm: #ffd86b;

  /* curso — 2do básico (teal + amarillo) */
  --c2-hue: #17b5a8;
  --c2-hue-soft: #d8f5f1;
  --c2-accent: #ffcb3a;
  --c2-ink: #0f6e67;

  /* curso — 4to básico (violet + indigo) */
  --c4-hue: #7a5af8;
  --c4-hue-soft: #ece7ff;
  --c4-accent: #ff6ea1;
  --c4-ink: #3f2c8a;

  /* variante B — paper/stickers */
  --b-paper: #fdfbf5;
  --b-rule: #ccd6e0;
  --b-highlight: #fff3a8;
  --b-pen: #2a2f4a;
  --b-tape: #ffd86b;

  /* sombras */
  --shadow-sm: 0 2px 6px rgba(29,36,54,0.06);
  --shadow-md: 0 10px 24px rgba(29,36,54,0.10);
  --shadow-lg: 0 18px 48px rgba(29,36,54,0.14);
  --shadow-pop: 0 6px 0 rgba(29,36,54,0.12);

  /* radios */
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 28px;
  --r-pill: 999px;
}

/* ============ Base ============ */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--a-bg);
  font-size: calc(16px * var(--text-scale));
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input {
  font-family: inherit;
}

img {
  max-width: 100%;
  display: block;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 800;
  margin: 0;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

/* ============ App shell ============ */

.app {
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  transition: background 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

.app-container {
  width: min(780px, 100%);
  margin: 0 auto;
  padding: 20px 18px 100px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

/* ============ VARIANT A — Babbel/Duolingo polished ============ */

.variant-a {
  background: var(--a-bg);
  background-image:
    radial-gradient(circle at 10% -5%, var(--a-bg-2) 0%, transparent 45%),
    radial-gradient(circle at 110% 5%, #fff3e3 0%, transparent 55%);
}

.variant-a .card {
  background: var(--a-panel);
  border-radius: var(--r-xl);
  border: 1px solid var(--a-line);
  box-shadow: var(--shadow-md);
  padding: 22px;
}

.variant-a .btn-primary {
  background: var(--a-primary);
  color: #fff;
  padding: 16px 22px;
  border-radius: var(--r-pill);
  font-size: 1rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  box-shadow: 0 4px 0 #d36318;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.variant-a .btn-primary:hover { transform: translateY(-1px); }
.variant-a .btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #d36318;
}
.variant-a .btn-primary:disabled {
  background: #e4e7ef;
  color: #9aa3b4;
  box-shadow: 0 4px 0 #cfd3dc;
  cursor: not-allowed;
}

.variant-a .btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  padding: 14px 18px;
  border-radius: var(--r-pill);
  border: 2px solid var(--a-line);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.variant-a .btn-ghost:hover { background: var(--a-bg-2); }

/* ============ VARIANT B — paper & stickers ============ */

.variant-b {
  background: var(--b-paper);
  background-image:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 31px,
      rgba(124,146,168,0.12) 32px
    ),
    radial-gradient(circle at 92% 8%, rgba(255,216,107,0.28), transparent 40%);
  background-attachment: fixed;
}

.variant-b .card {
  background: #fffef9;
  border-radius: 6px;
  border: 1.5px solid #2a2f4a;
  box-shadow: 4px 4px 0 #2a2f4a;
  padding: 22px 22px 24px;
  position: relative;
}

.variant-b .card::before {
  /* tape */
  content: "";
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  width: 90px;
  height: 22px;
  background: var(--b-tape);
  opacity: 0.85;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border-radius: 1px;
}

.variant-b .btn-primary {
  background: var(--b-pen);
  color: #fff;
  padding: 15px 24px;
  border-radius: 999px;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  box-shadow: 3px 3px 0 var(--b-tape);
  border: 1.5px solid var(--b-pen);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.variant-b .btn-primary:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 var(--b-tape); }
.variant-b .btn-primary:active {
  transform: translate(2px,2px);
  box-shadow: 1px 1px 0 var(--b-tape);
}
.variant-b .btn-primary:disabled {
  background: #d8dde6;
  color: #8a93a6;
  box-shadow: 3px 3px 0 #b8bec8;
  border-color: #b8bec8;
  cursor: not-allowed;
}

.variant-b .btn-ghost {
  background: #fffef9;
  color: var(--b-pen);
  padding: 13px 18px;
  border-radius: 999px;
  border: 1.5px solid var(--b-pen);
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.variant-b .btn-ghost:hover { background: var(--b-highlight); }

/* ============ Course theming ============ */
.course-2b {
  --c-hue: var(--c2-hue);
  --c-hue-soft: var(--c2-hue-soft);
  --c-accent: var(--c2-accent);
  --c-ink: var(--c2-ink);
}
.course-4b {
  --c-hue: var(--c4-hue);
  --c-hue-soft: var(--c4-hue-soft);
  --c-accent: var(--c4-accent);
  --c-ink: var(--c4-ink);
}

/* ============ Top bar ============ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 6px 18px;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  transition: background 0.15s;
}
.icon-btn:hover { background: rgba(0,0,0,0.05); }

.progress-bar {
  flex: 1;
  height: 14px;
  border-radius: 999px;
  background: rgba(0,0,0,0.08);
  overflow: hidden;
  position: relative;
}
.variant-b .progress-bar {
  background: #fff;
  border: 1.5px solid var(--b-pen);
  height: 16px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--c-hue), var(--c-accent));
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.06), inset 0 4px 0 rgba(255,255,255,0.25);
}
.variant-b .progress-fill {
  background: var(--c-hue);
  box-shadow: none;
}

.xp-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1.5px solid var(--a-line);
  font-weight: 800;
  color: var(--a-primary-ink);
  font-size: 0.92rem;
}
.variant-b .xp-chip {
  background: var(--b-highlight);
  border-color: var(--b-pen);
  color: var(--b-pen);
}
.xp-chip svg { width: 16px; height: 16px; }

/* ============ Home ============ */

.home-hero {
  text-align: center;
  padding: 28px 18px 22px;
}
.home-hero .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--c-ink);
  font-weight: 800;
  font-size: 0.78rem;
  margin-bottom: 6px;
}
.home-hero h1 {
  font-size: clamp(2.1rem, 6vw, 2.9rem);
  color: var(--c-ink);
}
.home-hero .home-sub {
  color: var(--ink-soft);
  margin: 10px 0 0;
  font-size: 1.05rem;
}

.course-switch {
  display: inline-flex;
  padding: 6px;
  border-radius: var(--r-pill);
  background: #fff;
  border: 1.5px solid var(--a-line);
  box-shadow: var(--shadow-sm);
  margin: 16px auto 0;
}
.variant-b .course-switch {
  border-color: var(--b-pen);
  box-shadow: 3px 3px 0 var(--b-pen);
  background: #fffef9;
}
.course-switch button {
  padding: 10px 18px;
  border-radius: var(--r-pill);
  color: var(--ink-soft);
  font-size: 0.95rem;
  font-weight: 800;
  white-space: nowrap;
  transition: all 0.15s;
}
.course-switch button.active {
  background: var(--c-hue);
  color: #fff;
}
.variant-b .course-switch button.active {
  background: var(--b-pen);
}

.lesson-path {
  display: grid;
  gap: 18px;
  margin: 24px auto 0;
}

.home-credit {
  margin: 22px 0 0;
  text-align: center;
  color: var(--ink-mute);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.lesson-node {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 18px;
  border-radius: var(--r-lg);
  background: #fff;
  border: 1px solid var(--a-line);
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  text-align: left;
  cursor: pointer;
  width: 100%;
}
.lesson-node:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.variant-b .lesson-node {
  background: #fffef9;
  border: 1.5px solid var(--b-pen);
  border-radius: 6px;
  box-shadow: 3px 3px 0 var(--b-pen);
}
.variant-b .lesson-node:hover {
  transform: translate(-1px,-1px);
  box-shadow: 4px 4px 0 var(--b-pen);
}

.lesson-node.locked {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.3);
}
.lesson-node.done .lesson-medal {
  background: var(--a-success);
  color: #fff;
}

.lesson-medal {
  width: 64px;
  height: 64px;
  border-radius: 999px;
  background: var(--c-hue-soft);
  color: var(--c-ink);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  position: relative;
}
.variant-b .lesson-medal {
  border: 1.5px solid var(--b-pen);
  background: var(--b-highlight);
}

.lesson-medal .lock-ico, .lesson-medal .check-ico {
  position: absolute;
  bottom: -6px;
  right: -6px;
  width: 26px;
  height: 26px;
  background: #fff;
  border-radius: 999px;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
  border: 1.5px solid var(--a-line);
  color: var(--ink-mute);
}
.lesson-node.done .lesson-medal .check-ico {
  color: var(--a-success);
  border-color: var(--a-success);
}

.lesson-info {
  min-width: 0;
}
.lesson-info h3 {
  font-size: 1.25rem;
  color: var(--ink);
  margin-bottom: 4px;
}
.lesson-info p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stars {
  display: inline-flex;
  gap: 3px;
}
.stars .star {
  width: 18px;
  height: 18px;
  color: #d7dce5;
}
.stars .star.filled {
  color: var(--c-accent);
}

.lesson-cta {
  display: grid;
  place-items: center;
  padding: 10px 14px;
  border-radius: var(--r-pill);
  background: var(--c-hue);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 86px;
}
.variant-b .lesson-cta {
  background: var(--b-pen);
  border-radius: 999px;
}

/* ============ Lesson — mascot strip ============ */

.mascot-strip {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 14px;
  margin: 4px 0 16px;
  align-items: end;
}

.mascot {
  width: 88px;
  height: 88px;
  position: relative;
}
.mascot svg { width: 100%; height: 100%; display: block; }
.mascot.bounce { animation: mascot-bounce 1.4s ease-in-out infinite; transform-origin: bottom center; }
@keyframes mascot-bounce {
  0%, 100% { transform: translateY(0) scale(1,1); }
  50% { transform: translateY(-6px) scale(0.98, 1.02); }
}

.mascot-bubble {
  background: #fff;
  border-radius: 18px;
  padding: 14px 16px;
  border: 1px solid var(--a-line);
  box-shadow: var(--shadow-sm);
  position: relative;
  font-weight: 700;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.35;
  min-height: 56px;
  display: flex;
  align-items: center;
}
.mascot-bubble::before {
  content: "";
  position: absolute;
  left: -8px;
  bottom: 14px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-left: 1px solid var(--a-line);
  border-bottom: 1px solid var(--a-line);
  transform: rotate(45deg);
}
.variant-b .mascot-bubble {
  background: #fffef9;
  border: 1.5px solid var(--b-pen);
  border-radius: 8px;
  box-shadow: 3px 3px 0 var(--b-pen);
}
.variant-b .mascot-bubble::before {
  background: #fffef9;
  border-left-color: var(--b-pen);
  border-bottom-color: var(--b-pen);
  left: -9px;
}

/* ============ Stage container ============ */

.stage {
  display: grid;
  gap: 18px;
}

.stage-title {
  font-size: 1.35rem;
  color: var(--ink);
  line-height: 1.2;
  text-wrap: balance;
}
.stage-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--c-ink);
  font-weight: 800;
  font-size: 0.75rem;
  margin-bottom: 6px;
}

/* stage: listen */
.listen-stage {
  text-align: center;
  padding: 36px 18px;
}
.listen-stage .play-hero {
  width: 140px;
  height: 140px;
  border-radius: 999px;
  background: var(--c-hue);
  color: #fff;
  display: grid;
  place-items: center;
  justify-self: center;
  margin: 6px auto 22px;
  box-shadow: 0 14px 0 color-mix(in oklab, var(--c-hue) 70%, black), 0 24px 40px rgba(0,0,0,0.12);
  transition: transform 0.1s ease;
  cursor: pointer;
  border: none;
}
.listen-stage .play-hero:hover { transform: translateY(-2px); }
.listen-stage .play-hero:active {
  transform: translateY(6px);
  box-shadow: 0 8px 0 color-mix(in oklab, var(--c-hue) 70%, black);
}
.listen-stage .play-hero svg { width: 60px; height: 60px; margin-left: 8px; }

.listen-stage .play-hero.playing {
  animation: pulse-ring 1.4s ease-out infinite;
}
@keyframes pulse-ring {
  0% { box-shadow: 0 14px 0 color-mix(in oklab, var(--c-hue) 70%, black), 0 0 0 0 color-mix(in oklab, var(--c-hue) 40%, transparent); }
  70% { box-shadow: 0 14px 0 color-mix(in oklab, var(--c-hue) 70%, black), 0 0 0 28px transparent; }
  100% { box-shadow: 0 14px 0 color-mix(in oklab, var(--c-hue) 70%, black), 0 0 0 0 transparent; }
}

.listen-hint {
  color: var(--ink-soft);
  font-weight: 600;
  margin: 0 0 10px;
}

/* stage: meaning */
.meaning-stage {
  padding: 22px;
}
.meaning-image {
  width: 100%;
  min-height: 120px;
  height: clamp(130px, 24vw, 180px);
  background: var(--c-hue-soft);
  border-radius: var(--r-lg);
  display: grid;
  place-items: center;
  font-size: 3.4rem;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--a-line);
}
.variant-b .meaning-image {
  border: 1.5px solid var(--b-pen);
  border-radius: 8px;
  background: var(--b-highlight);
  background-image:
    repeating-linear-gradient(45deg, transparent 0 10px, rgba(0,0,0,0.04) 10px 11px);
}
.meaning-word {
  font-family: var(--font-display);
  font-size: clamp(2rem, 7vw, 2.6rem);
  color: var(--c-ink);
  margin: 14px 0 4px;
  text-align: center;
}
.meaning-def {
  color: var(--ink-soft);
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 10px;
}
.meaning-phonetic {
  text-align: center;
  color: var(--ink-mute);
  font-family: ui-monospace, Menlo, monospace;
  letter-spacing: 0.08em;
  margin: 0 0 8px;
  font-size: 0.92rem;
}

/* stage: accent picker */
.accent-stage .accent-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 14px 0;
}
.accent-option {
  background: #fff;
  border: 2px solid var(--a-line);
  border-radius: var(--r-lg);
  padding: 22px 10px;
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.12s ease;
  position: relative;
}
.variant-b .accent-option {
  border: 1.5px solid var(--b-pen);
  background: #fffef9;
  border-radius: 6px;
  box-shadow: 2px 2px 0 var(--b-pen);
}
.accent-option:hover {
  transform: translateY(-2px);
  border-color: var(--c-hue);
}
.accent-option.selected {
  border-color: var(--c-hue);
  background: var(--c-hue-soft);
  color: var(--c-ink);
}
.accent-option .accent-mark {
  color: var(--a-primary);
  display: inline-block;
}
.variant-b .accent-option .accent-mark {
  color: #d64545;
}

/* stage: build letters */
.build-stage .build-target {
  min-height: 76px;
  background: var(--c-hue-soft);
  border-radius: var(--r-lg);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 16px;
  align-items: center;
  justify-content: center;
  border: 2px dashed color-mix(in oklab, var(--c-hue) 45%, transparent);
}
.variant-b .build-stage .build-target {
  background: #fff;
  border: 1.5px dashed var(--b-pen);
  border-radius: 6px;
}
.build-slot {
  min-width: 34px;
  min-height: 44px;
  border: none;
  border-bottom: 3px solid color-mix(in oklab, var(--c-hue) 55%, transparent);
  background: transparent;
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--c-ink);
  display: grid;
  place-items: center;
  padding: 0 4px;
  cursor: pointer;
  border-radius: 10px;
  transition: background 0.12s ease, transform 0.08s ease;
}
.build-slot:hover { transform: translateY(-1px); }
.build-slot.selected {
  background: color-mix(in oklab, var(--c-hue-soft) 75%, white);
  outline: 2px solid color-mix(in oklab, var(--c-hue) 65%, white);
}
.variant-b .build-slot.selected {
  background: var(--b-highlight);
  outline-color: var(--b-pen);
}

.build-hint {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

.letter-bank {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 8px 0 4px;
}
.letter-tile {
  min-width: 46px;
  height: 54px;
  padding: 0 10px;
  background: #fff;
  border-radius: 12px;
  border: 1.5px solid var(--a-line);
  box-shadow: 0 3px 0 var(--a-line);
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.08s;
}
.letter-tile:hover { transform: translateY(-2px); }
.letter-tile:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--a-line); }
.letter-tile.used {
  visibility: hidden;
  pointer-events: none;
}
.variant-b .letter-tile {
  background: #fffef9;
  border: 1.5px solid var(--b-pen);
  box-shadow: 2px 2px 0 var(--b-pen);
  border-radius: 4px;
}
.variant-b .letter-tile:active {
  box-shadow: 1px 1px 0 var(--b-pen);
  transform: translate(1px,1px);
}

/* stage: write */
.write-stage .input-block {
  display: flex;
  gap: 10px;
  align-items: center;
  background: #fff;
  border: 2px solid var(--a-line);
  border-radius: var(--r-lg);
  padding: 6px 6px 6px 20px;
  transition: border-color 0.15s;
}
.variant-b .write-stage .input-block {
  border: 1.5px solid var(--b-pen);
  background: #fffef9;
  border-radius: 8px;
  box-shadow: 2px 2px 0 var(--b-pen);
}
.write-stage .input-block:focus-within {
  border-color: var(--c-hue);
  box-shadow: 0 0 0 4px var(--c-hue-soft);
}
.write-stage input {
  flex: 1;
  border: none;
  outline: none;
  padding: 18px 4px;
  font-size: 1.3rem;
  font-family: var(--font-display);
  color: var(--ink);
  background: transparent;
  min-width: 0;
}

.audio-ctl {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  background: var(--c-hue);
  color: #fff;
  display: grid;
  place-items: center;
  border: none;
  cursor: pointer;
  transition: transform 0.08s;
  flex-shrink: 0;
}
.audio-ctl:hover { transform: scale(1.05); }
.audio-ctl svg { width: 22px; height: 22px; }

.backspace-btn {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  border: 1.5px solid var(--ink-line);
  background: #fff;
  color: var(--c-ink);
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s, transform 0.12s, border-color 0.12s;
}
.backspace-btn:hover:not(:disabled) { background: var(--ink-wash); transform: scale(1.04); }
.backspace-btn:active:not(:disabled) { transform: scale(0.96); }
.backspace-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.variant-b .backspace-btn {
  border: 1.5px solid var(--b-pen);
  box-shadow: 2px 2px 0 var(--b-pen);
  background: #fffef9;
}

/* stage: dictation full sentence */
.dictation-stage .dictation-card {
  padding: 20px 18px;
}
.dictation-stage .sentence-blanks {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 4.4vw, 1.9rem);
  line-height: 1.45;
  color: var(--ink);
  text-wrap: balance;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: baseline;
  padding: 12px 0;
}
.blank-input {
  display: inline-flex;
  align-items: center;
  background: #fff;
  border: 2px solid var(--a-line);
  border-radius: 12px;
  padding: 4px 10px;
  min-width: 120px;
}
.variant-b .blank-input {
  border: 1.5px solid var(--b-pen);
  background: #fffef9;
  box-shadow: 2px 2px 0 var(--b-pen);
  border-radius: 6px;
}
.blank-input input {
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-display);
  font-size: 1em;
  color: var(--c-ink);
  padding: 6px 2px;
  width: 100%;
}
.blank-input:focus-within {
  border-color: var(--c-hue);
  box-shadow: 0 0 0 4px var(--c-hue-soft);
}
.blank-input.active {
  border-color: var(--c-hue);
  box-shadow: 0 0 0 4px var(--c-hue-soft);
}
.blank-input.correct {
  border-color: var(--a-success);
  background: var(--a-success-soft);
}
.blank-input.correct input { color: var(--a-success); }
.blank-input.wrong {
  border-color: #e76767;
  background: #fff3f3;
}
.blank-input.wrong input { color: #b33535; }
.variant-b .blank-input.wrong {
  border-color: #b33535;
  box-shadow: 2px 2px 0 #b33535;
}

/* ============ Feedback banner ============ */

.feedback-banner {
  position: fixed;
  left: 50%;
  top: 16px;
  transform: translate(-50%, -140%);
  width: min(520px, calc(100% - 24px));
  padding: 16px 18px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  border-radius: var(--r-lg);
  box-shadow: 0 18px 40px rgba(0,0,0,0.18);
  transition: transform 0.32s cubic-bezier(0.2, 1.4, 0.4, 1);
  z-index: 50;
}
.feedback-dismiss-layer {
  position: fixed;
  inset: 0;
  z-index: 49;
  background: transparent;
}
.feedback-banner.show { transform: translate(-50%, 0); }

.feedback-banner.correct {
  background: #2ec27e;
  border: 2px solid #26a56a;
  color: #ffffff;
  animation: fb-pop 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.feedback-banner.almost {
  background: #ffb648;
  border: 2px solid #e69420;
  color: #4a2b00;
  cursor: pointer;
  animation: fb-shake 0.4s ease-in-out;
}
@keyframes fb-pop {
  0% { transform: translate(-50%, 0) scale(0.9); }
  60% { transform: translate(-50%, 0) scale(1.04); }
  100% { transform: translate(-50%, 0) scale(1); }
}
@keyframes fb-shake {
  0%, 100% { transform: translate(-50%, 0) rotate(0); }
  25% { transform: translate(calc(-50% - 4px), 0) rotate(-0.6deg); }
  75% { transform: translate(calc(-50% + 4px), 0) rotate(0.6deg); }
}

.feedback-banner .fb-mascot {
  width: 52px;
  height: 52px;
  background: rgba(255,255,255,0.25);
  border-radius: 999px;
  padding: 4px;
  flex-shrink: 0;
}
.feedback-banner.almost .fb-mascot { background: rgba(255,255,255,0.35); }

.feedback-banner .fb-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1;
}
.feedback-banner .fb-sub {
  font-weight: 700;
  font-size: 0.95rem;
  opacity: 0.92;
  margin-top: 4px;
}

.variant-b .feedback-banner.correct {
  background: var(--b-highlight);
  border: 2px dashed var(--b-pen);
  color: var(--b-pen);
  box-shadow: 4px 4px 0 var(--b-pen);
}
.variant-b .feedback-banner.almost {
  background: #ffe5b0;
  border: 2px dashed #b06a00;
  color: #4a2b00;
  box-shadow: 4px 4px 0 #b06a00;
}

/* ============ Footer action bar ============ */

.action-bar {
  position: sticky;
  bottom: 18px;
  background: transparent;
  padding: 6px 0 0;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  z-index: 5;
}

.action-bar .btn-primary { flex: 1; max-width: 520px; margin-left: auto; }
.action-bar .btn-ghost   { flex: 0; }

/* ============ Result screen ============ */

.result-hero {
  text-align: center;
  padding: 26px 14px 8px;
}
.result-hero h2 {
  font-size: clamp(2rem, 6vw, 2.6rem);
  color: var(--c-ink);
  margin: 10px 0;
}
.result-hero p {
  color: var(--ink-soft);
  margin: 0 auto;
  max-width: 480px;
  font-weight: 600;
  font-size: 1.05rem;
  text-wrap: balance;
}

.result-stars {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
}
.result-stars .star {
  width: auto;
  height: auto;
  display: inline-flex;
}
.result-stars .star svg {
  width: 36px;
  height: 36px;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 20px 0;
}
.result-stat {
  background: #fff;
  border: 1px solid var(--a-line);
  border-radius: var(--r-lg);
  padding: 16px 10px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.variant-b .result-stat {
  border: 1.5px solid var(--b-pen);
  background: #fffef9;
  border-radius: 6px;
  box-shadow: 2px 2px 0 var(--b-pen);
}
.result-stat .big {
  font-family: var(--font-display);
  font-size: 1.9rem;
  color: var(--c-ink);
  line-height: 1;
}
.result-stat .lbl {
  font-size: 0.78rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 6px;
  font-weight: 800;
}

.learned-list {
  display: grid;
  gap: 8px;
  margin: 16px 0 24px;
}
.learned-chip {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-radius: var(--r-lg);
  background: #fff;
  border: 1px solid var(--a-line);
}
.variant-b .learned-chip {
  background: #fffef9;
  border: 1.5px solid var(--b-pen);
  border-radius: 6px;
  box-shadow: 2px 2px 0 var(--b-pen);
}
.learned-chip .chip-icon {
  width: 36px; height: 36px;
  border-radius: 999px;
  background: var(--c-hue-soft);
  display: grid; place-items: center;
  font-size: 1.2rem;
}
.learned-chip .chip-word {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--ink);
}
.learned-chip .chip-meta {
  color: var(--ink-soft);
  font-size: 0.88rem;
  font-weight: 700;
}

/* ============ Confetti + celebrate ============ */
.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 20;
}
.confetti-piece {
  position: absolute;
  width: 10px;
  height: 14px;
  top: -20px;
  animation: confetti-fall 2.4s linear forwards;
}
@keyframes confetti-fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0.6; }
}

/* ============ Tweaks panel ============ */

.tweaks-panel {
  position: fixed;
  right: 14px;
  bottom: 14px;
  width: 280px;
  background: #fff;
  border-radius: var(--r-lg);
  border: 1px solid var(--a-line);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  z-index: 40;
  display: none;
  font-size: 0.9rem;
}
.tweaks-panel.open { display: block; }
.tweaks-panel h4 {
  font-size: 1rem;
  margin-bottom: 10px;
  color: var(--ink);
}
.tweaks-row { display: grid; gap: 6px; margin-bottom: 12px; }
.tweaks-row label { font-weight: 800; font-size: 0.8rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.05em; }
.tweaks-seg {
  display: inline-flex;
  background: #f2f3f8;
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
}
.tweaks-seg button {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.tweaks-seg button.on {
  background: var(--a-primary);
  color: #fff;
}

.tweaks-toggle-btn {
  position: fixed;
  right: 14px;
  bottom: 14px;
  width: 46px;
  height: 46px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--a-line);
  box-shadow: var(--shadow-md);
  display: none;
  place-items: center;
  z-index: 41;
  color: var(--ink-soft);
}
.tweaks-toggle-btn.show { display: grid; }

/* ============ Utils ============ */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* responsive */
@media (max-width: 520px) {
  .result-stats { grid-template-columns: 1fr 1fr 1fr; }
  .listen-stage .play-hero { width: 120px; height: 120px; }
  .listen-stage .play-hero svg { width: 48px; height: 48px; }
  .meaning-image { min-height: 104px; height: clamp(110px, 34vw, 150px); font-size: 2.8rem; }
  .result-stars { gap: 12px; }
  .result-stars .star svg { width: 34px; height: 34px; }

  .write-stage .input-block {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    gap: 8px;
    padding: 6px 8px 6px 10px;
    border-radius: 14px;
  }
  .write-stage .audio-ctl,
  .write-stage .backspace-btn {
    width: 44px;
    height: 44px;
  }
  .write-stage .audio-ctl svg {
    width: 18px;
    height: 18px;
  }
  .write-stage input {
    font-size: 1.1rem;
    padding: 12px 2px;
  }
  .write-stage .action-bar {
    position: static;
    padding-top: 10px;
  }
  .write-stage .action-bar .btn-primary {
    max-width: none;
    width: 100%;
    margin-left: 0;
  }
}
