/* ============================================================
   StudyHub — Ksanette's GCSE Companion
   Dark theme, modern, engaging for a teenager
   ============================================================ */

:root {
  --bg:          #0a0a18;
  --surface:     #13131f;
  --surface-2:   #1c1c2e;
  --surface-3:   #242438;
  --border:      rgba(255,255,255,0.07);
  --border-2:    rgba(255,255,255,0.12);
  --text:        #e2e8f0;
  --text-muted:  #8892a4;
  --text-dim:    #4a5568;

  --purple:  #7c3aed;
  --purple-l:#a78bfa;
  --cyan:    #06b6d4;
  --green:   #10b981;
  --amber:   #f59e0b;
  --red:     #ef4444;
  --orange:  #f97316;
  --blue:    #3b82f6;

  /* Subject colours */
  --c-eng-lang: #3b82f6;
  --c-eng-lit:  #8b5cf6;
  --c-maths:    #ef4444;
  --c-rs:       #f59e0b;
  --c-geo:      #10b981;
  --c-science:  #06b6d4;
  --c-dt:       #f97316;

  --radius:  12px;
  --radius-lg: 20px;
  --shadow:  0 4px 24px rgba(0,0,0,0.4);
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Poppins', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- App shell ---- */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 800px;
  margin: 0 auto;
}

/* ============================================================
   HEADER / NAV
   ============================================================ */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 60px;
  background: rgba(10,10,24,0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.1rem;
}
.brand-emoji { font-size: 1.3rem; }
.brand-name { background: linear-gradient(135deg, var(--purple-l), var(--cyan)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

.nav-tabs {
  display: flex;
  gap: 4px;
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-family: 'Poppins', sans-serif;
  font-size: 0.7rem;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
}
.nav-tab .tab-icon { font-size: 1.1rem; }
.nav-tab:hover { color: var(--text); background: var(--surface-2); }
.nav-tab.active {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-2);
}
.nav-tab.active .tab-icon { filter: drop-shadow(0 0 6px var(--purple-l)); }

/* ============================================================
   TAB CONTENT
   ============================================================ */
.tab-content {
  display: none;
  flex: 1;
  padding: 20px;
  animation: fadeIn 0.25s ease;
}
.tab-content.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   DASHBOARD
   ============================================================ */
.dash-hero {
  margin-bottom: 20px;
}
.greeting {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}
.date-line {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

/* ---- Countdown Card ---- */
.countdown-card {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4c1d95 100%);
  border: 1px solid rgba(124,58,237,0.35);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow), 0 0 40px rgba(124,58,237,0.15);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.countdown-card::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(167,139,250,0.15), transparent 70%);
  pointer-events: none;
}
.countdown-badge {
  display: inline-block;
  background: rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}
.countdown-subject {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 4px;
}
.countdown-paper {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.7);
  margin-bottom: 18px;
}
.countdown-timer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.timer-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 64px;
}
.timer-num {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(135deg, #fff, rgba(167,139,250,0.9));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.timer-label {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}
.timer-sep {
  font-size: 2rem;
  font-weight: 700;
  color: rgba(255,255,255,0.35);
  margin-top: -10px;
}
.countdown-date {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.6);
}

/* ---- Dashboard sections ---- */
.dash-section { margin-bottom: 28px; }
.dash-section h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text);
}
.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-row h2 { margin-bottom: 0; }

/* ---- Focus grid ---- */
.focus-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.focus-card {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 16px;
  border-left: 4px solid var(--purple);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: default;
}
.focus-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.focus-card-emoji { font-size: 1.5rem; margin-bottom: 8px; }
.focus-card-subject { font-size: 0.9rem; font-weight: 700; margin-bottom: 4px; }
.focus-card-topic { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 8px; line-height: 1.4; }
.focus-card-meta { font-size: 0.7rem; color: var(--text-dim); }
.focus-card-urgency {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 6px;
  background: rgba(255,255,255,0.08);
}

/* ---- Progress overview ---- */
.progress-overview {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.prog-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.prog-emoji { font-size: 1.2rem; width: 24px; text-align: center; }
.prog-name { font-size: 0.82rem; font-weight: 600; width: 130px; flex-shrink: 0; }
.prog-bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--surface-3);
  border-radius: 4px;
  overflow: hidden;
}
.prog-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}
.prog-pct {
  font-size: 0.75rem;
  color: var(--text-muted);
  width: 32px;
  text-align: right;
}

/* ---- Exam timeline ---- */
.exam-timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tl-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 16px;
  border: 1px solid var(--border);
  transition: border-color 0.2s;
}
.tl-item.past { opacity: 0.4; }
.tl-item.next-up { border-color: rgba(124,58,237,0.4); background: rgba(124,58,237,0.05); }
.tl-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tl-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  width: 80px;
  flex-shrink: 0;
}
.tl-subject { font-size: 0.85rem; font-weight: 600; flex: 1; }
.tl-paper { font-size: 0.75rem; color: var(--text-muted); }
.tl-days {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  white-space: nowrap;
}

/* ============================================================
   CHAT
   ============================================================ */
#tab-chat {
  padding: 0;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
}
#tab-chat.active { display: flex; }

.chat-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.kaibot-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}
.kaibot-avatar {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--purple), var(--cyan));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.kaibot-name { font-weight: 700; font-size: 1rem; }
.kaibot-sub { font-size: 0.72rem; color: var(--text-muted); }

/* Chips */
.chips-bar {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.chips-bar::-webkit-scrollbar { display: none; }
.chip {
  display: inline-block;
  white-space: nowrap;
  padding: 6px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 20px;
  font-size: 0.75rem;
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.18s;
  flex-shrink: 0;
}
.chip:hover {
  background: var(--purple);
  border-color: var(--purple);
  color: #fff;
}

/* Messages */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}
.messages-area::-webkit-scrollbar { width: 4px; }
.messages-area::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 2px; }

.message {
  display: flex;
  gap: 10px;
  max-width: 85%;
}
.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.message.bot {
  align-self: flex-start;
}

.msg-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  align-self: flex-end;
}
.message.bot .msg-avatar {
  background: linear-gradient(135deg, var(--purple), var(--cyan));
}
.message.user .msg-avatar {
  background: var(--surface-3);
}

.msg-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.88rem;
  line-height: 1.6;
}
.message.user .msg-bubble {
  background: linear-gradient(135deg, var(--purple), #6d28d9);
  border-bottom-right-radius: 4px;
  color: #fff;
}
.message.bot .msg-bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

/* Markdown rendering in bot messages */
.msg-bubble h2 { font-size: 1rem; font-weight: 700; margin: 12px 0 6px; color: var(--purple-l); }
.msg-bubble h3 { font-size: 0.92rem; font-weight: 700; margin: 10px 0 5px; color: var(--cyan); }
.msg-bubble h4 { font-size: 0.88rem; font-weight: 600; margin: 8px 0 4px; color: var(--amber); }
.msg-bubble p { margin: 4px 0; }
.msg-bubble ul, .msg-bubble ol { padding-left: 20px; margin: 6px 0; }
.msg-bubble li { margin: 3px 0; }
.msg-bubble strong { color: var(--purple-l); font-weight: 700; }
.msg-bubble em { color: var(--cyan); font-style: italic; }
.msg-bubble code {
  background: rgba(0,0,0,0.35);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.82rem;
  color: var(--amber);
}
.msg-bubble br { display: block; content: ''; margin: 2px 0; }

/* Typing indicator */
.typing-dots {
  display: flex;
  gap: 4px;
  padding: 4px 0;
  align-items: center;
}
.typing-dots span {
  width: 8px; height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%            { transform: translateY(-6px); opacity: 1; }
}

/* Input row */
.input-row {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  align-items: flex-end;
}
.user-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 24px;
  color: var(--text);
  font-family: 'Poppins', sans-serif;
  font-size: 0.88rem;
  padding: 10px 18px;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.5;
  transition: border-color 0.2s;
}
.user-input:focus {
  outline: none;
  border-color: var(--purple);
}
.user-input::placeholder { color: var(--text-dim); }
.send-btn {
  background: linear-gradient(135deg, var(--purple), #6d28d9);
  border: none;
  border-radius: 24px;
  color: #fff;
  font-family: 'Poppins', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 10px 18px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  white-space: nowrap;
  height: 42px;
}
.send-btn:hover { opacity: 0.85; }
.send-btn:active { transform: scale(0.97); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============================================================
   TRACKER
   ============================================================ */
.tracker-header {
  margin-bottom: 24px;
}
.tracker-header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 14px;
}
.tracker-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.tstat { display: flex; align-items: baseline; gap: 4px; }
.tstat-num { font-size: 1.6rem; font-weight: 800; color: var(--purple-l); }
.tstat-lbl { font-size: 0.75rem; color: var(--text-muted); }
.tstat-div { font-size: 1.4rem; color: var(--text-dim); margin: 0 4px; }
.tstat-pct {
  margin-left: auto;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--cyan);
}
.master-bar-outer {
  height: 10px;
  background: var(--surface-3);
  border-radius: 5px;
  overflow: hidden;
}
.master-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple), var(--cyan));
  border-radius: 5px;
  transition: width 0.6s ease;
}

/* Subject accordion cards */
.subject-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 14px;
  overflow: hidden;
  transition: border-color 0.2s;
}
.subject-card:hover { border-color: var(--border-2); }

.subject-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
}
.subject-emoji { font-size: 1.4rem; }
.subject-name { font-size: 0.95rem; font-weight: 700; flex: 1; }
.subject-count { font-size: 0.75rem; color: var(--text-muted); }
.subject-mini-bar {
  width: 60px; height: 6px;
  background: var(--surface-3);
  border-radius: 3px;
  overflow: hidden;
}
.subject-mini-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s;
}
.subject-toggle {
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: transform 0.25s;
}
.subject-card.open .subject-toggle { transform: rotate(180deg); }

.subject-topics {
  display: none;
  padding: 0 20px 16px;
  border-top: 1px solid var(--border);
}
.subject-card.open .subject-topics { display: block; }

.topic-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
  transition: opacity 0.15s;
}
.topic-item:last-child { border-bottom: none; }
.topic-item:hover { opacity: 0.85; }

.topic-check {
  width: 20px; height: 20px;
  border-radius: 6px;
  border: 2px solid var(--border-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.7rem;
  transition: all 0.2s;
}
.topic-item.done .topic-check {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.topic-item.done .topic-text {
  text-decoration: line-through;
  color: var(--text-dim);
}
.topic-text { font-size: 0.82rem; flex: 1; line-height: 1.4; }

.topic-conf {
  display: flex;
  gap: 3px;
}
.conf-star {
  font-size: 0.75rem;
  cursor: pointer;
  opacity: 0.3;
  transition: opacity 0.15s;
}
.conf-star.lit { opacity: 1; }

/* ============================================================
   PLANNER
   ============================================================ */
.planner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.planner-header h1 {
  font-size: 1.5rem;
  font-weight: 800;
}
.add-btn {
  background: linear-gradient(135deg, var(--purple), #6d28d9);
  border: none;
  border-radius: 24px;
  color: #fff;
  font-family: 'Poppins', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 18px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.add-btn:hover { opacity: 0.85; }

.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.week-label { font-size: 0.9rem; font-weight: 600; color: var(--text-muted); }
.week-arrow {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Poppins', sans-serif;
  font-size: 0.78rem;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.2s;
}
.week-arrow:hover { background: var(--surface-3); }

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.day-col {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  min-height: 120px;
}
.day-col.today { border-color: var(--purple); background: rgba(124,58,237,0.05); }
.day-col.has-exam { border-color: rgba(239,68,68,0.4); }

.day-head {
  padding: 6px 8px;
  font-size: 0.68rem;
  font-weight: 700;
  text-align: center;
  background: var(--surface-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.day-head.weekend { color: var(--text-muted); }
.day-head.today-head { color: var(--purple-l); }
.day-num { font-size: 0.85rem; font-weight: 800; margin-bottom: 2px; }

.day-events { padding: 6px; display: flex; flex-direction: column; gap: 4px; }

.event-block {
  padding: 4px 7px;
  border-radius: 6px;
  font-size: 0.65rem;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  position: relative;
}
.event-block:hover { opacity: 0.85; }
.event-block .ev-del {
  display: none;
  position: absolute;
  top: 2px; right: 4px;
  font-size: 0.6rem;
  cursor: pointer;
}
.event-block:hover .ev-del { display: inline; }

.event-block.study   { background: rgba(124,58,237,0.25); color: var(--purple-l); }
.event-block.homework{ background: rgba(59,130,246,0.25); color: #93c5fd; }
.event-block.social  { background: rgba(245,158,11,0.25); color: #fcd34d; }
.event-block.other   { background: rgba(75,85,99,0.4);   color: var(--text-muted); }
.event-block.exam    { background: rgba(239,68,68,0.2);   color: #fca5a5; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-bg.open { display: flex; }

.modal {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 90%;
  max-width: 400px;
  box-shadow: var(--shadow);
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 20px; }

.type-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.type-btn {
  padding: 7px 14px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-family: 'Poppins', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
}
.type-btn.active, .type-btn:hover {
  background: var(--purple);
  border-color: var(--purple);
  color: #fff;
}

.field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.field-input {
  width: 100%;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Poppins', sans-serif;
  font-size: 0.88rem;
  padding: 10px 14px;
  margin-bottom: 14px;
  transition: border-color 0.2s;
}
.field-input:focus { outline: none; border-color: var(--purple); }
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.field-group { display: flex; flex-direction: column; }
.field-group .field-input { margin-bottom: 0; }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.btn-primary {
  flex: 1;
  background: linear-gradient(135deg, var(--purple), #6d28d9);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-family: 'Poppins', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 12px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-primary:hover { opacity: 0.85; }
.btn-ghost {
  flex: 1;
  background: transparent;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: 'Poppins', sans-serif;
  font-size: 0.88rem;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }

/* ============================================================
   MISC / UTILITY
   ============================================================ */
.icon-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: 'Poppins', sans-serif;
  font-size: 0.75rem;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* Scrollbar global */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 2px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 600px) {
  .header { padding: 0 12px; }
  .nav-tab { padding: 6px 8px; }
  .tab-label { display: none; }
  .nav-tab .tab-icon { font-size: 1.2rem; }

  .tab-content { padding: 16px 14px; }
  #tab-chat { padding: 0; }

  .timer-num { font-size: 2.2rem; }
  .timer-unit { min-width: 52px; }

  .focus-grid { grid-template-columns: 1fr 1fr; }
  .week-grid { grid-template-columns: repeat(7, 1fr); gap: 3px; }
  .day-head { font-size: 0.6rem; padding: 4px 2px; }
  .event-block { font-size: 0.58rem; padding: 3px 5px; }

  .prog-name { width: 100px; font-size: 0.75rem; }
  .message { max-width: 95%; }
}

@media (max-width: 400px) {
  .countdown-subject { font-size: 1.1rem; }
  .timer-num { font-size: 1.8rem; }
  .focus-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   LOGIN OVERLAY
   ============================================================ */
.login-overlay {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 500;
  background: var(--bg);
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.login-card {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  width: 90%;
  max-width: 380px;
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 24px;
}

.login-title {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.login-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.login-error {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius);
  color: #fca5a5;
  font-size: 0.82rem;
  padding: 10px 14px;
  margin-bottom: 14px;
}

/* .field-label, .field-input, .btn-primary reused from existing styles */
.login-card .field-input { margin-bottom: 14px; }
.login-card .btn-primary  { width: 100%; margin-top: 6px; }

/* ============================================================
   PARENT BANNER
   ============================================================ */
.parent-banner {
  background: linear-gradient(90deg, rgba(245,158,11,0.12), rgba(245,158,11,0.04));
  border-bottom: 1px solid rgba(245,158,11,0.25);
  color: var(--amber);
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  padding: 7px 20px;
  letter-spacing: 0.04em;
}

/* ============================================================
   READ-ONLY TOPIC ITEMS (parent mode)
   ============================================================ */
.topic-item.readonly {
  cursor: default;
  pointer-events: none;
}
.topic-item.readonly:hover { opacity: 1; }

/* ============================================================
   TOPIC REVISE BUTTON
   ============================================================ */
.topic-revise-btn {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 600;
  font-family: inherit;
  color: #94a3b8;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 2px 8px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
  pointer-events: auto;
}
.topic-revise-btn:hover {
  background: rgba(139,92,246,0.25);
  border-color: rgba(139,92,246,0.5);
  color: #c4b5fd;
}

/* ============================================================
   REVISION PANEL OVERLAY
   ============================================================ */
.revise-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.revise-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.revise-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 780px;
  height: 88vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32,0.72,0,1);
  overflow: hidden;
}
.revise-overlay.open .revise-panel {
  transform: translateY(0);
}
.revise-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.4rem 0.8rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.revise-title-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
.rv-emoji { font-size: 1.6rem; flex-shrink: 0; }
.rv-subject {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.rv-topic {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 45vw;
}
.rv-close-btn { flex-shrink: 0; }
.revise-tabs {
  display: flex;
  gap: 0.4rem;
  padding: 0.75rem 1.4rem 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.rtab {
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.4rem 0.75rem 0.6rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.rtab:hover  { color: var(--text); }
.rtab.active { color: #a78bfa; border-bottom-color: #a78bfa; }
.revise-loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}
.revise-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: #a78bfa;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.revise-loading small { font-size: 0.78rem; opacity: 0.7; }
.revise-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.4rem 1.6rem 2rem;
  scroll-behavior: smooth;
}
.revise-body h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #c4b5fd;
  margin: 1.2rem 0 0.4rem;
}
.revise-body h3 {
  font-size: 0.93rem;
  font-weight: 600;
  color: var(--text);
  margin: 1rem 0 0.3rem;
}
.revise-body h4 {
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0.8rem 0 0.2rem;
}
.revise-body p  { margin: 0.3rem 0; line-height: 1.65; font-size: 0.9rem; }
.revise-body ul,
.revise-body ol { margin: 0.3rem 0 0.5rem 1.2rem; }
.revise-body li { margin: 0.25rem 0; font-size: 0.9rem; line-height: 1.6; }
.revise-body strong { color: #e2e8f0; }
.answer-reveal {
  margin: 0.4rem 0 1.2rem;
}
.reveal-btn {
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: #a78bfa;
  background: rgba(139,92,246,0.1);
  border: 1px solid rgba(139,92,246,0.35);
  border-radius: 8px;
  padding: 0.45rem 1.1rem;
  cursor: pointer;
  transition: background 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.reveal-btn:hover { background: rgba(139,92,246,0.22); }
.answer-content {
  border-left: 3px solid rgba(167,139,250,0.35);
  padding-left: 1rem;
  margin-top: 0.5rem;
}
.hide-btn {
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0.75rem;
  cursor: pointer;
  margin-bottom: 0.5rem;
  display: block;
}
.hide-btn:hover { color: var(--text); }
.revise-error {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}

/* ============================================================
   SAVE MY EXAMS LINK
   ============================================================ */
.sme-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #94a3b8;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 2px 7px;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
  pointer-events: auto;
}
.sme-link:hover {
  background: rgba(255,255,255,0.14);
  color: #e2e8f0;
}
