/* ─── Screen transitions ─────────────────────────────────────────────────── */
.screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow-y: auto;
  background: linear-gradient(to bottom right, #f1f5f9, #eff6ff, #f0fdf4);
}
.screen.active {
  display: flex;
  flex-direction: column;
  z-index: 2;
}

/* ─── Avatar picker ──────────────────────────────────────────────────────── */
.avatar-btn {
  border: 2px solid transparent;
  border-radius: 12px;
  transition: all 0.2s;
  cursor: pointer;
}
.avatar-btn:hover {
  background: #e0f2fe;
}
.avatar-btn.selected {
  border-color: #2563eb;
  background: #dbeafe;
}

/* ─── Profile cards ──────────────────────────────────────────────────────── */
.profile-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  cursor: default;
  border: 2px solid transparent;
  transition: all 0.2s;
}
.profile-card-delete {
  opacity: 0;
  transition: opacity 0.2s;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: #d1d5db;
  padding: 0 4px;
}
.profile-card:hover .profile-card-delete {
  opacity: 1;
}
.profile-card-delete:hover {
  color: #ef4444 !important;
}
.profile-card:hover {
  border-color: #2563eb;
  transform: scale(1.02);
}
.profile-card:active {
  transform: scale(0.98);
}

/* ─── Chat bubbles ───────────────────────────────────────────────────────── */
.chat-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.5;
  animation: fadeIn 0.3s ease;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.chat-bubble.teacher {
  background: white;
  border: 2px solid #cbd5e1;
  color: #1e293b;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.chat-bubble.child {
  background: linear-gradient(135deg, #2563eb, #0d9488);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Mic button states ──────────────────────────────────────────────────── */
/* Legacy mic-btn override kept for specificity */
#mic-btn.recording {
  background: linear-gradient(135deg, #ef4444, #f97316) !important;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* ─── Stars ──────────────────────────────────────────────────────────────── */
.star {
  font-size: 2.5rem;
  animation: starPop 0.5s ease;
}
.star:nth-child(2) { animation-delay: 0.1s; }
.star:nth-child(3) { animation-delay: 0.2s; }
.star:nth-child(4) { animation-delay: 0.3s; }
.star:nth-child(5) { animation-delay: 0.4s; }

@keyframes starPop {
  0% { transform: scale(0); }
  70% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* ─── Loading dots ───────────────────────────────────────────────────────── */
.loading-dots::after {
  content: '';
  animation: dots 1.5s infinite;
}
@keyframes dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

/* ─── Book Panel ─────────────────────────────────────────────────────────── */
.book-tab {
  background: transparent;
  color: #92400e;
  transition: all 0.2s;
}
.book-tab.active {
  background: white;
  color: #92400e;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.book-tab:hover:not(.active) {
  background: rgba(255,255,255,0.5);
}

/* Dialogue items */
.dialogue-item {
  padding: 8px 12px;
  border-radius: 10px;
  border-left: 3px solid #e5e7eb;
  background: white;
  transition: all 0.3s;
  font-size: 14px;
}
.dialogue-item .speaker {
  font-weight: 600;
  color: #1e40af;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.dialogue-item .text {
  color: #374151;
  margin-top: 2px;
}
.dialogue-item.highlighted {
  border-left-color: #f59e0b;
  background: #fef3c7;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3);
  transform: scale(1.02);
}

/* Vocabulary cards */
.vocab-card {
  padding: 8px 10px;
  border-radius: 10px;
  background: white;
  border: 1px solid #e5e7eb;
  transition: all 0.3s;
  font-size: 13px;
}
.vocab-card .word {
  font-weight: 700;
  color: #1e40af;
}
.vocab-card .translation {
  color: #6b7280;
  font-size: 11px;
}
.vocab-card .pronunciation {
  color: #0d9488;
  font-size: 11px;
  font-style: italic;
  letter-spacing: 0.5px;
}
.vocab-card.highlighted {
  border-color: #f59e0b;
  background: #fef3c7;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3);
  transform: scale(1.05);
}

/* Sentence items */
.sentence-item {
  padding: 8px 12px;
  border-radius: 10px;
  background: white;
  border: 1px solid #e5e7eb;
  font-size: 14px;
  color: #374151;
  transition: all 0.3s;
}
.sentence-item.highlighted {
  border-color: #f59e0b;
  background: #fef3c7;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3);
  font-weight: 600;
}

/* Highlight pulse animation */
@keyframes highlightPulse {
  0% { box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3); }
  50% { box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.1); }
  100% { box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3); }
}
.highlighted {
  animation: highlightPulse 2s ease infinite;
}

/* ─── Lesson screen ──────────────────────────────────────────────────────── */
#screen-lesson.active {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* ─── 3-Column Layout ────────────────────────────────────────────────────── */
.three-col-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 230px 1fr 290px;
  min-height: 0;
  overflow: hidden;
}

/* Tablet (768–1023px): teacher + chat, book → bottom sheet */
@media (max-width: 1023px) {
  .three-col-layout {
    grid-template-columns: 170px 1fr;
  }
}

/* Mobile (<640px): compact teacher strip + chat */
@media (max-width: 639px) {
  .three-col-layout {
    grid-template-columns: 72px 1fr;
  }
}

/* ─── Teacher Panel ──────────────────────────────────────────────────────── */
.teacher-panel {
  background: linear-gradient(165deg, #0f172a 0%, #1e3a5f 50%, #164e63 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 24px 14px 18px;
  border-right: 1px solid rgba(255,255,255,0.12);
  overflow: hidden;
}

.teacher-panel-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  flex: 1;
  justify-content: center;
  width: 100%;
}

/* Lily avatar ring */
.lily-ring {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08);
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
  flex-shrink: 0;
}
.lily-ring.state-speaking {
  border-color: #fde047;
  box-shadow: 0 0 0 6px rgba(253,224,71,0.2), 0 0 28px rgba(253,224,71,0.15);
  animation: speakPulse 0.9s ease-in-out infinite;
}
.lily-ring.state-listening {
  border-color: #34d399;
  box-shadow: 0 0 0 6px rgba(52,211,153,0.2);
  animation: listenPulse 1.4s ease-in-out infinite;
}
.lily-ring.state-thinking {
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(147,197,253,0.2);
  animation: thinkSpin 3s linear infinite;
}

.lily-avatar {
  font-size: 3.8rem;
  line-height: 1;
  user-select: none;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.25));
}

.lily-status-label {
  font-size: 11px;
  color: rgba(255,255,255,0.8);
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  text-align: center;
  min-height: 16px;
}

.word-display-panel {
  width: 100%;
  padding: 10px 12px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 12px;
  text-align: center;
}
.word-display-text {
  font-size: 14px;
  font-weight: 700;
  color: white;
  line-height: 1.4;
}

/* Controls */
.teacher-controls {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.teacher-status-text {
  font-size: 11px;
  color: rgba(255,255,255,0.65);
  text-align: center;
  min-height: 16px;
  word-break: break-word;
}
.mic-main-btn {
  width: 100%;
  padding: 12px 8px;
  border-radius: 16px;
  font-weight: 700;
  font-size: 14px;
  background: white;
  color: #1e3a5f;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.mic-main-btn:hover {
  box-shadow: 0 6px 18px rgba(0,0,0,0.22);
  transform: translateY(-1px);
}
.mic-main-btn:active { transform: scale(0.97); }
.mic-main-btn.recording {
  background: linear-gradient(135deg, #ef4444, #f97316) !important;
  color: white;
  animation: pulse 1s infinite;
}
.replay-btn {
  width: 100%;
  padding: 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255,255,255,0.18);
  color: white;
  border: 1px solid rgba(255,255,255,0.28);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.replay-btn:hover { background: rgba(255,255,255,0.28); }

/* Mobile overrides */
@media (max-width: 639px) {
  .teacher-panel {
    padding: 10px 5px 10px;
    justify-content: center;
    gap: 10px;
  }
  .teacher-panel-inner { gap: 8px; flex: 0; }
  .lily-ring { width: 56px; height: 56px; }
  .lily-avatar { font-size: 2rem; }
  .lily-status-label { display: none; }
  .word-display-panel { display: none !important; }
  .mic-btn-label { display: none; }
  .mic-main-btn { padding: 10px 4px; font-size: 20px; border-radius: 12px; }
  .replay-btn { padding: 7px 4px; font-size: 16px; }
  .replay-btn span { display: none; }
  .teacher-status-text { display: none; }
}

@keyframes speakPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
@keyframes listenPulse {
  0%, 100% { box-shadow: 0 0 0 6px rgba(52,211,153,0.2); }
  50% { box-shadow: 0 0 0 14px rgba(52,211,153,0.05); }
}
@keyframes thinkSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ─── Chat Panel Column ──────────────────────────────────────────────────── */
.chat-panel-col {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(to bottom, #f8fafc, #f0f9ff);
}
.chat-panel-header {
  padding: 8px 14px;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
  background: white;
}
.chat-area-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ─── Book Panel Column ──────────────────────────────────────────────────── */
.book-panel-col {
  background: linear-gradient(to bottom, #fffbeb, #ffffff);
  border-left: 1px solid #fde68a;
  overflow: hidden;
}
.book-panel-header {
  padding: 10px 12px;
  background: #fef3c7;
  border-bottom: 1px solid #fde68a;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ─── Floating Phase Nav Bar ─────────────────────────────────────────────── */
.phase-nav-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #e2e8f0;
  padding: 4px 8px 5px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.pnav-btn {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  transition: all 0.18s;
  white-space: nowrap;
  flex-shrink: 0;
}
.pnav-btn:hover:not(.locked) { background: #f1f5f9; color: #475569; }
.pnav-btn.active  { background: #dbeafe; color: #1e40af; }
.pnav-btn.done    { color: #22c55e; }
.pnav-btn.done::after { content: ' ✓'; }
.pnav-btn.locked  { opacity: 0.35; cursor: not-allowed; }
.pnav-sep { color: #cbd5e1; font-size: 10px; user-select: none; flex-shrink: 0; }

/* ─── Practice Screen ────────────────────────────────────────────────────── */
.practice-tab-btn {
  padding: 10px 6px;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  border-bottom: 3px solid transparent;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.practice-tab-btn.active {
  color: #1e3a5f;
  border-bottom-color: #2563eb;
}
.practice-tab-btn.done::after {
  content: ' ✓';
  color: #22c55e;
}
.practice-tab-content {
  min-height: 100%;
}

/* ─── RAM Card ───────────────────────────────────────────────────────────── */
.ram-card {
  background: white;
  border-radius: 20px;
  padding: 22px 18px 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.07);
  border: 1px solid #e2e8f0;
  max-width: 480px;
  margin: 0 auto;
}
.ram-progress-track {
  height: 5px;
  background: #e2e8f0;
  border-radius: 3px;
  margin-bottom: 20px;
  overflow: hidden;
}
.ram-progress-fill {
  height: 100%;
  background: linear-gradient(to right, #2563eb, #0d9488);
  border-radius: 3px;
  transition: width 0.4s ease;
}
.ram-listen-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #1e3a5f, #2563eb);
  color: white;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(37,99,235,0.25);
}
.ram-listen-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(37,99,235,0.35); }
.ram-listen-btn:active { transform: scale(0.97); }
.ram-listen-btn:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }
.ram-speak-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #059669, #0d9488);
  color: white;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(5,150,105,0.25);
  animation: speakPulse 1.4s ease-in-out infinite;
}
.ram-speak-btn:hover { transform: translateY(-1px); }
.ram-speak-btn:active { transform: scale(0.97); }

/* ─── Puzzle Grid ────────────────────────────────────────────────────────── */
.puzzle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-width: 600px;
  margin: 0 auto;
}
.puzzle-grid-sentences {
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.puzzle-item {
  padding: 10px 10px;
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  text-align: center;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  word-break: break-word;
  line-height: 1.3;
}
.puzzle-item:hover { border-color: #94a3b8; background: #f8fafc; }
.puzzle-item.selected-left  { border-color: #2563eb; background: #dbeafe; color: #1e40af; }
.puzzle-item.selected-right { border-color: #7c3aed; background: #ede9fe; color: #5b21b6; }
.puzzle-item.matched {
  border-color: #22c55e;
  background: #dcfce7;
  color: #15803d;
  animation: matchFade 0.65s ease forwards;
  pointer-events: none;
}
.puzzle-item.wrong {
  border-color: #ef4444 !important;
  background: #fee2e2 !important;
  animation: shake 0.4s ease;
}
.puzzle-item.empty { visibility: hidden; pointer-events: none; }

@keyframes matchFade {
  0%   { opacity: 1; transform: scale(1); }
  50%  { opacity: 0.7; transform: scale(1.04); }
  100% { opacity: 0; transform: scale(0.88); }
}
/* ─── Scramble (Cümle Kur) ──────────────────────────────────────────────── */
.scramble-answer-area {
  min-height: 52px;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  background: #f8fafc;
  transition: border-color 0.2s, background 0.2s;
}
.scramble-answer-area.correct {
  border-color: #22c55e;
  background: #f0fdf4;
}
.scramble-answer-area.wrong {
  border-color: #ef4444;
  background: #fef2f2;
  animation: shake 0.4s ease;
}
.scramble-words-area {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.scramble-chip {
  padding: 6px 12px;
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s;
}
.scramble-chip:hover { border-color: #6366f1; background: #eef2ff; color: #4338ca; }
.scramble-chip:active { transform: scale(0.95); }
.scramble-chip.used  { opacity: 0.2; cursor: default; pointer-events: none; }
.scramble-chip.answer-chip {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1d4ed8;
}
.scramble-chip.answer-chip:hover { border-color: #ef4444; background: #fef2f2; color: #dc2626; }

/* ─── Flashcard ─────────────────────────────────────────────────────────── */
.flashcard-card {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 2px solid #bae6fd;
  border-radius: 24px;
  padding: 24px 20px;
}

/* ─── Fill in the Blank ──────────────────────────────────────────────────── */
.fill-choice-btn {
  padding: 12px 8px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  background: white;
  transition: all 0.15s;
  text-align: center;
}
.fill-choice-btn:hover  { border-color: #6366f1; background: #eef2ff; }
.fill-choice-btn.correct { border-color: #22c55e; background: #f0fdf4; color: #16a34a; pointer-events: none; }
.fill-choice-btn.wrong   { border-color: #ef4444; background: #fef2f2; color: #dc2626; animation: shake 0.4s ease; pointer-events: none; }

/* ─── Slot & Swap Chips ─────────────────────────────────────────────────── */
.swap-chip {
  padding: 8px 16px;
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s;
}
.swap-chip:hover  { border-color: #8b5cf6; background: #f5f3ff; }
.swap-chip.active { border-color: #8b5cf6; background: #f5f3ff; color: #7c3aed; box-shadow: 0 0 0 3px #ddd6fe; }
.swap-chip:active { transform: scale(0.95); }

/* ─── Storyboard ─────────────────────────────────────────────────────────── */
.story-text-card {
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.story-text-card:hover { border-color: #6366f1; background: #fafaf9; }
.story-panel {
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.story-panel:hover   { border-color: #6366f1; background: #f5f3ff; }
.story-panel.playing { border-color: #22c55e; background: #f0fdf4; }
.story-panel .story-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #e2e8f0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #64748b;
  flex-shrink: 0;
}
.story-panel.playing .story-num { background: #22c55e; color: white; }

/* ─── Metin Ezber Cards ──────────────────────────────────────────────────── */
.mem-text-card {
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.mem-text-card:hover {
  border-color: #2563eb;
  background: #eff6ff;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(37,99,235,0.12);
}
.mem-text-card:active { transform: scale(0.97); }

/* ─── Metin Ezber – Full Text Panel ──────────────────────────────────────── */
.mem-fulltext-panel {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px 16px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.8;
  font-size: 13px;
  color: #94a3b8;
}
.mem-sentence {
  display: inline;
  border-radius: 4px;
  padding: 1px 2px;
  transition: all 0.3s;
}
.mem-sentence.active-chunk {
  color: #1e3a5f;
  font-weight: 700;
  background: #dbeafe;
  border-radius: 6px;
  padding: 2px 4px;
}
.mem-sentence.done-chunk {
  color: #22c55e;
}

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-7px); }
  40%     { transform: translateX(7px); }
  60%     { transform: translateX(-4px); }
  80%     { transform: translateX(4px); }
}

/* ─── Unit Cards ──────────────────────────────────────────────────────────── */
.unit-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
}
.unit-card:hover {
  border-color: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37,99,235,0.15);
}
.unit-card:active {
  transform: scale(0.98);
}
.unit-card-number {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #0d9488);
  color: white;
  font-weight: 800;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.unit-card-body {
  flex: 1;
  min-width: 0;
}
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─── Unit Phase Cards ────────────────────────────────────────────────────── */
.unit-phase-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
}
.unit-phase-card:hover {
  border-color: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37,99,235,0.12);
}
.unit-phase-card:active {
  transform: scale(0.98);
}
.unit-phase-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

/* ─── Learn Phase ─────────────────────────────────────────────────────────── */
.learn-tab-btn {
  border: none;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
}
.learn-tab-btn.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
  font-weight: 600;
}

.learn-dialogue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: white;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  transition: all 0.2s;
}
.learn-dialogue-item:hover {
  border-color: #93c5fd;
  background: #f0f9ff;
}
.learn-dialogue-speaker {
  font-size: 0.7rem;
  font-weight: 700;
  color: #6366f1;
  background: #eef2ff;
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
}
.learn-dialogue-text {
  flex: 1;
  font-size: 0.875rem;
  color: #1e293b;
}

.learn-vocab-card {
  background: white;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  padding: 14px;
  text-align: center;
  transition: all 0.2s;
}
.learn-vocab-card:hover {
  border-color: #93c5fd;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.06);
}

.learn-sentence-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: white;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  transition: all 0.2s;
}
.learn-sentence-item:hover {
  border-color: #93c5fd;
  background: #f0f9ff;
}

.learn-play-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #dbeafe;
  color: #2563eb;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}
.learn-play-btn:hover {
  background: #2563eb;
  color: white;
}

/* ─── Story Mode (Dialogue Chat) ──────────────────────────────────────── */
.story-chat-container {
  max-width: 480px;
  margin: 0 auto;
  min-height: 300px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.story-bubble {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 85%;
  animation: storyFadeIn 0.4s ease;
}
.story-bubble-left {
  align-self: flex-start;
}
.story-bubble-right {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.story-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.story-msg {
  background: white;
  border-radius: 14px;
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.story-bubble-right .story-msg {
  background: #eef2ff;
  border-color: #c7d2fe;
}
.story-speaker {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
.story-text {
  font-size: 0.875rem;
  color: #1e293b;
  line-height: 1.4;
}
@keyframes storyFadeIn {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.story-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
}
.story-play-btn {
  padding: 10px 24px;
  background: linear-gradient(135deg, #2563eb, #0d9488);
  color: white;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}
.story-play-btn:hover { transform: scale(1.05); }
.story-play-btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.story-pause-btn {
  padding: 10px 20px;
  background: #fef3c7;
  color: #92400e;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}
.story-pause-btn:hover { background: #fde68a; }
.story-replay-btn {
  padding: 10px 20px;
  background: #f1f5f9;
  color: #475569;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}
.story-replay-btn:hover { background: #e2e8f0; }

.story-next-tap {
  align-self: center;
  margin: 8px 0;
  padding: 10px 28px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  animation: storyFadeIn 0.3s ease;
  box-shadow: 0 2px 8px rgba(99,102,241,0.3);
  transition: transform 0.15s;
}
.story-next-tap:hover { transform: scale(1.05); }
.story-next-tap:active { transform: scale(0.95); }

/* ─── Gemini Live ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-box {
  background: white; border-radius: 1rem;
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e2e8f0;
}
.modal-header h3 {
  font-size: 1.1rem; font-weight: 700; color: #1e293b;
}
.modal-close {
  background: none; border: none; font-size: 1.25rem; color: #64748b;
  cursor: pointer; padding: 0.25rem;
}
.modal-close:hover { color: #1e293b; }

.live-box { max-width: 520px; }
.live-body {
  display: flex; flex-direction: column; gap: 1rem;
  padding: 1.25rem;
}
.live-mode-selector {
  display: flex; gap: 0.5rem;
}
.live-mode-btn {
  flex: 1; padding: 0.55rem 0.5rem;
  background: #f1f5f9; border: 1px solid #e2e8f0;
  color: #64748b; border-radius: 0.5rem;
  font-size: 0.8rem; font-weight: 500;
  cursor: pointer; transition: all 0.2s;
}
.live-mode-btn.active {
  background: #dbeafe; border-color: #3b82f6;
  color: #2563eb; font-weight: 600;
}
.live-context {
  padding: 0.6rem 1rem;
  background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 0.5rem; color: #334155;
  font-size: 0.9rem; font-style: italic;
}
.live-status {
  text-align: center; font-size: 0.8rem;
  color: #64748b; min-height: 1.2rem;
}
.live-visualizer {
  height: 36px; display: flex;
  align-items: center; justify-content: center; gap: 3px;
}
.live-wave {
  display: flex; gap: 3px; align-items: center; height: 100%;
}
.live-wave span {
  display: inline-block; width: 4px;
  background: #3b82f6; border-radius: 2px;
  animation: liveWave 0.6s ease-in-out infinite alternate;
}
@keyframes liveWave {
  from { height: 4px; opacity: 0.4; }
  to   { height: 24px; opacity: 1; }
}
.live-transcript {
  max-height: 140px; overflow-y: auto;
  background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 0.5rem; padding: 0.6rem;
  font-size: 0.85rem; color: #334155;
}
.live-msg {
  margin-bottom: 0.35rem;
  padding: 0.4rem 0.6rem; border-radius: 0.5rem;
  background: white; border: 1px solid #e2e8f0;
  font-size: 0.85rem; line-height: 1.4;
}
.live-msg.ai-msg {
  background: #eff6ff; border-color: #bfdbfe;
}
.live-msg.ai-msg strong { color: #2563eb; margin-right: 0.2rem; }
.live-msg.transcript-msg {
  background: #ecfdf5; border-color: #a7f3d0;
}
.live-msg.transcript-msg strong { color: #059669; margin-right: 0.2rem; }
.live-msg:last-child { margin-bottom: 0; }
.live-controls { display: flex; gap: 0.5rem; justify-content: center; }
.btn-primary {
  padding: 0.6rem 1.5rem; background: #2563eb; color: white;
  border: none; border-radius: 0.5rem; font-weight: 600;
  font-size: 0.9rem; cursor: pointer; transition: all 0.2s;
}
.btn-primary:hover { background: #1d4ed8; }
.btn-danger {
  padding: 0.6rem 1.5rem; background: #dc2626; color: white;
  border: none; border-radius: 0.5rem; font-weight: 600;
  font-size: 0.9rem; cursor: pointer; transition: all 0.2s;
}
.btn-danger:hover { background: #b91c1c; }
