@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  /* ── EdTech palette (TTP-inspired): academic ocean blue + mastery green ── */
  --bg: #F4F7FB;
  --surface: #ffffff;
  --surface-2: #F8FAFC;
  --surface-hover: #EFF4FA;
  --text: #0B1B33;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;

  /* Primary: deep ocean blue (was generic indigo→violet) */
  --primary: #1E5BA0;
  --primary-hover: #2E78D9;
  --primary-deep: #0F4C81;
  --primary-bright: #2E78D9;
  --primary-subtle: #DCEAFE;
  --primary-faint: #EFF6FF;
  --primary-gradient: linear-gradient(135deg, #1E5BA0 0%, #2E78D9 100%);
  --primary-gradient-soft: linear-gradient(135deg, #EFF6FF 0%, #DCEAFE 100%);

  /* Mastery green = the EdTech "you got it right" signal */
  --mastery: #16A34A;
  --mastery-soft: #DCFCE7;
  --mastery-deep: #15803D;

  --success: #16A34A;
  --success-subtle: #DCFCE7;
  --warning: #F59E0B;
  --warning-subtle: #FEF3C7;
  --danger: #DC2626;
  --danger-subtle: #FEE2E2;
  --info: #0EA5E9;
  --accent: #2E78D9;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 16px;
  --r-full: 9999px;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 6px 16px -4px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 16px 40px -8px rgba(15, 23, 42, 0.12), 0 4px 12px rgba(15, 23, 42, 0.05);
  --shadow-ring: 0 0 0 3px rgba(30, 91, 160, 0.18);

  --t-base: 150ms ease;
  --t-smooth: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-bounce: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
*::-webkit-scrollbar-track { background: transparent; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

body { min-height: 100vh; }

h1, h2, h3, h4 { letter-spacing: -0.02em; }

/* ── Layout ───────────────────────────────────────────────────────────── */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: var(--space-5) var(--space-3);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 50;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-3) var(--space-5);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.sidebar-brand .mark {
  width: 36px; height: 36px;
  background: var(--primary-gradient);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: -0.5px;
  box-shadow: var(--shadow-md);
}

.sidebar-brand .name {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  line-height: 1.2;
}

.sidebar-brand .name .sub {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 1px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.sidebar-nav .section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-subtle);
  font-weight: 700;
  padding: var(--space-3) var(--space-3) var(--space-2);
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 9px var(--space-3);
  border-radius: var(--r-md);
  text-decoration: none;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: var(--t-base);
}

.sidebar-nav a:hover { background: var(--surface-2); color: var(--text); }
.sidebar-nav a.active {
  background: var(--primary-gradient-soft);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-user {
  margin-top: auto;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  transition: var(--t-smooth);
  background: var(--surface);
}
.sidebar-user:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
/* New user (not yet signed up) — subtle indigo tint */
.sidebar-user:not(.signed-up) {
  background: var(--primary-gradient-soft);
  border-color: var(--primary-subtle);
}
.sidebar-user:not(.signed-up):hover {
  border-color: var(--primary);
}
.sidebar-user:not(.signed-up) .info .plan {
  color: var(--primary);
  font-weight: 600;
}
.sidebar-user.signed-up .info .plan {
  color: var(--success);
  font-weight: 600;
}
.sidebar-user .avatar {
  width: 36px; height: 36px;
  border-radius: var(--r-full);
  background: var(--primary-gradient);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.sidebar-user .info { flex: 1; min-width: 0; }
.sidebar-user .info .name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user .info .plan {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Main area */
.main {
  flex: 1;
  margin-left: 240px;
  min-height: 100vh;
  padding: var(--space-6) var(--space-8);
  max-width: 100%;
}
.main-inner { max-width: 1100px; margin: 0 auto; }

.page-header { margin-bottom: var(--space-6); }
.page-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.6px;
  margin: 0 0 4px;
  color: var(--text);
}
.page-subtitle { font-size: 14px; color: var(--text-muted); margin: 0; }

/* Mobile header (hidden on desktop) */
.mobile-header {
  display: none;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
  padding: var(--space-3) var(--space-4);
  align-items: center;
  gap: var(--space-3);
  position: sticky;
  top: 0;
  z-index: 40;
}
.mobile-header .brand-mark {
  width: 32px; height: 32px;
  background: var(--primary-gradient);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 12px;
}
.mobile-header .brand-text { font-weight: 700; font-size: 15px; flex: 1; }

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--border);
  padding: var(--space-2) 0 max(var(--space-2), env(safe-area-inset-bottom));
  z-index: 50;
  justify-content: space-around;
}
.bottom-nav a {
  flex: 1;
  text-align: center;
  padding: var(--space-3) var(--space-2);  /* was space-2/space-1 → ~24px tall, now ~44px */
  min-height: 44px;                          /* iOS HIG min tap target */
  text-decoration: none;
  color: var(--text-subtle);
  font-size: 11px;                           /* was 10px */
  font-weight: 500;
  transition: var(--t-base);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.bottom-nav a svg { display: block; margin: 0 auto 2px; }
.bottom-nav a.active { color: var(--primary); }

/* Responsive — tablets + phones (was 900px, kept) */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: var(--space-4); padding-bottom: 110px; }  /* was 90px — bumped for safer overlap */
  .mobile-header { display: flex; }
  .bottom-nav { display: flex; }
  .main-inner { max-width: 100%; }
  .page-title { font-size: 22px; }
  .page-header { margin-bottom: var(--space-4); }
}

/* Mobile-specific (≤480px) — Indian student phones (Redmi/Moto 360-414px width) */
@media (max-width: 480px) {
  body { font-size: 15px; -webkit-text-size-adjust: 100%; }
  label { font-size: 14px; }
  .main { padding: var(--space-3); padding-bottom: 110px; }   /* tighter inner padding */
  .page-title { font-size: 20px; line-height: 1.25; }
  .page-subtitle { font-size: 14px; }
  .page-header { margin-bottom: var(--space-3); }
  .card { padding: var(--space-4); }                          /* tighter cards */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; gap: var(--space-3); }
  .hero { padding: var(--space-4) !important; }
  .hero-title { font-size: 22px !important; line-height: 1.2; }
  .hero-quickask { flex-direction: column; }
  .hero-quickask input,
  .hero-quickask button { width: 100%; }
  .btn { padding: 13px 18px; font-size: 14.5px; min-height: 44px; }
  .chip { padding: 10px 14px; font-size: 13px; min-height: 38px; }
}

/* iOS auto-zoom guard: form fields must be ≥16px on touch devices */
@media (max-width: 600px) {
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* ── Card ────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-xs);
  transition: var(--t-smooth);
}
.card.hover:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.card h2 { margin: 0 0 var(--space-2); font-size: 18px; font-weight: 700; }
.card h3 { margin: 0 0 var(--space-2); font-size: 15px; font-weight: 600; }
.card p { margin: var(--space-1) 0; font-size: 14px; color: var(--text-muted); line-height: 1.55; }

.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  background: var(--primary-gradient);
  color: #fff;
  border: none;
  padding: 11px 18px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: var(--t-smooth);
  box-shadow: var(--shadow-sm);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-ring), var(--shadow-sm); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn.secondary {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); box-shadow: none;
}
.btn.secondary:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn.success { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.btn.danger { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); }
.btn.ghost { background: transparent; color: var(--text-muted); box-shadow: none; }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.full { width: 100%; }
.btn.small { padding: 7px 12px; font-size: 12px; }
.btn.large { padding: 14px 22px; font-size: 15px; }

/* ── Stat cards ──────────────────────────────────────────────────────── */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
  transition: var(--t-smooth);
}
.stat::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--primary-gradient);
  opacity: 0;
  transition: var(--t-smooth);
}
.stat:hover { box-shadow: var(--shadow-sm); }
.stat:hover::before { opacity: 1; }
.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 700;
  margin-bottom: var(--space-3);
}
.stat-value {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -1.5px;
  color: var(--text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-value .unit {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 4px;
}
.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: var(--space-3);
}
.stat-sub .delta-up { color: var(--success); font-weight: 600; }
.stat-sub .delta-down { color: var(--danger); font-weight: 600; }

/* ── Progress bar ────────────────────────────────────────────────────── */
.progress {
  height: 8px;
  background: var(--surface-2);
  border-radius: var(--r-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--primary-gradient);
  border-radius: var(--r-full);
  transition: width 0.9s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-fill.success { background: linear-gradient(90deg, #10b981, #22c55e); }
.progress-fill.warning { background: linear-gradient(90deg, #f59e0b, #facc15); }
.progress-fill.danger { background: linear-gradient(90deg, #ef4444, #f87171); }

/* Ring progress (SVG) */
.ring-progress {
  position: relative;
  width: 140px;
  height: 140px;
  display: inline-block;
}
.ring-progress svg { transform: rotate(-90deg); display: block; }
.ring-progress .ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 12; }
.ring-progress .ring-fg {
  fill: none;
  stroke: url(#ring-gradient);
  stroke-width: 12;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1);
}
.ring-progress .ring-label {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
.ring-progress .ring-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -1px;
  line-height: 1;
}
.ring-progress .ring-unit {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin-top: 3px;
}

/* ── Badges & chips ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.badge.primary { background: var(--primary-subtle); color: var(--primary); }
.badge.success { background: var(--success-subtle); color: #065f46; }
.badge.warning { background: var(--warning-subtle); color: #92400e; }
.badge.danger { background: var(--danger-subtle); color: #991b1b; }
.badge.neutral { background: var(--surface-2); color: var(--text-muted); }
.badge.pass { background: var(--success-subtle); color: #065f46; }
.badge.fail { background: var(--danger-subtle); color: #991b1b; }
.badge.muted { background: var(--surface-2); color: var(--text-muted); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--t-base);
  background: var(--surface);
  user-select: none;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active {
  background: var(--primary-gradient);
  color: white;
  border-color: transparent;
}
.chip-group { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* ── Forms ───────────────────────────────────────────────────────────── */
input, select, textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: var(--t-base);
}
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-ring);
}
textarea { resize: vertical; min-height: 80px; line-height: 1.55; }
label {
  display: block;
  font-size: 12.5px;
  color: var(--text);
  font-weight: 600;
  margin-bottom: var(--space-2);
}
.field { margin-bottom: var(--space-4); }
.field-help { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ── Utility ─────────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-center { text-align: center; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-lg { font-size: 16px; }
.font-bold { font-weight: 700; }
.font-mono { font-family: var(--font-mono); }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); }
.flex-center { display: flex; justify-content: center; align-items: center; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.w-full { width: 100%; }

/* ── Skeleton loading ────────────────────────────────────────────────── */
@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.4s infinite linear;
  border-radius: var(--r-sm);
}
.skeleton.line { height: 12px; margin: 6px 0; }
.skeleton.title { height: 22px; width: 60%; }
.skeleton.box { height: 80px; }

/* ── Toasts ──────────────────────────────────────────────────────────── */
#toasts {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 200;
  pointer-events: none;
  max-width: 380px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  pointer-events: auto;
  animation: toast-in var(--t-smooth);
  border-left: 3px solid var(--primary);
  min-width: 240px;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
@keyframes toast-in { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toast-out { to { transform: translateX(100%); opacity: 0; } }
.toast.leaving { animation: toast-out var(--t-smooth) forwards; }

/* ── Modal ───────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  animation: fade-in var(--t-smooth);
  padding: var(--space-4);
}
.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: var(--space-6);
  max-width: 460px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: modal-in var(--t-bounce);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
  from { transform: scale(0.95) translateY(10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}
.modal h3 { margin: 0 0 var(--space-3); font-size: 18px; }
.modal p { margin: 0 0 var(--space-5); color: var(--text-muted); font-size: 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: var(--space-2); }

/* ── Icons ───────────────────────────────────────────────────────────── */
.icon { flex-shrink: 0; display: inline-block; vertical-align: middle; }

/* ── Hero ────────────────────────────────────────────────────────────── */
.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--space-8) var(--space-6);
  margin-bottom: var(--space-6);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.hero::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 260px; height: 260px;
  background: var(--primary-gradient);
  border-radius: 50%;
  opacity: 0.09;
  filter: blur(60px);
  pointer-events: none;
}
.hero::after {
  content: '';
  position: absolute;
  bottom: -40px; left: 30%;
  width: 180px; height: 180px;
  background: linear-gradient(135deg, var(--mastery), var(--primary-bright));
  border-radius: 50%;
  opacity: 0.06;
  filter: blur(50px);
  pointer-events: none;
}
.hero-greeting {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: var(--space-2);
  letter-spacing: 0.2px;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 10px;
  background: var(--primary-gradient-soft);
  border-radius: var(--r-full);
}
.hero-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1.2px;
  margin: 0 0 var(--space-2);
  color: var(--text);
  line-height: 1.1;
}
.hero-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  margin: 0 0 var(--space-5);
  max-width: 560px;
  line-height: 1.6;
}
.hero-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; position: relative; }
@media (max-width: 560px) {
  .hero { padding: var(--space-5); }
  .hero-title { font-size: 24px; }
}

/* Hero quick-ask — lowest-friction entry point */
.hero-quickask {
  display: flex;
  gap: var(--space-2);
  max-width: 600px;
  margin-bottom: var(--space-5);
  position: relative;
  z-index: 2;
}
.hero-quickask input {
  flex: 1;
  padding: 14px 16px;
  font-size: 14.5px;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}
.hero-quickask input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-md), var(--shadow-ring);
}
.hero-quickask button {
  padding: 14px 18px;
  white-space: nowrap;
  font-size: 14px;
}
.hero-quickask-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: -12px;
  margin-bottom: var(--space-4);
  position: relative;
  z-index: 2;
}
@media (max-width: 560px) {
  .hero-quickask { flex-direction: column; }
  .hero-quickask button { padding: 12px 18px; }
}

/* Launch strip (early-access counter + "what's new") */
.launch-strip {
  display: none;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #fcd34d;
  border-radius: var(--r-md);
  padding: 10px 14px;
  margin-bottom: var(--space-4);
  font-size: 13px;
  gap: var(--space-4);
  align-items: center;
  flex-wrap: wrap;
  color: #78350f;
  position: relative;
  z-index: 2;
}
.launch-strip.show { display: flex; }
.launch-strip .claim { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.launch-strip .claim strong { color: #b45309; font-variant-numeric: tabular-nums; }
.launch-strip .divider { width: 1px; align-self: stretch; background: #fcd34d; }
.launch-strip .latest { display: flex; align-items: center; gap: 6px; color: #92400e; font-weight: 500; flex: 1; min-width: 240px; }
.launch-strip .latest .label { text-transform: uppercase; font-size: 10px; letter-spacing: 0.8px; color: #b45309; font-weight: 700; }
.launch-strip .closed { color: #991b1b; font-weight: 700; }
@media (max-width: 600px) {
  .launch-strip .divider { display: none; }
}

/* ── Tile (feature card) ─────────────────────────────────────────────── */
.tile {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-5);
  text-decoration: none;
  color: inherit;
  transition: var(--t-smooth);
  position: relative;
  box-shadow: var(--shadow-xs);
}
.tile:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}
.tile-icon {
  width: 44px; height: 44px;
  background: var(--primary-gradient-soft);
  color: var(--primary);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
}
.tile-icon svg { width: 22px; height: 22px; }
.tile-title { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.tile-desc { font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.tile-arrow {
  position: absolute;
  top: var(--space-5); right: var(--space-5);
  color: var(--text-subtle);
  transition: var(--t-base);
}
.tile:hover .tile-arrow { color: var(--primary); transform: translateX(4px); }

/* ── Heatmap ─────────────────────────────────────────────────────────── */
.heatmap {
  display: grid;
  grid-template-columns: repeat(30, 1fr);
  gap: 3px;
  max-width: 520px;
}
.heatmap .cell {
  aspect-ratio: 1;
  background: var(--surface-2);
  border-radius: 2px;
  transition: var(--t-base);
}
.heatmap .cell.l1 { background: #c7d2fe; }
.heatmap .cell.l2 { background: #818cf8; }
.heatmap .cell.l3 { background: #1E5BA0; }
.heatmap .cell.l4 { background: #4338ca; }
.heatmap .cell:hover { transform: scale(1.6); z-index: 1; }

/* ── Sparkline ───────────────────────────────────────────────────────── */
.sparkline path.line { stroke: var(--primary); stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.sparkline path.area { fill: url(#spark-gradient); stroke: none; }

/* ── Bar chart (topic breakdown) ─────────────────────────────────────── */
.topic-bar { margin-bottom: var(--space-4); }
.topic-bar .label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12.5px;
}
.topic-bar .label strong { color: var(--text); font-weight: 600; }
.topic-bar .label .n { color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ── Chat (tutor) ────────────────────────────────────────────────────── */
.messages {
  padding-bottom: 140px;
  min-height: calc(100vh - 200px);
}
.message {
  margin-bottom: var(--space-4);
  max-width: 90%;
  animation: fade-in var(--t-smooth);
}
.message.user { margin-left: auto; }
.message.user .bubble {
  background: var(--primary-gradient);
  color: #fff;
  padding: 12px 16px;
  border-radius: 18px 18px 4px 18px;
  font-size: 14px;
  display: inline-block;
  box-shadow: var(--shadow-sm);
}
.message.tutor .bubble {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 16px 20px;
  border-radius: 4px 18px 18px 18px;
  font-size: 14px;
  line-height: 1.65;
  box-shadow: var(--shadow-xs);
}
.message.tutor .bubble h2 { font-size: 16px; color: var(--primary); margin: 14px 0 6px; font-weight: 700; }
.message.tutor .bubble h3 { font-size: 14px; margin: 10px 0 4px; font-weight: 600; }
.message.tutor .bubble code { background: var(--surface-2); padding: 2px 6px; border-radius: 4px; font-size: 12px; font-family: var(--font-mono); }
.message.tutor .bubble pre { background: var(--surface-2); padding: 12px; border-radius: var(--r-md); overflow-x: auto; }
.message.tutor .bubble ul, .message.tutor .bubble ol { padding-left: 22px; margin: 8px 0; }
.message.tutor .bubble li { margin: 4px 0; }
.message.tutor .bubble p { margin: 6px 0; color: var(--text); }
.message.tutor .sources {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
}
.message.tutor .sources details summary { cursor: pointer; color: var(--primary); font-weight: 600; }

.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}
.typing-indicator span {
  width: 7px; height: 7px;
  background: var(--text-subtle);
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

.input-area {
  position: fixed;
  bottom: 0;
  left: 240px;
  right: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: var(--space-4) var(--space-8);
  z-index: 30;
}
.input-area-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  gap: var(--space-2);
  align-items: flex-end;
}
.input-area textarea {
  flex: 1;
  min-height: 44px;
  max-height: 180px;
  border-radius: var(--r-lg);
  padding: 12px 14px;
}
.input-area .send-btn {
  width: 44px; height: 44px;
  padding: 0;
  border-radius: var(--r-md);
}
.input-area .hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: center;
}
@media (max-width: 900px) {
  .input-area { left: 0; bottom: 72px; padding: var(--space-3); }
}

/* ── Question card (practice/mock/custom) ────────────────────────────── */
.qcard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-xs);
  transition: var(--t-smooth);
}
.qcard:hover { box-shadow: var(--shadow-sm); }
.qcard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}
.qcard-number {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.qcard-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.qcard-case {
  background: var(--warning-subtle);
  border-left: 3px solid var(--warning);
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  color: #78350f;
  margin-bottom: var(--space-3);
  line-height: 1.6;
}
.qcard-text {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: var(--space-3);
}
.qcard-options { margin-bottom: var(--space-3); }
.qcard-options div { font-size: 13.5px; padding: 4px 0; color: var(--text); }
.qcard textarea { margin-top: var(--space-2); }

.feedback {
  margin-top: var(--space-4);
  padding: var(--space-4);
  background: var(--surface-2);
  border-radius: var(--r-md);
  animation: fade-in var(--t-smooth);
}
.feedback h4 { margin: 0 0 var(--space-2); font-size: 14px; color: var(--primary); }
.feedback ul { margin: var(--space-2) 0; padding-left: 18px; font-size: 12.5px; }
.feedback li { margin: 3px 0; }
.feedback details summary { cursor: pointer; color: var(--primary); font-size: 12.5px; font-weight: 600; }
.feedback .model-answer {
  margin-top: 8px;
  padding: 12px;
  background: var(--success-subtle);
  border-radius: var(--r-sm);
  font-size: 12.5px;
  line-height: 1.6;
}

/* ── Flashcard flip ──────────────────────────────────────────────────── */
.flashcard-container {
  perspective: 1200px;
  max-width: 520px;
  margin: 0 auto var(--space-5);
}
.flashcard {
  position: relative;
  width: 100%;
  min-height: 260px;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}
.flashcard.flipped { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute;
  inset: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--space-6);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.flashcard-face.back {
  transform: rotateY(180deg);
  background: linear-gradient(135deg, #f0f4ff 0%, #faf5ff 100%);
}
.flashcard-face .type-badge {
  position: absolute;
  top: var(--space-4);
  left: var(--space-4);
}
.flashcard-face .subject-badge {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
}
.flashcard-front-text {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
  letter-spacing: -0.3px;
}
.flashcard-back-text {
  font-size: 14.5px;
  color: var(--text);
  line-height: 1.6;
  text-align: left;
  max-height: 260px;
  overflow-y: auto;
  width: 100%;
  padding: 0 var(--space-2);
}
.flashcard-back-text strong { color: var(--primary); }

.rate-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
  max-width: 520px;
  margin: 0 auto;
}
.rate-btn {
  padding: var(--space-4) var(--space-2);
  border-radius: var(--r-md);
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--t-smooth);
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  box-shadow: var(--shadow-sm);
}
.rate-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.rate-btn .kbd {
  font-size: 10px;
  opacity: 0.7;
  font-family: var(--font-mono);
}
.rate-btn.again { background: linear-gradient(135deg, #ef4444, #dc2626); }
.rate-btn.hard { background: linear-gradient(135deg, #f59e0b, #d97706); }
.rate-btn.good { background: linear-gradient(135deg, #10b981, #059669); }
.rate-btn.easy { background: linear-gradient(135deg, var(--primary), var(--primary-deep)); }

/* ── Timer bar ───────────────────────────────────────────────────────── */
.timer-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
}
.timer-bar .title { font-size: 13px; font-weight: 600; color: var(--text); }
.timer-bar .time {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}
.timer-bar .time.warning { color: var(--warning); }
.timer-bar .time.danger { color: var(--danger); animation: pulse-danger 1s infinite; }
@keyframes pulse-danger { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

.section-head {
  background: var(--primary-gradient-soft);
  border: 1px solid var(--primary-subtle);
  border-radius: var(--r-md);
  padding: 10px 16px;
  margin: var(--space-4) 0 var(--space-3);
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.2px;
}
.subsection-head {
  font-size: 11px;
  color: var(--text-subtle);
  margin: var(--space-4) 0 var(--space-2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* ════════════════════════════════════════════════════════════════════
   GLOBAL MOBILE FIXES (Apr 2026)
   Applies to EVERY page. Aggressive overflow elimination because the
   home-page-only fix didn't catch /diagnostic, /past-papers, /drill,
   /may-2026, etc. Google SEO traffic incoming — these MUST be clean.
   ════════════════════════════════════════════════════════════════════ */

@media (max-width: 600px) {
  /* 1. Universal box model + overflow safety — TRUE NUCLEAR */
  *, *::before, *::after {
    box-sizing: border-box !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }
  html { overflow-x: hidden; width: 100%; }
  body { overflow-x: hidden; width: 100vw; max-width: 100vw; margin: 0; padding-bottom: 70px; }
  .app, .main, #app, #root { width: 100% !important; max-width: 100% !important; overflow-x: hidden !important; }
  /* Kill inline padding on cards so they don't push past viewport */
  .card[style*="padding: 36px"], .card[style*="padding: 32px"], .card[style*="padding:36px"], .card[style*="padding:32px"] {
    padding: 16px !important;
  }
  /* Force ALL flex containers to wrap on mobile (catch JS inline styles) */
  [style*="display: flex"]:not([style*="flex-direction: column"]):not([style*="flex-direction:column"]),
  [style*="display:flex"]:not([style*="flex-direction: column"]):not([style*="flex-direction:column"]) {
    flex-wrap: wrap !important;
  }
  /* SVGs/images explicit sizing (max-width:100% nukes intrinsic SVG icons otherwise) */
  svg[width][height], img[width][height] { max-width: none !important; }
  svg.icon, .icon svg { max-width: 100% !important; height: auto !important; }

  /* CRITICAL: 2-column grids with sidebar (1fr Npx pattern) MUST stack on mobile */
  .lesson-detail-grid, .paper-detail-grid {
    grid-template-columns: 1fr !important;
    gap: 18px !important;
  }
  /* Email + button forms: stack vertically so input doesn't get squashed by nowrap button */
  #may2026-all-form, .email-cta-form, form[style*="display:flex"]:not([style*="flex-direction"]) {
    flex-direction: column !important;
  }
  #may2026-all-form input, #may2026-all-form button,
  .email-cta-form input, .email-cta-form button {
    width: 100% !important;
  }
  /* Catch any other inline-styled grid with 1fr + fixed-px sidebar */
  [style*="grid-template-columns:1fr"][style*="px"],
  [style*="grid-template-columns: 1fr"][style*="px"],
  [style*="grid-template-columns: 240px"], [style*="grid-template-columns: 280px"],
  [style*="grid-template-columns:240px"], [style*="grid-template-columns:280px"] {
    grid-template-columns: 1fr !important;
  }

  /* 2. Force every text-bearing element to wrap */
  h1, h2, h3, h4, h5, h6, p, span, a, li, td, th, label, div, blockquote {
    word-break: break-word;
    overflow-wrap: anywhere;
    max-width: 100%;
  }

  /* 3. Container hard-caps — never wider than viewport */
  .main, .main-inner, .card, .hero, section, article {
    max-width: 100%;
    min-width: 0;
  }
  .main-inner { padding-left: 12px; padding-right: 12px; }
  .card { padding: 16px !important; }
  .hero { padding: 18px 16px !important; margin-bottom: 24px !important; }

  /* 4. Page header sizing */
  .page-title { font-size: 22px !important; line-height: 1.2 !important; letter-spacing: -0.2px !important; }
  .page-subtitle { font-size: 13.5px !important; line-height: 1.5 !important; }
  .page-header { margin-bottom: 18px !important; }

  /* 5. UNCONDITIONAL heading caps — overrides ANY inline font-size */
  h1 { font-size: 22px !important; line-height: 1.2 !important; letter-spacing: -0.2px !important; }
  h2 { font-size: 19px !important; line-height: 1.22 !important; letter-spacing: -0.2px !important; }
  h3 { font-size: 17px !important; line-height: 1.3 !important; }
  h4 { font-size: 15px !important; }
  /* Hero titles (homepage) get a tiny bit more */
  .hero-title, .hero-2col .hero-title { font-size: 24px !important; line-height: 1.18 !important; }

  /* 6. Stack ALL multi-column grids */
  .grid, .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; gap: 14px !important; }

  /* 7. Stack ALL inline-styled flex 2-cols (used in stat boxes) */
  div[style*="display:flex"][style*="gap"] {
    flex-wrap: wrap;
  }
  /* Specifically: any flex container holding stat tiles where children have flex:1 */
  .stat-row, .two-col, .stats-grid, .meta-strip { flex-wrap: wrap !important; gap: 10px !important; }

  /* 8. Form fields: full width, no horizontal scrolling */
  input, select, textarea, button {
    max-width: 100%;
    box-sizing: border-box;
  }
  input[type="text"], input[type="email"], input[type="search"],
  input[type="tel"], input[type="url"], select, textarea {
    width: 100%;
  }
  /* Prevent iOS auto-zoom (must be ≥16px) */
  input, select, textarea { font-size: 16px !important; }

  /* 9. Tables shouldn't overflow — let user scroll horizontally INSIDE them, not the page */
  table { max-width: 100%; display: block; overflow-x: auto; }

  /* 10. Buttons + chips stay inside parent */
  .btn { white-space: normal; max-width: 100%; }
  .chip { white-space: normal; }

  /* 11. Inline min-widths in HTML strings (used in study plan, dashboards) — kill them */
  [style*="min-width:200px"], [style*="min-width:220px"], [style*="min-width:240px"],
  [style*="min-width: 200px"], [style*="min-width: 220px"], [style*="min-width: 240px"] {
    min-width: 0 !important;
  }

  /* 12. Reduce huge inline section margins (margin-top:48px, 64px) */
  section[style*="margin-top:64px"] { margin-top: 28px !important; }
  section[style*="margin-top:48px"] { margin-top: 22px !important; }

  /* 13. Code/pre blocks scroll instead of overflow */
  pre, code { max-width: 100%; overflow-x: auto; word-break: normal; }

  /* 14. Images + iframes never overflow */
  img, iframe, video, canvas, svg { max-width: 100%; height: auto; }

  /* 15. Bottom nav clearance — content shouldn't hide behind sticky bottom-nav */
  body { padding-bottom: 70px; }
}
