/* ============================================================
   STUDY HISTORY
============================================================ */
.history-item {
  background: white;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.history-grade {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
}

.history-grade-again { background: #FEE2E2; color: #991B1B; }
.history-grade-hard { background: #FEF3C7; color: #B45309; }
.history-grade-good { background: #DBEAFE; color: #1D4ED8; }
.history-grade-easy { background: #DCFCE7; color: #15803D; }

/* ============================================================
   LOADING / SPINNER
============================================================ */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--ss-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-secondary);
  font-weight: 600;
}

/* ============================================================
   RESPONSIVE / DESKTOP WRAPPER
============================================================ */

/* ============================================================
   COMING SOON BADGE
============================================================ */
.coming-soon {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #FEF3C7;
  color: #B45309;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Topic unlock progress */
.topic-progress {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}

.topic-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.topic-progress-name {
  font-size: 14px;
  font-weight: 700;
}

.topic-progress-pct {
  font-size: 13px;
  font-weight: 800;
}

.topic-progress-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
}

.topic-progress-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.6s ease;
}

/* Exam question dropdown */
.exam-q-dropdown {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.exam-q-toggle {
  padding: 12px 16px;
  background: #F9FAFB;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.exam-q-body {
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  border-top: 1px solid var(--border);
}

.mark-scheme {
  margin-top: 8px;
  padding: 10px;
  background: #F0FDF9;
  border-radius: 8px;
  font-size: 12px;
  color: #15803D;
  font-weight: 600;
  line-height: 1.5;
}

/* ============================================================
   PLACEHOLDER / PLACEHOLDER CONTENT NOTICE
============================================================ */
.placeholder-notice {
  background: #FEF3C7;
  border: 1px solid #FCD34D;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 700;
  color: #B45309;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── V1 FLASHCARD STYLES ── */
.ans-list { list-style: none; padding: 0; margin: 12px 0 0 0; }
.ans-list li { padding: 8px 12px 8px 22px; margin-bottom: 6px; background: #F0FBF7; border-radius: 10px; font-size: 14px; font-weight: 700; color: #1a1a2e; border-left: 3px solid #00C896; line-height: 1.5; position: relative; }
.ans-list li strong { color: #00C896; }
.reveal-btn { width: 100%; padding: 16px; background: linear-gradient(135deg, #2D6A4F, #00C896); color: white; border: none; border-radius: 14px; font-size: 15px; font-weight: 800; cursor: pointer; font-family: inherit; margin-top: 8px; }
.card-hint { background: #FFF8E1; border-radius: 10px; padding: 10px 14px; margin-top: 8px; font-size: 13px; font-weight: 700; color: #8B6914; border-left: 3px solid #FFB300; }
.card-hint::before { content: '💡 '; }
.exam-reveal-btn { width: 100%; padding: 12px 16px; background: #EEF2FF; border: 2px solid #818CF8; border-radius: 12px; cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 800; color: var(--gm-forest); display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.exam-card { display: none; background: #F8FAFF; border-radius: 12px; padding: 16px; margin-top: 8px; border: 2px solid #C7D2FE; }
.exam-card.open { display: block; }
.exam-wow { font-size: 13px; font-weight: 900; color: var(--gm-forest); margin-bottom: 4px; }
.exam-q-box { background: white; border-radius: 10px; padding: 12px; margin: 8px 0; border: 1px solid #C7D2FE; font-size: 14px; font-weight: 700; font-style: italic; color: #1a1a2e; line-height: 1.5; }
.exam-marks-pill { display: inline-block; background: var(--gm-forest); color: white; border-radius: 6px; padding: 2px 10px; font-size: 11px; font-weight: 800; margin-top: 6px; }
.exam-ms-lbl { font-size: 11px; font-weight: 800; color: var(--gm-forest); text-transform: uppercase; margin: 10px 0 6px; }
.exam-ms-opt { display: flex; align-items: flex-start; gap: 6px; padding: 4px 0; font-size: 13px; font-weight: 700; color: #1a1a2e; }
.tick { color: #00C896; font-size: 14px; flex-shrink: 0; }
.c-tier { font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: 20px; }
.c-tier.h { background: #EEF2FF; color: var(--gm-forest); }
.c-tier.f { background: #F0FBF7; color: #00C896; }
.ans-lbl { font-size: 12px; font-weight: 800; color: #00C896; text-transform: uppercase; margin-bottom: 4px; }
.rate-btn { flex: 1; padding: 12px 4px; border: none; border-radius: 12px; font-family: inherit; font-size: 13px; font-weight: 800; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.rate-btn.again { background: #FEE2E2; color: #DC2626; }
.rate-btn.hard { background: #FEF3C7; color: #D97706; }
.rate-btn.good { background: #DCFCE7; color: #16A34A; }
.rate-btn.easy { background: #EEF2FF; color: var(--gm-forest); }
.rate-btn .em { font-size: 18px; }
.rating-grid { display: flex; gap: 8px; margin: 12px 0; }
.rating-prompt { font-size: 13px; font-weight: 800; color: var(--text-secondary); text-align: center; margin-bottom: 4px; }

.toggle-switch { position: relative; width: 48px; height: 26px; flex-shrink: 0; }
.toggle-track { width: 48px; height: 26px; border-radius: 13px; background: #E2E8F0; transition: background .2s; }
.toggle-track.on { background: #00C896; }
.toggle-thumb { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: white; box-shadow: 0 1px 4px rgba(0,0,0,0.2); transition: left .2s; }
.toggle-thumb.on { left: 25px; }

/* ── PWA Standalone: push overlays below notch/island ── */
@media (display-mode: standalone) {
  .portal-overlay { padding-top: env(safe-area-inset-top, 0px); }
  .parent-sticky-hdr { top: env(safe-area-inset-top, 0px); }
}
/* ── Parent portal sticky top section ── */
.parent-sticky-hdr { position: sticky; top: 0; z-index: 200; }

/* ── AI Tutor Chat Widget ── */
#ai-chat-widget {
  position: fixed !important;
  bottom: 0 !important;
  right: 24px;
  width: 500px;
  background: #fff;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
  z-index: 9999;
  font-family: Nunito, sans-serif;
  overflow: hidden;
  transition: box-shadow 0.3s ease;
}
#ai-chat-header {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  padding: 14px 18px;
  border-radius: 16px 16px 0 0;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#ai-chat-header .chat-title {
  font-size: 15px;
  font-weight: 800;
  font-family: Nunito, sans-serif;
}
#ai-chat-body {
  display: flex;
  flex-direction: column;
  height: 550px;
}
/* The widget had no mobile-specific rules at all -- a fixed 500px width
   pinned to bottom:0 sat directly on top of .v3-bottom-nav (also bottom:0)
   on every screen under 1024px where the widget isn't explicitly hidden,
   obscuring the nav bar underneath it (z-index 9999 vs 200). */
@media (max-width: 1023px) {
  #ai-chat-widget {
    left: 12px;
    right: 12px;
    width: auto;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 8px) !important;
  }
  #ai-chat-body {
    height: min(550px, 60vh);
  }
}
#ai-chat-widget.closed #ai-chat-body { display: none; }
#ai-chat-widget.hidden { display: none; }
#ai-chat-messages {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ai-msg-user {
  background: #6366f1;
  color: #fff;
  padding: 10px 14px;
  border-radius: 14px;
  border-bottom-right-radius: 4px;
  font-size: 0.88rem;
  font-weight: 600;
  max-width: 80%;
  align-self: flex-end;
  line-height: 1.5;
  font-family: Nunito, sans-serif;
  word-break: break-word;
  overflow-wrap: break-word;
}
.ai-msg-ai {
  background: #fff;
  color: #1e293b;
  padding: 10px 14px;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  font-size: 0.88rem;
  font-weight: 600;
  max-width: 80%;
  align-self: flex-start;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  line-height: 1.5;
  font-family: Nunito, sans-serif;
  word-break: break-word;
  overflow-wrap: break-word;
}
#ai-chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
}
#ai-chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.88rem;
  font-family: Nunito, sans-serif;
  font-weight: 600;
  outline: none;
}
#ai-chat-input-area button {
  background: #6366f1;
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  font-family: Nunito, sans-serif;
}
@keyframes confettiFall {
  0%   { transform: translateY(-10px) rotate(var(--rot,0deg)) scale(1); opacity:1; }
  100% { transform: translateY(110vh) rotate(calc(var(--rot,0deg) + 360deg)) scale(0.5); opacity:0; }
}
@keyframes streakPulse {
  0%,100% { box-shadow:0 0 0 0 rgba(220,38,38,0.5); }
  50%      { box-shadow:0 0 0 10px rgba(220,38,38,0); }
}
@keyframes levelUpEntry {
  0%   { transform:scale(0.6); opacity:0; }
  70%  { transform:scale(1.08); opacity:1; }
  100% { transform:scale(1); }
}
@keyframes cardRevealIn {
  from { transform:perspective(600px) rotateX(-90deg); opacity:0; }
  to   { transform:perspective(600px) rotateX(0deg);   opacity:1; }
}
@keyframes slideUpFade {
  from { transform:translateY(20px); opacity:0; }
  to   { transform:translateY(0);    opacity:1; }
}

/* ── Long Term Progress Tracker ─────────────────────────────────────────────── */
.pt-wrap { padding-bottom: 100px; }
.pt-legend { padding: 10px 16px; font-size: 12px; font-weight: 700; color: #64748B; border-bottom: 1px solid #E2E8F0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pt-pip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 800; }
.pt-entry { }
.pt-row { display: flex; align-items: center; gap: 8px; padding: 12px 16px; cursor: pointer; user-select: none; transition: background .1s; border-bottom: 1px solid #E2E8F0; }
.pt-row:active { opacity: .8; }
.pt-chevron { font-size: 10px; color: #94A3B8; flex-shrink: 0; transition: transform .18s; display: inline-block; }
.pt-entry.pt-open > .pt-row .pt-chevron { transform: rotate(90deg); }
.pt-entry > .pt-children { display: none; }
.pt-entry.pt-open > .pt-children { display: block; }
/* Level 1 — Subject */
.pt-subject-row { background: #EFF6FF; font-size: 15px; font-weight: 800; color: #1E3A5F; border-top: 2px solid #BFDBFE; }
/* Level 2 — Topic */
.pt-topic-row { background: #F8FAFC; font-size: 14px; font-weight: 700; color: #334155; padding-left: 32px !important; }
/* Level 3 — Card */
.pt-card-item { font-size: 13px; font-weight: 600; line-height: 1.45; padding: 8px 16px 8px 48px; border-bottom: 1px solid #F1F5F9; color: #1E293B; background: #FFFFFF; }
.pt-card-item.pt-mem  { background: #64D870; color: #14532D; }
.pt-card-item.pt-mas  { background: #007D0C; color: #FFFFFF; }
/* Stat badges */
.pt-counts { margin-left: auto; display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.pt-badge { font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 20px; white-space: nowrap; }
.pt-badge-m { background: #DCFCE7; color: #15803D; }
.pt-badge-s { background: #14532D; color: #FFFFFF; }
.pt-badge-t { font-size: 11px; font-weight: 600; color: #94A3B8; }
/* ── Exam board selector ───────────────────────────────────────────────────── */
.board-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.board-opt { padding: 10px 12px; border-radius: 10px; border: 1.5px solid #E2E8F0; background: white; font-size: 13px; font-weight: 800; cursor: pointer; text-align: center; color: #0F172A; transition: border-color .15s, background .15s; }
.board-opt.active { border-color: var(--gm-forest); background: #EEF2FF; color: var(--gm-forest); }
.board-opt.coming { opacity: 0.42; cursor: not-allowed; pointer-events: none; color: #64748B; }
.coming-soon-tag { display: block; font-size: 10px; font-weight: 700; color: #94A3B8; margin-top: 2px; letter-spacing: 0.03em; }
/* ── Parent Insight + Feed ─────────────────────────────────────────────────── */
.parent-insight-bg { background: #F5F0E8; min-height: 100vh; }
.insight-tip-card { background: #FDF6EC; border: 1.5px solid #E8D5B0; border-radius: 20px; padding: 24px 20px; }
.insight-tip-lbl { background: linear-gradient(135deg,var(--gm-forest),var(--gm-forest)); color: white; border-radius: 10px; padding: 5px 12px; font-size: 10px; font-weight: 800; letter-spacing: 0.1em; display: inline-block; margin-bottom: 12px; }
.feed-card { background: #F5F0E8; border-radius: 20px; overflow: hidden; margin-bottom: 16px; box-shadow: 0 2px 12px rgba(0,0,0,0.07); }
.feed-hdr-purple { background: linear-gradient(135deg,var(--gm-forest),var(--gm-forest)); padding: 10px 20px; font-size: 10px; font-weight: 800; letter-spacing: 0.1em; color: white; text-transform: uppercase; }
.feed-hdr-green { background: linear-gradient(135deg,#16A34A,#15803D); padding: 10px 20px; font-size: 10px; font-weight: 800; letter-spacing: 0.1em; color: white; text-transform: uppercase; }
.feed-card-body { padding: 16px 20px 6px; }
.feed-card-headline { font-size: 16px; font-weight: 900; color: #1E1409; margin-bottom: 8px; line-height: 1.3; }
.feed-card-text { font-size: 13px; color: #5D4037; font-weight: 600; line-height: 1.6; }
.feed-card-actions { display: flex; gap: 8px; padding: 10px 20px 16px; }
.feed-btn { flex: 1; padding: 8px; border-radius: 8px; border: 1.5px solid #C4A882; background: transparent; font-size: 12px; font-weight: 800; cursor: pointer; font-family: inherit; color: #5D4037; transition: background .15s; }
.feed-btn:hover { background: rgba(0,0,0,0.05); }
.feed-btn.saved { border-color: var(--gm-forest); color: var(--gm-forest); }
.insight-badge { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #EF4444; margin-left: 5px; vertical-align: middle; position: relative; top: -1px; }
/* ── Student StudyCoach ────────────────────────────────────────────────── */
.studycoach-screen { min-height: 100vh; background: #F0FDF4; padding-bottom: 100px; }
.studycoach-hdr { background: linear-gradient(135deg,#16A34A,#15803D); padding: 22px 20px 18px; color: white; display: flex; align-items: center; gap: 12px; }
.gm-journal-ta::placeholder { color: #B8A88A; font-family: 'Caveat', cursive; }

  /* ─── DEEP DIVE / AQA EXAM PAPER ─── */
  .aqa-paper {
    background: white;
    border: 2px solid #1a1a1a;
    border-radius: 4px;
    padding: 20px;
    position: relative;
    font-family: inherit;
  }
  .aqa-paper-header {
    border-bottom: 3px solid #1a1a1a;
    padding-bottom: 10px;
    margin-bottom: 16px;
  }
  .aqa-question-block {
    display: flex;
    gap: 14px;
    margin-bottom: 14px;
  }
  .aqa-q-num {
    font-size: 16px;
    font-weight: 900;
    color: #1a1a1a;
    white-space: nowrap;
    padding-top: 2px;
    min-width: 36px;
  }
  .aqa-q-text {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.6;
    color: #1a1a1a;
    margin-bottom: 6px;
  }
  .aqa-marks-label {
    font-size: 13px;
    font-weight: 800;
    color: #333;
    text-align: right;
  }
  .aqa-answer-area {
    border: 1px solid #ccc;
    border-radius: 2px;
    padding: 8px 12px;
    min-height: 120px;
    background: #FAFAFA;
    margin: 8px 0;
  }
  .aqa-textarea {
    background: transparent;
    border: none;
    border-bottom: 1px solid #ccc;
    border-radius: 0;
    resize: vertical;
    font-size: 14px;
    line-height: 1.8;
  }
  .aqa-mark-scheme {
    background: #F0FDF4;
    border: 1.5px solid #4ADE80;
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
  }
  .aqa-ms-header {
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #15803D;
    margin-bottom: 8px;
  }
  .aqa-ms-body {
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.6;
  }
  /* Gap input for Fill the Gaps */
  .gap-input {
    display: inline-block;
    border: 2px solid var(--ss-blue);
    border-radius: 6px;
    background: #EFF6FF;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    outline: none;
    padding: 3px 8px;
    min-width: 60px;
    vertical-align: middle;
    margin: 0 2px;
    transition: border-color 0.2s, background 0.2s;
  }
  .gap-input.correct { border-color: var(--ss-green); background: #F0FDF4; }
  .gap-input.wrong { border-color: var(--ss-red); background: #FFF0F0; }
  .keyword-chip:active { background: #BBF7D0 !important; transform: scale(0.95); }
/* ── Pin shortcuts ─────────────────────────────────────────────────────────────────────── */
.gm-mobile-pins-row{display:flex;overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch;gap:8px;padding:6px 12px;background:white;border-top:0.5px solid var(--gm-border,#E2E8F0);box-shadow:0 -2px 8px rgba(0,0,0,0.06);flex-shrink:0;}
.gm-mobile-pins-row::-webkit-scrollbar{display:none;}
@media(min-width:1024px){.gm-mobile-pins-row{display:none;}}
.gm-sb-pin-wrap{position:relative;display:flex;justify-content:center;}
.gm-sb-pin-tip{position:absolute;left:56px;top:50%;transform:translateY(-50%);background:white;color:#1A2E22;font-size:11px;font-weight:700;padding:4px 10px;border-radius:8px;white-space:nowrap;pointer-events:none;opacity:0;box-shadow:0 2px 8px rgba(0,0,0,0.15);transition:opacity 0.15s;z-index:200;}
.gm-sb-pin-wrap:hover .gm-sb-pin-tip{opacity:1;}
@keyframes gmPinPulse{0%,100%{opacity:0.5;}50%{opacity:1;}}
.gm-pulse{animation:gmPinPulse 2s ease-in-out infinite;}
.gm-sb-divider{height:1px;background:rgba(255,255,255,0.2);margin:6px 8px;}

/* Phase 3: shared admin table component -- hover/cursor states need real CSS,
   can't be expressed as inline styles like the rest of the admin screens. */
.admin-table{width:100%;border-collapse:collapse;font-size:13px;}
.admin-table th{text-align:left;padding:10px 12px;font-size:11px;font-weight:700;color:#64748B;text-transform:uppercase;letter-spacing:0.02em;border-bottom:1.5px solid #E2E8F0;white-space:nowrap;}
.admin-table th.sortable{cursor:pointer;user-select:none;}
.admin-table th.sortable:hover{color:#1E293B;}
.admin-table td{padding:10px 12px;border-bottom:1px solid #F1F5F9;color:#334155;vertical-align:top;}
.admin-table tbody tr:hover{background:#F8FAFC;}
.admin-table tbody tr:last-child td{border-bottom:none;}
.admin-filter-chip{padding:4px 10px;font-size:11px;}
.admin-details-toggle{cursor:pointer;color:#6366F1;font-weight:700;font-size:11px;}

