:root {
  --white: #ffffff;
  --black: #0a0a0a;
  --blue-dark: #0a1e3d;
  --blue-primary: #1a56db;
  --blue-light: #3b82f6;
  --blue-bg: #e8f0fe;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-900: #0f172a;
  --shadow: 0 4px 24px rgba(10, 30, 61, 0.12);
  --radius: 12px;
  --topbar-h: 48px;
  --tabs-h: 42px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  min-height: 100dvh;
}

/* ============================================================
   AUTH PAGE
   ============================================================ */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--white) 0%, var(--blue-bg) 100%);
  padding: 16px;
  min-height: 100vh;
  min-height: 100dvh;
}
.auth-container { width: 100%; max-width: 420px; }
.auth-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 16px;
  padding: 32px 24px;
  box-shadow: var(--shadow);
}
.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo h1 { font-size: 24px; font-weight: 800; color: var(--blue-primary); margin-top: 2px; }
.tagline { color: var(--gray-500); font-size: 11px; font-weight: 500; letter-spacing: 2px; margin-top: 2px; }

.auth-tabs {
  display: flex;
  background: var(--gray-100);
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 20px;
}
.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
}
.auth-tab.active {
  background: var(--white);
  color: var(--blue-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.auth-form { display: none; flex-direction: column; gap: 14px; }
.auth-form.active { display: flex; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--gray-700); }
.form-group input {
  padding: 12px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus {
  border-color: var(--blue-primary);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.12);
}
.password-wrapper { position: relative; display: flex; align-items: center; width: 100%; }
.password-wrapper input { flex: 1; padding-right: 42px; width: 100%; }
.toggle-password {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 22px;
  padding: 0; line-height: 1; color: var(--gray-500); z-index: 2;
  display: flex; align-items: center; justify-content: center; width: 28px; height: 28px;
}

.btn-primary {
  padding: 12px 20px;
  background: var(--blue-primary);
  color: var(--white);
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary { background: var(--white); color: var(--blue-primary); border: 1.5px solid var(--blue-primary); }
.btn-secondary:hover { background: var(--blue-bg); }

.remember-me {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--gray-600);
  cursor: pointer;
  user-select: none;
}
.remember-me input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--blue-primary);
  cursor: pointer;
  margin: 0;
}

.auth-toggle-text { text-align: center; font-size: 13px; color: var(--gray-500); }
.auth-toggle-text a { color: var(--blue-primary); text-decoration: none; font-weight: 600; }

.auth-footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 24px;
  padding-bottom: 8px;
}
.auth-footer-links a {
  color: var(--gray-500);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: color 0.2s;
}
.auth-footer-links a:hover { color: var(--blue-primary); }

/* ============================================================
   APP PAGE — LAYOUT
   ============================================================ */
.app-page {
  overflow-x: hidden;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  max-width: 100vw;
}
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  max-width: 100%;
}

/* Top Bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  height: var(--topbar-h);
  flex-shrink: 0;
  min-width: 0;
  overflow: hidden;
}
.topbar-left { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.topbar-center { flex: 1; min-width: 0; padding: 0 8px; }
.topbar-right { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

.logo-icon { font-size: 20px; }
.logo-text { font-size: 16px; font-weight: 800; color: var(--blue-primary); }

.btn-icon {
  background: var(--gray-100);
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--gray-200); }
.btn-icon:active { background: var(--gray-300); }
#logoutBtn:hover { background: #dc2626; color: #fff; }
#logoutBtn:active { background: #b91c1c; color: #fff; }

/* Feature Tabs — shown on desktop, hidden on mobile (mobile uses FAB) */
.feature-tabs {
  display: flex;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 8px;
  flex-shrink: 0;
  height: var(--tabs-h);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.feature-tabs::-webkit-scrollbar { display: none; }
.feature-tab {
  padding: 10px 16px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.feature-tab:hover { color: var(--blue-primary); }
.feature-tab.active { color: var(--blue-primary); border-bottom-color: var(--blue-primary); }

/* Main Area */
.main-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  width: 100%;
  max-width: 100%;
}

/* Whiteboard */
.whiteboard-section {
  flex: 0 0 auto;
  height: 35vh;
  min-height: 160px;
  max-height: 280px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
}
.whiteboard-section.hidden { display: none; }
.main-area.whiteboard-hidden .interaction-section { flex: 1; width: 100%; max-width: 100%; }
.whiteboard-container {
  flex: 1;
  min-height: 0;
  background: var(--white);
  border: 2px solid var(--gray-200);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  position: relative;
  width: 100%;
  max-width: 100%;
}
.canvas-wrapper { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; border-radius: 10px 10px 0 0; }
.canvas-wrapper canvas { width: 100%; display: block; background: var(--white); cursor: crosshair; touch-action: none; }
.whiteboard-controls { display: flex; gap: 6px; padding: 6px 10px; border-top: 1px solid var(--gray-200); background: var(--gray-50); flex-shrink: 0; }

.btn-sm {
  padding: 5px 12px;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-sm:hover { background: var(--blue-primary); color: var(--white); border-color: var(--blue-primary); }
.btn-sm:active { transform: scale(0.95); }

/* Avatar overlay — bottom-right of whiteboard */
.avatar-overlay {
  position: absolute;
  bottom: 44px;
  right: 2px;
  z-index: 5;
  pointer-events: none;
  width: 60px;
  height: auto;
}
.lecturer-svg { width: 100%; height: auto; display: block; filter: drop-shadow(-2px 4px 8px rgba(0, 0, 0, 0.15)); }

/* Interaction Section */
.interaction-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  width: 100%;
  max-width: 100%;
}

/* ============================================================
   MODE PANELS
   ============================================================ */
.mode-panel { display: none; flex-direction: column; flex: 1; overflow: hidden; }
.mode-panel.active { display: flex; }
.mode-header { padding: 8px 12px 2px; flex-shrink: 0; }
.mode-header h3 { font-size: 14px; color: var(--blue-primary); margin-bottom: 1px; }
.mode-header p { font-size: 11px; color: var(--gray-500); }

/* ASK MODE */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.message {
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.6;
  max-width: 94%;
}
.message.system { background: var(--blue-bg); color: var(--gray-900); align-self: flex-start; border-bottom-left-radius: 2px; }
.message.user { background: var(--blue-primary); color: var(--white); align-self: flex-end; border-bottom-right-radius: 2px; }

.chat-input-area {
  padding: 6px 10px 8px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
  flex-shrink: 0;
}
.input-row { display: flex; gap: 6px; }
#chatInput {
  flex: 1;
  padding: 10px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: 16px;
  outline: none;
  min-width: 0;
  resize: none;
  font-family: inherit;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
}
#chatInput:focus { border-color: var(--blue-primary); }
.btn-send { padding: 10px 16px; font-size: 14px; white-space: nowrap; }
#cameraBtn { font-size: 18px; }
#imagePreview {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px 0 0;
  position: relative;
}
#imagePreview img {
  max-height: 80px;
  max-width: 100px;
  border-radius: 6px;
  border: 1.5px solid var(--gray-200);
  object-fit: cover;
}
.img-preview-close {
  position: absolute;
  top: 2px;
  left: 0;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.difficulty-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 5px;
  font-size: 11px;
  color: var(--gray-500);
  overflow-x: auto;
}
.diff-btn {
  padding: 3px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 12px;
  background: var(--white);
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.diff-btn.active { background: var(--blue-primary); color: var(--white); border-color: var(--blue-primary); }
.diff-btn:hover:not(.active) { border-color: var(--blue-primary); color: var(--blue-primary); }

/* NOTES MODE */
.notes-header {
  font-size: 13px;
  font-weight: 700;
  color: var(--blue-primary);
  padding: 6px 0 4px;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 8px;
}
.notes-result {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  font-size: 13px;
  line-height: 1.6;
}
.notes-result p { margin: 0; }

/* EXAM MODE */
#modeNotes { padding: 8px 12px; }
#notesInput {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  resize: vertical;
  font-family: inherit;
  min-height: 120px;
}
#notesInput:focus { border-color: var(--blue-primary); }
#modeExam { padding: 8px 12px; }
.exam-row { display: flex; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
#examTopic {
  flex: 1;
  min-width: 120px;
  padding: 9px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}
#examTopic:focus { border-color: var(--blue-primary); }
.exam-timer { text-align: center; font-size: 13px; color: var(--gray-500); margin: 4px 0; font-weight: 600; }
.exam-result { flex: 1; overflow-y: auto; font-size: 13px; line-height: 1.6; }
.exam-result .flashcard { margin-bottom: 8px; padding: 8px; background: var(--blue-bg); border-radius: 8px; }
.exam-result .flashcard strong { color: var(--blue-primary); }

/* QUIZ */
.quiz-container { padding: 6px 0; }
.quiz-question {
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
}
.quiz-q-text {
  font-weight: 600;
  font-size: 13px;
  color: var(--gray-900);
  margin-bottom: 8px;
  line-height: 1.5;
}
.quiz-options { display: flex; flex-direction: column; gap: 4px; }
.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--gray-700);
  transition: all 0.15s;
  line-height: 1.4;
  background: var(--gray-50);
}
.quiz-option:hover { border-color: var(--blue-primary); background: var(--blue-bg); }
.quiz-option input[type="radio"] {
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--blue-primary);
}
.quiz-option:has(input:checked) {
  border-color: var(--blue-primary);
  background: var(--blue-bg);
  color: var(--blue-primary);
  font-weight: 600;
}
.quiz-opt-label { flex: 1; white-space: normal; word-break: break-word; }
.quiz-submit-btn {
  display: block;
  width: 100%;
  padding: 12px;
  background: var(--blue-primary);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  margin: 8px 0;
}
.quiz-submit-btn:hover { background: var(--blue-dark); }
.quiz-submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Quiz results */
.quiz-result-header {
  text-align: center;
  padding: 16px;
  border-radius: 10px;
  margin-bottom: 12px;
}
.quiz-pass { background: #dcfce7; border: 1.5px solid #86efac; }
.quiz-fail { background: #fef2f2; border: 1.5px solid #fca5a5; }
.quiz-score {
  display: block;
  font-size: 32px;
  font-weight: 800;
  color: var(--gray-900);
}
.quiz-grade {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-600);
  margin-top: 4px;
}
.quiz-correct { border-color: #86efac; background: #f0fdf4; }
.quiz-incorrect { border-color: #fca5a5; background: #fef2f2; }
.quiz-option-result {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--gray-700);
  border: 1.5px solid var(--gray-200);
  background: var(--gray-50);
}
.quiz-opt-correct {
  border-color: #86efac;
  background: #dcfce7;
  color: #166534;
  font-weight: 600;
}
.quiz-opt-wrong {
  border-color: #fca5a5;
  background: #fef2f2;
  color: #991b1b;
  font-weight: 600;
}
.quiz-correct-answer {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #166534;
  text-align: center;
  padding: 6px;
  background: #dcfce7;
  border-radius: 6px;
}
.quiz-new-btn {
  display: block;
  width: 100%;
  padding: 10px;
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  margin: 8px 0;
}
.quiz-new-btn:hover { background: var(--gray-200); }

/* ============================================================
   SCROLLBAR
   ============================================================ */
.chat-messages::-webkit-scrollbar,
.notes-result::-webkit-scrollbar,
.exam-result::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-track,
.notes-result::-webkit-scrollbar-track,
.exam-result::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb,
.notes-result::-webkit-scrollbar-thumb,
.exam-result::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }

/* ============================================================
   INFO PAGES (about, review, contact)
   ============================================================ */
.page-nav {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.page-nav::-webkit-scrollbar { display: none; }
.back-btn {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 28px;
  background: var(--blue-primary);
  color: #fff;
  border: none;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(26, 86, 219, 0.3);
  z-index: 50;
  transition: all 0.2s;
  white-space: nowrap;
}
.back-btn:hover { background: var(--blue-dark); transform: translateX(-50%) translateY(-1px); box-shadow: 0 6px 20px rgba(26, 86, 219, 0.4); }
.back-btn:active { transform: translateX(-50%) translateY(0); }
.page-nav a {
  color: var(--blue-primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  padding: 6px 14px;
  border-radius: 6px;
  transition: background 0.2s;
  white-space: nowrap;
}
.page-nav a:hover { background: var(--blue-bg); }
.page-nav a.active { background: var(--blue-primary); color: white; }

/* ============================================================
   APP FOOTER
   ============================================================ */
.app-footer {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 10px 16px;
  flex-shrink: 0;
  background: var(--white);
  border-top: 1px solid var(--gray-200);
}
.app-footer a {
  color: var(--gray-500);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: color 0.2s;
}
.app-footer a:hover { color: var(--blue-primary); }

/* ============================================================
   MOBILE BOTTOM BAR
   ============================================================ */
.mobile-bottom-bar {
  display: none;
}

.fab-overlay {
  position: fixed;
  inset: 0;
  z-index: 98;
  background: rgba(0, 0, 0, 0.3);
  display: none;
}
.fab-overlay.open { display: block; }

.fab-menu {
  position: fixed;
  bottom: 72px;
  left: 10px;
  z-index: 101;
  background: var(--white);
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  display: none;
  min-width: 180px;
}
.fab-menu.open { display: block; }

.fab-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--blue-primary);
  color: white;
  font-size: 26px;
  font-weight: 300;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.fab-btn.open { transform: rotate(45deg); background: var(--blue-dark); }

.mobile-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--gray-100);
  border-radius: 24px;
  padding: 2px 2px 2px 14px;
  min-width: 0;
}
#mobileInput {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  outline: none;
  min-width: 0;
  font-family: inherit;
  color: var(--gray-900);
}
#mobileInput::placeholder { color: var(--gray-500); }

.mobile-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
.mobile-icon-btn:hover { background: var(--gray-200); }
.mobile-icon-btn.send-btn { background: var(--blue-primary); color: white; }
.mobile-icon-btn.send-btn:hover { background: var(--blue-dark); }
#mobileShareBtn { font-size: 16px; }

.fab-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.fab-option:hover { background: var(--gray-50); }
.fab-option.active { color: var(--blue-primary); background: var(--blue-bg); }
.fab-option:not(:last-child) { border-bottom: 1px solid var(--gray-100); }

/* ============================================================
   TYPING ANIMATION
   ============================================================ */
.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--blue-primary);
  margin-left: 2px;
  animation: blink 0.7s step-end infinite;
  vertical-align: text-bottom;
}
@keyframes blink {
  50% { opacity: 0; }
}
.typing-text {
  white-space: pre-wrap;
  word-break: break-word;
}

/* ============================================================
   LOADING DOTS
   ============================================================ */
.loading-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue-primary);
  animation: dotBounce 1.2s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ============================================================
   SUGGESTED QUESTIONS
   ============================================================ */
.suggested-questions {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 0;
  margin: 2px 0 6px;
}
.suggested-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.suggested-q {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: var(--gray-50);
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-900);
  cursor: pointer;
  transition: all 0.15s;
  white-space: normal;
  text-align: left;
  word-break: break-word;
  line-height: 1.4;
}
.suggested-q:hover {
  background: var(--blue-bg);
  border-color: var(--blue-primary);
  color: var(--blue-primary);
}
.suggested-q:active {
  background: var(--blue-primary);
  color: var(--white);
}

/* ============================================================
   QUICK TOPIC BUTTONS
   ============================================================ */
.topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 4px 10px 8px;
}
.topic-chip {
  padding: 6px 14px;
  border: 1px solid var(--gray-300);
  border-radius: 18px;
  background: var(--gray-50);
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-700);
  cursor: pointer;
  transition: all 0.2s;
  white-space: normal;
  text-align: left;
  word-break: break-word;
  line-height: 1.3;
}
.topic-chip:hover {
  border-color: var(--blue-primary);
  color: var(--blue-primary);
  background: var(--white);
}
.topic-chip:active {
  transform: scale(0.96);
}

/* ============================================================
   STREAK BADGE
   ============================================================ */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  background: linear-gradient(135deg, #f97316, #ef4444);
  color: white;
  font-size: 11px;
  font-weight: 700;
  border-radius: 12px;
  margin-left: 6px;
  white-space: nowrap;
}

/* ============================================================
   SAVE, PLAY, SHARE BUTTONS
   ============================================================ */
.save-btn, .share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
  margin-left: 3px;
  vertical-align: middle;
}
.save-btn:hover, .share-btn:hover {
  background: var(--gray-200);
  transform: scale(1.1);
}
.share-btn { color: #25D366; }

/* ============================================================
   HISTORY PANEL
   ============================================================ */
.history-panel {
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  overflow: hidden;
  margin: 4px 0;
  box-shadow: var(--shadow);
}
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  font-size: 13px;
  font-weight: 700;
  color: var(--blue-primary);
}
.history-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--gray-500);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.history-close:hover { color: var(--gray-900); }
.history-list { max-height: 280px; overflow-y: auto; }
.history-item {
  padding: 8px 10px;
  border-bottom: 1px solid var(--gray-100);
  transition: background 0.15s;
}
.history-item:hover { background: var(--blue-bg); }
.history-item:last-child { border-bottom: none; }
.history-q { font-size: 12px; font-weight: 700; color: var(--gray-900); margin-bottom: 2px; }
.history-a { font-size: 11px; color: var(--gray-600); line-height: 1.4; margin-bottom: 4px; }
.history-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 10px; color: var(--gray-500); }
.history-play {
  background: var(--blue-bg);
  border: none;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  color: var(--blue-primary);
  font-weight: 600;
}
.history-play:hover { background: var(--blue-primary); color: #fff; }
.history-del {
  background: transparent;
  border: none;
  font-size: 12px;
  color: var(--gray-500);
  cursor: pointer;
  padding: 2px 4px;
}
.history-del:hover { color: #dc2626; }
.history-empty {
  padding: 16px 10px;
  text-align: center;
  font-size: 12px;
  color: var(--gray-500);
}

/* ============================================================
   SAVE & SHARE IN MESSAGES
   ============================================================ */
.message.system .msg-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ============================================================
   KEYFRAMES
   ============================================================ */


/* ============================================================
   RESPONSIVE — TABLETS+ (≥768px)
   ============================================================ */
@media (min-width: 768px) {
  .main-area { flex-direction: row; min-height: 0; overflow: hidden; }
  .app-footer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; }
  .interaction-section { width: 400px; max-width: 400px; flex: none; border-top: none; border-left: 1px solid var(--gray-200); padding-bottom: 48px; display: flex; flex-direction: column; height: 100%; min-height: 0; }
  .chat-messages { flex: 1; overflow-y: auto; min-height: 0; }
  .whiteboard-section { flex: 1; width: auto; min-width: 0; height: 100%; min-height: 0; max-height: none; padding: 12px 12px 60px; }
  .whiteboard-controls { padding: 8px 12px; }
  .mode-header { padding: 10px 16px 4px; }
  .mode-header h3 { font-size: 15px; }
  .avatar-overlay { bottom: 56px; right: 6px; width: 100px; }
  .mobile-bottom-bar, .fab-overlay, .fab-menu { display: none !important; }
  .feature-tabs { display: flex; }
}

/* ============================================================
   RESPONSIVE — MOBILE (<768px)
   ============================================================ */
@media (max-width: 767px) {
  .feature-tabs { display: none; }
  #modeAsk .input-row { display: none; }
  .interaction-section { padding-bottom: 80px; }
  .mobile-bottom-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    padding: 8px 10px;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
  }
  .app-footer { padding: 8px 16px 80px; gap: 10px; flex-wrap: wrap; }
  .app-footer a { font-size: 12px; }
}

/* ============================================================
   RESPONSIVE — LANDSCAPE PHONES
   ============================================================ */
@media (max-height: 500px) {
  :root { --topbar-h: 40px; --tabs-h: 36px; }
  .avatar-overlay { width: 44px; bottom: 38px; right: 1px; }
  .whiteboard-section { height: 30vh; min-height: 100px; max-height: 180px; }
  .feature-tab { padding: 8px 10px; font-size: 12px; }
  .mode-header { display: none; }
}

/* ============================================================
   RESPONSIVE — VERY SMALL PHONES (≤380px)
   ============================================================ */
@media (max-width: 380px) {
  .topbar { padding: 4px 6px; }
  .topbar-left { gap: 4px; }
  .logo-text { font-size: 14px; }
  .logo-icon { font-size: 16px; }
  .topbar-right { gap: 1px; }
  .btn-icon { width: 26px; height: 26px; font-size: 12px; }
  .feature-tab { padding: 8px 8px; font-size: 11px; }
  .whiteboard-section { height: 30vh; min-height: 120px; max-height: 200px; padding: 4px; }
  .avatar-overlay { width: 50px; bottom: 36px; right: 1px; }
  .whiteboard-controls { padding: 4px 6px; gap: 4px; }
  .btn-sm { padding: 3px 8px; font-size: 10px; }
  .chat-messages { padding: 6px 6px; }
  .message { padding: 6px 10px; font-size: 15px; max-width: 96%; }
  .chat-input-area { padding: 4px 6px 6px; }
  #chatInput { padding: 8px 10px; font-size: 14px; }
  .btn-send { padding: 8px 12px; font-size: 12px; }
  .mode-header { padding: 4px 8px 0; }
  .mode-header h3 { font-size: 12px; }
  .mode-header p { font-size: 10px; }
  .difficulty-selector { gap: 2px; font-size: 10px; }
  .diff-btn { padding: 2px 8px; font-size: 10px; }
  #modeNotes { padding: 4px 6px; }
  #notesInput { padding: 8px; font-size: 13px; min-height: 80px; }
  .notes-result { font-size: 12px; padding: 4px 0; }
  #modeExam { padding: 4px 6px; }
  .exam-row { gap: 4px; }
  #examTopic { padding: 7px 10px; font-size: 13px; min-width: 80px; }
  .exam-timer { font-size: 11px; }
  .exam-result { font-size: 12px; }
  .mobile-bottom-bar { padding: 6px 6px; gap: 4px; }
  .mobile-input-wrap { gap: 3px; padding: 2px 2px 2px 10px; }
  #mobileInput { padding: 6px 8px; font-size: 13px; }
  .mobile-icon-btn { width: 32px; height: 32px; font-size: 15px; }
  .fab-btn { width: 36px; height: 36px; font-size: 20px; }
  .fab-menu { left: 6px; bottom: 66px; }
}

.file-input-hidden {
  position: fixed;
  left: -9999px;
  top: -9999px;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
