:root {
  --purple: #9333ea;
  --purple-light: #a855f7;
  --purple-dark: #7e22ce;
  --purple-bg: #f3e8ff;
  --teal: #30D5C8;
  --teal-dark: #14b8a6;
  --green: #22c55e;
  --orange: #f59e0b;
  --red: #ef4444;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #fff;
  color: var(--gray-800);
  min-height: 100dvh;
  line-height: 1.6;
  overflow: hidden;
}

/* Utility */
.hidden { display: none !important; }

/* ===== NAV ===== */
.app-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--gray-200);
  z-index: 100;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-left img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.nav-left span {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
}

.nav-back {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--purple);
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 6px;
}

.nav-back:hover { background: var(--purple-bg); }

.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-streak {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--orange);
}

.nav-xp {
  font-size: 12px;
  font-weight: 600;
  color: var(--purple);
  background: var(--purple-bg);
  padding: 3px 10px;
  border-radius: 100px;
}

.sign-out-btn {
  font-size: 13px;
  color: var(--gray-500);
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  padding: 4px 8px;
}
.sign-out-btn:hover { color: var(--gray-800); }

/* ===== MAIN CONTENT ===== */
.app-content {
  margin-top: 56px;
  height: calc(100dvh - 56px);
  overflow-y: auto;
}

/* ===== VIEWS ===== */
.view {
  display: none;
  height: 100%;
}
.view.active {
  display: flex;
  flex-direction: column;
}

/* ===== SIGN-IN VIEW ===== */
.sign-in-view {
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #f3e8ff 0%, #fff 60%);
  padding: 24px;
}

.sign-in-card {
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.sign-in-logo {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  margin-bottom: 16px;
}

.sign-in-card h1 {
  font-size: 28px;
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: 8px;
}

.sign-in-card .subtitle {
  font-size: 15px;
  color: var(--gray-500);
  margin-bottom: 32px;
}

.sign-in-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.sign-in-form label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
}

.input-field {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  font-family: inherit;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s;
}

.input-field:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(147,51,234,0.1);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--purple);
  color: #fff;
}
.btn-primary:hover { background: var(--purple-dark); }
.btn-primary:disabled {
  background: var(--gray-300);
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}
.btn-secondary:hover { background: var(--gray-200); }

.btn-outline {
  background: transparent;
  color: var(--purple);
  border: 1.5px solid var(--purple);
}
.btn-outline:hover { background: var(--purple-bg); }

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

.btn-block { width: 100%; }

.turnstile-box {
  display: flex;
  justify-content: center;
  margin: 8px 0;
}

.sign-in-check-email {
  padding: 24px;
  background: var(--gray-50);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
}

.sign-in-check-email h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.sign-in-check-email p {
  font-size: 14px;
  color: var(--gray-500);
}

.error-msg {
  font-size: 13px;
  color: var(--red);
  margin-top: 4px;
}

/* ===== HOME VIEW ===== */
.home-view {
  overflow-y: auto;
}

.home-scroll {
  padding: 20px 16px 100px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.garden-canvas-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  background: linear-gradient(180deg, #e0f2fe 0%, #bbf7d0 70%, #86efac 100%);
  position: relative;
}

.garden-canvas-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.streak-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 100px;
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  gap: 6px;
}

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.quick-action {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}

.quick-action:hover {
  border-color: var(--purple);
  box-shadow: var(--shadow-md);
}

.quick-action .icon {
  font-size: 24px;
  margin-bottom: 8px;
}

.quick-action .title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-900);
}

.quick-action .desc {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 2px;
}

/* ===== BACKPACK VIEW ===== */
.backpack-view {
  overflow-y: auto;
}

.backpack-scroll {
  padding: 20px 16px 100px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 20px;
  background: var(--gray-50);
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--purple);
  background: var(--purple-bg);
}

.upload-zone .icon { font-size: 32px; margin-bottom: 8px; }
.upload-zone .title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-700);
}
.upload-zone .hint {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 4px;
}

.upload-zone input[type="file"] { display: none; }

.upload-progress {
  margin-bottom: 20px;
}

.progress-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--purple);
  border-radius: 3px;
  transition: width 0.3s;
  width: 0%;
}

.book-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.book-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
}

.book-card:hover {
  border-color: var(--purple);
  box-shadow: var(--shadow);
}

.book-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--purple-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.book-info {
  flex: 1;
  min-width: 0;
}

.book-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-meta {
  font-size: 12px;
  color: var(--gray-500);
  display: flex;
  gap: 8px;
  align-items: center;
}

.book-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 100px;
  font-weight: 500;
}

.book-badge.classroom {
  background: rgba(48, 213, 200, 0.15);
  color: var(--teal-dark);
}

.book-chevron {
  color: var(--gray-400);
  font-size: 18px;
}

.how-it-works {
  margin-top: 24px;
  padding: 20px;
  background: var(--gray-50);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
}

.how-it-works h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 12px;
}

.step {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.step-num {
  width: 24px;
  height: 24px;
  background: var(--purple);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-text {
  font-size: 13px;
  color: var(--gray-600);
  line-height: 1.5;
}

.join-class-section {
  margin-top: 20px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
}

.join-class-section h3 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
}

.join-class-row {
  display: flex;
  gap: 8px;
}

.join-class-row input {
  flex: 1;
}

/* ===== PAGE GRID VIEW ===== */
.page-grid-view {
  overflow-y: auto;
}

.page-grid-scroll {
  padding: 20px 16px 100px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.page-grid-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.page-grid-header h2 {
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.study-btn {
  flex-shrink: 0;
}

.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.page-thumb {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--gray-200);
  cursor: pointer;
  transition: all 0.15s;
  background: var(--gray-100);
}

.page-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.page-thumb.selected {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(147,51,234,0.25);
}

.page-thumb.covered::after {
  content: '';
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  background: var(--green);
  border-radius: 50%;
  border: 2px solid #fff;
}

.page-num {
  position: absolute;
  bottom: 4px;
  left: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: rgba(0,0,0,0.5);
  padding: 1px 6px;
  border-radius: 4px;
}

.select-all-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.select-all-row span {
  font-size: 13px;
  color: var(--gray-500);
}

/* ===== TUTOR VIEW ===== */
.tutor-view {
  flex-direction: row;
  height: 100%;
  overflow: hidden;
}

.pdf-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--gray-100);
  border-right: 1px solid var(--gray-200);
  min-width: 0;
}

.pdf-canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 8px;
}

.pdf-canvas-wrap canvas {
  max-width: 100%;
  max-height: 100%;
  box-shadow: var(--shadow-lg);
  background: #fff;
}

.pdf-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px;
  background: #fff;
  border-top: 1px solid var(--gray-200);
}

.pdf-nav button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--gray-200);
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.pdf-nav button:hover { background: var(--gray-100); }
.pdf-nav button:disabled { opacity: 0.3; cursor: not-allowed; }

.pdf-nav span {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
}

.chat-panel {
  width: 420px;
  display: flex;
  flex-direction: column;
  background: #fff;
  min-width: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-msg {
  max-width: 90%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

.chat-msg.assistant {
  align-self: flex-start;
  background: var(--gray-100);
  border-bottom-left-radius: 4px;
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--purple);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg.streaming {
  background: var(--gray-50);
}

.chat-msg img {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 8px;
}

/* MC / Interactive question cards */
.chat-mc-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  align-self: flex-start;
  max-width: 95%;
}

.chat-mc-card .mc-question {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  line-height: 1.5;
}

.mc-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  margin-bottom: 6px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.4;
}

.mc-option:hover { border-color: var(--purple); background: var(--purple-bg); }
.mc-option.correct { border-color: var(--green); background: rgba(34,197,94,0.08); }
.mc-option.incorrect { border-color: var(--red); background: rgba(239,68,68,0.08); }
.mc-option.disabled { pointer-events: none; opacity: 0.7; }

.mc-feedback {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
}

.mc-feedback.correct {
  background: rgba(34,197,94,0.08);
  color: var(--green);
}

.mc-feedback.incorrect {
  background: rgba(239,68,68,0.08);
  color: var(--red);
}

/* Drag-drop */
.chat-dd-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  align-self: flex-start;
  max-width: 95%;
}

.dd-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.dd-chip {
  padding: 6px 14px;
  background: var(--purple-bg);
  color: var(--purple);
  font-size: 13px;
  font-weight: 600;
  border-radius: 100px;
  cursor: grab;
  user-select: none;
  transition: all 0.15s;
}

.dd-chip:active { cursor: grabbing; }
.dd-chip.placed { opacity: 0.4; pointer-events: none; }

.dd-slots {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dd-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1.5px dashed var(--gray-300);
  border-radius: var(--radius-sm);
  min-height: 40px;
  font-size: 13px;
  color: var(--gray-500);
  transition: all 0.15s;
}

.dd-slot.filled {
  border-style: solid;
  border-color: var(--purple);
  color: var(--gray-800);
}

/* Fill-blank */
.chat-fb-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  align-self: flex-start;
  max-width: 95%;
}

.fb-sentence {
  font-size: 14px;
  line-height: 2;
}

.fb-blank {
  display: inline-block;
  min-width: 80px;
  border-bottom: 2px solid var(--purple);
  padding: 2px 4px;
  font-weight: 600;
  text-align: center;
}

.fb-input {
  display: inline-block;
  width: 100px;
  padding: 4px 8px;
  border: 1.5px solid var(--gray-300);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  text-align: center;
  outline: none;
}

.fb-input:focus {
  border-color: var(--purple);
}

/* Chat input */
.chat-input-wrap {
  padding: 12px 16px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: #fff;
}

.chat-input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 8px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: 20px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.5;
}

.chat-input:focus { border-color: var(--purple); }

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--purple);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.chat-send-btn:hover { background: var(--purple-dark); }
.chat-send-btn:disabled { background: var(--gray-300); cursor: not-allowed; }

/* ===== WARMUP VIEW ===== */
.warmup-view {
  overflow-y: auto;
}

.warmup-scroll {
  padding: 20px 16px 100px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.warmup-setup {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
}

.form-group select {
  padding: 10px 14px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: #fff;
}

.form-group select:focus { border-color: var(--purple); }

.warmup-problems {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.warmup-problem-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
}

.warmup-problem-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--purple);
  margin-bottom: 8px;
}

.warmup-problem-q {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
  line-height: 1.5;
}

.warmup-score {
  text-align: center;
  padding: 24px;
  background: var(--gray-50);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.warmup-score .score-num {
  font-size: 40px;
  font-weight: 800;
  color: var(--purple);
}

.warmup-score .score-label {
  font-size: 14px;
  color: var(--gray-500);
}

/* Hint/Explanation toggle */
.hint-toggle {
  font-size: 13px;
  color: var(--purple);
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  font-weight: 500;
  padding: 4px 0;
  margin-top: 8px;
}

.hint-text {
  font-size: 13px;
  color: var(--gray-600);
  background: var(--gray-50);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-top: 6px;
  line-height: 1.5;
}

/* Worked example */
.worked-example {
  margin-top: 10px;
  padding: 12px;
  background: rgba(147,51,234,0.04);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--purple);
}

.worked-example .we-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--purple);
  margin-bottom: 6px;
}

.worked-example .we-problem {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}

.worked-example .we-steps {
  font-size: 13px;
  color: var(--gray-600);
  line-height: 1.6;
  list-style: decimal inside;
}

.worked-example .we-steps li {
  margin-bottom: 4px;
}

/* ===== PLAN VIEW ===== */
.plan-view {
  overflow-y: auto;
}

.plan-scroll {
  padding: 20px 16px 100px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.plan-day-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.15s;
}

.plan-day-card:hover {
  border-color: var(--purple);
  box-shadow: var(--shadow);
}

.plan-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.plan-day-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--purple);
}

.plan-day-title {
  font-size: 15px;
  font-weight: 600;
  margin-top: 4px;
}

.plan-day-summary {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 4px;
  line-height: 1.5;
}

.plan-day-status {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 100px;
}

.plan-day-status.done {
  background: rgba(34,197,94,0.1);
  color: var(--green);
}

.plan-day-status.current {
  background: var(--purple-bg);
  color: var(--purple);
}

/* ===== GARDEN VIEW ===== */
.garden-view {
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #e0f2fe 0%, #bbf7d0 70%, #86efac 100%);
}

.garden-full-canvas {
  width: 100%;
  height: 100%;
}

/* ===== LOADING ===== */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  flex-direction: column;
  gap: 12px;
}

.loading-overlay span {
  font-size: 14px;
  color: var(--gray-500);
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-900);
  color: #fff;
  padding: 10px 20px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.toast.show { opacity: 1; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 40px 24px;
  color: var(--gray-400);
}

.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state .title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 4px;
}
.empty-state .desc { font-size: 13px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .tutor-view {
    flex-direction: column;
  }

  .pdf-panel {
    flex: none;
    height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--gray-200);
  }

  .chat-panel {
    width: 100%;
    flex: 1;
    min-height: 0;
  }

  .page-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .pdf-panel {
    height: 35vh;
  }

  .chat-panel {
    width: 100%;
  }
}

/* ===== BOTTOM TAB BAR ===== */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  font-weight: 500;
  color: var(--gray-400);
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  padding: 4px 12px;
  transition: color 0.15s;
}

.tab-item.active { color: var(--purple); }

.tab-item .tab-icon {
  font-size: 22px;
  line-height: 1;
}

/* Audio playback indicator */
.audio-playing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--purple);
  margin-top: 6px;
}

.audio-bars {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 14px;
}

.audio-bars span {
  width: 3px;
  background: var(--purple);
  border-radius: 1px;
  animation: audioBar 0.6s ease-in-out infinite alternate;
}

.audio-bars span:nth-child(2) { animation-delay: 0.15s; }
.audio-bars span:nth-child(3) { animation-delay: 0.3s; }

@keyframes audioBar {
  from { height: 4px; }
  to { height: 14px; }
}

/* ===== ONBOARDING ===== */
.onboarding-view {
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #f3e8ff 0%, #fff 60%);
  padding: 24px;
}

.onboarding-scroll {
  width: 100%;
  max-width: 440px;
}

.onboarding-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 32px 24px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.onboarding-step-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
}

.onboarding-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gray-300);
}

.onboarding-dot.active { background: var(--purple); }
.onboarding-dot.done { background: var(--green); }

.onboarding-card h2 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 8px;
}

.onboarding-card .subtitle {
  font-size: 14px;
  color: var(--gray-500);
  margin-bottom: 24px;
}

.onboarding-card .form-group {
  text-align: left;
  margin-bottom: 16px;
}

.subject-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 16px 0;
}

.subject-chip {
  padding: 8px 18px;
  border: 1.5px solid var(--gray-300);
  border-radius: 100px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
  background: #fff;
  font-family: inherit;
}

.subject-chip:hover { border-color: var(--purple); }
.subject-chip.selected {
  background: var(--purple);
  color: #fff;
  border-color: var(--purple);
}

.onboarding-nav {
  display: flex;
  gap: 8px;
  margin-top: 24px;
}

.onboarding-nav .btn { flex: 1; }

/* ===== SETTINGS VIEW ===== */
.settings-view {
  overflow-y: auto;
}

.settings-scroll {
  padding: 20px 16px 100px;
  max-width: 500px;
  margin: 0 auto;
  width: 100%;
}

.settings-section {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.settings-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.settings-field:last-child { margin-bottom: 0; }

.settings-field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
}

.chip-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-picker .subject-chip {
  padding: 5px 14px;
  font-size: 13px;
}

/* LaTeX / KaTeX rendering */
.katex { font-size: 1em !important; }
.katex-display { margin: 8px 0 !important; }
