/* ── OLIVIA HOMEWORK HELPER — Main Stylesheet ── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:      #1E4D8C;
  --navy-dark: #163A6B;
  --navy-light:#2563a8;
  --gold:      #FFD166;
  --gold-dark: #E6B84D;
  --teal:      #06BCC1;
  --green:     #2ECC71;
  --red:       #E74C3C;
  --bg:        #F0F7FF;
  --white:     #FFFFFF;
  --text:      #1a3050;
  --muted:     #6b8cae;
  --border:    #D5E8FF;
  --bubble-olivia: #FFFFFF;
  --bubble-user:   #1E4D8C;
  --radius:    16px;
  --shadow:    0 4px 24px rgba(30,77,140,0.10);
}

html, body {
  height: 100%;
  font-family: 'Nunito', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ── SCREENS ─────────────────────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
  transform: translateY(20px);
  overflow-y: auto;
}
.screen.active {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

/* ── AVATAR ──────────────────────────────────────────────────────────── */
.avatar-circle {
  width: 120px; height: 120px;
  border-radius: 50%;
  background: #FFE0BC;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.avatar-circle.sm { width: 72px; height: 72px; }
.avatar-circle.xs { width: 42px; height: 42px; }

.av-hair {
  position: absolute; top: 0; left: 0; right: 0;
  height: 48%;
  background: #4A2810;
  border-radius: 50% 50% 30% 30%;
  z-index: 2;
}
.avatar-circle.sm .av-hair { height: 44%; }
.avatar-circle.xs .av-hair { height: 44%; }

.av-face {
  position: absolute;
  top: 28%; left: 50%;
  transform: translateX(-50%);
  width: 70%;
  display: flex; flex-direction: column; align-items: center;
  gap: 6px;
  z-index: 3;
}
.avatar-circle.sm .av-face { top: 26%; gap: 3px; }
.avatar-circle.xs .av-face { top: 26%; gap: 2px; }

.av-eyes {
  display: flex; gap: 14px;
}
.av-eyes span {
  width: 9px; height: 9px;
  background: #2C1A0E;
  border-radius: 50%;
  display: block;
}
.avatar-circle.sm .av-eyes span { width: 6px; height: 6px; }
.avatar-circle.xs .av-eyes span { width: 4px; height: 4px; }
.avatar-circle.sm .av-eyes { gap: 8px; }
.avatar-circle.xs .av-eyes { gap: 5px; }

.av-nose {
  width: 5px; height: 3px;
  background: #C47A50;
  border-radius: 50%;
}

.av-smile {
  width: 22px; height: 10px;
  border: 2.5px solid #C0623A;
  border-top: none;
  border-radius: 0 0 20px 20px;
}
.avatar-circle.sm .av-smile { width: 14px; height: 6px; border-width: 2px; }
.avatar-circle.xs .av-smile { width: 10px; height: 4px; border-width: 1.5px; }

.av-body {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 30%;
  background: #4B9CD3;
  border-radius: 30px 30px 0 0;
  z-index: 2;
}

/* ── WELCOME SCREEN ──────────────────────────────────────────────────── */
.welcome-screen {
  background: linear-gradient(160deg, #1E4D8C 0%, #2563a8 50%, #1a3d70 100%);
}
.welcome-content {
  display: flex; flex-direction: column;
  align-items: center; text-align: center;
  padding: 40px 32px;
  max-width: 420px;
}
.welcome-avatar {
  position: relative;
  margin-bottom: 24px;
}
.avatar-glow {
  position: absolute; inset: -12px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,209,102,0.3) 0%, transparent 70%);
  animation: glow-pulse 2.5s ease-in-out infinite;
}
@keyframes glow-pulse {
  0%,100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.12); opacity: 1; }
}
.welcome-title {
  font-size: 38px; font-weight: 900;
  color: #fff; margin-bottom: 12px;
  line-height: 1.1;
}
.welcome-title span { color: var(--gold); }
.welcome-sub {
  font-size: 16px; color: rgba(255,255,255,0.85);
  line-height: 1.6; margin-bottom: 32px;
}
.btn-start {
  background: var(--gold);
  color: var(--navy-dark);
  border: none; border-radius: 50px;
  padding: 16px 40px;
  font-size: 17px; font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(255,209,102,0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  margin-bottom: 14px;
}
.btn-start:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(255,209,102,0.5); }
.btn-start:active { transform: scale(0.97); }
.welcome-note { font-size: 13px; color: rgba(255,255,255,0.5); font-weight: 600; }

/* ── ONBOARDING ──────────────────────────────────────────────────────── */
.name-screen, .grade-screen {
  background: var(--bg);
  padding: 20px;
}
.onboard-wrap {
  width: 100%; max-width: 440px;
  display: flex; flex-direction: column;
  align-items: center; gap: 20px;
}
.onboard-avatar.small { margin-bottom: -8px; }
.speech-bubble {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 18px 18px 18px 4px;
  padding: 16px 20px;
  font-size: 15px; font-weight: 600;
  color: var(--text);
  line-height: 1.6;
  width: 100%;
  box-shadow: var(--shadow);
}
.onboard-input-wrap {
  display: flex; gap: 10px; width: 100%;
}
.onboard-input {
  flex: 1;
  border: 2px solid var(--border);
  border-radius: 50px;
  padding: 12px 20px;
  font-size: 15px; font-weight: 600;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color 0.2s;
}
.onboard-input:focus { border-color: var(--navy); }
.btn-next {
  background: var(--navy);
  color: white; border: none;
  border-radius: 50px;
  padding: 12px 24px;
  font-size: 15px; font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, transform 0.1s;
}
.btn-next:hover { background: var(--navy-light); }
.btn-next:active { transform: scale(0.97); }

/* ── GRADE GRID ──────────────────────────────────────────────────────── */
.grade-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px; width: 100%;
}
.grade-card {
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  display: flex; flex-direction: column;
  align-items: center; gap: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.grade-card:hover { border-color: var(--navy); transform: translateY(-2px); box-shadow: var(--shadow); }
.grade-card.selected { border-color: var(--navy); background: #EBF3FF; }
.grade-icon { font-size: 28px; }
.grade-label { font-size: 20px; font-weight: 900; color: var(--navy); }
.grade-sub { font-size: 11px; color: var(--muted); font-weight: 600; text-align: center; }

/* ── CHAT SCREEN ─────────────────────────────────────────────────────── */
.chat-screen {
  justify-content: flex-start;
  background: var(--bg);
  padding: 0;
}

/* Topbar */
.topbar {
  width: 100%;
  background: var(--navy);
  padding: 10px 16px;
  display: flex; align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-avatar { position: relative; }
.av-ring {
  position: absolute; inset: -3px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  transition: border-color 0.3s;
}
.av-ring.speaking {
  border-color: var(--gold);
  animation: ring-pulse 1s ease-in-out infinite;
}
@keyframes ring-pulse {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
.topbar-info { display: flex; flex-direction: column; }
.topbar-name { font-size: 15px; font-weight: 800; color: #fff; }
.topbar-status { font-size: 11px; color: rgba(255,255,255,0.65); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.student-chip {
  font-size: 12px; font-weight: 700;
  color: var(--gold);
  background: rgba(255,209,102,0.12);
  padding: 4px 10px; border-radius: 20px;
  border: 1px solid rgba(255,209,102,0.3);
}
.icon-btn {
  background: rgba(255,255,255,0.1);
  border: none; border-radius: 50%;
  width: 32px; height: 32px;
  cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.icon-btn:hover { background: rgba(255,255,255,0.2); }
.icon-btn.active { background: var(--gold); }

/* Progress strip */
.progress-strip {
  display: flex; gap: 6px;
  padding: 8px 14px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
}
.p-chip {
  font-size: 11px; font-weight: 700;
  padding: 4px 10px; border-radius: 20px;
  background: #EEF3FA; color: #7a9ac0;
  white-space: nowrap;
  transition: all 0.3s;
}
.p-chip.active { background: var(--navy); color: #fff; }
.p-chip.done { background: #D4EDDA; color: #1E7A3C; }

/* Chat messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex; flex-direction: column; gap: 12px;
  scroll-behavior: smooth;
}
.msg-wrap { display: flex; align-items: flex-end; gap: 8px; }
.msg-wrap.user { flex-direction: row-reverse; }

.av-mini {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--navy);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: var(--gold);
}

.bubble {
  max-width: 78%;
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 14.5px; line-height: 1.6; font-weight: 600;
  animation: bubble-in 0.25s ease-out;
}
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.bubble.olivia {
  background: var(--white);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-bottom-left-radius: 4px;
}
.bubble.user {
  background: var(--navy);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.bubble.photo-msg {
  background: #EBF5FF;
  border: 1.5px dashed var(--navy);
  color: var(--navy);
  font-size: 13px;
}

/* Typing dots */
.typing { display: flex; gap: 5px; padding: 4px 2px; align-items: center; }
.typing span {
  width: 7px; height: 7px;
  background: #4B9CD3; border-radius: 50%;
  animation: tdot 1.2s ease-in-out infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes tdot { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-5px)} }

/* Subject strip */
.subject-strip {
  padding: 8px 14px;
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 6px;
  overflow-x: auto; flex-shrink: 0;
}
.subject-label { font-size: 11px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.subj-btn {
  font-size: 12px; font-weight: 700;
  padding: 5px 12px; border-radius: 20px;
  background: #EBF3FF; color: var(--navy);
  border: 1.5px solid var(--border);
  cursor: pointer; white-space: nowrap;
  transition: all 0.2s;
}
.subj-btn:hover { background: var(--navy); color: #fff; border-color: var(--navy); }

/* Input area */
.input-area {
  background: var(--white);
  border-top: 1.5px solid var(--border);
  padding: 10px 12px 14px;
  flex-shrink: 0;
}
.input-row { display: flex; gap: 8px; align-items: flex-end; }
.msg-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px; font-weight: 600;
  font-family: inherit; color: var(--text);
  background: var(--bg);
  resize: none; outline: none;
  min-height: 44px; max-height: 120px;
  line-height: 1.5;
  transition: border-color 0.2s;
}
.msg-input:focus { border-color: var(--navy); }
.msg-input::placeholder { color: #99b8d8; }
.send-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--navy); border: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 0.2s, transform 0.1s;
}
.send-btn:hover { background: var(--navy-light); }
.send-btn:active { transform: scale(0.94); }
.send-btn:disabled { background: #ccc; cursor: not-allowed; }

.input-actions {
  display: flex; gap: 8px;
  margin-top: 8px; align-items: center;
}
.action-btn {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 700; color: var(--muted);
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 20px; padding: 6px 12px;
  cursor: pointer; transition: all 0.2s;
}
.action-btn:hover { border-color: var(--navy); color: var(--navy); }
.photo-preview {
  font-size: 12px; font-weight: 700;
  color: var(--green); background: #EAFAF1;
  border: 1.5px solid #A9DFBF;
  border-radius: 20px; padding: 5px 12px;
  display: flex; align-items: center; gap: 6px;
}
.clear-photo {
  background: none; border: none;
  color: var(--red); cursor: pointer; font-size: 12px; font-weight: 800;
}

/* ── MODAL ───────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal-box {
  background: var(--white);
  border-radius: 20px;
  width: 100%; max-width: 420px;
  max-height: 80vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 17px; font-weight: 800; color: var(--navy); }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 16px; color: var(--muted);
}
.modal-body { flex: 1; overflow-y: auto; padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px;
}
.btn-modal-primary {
  flex: 1; background: var(--navy); color: #fff;
  border: none; border-radius: 50px; padding: 12px;
  font-size: 14px; font-weight: 700; cursor: pointer;
}
.btn-modal-secondary {
  background: none; color: var(--muted);
  border: 1.5px solid var(--border); border-radius: 50px; padding: 12px 20px;
  font-size: 14px; font-weight: 700; cursor: pointer;
}
.summary-stat {
  background: var(--bg); border-radius: 10px;
  padding: 12px 16px; margin-bottom: 10px;
  display: flex; justify-content: space-between; align-items: center;
}
.summary-stat-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.summary-stat-val { font-size: 15px; font-weight: 800; color: var(--navy); }
.summary-topics {
  background: #EBF3FF; border-radius: 10px;
  padding: 12px 16px; margin-top: 10px;
  font-size: 13px; font-weight: 600; line-height: 1.8; color: var(--text);
}

/* ── SCROLLBAR ───────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cce0f5; border-radius: 10px; }

/* ── RESPONSIVE ──────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .welcome-title { font-size: 30px; }
  .bubble { font-size: 13.5px; }
}

.mic-btn { width:44px; height:44px; border-radius:50%; background:var(--bg); border:1.5px solid var(--border); cursor:pointer; display:flex; align-items:center; justify-content:center; font-size:18px; flex-shrink:0; transition:all 0.2s; }
.mic-btn:hover { background:#EBF3FF; border-color:var(--navy); }
.mic-btn.listening { background:#FFE5E5; border-color:#E74C3C; animation:mic-pulse 1s ease-in-out infinite; }
@keyframes mic-pulse { 0%,100%{transform:scale(1);box-shadow:0 0 0 0 rgba(231,76,60,0.4)} 50%{transform:scale(1.05);box-shadow:0 0 0 8px rgba(231,76,60,0)} }
