:root {
  --bg: #fff8fb;
  --bg-2: #fff0f6;
  --panel: rgba(255, 255, 255, 0.92);
  --text: #2a1f2b;
  --muted: #756575;
  --line: #efd9e6;
  --accent: #c0267c;
  --accent-2: #db2777;
  --accent-3: #7c3aed;
  --shadow: 0 18px 50px rgba(192, 38, 124, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, #ffe6f1 0, transparent 30%),
    radial-gradient(circle at top right, #fff0f7 0, transparent 28%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
}

a { color: inherit; text-decoration: none; }

.app-shell {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid rgba(239, 217, 230, 0.9);
  background: rgba(255, 248, 251, 0.75);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.brand strong,
.brand small { display: block; }
.brand small { color: var(--muted); }

.side-nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border-radius: 16px;
  color: var(--muted);
  font-weight: 700;
}

.nav-item:hover,
.nav-item.active {
  color: var(--accent-2);
  background: rgba(255,255,255,0.88);
  border: 1px solid var(--line);
}

.sidebar-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.sidebar-card {
  margin-top: 24px;
  padding: 18px;
}

.sidebar-card p {
  color: var(--muted);
  line-height: 1.7;
}

.mini-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-tags span,
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--accent-2);
}

.main-content {
  width: min(1220px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 64px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  gap: 20px;
  padding: 22px;
}

.hero-copy {
  padding: 14px 8px 14px 8px;
}

.soft {
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(255,244,249,0.92));
}

.eyebrow,
.panel-label,
.metric-label {
  margin: 0 0 10px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(38px, 6vw, 74px);
  line-height: 1.02;
}

h2 {
  margin: 0 0 12px;
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.18;
}

h3 {
  margin: 0 0 10px;
  font-size: 20px;
}

.lead,
.muted,
.panel p,
.lesson-list p,
.metric-card p,
.next-lesson-card p,
.star-card span {
  color: var(--muted);
  line-height: 1.8;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 20px;
  border-radius: 16px;
  border: none;
  text-decoration: none;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 700;
  box-shadow: 0 14px 28px rgba(192, 38, 124, 0.16);
}

.btn.secondary {
  color: var(--accent-2);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: none;
}

.feature-list {
  margin: 16px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.85;
}

.metrics-grid,
.rewards-row,
.schedule-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.metric-card,
.star-card,
.schedule-card {
  padding: 22px;
}

.metric-card strong,
.star-card strong,
.schedule-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 20px;
}

.section-block {
  margin-top: 20px;
}

.section-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 14px;
}

.chat-demo {
  display: grid;
  gap: 12px;
}

.speech-bubble {
  max-width: 820px;
  padding: 16px 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  line-height: 1.8;
}

.speech-bubble.user {
  background: #fff;
  margin-left: auto;
}

.speech-bubble.bot {
  background: rgba(255, 244, 249, 0.9);
}

.speech-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.lesson-list,
.progress-list {
  display: grid;
  gap: 14px;
}

.lesson-list article,
.next-lesson-card,
.progress-list div {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,0.75);
}

.progress-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.progress-list strong,
.next-lesson-card strong {
  font-size: 18px;
}

.schedule-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255,255,255,0.9);
}

.schedule-card span {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 800;
}

.schedule-card.active {
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(255,240,247,0.95));
}

.star-card {
  display: grid;
  gap: 8px;
  text-align: center;
  font-size: 38px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255,255,255,0.92);
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(239, 217, 230, 0.9);
  }
}

@media (max-width: 900px) {
  .hero,
  .metrics-grid,
  .two-col,
  .schedule-grid,
  .rewards-row {
    grid-template-columns: 1fr;
  }

  .section-top,
  .progress-list div {
    flex-direction: column;
    align-items: start;
  }
}

@media (max-width: 700px) {
  .main-content {
    width: min(100% - 18px, 1220px);
  }

  .panel,
  .speech-bubble,
  .schedule-card,
  .star-card {
    border-radius: 20px;
  }

  h1 { font-size: 42px; }
  h2 { font-size: 28px; }
}

/* ── Chat window ─────────────────────────────────────────────────────────── */
.chat-window {
  min-height: 300px;
  max-height: 460px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 248, 251, 0.7);
  margin-bottom: 14px;
}

.chat-input-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.chat-input {
  flex: 1;
  padding: 14px 18px;
  border-radius: 16px;
  border: 1px solid var(--line);
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  outline: none;
}

.chat-input:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(219, 39, 119, 0.08);
}

.chat-quick-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn.small {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 12px;
}

/* ── Stats sidebar card ───────────────────────────────────────────────────── */
.stats-card {
  margin-top: 12px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.stat-row:last-child { border-bottom: none; }
.stat-row span { color: var(--muted); }
.stat-row strong { color: var(--accent-2); }

/* ── Vocab tag cloud ──────────────────────────────────────────────────────── */
.vocab-tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.vocab-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-2);
}

.vocab-tag small {
  font-size: 10px;
  color: var(--muted);
  font-weight: 400;
}

/* ── Star burst ───────────────────────────────────────────────────────────── */
.star-burst {
  margin-top: 16px;
  padding: 18px 24px;
  border-radius: 22px;
  background: linear-gradient(135deg, #fff4cc, #fff9e6);
  border: 2px solid #fde68a;
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  animation: pop 0.4s ease;
}

.star-burst.hidden { display: none; }

@keyframes pop {
  0%   { transform: scale(0.7); opacity: 0; }
  60%  { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

/* ── Typing indicator ─────────────────────────────────────────────────────── */
.speech-bubble.typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 12px 18px;
}

.speech-bubble.typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-2);
  animation: bounce 1.2s infinite;
}

.speech-bubble.typing span:nth-child(2) { animation-delay: .2s; }
.speech-bubble.typing span:nth-child(3) { animation-delay: .4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40%            { transform: translateY(-8px); opacity: 1; }
}

/* ── Tab sections ─────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.tab-section { padding-bottom: 48px; }

/* ── Language switcher ────────────────────────────────────────────────────── */
.lang-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.lang-label { font-size: 13px; color: var(--muted); font-weight: 600; }

.lang-btn {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
}

.lang-btn.active,
.lang-btn:hover {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-color: transparent;
}

/* ── Mic button ───────────────────────────────────────────────────────────── */
.mic-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.mic-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  animation: pulse-mic 1.5s infinite;
}

@keyframes pulse-mic {
  0%,100% { box-shadow: 0 0 0 0 rgba(192,38,124,0.3); }
  50%      { box-shadow: 0 0 0 10px rgba(192,38,124,0); }
}

/* ── Voice status bar ─────────────────────────────────────────────────────── */
.voice-status {
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(255,244,249,0.9);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-2);
  margin-top: 10px;
  animation: fade-in 0.3s ease;
}

/* ── Chat top controls ────────────────────────────────────────────────────── */
.chat-top-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Answer feedback ──────────────────────────────────────────────────────── */
.answer-feedback {
  margin-top: 14px;
  padding: 16px 20px;
  border-radius: 18px;
  font-size: 15px;
  font-weight: 600;
  animation: fade-in 0.3s ease;
}

.answer-feedback.correct {
  background: #f0fdf4;
  border: 2px solid #86efac;
  color: #166534;
}

.answer-feedback.wrong {
  background: #fff7ed;
  border: 2px solid #fdba74;
  color: #9a3412;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

/* ── History list ─────────────────────────────────────────────────────────── */
.history-list {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.history-card {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255,255,255,0.9);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.history-stats {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

/* ── TTS button ───────────────────────────────────────────────────────────── */
.tts-btn {
  background: #fff;
  border: 1px solid var(--line);
  transition: all 0.2s;
}

.tts-btn.active,
.tts-btn:hover {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-color: transparent;
  color: #fff;
}

.tts-btn.speaking {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-color: transparent;
  color: #fff;
  animation: pulse-mic 1.2s infinite;
}

/* ── Lily Avatar in Chat ───────────────────────────────────────────────────── */
.lily-avatar-container {
  position: absolute;
  left: -90px;
  top: 20px;
  width: 80px;
  height: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lily-avatar {
  width: 70px;
  height: 90px;
  transition: transform 0.3s ease;
}

/* Avatar animations */
.lily-idle {
  animation: lily-breathe 3s ease-in-out infinite;
}

@keyframes lily-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

.lily-speaking {
  animation: lily-bounce 0.5s ease-in-out infinite;
}

@keyframes lily-bounce {
  0%, 100% { transform: translateY(0) scale(1.02); }
  50% { transform: translateY(-4px) scale(1.04); }
}

.lily-thinking {
  animation: lily-sway 2s ease-in-out infinite;
}

@keyframes lily-sway {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}

.lily-happy {
  animation: lily-jump 0.6s ease-in-out;
}

@keyframes lily-jump {
  0% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-15px) scale(1.05); }
  60% { transform: translateY(-5px) scale(1.02); }
  100% { transform: translateY(0) scale(1); }
}

.lily-glow {
  filter: drop-shadow(0 0 8px rgba(255, 105, 180, 0.6));
}

.chat-window-with-avatar {
  position: relative;
  padding-left: 60px;
}

/* ── Weekly Schedule UI ───────────────────────────────────────────────────── */
.week-schedule {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.week-day {
  padding: 12px 8px;
  border-radius: 16px;
  background: rgba(255,255,255,0.8);
  border: 1px solid var(--line);
  text-align: center;
}

.week-day.today {
  background: linear-gradient(180deg, rgba(255,244,249,0.95), rgba(255,240,247,0.9));
  border-color: var(--accent-2);
}

.week-day-name {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.week-day.today .week-day-name {
  color: var(--accent-2);
}

.week-day-subjects {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.week-subject-tag {
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  background: var(--accent-2);
  color: white;
}

.week-subject-tag.english { background: #3b82f6; }
.week-subject-tag.math { background: #f59e0b; }
.week-subject-tag.vietnamese { background: #ef4444; }
.week-subject-tag.review { background: #8b5cf6; }
.week-subject-tag.quiz { background: #10b981; }
.week-subject-tag.free-reading { background: #ec4899; }

.week-learn-btn {
  margin-top: 6px;
  padding: 4px 8px;
  border-radius: 8px;
  border: none;
  background: rgba(192, 38, 124, 0.1);
  color: var(--accent-2);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.week-learn-btn:hover {
  background: var(--accent-2);
  color: white;
}

/* Week topics list */
.week-topics {
  margin-top: 20px;
}

.week-topic-card {
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255,255,255,0.85);
  border: 1px solid var(--line);
  margin-bottom: 10px;
}

.week-topic-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.week-topic-emoji {
  font-size: 20px;
}

.week-topic-name {
  font-weight: 700;
  color: var(--text);
}

.week-topic-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.week-topic-item {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,0.05);
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 900px) {
  .week-schedule {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 600px) {
  .week-schedule {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── Lily Avatar Panel ────────────────────────────────────────────────────── */
.lily-avatar-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 0 8px;
}

.lily-avatar-wrap {
  position: relative;
  width: 120px;
  height: 160px;
}

.lily-avatar-img {
  width: 120px;
  height: 160px;
  object-fit: contain;
  filter: drop-shadow(0 4px 16px rgba(192,38,124,0.18));
  transition: filter 0.3s;
}

.lily-name-tag {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #f9a8d4, #c026d3);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  padding: 3px 12px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(192,38,124,0.3);
}

.lily-status-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #fff;
  transition: background 0.3s;
}

.lily-mood {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-2);
  text-align: center;
  min-height: 20px;
}

/* ── Avatar states ────────────────────────────────────────────────────────── */
@keyframes lily-breathe {
  0%,100% { transform: scale(1) translateY(0); }
  50%      { transform: scale(1.025) translateY(-2px); }
}

@keyframes lily-sway {
  0%,100% { transform: rotate(0deg); }
  25%     { transform: rotate(-3deg) translateX(-2px); }
  75%     { transform: rotate(3deg) translateX(2px); }
}

@keyframes lily-speak {
  0%,100% { transform: scale(1) translateY(0); }
  25%     { transform: scale(1.03) translateY(-3px); }
  50%     { transform: scale(1) translateY(0); }
  75%     { transform: scale(1.02) translateY(-2px); }
}

@keyframes lily-happy {
  0%     { transform: scale(1) translateY(0) rotate(0deg); }
  20%    { transform: scale(1.08) translateY(-10px) rotate(-5deg); }
  40%    { transform: scale(1.08) translateY(-10px) rotate(5deg); }
  60%    { transform: scale(1.04) translateY(-5px) rotate(-2deg); }
  80%    { transform: scale(1.02) translateY(-2px) rotate(1deg); }
  100%   { transform: scale(1) translateY(0) rotate(0deg); }
}

@keyframes lily-listen {
  0%,100% { transform: scale(1) rotate(0deg); }
  50%     { transform: scale(1.02) rotate(-2deg); }
}

.lily-idle      { animation: lily-breathe 3s ease-in-out infinite; }
.lily-thinking  { animation: lily-sway 1.2s ease-in-out infinite; }
.lily-speaking  { animation: lily-speak 0.6s ease-in-out infinite; }
.lily-happy     { animation: lily-happy 0.8s ease-in-out 1; }
.lily-listening { animation: lily-listen 1.5s ease-in-out infinite; }

/* ═══════════════════════════════════════════════════════════
   LILY CHARACTER — BUDDY LAYOUT  v0.4.2
   ═══════════════════════════════════════════════════════════ */

/* Full-height chat panel */
.chat-full-panel {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
  min-height: 580px;
}

/* Side-by-side: Lily | Chat */
.chat-buddy-layout {
  display: flex;
  gap: 16px;
  flex: 1;
  min-height: 0;
  align-items: flex-start;
}

/* ── Left: Lily column ─────────────────────────────────── */
.lily-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 180px;
  min-width: 150px;
  flex-shrink: 0;
  position: relative;
  padding-top: 20px;
}

/* Speech cloud bubble */
/* Speech cloud — dynamic size, floats right of Lily's mouth */
.lily-speech-cloud {
  position: absolute;
  /* anchored near Lily's mouth (bottom-right of char) */
  bottom: 95px;
  left: 155px;
  /* Width scales with content: min 160px → max 280px */
  width: max-content;
  min-width: 160px;
  max-width: min(280px, calc(100vw - 220px));
  /* Height is auto — grows with text */
  padding: 14px 18px 14px 16px;
  background: linear-gradient(135deg, #ffffff 0%, #f0f9ff 100%);
  border: 2px solid #93c5fd;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  z-index: 20;
  box-shadow:
    0 4px 24px rgba(59,130,246,0.14),
    0 1px 4px rgba(0,0,0,0.06);
  display: none;
  flex-direction: column;
  gap: 6px;
  transition: opacity 0.35s ease, transform 0.35s ease;
  transform-origin: bottom left;
  animation: cloud-pop 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes cloud-pop {
  from { opacity: 0; transform: scale(0.8) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Tiny bubble trail from mouth */
.lily-cloud-tail {
  position: absolute;
  bottom: -12px;
  left: 14px;
}
.lily-cloud-tail::before,
.lily-cloud-tail::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: #93c5fd;
}
.lily-cloud-tail::before {
  width: 10px;
  height: 10px;
  bottom: 0;
  left: 0;
}
.lily-cloud-tail::after {
  width: 6px;
  height: 6px;
  bottom: -10px;
  left: 10px;
}

/* Lily name badge inside cloud */
.lily-cloud-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #60a5fa;
  margin-bottom: 2px;
}

/* Main text — auto size based on length */
.lily-cloud-text {
  font-size: 15px;
  font-weight: 600;
  color: #1e40af;
  line-height: 1.55;
  letter-spacing: 0.01em;
  word-break: break-word;
  white-space: pre-wrap;
  /* Shrink font when text is very long */
  transition: font-size 0.2s ease;
}
.lily-cloud-text.compact  { font-size: 13px; }
.lily-cloud-text.tiny     { font-size: 12px; }

/* Lily character image */
.lily-char-wrap {
  position: relative;
  width: 160px;
  height: 210px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.lily-char-img {
  width: 160px;
  height: 210px;
  object-fit: contain;
  filter: drop-shadow(0 6px 20px rgba(245,158,11,0.2));
  transition: filter 0.3s;
  display: block;
}

.lily-mouth-canvas {
  position: absolute;
  bottom: 68px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  opacity: 0; /* hidden — lip sync via SVG DOM instead */
}

/* Name + mood */
.lily-char-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.lily-char-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 800;
  color: var(--fg, #1e293b);
  letter-spacing: 0.02em;
}

.lily-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  display: inline-block;
  transition: background 0.3s;
  flex-shrink: 0;
}

.lily-char-mood {
  font-size: 12px;
  font-weight: 600;
  color: #6366f1;
  text-align: center;
  min-height: 18px;
  animation: lily-mood-fade 0.4s ease;
}
@keyframes lily-mood-fade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Voice toggle button */
.lily-voice-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #eff6ff, #e0e7ff);
  border: 1.5px solid #bfdbfe;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  color: #3730a3;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 4px;
}
.lily-voice-btn:hover {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  border-color: transparent;
}
.lily-voice-btn.speaking {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  border-color: transparent;
  animation: pulse-mic 1s infinite;
}

/* ── Right: Chat column ────────────────────────────────── */
.chat-col {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  gap: 10px;
  height: 100%;
}

.chat-col .chat-window {
  flex: 1;
}

/* Send button accent */
.btn-send {
  background: linear-gradient(135deg, #3b82f6, #6366f1) !important;
  color: #fff !important;
  border: none !important;
  font-size: 15px !important;
}

/* ── Avatar animation states ───────────────────────────── */
.lily-idle      { animation: lily-breathe 3.2s ease-in-out infinite; }
.lily-thinking  { animation: lily-sway 1.1s ease-in-out infinite; }
.lily-speaking  { animation: lily-speak-bob 0.55s ease-in-out infinite; }
.lily-happy     { animation: lily-jump 0.7s ease-in-out 2; }
.lily-listening { animation: lily-lean 2s ease-in-out infinite; }

@keyframes lily-breathe {
  0%,100% { transform: scale(1) translateY(0); }
  50%      { transform: scale(1.02) translateY(-3px); }
}
@keyframes lily-sway {
  0%,100% { transform: rotate(0deg) translateX(0); }
  30%     { transform: rotate(-3deg) translateX(-3px); }
  70%     { transform: rotate(3deg) translateX(3px); }
}
@keyframes lily-speak-bob {
  0%,100% { transform: scale(1) translateY(0); }
  30%     { transform: scale(1.03) translateY(-4px); }
  60%     { transform: scale(1.01) translateY(-1px); }
}
@keyframes lily-jump {
  0%,100% { transform: scale(1) translateY(0); }
  25%     { transform: scale(1.06) translateY(-12px) rotate(-4deg); }
  50%     { transform: scale(1.06) translateY(-12px) rotate(4deg); }
  75%     { transform: scale(1.02) translateY(-5px); }
}
@keyframes lily-lean {
  0%,100% { transform: rotate(0deg); }
  50%     { transform: rotate(-5deg) translateX(-4px); }
}

/* Responsive: stack on small screens */
@media (max-width: 640px) {
  .chat-buddy-layout {
    flex-direction: column;
  }
  .lily-col {
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 0;
  }
  .lily-char-wrap { width: 80px; height: 110px; }
  .lily-char-img  { width: 80px; height: 110px; }
  .lily-speech-cloud {
    position: static;
    width: auto;
    margin-bottom: 8px;
  }
  .lily-cloud-tail { display: none; }
}

/* ── End session button ─────────────────────────────────────────────────── */
.btn-end-session {
  background: linear-gradient(135deg, #fef3c7, #fde68a) !important;
  color: #92400e !important;
  border: 1.5px solid #fcd34d !important;
  font-size: 12px !important;
  padding: 8px 12px !important;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-end-session:hover {
  background: linear-gradient(135deg, #f59e0b, #d97706) !important;
  color: #fff !important;
  border-color: transparent !important;
}

/* ── lily-cloud-label ───────────────────────────────────────────────────── */
.lily-cloud-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #60a5fa;
  margin-bottom: 4px;
}

/* ═══════════════════════════════════════════════════════════
   SCHOOL NEWS SECTION  v1.0
   ═══════════════════════════════════════════════════════════ */

.school-news-section {
  margin-top: 20px;
  padding: 20px 24px;
  border-left: 4px solid #3b82f6;
}

.school-news-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.school-news-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.school-news-icon {
  font-size: 28px;
  line-height: 1;
}
.school-news-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.school-news-date {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
}
.btn-refresh-news {
  background: transparent;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-refresh-news:hover { background: #f1f5f9; }

/* Lily reminder box */
.lily-reminder-box {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 2px solid #fde68a;
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.lily-reminder-img {
  width: 56px;
  height: 72px;
  object-fit: contain;
  flex-shrink: 0;
}
.lily-reminder-bubble {
  flex: 1;
}
.lily-reminder-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #d97706;
  margin-bottom: 4px;
}
.lily-reminder-text {
  font-size: 14px;
  font-weight: 600;
  color: #92400e;
  line-height: 1.5;
}

/* News items grid */
.school-news-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.school-news-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid #e2e8f0;
  transition: transform 0.15s, box-shadow 0.15s;
}
.school-news-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.school-news-card-icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}
.school-news-card-text {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  word-break: break-word;
}

/* Full summary expandable */
.school-news-full {
  margin-top: 8px;
}
.school-news-full summary {
  font-size: 13px;
  font-weight: 600;
  color: #3b82f6;
  cursor: pointer;
  padding: 6px 0;
}
.school-news-summary-text {
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.7;
  color: #374151;
  padding: 12px;
  background: #f8fafc;
  border-radius: 10px;
}

/* Loading state */
.school-news-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 0;
  color: #64748b;
  font-size: 14px;
}
.loading-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #3b82f6;
  animation: dot-pulse 1.2s ease-in-out infinite;
}
@keyframes dot-pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50%       { opacity: 1;   transform: scale(1.2); }
}

@media (max-width: 600px) {
  .school-news-items {
    grid-template-columns: 1fr;
  }
}

/* --- School News Section --- */
.school-news-section { margin-top: 20px; border-left: 4px solid #3b82f6; }
.school-news-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.school-news-title { display: flex; align-items: center; gap: 12px; }
.school-news-icon { font-size: 28px; }
.school-news-date { font-size: 12px; font-weight: 600; color: #64748b; }
.lily-reminder-box { display: flex; align-items: flex-start; gap: 12px; background: #fffbeb; border: 2px solid #fde68a; border-radius: 16px; padding: 14px; margin: 8px 0 16px; }
.lily-reminder-img { width: 50px; height: 65px; object-fit: contain; flex-shrink: 0; }
.lily-reminder-label { font-size: 11px; font-weight: 800; text-transform: uppercase; color: #d97706; margin-bottom: 2px; }
.lily-reminder-text { font-size: 14px; font-weight: 600; color: #92400e; line-height: 1.5; }
.school-news-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.school-news-card { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1.5px solid #e2e8f0; border-radius: 12px; background: #f8fafc; }
.school-news-card-icon { font-size: 18px; margin-top: 1px; }
.school-news-card-text { font-size: 13px; font-weight: 600; line-height: 1.5; color: #334155;}
