:root {
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-light: #eff6ff;
  --bg-dark: #0f172a;
  --surface-dark: #1e293b;
  --surface-card: #24344d;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --accent-purple: #8b5cf6;
  --font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
}

/* Header & Top Bar */
.navbar {
  background: var(--surface-dark);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  font-size: 24px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.brand-title h1 {
  font-size: 18px;
  font-weight: 700;
}

.brand-title p {
  font-size: 12px;
  color: var(--text-muted);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.search-box {
  position: relative;
  width: 280px;
}

.search-box input {
  width: 100%;
  padding: 8px 14px 8px 36px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: var(--surface-card);
  color: var(--text-main);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

/* Nav Tabs */
.tabs-bar {
  display: flex;
  background: var(--surface-dark);
  padding: 8px 24px 0 24px;
  border-bottom: 1px solid var(--border-color);
  gap: 8px;
  overflow-x: auto;
}

.nav-tab {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-tab:hover {
  color: var(--text-main);
}

.nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: rgba(59, 130, 246, 0.08);
  border-radius: 6px 6px 0 0;
}

/* Layout */
.app-container {
  max-width: 1350px;
  margin: 0 auto;
  padding: 24px;
}

/* Hero / Fast Track Cram Banner */
.cram-banner {
  background: linear-gradient(135deg, #1e3a8a, #4338ca);
  border: 1px solid #3b82f6;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.cram-text h2 {
  font-size: 20px;
  margin-bottom: 4px;
  color: #fff;
}

.cram-text p {
  font-size: 14px;
  color: #c7d2fe;
}

.cram-buttons {
  display: flex;
  gap: 12px;
}

.btn {
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background: #2d4160;
}

.btn-accent {
  background: var(--accent-green);
  color: white;
}
.btn-accent:hover {
  background: #059669;
}

/* Sub-nav Pill Filter */
.filter-pills {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.pill-btn {
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--surface-dark);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.pill-btn:hover, .pill-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Card Lists */
.qa-card {
  background: var(--surface-dark);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s, border-color 0.2s;
}

.qa-card:hover {
  border-color: #475569;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  text-transform: uppercase;
}

.badge-long { background: rgba(139, 92, 246, 0.2); color: #c4b5fd; border: 1px solid #8b5cf6; }
.badge-short { background: rgba(59, 130, 246, 0.2); color: #93c5fd; border: 1px solid #3b82f6; }
.badge-mcq { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; border: 1px solid #10b981; }
.badge-lab { background: rgba(245, 158, 11, 0.2); color: #fde68a; border: 1px solid #f59e0b; }

.q-title {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  flex: 1;
  margin-right: 12px;
}

.answer-body {
  font-size: 14px;
  color: #cbd5e1;
  background: var(--surface-card);
  padding: 14px 18px;
  border-radius: 8px;
  border-left: 4px solid var(--primary);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}

.answer-body code {
  background: #1e293b;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Consolas', monospace;
  color: #38bdf8;
}

.answer-body pre {
  background: #0f172a;
  padding: 12px;
  border-radius: 6px;
  margin: 10px 0;
  overflow-x: auto;
  font-family: 'Consolas', monospace;
  color: #a5f3fc;
  border: 1px solid #334155;
}

/* MCQ Options */
.mcq-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

@media (max-width: 768px) {
  .mcq-options-grid {
    grid-template-columns: 1fr;
  }
}

.mcq-opt {
  padding: 10px 14px;
  background: var(--surface-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mcq-opt:hover {
  background: #2e4466;
}

.mcq-opt.selected-correct {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--accent-green);
  color: #a7f3d0;
  font-weight: bold;
}

.mcq-opt.selected-wrong {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--accent-red);
  color: #fca5a5;
}

/* Interactive Visualizer Canvas */
.viz-panel {
  background: var(--surface-dark);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
}

.viz-canvas-area {
  height: 240px;
  background: #0a0f1d;
  border-radius: 8px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  margin: 16px 0;
  border: 1px solid #1e293b;
}

.bar-element {
  width: 44px;
  background: #3b82f6;
  border-radius: 6px 6px 0 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 6px;
  color: white;
  font-weight: bold;
  font-size: 13px;
  transition: height 0.3s ease, background-color 0.3s ease;
}

.bar-element.comparing {
  background: #f59e0b !important;
}

.bar-element.swapping {
  background: #ef4444 !important;
}

.bar-element.sorted {
  background: #10b981 !important;
}

/* Stack Visualizer */
.stack-canvas {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 6px;
  width: 180px;
  margin: 0 auto;
  border-bottom: 6px solid #475569;
  border-left: 4px solid #475569;
  border-right: 4px solid #475569;
  padding: 8px;
  min-height: 190px;
}

.stack-item {
  width: 100%;
  padding: 10px;
  background: #3b82f6;
  color: white;
  text-align: center;
  border-radius: 4px;
  font-weight: bold;
  animation: slideDown 0.25s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Code sandbox */
.sandbox-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 900px) {
  .sandbox-split {
    grid-template-columns: 1fr;
  }
}

.code-editor-area {
  width: 100%;
  height: 280px;
  background: #0f172a;
  color: #38bdf8;
  font-family: 'Consolas', monospace;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  resize: vertical;
}

.preview-frame {
  width: 100%;
  height: 280px;
  background: white;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

/* Quiz Modal */
.quiz-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.quiz-dialog {
  background: var(--surface-dark);
  border: 1px solid var(--border-color);
  width: 90%;
  max-width: 650px;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.quiz-timer {
  font-size: 18px;
  font-weight: bold;
  color: var(--accent-amber);
}

/* Footer */
footer {
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
  font-size: 13px;
  border-top: 1px solid var(--border-color);
  margin-top: 40px;
}
