/* ============================================================
   FLASHCARD SCREEN
============================================================ */
.session-header {
  background: white;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.progress-dots {
  display: flex;
  gap: 6px;
}

.progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.3s;
}

.progress-dot.done { background: var(--ss-green); }
.progress-dot.current { background: var(--ss-blue); }

.flashcard-area {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.flashcard {
  background: white;
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow-lg);
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: transform 0.3s ease;
}

.flashcard-tag {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

.flashcard-question {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--text);
}

.flashcard-answer {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 2px solid var(--bg);
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 600;
  line-height: 1.6;
}

.flip-hint {
  text-align: center;
  font-size: 13px;
  color: var(--text-light);
  font-weight: 600;
}

.grade-buttons {
  display: flex;
  gap: 10px;
}

.ai-mode-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  background: white;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.toggle-switch input { display: none; }

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 12px;
  transition: background 0.2s;
}

.toggle-track.on { background: var(--ss-green); }

.toggle-thumb {
  position: absolute;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.toggle-thumb.on { transform: translateX(20px); }

.ai-answer-input {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.ai-feedback {
  background: #F0FDF9;
  border-left: 4px solid var(--ss-green);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  font-weight: 600;
  animation: slideUp 0.3s ease;
}

/* ============================================================
   FULL LEARNING SESSION
============================================================ */
.phase-bar {
  display: flex;
  background: white;
  border-bottom: 1px solid var(--border);
}

.phase-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-light);
  position: relative;
}

.phase-item.active { color: var(--ss-blue); }
.phase-item.done { color: var(--ss-green); }

.phase-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
}

.phase-item.active .phase-dot { background: var(--ss-blue); color: white; }
.phase-item.done .phase-dot { background: var(--ss-green); color: white; }

.timer-badge {
  background: var(--bg-dark);
  color: white;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.timer-badge.warning { background: var(--ss-red); animation: pulse 1s ease infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.ko-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
}

.ko-row {
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.4;
  background: white;
  border-radius: 0;
}

.ko-row:nth-child(odd) { background: #F9FAFB; }
.ko-q { font-weight: 700; color: var(--text); }
.ko-a { color: var(--text-secondary); font-weight: 600; }

.mcq-option {
  background: white;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s;
  text-align: left;
  font-family: var(--font);
  width: 100%;
  color: var(--text);
}

.mcq-option:hover { border-color: var(--ss-blue); background: #F0F6FF; }
.mcq-option.correct { border-color: var(--ss-green); background: #DCFCE7; color: #15803D; }
.mcq-option.wrong { border-color: var(--ss-red); background: #FEE2E2; color: #991B1B; }

.transition-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  background: linear-gradient(135deg, #F0FDF9 0%, #EFF6FF 100%);
}

.transition-emoji { font-size: 72px; margin-bottom: 20px; animation: pop 0.5s ease; }
.transition-title { font-size: 28px; font-weight: 900; color: var(--text); margin-bottom: 12px; }
.transition-sub { font-size: 16px; color: var(--text-secondary); font-weight: 600; line-height: 1.5; }

.end-screen {
  flex: 1;
  padding: 24px 20px 100px;
  overflow-y: auto;
}

.end-hero {
  background: linear-gradient(135deg, #00C896, #4F8EF7);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  color: white;
  text-align: center;
  margin-bottom: 20px;
}

.end-emoji { font-size: 64px; margin-bottom: 12px; }
.end-title { font-size: 28px; font-weight: 900; margin-bottom: 4px; }
.end-sub { font-size: 15px; opacity: 0.9; font-weight: 600; }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-number { font-size: 28px; font-weight: 900; }
.stat-label { font-size: 12px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }

/* ============================================================
   TEACHER DASHBOARD
============================================================ */
.dashboard-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 0 20px;
}

.rag-grid {
  overflow-x: auto;
}

.rag-table {
  border-collapse: collapse;
  font-size: 12px;
  min-width: 500px;
}

.rag-table th {
  padding: 8px 10px;
  background: var(--bg);
  font-weight: 700;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.rag-table td {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  font-weight: 600;
}

.rag-cell {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  margin: 0 auto;
}

.rag-r { background: #FEE2E2; color: #991B1B; }
.rag-a { background: #FEF3C7; color: #B45309; }
.rag-g { background: #DCFCE7; color: #15803D; }
.rag-none { background: var(--bg); color: var(--text-light); }

/* ============================================================
   AI TUTOR SCREEN
============================================================ */
.tutor-chat {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 140px;
}

.chat-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  animation: slideUp 0.2s ease;
}

.chat-bubble.user {
  background: var(--ss-blue);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-bubble.ai {
  background: white;
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
}

.chat-bubble.ai.loading {
  display: flex;
  gap: 4px;
  align-items: center;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--text-light);
  border-radius: 50%;
  animation: typingBounce 1.2s ease infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
  40% { transform: scale(1.1); opacity: 1; }
}

.tutor-input-bar {
  position: fixed;
  bottom: env(safe-area-inset-bottom, 0px);
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.tutor-input {
  flex: 1;
  border: 2px solid var(--border);
  border-radius: 20px;
  padding: 10px 16px;
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  resize: none;
  max-height: 100px;
  overflow-y: auto;
}
.tutor-input:focus { border-color: var(--ss-purple); }

.tutor-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--ss-purple);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s;
}
.tutor-send-btn:hover { transform: scale(1.08); }

.suggested-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px 12px;
}

.suggested-q {
  background: white;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.suggested-q:hover { border-color: var(--ss-purple); color: var(--ss-purple); }

/* ============================================================
   PARENT PORTAL
============================================================ */
.portal-overlay {
  position: fixed;
  inset: 0;
  background: white;
  z-index: 200;
  display: flex;
  flex-direction: column;
}

.portal-header {
  background: linear-gradient(135deg, #8B5CF6, #4F8EF7);
  padding: 40px 24px 24px;
  color: white;
}

.portal-tabs {
  display: flex;
  background: white;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.portal-tab {
  flex-shrink: 0;
  padding: 14px 20px;
  border-bottom: 3px solid transparent;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-secondary);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font);
}

.portal-tab.active { color: var(--ss-purple); border-bottom-color: var(--ss-purple); }

/* ============================================================
   PROFILE SCREEN
============================================================ */
.profile-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px 20px;
}

.profile-hero {
  background: linear-gradient(135deg, var(--ss-green), var(--ss-blue));
  border-radius: var(--radius-lg);
  padding: 24px;
  color: white;
  text-align: center;
  margin-bottom: 20px;
}

.avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin: 0 auto 12px;
}

.badge-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 12px;
  place-items: center;
}

.badge-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.badge-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}

.badge-icon.earned { background: #FEF3C7; }
.badge-label { font-size: 10px; font-weight: 700; color: var(--text-secondary); text-align: center; line-height: 1.3; }

@media (max-width: 380px) {
  .badge-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================================
   KNOWLEDGE ORGANISER
============================================================ */
.ko-screen {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 20px;
}

.ko-header {
  padding: 20px;
  background: white;
  border-bottom: 1px solid var(--border);
}

.ko-content {
  padding: 16px 20px;
}

.ko-topic-block {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.ko-topic-header {
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 800;
  color: white;
}

.ko-item {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--border);
}

.ko-item-q {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  border-right: 1px solid var(--border);
  background: #FAFAFA;
}

.ko-item-a {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ============================================================
   MODALS
============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  /* Was 300 — below the sliding student panel's own backdrop (900/901), so a modal opened
     from within an open panel (e.g. the reset-progress confirmation) had its clicks silently
     intercepted by the panel's backdrop instead of reaching the modal. Found via a real
     end-to-end test, not a pre-existing showModal() caller — nothing else opened a modal
     from inside the panel before. Raised above the panel, still below toasts/critical overlays. */
  z-index: 950;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: white;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 20px;
}

.modal-title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 16px;
}

