/* ==========================================================================
   Pragora AI India — Design System
   Premium dark-first SaaS aesthetic with glassmorphism and smooth motion.
   ========================================================================== */

:root {
  --ink: #0b0b0f;
  --panel: #111827;
  --gold: #facc15;
  --gold-deep: #f59e0b;
  --line: rgba(255, 255, 255, 0.08);
  --text: #e5e7eb;
  --muted: #9ca3af;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-strong: rgba(255, 255, 255, 0.07);
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.75);
}

html.light {
  --ink: #f7f7fb;
  --panel: #ffffff;
  --line: rgba(15, 23, 42, 0.1);
  --text: #0f172a;
  --muted: #52607a;
  --surface: rgba(15, 23, 42, 0.03);
  --surface-strong: rgba(15, 23, 42, 0.06);
  --shadow: 0 20px 50px -24px rgba(15, 23, 42, 0.28);
}

html { scroll-behavior: smooth; }

body {
  background: var(--ink);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

html.light body { background: var(--ink); color: var(--text); }

/* ---------- Ambient background ---------- */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  pointer-events: none;
}
.aurora span {
  position: absolute;
  display: block;
  border-radius: 9999px;
  filter: blur(90px);
  opacity: 0.4;
  animation: drift 22s ease-in-out infinite;
}
.aurora span:nth-child(1) { width: 46rem; height: 46rem; top: -14rem; left: -10rem; background: radial-gradient(circle, rgba(250,204,21,.5), transparent 65%); }
.aurora span:nth-child(2) { width: 40rem; height: 40rem; top: 22%; right: -14rem; background: radial-gradient(circle, rgba(96,165,250,.42), transparent 65%); animation-delay: -7s; }
.aurora span:nth-child(3) { width: 38rem; height: 38rem; bottom: -14rem; left: 26%; background: radial-gradient(circle, rgba(167,139,250,.38), transparent 65%); animation-delay: -13s; }
html.light .aurora span { opacity: 0.28; }

@keyframes drift {
  0%, 100% { transform: translate3d(0,0,0) scale(1); }
  33% { transform: translate3d(4rem,-3rem,0) scale(1.12); }
  66% { transform: translate3d(-3rem,3rem,0) scale(0.94); }
}

.grid-veil {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.028) 1px, transparent 1px);
  background-size: 62px 62px;
  mask-image: radial-gradient(ellipse 85% 60% at 50% 0%, #000 40%, transparent 100%);
}
html.light .grid-veil {
  background-image:
    linear-gradient(rgba(15,23,42,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15,23,42,.05) 1px, transparent 1px);
}

/* ---------- Glass surfaces ---------- */
.glass {
  background: var(--surface);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: 1.25rem;
  box-shadow: var(--shadow);
}
.glass-strong { background: var(--surface-strong); }

.glow-card { position: relative; overflow: hidden; transition: transform .45s cubic-bezier(.22,1,.36,1), border-color .35s; }
.glow-card::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(130deg, rgba(250,204,21,.55), transparent 42%, transparent 62%, rgba(96,165,250,.4));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity .4s ease;
  pointer-events: none;
}
.glow-card:hover { transform: translateY(-6px); }
.glow-card:hover::after { opacity: 1; }

/* ---------- Typography ---------- */
.font-display { font-family: 'Sora', system-ui, sans-serif; }
.text-gradient-gold {
  background: linear-gradient(100deg, #fde68a 0%, #facc15 45%, #f59e0b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.text-gradient-cool {
  background: linear-gradient(100deg, #ffffff 0%, #cbd5e1 50%, #94a3b8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
html.light .text-gradient-cool { background: linear-gradient(100deg,#0f172a,#334155); -webkit-background-clip: text; background-clip: text; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  padding: .8rem 1.5rem; border-radius: 9999px; font-weight: 600; font-size: .95rem;
  transition: transform .22s cubic-bezier(.22,1,.36,1), box-shadow .3s, background .3s, color .3s;
  cursor: pointer; border: 1px solid transparent; white-space: nowrap; text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn-gold {
  background: linear-gradient(120deg, #fde047, #facc15 40%, #f59e0b);
  color: #16130a; box-shadow: 0 10px 34px -12px rgba(250,204,21,.85);
}
.btn-gold:hover { transform: translateY(-2px); box-shadow: 0 16px 44px -12px rgba(250,204,21,.95); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-strong); transform: translateY(-2px); }
.btn-sm { padding: .5rem 1rem; font-size: .82rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }

/* ---------- Entrance animations ---------- */
.reveal { opacity: 0; transform: translateY(28px); transition: opacity .8s cubic-bezier(.22,1,.36,1), transform .8s cubic-bezier(.22,1,.36,1); }
.reveal.in { opacity: 1; transform: none; }
.reveal-scale { opacity: 0; transform: scale(.94); transition: opacity .7s ease, transform .7s cubic-bezier(.22,1,.36,1); }
.reveal-scale.in { opacity: 1; transform: none; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(18px);} to { opacity: 1; transform: none; } }
.animate-fade-up { animation: fadeUp .6s cubic-bezier(.22,1,.36,1) both; }

@keyframes floaty { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-14px);} }
.floaty { animation: floaty 6s ease-in-out infinite; }

@keyframes shimmer { 0% { background-position: -600px 0; } 100% { background-position: 600px 0; } }
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,.05) 25%, rgba(255,255,255,.13) 50%, rgba(255,255,255,.05) 75%);
  background-size: 600px 100%;
  animation: shimmer 1.5s linear infinite;
  border-radius: .75rem;
}

/* Rotating hero words */
.word-rotator { position: relative; display: inline-block; min-height: 1.15em; vertical-align: bottom; }
.word-rotator span {
  position: absolute; left: 0; top: 0; white-space: nowrap;
  opacity: 0; transform: translateY(90%) rotateX(-45deg);
  transition: opacity .55s ease, transform .55s cubic-bezier(.22,1,.36,1);
}
.word-rotator span.active { opacity: 1; transform: none; }
.word-rotator span.leaving { opacity: 0; transform: translateY(-90%) rotateX(45deg); }

/* Typing caret */
.caret::after {
  content: '';
  display: inline-block; width: 2px; height: 1em;
  background: var(--gold); margin-left: 3px; vertical-align: -.12em;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Inputs ---------- */
.field {
  width: 100%; background: var(--surface); border: 1px solid var(--line);
  border-radius: .9rem; padding: .8rem 1rem; color: var(--text);
  transition: border-color .25s, box-shadow .25s, background .25s; outline: none; font-size: .95rem;
}
.field::placeholder { color: var(--muted); }
.field:focus { border-color: rgba(250,204,21,.65); box-shadow: 0 0 0 4px rgba(250,204,21,.14); background: var(--surface-strong); }
select.field option { background: #111827; color: #e5e7eb; }
html.light select.field option { background: #fff; color: #0f172a; }

.chip {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .32rem .8rem; border-radius: 9999px; font-size: .78rem; font-weight: 500;
  background: rgba(250,204,21,.1); color: var(--gold); border: 1px solid rgba(250,204,21,.24);
}
html.light .chip { color: #92610a; background: rgba(250,204,21,.18); }

/* ---------- Prose (AI markdown output) ---------- */
.prose-pragora { color: var(--text); line-height: 1.78; font-size: .98rem; }
.prose-pragora h1, .prose-pragora h2, .prose-pragora h3 {
  font-family: 'Sora', sans-serif; color: var(--text); font-weight: 700;
  margin: 1.6em 0 .6em; line-height: 1.3;
}
.prose-pragora h1 { font-size: 1.6rem; }
.prose-pragora h2 { font-size: 1.28rem; padding-left: .7rem; border-left: 3px solid var(--gold); }
.prose-pragora h3 { font-size: 1.08rem; color: var(--gold); }
.prose-pragora p { margin: .85em 0; }
.prose-pragora ul, .prose-pragora ol { margin: .85em 0; padding-left: 1.4em; }
.prose-pragora ul { list-style: disc; }
.prose-pragora ol { list-style: decimal; }
.prose-pragora li { margin: .4em 0; }
.prose-pragora strong { color: var(--gold); font-weight: 650; }
html.light .prose-pragora strong { color: #a16207; }
.prose-pragora code {
  background: var(--surface-strong); padding: .16em .45em; border-radius: .35rem;
  font-family: ui-monospace, monospace; font-size: .88em; color: #7dd3fc;
}
.prose-pragora pre {
  background: rgba(0,0,0,.42); border: 1px solid var(--line); border-radius: .9rem;
  padding: 1rem; overflow-x: auto; margin: 1em 0;
}
.prose-pragora pre code { background: none; color: #e2e8f0; padding: 0; }
.prose-pragora blockquote { border-left: 3px solid rgba(250,204,21,.5); padding-left: 1rem; color: var(--muted); margin: 1em 0; }
.prose-pragora table { width: 100%; border-collapse: collapse; margin: 1em 0; font-size: .9rem; }
.prose-pragora th, .prose-pragora td { border: 1px solid var(--line); padding: .55rem .7rem; text-align: left; }
.prose-pragora th { background: var(--surface-strong); font-weight: 600; }
.prose-pragora hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em 0; }

/* ---------- Tabs ---------- */
.tab-btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .58rem 1.05rem; border-radius: 9999px; font-size: .87rem; font-weight: 500;
  color: var(--muted); border: 1px solid transparent; transition: all .25s; white-space: nowrap; cursor: pointer;
}
.tab-btn:hover { color: var(--text); background: var(--surface); }
.tab-btn.active {
  color: #16130a; background: linear-gradient(120deg,#fde047,#facc15 45%,#f59e0b);
  box-shadow: 0 8px 24px -10px rgba(250,204,21,.8); font-weight: 650;
}

/* ---------- Video Engine ---------- */
.video-stage {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  background: radial-gradient(ellipse at 50% 35%, #171b2e 0%, #0b0b0f 72%);
  border-radius: 1.1rem; overflow: hidden; border: 1px solid var(--line);
}
.video-stage:fullscreen { border-radius: 0; border: none; }
.video-stage:fullscreen .slide-body { padding: 4vh 5vw; }

.slide {
  position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 1fr;
  opacity: 0; transform: translateX(40px) scale(.985); pointer-events: none;
  transition: opacity .75s cubic-bezier(.22,1,.36,1), transform .75s cubic-bezier(.22,1,.36,1);
}
.slide.active { opacity: 1; transform: none; pointer-events: auto; }
.slide.leaving { opacity: 0; transform: translateX(-40px) scale(.985); }
@media (max-width: 860px) {
  .slide { grid-template-columns: 1fr; grid-template-rows: 44% 56%; }
}

.slide-body { padding: clamp(1rem, 3.2vw, 2.6rem); display: flex; flex-direction: column; justify-content: center; gap: .85rem; overflow: hidden; }
.slide-visual { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.24); }
.slide-visual img { width: 100%; height: 100%; object-fit: cover; animation: kenburns 14s ease-out both; }
.slide-visual-tag {
  position: absolute; bottom: .5rem; right: .5rem;
  font-size: .52em; letter-spacing: .04em;
  padding: .2em .55em; border-radius: .4rem;
  background: rgba(6,6,10,.68); color: rgba(226,232,240,.85);
  border: 1px solid rgba(255,255,255,.12); backdrop-filter: blur(4px);
}
@keyframes kenburns { from { transform: scale(1.06); } to { transform: scale(1.14); } }

.slide-title {
  font-family: 'Sora', sans-serif; font-weight: 800; line-height: 1.15;
  font-size: clamp(1.15rem, 2.9vw, 2.4rem);
}
.slide-point {
  display: flex; gap: .6rem; align-items: flex-start;
  font-size: clamp(.76rem, 1.28vw, 1.02rem); color: #cbd5e1; line-height: 1.5;
  opacity: 0; transform: translateY(12px); animation: fadeUp .55s cubic-bezier(.22,1,.36,1) forwards;
}
.captions {
  position: absolute; left: 50%; bottom: 4.6rem; transform: translateX(-50%);
  max-width: 84%; text-align: center; padding: .55rem 1.1rem; border-radius: .7rem;
  background: rgba(0,0,0,.72); backdrop-filter: blur(8px); color: #fff;
  font-size: clamp(.78rem, 1.35vw, 1.05rem); line-height: 1.45; border: 1px solid rgba(255,255,255,.1);
}
.video-bar {
  position: absolute; left: 0; right: 0; bottom: 0; padding: .7rem 1rem;
  background: linear-gradient(to top, rgba(0,0,0,.92), rgba(0,0,0,.45) 65%, transparent);
  display: flex; align-items: center; gap: .7rem;
}
.progress-track { flex: 1; height: 5px; border-radius: 9999px; background: rgba(255,255,255,.2); overflow: hidden; cursor: pointer; }
.progress-fill { height: 100%; background: linear-gradient(90deg,#fde047,#f59e0b); width: 0%; transition: width .25s linear; border-radius: 9999px; }
.icon-btn {
  width: 2.3rem; height: 2.3rem; display: grid; place-items: center; border-radius: 9999px;
  background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.14);
  transition: background .22s, transform .22s; cursor: pointer; flex-shrink: 0;
}
.icon-btn:hover { background: rgba(250,204,21,.28); transform: scale(1.07); }
.icon-btn:disabled { opacity: .45; cursor: not-allowed; }
/* Toggle buttons (captions, mic, camera) show their on-state in the control bar. */
.icon-btn.is-active { background: rgba(250,204,21,.32); border-color: rgba(250,204,21,.55); color: #fde047; }

/* Narration volume — a real range input, styled to match the control bar. */
.video-volume {
  -webkit-appearance: none; appearance: none;
  width: 68px; height: 5px; flex-shrink: 0; cursor: pointer;
  border-radius: 9999px; background: rgba(255,255,255,.24);
}
.video-volume::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; border-radius: 9999px; border: none;
  background: #fde047; cursor: pointer;
}
.video-volume::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 9999px; border: none;
  background: #fde047; cursor: pointer;
}
.video-volume:focus-visible { outline: 2px solid rgba(250,204,21,.6); outline-offset: 3px; }
/* On a phone the bar is tight; the slider is the first thing to go. */
@media (max-width: 640px) { .video-volume { display: none; } }

/* ---------- Mind map ---------- */
.mindmap-wrap { overflow: auto; padding: 1.25rem; }
.mm-node {
  display: inline-flex; align-items: center; gap: .5rem; padding: .5rem .95rem;
  border-radius: .75rem; font-size: .85rem; font-weight: 500;
  background: var(--surface-strong); border: 1px solid var(--line); transition: all .28s; cursor: default;
}
.mm-root { background: linear-gradient(120deg,#fde047,#f59e0b); color: #16130a; font-weight: 700; font-size: .95rem; border: none; }
.mm-branch { border-color: rgba(250,204,21,.35); }
.mm-node:hover { transform: translateX(4px); border-color: rgba(250,204,21,.7); box-shadow: 0 6px 20px -8px rgba(250,204,21,.5); }
.mm-children { position: relative; padding-left: 1.4rem; margin-left: .9rem; border-left: 1px dashed rgba(250,204,21,.32); }
.mm-item { position: relative; margin: .5rem 0; }
.mm-item::before {
  content: ''; position: absolute; left: -1.4rem; top: 1.1rem; width: 1.2rem;
  border-top: 1px dashed rgba(250,204,21,.32);
}

/* ---------- Quiz ---------- */
.quiz-option {
  display: flex; align-items: flex-start; gap: .75rem; width: 100%; text-align: left;
  padding: .85rem 1rem; border-radius: .85rem; border: 1px solid var(--line);
  background: var(--surface); transition: all .22s; cursor: pointer; font-size: .92rem;
}
.quiz-option:hover:not(:disabled) { border-color: rgba(250,204,21,.6); background: var(--surface-strong); transform: translateX(3px); }
.quiz-option.correct { border-color: #22c55e; background: rgba(34,197,94,.14); }
.quiz-option.wrong { border-color: #ef4444; background: rgba(239,68,68,.14); }
.quiz-option:disabled { cursor: default; }
.quiz-key {
  width: 1.7rem; height: 1.7rem; flex-shrink: 0; display: grid; place-items: center;
  border-radius: .5rem; background: var(--surface-strong); font-size: .78rem; font-weight: 700; color: var(--gold);
}

/* ---------- Chat ---------- */
.bubble { max-width: 84%; padding: .8rem 1.05rem; border-radius: 1.1rem; font-size: .93rem; line-height: 1.65; animation: fadeUp .35s ease both; }
.bubble-user { margin-left: auto; background: linear-gradient(120deg,#fde047,#f59e0b); color: #16130a; border-bottom-right-radius: .3rem; font-weight: 500; }
.bubble-ai { background: var(--surface-strong); border: 1px solid var(--line); border-bottom-left-radius: .3rem; }

.typing-dots span {
  display: inline-block; width: 6px; height: 6px; margin: 0 2px; border-radius: 50%;
  background: var(--gold); animation: bounceDot 1.3s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .18s; }
.typing-dots span:nth-child(3) { animation-delay: .36s; }
@keyframes bounceDot { 0%,60%,100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-6px); opacity: 1; } }

/* ---------- Leaderboard ---------- */
.rank-badge { width: 2.1rem; height: 2.1rem; display: grid; place-items: center; border-radius: .65rem; font-weight: 800; font-size: .85rem; }
.rank-1 { background: linear-gradient(120deg,#fde047,#f59e0b); color: #16130a; }
.rank-2 { background: linear-gradient(120deg,#e2e8f0,#94a3b8); color: #0f172a; }
.rank-3 { background: linear-gradient(120deg,#fdba74,#c2703a); color: #1c0f05; }
.rank-x { background: var(--surface-strong); color: var(--muted); }

/* ---------- Utilities ---------- */
.scroll-slim::-webkit-scrollbar { width: 7px; height: 7px; }
.scroll-slim::-webkit-scrollbar-track { background: transparent; }
.scroll-slim::-webkit-scrollbar-thumb { background: rgba(148,163,184,.32); border-radius: 9999px; }
.scroll-slim::-webkit-scrollbar-thumb:hover { background: rgba(250,204,21,.55); }

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

.text-muted { color: var(--muted); }
.border-line { border-color: var(--line); }
.bg-surface { background: var(--surface); }
.bg-surface-strong { background: var(--surface-strong); }

/* ---------- AI Teacher avatar states ---------- */
/* One element, five states. Animations stay subtle so they never pull focus
   away from the lesson: slow breathing at rest, gentle cues while working. */
.teacher-avatar {
  position: relative;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: 1rem;
  background: linear-gradient(135deg, var(--gold-soft, #FDE68A), #FACC15, #F59E0B);
  color: #16130a;
  transition: box-shadow .45s ease, transform .45s ease;
}
.teacher-avatar .ta-icon { font-size: 1rem; line-height: 1; transition: opacity .3s ease; }

/* Pulse ring — rendered once, driven per state. */
.teacher-avatar::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 2px solid rgba(250, 204, 21, .55);
  opacity: 0;
  transform: scale(.94);
  pointer-events: none;
}

/* IDLE — a slow, calm breath. */
.teacher-avatar[data-state='idle'] { animation: ta-breathe 4.2s ease-in-out infinite; }
@keyframes ta-breathe {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(250, 204, 21, .18); }
  50%      { transform: scale(1.03); box-shadow: 0 0 18px 2px rgba(250, 204, 21, .22); }
}

/* LISTENING — outward ripples, as if picking up the student's voice. */
.teacher-avatar[data-state='listening'] { box-shadow: 0 0 22px 3px rgba(52, 211, 153, .35); }
.teacher-avatar[data-state='listening']::after {
  border-color: rgba(52, 211, 153, .65);
  animation: ta-ripple 1.5s ease-out infinite;
}
@keyframes ta-ripple {
  0%   { opacity: .85; transform: scale(.92); }
  100% { opacity: 0;   transform: scale(1.45); }
}

/* THINKING — a steady rotating sweep. */
.teacher-avatar[data-state='thinking'] { box-shadow: 0 0 20px 2px rgba(250, 204, 21, .35); }
.teacher-avatar[data-state='thinking']::after {
  opacity: 1;
  border-color: transparent;
  border-top-color: rgba(250, 204, 21, .9);
  border-right-color: rgba(250, 204, 21, .45);
  animation: ta-spin 1.1s linear infinite;
}
@keyframes ta-spin { to { transform: rotate(360deg) scale(1); } }

/* SPEAKING — a soft rhythmic bob with an equaliser underneath. */
.teacher-avatar[data-state='speaking'] { animation: ta-speak 1.05s ease-in-out infinite; }
@keyframes ta-speak {
  0%, 100% { transform: scale(1);    box-shadow: 0 0 16px 1px rgba(96, 165, 250, .3); }
  50%      { transform: scale(1.06); box-shadow: 0 0 26px 5px rgba(96, 165, 250, .45); }
}

/* GENERATING — warm amber glow while a lesson is being built. */
.teacher-avatar[data-state='generating'] { animation: ta-generate 1.6s ease-in-out infinite; }
@keyframes ta-generate {
  0%, 100% { box-shadow: 0 0 14px 1px rgba(245, 158, 11, .35); }
  50%      { box-shadow: 0 0 30px 7px rgba(245, 158, 11, .6); }
}

/* Equaliser bars, shown only while speaking. */
.ta-eq { display: none; align-items: flex-end; gap: 2px; height: 12px; }
.teacher-avatar[data-state='speaking'] ~ .ta-meta .ta-eq { display: inline-flex; }
.ta-eq span {
  width: 2.5px; border-radius: 2px; background: var(--gold, #FACC15);
  animation: ta-eq-bar .9s ease-in-out infinite;
}
.ta-eq span:nth-child(1) { height: 40%; animation-delay: 0s; }
.ta-eq span:nth-child(2) { height: 90%; animation-delay: .12s; }
.ta-eq span:nth-child(3) { height: 60%; animation-delay: .24s; }
.ta-eq span:nth-child(4) { height: 100%; animation-delay: .36s; }
.ta-eq span:nth-child(5) { height: 50%; animation-delay: .48s; }
@keyframes ta-eq-bar { 0%, 100% { transform: scaleY(.4); } 50% { transform: scaleY(1); } }

/* State caption under the teacher name. */
.ta-status { font-size: 11.5px; color: var(--muted); transition: color .3s ease; }
.ta-status[data-state='listening'] { color: #34d399; }
.ta-status[data-state='thinking']  { color: #facc15; }
.ta-status[data-state='speaking']  { color: #60a5fa; }
.ta-status[data-state='generating'] { color: #f59e0b; }

/* ---------- Call Your AI Teacher ---------- */
.call-overlay {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center;
  background: rgba(6, 6, 10, .82);
  backdrop-filter: blur(14px);
  padding: 1.25rem;
}
.call-overlay[hidden] { display: none; }
.call-panel {
  width: min(420px, 100%);
  border-radius: 1.5rem;
  border: 1px solid var(--line);
  background: var(--surface-strong, #14141b);
  padding: 2rem 1.5rem 1.5rem;
  text-align: center;
  animation: call-in .32s cubic-bezier(.2, .8, .3, 1);
}
@keyframes call-in { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.call-avatar { width: 96px; height: 96px; margin: 0 auto; }
.call-avatar .ta-icon { font-size: 2rem; }
.call-transcript {
  min-height: 3.5rem; max-height: 8rem; overflow-y: auto;
  font-size: 13px; line-height: 1.6; color: var(--muted);
  text-align: left; margin-top: 1rem; padding: .75rem .9rem;
  border-radius: .85rem; background: var(--surface); border: 1px solid var(--line);
}
.call-btn {
  width: 3.25rem; height: 3.25rem; border-radius: 9999px;
  display: grid; place-items: center; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted);
  transition: transform .2s ease, background .2s ease, color .2s ease;
}
.call-btn:hover { transform: translateY(-2px); color: #fff; }
.call-btn.is-active { background: rgba(250, 204, 21, .16); border-color: rgba(250, 204, 21, .5); color: #facc15; }
.call-btn.call-end { background: #dc2626; border-color: #dc2626; color: #fff; }
.call-btn.call-end:hover { background: #b91c1c; }

/* ===== Authentication & onboarding ===== */
.auth-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .25rem;
  padding: .25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .85rem;
}
.auth-switch-btn {
  padding: .55rem .5rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  border-radius: .6rem;
  transition: color .25s ease, background .25s ease, box-shadow .25s ease;
}
.auth-switch-btn:hover { color: var(--text); }
.auth-switch-btn.active {
  color: #0b0b0f;
  background: linear-gradient(135deg, #fde68a, #facc15 55%, #f59e0b);
  box-shadow: 0 8px 22px -12px rgba(250, 204, 21, .9);
}
html.light .auth-switch-btn.active { color: #1f1300; }

.auth-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .65rem;
  width: 100%;
  padding: .78rem 1rem;
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: .8rem;
  transition: transform .22s ease, border-color .25s ease, background .25s ease;
}
.auth-google:hover { transform: translateY(-2px); border-color: rgba(250, 204, 21, .45); }
.auth-google:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: .8rem;
  margin: 1.35rem 0;
  color: var(--muted);
  font-size: .74rem;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.auth-alert {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  padding: .65rem .8rem;
  font-size: .8rem;
  line-height: 1.5;
  border-radius: .65rem;
  border: 1px solid transparent;
  animation: fadeUp .35s cubic-bezier(.22, 1, .36, 1) both;
}
.auth-alert-error { color: #fca5a5; background: rgba(220, 38, 38, .1); border-color: rgba(220, 38, 38, .3); }
.auth-alert-ok { color: #86efac; background: rgba(22, 163, 74, .1); border-color: rgba(22, 163, 74, .3); }
html.light .auth-alert-error { color: #b91c1c; }
html.light .auth-alert-ok { color: #15803d; }

/* Onboarding option cards (board, language) */
.opt-card {
  padding: .7rem .6rem;
  font-size: .8rem;
  font-weight: 550;
  line-height: 1.3;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .7rem;
  transition: transform .2s ease, color .22s ease, border-color .22s ease, background .22s ease;
}
.opt-card:hover { color: var(--text); transform: translateY(-2px); border-color: rgba(250, 204, 21, .35); }
.opt-card.selected {
  color: var(--gold);
  background: rgba(250, 204, 21, .12);
  border-color: rgba(250, 204, 21, .55);
  box-shadow: 0 0 0 3px rgba(250, 204, 21, .1);
}
html.light .opt-card.selected { color: #92610a; }

/* Profile menu in the navbar */
.profile-menu {
  position: absolute;
  top: calc(100% + .5rem);
  right: 0;
  width: 15rem;
  padding: .45rem;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: .9rem;
  box-shadow: 0 22px 60px -18px rgba(0, 0, 0, .8);
  backdrop-filter: blur(18px);
  animation: fadeUp .22s cubic-bezier(.22, 1, .36, 1) both;
  z-index: 60;
}
html.light .profile-menu { box-shadow: 0 22px 60px -22px rgba(15, 23, 42, .28); }
.profile-menu-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  padding: .55rem .65rem;
  font-size: .82rem;
  color: var(--text);
  border-radius: .55rem;
  text-align: left;
  transition: background .18s ease, color .18s ease;
}
.profile-menu-item:hover { background: var(--surface); color: var(--gold); }
.profile-menu-item.danger:hover { color: #f87171; background: rgba(220, 38, 38, .1); }

/* ==========================================================================
   Virtual AI Teacher avatar
   The still portrait is always painted; the clip fades in over it only while
   generated speech is playing, so a blocked/failed clip degrades to a photo
   rather than an empty frame.
   ========================================================================== */
.avatar-stage {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  background: linear-gradient(160deg, #12121a, #0b0b0f);
  isolation: isolate;
}
.avatar-portrait,
.avatar-clip {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
}
.avatar-clip { opacity: 0; transition: opacity .45s ease; }
.avatar-stage[data-avatar-state='speaking'] .avatar-clip { opacity: 1; }

/* Soft glow that reflects what the teacher is doing. */
.avatar-ring {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(250, 204, 21, .18);
  transition: box-shadow .35s ease;
}
.avatar-stage[data-avatar-state='listening'] .avatar-ring {
  box-shadow: inset 0 0 0 2px rgba(52, 211, 153, .55), 0 0 26px rgba(52, 211, 153, .28);
}
.avatar-stage[data-avatar-state='thinking'] .avatar-ring {
  box-shadow: inset 0 0 0 2px rgba(250, 204, 21, .5), 0 0 24px rgba(250, 204, 21, .26);
  animation: avatar-pulse 1.5s ease-in-out infinite;
}
.avatar-stage[data-avatar-state='speaking'] .avatar-ring {
  box-shadow: inset 0 0 0 2px rgba(56, 189, 248, .55), 0 0 30px rgba(56, 189, 248, .3);
}
@keyframes avatar-pulse { 0%, 100% { opacity: .65 } 50% { opacity: 1 } }

/* Lip-sync indicator: scaled live from the generated audio envelope. */
.avatar-mouth {
  position: absolute;
  left: 50%;
  bottom: 14%;
  width: 26%;
  height: 4px;
  transform: translateX(-50%) scaleY(.25);
  transform-origin: center;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(250, 204, 21, .9), transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s linear;
}
.avatar-stage[data-avatar-state='speaking'] .avatar-mouth { opacity: .6; }

/* Small round avatar used in the chat header and call chrome. */
.avatar-stage.avatar-chip { border-radius: 999px; }
.avatar-stage.avatar-chip .avatar-mouth { display: none; }

/* ---- Video call layout ----
   The overlay centres its child, so without an explicit cap the panel grows
   with the lesson content and pushes End Call past the bottom of the screen.
   The panel is therefore pinned to the viewport and only the board scrolls —
   essential controls must always stay reachable. */
#vc-overlay {
  place-items: stretch;
  padding: 0;
}
#vc-overlay > * {
  height: 100%;
  max-height: 100dvh;
  min-height: 0;
}
.vc-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 16px;
  min-height: 0;
  overflow: hidden;
}
.vc-slide {
  background: linear-gradient(165deg, rgba(24, 24, 33, .95), rgba(11, 11, 15, .95));
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  min-height: 0;
}
/* The board is the only part allowed to scroll. */
#vc-board-body { min-height: 0; }
/* An illustration never grows the panel; it fits the space it is given. */
.vc-slide-img img { max-height: 34vh; width: auto; margin-inline: auto; object-fit: contain; }
.vc-bullet {
  opacity: 0;
  transform: translateY(8px);
  animation: vc-bullet-in .5s ease forwards;
}
@keyframes vc-bullet-in { to { opacity: 1; transform: translateY(0); } }
.vc-slide-img {
  animation: vc-img-in .6s ease forwards;
  opacity: 0;
}
@keyframes vc-img-in { to { opacity: 1; } }

/* Student self-view: a small picture-in-picture inside the teacher pane, so
   the student can aim the page at the camera while still seeing the teacher. */
.vc-selfview {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 30%;
  max-width: 170px;
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  z-index: 2;
}
.vc-selfview-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.vc-selfview-tag {
  position: absolute;
  left: 6px;
  bottom: 6px;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, .6);
  backdrop-filter: blur(4px);
}

/* Voice-activity indicator. The level bar is fed by real microphone energy,
   so an open microphone looks open instead of merely being claimed to be. */
.voice-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
}
.voice-indicator[data-tone='sky'] { color: #7dd3fc; border-color: rgba(56, 189, 248, .35); background: rgba(56, 189, 248, .12); }
.voice-indicator[data-tone='gold'] { color: #fcd34d; border-color: rgba(251, 191, 36, .38); background: rgba(251, 191, 36, .12); }
.voice-indicator[data-tone='emerald'] { color: #6ee7b7; border-color: rgba(52, 211, 153, .35); background: rgba(52, 211, 153, .12); }
.voice-level {
  display: inline-block;
  width: 46px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .16);
  overflow: hidden;
}
.voice-level-bar {
  display: block;
  height: 100%;
  width: 4%;
  border-radius: 999px;
  background: currentColor;
  transition: width .08s linear;
}

/* Tablet and mobile: stack the avatar above the lesson panel. */
@media (max-width: 900px) {
  .vc-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }
  /* Avatar becomes a compact picture-in-picture so slides get the space. */
  .vc-grid > .vc-avatar-pane { max-height: 30vh; }
  .vc-slide-img img { max-height: 22vh; }
  .vc-selfview { width: 24%; max-width: 110px; }
}

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