/* ══════════════════════════════════════════
   MedScholar — styles.css
   Extracted from index.html + mobile fixes
══════════════════════════════════════════ */
/* ══════════════════════════════════════════
   DESIGN SYSTEM — MedScholar PassMed v5
══════════════════════════════════════════ */
:root {
  /* Primary Medical Blues */
  --primary-50: #e6f0ff;
  --primary-100: #b3d1ff;
  --primary-200: #80b3ff;
  --primary-300: #4d94ff;
  --primary-400: #1a75ff;
  --primary-500: #0056d2;
  --primary-600: #0045a8;
  --primary-700: #00347e;
  --primary-800: #002254;
  --primary-900: #00112a;

  /* Clinical Accents */
  --success: #00a86b;
  --warning: #f5a623;
  --danger: #e53e3e;
  --info: #3b9eff;

  /* Neutrals */
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Legacy aliases (for JS/existing code compat) */
  --bg:        var(--gray-50);
  --surface:   #ffffff;
  --surface2:  var(--gray-100);
  --surface3:  var(--gray-200);
  --rim:       rgba(0,0,0,.08);
  --rim2:      rgba(0,0,0,.14);
  --text:      var(--gray-900);
  --text2:     var(--gray-500);
  --text3:     var(--gray-400);
  --accent:    var(--info);
  --accent2:   #1870d8;
  --emerald:   var(--success);
  --ruby:      var(--danger);
  --amber:     var(--warning);
  --violet:    #a07ef8;

  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow:    0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  /* Border radii */
  --r-xs:  4px;
  --r-sm:  6px;
  --r:     8px;

  /* Spacing */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px;

  /* Fonts */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

  /* Layout */
  --sidebar-w: 260px;
  --topbar-h: 64px;

  /* Focus mode */
  --focus-bg: var(--gray-50);
  --focus-surface: var(--gray-100);

  --ease: cubic-bezier(.4,0,.2,1);
}

/* ─── FOCUS MODE ─── */
body.focus-mode #sidebar-nav { background: var(--focus-surface); }
body.focus-mode #top-bar { background: var(--focus-surface); }
body.focus-mode { background: var(--focus-bg); }
body.focus-mode #main { background: var(--focus-bg); }
body.focus-mode .card-face,
body.focus-mode .lc-panel { background: var(--focus-surface) !important; }
.focus-mode-btn {
  background: var(--surface2); border: 1px solid var(--rim); border-radius: 20px;
  padding: 4px 11px; cursor: pointer; font-size: .76rem; color: var(--text2);
  font-family: inherit; transition: all .18s; display: flex; align-items: center; gap: 5px;
  white-space: nowrap;
}
.focus-mode-btn:hover { color: var(--text); border-color: var(--rim2); }
.focus-mode-btn.active { background: rgba(59,158,255,.12); color: var(--accent); border-color: rgba(59,158,255,.3); }

:root.dark {
  --gray-50: #0f172a;
  --gray-100: #1e293b;
  --gray-200: #334155;
  --gray-300: #475569;
  --gray-400: #64748b;
  --gray-500: #94a3b8;
  --gray-600: #cbd5e1;
  --gray-700: #e2e8f0;
  --gray-800: #f1f5f9;
  --gray-900: #f8fafc;
  --primary-500: #3b9eff;
  --bg:        #0f172a;
  --surface:   #1e293b;
  --surface2:  #334155;
  --surface3:  #475569;
  --rim:       rgba(255,255,255,.065);
  --rim2:      rgba(255,255,255,.12);
  --text:      #f1f5f9;
  --text2:     #94a3b8;
  --text3:     #64748b;
  --focus-bg:      #050b12;
  --focus-surface: #091522;
}


*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: var(--font-sans); background: var(--bg); color: var(--text); overflow: hidden; -webkit-font-smoothing: antialiased; }
/* Critical: every flex container in the chain needs min-height: 0 to allow children to shrink and scroll */
#shell, #main-wrapper, #main, #content { min-height: 0; }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--rim2); border-radius: 2px; }

/* ─── STORAGE HEALTH BANNER ─── */
#storageWarning {
  display: none; position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: rgba(255,185,48,.12); border: 1px solid rgba(255,185,48,.4);
  border-radius: var(--r); padding: 10px 18px; font-size: .8rem; color: var(--amber);
  z-index: 8900; display: none; align-items: center; gap: 10px; max-width: 400px;
  box-shadow: var(--shadow-sm);
}
#storageWarning.show { display: flex; }

/* ─── KB SHORTCUT DISCOVERY TOOLTIP ─── */
.kb-discovery-banner {
  display: none; background: var(--surface2); border: 1px solid var(--rim2);
  border-radius: var(--r); padding: 12px 16px; margin-bottom: 14px;
  font-size: .8rem; color: var(--text2); position: relative;
}
.kb-discovery-banner.show { display: block; }
.kb-discovery-banner strong { color: var(--text); }
.kb-discovery-close { position: absolute; top: 8px; right: 10px; cursor: pointer; color: var(--text3); background: none; border: none; font-size: .9rem; padding: 0; }
.kb-discovery-keys { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* ─── CONFIRM DIALOG ─── */
#confirmDialog {
  display: none; position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,.7); align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
#confirmDialog.show { display: flex; }
.confirm-box {
  background: var(--surface); border: 1px solid var(--rim2);
  border-radius: var(--r); padding: 24px; max-width: 360px; width: 90vw;
  box-shadow: var(--shadow);
}
.confirm-title { font-family: var(--font-sans); font-size: 1.1rem; margin-bottom: 8px; }
.confirm-msg { font-size: .84rem; color: var(--text2); line-height: 1.55; margin-bottom: 18px; }
.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ─── STREAK HEATMAP TOOLTIP ─── */
.streak-day { position: relative; cursor: default; }

/* subtle noise texture on bg */
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  opacity: .5;
}

/* ─── LAYOUT — Sidebar Architecture ─── */
#shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  position: relative;
  z-index: 1;
  background: var(--gray-50);
}

/* ════ SIDEBAR ════ */
#sidebar-nav {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
  z-index: 10;
  transition: width 0.2s var(--ease);
}

.sidebar-header {
  padding: 18px 16px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sb-logo-icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0; color: white;
}

.sb-wordmark {
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gray-800);
  letter-spacing: -0.3px;
}

.sb-wordmark span { color: var(--primary-500); }

.sidebar-nav-body {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 24px;
}

.nav-section-title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--gray-400);
  padding: 0 12px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  margin: 2px 0;
  border-radius: 8px;
  color: var(--gray-600);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: var(--font-sans);
  gap: 0;
}

.nav-item:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}

.nav-item.active {
  background: var(--primary-50);
  color: var(--primary-600);
  font-weight: 600;
}

.nav-icon {
  width: 24px;
  margin-right: 10px;
  font-size: 1rem;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--gray-200);
  color: var(--gray-600);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 99px;
  font-family: var(--font-mono);
}

.nav-item.active .nav-badge {
  background: var(--primary-100);
  color: var(--primary-700);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--gray-200);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  cursor: pointer;
  padding: 6px 4px;
  border-radius: 8px;
  transition: background 0.15s;
}
.sidebar-user:hover { background: var(--gray-100); }

.sb-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.9rem;
  flex-shrink: 0;
}

.sb-user-info { flex: 1; min-width: 0; }
.sb-user-name { font-weight: 600; font-size: 0.825rem; color: var(--gray-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-streak { font-size: 0.7rem; color: var(--warning); font-weight: 500; }

.sidebar-progress-row {
  margin-bottom: 12px;
}
.sb-prog-label {
  display: flex; justify-content: space-between;
  font-size: 0.68rem; color: var(--gray-500); margin-bottom: 5px;
}
.sb-prog-bar {
  height: 4px; background: var(--gray-200); border-radius: 99px; overflow: hidden;
}
.sb-prog-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-500), var(--success));
  border-radius: 99px;
  transition: width 0.3s;
}

.sidebar-bottom-actions {
  display: flex; gap: 6px;
}

.sb-action-btn {
  flex: 1;
  height: 34px;
  border: 1px solid var(--gray-200);
  background: var(--gray-50);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  font-family: var(--font-sans);
  color: var(--gray-500);
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 500;
}

.sb-action-btn:hover {
  background: var(--gray-200);
  color: var(--gray-700);
}

/* Main area */
#main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ════ TOP BAR ════ */
#top-bar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}

.top-bar-left {
  display: flex; align-items: baseline; gap: 8px;
}

.top-bar-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gray-800);
  margin: 0;
}

.top-bar-breadcrumb {
  font-size: 0.75rem;
  color: var(--gray-400);
}

.top-bar-right {
  display: flex; align-items: center; gap: 14px;
}

.top-bar-search {
  position: relative; width: 260px;
}
.top-bar-search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--gray-400); font-size: 0.85rem;
}
.top-bar-search input {
  width: 100%; height: 36px;
  padding: 0 12px 0 32px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: var(--gray-50);
  font-size: 0.825rem;
  font-family: var(--font-sans);
  color: var(--text);
  transition: all 0.15s;
}
.top-bar-search input:focus {
  outline: none;
  border-color: var(--primary-400);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(0,86,210,0.1);
}

.search-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--rim2);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  max-height: 340px;
  overflow-y: auto;
}
.search-dropdown.open { display: block; }
.search-drop-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 9px 13px; cursor: pointer;
  border-bottom: 1px solid var(--rim);
  transition: background .12s;
}
.search-drop-item:last-child { border-bottom: none; }
.search-drop-item:hover,
.search-drop-item.focused { background: var(--primary-50); }
.search-drop-item-title {
  font-size: .84rem; font-weight: 500; color: var(--text);
}
.search-drop-item-meta {
  font-size: .75rem; color: var(--text2);
}
.search-drop-empty {
  padding: 14px 13px; font-size: .83rem; color: var(--text3); text-align: center;
}
.search-drop-header {
  padding: 6px 13px 4px;
  font-size: .7rem; font-weight: 600; color: var(--text3);
  text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--rim);
}
mark.sh { background: rgba(59,158,255,.18); color: var(--primary-600); border-radius: 2px; padding: 0 1px; }

.top-bar-quick-stats {
  display: flex; gap: 8px;
}

.tb-quick-stat {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  background: var(--gray-100);
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gray-600);
}

/* Floating Action Button */
.fab-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  height: 50px;
  padding: 0 22px;
  background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
  color: white;
  border: none;
  border-radius: 25px;
  font-weight: 600;
  font-size: 0.875rem;
  display: none;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: all 0.2s;
  z-index: 200;
  font-family: var(--font-sans);
}
.fab-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl);
}


/* ─── PRIORITY CARD (Today's Focus) ─── */
.priority-card {
  background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-800) 100%);
  border-radius: 12px; padding: 24px 28px; margin-bottom: 20px;
  color: #fff; position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  box-shadow: var(--shadow-md);
}
.priority-card::before {
  content: ''; position: absolute; top: -60px; right: -40px;
  width: 200px; height: 200px; border-radius: 50%;
  background: rgba(255,255,255,.08); pointer-events: none;
}
.priority-card::after {
  content: ''; position: absolute; bottom: -40px; left: -20px;
  width: 150px; height: 150px; border-radius: 50%;
  background: rgba(255,255,255,.05); pointer-events: none;
}
.priority-card-body { flex: 1; min-width: 200px; position: relative; z-index: 1; }
.priority-card-eyebrow { font-size: .7rem; opacity: .8; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 6px; }
.priority-card-title { font-family: var(--font-sans); font-size: 1.5rem; font-weight: 700; margin-bottom: 6px; }
.priority-card-sub { font-size: .84rem; opacity: .9; line-height: 1.5; margin-bottom: 16px; }
.priority-card-actions { display: flex; gap: 8px; flex-wrap: wrap; position: relative; z-index: 1; }
.btn-white { background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.3); color: #fff; padding: 8px 18px; border-radius: var(--r-sm); font-family: inherit; font-weight: 600; font-size: .82rem; cursor: pointer; transition: all .16s; backdrop-filter: blur(4px); }
.btn-white:hover { background: rgba(255,255,255,.3); }
.btn-white-solid { background: #fff; color: var(--accent2); padding: 8px 18px; border-radius: var(--r-sm); font-family: inherit; font-weight: 700; font-size: .82rem; cursor: pointer; border: none; transition: all .16s; }
.btn-white-solid:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.2); }
.priority-stats { display: flex; gap: 20px; flex-wrap: wrap; position: relative; z-index: 1; }
.priority-stat { text-align: center; }
.priority-stat-v { font-size: 1.8rem; font-weight: 700; font-family: var(--font-sans); line-height: 1; }
.priority-stat-l { font-size: .65rem; text-transform: uppercase; letter-spacing: 1px; opacity: .8; margin-top: 3px; font-weight: 600; }

/* ─── STUDY LANE ─── */
.study-lane {
  background: var(--surface); border: 1px solid var(--rim);
  border-radius: var(--r); padding: 20px 24px; margin-bottom: 16px;
}
.study-lane-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.study-lane-title { font-weight: 700; font-size: .9rem; }
.study-lane-steps { display: flex; align-items: center; gap: 0; }
.study-lane-step {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  border-radius: var(--r-sm); cursor: pointer; transition: all .16s;
  flex: 1; min-width: 0; border: 1px solid var(--rim);
  background: var(--surface2); position: relative;
}
.study-lane-step:not(:last-child) { margin-right: -1px; border-radius: var(--r-sm) 0 0 var(--r-sm); }
.study-lane-step:not(:first-child) { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.study-lane-step:only-child { border-radius: var(--r-sm); }
.study-lane-step:hover { background: var(--surface3); z-index: 1; }
.study-lane-step.step-learn { --step-color: var(--amber); }
.study-lane-step.step-practice { --step-color: var(--emerald); }
.study-lane-step.step-test { --step-color: var(--accent); }
.step-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--step-color); flex-shrink: 0; }
.step-label { font-weight: 600; font-size: .8rem; color: var(--text); }
.step-count { font-family: var(--font-mono); font-size: .72rem; color: var(--text3); margin-left: auto; }
.view { display: none; flex: 1; min-height: 0; overflow: hidden; flex-direction: column; height: 100%; }
.view.active {
  display: flex;
  animation: viewIn .2s var(--ease) both;
}
@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* Ensure scroll-area actually scrolls within the flex chain */
.scroll-area { flex: 1; overflow-y: auto; padding: 28px; min-height: 0; }
.sb-header { padding: 20px 16px 16px; border-bottom: 1px solid var(--rim); flex-shrink: 0; }
.sb-logo { display: flex; align-items: center; gap: 10px; }
.sb-logo-icon {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--violet));
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; flex-shrink: 0;
}
.sb-wordmark { font-family: var(--font-sans); font-size: 1.2rem; font-weight: 700; }
.sb-wordmark span { color: var(--accent); }

.sb-nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
/* Improvement #10 — two size levels for section labels only */
.sb-section { font-size: .68rem; letter-spacing: 1px; text-transform: uppercase; color: var(--text3); padding: 14px 10px 4px; font-weight: 700; }
.sb-item {
  display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: var(--r-sm);
  color: var(--text2); cursor: pointer; font-size: .83rem; font-weight: 500;
  transition: background .13s, color .13s; user-select: none; margin-bottom: 1px;
}
.sb-item:hover { background: var(--surface2); color: var(--text); }
.sb-item.active { background: rgba(59,158,255,.13); color: var(--accent); }
.sb-ic { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; font-size: .88rem; flex-shrink: 0; border-radius: var(--r-xs); background: var(--surface2); transition: background .13s; }
.sb-item.active .sb-ic { background: rgba(59,158,255,.18); }
.sb-item .sb-badge { margin-left: auto; font-family: var(--font-mono); font-size: .68rem; color: var(--text3); background: var(--surface3); padding: 2px 6px; border-radius: 8px; }
.sb-item.active .sb-badge { color: var(--accent); background: rgba(59,158,255,.14); }
/* Study loop step numbers */
.sb-step { width: 16px; height: 16px; border-radius: 50%; background: var(--surface3); border: 1px solid var(--rim2); font-size: .6rem; font-weight: 700; display: flex; align-items: center; justify-content: center; color: var(--text3); flex-shrink: 0; margin-left: auto; }
.sb-item.active .sb-step { background: rgba(59,158,255,.18); border-color: rgba(59,158,255,.3); color: var(--accent); }
/* Streak in sidebar */
.sb-streak { display: flex; align-items: center; gap: 7px; padding: 6px 11px; color: var(--amber); font-size: .78rem; font-weight: 600; }
.sb-streak-ic { font-size: .9rem; }

.sb-footer { padding: 14px; border-top: 1px solid var(--rim); flex-shrink: 0; }
.sb-prog-row { display: flex; justify-content: space-between; font-size: .75rem; color: var(--text2); margin-bottom: 7px; }
.sb-prog-row b { color: var(--text); font-weight: 700; }
.sb-bar-track { background: var(--surface3); border-radius: 99px; height: 3px; }
.sb-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--emerald)); border-radius: 99px; transition: width .6s var(--ease); }

/* Streak heatmap */
.streak-heatmap { display: flex; gap: 4px; margin-top: 8px; }
.streak-day { width: 14px; height: 14px; border-radius: 3px; background: var(--surface3); transition: background .2s; flex-shrink: 0; }
.streak-day.active { background: var(--emerald); }

/* ─── TOPBAR ─── */
#topbar {
  background: var(--surface); border-bottom: 1px solid var(--rim);
  height: 52px; display: flex; align-items: center; padding: 0 18px; gap: 0; flex-shrink: 0; z-index: 50;
}
/* Left zone: menu + breadcrumb */
.tb-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.tb-title { font-size: .88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Center zone: student identity — improvement #1 (moved from sidebar) */
.tb-student {
  display: flex; align-items: center; gap: 8px; padding: 4px 10px;
  border-radius: var(--r-sm); cursor: pointer; transition: background .14s;
  border: 1px solid transparent;
}
.tb-student:hover { background: var(--surface2); border-color: var(--rim); }
.tb-student-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--violet));
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.tb-student-name { font-size: .8rem; font-weight: 600; color: var(--text); }
/* Right zone: actions */
.tb-actions { display: flex; align-items: center; gap: 8px; }
.tb-sep { width: 1px; height: 14px; background: var(--rim2); margin: 0 4px; }
.tb-stat { display: flex; align-items: center; gap: 4px; font-size: .75rem; color: var(--text2); }
.tb-stat strong { color: var(--text); font-weight: 600; }
#menuBtn { display: none; width: 32px; height: 32px; align-items: center; justify-content: center; background: var(--surface2); border: 1px solid var(--rim); border-radius: var(--r-xs); cursor: pointer; flex-shrink: 0; }
.theme-btn { background: var(--surface2); border: 1px solid var(--rim); border-radius: 20px; padding: 4px 11px; cursor: pointer; font-size: .76rem; color: var(--text2); font-family: inherit; transition: all .18s; display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.theme-btn:hover { color: var(--text); border-color: var(--rim2); }

/* ─── BUTTONS ─── */
.btn { border: none; cursor: pointer; font-family: inherit; font-weight: 500; border-radius: 8px; transition: all .15s; font-size: .825rem; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.btn-primary { background: var(--primary-500); color: #fff; padding: 8px 18px; border: 1px solid var(--primary-600); }
.btn-primary:hover { background: var(--primary-600); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--surface); color: var(--gray-700); padding: 8px 16px; border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-300); }
.btn-ghost { background: transparent; color: var(--text2); padding: 8px 13px; }
.btn-ghost:hover { color: var(--text); background: var(--surface2); }
.btn-emerald { background: var(--emerald); color: #041a10; padding: 8px 18px; font-weight: 700; }
.btn-emerald:hover { opacity: .88; }
.btn-amber { background: var(--amber); color: #1a0f00; padding: 8px 18px; font-weight: 700; }
.btn-amber:hover { opacity: .88; }
.btn-sm { padding: 6px 13px; font-size: .74rem; }
.btn-xs { padding: 3px 9px; font-size: .68rem; }
.btn:disabled { opacity: .38; cursor: not-allowed; transform: none !important; }

/* ─── CONTENT ─── */
#content { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
/* Ensure #main properly passes height down to views */
#main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.scroll-area { flex: 1; overflow-y: auto; padding: 28px; min-height: 0; }
.max-w { max-width: 1080px; margin: 0 auto; width: 100%; }

/* ─── LOADING ─── */
#loadingScreen {
  position: fixed; inset: 0; background: var(--bg); z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
}
.loader-pulse { position: relative; width: 56px; height: 56px; }
.loader-pulse::before, .loader-pulse::after { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; animation: pulse-ring 1.8s ease infinite; }
.loader-pulse::after { animation-delay: .9s; }
.loader-core { position: absolute; inset: 9px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--violet)); animation: pulse-core 1.8s ease infinite; }
@keyframes pulse-ring { 0%{transform:scale(.5);opacity:.8} 100%{transform:scale(1.6);opacity:0} }
@keyframes pulse-core { 0%,100%{transform:scale(.85)} 50%{transform:scale(1)} }
.loader-title { font-family: var(--font-sans); font-size: 1.5rem; font-weight: 700; }
.loader-title span { color: var(--accent); }
.loader-sub { font-size: .8rem; color: var(--text2); }
.loader-bar { width: 240px; height: 3px; background: var(--surface2); border-radius: 99px; }
.loader-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--emerald)); border-radius: 99px; transition: width .3s; }
.loader-status { font-size: .7rem; color: var(--text3); }

/* ─── DASHBOARD ─── */
/* Improvement #4: Hero as daily brief, not generic gradient box */
.hero {
  border-radius: var(--r); padding: 28px 32px; margin-bottom: 20px;
  background: var(--surface); border: 1px solid var(--rim);
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center;
}
.hero::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(59,158,255,.04) 0%, transparent 60%);
  pointer-events: none;
}
.hero-left { min-width: 0; }
.hero-eyebrow { font-size: .75rem; color: var(--text3); font-weight: 500; margin-bottom: 6px; }
.hero-title { font-family: var(--font-sans); font-size: 1.75rem; font-weight: 700; margin-bottom: 6px; line-height: 1.2; }
.hero-sub { color: var(--text2); font-size: .875rem; line-height: 1.65; }
.hero-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
/* Daily brief panel inside hero */
.hero-brief {
  display: flex; flex-direction: column; gap: 8px; min-width: 200px;
  padding: 16px 20px; background: var(--surface2); border-radius: var(--r-sm);
  border: 1px solid var(--rim);
}
.hero-brief-label { font-size: .68rem; color: var(--text3); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 2px; }
.hero-brief-item { display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--text2); }
.hero-brief-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.hero-brief-count { font-family: var(--font-mono); font-weight: 700; color: var(--text); font-size: .78rem; margin-left: auto; }

/* ─── DASHBOARD GRID ─── */
/* Improvement #4: 2fr 1fr ratio */
.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 20px; min-width: 0; }
@media(max-width:1024px) { .dash-grid { grid-template-columns: 1fr; } }

/* KPI row — improvement #9: 4 equal (no longer need primary span) */
.kpi-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; margin-bottom: 16px; }
@media(max-width:720px) { .kpi-grid { grid-template-columns: repeat(2,1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--rim); border-radius: var(--r); padding: 18px 16px; position: relative; overflow: hidden; transition: transform .18s, box-shadow .18s; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.kpi::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--kpi-color, var(--accent)); }
/* Improvement #6 — consolidate label sizes: use exactly .75rem here */
.kpi-label { font-size: .75rem; color: var(--text2); font-weight: 600; margin-bottom: 7px; }
.kpi-val { font-family: var(--font-sans); font-size: 1.85rem; font-weight: 700; line-height: 1; }
.kpi-note { font-size: .75rem; color: var(--text2); margin-top: 5px; }
.kpi-delta { font-size: .72rem; font-weight: 700; padding: 2px 6px; border-radius: 5px; display: inline-block; margin-top: 4px; }
.kpi-delta.up { color: var(--emerald); background: rgba(0,212,158,.1); }
.kpi-delta.down { color: var(--ruby); background: rgba(255,79,101,.1); }

/* Today's Plan card */
.plan-card { background: var(--surface); border: 1px solid var(--rim); border-radius: var(--r); padding: 20px; height: 100%; }
.plan-card-title { display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: .9rem; margin-bottom: 14px; }
.plan-card-title .plan-date { margin-left: auto; font-size: .75rem; color: var(--text3); font-family: var(--font-mono); }
.plan-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; }
.plan-item:not(:last-child) { border-bottom: 1px solid var(--rim); }
.plan-item-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.plan-item-label { font-size: .84rem; color: var(--text2); flex: 1; }
.plan-item-count { font-family: var(--font-mono); font-size: .75rem; color: var(--text); font-weight: 600; }
.plan-start-btn { width: 100%; margin-top: 14px; }

/* Weak areas card — improvement #8: neutral, accent-only percentages */
.weak-card { background: var(--surface); border: 1px solid var(--rim); border-radius: var(--r); padding: 18px; margin-bottom: 16px; }
.dash-tips-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 24px; }
@media(max-width:640px) { .dash-tips-grid { grid-template-columns: 1fr; } }
.dash-tip { display: flex; gap: 11px; align-items: flex-start; }
.dash-tip-key { font-size: .95rem; width: 24px; flex-shrink: 0; margin-top: 1px; }
.dash-tip-name { font-size: .81rem; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.dash-tip-desc { font-size: .76rem; color: var(--text2); line-height: 1.55; }
.weak-card-title { display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: .875rem; color: var(--text); margin-bottom: 12px; }
.weak-item { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.weak-item:not(:last-child) { border-bottom: 1px solid var(--rim); }
.weak-topic { font-size: .84rem; color: var(--text); flex: 1; }
.weak-pct { font-family: var(--font-mono); font-size: .75rem; font-weight: 700; color: var(--ruby); }
.weak-bar-track { width: 56px; height: 3px; background: var(--surface3); border-radius: 99px; flex-shrink: 0; }
.weak-bar-fill { height: 100%; border-radius: 99px; background: var(--ruby); opacity: .65; }
/* improvement #21: What to do next card on Progress */
.next-action-card {
  background: linear-gradient(135deg, var(--surface2) 0%, var(--surface3) 100%);
  border: 1px solid rgba(59,158,255,.18); border-radius: var(--r); padding: 20px;
  margin-bottom: 20px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.next-action-icon { font-size: 2rem; flex-shrink: 0; }
.next-action-body { flex: 1; min-width: 200px; }
.next-action-label { font-size: .68rem; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); font-weight: 700; margin-bottom: 4px; }
.next-action-title { font-weight: 600; font-size: .95rem; margin-bottom: 4px; }
.next-action-sub { font-size: .82rem; color: var(--text2); line-height: 1.5; }

/* Section header */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-title { font-family: var(--font-sans); font-size: 1rem; font-weight: 600; color: var(--gray-700); }
.section-link { font-size: .8rem; color: var(--accent); cursor: pointer; font-weight: 500; }
.section-link:hover { text-decoration: underline; }

/* Module grid */
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin-bottom: 24px; }
.module-card { background: var(--surface); border: 1px solid var(--rim); border-radius: var(--r); padding: 16px; cursor: pointer; transition: border-color .18s, transform .18s, box-shadow .18s; }
.module-card:hover, .module-card:focus-visible { border-color: rgba(59,158,255,.35); transform: translateY(-2px); box-shadow: var(--shadow-sm); outline: 2px solid var(--accent); outline-offset: 2px; }
.module-code { font-family: var(--font-mono); font-size: .68rem; color: var(--accent); margin-bottom: 5px; font-weight: 500; }
.module-title { font-weight: 600; font-size: .875rem; margin-bottom: 9px; line-height: 1.4; }
.module-meta { display: flex; gap: 10px; font-size: .75rem; color: var(--text3); margin-bottom: 10px; }
.module-prog-bar { background: var(--surface3); border-radius: 99px; height: 3px; }
.module-prog-fill { height: 100%; border-radius: 99px; transition: width .5s; }

/* ─── LESSONS ─── */
#lessonsShell {
  display: grid;
  grid-template-columns: 210px 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-top: 1px solid var(--rim);
}
#lessonsShell > * { min-height: 0; overflow: hidden; }

.ll-list-panel {
  background: var(--surface);
  border-right: 1px solid var(--rim);
  display: flex;
  flex-direction: column;
}
/* improvement #7 — no uppercase on panel header, just weight */
.ll-panel-header { padding: 14px; border-bottom: 1px solid var(--rim); flex-shrink: 0; }
.ll-panel-title { font-size: .8rem; font-weight: 700; color: var(--text); }
.ll-list { flex: 1; overflow-y: auto; }
.ll-item { display: flex; align-items: center; gap: 9px; padding: 9px 12px; cursor: pointer; transition: background .1s; border-radius: var(--r-xs); margin: 2px 6px; }
.ll-item:hover { background: var(--surface2); }
.ll-item.active { background: rgba(59,158,255,.1); border-left: 2px solid var(--accent); padding-left: 10px; margin-left: 3px; border-radius: 0 var(--r-xs) var(--r-xs) 0; }
/* improvement #6 — .68rem as minimum instead of .58rem */
.ll-num { font-family: var(--font-mono); font-size: .68rem; color: var(--text3); flex-shrink: 0; width: 22px; }
.ll-name { font-size: .8rem; color: var(--text2); line-height: 1.4; flex: 1; }
.ll-item.active .ll-name { color: var(--accent); font-weight: 500; }
/* Completed lesson — clearly marked */
.ll-item.done { background: rgba(16,185,129,.06); }
.ll-item.done .ll-name { color: var(--text3); text-decoration: line-through; text-decoration-color: var(--emerald); }
.ll-item.done .ll-check { color: var(--emerald); font-size: .85rem; font-weight: 700; }
.ll-item.active.done .ll-name { color: var(--accent); text-decoration: none; }

.lc-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  min-width: 0;
  overflow: hidden; /* ensures lc-nav is never pushed off screen */
}
/* improvement #3: tighter padding for reading column */
.lc-header { padding: 22px clamp(16px, 4vw, 56px) 16px; background: var(--surface); border-bottom: 1px solid var(--rim); flex-shrink: 0; }
.lc-badge { font-family: var(--font-mono); font-size: .68rem; color: var(--accent); margin-bottom: 7px; }
.lc-title { font-family: var(--font-sans); font-size: 1.55rem; font-weight: 500; margin-bottom: 7px; }
.lc-meta { display: flex; gap: 14px; font-size: .75rem; color: var(--text3); }
.lc-body {
  flex: 1;
  overflow-y: auto;
  padding: 36px clamp(16px, 4vw, 56px);
}
.lc-body-inner {
  max-width: 100%;
  width: 100%;
}
.lc-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px clamp(16px, 4vw, 56px);
  border-top: 1px solid var(--rim);
  background: var(--surface);
  flex-shrink: 0;
}

/* Lesson content */
.ls-section { margin-bottom: 28px; }
/* improvement #7: no uppercase on section labels */
.ls-section-label { font-size: .75rem; font-weight: 700; color: var(--text3); margin-bottom: 11px; display: flex; align-items: center; gap: 8px; }
.ls-section-label::after { content: ''; flex: 1; height: 1px; background: var(--rim); }
.content-block { background: var(--surface); border: 1px solid var(--rim); border-radius: var(--r-sm); padding: 15px 18px; margin-bottom: 9px; }
.content-block-title { font-weight: 600; font-size: .875rem; margin-bottom: 5px; }
.content-block-text { font-size: .9rem; color: var(--text2); line-height: 1.85; }
.cb-para { margin: 0 0 10px 0; }
.cb-para:last-child { margin-bottom: 0; }
.cb-subhead {
  font-size: .79rem; font-weight: 700; color: var(--text);
  margin: 16px 0 5px; padding-bottom: 4px;
  border-bottom: 1px solid var(--rim);
  text-transform: uppercase; letter-spacing: .4px;
}
.cb-subhead:first-child { margin-top: 4px; }
.callout { border-left: 3px solid; padding: 11px 15px; border-radius: 0 var(--r-sm) var(--r-sm) 0; margin-bottom: 9px; }
/* improvement #7: no uppercase callout labels */
.callout-label { font-weight: 700; font-size: .75rem; margin-bottom: 4px; }
.callout-text { font-size: .84rem; color: var(--text2); line-height: 1.7; }
.callout.hy { border-color: var(--amber); background: rgba(255,185,48,.04); }
.callout.hy .callout-label { color: var(--amber); }
.callout.cl { border-color: var(--emerald); background: rgba(0,212,158,.04); }
.callout.cl .callout-label { color: var(--emerald); }
.callout.nt { border-color: var(--accent); background: rgba(59,158,255,.04); }
.callout.nt .callout-label { color: var(--accent); }
.callout.cc { border-color: var(--violet); background: rgba(160,126,248,.04); }
.callout.cc .callout-label { color: var(--violet); }
.callout-list { margin: 6px 0 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 7px; }
.callout-list li { font-size: .84rem; color: var(--text2); line-height: 1.65; }

/* Active recall prompt */
.recall-prompt { border: 1px solid rgba(59,158,255,.25); border-radius: var(--r); padding: 16px 18px; margin: 20px 0; background: rgba(59,158,255,.04); }
.recall-prompt-label { font-size: .75rem; font-weight: 700; color: var(--accent); margin-bottom: 7px; display: flex; align-items: center; gap: 6px; }
.recall-q { font-size: .875rem; color: var(--text); line-height: 1.6; margin-bottom: 10px; font-weight: 500; }
.recall-reveal-btn { font-size: .75rem; color: var(--accent); background: none; border: 1px solid rgba(59,158,255,.3); border-radius: 6px; padding: 5px 12px; cursor: pointer; font-family: inherit; font-weight: 600; transition: all .15s; }
.recall-reveal-btn:hover { background: rgba(59,158,255,.1); }
.recall-answer { margin-top: 10px; padding: 10px 12px; background: rgba(59,158,255,.06); border-radius: var(--r-xs); font-size: .84rem; color: var(--text2); line-height: 1.65; display: none; }
.recall-answer.show { display: block; animation: fadeUp .2s var(--ease); }

.terms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 9px; }
.term-card { background: var(--surface); border: 1px solid var(--rim); border-radius: var(--r-sm); padding: 12px; }
.term-name { font-weight: 600; font-size: .84rem; margin-bottom: 2px; }
.term-pron { font-family: var(--font-mono); font-size: .68rem; color: var(--accent); margin-bottom: 4px; }
.term-def { font-size: .8rem; color: var(--text2); line-height: 1.55; }
.obj-list { list-style: none; }
.obj-list li { padding: 7px 0; border-bottom: 1px solid var(--rim); font-size: .84rem; color: var(--text2); display: flex; gap: 9px; align-items: flex-start; line-height: 1.6; }
.obj-list li::before { content: '—'; color: var(--accent); flex-shrink: 0; font-weight: 700; }
.kp-list { list-style: none; display: grid; gap: 7px; }
.kp-list li { padding: 9px 13px; background: var(--surface); border-radius: var(--r-sm); border-left: 3px solid var(--violet); font-size: .84rem; color: var(--text2); line-height: 1.58; }
.ref-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
/* improvement #7: no uppercase on table headers */
.ref-table th { background: var(--surface3); padding: 8px 12px; text-align: left; font-size: .75rem; border-bottom: 1px solid var(--rim); font-weight: 700; }
.ref-table td { padding: 8px 12px; color: var(--text2); border-bottom: 1px solid var(--rim); vertical-align: top; line-height: 1.45; }

/* Quick check */
.qc-wrap { background: var(--surface); border: 1px solid var(--rim); border-radius: var(--r); padding: 18px; margin-bottom: 11px; }
.qc-stem { font-weight: 600; font-size: .875rem; margin-bottom: 12px; line-height: 1.6; }
.qc-opts { display: grid; gap: 7px; }
.qc-opt { background: var(--surface2); border: 1px solid var(--rim); border-radius: var(--r-sm); padding: 9px 13px; cursor: pointer; font-size: .84rem; color: var(--text2); transition: all .13s; }
.qc-opt:hover:not([data-locked]) { border-color: var(--accent); color: var(--text); }
.qc-opt.correct { border-color: var(--emerald); background: rgba(0,212,158,.07); color: var(--emerald); }
.qc-opt.wrong { border-color: var(--ruby); background: rgba(255,79,101,.07); color: var(--ruby); }
.qc-exp { margin-top: 10px; padding: 11px 13px; background: rgba(59,158,255,.05); border-radius: var(--r-xs); font-size: .82rem; color: var(--text2); line-height: 1.65; display: none; border: 1px solid rgba(59,158,255,.14); }
.qc-exp.show { display: block; }

/* Chips */
.chips-bar { padding: 12px 18px; border-bottom: 1px solid var(--rim); flex-shrink: 0; background: var(--surface); }
/* improvement #7: no uppercase on chips label */
.chips-label { font-size: .75rem; font-weight: 700; color: var(--text3); margin-bottom: 9px; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chip { background: var(--surface2); border: 1px solid var(--rim2); border-radius: 99px; padding: 4px 13px; font-size: .78rem; color: var(--text2); cursor: pointer; transition: all .13s; user-select: none; font-weight: 500; }
.chip.active { background: rgba(59,158,255,.13); border-color: rgba(59,158,255,.4); color: var(--accent); font-weight: 700; }
.chip:hover:not(.active) { color: var(--text); background: var(--surface3); }

/* ─── FLASHCARDS ─── */
.fc-view-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center; padding: 24px 24px 48px; min-height: 0; }
.fc-header-meta { display: flex; align-items: center; justify-content: space-between; width: 100%; max-width: 700px; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
.fc-counter { font-size: .8rem; color: var(--text2); }
.fc-counter strong { color: var(--text); }
.fc-queue-info { display: flex; gap: 12px; align-items: center; font-size: .75rem; }
.fc-queue-badge { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; }
.fc-queue-badge.again { color: var(--ruby); }
.fc-queue-badge.hard { color: var(--amber); }

.fc-prog-track { width: 100%; max-width: 700px; height: 4px; background: var(--surface3); border-radius: 99px; margin-bottom: 28px; }
.fc-prog-fill { height: 100%; background: linear-gradient(90deg, var(--primary-500), var(--success)); border-radius: 99px; transition: width .4s var(--ease); }

/* Card stage: uses padding-bottom trick so height = width * ratio, accommodating absolute children */
.card-stage {
  width: 100%;
  max-width: 700px;
  perspective: 1800px;
  cursor: pointer;
  flex-shrink: 0;
  margin-bottom: 0;
  height: 280px; /* explicit fixed height so absolute children are visible */
  position: relative;
}
.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .5s cubic-bezier(.4,0,.2,1);
}
.card-inner.flipped { transform: rotateY(180deg); }
.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 40px 36px;
  text-align: center;
  border: 1px solid var(--gray-200);
  box-shadow: 0 2px 12px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06);
  overflow-y: auto;
}
.card-front {
  background: var(--surface);
}
.card-back {
  background: linear-gradient(145deg, var(--gray-50), var(--gray-100));
  transform: rotateY(180deg);
}
.card-tag-chip { position: absolute; top: 14px; left: 14px; background: var(--gray-100); border: 1px solid var(--gray-200); border-radius: 99px; padding: 3px 10px; font-size: .68rem; color: var(--gray-500); font-weight: 600; }
.card-repeat-badge { position: absolute; top: 14px; right: 14px; border-radius: 99px; padding: 3px 10px; font-size: .68rem; font-weight: 700; }
.card-repeat-badge.again { background: rgba(229,62,62,.1); border: 1px solid rgba(229,62,62,.3); color: var(--danger); }
.card-repeat-badge.hard { background: rgba(245,166,35,.1); border: 1px solid rgba(245,166,35,.3); color: var(--warning); }
.card-hint { position: absolute; bottom: 14px; font-size: .72rem; color: var(--gray-400); display: flex; align-items: center; gap: 4px; }
.card-label { font-size: .65rem; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--gray-400); margin-bottom: 16px; }
.card-back .card-label { color: var(--success); }
.card-q-text { font-size: 1.1rem; font-weight: 500; color: var(--gray-800); line-height: 1.65; max-width: 580px; }
.card-a-text { font-size: .95rem; color: var(--gray-600); line-height: 1.75; max-width: 580px; }
.card-sm2-info { position: absolute; bottom: 14px; right: 14px; font-family: var(--font-mono); font-size: .65rem; color: var(--gray-400); }

/* Rate buttons — clear, well-spaced */
.rate-btns {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  margin-bottom: 16px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  max-width: 700px;
}
.rate-btn {
  padding: 12px 22px;
  border: 1.5px solid;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: .875rem;
  transition: all .18s var(--ease);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 100px;
  flex: 1;
  max-width: 160px;
  min-height: 60px;
  justify-content: center;
  background: var(--surface);
}
.rate-btn .rate-next { font-size: .7rem; font-weight: 400; opacity: .65; }
.rate-btn.again { border-color: rgba(229,62,62,.5); color: var(--danger); }
.rate-btn.again:hover { background: var(--danger); color: #fff; border-color: var(--danger); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(229,62,62,.3); }
.rate-btn.again:active { animation: pulse-again .3s var(--ease); }
.rate-btn.hard { border-color: rgba(245,166,35,.5); color: var(--warning); }
.rate-btn.hard:hover { background: var(--warning); color: #fff; border-color: var(--warning); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(245,166,35,.3); }
.rate-btn.good { border-color: rgba(0,168,107,.5); color: var(--success); }
.rate-btn.good:hover { background: var(--success); color: #fff; border-color: var(--success); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,168,107,.3); }
.rate-btn.good:active { animation: glow-good .4s var(--ease); }
.rate-btn.easy { border-color: rgba(59,158,255,.5); color: var(--info); }
.rate-btn.easy:hover { background: var(--info); color: #fff; border-color: var(--info); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(59,158,255,.3); }
.rate-btn.easy:active { animation: expand-easy .35s var(--ease); }

@keyframes pulse-again { 0%{box-shadow:0 0 0 0 rgba(255,79,101,.4)} 70%{box-shadow:0 0 0 10px rgba(255,79,101,0)} 100%{box-shadow:0 0 0 0 rgba(255,79,101,0)} }
@keyframes glow-good { 0%{box-shadow:0 0 0 0 rgba(0,212,158,.4)} 70%{box-shadow:0 0 0 10px rgba(0,212,158,0)} 100%{box-shadow:0 0 0 0 rgba(0,212,158,0)} }
@keyframes expand-easy { 0%{transform:scale(1)} 50%{transform:scale(1.06)} 100%{transform:scale(1)} }

/* improvement #11: score row HIDDEN during study, shown on completion only */
.fc-score-row { display: flex; gap: 24px; margin-bottom: 16px; }
.fcs { text-align: center; }
.fcs-v { font-size: 1.1rem; font-weight: 700; font-family: var(--font-sans); }
.fcs-v.g { color: var(--emerald); }
.fcs-v.b { color: var(--accent); }
.fcs-v.y { color: var(--amber); }
.fcs-v.r { color: var(--ruby); }
.fcs-l { font-size: .68rem; color: var(--text3); margin-top: 2px; }
.fc-nav-row { display: flex; gap: 7px; }
.fc-done-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 44px 28px; text-align: center; max-width: 480px; gap: 14px; }
.fc-done-icon { font-size: 2.8rem; }
.fc-done-title { font-family: var(--font-sans); font-size: 1.5rem; }
.fc-done-sub { font-size: .875rem; color: var(--text2); line-height: 1.65; }

/* ─── LESSONS DASHBOARD ─── */
.ls-dashboard {
  flex: 1; overflow-y: auto; padding: 24px; min-height: 0;
}
.ls-study-panel { flex: 1; overflow: hidden; display: none; flex-direction: column; }
.ls-study-panel.active { display: flex; }
.ls-study-topbar {
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--rim);
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
}
.ls-study-topbar-mod { font-weight: 600; font-size: .85rem; flex: 1; }
.ls-study-topbar-progress { font-family: var(--font-mono); font-size: .72rem; color: var(--text3); display:flex; gap:8px; align-items:center; }
.ls-mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.ls-mod-card {
  background: var(--surface); border: 1px solid var(--rim);
  border-radius: var(--r); padding: 18px 20px; cursor: pointer;
  transition: all .18s var(--ease); position: relative; overflow: hidden;
}
.ls-mod-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--deck-color, var(--accent));
}
.ls-mod-card:hover { border-color: rgba(59,158,255,.4); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.ls-mod-card:hover .ls-mod-start { opacity: 1; }
.ls-mod-card.all-done { opacity: .82; }
.ls-mod-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.ls-mod-code { font-family: var(--font-mono); font-size: .6rem; color: var(--accent); font-weight: 500; }
.ls-mod-start { font-size: .7rem; font-weight: 700; color: var(--accent); opacity: 0.45; transition: opacity .15s; }
.ls-mod-name { font-weight: 600; font-size: .88rem; line-height: 1.4; margin-bottom: 10px; }
.ls-mod-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.ls-mod-badge {
  font-family: var(--font-mono); font-size: .72rem; font-weight: 700;
  padding: 3px 9px; border-radius: 6px; display: flex; align-items: center; gap: 4px;
}
.ls-mod-badge.done { background: rgba(0,212,158,.1); color: var(--emerald); }
.ls-mod-badge.remaining { background: rgba(59,158,255,.1); color: var(--accent); }
.ls-mod-badge.total { background: var(--surface3); color: var(--text3); }
.ls-mod-bar-wrap { height: 3px; background: var(--surface3); border-radius: 99px; }
.ls-mod-bar-fill { height: 100%; border-radius: 99px; }
.ls-mod-total { margin-top: 7px; font-size: .68rem; color: var(--text3); }
/* Reset buttons */
.btn-danger { background: rgba(255,79,101,.1); color: var(--ruby); border: 1px solid rgba(255,79,101,.25); padding: 6px 14px; font-size: .74rem; }
.btn-danger:hover { background: rgba(255,79,101,.2); border-color: var(--ruby); }
/* Quiz gate */
.quiz-gate-notice {
  margin-top: 12px; padding: 12px 16px;
  background: rgba(255,185,48,.06); border: 1px solid rgba(255,185,48,.25);
  border-radius: var(--r-sm); font-size: .82rem; color: var(--amber); line-height: 1.6;
}
.quiz-gate-notice.pass { background: rgba(0,212,158,.06); border-color: rgba(0,212,158,.25); color: var(--emerald); }
.quiz-score-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--surface2); border-radius: var(--r-sm);
  margin-top: 8px; font-size: .82rem;
}
.quiz-score-val { font-family: var(--font-sans); font-size: 1.3rem; font-weight: 700; }
.quiz-score-val.pass { color: var(--emerald); }
.quiz-score-val.fail { color: var(--ruby); }

/* ─── FLASHCARD DASHBOARD (Anki-style) ─── */
.fc-dashboard {
  flex: 1; overflow-y: auto; padding: 24px; min-height: 0;
}
.fc-dash-hero {
  border-radius: var(--r); padding: 28px 32px; margin-bottom: 22px;
  background: linear-gradient(135deg, var(--surface2) 0%, var(--surface3) 100%);
  border: 1px solid var(--rim); position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.fc-dash-hero::after { content: ''; position: absolute; top: -40px; right: -40px; width: 200px; height: 200px; border-radius: 50%; background: radial-gradient(circle, rgba(160,126,248,.15), transparent 70%); pointer-events: none; }
.fc-dash-hero-text { flex: 1; min-width: 220px; }
.fc-dash-hero-title { font-family: var(--font-sans); font-size: 1.6rem; font-weight: 700; margin-bottom: 5px; }
.fc-dash-hero-sub { font-size: .83rem; color: var(--text2); line-height: 1.6; }
.fc-dash-stats { display: flex; gap: 22px; flex-wrap: wrap; }
.fc-dash-stat { text-align: center; }
.fc-dash-stat-v { font-family: var(--font-sans); font-size: 1.6rem; font-weight: 700; line-height: 1; }
.fc-dash-stat-v.new { color: var(--accent); }
.fc-dash-stat-v.due { color: var(--amber); }
.fc-dash-stat-v.done { color: var(--emerald); }
.fc-dash-stat-l { font-size: .62rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text3); margin-top: 3px; font-weight: 600; }

.fc-deck-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}
.fc-deck-card {
  background: var(--surface); border: 1px solid var(--rim);
  border-radius: var(--r); padding: 18px 20px; cursor: pointer;
  transition: all .18s var(--ease); position: relative; overflow: hidden;
}
.fc-deck-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--deck-color, var(--accent));
}
.fc-deck-card:hover { border-color: rgba(59,158,255,.4); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.fc-deck-card:hover .fc-deck-start { opacity: 1; }
.fc-deck-card.all-done { opacity: .75; }
.fc-deck-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.fc-deck-code { font-family: var(--font-mono); font-size: .6rem; color: var(--accent); font-weight: 500; }
.fc-deck-start { opacity: 0; font-size: .7rem; font-weight: 700; color: var(--accent); transition: opacity .15s; }
.fc-deck-name { font-weight: 600; font-size: .88rem; line-height: 1.4; margin-bottom: 12px; }
.fc-deck-counts { display: flex; gap: 10px; margin-bottom: 12px; }
.fc-deck-count {
  display: flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: .75rem; font-weight: 700;
  padding: 3px 9px; border-radius: 6px;
}
.fc-deck-count.new { background: rgba(59,158,255,.1); color: var(--accent); }
.fc-deck-count.due { background: rgba(255,185,48,.1); color: var(--amber); }
.fc-deck-count.done { background: rgba(0,212,158,.1); color: var(--emerald); }
.fc-deck-count.empty { background: var(--surface3); color: var(--text3); }
.fc-deck-bar-wrap { height: 3px; background: var(--surface3); border-radius: 99px; }
.fc-deck-bar-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--emerald)); }
.fc-deck-total { margin-top: 7px; font-size: .68rem; color: var(--text3); }

.fc-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; margin-top: 4px; }
.fc-section-title { font-family: var(--font-sans); font-size: 1.15rem; font-weight: 500; }

/* Flashcard study panel (now a sub-view within flashcards) */
.fc-study-panel { flex: 1; overflow: hidden; display: none; flex-direction: column; }
.fc-study-panel.active { display: flex; }
.fc-study-topbar {
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--rim);
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
}
.fc-study-topbar-deck { font-weight: 600; font-size: .85rem; flex: 1; }
.fc-study-topbar-count { font-family: var(--font-mono); font-size: .72rem; color: var(--text3); }

/* ─── QUESTION BANK DASHBOARD (NEW) ─── */

.qb-page-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px;
}
.qb-page-title {
  font-family: var(--font-sans); font-size: 1.4rem; font-weight: 700; color: var(--text);
}
.qb-reset-btn {
  background: var(--surface); border: 1.5px solid var(--ruby); color: var(--ruby);
  padding: 7px 16px; font-size: .8rem; font-weight: 600; border-radius: var(--r-sm);
  cursor: pointer; transition: all .15s; display: inline-flex; align-items: center; gap: 6px; opacity: 0.85;
}
.qb-reset-btn:hover { background: var(--ruby); color: #fff; opacity: 1; box-shadow: 0 2px 8px rgba(229,62,62,.25); }

.qb-dashboard {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  min-height: 0;
}
.qb-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}
.qb-stat-card {
  background: var(--surface);
  border: 1px solid var(--rim);
  border-radius: var(--r);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.qb-stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--stat-color, var(--accent));
}
.qb-stat-value {
  font-family: var(--font-sans);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}
.qb-stat-label {
  font-size: .75rem;
  font-weight: 700;
  color: var(--text3);
}
.qb-stat-note {
  font-size: .75rem;
  color: var(--text2);
  margin-top: 8px;
}

/* Module selection area */
.module-selection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.module-selection-title {
  font-family: var(--font-sans);
  font-size: 1.3rem;
  font-weight: 500;
}
.module-selection-actions {
  display: flex;
  gap: 8px;
}
.module-grid-selectable {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.module-card-selectable {
  background: var(--surface);
  border: 2px solid var(--rim);
  border-radius: var(--r);
  padding: 18px;
  cursor: pointer;
  transition: all .18s var(--ease);
  position: relative;
}
.module-card-selectable:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.module-card-selectable.selected {
  border-color: var(--accent);
  background: rgba(59,158,255,.05);
}
.module-card-selectable.selected::before {
  content: '✓';
  position: absolute;
  top: 12px;
  right: 12px;
  width: 24px;
  height: 24px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
}
.module-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.module-card-code {
  font-family: var(--font-mono);
  font-size: .65rem;
  color: var(--accent);
  font-weight: 500;
}
.module-card-count {
  font-size: .65rem;
  color: var(--text3);
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: 99px;
}
.module-card-title {
  font-weight: 600;
  font-size: .9rem;
  margin-bottom: 12px;
  line-height: 1.4;
}
.module-card-stats {
  display: flex;
  gap: 12px;
  font-size: .7rem;
  color: var(--text2);
  margin-bottom: 12px;
}
.module-card-progress {
  display: flex;
  align-items: center;
  gap: 8px;
}
.module-card-progress-bar {
  flex: 1;
  height: 4px;
  background: var(--surface3);
  border-radius: 99px;
}
.module-card-progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width .3s;
}

/* Question type selector */
.question-type-selector {
  background: var(--surface2);
  border: 1px solid var(--rim);
  border-radius: var(--r);
  padding: 20px;
  margin-top: 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.question-type-label {
  font-size: .8rem;
  font-weight: 700;
  color: var(--text3);
}
.question-type-options {
  display: flex;
  gap: 12px;
  flex: 1;
}
.question-type-option {
  background: var(--surface3);
  border: 1px solid var(--rim2);
  border-radius: 99px;
  padding: 8px 20px;
  font-size: .8rem;
  color: var(--text2);
  cursor: pointer;
  transition: all .15s;
  font-weight: 500;
}
.question-type-option:hover {
  border-color: var(--accent);
  color: var(--text);
}
.question-type-option.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent2);
}
.question-type-option .count {
  margin-left: 4px;
  font-size: .7rem;
  opacity: 0.8;
}
.question-type-option.active .count {
  color: rgba(255,255,255,.9);
}

/* Start session button */
.start-session-container {
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--rim);
}
.start-session-btn {
  background: linear-gradient(135deg, var(--accent), var(--violet));
  color: #fff;
  padding: 12px 32px;
  font-size: .9rem;
  font-weight: 700;
  border-radius: var(--r);
  border: none;
  cursor: pointer;
  transition: all .2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.start-session-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.start-session-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ── CUSTOM QUESTION SET BUILDER ── */
.cqs-section {
  background: var(--surface);
  border: 1px solid var(--rim);
  border-radius: var(--r);
  margin-top: 24px;
  overflow: hidden;
}
.cqs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid transparent;
  transition: background .15s;
}
.cqs-header:hover { background: var(--surface2); }
.cqs-header.open { border-bottom-color: var(--rim); }
.cqs-header-left {
  display: flex; align-items: center; gap: 10px;
}
.cqs-title {
  font-weight: 600; font-size: .95rem; color: var(--text);
}
.cqs-subtitle {
  font-size: .75rem; color: var(--text3); margin-top: 1px;
}
.cqs-badge {
  background: var(--accent); color: #fff;
  font-size: .65rem; font-weight: 700;
  padding: 2px 7px; border-radius: 99px;
  font-family: var(--font-mono);
}
.cqs-chevron {
  color: var(--text3); font-size: .8rem; transition: transform .2s;
}
.cqs-chevron.open { transform: rotate(180deg); }
.cqs-body { display: none; padding: 20px; }
.cqs-body.open { display: block; }

/* Search row */
.cqs-search-row {
  display: flex; gap: 10px; margin-bottom: 14px;
}
.cqs-search-wrap {
  position: relative; flex: 1;
}
.cqs-search-wrap svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--text3); pointer-events: none;
}
.cqs-search-input {
  width: 100%; height: 38px;
  padding: 0 12px 0 32px;
  border: 1px solid var(--rim2);
  border-radius: var(--r-sm);
  background: var(--surface2);
  font-size: .84rem; font-family: var(--font-sans); color: var(--text);
  transition: all .15s;
}
.cqs-search-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(59,158,255,.12);
}
.cqs-search-input::placeholder { color: var(--text3); }

/* Tag result list */
.cqs-results {
  max-height: 260px; overflow-y: auto;
  border: 1px solid var(--rim); border-radius: var(--r-sm);
  margin-bottom: 14px;
}
.cqs-result-empty {
  padding: 18px 14px; text-align: center;
  font-size: .82rem; color: var(--text3);
}
.cqs-result-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px;
  border-bottom: 1px solid var(--rim);
  cursor: pointer; transition: background .12s;
}
.cqs-result-item:last-child { border-bottom: none; }
.cqs-result-item:hover { background: var(--surface2); }
.cqs-result-item.already-added { opacity: .45; cursor: default; pointer-events: none; }
.cqs-result-name {
  font-size: .84rem; font-weight: 500; color: var(--text);
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cqs-result-name mark { background: rgba(59,158,255,.2); color: var(--primary-600); border-radius: 2px; padding: 0 1px; }
.cqs-result-right {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0; margin-left: 10px;
}
.cqs-result-count {
  font-size: .72rem; font-family: var(--font-mono);
  background: var(--surface3); color: var(--text2);
  padding: 2px 7px; border-radius: 99px;
}
.cqs-add-btn {
  width: 26px; height: 26px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 50%;
  font-size: .9rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, background .15s;
}
.cqs-add-btn:hover { transform: scale(1.15); background: var(--accent2); }

/* Selected tags chips */
.cqs-selected-label {
  font-size: .75rem; font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: 8px;
}
.cqs-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  min-height: 32px; margin-bottom: 14px;
}
.cqs-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(59,158,255,.1); border: 1px solid rgba(59,158,255,.3);
  color: var(--accent); border-radius: 99px;
  padding: 4px 10px; font-size: .78rem; font-weight: 500;
  max-width: 240px;
}
.cqs-chip-name {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cqs-chip-count {
  font-family: var(--font-mono); font-size: .68rem;
  background: rgba(59,158,255,.2); border-radius: 99px;
  padding: 1px 5px; flex-shrink: 0;
}
.cqs-chip-remove {
  background: none; border: none; cursor: pointer;
  color: var(--accent); font-size: .85rem; line-height: 1;
  padding: 0; flex-shrink: 0; opacity: .7;
  transition: opacity .12s;
}
.cqs-chip-remove:hover { opacity: 1; }
.cqs-chips-empty {
  font-size: .8rem; color: var(--text3); padding: 4px 0;
}

/* Footer row */
.cqs-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 14px; border-top: 1px solid var(--rim); gap: 10px; flex-wrap: wrap;
}
.cqs-total-label {
  font-size: .82rem; color: var(--text2);
}
.cqs-total-count {
  font-weight: 700; color: var(--text);
  font-family: var(--font-mono);
}
.cqs-footer-actions { display: flex; gap: 8px; }
.cqs-start-btn {
  background: linear-gradient(135deg, var(--emerald), #00c47c);
  color: #fff; padding: 9px 22px;
  font-size: .85rem; font-weight: 700;
  border-radius: var(--r-sm); border: none; cursor: pointer;
  transition: all .18s; display: inline-flex; align-items: center; gap: 6px;
}
.cqs-start-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.cqs-start-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }

/* Question palette (from previous enhancement) */
#questionPalette {
  position: fixed;
  right: 0;
  top: 0;
  width: 280px;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--rim);
  transform: translateX(100%);
  transition: transform 0.3s var(--ease);
  z-index: 150;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
#questionPalette.open {
  transform: translateX(0);
}
.palette-header {
  padding: 18px 16px;
  border-bottom: 1px solid var(--rim);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.palette-title {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text);
}
.palette-close {
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border-radius: 50%;
  border: 1px solid var(--rim);
}
.palette-grid {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  align-content: start;
}
.palette-item {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 1px solid var(--rim);
  border-radius: var(--r-xs);
  font-size: .7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.palette-item:hover {
  transform: scale(1.05);
  border-color: var(--accent);
}
.palette-item.answered {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent2);
}
.palette-item.correct {
  background: var(--emerald);
  color: #041a10;
  border-color: var(--emerald);
}
.palette-item.incorrect {
  background: var(--ruby);
  color: #fff;
  border-color: var(--ruby);
}
.palette-item.flagged::after {
  content: '⚑';
  position: absolute;
  top: -2px;
  right: -2px;
  font-size: .5rem;
  color: var(--amber);
}
/* ─── BMC SAFE ZONE ───────────────────────────────────────────
   The Buy Me a Coffee widget sits fixed at bottom-right with
   x_margin=18 y_margin=18. Its button is ~60px wide × ~60px tall.
   All fixed bottom-right UI must stay ABOVE bottom: 96px to avoid
   overlapping it. Elements at bottom-left or centered are unaffected.
─────────────────────────────────────────────────────────────── */
.palette-toggle {
  position: fixed;
  right: 20px;
  bottom: 96px; /* pushed above BMC widget (60px tall + 18px margin + 18px gap) */
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--violet));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  border: 1px solid var(--rim2);
  z-index: 151;
  font-size: 1.2rem;
  transition: all 0.2s;
}
.palette-toggle:hover {
  transform: scale(1.05);
}

/* ─── QUIZ OVERLAY ─── */
#quizOverlay { display: none; position: fixed; inset: 0; background: var(--bg); z-index: 200; flex-direction: column; overflow: hidden; }
.quiz-topbar { background: var(--surface); border-bottom: 1px solid var(--rim); padding: 0 24px; display: flex; align-items: center; gap: 12px; flex-shrink: 0; height: 56px; }
.quiz-topbar-left { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
/* improvement #13 — breadcrumb context */
.quiz-breadcrumb { font-size: .75rem; color: var(--text3); display: flex; align-items: center; gap: 6px; }
.quiz-breadcrumb-sep { color: var(--text3); opacity: .5; }
.quiz-breadcrumb-current { color: var(--text2); font-weight: 500; }
.quiz-topbar-center { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.quiz-topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.quiz-prog-track { width: 100%; height: 4px; background: var(--surface3); border-radius: 99px; }
.quiz-prog-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--emerald)); border-radius: 99px; transition: width .4s var(--ease); }
.quiz-prog-label { display: flex; justify-content: space-between; font-size: .68rem; color: var(--text3); font-family: var(--font-mono); }
.quiz-body { flex: 1; overflow-y: auto; padding: 36px 22px 80px; }
.quiz-inner { max-width: 760px; margin: 0 auto; }

/* Question number badge */
.quiz-q-num {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: .68rem;
  color: var(--text3); margin-bottom: 14px;
  background: var(--surface2); border: 1px solid var(--rim);
  border-radius: 99px; padding: 4px 12px;
}
.quiz-q-domain {
  font-size: .68rem; color: var(--accent); font-weight: 500;
  padding-left: 8px; border-left: 1px solid var(--rim2);
}

/* Question stem */
.quiz-stem {
  font-family: var(--font-sans);
  font-size: 1.08rem; font-weight: 500;
  color: var(--text); line-height: 1.65;
  margin-bottom: 24px;
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--rim);
  border-radius: var(--r);
  border-left: 3px solid var(--accent);
}

/* Options */
.quiz-opts { display: grid; gap: 8px; }
.quiz-opt {
  padding: 14px 18px; border-radius: var(--r);
  border: 1.5px solid var(--rim); background: var(--surface);
  cursor: pointer; font-size: .9rem; font-weight: 400;
  color: var(--text); display: flex; gap: 14px;
  align-items: flex-start; transition: all .14s; line-height: 1.6;
  position: relative;
}
.quiz-opt:hover:not(.locked):not(.correct):not(.wrong) {
  border-color: var(--accent); background: var(--surface2);
  transform: translateX(2px);
}
.quiz-opt.correct { border-color: var(--emerald); background: rgba(0,212,158,.08); color: var(--emerald); }
.quiz-opt.wrong { border-color: var(--ruby); background: rgba(255,79,101,.07); color: var(--ruby); }
.quiz-opt.locked { cursor: default; }

/* Option letter badge */
.q-opt-letter {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: .78rem; font-weight: 700;
  background: var(--surface2); border: 1px solid var(--rim2);
  font-family: var(--font-mono); margin-top: 1px;
  transition: all .14s;
}
.quiz-opt:hover:not(.locked):not(.correct):not(.wrong) .q-opt-letter {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.quiz-opt.correct .q-opt-letter { background: var(--emerald); border-color: var(--emerald); color: #041a10; }
.quiz-opt.wrong .q-opt-letter { background: var(--ruby); border-color: var(--ruby); color: #fff; }

/* Explanation box */
.quiz-exp {
  margin-top: 16px; padding: 16px 20px;
  border: 1px solid var(--rim); border-radius: var(--r);
  background: var(--surface); color: var(--text2);
  font-size: .875rem; line-height: 1.7; display: none;
  border-left: 3px solid var(--accent);
  animation: fadeUp .25s var(--ease);
}
.quiz-exp.show { display: block; }
.quiz-exp-label { color: var(--accent); font-weight: 700; font-size: .75rem; margin-bottom: 9px; display: flex; align-items: center; gap: 6px; }
.quiz-exp-result { font-size: .84rem; font-weight: 700; margin-bottom: 10px; padding: 6px 12px; border-radius: var(--r-sm); display: inline-block; }
.quiz-exp-result.correct-result { color: var(--emerald); background: rgba(0,212,158,.1); }
.quiz-exp-result.wrong-result { color: var(--ruby); background: rgba(255,79,101,.1); }

/* improvement #15 — confidence rating fades in after 1.5s delay */
.conf-rate-prompt {
  margin-top: 12px; padding: 14px 18px;
  background: var(--surface2); border: 1px solid var(--rim);
  border-radius: var(--r); display: flex; align-items: center;
  gap: 16px; flex-wrap: wrap;
  animation: fadeUp .4s var(--ease) 1.5s both;
}
.conf-rate-label {
  font-size: .8rem; font-weight: 600; color: var(--text2);
  white-space: nowrap;
}
.conf-rate-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.conf-rate-btn {
  border: 1.5px solid var(--rim2); border-radius: 99px;
  background: var(--surface3); color: var(--text2);
  font-family: inherit; font-size: .8rem; font-weight: 500;
  padding: 5px 14px; cursor: pointer; transition: all .14s; min-height: 36px;
}
.conf-rate-btn:hover { border-color: var(--accent); color: var(--text); }
.conf-rate-btn.active.guess { background: rgba(255,79,101,.15); border-color: var(--ruby); color: var(--ruby); }
.conf-rate-btn.active.unsure { background: rgba(255,185,48,.15); border-color: var(--amber); color: var(--amber); }
.conf-rate-btn.active.confident { background: rgba(0,212,158,.15); border-color: var(--emerald); color: var(--emerald); }

/* Keyboard shortcut hint in quiz */
.quiz-kb-hint {
  display: flex; gap: 10px; flex-wrap: wrap;
  font-size: .68rem; color: var(--text3); margin-top: 14px;
  padding-top: 12px; border-top: 1px solid var(--rim);
}
.quiz-kb-key { display: inline-flex; align-items: center; gap: 4px; }
.kbd {
  font-family: var(--font-mono);
  background: var(--surface3); border: 1px solid var(--rim2);
  border-radius: 4px; padding: 1px 5px; font-size: .68rem;
}

/* Actions bar */
.quiz-actions {
  margin-top: 22px; display: flex; justify-content: space-between;
  align-items: center; padding-top: 16px; border-top: 1px solid var(--rim);
}

/* improvement #16: results ring shows raw score/total + qualitative label */
.results-wrap { max-width: 700px; margin: 0 auto; padding: 44px 22px; }
.res-ring { width: 150px; height: 150px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: conic-gradient(var(--emerald) 0% var(--p, 0%), var(--surface3) var(--p, 0%)); position: relative; margin: 0 auto 24px; }
.res-ring::after { content: ''; position: absolute; width: 108px; height: 108px; background: var(--bg); border-radius: 50%; }
.res-score-inner { position: relative; z-index: 1; text-align: center; }
.res-score-fraction { font-family: var(--font-sans); font-size: 1.6rem; font-weight: 700; line-height: 1; }
.res-score-pct { font-size: .72rem; color: var(--text2); margin-top: 2px; }
.res-quality { font-size: .75rem; font-weight: 700; padding: 4px 12px; border-radius: 99px; display: inline-block; margin: 0 auto 16px; }
.res-quality.strong { background: rgba(0,212,158,.1); color: var(--emerald); }
.res-quality.borderline { background: rgba(255,185,48,.1); color: var(--amber); }
.res-quality.needs-work { background: rgba(255,79,101,.1); color: var(--ruby); }
.res-title { font-family: var(--font-sans); font-size: 1.7rem; margin-bottom: 7px; }
.res-sub { color: var(--text2); font-size: .875rem; margin-bottom: 26px; }
.res-breakdown { display: flex; gap: 22px; justify-content: center; margin-bottom: 24px; }
.res-stat { text-align: center; }
.res-stat-v { font-size: 1.4rem; font-weight: 700; font-family: var(--font-sans); }
.res-stat-l { font-size: .68rem; color: var(--text3); margin-top: 2px; }
.conf-breakdown { background: var(--surface2); border-radius: var(--r-sm); padding: 14px 18px; margin: 16px 0; text-align: left; }
.conf-breakdown-title { font-size: .75rem; font-weight: 700; color: var(--text3); margin-bottom: 10px; }
.conf-row { display: flex; align-items: center; gap: 10px; font-size: .84rem; margin-bottom: 6px; }
.conf-row:last-child { margin-bottom: 0; }

/* Streak heatmap */
.streak-heatmap { display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.streak-day { width: 14px; height: 14px; border-radius: 3px; background: var(--surface3); transition: background .2s; }
.streak-day.active { background: var(--emerald); }
.streak-day.missed { background: var(--surface3); opacity: .5; }

/* Performance indicator */
.perf-indicator {
  display: none; position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid rgba(255,185,48,.4); border-radius: var(--r);
  padding: 12px 20px; font-size: .84rem; color: var(--amber); z-index: 5000;
  box-shadow: var(--shadow-sm); animation: fadeUp .3s var(--ease);
  display: flex; align-items: center; gap: 10px;
}
.perf-indicator.show { display: flex; }

/* KPI primary emphasis */
.kpi.primary { grid-column: span 2; }
@media(max-width:720px) { .kpi.primary { grid-column: span 1; } }
.prog-module-card { background: var(--surface); border: 1px solid var(--rim); border-radius: var(--r); padding: 16px; margin-bottom: 10px; }
.prog-module-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.prog-module-name { font-weight: 600; font-size: .855rem; }
.prog-module-pct { font-size: .75rem; color: var(--text2); }
.prog-bar-track { background: var(--surface3); border-radius: 99px; height: 4px; }
.prog-bar-fill { height: 100%; border-radius: 99px; transition: width .6s var(--ease); }

/* Insight charts (simple CSS bars) */
.insight-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 20px; }
@media(max-width:720px) { .insight-row { grid-template-columns: 1fr; } }
.insight-card { background: var(--surface); border: 1px solid var(--rim); border-radius: var(--r); padding: 18px; }
.insight-card-title { font-size: .82rem; font-weight: 700; color: var(--text3); margin-bottom: 14px; }
.bar-chart { display: grid; gap: 8px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-label { font-size: .75rem; color: var(--text2); width: 120px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; height: 6px; background: var(--surface3); border-radius: 99px; }
.bar-fill { height: 100%; border-radius: 99px; transition: width 1s var(--ease); }
.bar-pct { font-family: var(--font-mono); font-size: .68rem; color: var(--text2); width: 32px; text-align: right; flex-shrink: 0; }

/* ─── EMPTY / TOAST ─── */
.empty { text-align: center; padding: 60px 22px; }
.empty-icon { font-size: 2.4rem; margin-bottom: 14px; }
.empty-title { font-family: var(--font-sans); font-size: 1.2rem; margin-bottom: 7px; }
.empty-sub { color: var(--text2); font-size: .835rem; line-height: 1.65; }
#toast { position: fixed; bottom: 20px; left: 20px; background: var(--surface); border: 1px solid var(--rim2); border-radius: var(--r); padding: 10px 16px; font-size: .835rem; box-shadow: var(--shadow); transform: translateY(80px); opacity: 0; transition: all .3s var(--ease); z-index: 9000; display: flex; align-items: center; gap: 8px; max-width: calc(100vw - 120px); /* never reaches BMC zone */ }
#toast.show { transform: translateY(0); opacity: 1; }

/* ─── MODAL ─── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 8000; align-items: center; justify-content: center; }
.modal-overlay.show { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--rim2); border-radius: var(--r); padding: 28px; width: 480px; max-width: 95vw; box-shadow: var(--shadow); }
.modal-title { font-family: var(--font-sans); font-size: 1.3rem; margin-bottom: 6px; }
.modal-sub { font-size: .82rem; color: var(--text2); margin-bottom: 20px; line-height: 1.55; }
.modal-input { width: 100%; background: var(--surface2); border: 1px solid var(--rim2); border-radius: var(--r-sm); padding: 9px 14px; color: var(--text); font-family: inherit; font-size: .875rem; outline: none; margin-bottom: 14px; }
.modal-input:focus { border-color: var(--accent); }
.modal-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.modal-select { width: 100%; background: var(--surface2); border: 1px solid var(--rim2); border-radius: var(--r-sm); padding: 8px 12px; color: var(--text); font-family: inherit; font-size: .82rem; outline: none; }
.modal-label { font-size: .72rem; color: var(--text2); margin-bottom: 5px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.modal-check-row { display: flex; align-items: center; gap: 9px; font-size: .82rem; color: var(--text2); margin-bottom: 10px; cursor: pointer; }
.modal-check-row input { cursor: pointer; accent-color: var(--accent); width: 15px; height: 15px; }

/* ─── REVIEW TABS ─── */
.review-tabs {
  display: flex;
  border-bottom: 1px solid var(--rim);
  margin-bottom: 20px;
  gap: 4px;
}
.review-tab {
  padding: 8px 16px;
  background: var(--surface2);
  border: 1px solid var(--rim);
  border-bottom: none;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  font-size: .8rem;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
}
.review-tab:hover {
  background: var(--surface3);
  color: var(--text);
}
.review-tab.active {
  background: var(--surface);
  color: var(--accent);
  font-weight: 700;
  border-bottom: 2px solid var(--accent);
}
.review-panel {
  display: none;
  padding: 12px 0;
}
.review-panel.active {
  display: block;
}
.review-question-item {
  padding: 12px;
  border: 1px solid var(--rim);
  border-radius: var(--r-sm);
  margin-bottom: 8px;
  background: var(--surface2);
  cursor: pointer;
  transition: all 0.15s;
}
.review-question-item:hover {
  border-color: var(--accent);
  transform: translateX(2px);
}
.review-question-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .7rem;
  color: var(--text3);
  margin-bottom: 4px;
}
.review-question-stem {
  font-size: .82rem;
  color: var(--text);
  line-height: 1.5;
}
.review-metrics {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  font-size: .68rem;
  color: var(--text2);
}
.insight-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: .65rem;
  font-weight: 600;
}
.insight-badge.rushed { background: rgba(255,79,101,.1); color: var(--ruby); }
.insight-badge.changed { background: rgba(255,185,48,.1); color: var(--amber); }
.insight-badge.confident-wrong { background: rgba(255,79,101,.15); color: var(--ruby); font-weight: 700; }

/* ─── SIDEBAR OVERLAY / RESPONSIVE ─── */
.sb-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 99; }
.sb-overlay.active { display: block; }

@media(max-width:1024px) {
  #sidebar-nav {
    width: 72px;
  }
  .sb-wordmark,
  .sidebar-nav-body .nav-item span:not(.nav-icon):not(.nav-badge),
  .nav-section-title,
  .sb-user-info,
  .sidebar-progress-row,
  .sb-action-btn span:not(:first-child) {
    display: none;
  }
  .nav-item {
    justify-content: center;
    padding: 10px;
  }
  .nav-icon {
    margin-right: 0;
    font-size: 1.2rem;
  }
  .sidebar-header {
    justify-content: center;
  }
  .sidebar-user {
    justify-content: center;
  }
  .nav-badge {
    display: none;
  }
}

@media(max-width:880px) {
  /* ── Lesson list: collapsed by default when a lesson is open ── */
  #lessonsShell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  /* List panel: collapses to a slim header bar; expands on .expanded */
  .ll-list-panel {
    max-height: 44px;
    overflow: hidden;
    transition: max-height .28s cubic-bezier(.4,0,.2,1);
    border-right: none;
    border-bottom: 1px solid var(--rim);
    z-index: 2;
  }
  .ll-list-panel.expanded {
    max-height: 260px;
  }
  /* When no lesson is loaded yet, keep list open so user can pick one */
  #lessonsShell.no-lesson-selected .ll-list-panel {
    max-height: 260px;
  }
  /* Panel header becomes a tappable toggle row */
  .ll-panel-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    min-height: 44px;
    flex-shrink: 0;
  }
  .ll-panel-header::after {
    content: '▾';
    font-size: .75rem;
    color: var(--text3);
    transition: transform .2s;
    margin-left: 8px;
    flex-shrink: 0;
  }
  .ll-list-panel.expanded .ll-panel-header::after {
    transform: rotate(180deg);
  }
  .ll-list {
    max-height: 210px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .lc-body { padding: 20px; }
  .lc-body-inner { padding: 0; max-width: 100%; }
  .lc-header, .lc-nav { padding: 14px 20px; }
  .kpi-grid { grid-template-columns: repeat(2,1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  #questionPalette { width: 100%; }
  .qb-stats-grid { grid-template-columns: repeat(2,1fr); }
  .rate-btn { min-height: 54px; }
  .conf-rate-btn { min-height: 44px; }
  .quiz-opt { min-height: 52px; }
  .priority-card { grid-template-columns: 1fr; }
  .study-lane-steps { flex-direction: column; }
  .study-lane-step { border-radius: var(--r-sm) !important; margin-right: 0 !important; margin-bottom: 4px; }
  .top-bar-search { width: 160px; }
}

@keyframes fadeUp { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }
.fade-up { animation: fadeUp .22s var(--ease) forwards; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}
@keyframes popIn { from{opacity:0;transform:scale(.9)} to{opacity:1;transform:scale(1)} }
.pop-in { animation: popIn .2s var(--ease) forwards; }
/* ─── CONTENT RATING ─── */
.content-rating {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--r-sm);
  background: var(--surface2); border: 1px solid var(--rim);
  font-size: .8rem; color: var(--text2);
}
.content-rating-label { font-weight: 600; margin-right: 2px; white-space: nowrap; }
.rating-thumbs { display: flex; gap: 5px; }
.rating-thumb {
  background: var(--surface3); border: 1px solid var(--rim2);
  border-radius: 8px; padding: 5px 10px; cursor: pointer;
  font-size: .95rem; transition: all .15s; line-height: 1;
  display: flex; align-items: center; gap: 4px;
}
.rating-thumb:hover { border-color: var(--accent); transform: translateY(-1px); }
.rating-thumb.active-up   { background: rgba(0,212,158,.12); border-color: var(--emerald); }
.rating-thumb.active-down { background: rgba(255,79,101,.1);  border-color: var(--ruby); }
.rating-thumb .thumb-count { font-size: .7rem; font-weight: 700; color: var(--text3); font-family: var(--font-mono); }
.rating-thumb.active-up   .thumb-count { color: var(--emerald); }
.rating-thumb.active-down .thumb-count { color: var(--ruby); }
.rating-divider { width: 1px; height: 18px; background: var(--rim2); flex-shrink: 0; }
.rating-stars { display: flex; gap: 3px; align-items: center; }
.rating-star {
  background: none; border: none; cursor: pointer; font-size: 1.1rem;
  line-height: 1; padding: 2px; transition: transform .1s; opacity: .35;
  color: var(--amber);
}
.rating-star:hover,
.rating-star.active { opacity: 1; transform: scale(1.15); }
.rating-star-label { font-size: .72rem; color: var(--text3); font-family: var(--font-mono); margin-left: 2px; min-width: 28px; }
.rating-done { font-size: .75rem; color: var(--emerald); font-weight: 600; display: none; animation: fadeUp .2s var(--ease); }
/* Rating summary rows in Progress tab */
.rating-summary-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--rim); font-size: .83rem;
}
.rating-summary-item:last-child { border-bottom: none; }
.rating-summary-type { font-size: .65rem; text-transform: uppercase; letter-spacing: .6px; font-weight: 700; color: var(--text3); width: 62px; flex-shrink: 0; }
.rating-summary-title { color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rating-summary-score { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.rating-tb { font-size: .85rem; }
.rating-stars-sm { font-size: .75rem; color: var(--amber); letter-spacing: 1px; }
.rating-stars-sm.dim { opacity: .3; }
/* ══════════════════════════════════════════════════════════
   MOBILE & TABLET RESPONSIVE  —  MedScholar
══════════════════════════════════════════════════════════ */

/* ── Phone warning banner — only on mobile ── */
#phoneWarningBanner {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1100;
  padding: 0;
}
#phoneWarningInner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  color: #e2e8f0;
  padding: 12px 14px;
  font-family: var(--font-sans);
  font-size: .8rem;
  line-height: 1.4;
  border-bottom: 2px solid var(--primary-500);
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
}
#phoneWarningIcon { font-size: 1.5rem; flex-shrink: 0; }
#phoneWarningText { flex: 1; }
#phoneWarningText strong { display: block; font-size: .85rem; margin-bottom: 2px; color: #fff; }
#phoneWarningText span { color: #94a3b8; font-size: .75rem; }
#phoneWarningClose {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  color: #e2e8f0;
  border-radius: 6px;
  padding: 4px 9px;
  font-size: .8rem;
  cursor: pointer;
  flex-shrink: 0;
  font-family: var(--font-sans);
}
#phoneWarningClose:active { background: rgba(255,255,255,.2); }

@media (max-width: 640px) {
  #phoneWarningBanner.visible { display: block; }
  /* Push top bar down to make room for banner */
  body.phone-warning-shown #top-bar { top: var(--phone-banner-h, 74px); }
  body.phone-warning-shown #sidebar-nav { top: var(--phone-banner-h, 74px); }
}
/* ── Bottom nav — desktop: hidden ── */
#mobileBottomNav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(56px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--gray-200);
  z-index: 500;
  box-shadow: 0 -2px 10px rgba(0,0,0,.08);
}
.mbn-item {
  flex: 1; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px; padding: 6px 2px;
  background: none; border: none; cursor: pointer;
  font-family: var(--font-sans);
  color: var(--gray-400);
  -webkit-tap-highlight-color: transparent;
}
.mbn-item.active { color: var(--primary-500); }
.mbn-icon { font-size: 1.2rem; line-height: 1; }
.mbn-label { font-size: 0.6rem; font-weight: 600; }

/* ── Lesson list toggle pill — always hidden unless JS shows it ── */
#mobileLessonListBtn {
  display: none;
  position: fixed;
  bottom: calc(64px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  z-index: 490;
  background: var(--primary-500); color: #fff;
  border: none; border-radius: 99px;
  padding: 9px 20px;
  font-size: .82rem; font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer; white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,86,210,.35);
}

/* ══════════════════════════════
   TABLET  641px – 1024px
   (Sidebar already collapses to icons — just minor tweaks)
══════════════════════════════ */
@media (max-width: 1024px) {
  .top-bar-search { width: 180px; }
  .scroll-area { padding: 20px; }
}

/* ══════════════════════════════
   MOBILE  ≤ 640px
══════════════════════════════ */
@media (max-width: 640px) {

  /* Show bottom nav */
  #mobileBottomNav { display: flex; }

  /* ── Sidebar: hidden on mobile — bottom nav handles navigation ── */
  #sidebar-nav { display: none !important; }

  /* ── Shell: sidebar takes no space ── */
  #shell { position: relative; }
  #main-wrapper { width: 100%; min-width: 0; }

  /* ── Top bar ── */
  #top-bar { padding: 0 10px; height: 50px; gap: 6px; }
  .top-bar-title { font-size: 0.9rem; }
  .top-bar-search { width: 120px; }
  .top-bar-quick-stats { display: none; }

  /* ── All scrollable views: pad bottom for bottom nav ── */
  /* Use a CSS variable so each container can reference it */
  :root { --mobile-nav-h: calc(56px + env(safe-area-inset-bottom)); }

  .scroll-area            { padding: 14px; padding-bottom: calc(var(--mobile-nav-h) + 14px); }
  .ls-dashboard           { padding: 14px; padding-bottom: calc(var(--mobile-nav-h) + 14px); }
  .fc-dashboard           { padding: 14px; padding-bottom: calc(var(--mobile-nav-h) + 14px); }
  .qb-table-wrap,
  #qbTableWrap            { padding-bottom: calc(var(--mobile-nav-h) + 8px); }

  /* ── Dashboard: single scrollable page, no split-screen ── */
  #view-dashboard {
    height: auto !important;
    overflow: visible !important;
    min-height: 0;
  }
  #view-dashboard .scroll-area {
    overflow-y: visible !important;
    height: auto !important;
    flex: none !important;
    padding-bottom: calc(var(--mobile-nav-h) + 16px);
  }
  /* The overall content area must scroll instead */
  #main, #content {
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  /* ── Dashboard ── */
  .priority-card          { grid-template-columns: 1fr !important; }
  .priority-card-body     { padding: 18px 16px; }
  .priority-card-title    { font-size: 1.25rem; }
  .priority-stats         { border-left: none !important; border-top: 1px solid rgba(255,255,255,.15); padding: 12px 16px !important; }
  .kpi-grid               { grid-template-columns: repeat(2,1fr); gap: 8px; }
  .kpi                    { padding: 12px 10px; }
  .dash-grid              { grid-template-columns: 1fr; }
  .hero                   { grid-template-columns: 1fr; padding: 18px; }
  .hero-brief             { display: none; }
  .hero-title             { font-size: 1.3rem; }
  .module-grid            { grid-template-columns: 1fr !important; }
  .section-title          { font-size: .9rem; }
  .study-lane-steps       { flex-direction: column; }
  .study-lane-step        { border-radius: var(--r-sm) !important; margin-right: 0 !important; margin-bottom: 4px; }

  /* ── LESSONS — completely rethought for mobile ── */
  /* The study panel fills the screen, no side-by-side split */
  #view-lessons           { display: flex; flex-direction: column; }

  /* Hide the top sub-bar (module name/progress) — too much chrome */
  .ls-study-topbar        { display: none !important; }

  /* lessonsShell: single column, lesson content fills everything */
  #lessonsShell {
    display: flex !important;
    flex-direction: column !important;
    flex: 1;
    overflow: hidden;
  }

  /* lc-panel (lesson content): takes full height */
  .lc-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    /* Push content above mobile bottom nav */
    padding-bottom: var(--mobile-nav-h);
  }

  /* lc-header: compact */
  .lc-header { padding: 12px 14px !important; }
  .lc-title  { font-size: 1.05rem; line-height: 1.3; }
  .lc-meta   { font-size: .7rem; gap: 8px; }
  .lc-badge  { display: none; }

  /* lc-body: scrolls freely */
  .lc-body {
    flex: 1;
    overflow-y: auto !important;
    padding: 16px 14px !important;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
  }
  .lc-body-inner { max-width: 100%; padding: 0 !important; }

  /* lc-nav: always visible at the bottom of the panel, never covered */
  .lc-nav {
    flex-shrink: 0;
    background: var(--surface);
    border-top: 1px solid var(--rim);
    padding: 8px 12px !important;
    gap: 8px;
    flex-wrap: nowrap;
    /* NOT sticky/fixed — it's a normal flex child that sits at the bottom */
  }
  .lc-nav .btn { font-size: .78rem; padding: 8px 6px; min-height: 40px; }
  /* Mark complete button: full width row on mobile so it's obvious */
  .lc-nav > div { flex: 1; justify-content: center; flex-wrap: wrap; gap: 8px; }
  #markDoneBtn_,
  [id^="markDoneBtn_"] { width: 100%; justify-content: center; min-height: 44px; font-size: .9rem; }

  /* ll-list-panel: slide-up sheet from bottom */
  .ll-list-panel {
    position: fixed !important;
    left: 0; right: 0;
    bottom: calc(var(--mobile-nav-h));
    height: 50vh;
    z-index: 480;
    border-radius: 14px 14px 0 0;
    border-top: 1px solid var(--rim);
    box-shadow: 0 -4px 24px rgba(0,0,0,.15);
    transform: translateY(100%);
    transition: transform .26s cubic-bezier(.4,0,.2,1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .ll-list-panel.mobile-drawer-open { transform: translateY(0); }

  /* Drag handle on panel header */
  .ll-panel-header {
    position: relative;
    padding: 14px 16px 10px;
    flex-shrink: 0;
    cursor: pointer;
    user-select: none;
    border-radius: 14px 14px 0 0;
  }
  .ll-panel-header::before {
    content: '';
    display: block;
    width: 32px; height: 4px;
    background: var(--gray-300);
    border-radius: 99px;
    margin: 0 auto 10px;
  }
  .ll-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

  /* ── Flashcards ── */
  .fc-dash-hero           { padding: 18px 16px; flex-direction: column; gap: 14px; }
  .fc-dash-hero-title     { font-size: 1.2rem; }
  .fc-deck-grid           { grid-template-columns: 1fr; }
  .fc-study-shell         { padding: 12px; }
  .card-outer             { height: 220px; max-width: 100%; }
  .card-face              { padding: 20px 16px; }
  .card-q-text            { font-size: .95rem; }
  .card-a-text            { font-size: .88rem; }
  .rate-btns              { gap: 6px; margin-top: 12px; flex-wrap: nowrap; }
  .rate-btn               { min-width: 0; flex: 1; padding: 10px 4px; font-size: .78rem; min-height: 52px; }
  .rate-btn .rate-next    { display: none; }

  /* ── Question bank ── */
  .qb-stats-grid          { grid-template-columns: repeat(2,1fr) !important; }
  .qb-header              { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; }
  .qb-filters             { flex-wrap: wrap; gap: 6px; }

  /* ── Quiz overlay ── */
  .quiz-topbar            { padding: 0 10px; height: 48px; gap: 6px; }
  .quiz-breadcrumb        { display: none; }
  .quiz-body              { padding: 14px 12px; padding-bottom: calc(var(--mobile-nav-h) + 16px); }
  .quiz-inner             { max-width: 100%; }
  .quiz-stem              { font-size: .9rem; padding: 12px 14px; }
  .quiz-opt               { padding: 11px 12px; font-size: .85rem; min-height: 50px; }
  .q-opt-letter           { width: 24px; height: 24px; font-size: .72rem; }

  /* ── Modals ── */
  .modal                  { width: 92vw !important; padding: 22px 18px; }
  .confirm-box            { width: 88vw; }

  /* ── Progress ── */
  .insight-row            { grid-template-columns: 1fr !important; }
  .kpi.primary            { grid-column: span 1 !important; }

  /* ── Touch targets ── */
  .btn                    { min-height: 40px; }
  .ll-item                { min-height: 42px; padding: 10px 12px; }
  .ls-mod-card            { padding: 14px; }
  .fc-deck-card           { padding: 14px; }
  .rating-thumb           { padding: 8px 12px; min-height: 36px; }
}

/* ══════════════════════════════════════════════════════════
   MOBILE STACKING FIXES — added during refactor
   Ensures only one .view is ever visible at a time and
   fixes the flex/overflow chain on phone & tablet.
══════════════════════════════════════════════════════════ */

/* ── 1. HARD RULE: inactive views must never show ── */
.view {
  display: none !important;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  flex-direction: column;
  height: 100%;
}
.view.active {
  display: flex !important;
  animation: viewIn .2s var(--ease) both;
}

/* ── 2. Shell flex chain: every node must pass height down ── */
#shell,
#main-wrapper,
#main,
#content {
  min-height: 0;
  overflow: hidden;
}
#content {
  flex: 1;
  display: flex;
  flex-direction: column;
}
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ── 3. Tablet (641–1024px): sidebar collapse ── */
@media (max-width: 1024px) and (min-width: 641px) {
  /* Collapse sidebar to icon-only strip */
  #sidebar-nav {
    width: 60px !important;
    overflow: hidden;
  }
  .sb-wordmark,
  .nav-section-title,
  .sb-user-info,
  .sidebar-progress-row,
  .sidebar-bottom-actions span,
  .nav-badge {
    display: none !important;
  }
  .sidebar-nav-body .nav-item span:not(.nav-icon):not(.nav-badge) {
    display: none !important;
  }
  .nav-item {
    justify-content: center !important;
    padding: 10px 0 !important;
  }
  .nav-icon { margin-right: 0 !important; font-size: 1.2rem !important; }
  .sidebar-header { justify-content: center !important; padding: 18px 0 !important; }
  .sidebar-user { justify-content: center !important; }
  .sidebar-footer { padding: 10px 0; }
  .sb-action-btn { font-size: 0; padding: 0; width: 36px; height: 36px; }
  .sb-action-btn span:last-child { display: none !important; }
}

/* ── 4. Mobile (≤640px): prevent sub-panels stacking inside views ── */
@media (max-width: 640px) {

  /* Lessons: only one panel visible at a time */
  #lsDashboard,
  #lsStudyPanel {
    position: absolute;
    inset: 0;
    transition: transform .25s var(--ease);
    background: var(--bg);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  #view-lessons {
    position: relative;
    overflow: hidden;
  }
  #lsDashboard {
    transform: translateX(0);
    z-index: 1;
  }
  #lsStudyPanel {
    transform: translateX(100%);
    z-index: 2;
  }
  /* JS adds .panel-study-active to #view-lessons to slide panel in */
  #view-lessons.panel-study-active #lsDashboard { transform: translateX(-40%); }
  #view-lessons.panel-study-active #lsStudyPanel { transform: translateX(0); }

  /* Flashcards: same pattern */
  #fcDashboard,
  #fcStudyPanel {
    position: absolute;
    inset: 0;
    transition: transform .25s var(--ease);
    background: var(--bg);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  #view-flashcards {
    position: relative;
    overflow: hidden;
  }
  #fcDashboard {
    transform: translateX(0);
    z-index: 1;
  }
  #fcStudyPanel {
    transform: translateX(100%);
    z-index: 2;
  }
  #view-flashcards.panel-study-active #fcDashboard { transform: translateX(-40%); }
  #view-flashcards.panel-study-active #fcStudyPanel { transform: translateX(0); }

  /* QBank: hide quiz overlay stacking issues */
  #quizOverlay {
    position: fixed !important;
    inset: 0;
    z-index: 900;
  }

  /* Prevent body scroll when a view is active */
  body { overflow: hidden !important; }

  /* Safe bottom padding for all scrollable areas */
  .scroll-area,
  .ls-dashboard,
  .fc-dashboard {
    padding-bottom: calc(var(--mobile-nav-h, 72px) + 16px) !important;
  }

  /* QBank table wrap safe area */
  .qb-table-wrap,
  #qbTableWrap {
    padding-bottom: calc(var(--mobile-nav-h, 72px) + 8px) !important;
  }
}