/* ============================================================
   DSA PREP STUDIO — Full Design System
   Dark mode • Glassmorphism • Premium Aesthetic
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── CSS Custom Properties ── */
:root {
  --bg-base:        #080b12;
  --bg-surface:     #0e1320;
  --bg-elevated:    #141927;
  --bg-card:        #161d2e;
  --bg-glass:       rgba(20, 28, 50, 0.7);

  --border:         rgba(255,255,255,0.07);
  --border-active:  rgba(79,142,247,0.4);

  --blue:           #4f8ef7;
  --blue-dim:       rgba(79,142,247,0.15);
  --purple:         #a78bfa;
  --purple-dim:     rgba(167,139,250,0.15);
  --green:          #34d399;
  --green-dim:      rgba(52,211,153,0.15);
  --amber:          #f59e0b;
  --red:            #f87171;
  --red-dim:        rgba(248,113,113,0.15);
  --cyan:           #38bdf8;

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-dim:       #475569;

  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.4);
  --shadow:    0 4px 24px rgba(0,0,0,0.5);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.6);

  --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; outline: none; }
::selection { background: var(--blue-dim); color: var(--blue); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ============================================================
   LAYOUT — Shell
   ============================================================ */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: 240px;
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 24px 20px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.logo-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.logo-sub {
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 400;
  display: block;
}

.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
}

.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  padding: 8px 8px 4px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
  cursor: pointer;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--blue-dim);
  color: var(--blue);
  font-weight: 600;
}

.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--blue);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}
.nav-badge.amber { background: var(--amber); }
.nav-badge.green { background: var(--green); color: #0f2b20; }

/* Category sub-nav */
.cat-list { margin-top: 4px; }
.cat-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px 6px 18px;
  font-size: 12.5px;
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 1px;
}
.cat-item:hover { color: var(--text-secondary); background: var(--bg-elevated); }
.cat-item.active { color: var(--text-primary); }
.cat-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* Sidebar streak card */
.sidebar-streak {
  margin: 12px;
  padding: 14px;
  background: linear-gradient(135deg, rgba(79,142,247,0.12), rgba(167,139,250,0.08));
  border: 1px solid var(--border-active);
  border-radius: var(--radius);
}
.streak-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }
.streak-val { font-size: 28px; font-weight: 800; color: var(--amber); line-height: 1; margin: 4px 0 2px; }
.streak-sub { font-size: 11px; color: var(--text-secondary); }

/* ── Main Content ── */
.main-content {
  margin-left: 240px;
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Top Bar ── */
.topbar {
  height: 60px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.topbar-breadcrumb {
  font-size: 13px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.search-bar {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 14px;
  transition: all var(--transition);
}
.search-bar:focus-within {
  border-color: var(--border-active);
  background: var(--bg-card);
}
.search-bar input {
  background: none; border: none; outline: none;
  font-family: var(--font-sans);
  font-size: 13.5px;
  color: var(--text-primary);
  width: 220px;
}
.search-bar input::placeholder { color: var(--text-dim); }
.search-icon { color: var(--text-dim); font-size: 14px; }

/* ── Page Content ── */
.page { padding: 28px; display: none; }
.page.active { display: block; }

/* ============================================================
   DASHBOARD
   ============================================================ */

.dashboard-hero {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--card-accent, linear-gradient(90deg, var(--blue), var(--purple)));
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-active); }

.stat-icon { font-size: 22px; margin-bottom: 10px; }
.stat-val { font-size: 32px; font-weight: 800; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; font-weight: 500; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* Category mastery */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
}
.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mastery-item {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
}
.mastery-name { font-size: 12.5px; color: var(--text-secondary); width: 130px; flex-shrink: 0; }
.mastery-bar-wrap { flex: 1; height: 6px; background: var(--bg-elevated); border-radius: 3px; overflow: hidden; }
.mastery-bar { height: 100%; border-radius: 3px; transition: width 0.8s ease; }
.mastery-pct { font-size: 11px; color: var(--text-dim); width: 32px; text-align: right; }

/* Heatmap */
.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(26, 1fr);
  gap: 3px;
  margin-top: 8px;
}
.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 2px;
  background: var(--bg-elevated);
  transition: all var(--transition);
  cursor: default;
}
.heatmap-cell:hover { transform: scale(1.4); }
.heatmap-cell[data-count="1"] { background: rgba(79,142,247,0.3); }
.heatmap-cell[data-count="2"] { background: rgba(79,142,247,0.5); }
.heatmap-cell[data-count="3"] { background: rgba(79,142,247,0.7); }
.heatmap-cell[data-count="4"] { background: var(--blue); }

/* Due cards list */
.due-list { display: flex; flex-direction: column; gap: 8px; }
.due-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: all var(--transition);
  cursor: pointer;
  border: 1px solid transparent;
}
.due-item:hover { border-color: var(--border-active); background: var(--bg-card); }
.due-cat-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.due-title { flex: 1; color: var(--text-primary); font-weight: 500; }
.due-interval { font-size: 11px; color: var(--text-dim); }

/* ============================================================
   LIBRARY
   ============================================================ */

.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.filter-chip {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-elevated);
  color: var(--text-dim);
  border: 1px solid var(--border);
  transition: all var(--transition);
  cursor: pointer;
}
.filter-chip:hover { color: var(--text-secondary); border-color: var(--border-active); }
.filter-chip.active { background: var(--blue-dim); color: var(--blue); border-color: var(--border-active); }

.patterns-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
}

/* Pattern Card */
.pattern-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
}

.pattern-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-color, var(--blue));
  opacity: 0;
  transition: opacity var(--transition);
}

.pattern-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  border-color: rgba(255,255,255,0.12);
}
.pattern-card:hover::before { opacity: 1; }

.card-header {
  padding: 18px 20px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.card-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.card-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--bg-elevated);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-difficulty {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.diff-Easy   { background: var(--green-dim); color: var(--green); }
.diff-Medium { background: rgba(245,158,11,0.15); color: var(--amber); }
.diff-Hard   { background: var(--red-dim); color: var(--red); }

.card-complexity {
  padding: 12px 20px;
  display: flex;
  gap: 16px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.complexity-item {
  display: flex; flex-direction: column; gap: 2px;
}
.complexity-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.complexity-val { font-family: var(--font-mono); font-size: 12px; color: var(--green); font-weight: 600; }

.card-preview {
  padding: 12px 20px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.card-footer {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-srs-badge {
  font-size: 10px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 4px;
}

.srs-dot { width: 7px; height: 7px; border-radius: 50%; }
.srs-new      { background: var(--text-dim); }
.srs-due      { background: var(--amber); }
.srs-learning { background: var(--blue); }
.srs-mastered { background: var(--green); }

.card-open-btn {
  font-size: 11px;
  font-weight: 600;
  color: var(--blue);
  background: var(--blue-dim);
  padding: 4px 12px;
  border-radius: 20px;
  transition: all var(--transition);
}
.pattern-card:hover .card-open-btn {
  background: var(--blue);
  color: white;
}

/* ============================================================
   PATTERN DETAIL VIEW
   ============================================================ */

.detail-view {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg-base);
  overflow-y: auto;
}
.detail-view.open { display: block; }

.detail-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 28px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.back-btn {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.back-btn:hover { color: var(--text-primary); border-color: var(--border-active); }

.detail-body {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 28px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.detail-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.detail-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

.complexity-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(52,211,153,0.2);
}

/* Two-column info grid */
.detail-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.info-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.info-panel-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.info-panel ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.info-panel li {
  font-size: 13.5px;
  color: var(--text-secondary);
  padding-left: 16px;
  position: relative;
  line-height: 1.5;
}

.info-panel li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--blue);
  font-size: 11px;
  top: 2px;
}

.trigger-words {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.trigger-chip {
  font-size: 12px;
  padding: 4px 12px;
  background: rgba(167,139,250,0.12);
  color: var(--purple);
  border: 1px solid rgba(167,139,250,0.25);
  border-radius: 20px;
  font-weight: 500;
}

/* Visualization Panel */
.viz-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  overflow: hidden;
}

.viz-panel-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 16px;
}

/* Code Panel */
.code-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.code-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.code-lang-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--amber);
  background: rgba(245,158,11,0.12);
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid rgba(245,158,11,0.2);
}

.copy-btn {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  font-family: var(--font-sans);
  font-weight: 500;
}
.copy-btn:hover { color: var(--text-primary); border-color: var(--border-active); }
.copy-btn.copied { color: var(--green); border-color: rgba(52,211,153,0.3); }

.code-block {
  padding: 20px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: #e2e8f0;
  background: #0a0f1a;
}

/* Pitfalls and Tips */
.pitfall-item, .tip-item {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 8px;
}
.pitfall-item {
  background: var(--red-dim);
  border-left: 3px solid var(--red);
  color: #fca5a5;
}
.tip-item {
  background: var(--green-dim);
  border-left: 3px solid var(--green);
  color: #6ee7b7;
}

.related-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.related-chip {
  font-size: 12px;
  padding: 4px 12px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  transition: all var(--transition);
  cursor: pointer;
}
.related-chip:hover { border-color: var(--blue); color: var(--blue); }

/* ============================================================
   REVIEW / FLASHCARD MODE
   ============================================================ */

.review-container {
  max-width: 700px;
  margin: 0 auto;
}

.review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.review-progress-bar {
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  margin-bottom: 24px;
  overflow: hidden;
}
.review-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--purple));
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* Flashcard */
.flashcard {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  min-height: 400px;
  position: relative;
  transition: all var(--transition);
}

.flashcard-front, .flashcard-back {
  padding: 32px;
}

.flashcard-front { min-height: 400px; display: flex; flex-direction: column; justify-content: space-between; }
.flashcard-back  { border-top: 1px solid var(--border); }

.fc-category-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 16px;
}

.fc-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 16px;
  line-height: 1.3;
}

.fc-trigger {
  font-size: 14px;
  color: var(--purple);
  background: var(--purple-dim);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  line-height: 1.5;
}

.fc-complexity-row {
  display: flex;
  gap: 12px;
}

.fc-complexity {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--green);
  font-weight: 600;
  border: 1px solid rgba(52,211,153,0.2);
}

.reveal-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  color: white;
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  margin-top: 16px;
  transition: all var(--transition);
  letter-spacing: 0.03em;
}
.reveal-btn:hover { opacity: 0.9; transform: translateY(-1px); }

.reveal-section { display: none; }
.reveal-section.shown { display: block; }

/* Rating Buttons */
.rating-section {
  display: none;
  margin-top: 24px;
}
.rating-section.shown { display: block; }

.rating-label {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  margin-bottom: 12px;
}

.rating-btns {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.rating-btn {
  padding: 12px 8px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 700;
  border: 2px solid;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  line-height: 1.2;
}

.rating-btn .rating-main { display: block; font-size: 14px; }
.rating-btn .rating-sub  { display: block; font-size: 10px; margin-top: 3px; opacity: 0.7; font-weight: 500; }

.rating-again { color: #f87171; border-color: rgba(248,113,113,0.3); background: rgba(248,113,113,0.08); }
.rating-again:hover { background: rgba(248,113,113,0.2); box-shadow: 0 0 20px rgba(248,113,113,0.2); }
.rating-hard  { color: var(--amber); border-color: rgba(245,158,11,0.3); background: rgba(245,158,11,0.08); }
.rating-hard:hover  { background: rgba(245,158,11,0.2); }
.rating-good  { color: var(--blue); border-color: rgba(79,142,247,0.3); background: rgba(79,142,247,0.08); }
.rating-good:hover  { background: rgba(79,142,247,0.2); }
.rating-easy  { color: var(--green); border-color: rgba(52,211,153,0.3); background: rgba(52,211,153,0.08); }
.rating-easy:hover  { background: rgba(52,211,153,0.2); box-shadow: 0 0 20px rgba(52,211,153,0.15); }

/* Review empty state */
.review-empty {
  text-align: center;
  padding: 80px 20px;
}
.review-empty-icon { font-size: 64px; margin-bottom: 16px; }
.review-empty-title { font-size: 22px; font-weight: 800; color: var(--text-primary); margin-bottom: 8px; }
.review-empty-sub { font-size: 14px; color: var(--text-secondary); }

/* Review complete */
.review-complete {
  text-align: center;
  padding: 60px 20px;
  display: none;
}
.review-complete.shown { display: block; }

.complete-icon {
  width: 80px; height: 80px;
  background: linear-gradient(135deg, var(--green-dim), rgba(52,211,153,0.25));
  border: 2px solid var(--green);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px;
  margin: 0 auto 20px;
  box-shadow: 0 0 40px rgba(52,211,153,0.2);
}

/* ============================================================
   VISUALIZATIONS (Shared Styles)
   ============================================================ */

.viz-root {
  font-family: var(--font-sans);
  font-size: 13px;
}

.viz-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.viz-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.viz-accent { color: var(--blue); font-weight: 600; }
.viz-green  { color: var(--green); font-weight: 600; }
.viz-red    { color: var(--red); font-weight: 600; }
.viz-purple { color: var(--purple); font-weight: 600; }
.viz-dim    { color: var(--text-dim); }

/* Array cells */
.viz-array-wrap {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: nowrap;
  overflow-x: auto;
}

.viz-cell {
  width: 50px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--bg-elevated);
  transition: all 0.3s ease;
  text-align: center;
}
.viz-val { font-size: 16px; font-weight: 700; color: var(--text-primary); padding: 8px 2px 4px; }
.viz-idx { font-size: 9px; color: var(--text-dim); padding-bottom: 6px; font-family: var(--font-mono); }

.viz-in-window { background: rgba(79,142,247,0.2); border-color: var(--blue); }
.viz-entering  { background: rgba(52,211,153,0.2); border-color: var(--green); }
.viz-leaving   { background: rgba(248,113,113,0.15); border-color: var(--red); opacity: 0.6; }
.viz-eliminated { opacity: 0.25; }
.viz-mid        { background: rgba(79,142,247,0.3); border-color: var(--blue); box-shadow: 0 0 14px rgba(79,142,247,0.4); }
.viz-ptr-l      { border-color: var(--blue); background: rgba(79,142,247,0.15); }
.viz-ptr-r      { border-color: var(--purple); background: rgba(167,139,250,0.15); }
.viz-between    { opacity: 0.5; }
.viz-popped     { border-color: var(--green); background: rgba(52,211,153,0.2); }

.viz-result-badge {
  font-size: 9px;
  color: var(--green);
  font-weight: 700;
  margin-top: 2px;
}

/* Window indicator bar */
.viz-window-bar {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  position: relative;
  margin-bottom: 12px;
  overflow: visible;
}
.viz-window-indicator {
  position: absolute;
  height: 6px;
  background: linear-gradient(90deg, var(--blue), var(--purple));
  border-radius: 3px;
  transition: left 0.4s ease, width 0.4s ease;
  top: 0;
}

/* Linked list */
.viz-linked-list {
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 12px 0;
  overflow-x: auto;
  padding-bottom: 8px;
}
.viz-node-wrap { display: flex; align-items: center; position: relative; }
.viz-node {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
  position: relative;
  transition: all 0.3s ease;
  flex-shrink: 0;
}
.viz-node-slow { border-color: var(--blue); background: rgba(79,142,247,0.2); }
.viz-node-fast { border-color: var(--purple); background: rgba(167,139,250,0.2); }
.viz-node-both { border-color: var(--green); background: rgba(52,211,153,0.2); box-shadow: 0 0 20px rgba(52,211,153,0.3); }
.viz-ptr-label { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); font-size: 9px; font-weight: 700; border-radius: 3px; padding: 1px 4px; }
.slow-label { background: var(--blue); color: white; }
.fast-label { background: var(--purple); color: white; }
.both-label { background: var(--green); color: #0f2b20; white-space: nowrap; }
.viz-arrow { font-size: 16px; color: var(--text-dim); padding: 0 2px; }
.viz-cycle-arrow { font-size: 11px; color: var(--amber); margin-left: 8px; }

/* Stack visual */
.viz-stack-visual {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  min-height: 44px;
}
.viz-stack-label { font-size: 11px; color: var(--text-dim); flex-shrink: 0; }
.viz-stack-items { display: flex; gap: 6px; flex-wrap: wrap; }
.viz-stack-item {
  background: var(--bg-card);
  border: 1px solid var(--border-active);
  color: var(--blue);
  font-size: 12px; font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  display: flex; gap: 4px; align-items: center;
}

/* SVG wrapper */
.viz-svg-wrap {
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

/* Legend */
.viz-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.viz-legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }

/* Log */
.viz-log {
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-secondary);
  min-height: 38px;
  display: flex; align-items: center;
  margin-bottom: 12px;
  line-height: 1.5;
}

/* Controls */
.viz-controls {
  display: flex;
  gap: 8px;
}
.viz-btn {
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: all var(--transition);
  font-family: var(--font-sans);
}
.viz-btn:hover { border-color: var(--border-active); color: var(--text-primary); }
.viz-play { background: var(--blue-dim); color: var(--blue); border-color: var(--border-active); }
.viz-reset { margin-left: auto; }

/* Mode tabs (DFS) */
.viz-mode-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.viz-tab {
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 12px; font-weight: 600;
  background: var(--bg-elevated);
  color: var(--text-dim);
  border: 1px solid var(--border);
  transition: all var(--transition);
  font-family: var(--font-sans);
  cursor: pointer;
}
.viz-tab.active { background: var(--blue-dim); color: var(--blue); border-color: var(--border-active); }

/* Traversal sequence */
.viz-sequence {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 10px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}
.viz-seq-item {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-dim);
  border: 1px solid var(--border);
  font-weight: 600;
}
.viz-seq-done    { color: var(--green); border-color: rgba(52,211,153,0.3); background: rgba(52,211,153,0.08); }
.viz-seq-current { color: var(--blue); border-color: var(--blue); background: var(--blue-dim); box-shadow: 0 0 10px rgba(79,142,247,0.3); }

/* DP Table */
.viz-dp-table-wrap { overflow-x: auto; margin-bottom: 12px; }
.viz-dp-table {
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
  width: max-content;
}
.viz-dp-table th, .viz-dp-table td {
  width: 32px; height: 32px;
  text-align: center;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.viz-dp-table th { background: var(--bg-elevated); color: var(--text-dim); font-weight: 700; }
.viz-dp-filled  { background: rgba(79,142,247,0.12); color: var(--text-primary); }
.viz-dp-current { background: var(--blue) !important; color: white !important; font-weight: 700; border-color: var(--blue) !important; box-shadow: 0 0 12px rgba(79,142,247,0.5); }
.viz-dp-diag    { background: rgba(167,139,250,0.15); color: var(--purple); }

/* Bar chart (prefix sum) */
.viz-bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 100px;
  margin-bottom: 16px;
  padding: 0 4px;
}
.viz-bar-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.viz-bar-val { font-size: 11px; color: var(--text-secondary); font-weight: 600; }
.viz-bar {
  width: 100%;
  min-height: 10px;
  border-radius: 3px 3px 0 0;
  background: var(--bg-elevated);
  transition: all 0.4s ease;
}
.viz-bar-idx { font-size: 9px; color: var(--text-dim); font-family: var(--font-mono); }

.viz-prefix-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.viz-prefix-label { font-size: 11px; color: var(--text-dim); flex-shrink: 0; }
.viz-prefix-cell {
  font-family: var(--font-mono);
  font-size: 12px;
  width: 36px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-elevated);
  color: var(--text-dim);
  font-weight: 600;
  transition: all 0.3s ease;
}
.viz-prefix-cell.viz-mid { color: white; background: var(--blue); border-color: var(--blue); }
.viz-prefix-cell.viz-in-window { color: var(--green); background: rgba(52,211,153,0.1); border-color: rgba(52,211,153,0.3); }

.viz-query-demo {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

/* Backtracking styles */
.viz-bt-visual {
  padding: 12px 14px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  min-height: 60px;
  display: flex;
  align-items: center;
}
.viz-bt-path {
  display: flex;
  align-items: center;
  gap: 10px;
  transition: margin 0.3s ease;
}
.viz-bt-arrow { font-size: 14px; color: var(--text-dim); letter-spacing: -2px; }
.viz-bt-current { font-family: var(--font-mono); font-size: 16px; font-weight: 700; color: var(--text-primary); }
.viz-bt-state {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
}
.viz-bt-state.record   { background: var(--green-dim); color: var(--green); }
.viz-bt-state.choose   { background: var(--blue-dim);  color: var(--blue); }
.viz-bt-state.unchoose { background: var(--purple-dim); color: var(--purple); }

.viz-subsets-found { margin-bottom: 12px; }
.viz-subset-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.viz-subset-chip {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}
.viz-subset-chip.latest {
  background: var(--green-dim);
  color: var(--green);
  border-color: rgba(52,211,153,0.3);
}

/* Union Find */
.viz-parent-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}
.viz-parent-cell {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* ============================================================
   UTILITY / SHARED
   ============================================================ */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.btn-primary {
  padding: 8px 20px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  color: white;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-sans);
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-title { font-size: 16px; font-weight: 700; color: var(--text-secondary); margin-bottom: 6px; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .sidebar { width: 200px; }
  .main-content { margin-left: 200px; }
  .dashboard-hero { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .detail-info-grid { grid-template-columns: 1fr; }
  .rating-btns { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .sidebar { transform: translateX(-100%); position: fixed; z-index: 200; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page { padding: 16px; }
  .patterns-grid { grid-template-columns: 1fr; }
  .dashboard-hero { grid-template-columns: 1fr; }
}

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.fade-in { animation: fadeIn 0.3s ease forwards; }

/* Highlight.js overrides */
.hljs { background: transparent !important; padding: 0 !important; }
.hljs-comment { color: #64748b !important; font-style: italic; }
.hljs-keyword { color: #c084fc !important; }
.hljs-string  { color: #34d399 !important; }
.hljs-number  { color: #f59e0b !important; }
.hljs-title, .hljs-function { color: #4f8ef7 !important; }
.hljs-type    { color: #38bdf8 !important; }
.hljs-built_in { color: #f87171 !important; }
.hljs-params  { color: #e2e8f0 !important; }
