/* ── 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;
  padding-top: 80px;
  overflow: hidden !important;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  position: fixed;
  top: env(safe-area-inset-top);
  left: 0;
  right: 0;
  z-index: 1000;
  width: 100%;
  background: var(--navy);
  padding: 10px 16px;
  padding-top: max(14px, calc(env(safe-area-inset-top) + 4px));
  padding-right: max(16px, env(safe-area-inset-right));
  display: flex; align-items: center;
  justify-content: flex-start;
  gap: 8px;
  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: 16px;
  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; }

  /* Topbar — compact single row on mobile */
  .topbar {
    padding: 6px 8px;
    flex-wrap: nowrap;
    overflow: visible;
    width: 100%;
    box-sizing: border-box;
  }
  .topbar-left { gap: 6px; flex-shrink: 0; min-width: 0; overflow: hidden; width: auto; }
  .topbar-name { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-status { display: none; }
  .student-chip { font-size: 10px; padding: 2px 6px; white-space: nowrap; }
  .topbar-right { gap: 4px; flex-shrink: 0; margin-left: 8px; }
  .summary-btn { padding: 5px 8px; font-size: 10px; gap: 2px; }
  .session-btn { padding: 5px 8px; font-size: 10px; gap: 2px; }
  /* Fix avatar size on mobile */
  .topbar-avatar { width: 36px !important; height: 36px !important; flex-shrink: 0; }
  .topbar-avatar svg, .topbar-avatar img { width: 36px !important; height: 36px !important; }
  .av-face { width: 36px !important; height: 36px !important; }
  /* Show name on mobile */
  .topbar-name { display: block; }
  /* Make buttons fit */
  .summary-btn, .session-btn { padding: 6px 10px; font-size: 12px; white-space: nowrap; flex-shrink: 0; }
  .topbar-right { flex-shrink: 0; overflow: visible; padding-right: max(8px, env(safe-area-inset-right)); }
  .topbar { overflow: visible; }


  /* Grade cards — make sure they fit */
  .grade-card { padding: 16px 10px; }

  /* Chat messages — more breathing room */
  .bubble { max-width: 88%; }

  /* Input area — reduce padding on mobile */
  .input-area { padding: 8px 10px 10px; }
  .msg-input { font-size: 16px; padding: 10px 14px; } /* 16px prevents iOS zoom */
  
  /* Subject strip — smaller buttons */
  .subj-btn { font-size: 11px; padding: 4px 10px; }

  /* Upload/camera buttons — smaller on mobile */
  .action-btn { font-size: 11px; padding: 5px 10px; }

  /* Diagram modal — full screen on mobile */
  #diagramModal > div { 
    max-width: 96%; 
    max-height: 85vh; 
    padding: 16px 12px;
    margin: 0 8px;
  }

  /* Drawing button — full width on mobile */
  .drawing-btn { width: 100%; justify-content: center; }

  /* Progress chips — smaller */
  .p-chip { font-size: 10px; padding: 4px 8px; }
}

.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)} }
/* ── TOPBAR ACTION BUTTONS (New Session / Summary) ───────────────────── */
.topbar-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 50px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s, box-shadow 0.15s, background 0.2s;
  flex-shrink: 0;
}
.topbar-action-btn:hover  { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0,0,0,0.2); }
.topbar-action-btn:active { transform: scale(0.96); }

.session-btn {
  background: #FF8C00;
  color: #fff;
}
.session-btn:hover { background: #e67e00; }

.summary-btn {
  background: var(--teal);
  color: #fff;
}
.summary-btn:hover { background: #04a8ac; }

/* ── SESSION REPORT STYLES ───────────────────────────────────────────── */
.report-header-info { margin-bottom: 16px; }

.report-problems-section { margin-bottom: 16px; }

.report-section-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border);
}

.report-problem {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 12px;
  background: var(--bg);
  border-radius: 10px;
  margin-bottom: 6px;
}
.problem-num {
  font-size: 12px;
  font-weight: 900;
  color: var(--white);
  background: var(--navy);
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.problem-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.problem-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
}
.problem-meta {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}
.problem-time {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.report-note {
  background: #FFF8E7;
  border-left: 4px solid #FF8C00;
  border-radius: 0 10px 10px 0;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.6;
  margin-top: 4px;
}

.btn-modal-print {
  flex: 1;
  background: #FF8C00;
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.btn-modal-print:hover { background: #e67e00; }

.btn-modal-copy {
  flex: 1;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.btn-modal-copy:hover { background: var(--navy-light); }
/* ── DRAWING BUTTON ──────────────────────────────────────────────────────── */
.drawing-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  background: linear-gradient(135deg, #FF8C00, #e67e00);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 3px 10px rgba(255,140,0,0.3);
}
.drawing-btn:hover  { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(255,140,0,0.4); }
.drawing-btn:active { transform: scale(0.96); }
.drawing-btn:disabled { background: #ccc; box-shadow: none; cursor: not-allowed; }

/* ── DIAGRAM MODAL ───────────────────────────────────────────────────────── */
.diagram-modal-box {
  max-width: 480px !important;
}
#diagramContent svg {
  width: 100%;
  height: auto;
  border-radius: 12px;
  background: #f8fbff;
  border: 1.5px solid var(--border);
  padding: 8px;
}

/* PWA standalone mode — tighter topbar */
@media (display-mode: standalone) {
  .topbar {
    padding: 4px 8px !important;
    padding-top: env(safe-area-inset-top) !important;
  }
  .chat-screen {
    padding-top: calc(env(safe-area-inset-top) + 100px) !important;
  }
}

/* ── GRADE PAGE (all groups on one screen) ───────────────────────────── */
.grade-page-wrap {
  width: 100%; max-width: 900px;
  display: flex; flex-direction: column;
  align-items: center; gap: 20px;
  padding: 20px;
}
.grade-bubble { max-width: 500px; }
.grade-groups {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  width: 100%;
}
.grade-group {
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 16px 12px;
  display: flex; flex-direction: column;
  gap: 12px;
}
.grade-group-header {
  display: flex; flex-direction: column;
  align-items: center; gap: 4px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}
.grade-group-icon { font-size: 24px; }
.grade-group-title {
  font-size: 12px; font-weight: 800;
  color: var(--navy); text-transform: uppercase;
  letter-spacing: 0.5px; text-align: center;
}
.grade-group-cards {
  display: flex; flex-direction: column; gap: 8px;
}
.grade-group-cards .grade-card {
  padding: 10px 8px;
  flex-direction: row;
  justify-content: flex-start;
  gap: 10px;
}
.grade-group-cards .grade-label {
  font-size: 18px; min-width: 24px; text-align: center;
}
.grade-group-cards .grade-sub {
  font-size: 12px; text-align: left;
}
.back-btn {
  align-self: flex-start;
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 50px;
  padding: 6px 16px;
  font-size: 13px; font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
}
.back-btn:hover { border-color: var(--navy); color: var(--navy); }

/* Mobile — stack groups 2x2 */
@media (max-width: 640px) {
  .grade-groups { grid-template-columns: repeat(2, 1fr); }
}

/* ── GRADE GROUP COLORS ──────────────────────────────────────────────── */
.grade-group.early-elem  { background: #F0FAF0; border-color: #B8E0B8; }
.grade-group.elementary  { background: #FFFBF0; border-color: #F0DFA0; }
.grade-group.middle      { background: #F5F0FF; border-color: #C8B8F0; }
.grade-group.high        { background: #F0F4FF; border-color: #B8C8F0; }

.grade-group.early-elem .grade-group-title  { color: #2D7A2D; }
.grade-group.elementary .grade-group-title  { color: #8A6A00; }
.grade-group.middle     .grade-group-title  { color: #5A3D9A; }
.grade-group.high       .grade-group-title  { color: #1E3D8A; }

.grade-group.early-elem .grade-group-header { border-bottom-color: #B8E0B8; }
.grade-group.elementary .grade-group-header { border-bottom-color: #F0DFA0; }
.grade-group.middle     .grade-group-header { border-bottom-color: #C8B8F0; }
.grade-group.high       .grade-group-header { border-bottom-color: #B8C8F0; }

/* Olivia Audio Player */
.olivia-player {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 6px 12px;
  background: white;
  border: 1px solid #d0dff0;
  border-radius: 13px;
  box-shadow: 0 3px 10px rgba(30,77,140,0.08);
  width: 100%;
  box-sizing: border-box;
}
.player-btn {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #c5d8f0;
  border-radius: 50%;
  background: white;
  color: var(--navy);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.player-btn:hover { background: var(--navy); color: white; border-color: var(--navy); }
.player-btn.active { background: var(--navy); color: white; border-color: var(--navy); }
.player-time {
  font-size: 11px;
  color: var(--navy);
  font-weight: 600;
  min-width: 32px;
  text-align: center;
}
.player-progress {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #d0dff0;
  border-radius: 2px;
  cursor: pointer;
  outline: none;
}
.player-progress::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--navy);
  cursor: pointer;
}
.player-progress::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--navy);
  border: none;
  cursor: pointer;
}

/* Legacy — keep for fallback */
.audio-controls { display: none; }
.replay-btn, .pause-btn { display: none; }

.inline-draw { margin: 10px 0 4px; padding: 8px; background: #f4f8ff; border: 1px solid #d6e4f7; border-radius: 12px; text-align: center; overflow-x: auto; }
.inline-draw svg { max-width: 100%; height: auto; }

.recap-btn{display:block;margin:10px auto 0;padding:10px 18px;border:none;border-radius:20px;background:#FF8C00;color:#fff;font-weight:700;font-size:15px;cursor:pointer;font-family:inherit}
.recap-btn:disabled{opacity:.7}
.recap-box{margin-top:10px;padding:10px;background:#f3f8ff;border:1px solid #cfe0f5;border-radius:12px;text-align:center}
.recap-head{font-weight:700;color:#1E4D8C;margin-bottom:4px}
.recap-pic svg{max-width:100%;height:auto}
.recap-cap{font-size:15px;color:#1E4D8C;margin:6px 0;min-height:44px;text-align:left}
.recap-stop{border:1px solid #1E4D8C;background:#fff;color:#1E4D8C;border-radius:14px;padding:4px 12px;font-weight:700;cursor:pointer}

.recap-step{font-size:12px;font-weight:800;color:#FF8C00;text-transform:uppercase;letter-spacing:.6px;margin-bottom:4px}
.recap-cap{min-height:96px}
.recap-line{opacity:0;max-height:0;overflow:hidden;transition:opacity .4s;font-size:17px;line-height:1.5;margin:0;color:#4a6a8f;padding-left:8px;border-left:3px solid transparent}
.recap-line.show{opacity:1;max-height:220px;margin:6px 0}
.recap-line.active{color:#1E4D8C;font-weight:600;border-left-color:#FF8C00}
.recap-line b{color:#1E4D8C;font-weight:800}

.recap-actions{display:flex;gap:10px;justify-content:center;flex-wrap:wrap;margin-top:10px}
.recap-actions .recap-btn{margin:0}
.newprob-btn{padding:10px 18px;border:none;border-radius:20px;background:#2A9D8F;color:#fff;font-weight:700;font-size:15px;cursor:pointer;font-family:inherit}

.recap-ask{text-align:center;color:#1D3C7A;font-weight:700;font-size:15px;margin-top:12px}

/* input layout: photo/camera buttons to the right of the question box */
.input-area { display: flex; align-items: flex-end; gap: 10px; }
.input-area .input-row { flex: 1; min-width: 0; }
.input-area .input-actions { margin-top: 0; flex-direction: column; align-items: stretch; gap: 6px; flex-shrink: 0; }
.input-area .action-btn { justify-content: flex-start; white-space: nowrap; }
@media (max-width: 600px) {
  .input-area .action-btn { font-size: 0; gap: 0; padding: 10px; justify-content: center; }
}

/* order: question box, upload/camera, mic, send */
.input-area .input-row { display: contents; }
.input-area .msg-input { order: 1; flex: 1; min-width: 0; }
.input-area .input-actions { order: 2; }
.input-area .input-row > div { order: 3; }
.input-area .send-btn { order: 4; }

/* fixed audio player dock above the input area */
#playerDock { background: var(--white); border-top: 1.5px solid var(--border); padding: 6px 12px 0; flex-shrink: 0; }
#playerDock:empty { display: none; }
#playerDock .olivia-player { margin: 0; }

/* split layout: steps left, current picture right (wide screens, ?layout=split) */
.teach-split { min-width: min(820px, 78vw); }
.bubble:has(.teach-split) { overflow: visible; }
.teach-split-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.teach-split .teach-board { position: sticky; top: 8px; background: #fff; border: 1.5px solid #dbe6f5; border-radius: 14px; padding: 10px; min-height: 200px; display: flex; align-items: center; justify-content: center; }
.teach-split .teach-board svg { max-width: 100%; height: auto; max-height: 420px; }
.teach-split .teach-block { opacity: .55; transition: opacity .25s, background .25s; border-radius: 10px; padding: 8px 10px; }
.teach-split .teach-block.current { opacity: 1; background: #fff7e6; box-shadow: inset 4px 0 0 #FF8C00; }

/* split v2: two scrolling panes, pictures stack up */
.teach-split-wrap { height: min(72vh, 620px); align-items: stretch; }
.teach-split .teach-stack { height: 100%; overflow-y: auto; padding-right: 6px; }
.teach-split .teach-board { position: static; height: 100%; overflow-y: auto; display: block; padding: 8px; min-height: 0; }
.teach-split .teach-board svg { max-height: 300px; }
.teach-pic { border: 1.5px solid #e1eaf7; border-radius: 12px; padding: 6px 6px 2px; margin-bottom: 10px; background: #fff; opacity: .6; transition: opacity .25s, border-color .25s; }
.teach-pic.current { opacity: 1; border-color: #FF8C00; }
.teach-pic-lab { font-size: 11px; font-weight: 800; color: #f08c00; text-transform: uppercase; letter-spacing: .3px; }

/* mode switch */
#modeBar { background: var(--white); border-top: 1.5px solid var(--border); padding: 6px 12px 2px; flex-shrink: 0; text-align: center; }
#modeBar .mode-btns { display: inline-flex; border: 1.5px solid var(--border); border-radius: 20px; overflow: hidden; }
#modeBar button { border: 0; background: var(--bg); color: var(--muted); font-size: 12px; font-weight: 700; font-family: inherit; padding: 5px 14px; cursor: pointer; }
#modeBar button.on { background: var(--navy); color: #fff; }
#modeBar .mode-note { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* compact mode switch beside upload/camera */
.input-area #modeBar { order: 2; display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; padding: 0; border: 0; background: none; }
.input-area #modeBar button { border: 1.5px solid var(--border); border-radius: 20px; padding: 6px 12px; font-size: 12px; white-space: nowrap; }
.input-area #modeBar button.on { border-color: var(--navy); }
@media (max-width: 520px) { .input-area #modeBar button { padding: 6px 8px; font-size: 11px; } }

/* hide the top progress chips to save space */
.progress-strip { display: none !important; }

.recap-pace{margin-left:8px;border:1px solid #1E4D8C;background:#fff;color:#1E4D8C;border-radius:14px;padding:4px 12px;font-weight:700;cursor:pointer;font-family:inherit}

#playerDock { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.dock-lesson { display: flex; flex-direction: column; gap: 4px; }
.dock-lesson button { border: 1px solid #1E4D8C; background: #fff; color: #1E4D8C; border-radius: 14px; padding: 4px 10px; font-weight: 700; font-size: 12px; cursor: pointer; font-family: inherit; white-space: nowrap; }

/* compact dock row */
#playerDock { flex-wrap: nowrap !important; gap: 6px !important; padding: 4px 8px 0 !important; }
#playerDock .olivia-player { display: flex !important; align-items: center !important; flex: 0 1 230px !important; min-width: 0 !important; width: auto !important; max-width: none !important; padding: 2px 8px !important; gap: 5px !important; border-radius: 16px !important; margin: 0 !important; }
#playerDock .player-btn { width: 24px !important; height: 24px !important; min-width: 24px !important; padding: 0 !important; font-size: 11px !important; line-height: 1 !important; }
#playerDock .player-time { font-size: 10px !important; min-width: 0 !important; }
#playerDock .player-progress { flex: 1 1 50px !important; width: 50px !important; min-width: 30px !important; }
.dock-lesson { flex-direction: row !important; gap: 6px !important; flex-shrink: 0; }
.dock-lesson button { padding: 3px 9px !important; font-size: 11px !important; line-height: 1.3; height: 26px; }

/* olivia_zoom85: shrink everything 15%. Remove this rule (or restore .bak_zoom) to undo */
html { zoom: .85; }

/* olivia_chips */
.grade-card.has-chips { flex-wrap: wrap; height: auto; }
.grade-chips { flex: 0 0 100%; display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.grade-chip { font-size: 10px; font-weight: 700; padding: 3px 7px; border-radius: 10px; background: #eef5ff; color: #1E4D8C; border: 1px solid #D5E8FF; cursor: pointer; }
.grade-chip:hover { background: #1E4D8C; color: #fff; }

/* olivia_def: sharper grade screens (zoom back up to ~98%), bigger darker chips */
#gradeScreen, #specificGradeScreen, #subjectScreen { zoom: 1.15; }
.grade-chips { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.grade-chip { font-size: 12px; font-weight: 800; padding: 5px 8px; text-align: center; color: #0f2f5c; background: #e4efff; border: 1px solid #b9d3f5; }
.grade-card .grade-sub { color: #1a3050; font-weight: 700; }

/* olivia_col: a little more colour */
.grade-chip[data-chip="Math"] { background: #dcebff; border-color: #a9c9f5; color: #0f2f5c; }
.grade-chip[data-chip="Reading & Writing"] { background: #dcf5e3; border-color: #a6dcb5; color: #12502a; }
.grade-chip[data-chip="Science"] { background: #ebe3fb; border-color: #c6b6ee; color: #3a1d78; }
.grade-chip[data-chip="History"] { background: #fff4e6; border-color: #f7dcb8; color: #7a4a14; }
.grade-chip:hover { filter: brightness(.93); background-clip: padding-box; color: inherit; }
.grade-group.early, .grade-group:nth-child(1) { background: #e6f6e8; border-color: #a9dcb0; }
.grade-group.elementary, .grade-group:nth-child(2) { background: #fff7d9; border-color: #f0d98a; }
.grade-group .grade-card { border-width: 2px; border-color: #c4dcfa; }

/* olivia_ad */
html.ad-mode .screen:not(#chatScreen) { display: none !important; }
html.ad-mode .topbar, html.ad-mode .progress-strip, html.ad-mode .subject-strip,
html.ad-mode .input-actions, html.ad-mode #modeBar, html.ad-mode #micBtn, html.ad-mode #micHint,
html.ad-mode #playerDock, html.ad-mode .dock-lesson { display: none !important; }
html.ad-frame body { background: #111; }
html.ad-frame .screen { left: 50% !important; right: auto !important; width: calc(min(100dvh * .5625, 100vw) / .85) !important; transform: translateX(-50%); }
html.ad-wide .screen { width: calc(min(100dvh * 1.7778, 100vw) / .85) !important; }

/* olivia_ad3 */
html.ad-mode .recap-stop, html.ad-mode .recap-pace { display: none !important; }

/* olivia_ad5 */
html.ad-mode .recap-ask { display: none !important; }

/* olivia_mathonly + new mode buttons */
html.math-only .grade-chips, html.math-only #subjectStrip { display: none !important; }
#mathPill { display: block; width: fit-content; margin: 6px auto 4px; background: #FFD9A0; color: #0B2A66; border: 2px solid #FF9F1C; border-radius: 20px; padding: 4px 18px; font-weight: 800; font-size: 15px; text-align: center; }
#modeBar button, .input-area #modeBar button { background: #FFD9A0; color: #0B2A66; font-weight: 800; border: 1.5px solid #F0B060; }
#modeBar button.on, .input-area #modeBar button.on { background: #FF9F1C; color: #0B2A66; border-color: #C46A00; box-shadow: 0 0 0 2px rgba(255,159,28,.35); }

/* olivia_disc */
#aiNote { font-size: 10px; color: var(--muted); text-align: center; padding: 2px 10px 6px; line-height: 1.3; background: var(--white); flex-shrink: 0; }
html.ad-mode #aiNote { display: none !important; }

/* olivia_lines: slightly firmer soft borders (undo: restore styles/main.css.bak_lines) */
:root { --border: #B4CFEE; }
.action-btn, .input-actions .action-btn { border: 1.5px solid #A9C6EA !important; color: #2A558F !important; }
.olivia-player { border-color: #B4CFEE !important; }
#aiNote { color: #55759B; }

/* olivia_touch: no zoom on touch devices and small screens (iPhone Safari made the page wider than the screen) */
@media (pointer: coarse), (max-width: 900px) {
  html, #gradeScreen, #specificGradeScreen, #subjectScreen { zoom: 1 !important; }
}
@media (max-width: 600px) {
  #playerDock { flex-wrap: wrap !important; justify-content: center; }
}

/* olivia_phone: stack the bottom block and let tall screens scroll on phones */
@media (max-width: 600px) {
  .input-area { flex-wrap: wrap; box-sizing: border-box; width: 100%; max-width: 100%; justify-content: center; align-items: center; gap: 8px; padding: 8px 10px 4px; }
  .input-area .msg-input { order: 1; flex: 1 1 calc(100% - 60px); min-width: 0; }
  .input-area .send-btn { order: 2; flex: 0 0 auto; }
  .input-area #modeBar { order: 3; }
  .input-area .input-actions { order: 4; }
  .input-area .input-row > div { order: 5; }
  .chat-messages { width: 100%; box-sizing: border-box; overflow-x: hidden; }
  #aiNote { box-sizing: border-box; width: 100%; }
  #gradeScreen, #specificGradeScreen, #subjectScreen { justify-content: flex-start !important; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: 90px; box-sizing: border-box; }
}

/* olivia_head: compact chat header on phones (a header wider than the screen made iPhone Safari widen the whole page) */
@media (max-width: 600px) {
  .topbar { box-sizing: border-box; max-width: 100%; padding-left: 8px !important; padding-right: 8px !important; gap: 6px; }
  .topbar-left { min-width: 0; gap: 6px; }
  .topbar-status { display: none !important; }
  .topbar-right { min-width: 0; gap: 5px !important; flex-shrink: 1; }
  .student-chip { font-size: 9.5px !important; padding: 3px 6px !important; max-width: 124px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-action-btn { padding: 6px 10px !important; font-size: 12px !important; }
  .topbar .icon-btn { width: 30px !important; height: 30px !important; font-size: 15px !important; }
}

/* olivia_vp: stop iOS zooming in on the typing box */
@media (pointer: coarse), (max-width: 900px) {
  textarea, input, select { font-size: 16px !important; }
}

/* olivia_compact */
@media (max-width: 520px) {
  .input-area #modeBar { flex-direction: row; gap: 4px; }
  .input-area .input-actions { flex-direction: row; gap: 4px; }
  .input-area .action-btn { padding: 8px; }
  .input-area .mic-btn { width: 40px; height: 40px; }
  #micHint { display: none !important; }
}

/* olivia_pic */
.teach-pic, .recap-pic { height: auto !important; min-height: 0 !important; aspect-ratio: auto !important; }
.teach-pic svg, .recap-pic svg { display: block; width: 100%; height: auto !important; max-height: none; }
#aiNote { white-space: nowrap; font-size: 11px; padding: 4px 8px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 400px) { #aiNote { font-size: 10px; } }
