/* ═══════════════════════════════════════════
   CSS VARIABLES & THEME (Matching your engine)
═══════════════════════════════════════════ */
:root {
  --bg:         #0d1117;
  --surface:    #161b22;
  --surface2:   #1c2330;
  --border:     #30363d;
  --text:       #e6edf3;
  --text-muted: #8b949e;
  --accent:     #f0a500;
  --accent-dim: rgba(240,165,0,0.12);
  --radius:     12px;
  --shadow:     0 4px 24px rgba(0,0,0,0.4);

  --wrong:        #da3633;
  --wrong-bg:     rgba(218,54,51,0.12);
  --flagged:      #58a6ff;
  --flagged-bg:   rgba(88,166,255,0.12);
  --correct:      #2ea043;
  --correct-bg:   rgba(46,160,67,0.12);
}
[data-theme="light"] {
  --bg:         #f3f0eb;
  --surface:    #ffffff;
  --surface2:   #f8f6f1;
  --border:     #d0ccc5;
  --text:       #1c1917;
  --text-muted: #78716c;
  --accent:     #c27803;
  --accent-dim: rgba(194,120,3,0.10);
  --shadow:     0 4px 24px rgba(0,0,0,0.10);
  --skip:       #3b82f6;
  --correct-bg: rgba(34,197,94,0.12);
  --wrong-bg:   rgba(239,68,68,0.12);
  --flagged-bg: rgba(59,130,246,0.12);
}

/* ═══════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  
  display: flex;
  flex-direction: column;
}
button, a { cursor: pointer; font-family: inherit; border: none; outline: none; text-decoration: none; }

/* ═══════════════════════════════════════════
   TOP BAR
═══════════════════════════════════════════ */
.topbar {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  font-weight: 700;
  flex: 1;
  color: var(--text);
}
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  
  font-size: 1.1rem;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.back-btn { margin-right: 0.75rem; }

/* ═══════════════════════════════════════════
   MAIN LAYOUT & HERO
═══════════════════════════════════════════ */
.container {
  flex: 1;
  overflow-y: auto;
  padding: 3rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.hero {
  text-align: center;
  max-width: 600px;
  margin-bottom: 3.5rem;
}
.hero h1 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  line-height: 1.1;
  margin-bottom: 1rem;
}
.hero h1 span { color: var(--accent); }
.hero p {
  color: var(--text-muted);
  font-size: 1.05rem;
}

/* ═══════════════════════════════════════════
   QUIZ GRID & CARDS
═══════════════════════════════════════════ */
.quiz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
  width: 100%;
  max-width: 1100px;
}
.quiz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  
}
.quiz-card:hover {
  transform: translateY(-5px);
  border-color: var(--accent);
}
.card-icon {
  width: 56px; height: 56px;
  background: var(--accent-dim);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 1.25rem;
}
.card-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  color: var(--text);
  margin-bottom: 0.5rem;
  line-height: 1.2;
}
.card-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  flex: 1;
}
.card-meta {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.meta-badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.btn-take-quiz {
  display: inline-block;
  text-align: center;
  width: 100%;
  padding: 0.85rem;
  border-radius: var(--radius);
  background: var(--accent);
  color: #000;
  font-weight: 700;
  font-size: 0.95rem;
  
}
.btn-take-quiz:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-take-quiz:active { transform: translateY(0); }

/* ═══════════════════════════════════════════
   FOOTNOTE
═══════════════════════════════════════════ */
.footer-note {
  margin-top: 3rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.footer-note a {
  color: var(--accent);
  text-decoration: none;
  
}
.footer-note a:hover {
  opacity: 0.8;
}

/* ═══════════════════════════════════════════
   QUESTION TRACKER DASHBOARD
═══════════════════════════════════════════ */
.btn-tracker {
  width: 38px; height: 38px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 1.1rem;
  
  cursor: pointer;
  position: relative;
  margin-right: 0.5rem;
}
.btn-tracker:hover { color: var(--accent); border-color: var(--accent); }
.btn-tracker .tracker-badge {
  position: absolute; top: -3px; right: -3px;
  min-width: 15px; height: 15px;
  border-radius: 8px;
  background: var(--text-muted);
  color: var(--surface);
  font-size: 0.55rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
  line-height: 1;
  opacity: 0.75;
}
.btn-tracker .tracker-badge:empty { display: none; }

.dash-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.dash-overlay.open { display: flex; }

/* Modal overlay for confirmations (same as quiz-engine) */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  z-index: 2100; display: none; align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 2rem; max-width: 420px; width: 100%; box-shadow: var(--shadow);
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { opacity:0; transform: translateY(20px); } to { opacity:1; transform: translateY(0); } }
.modal h3 { font-family: 'Playfair Display', serif; font-size: 1.3rem; margin-bottom: 0.75rem; }
.modal p  { color: var(--text-muted); font-size: 0.9rem; line-height: 1.6; margin-bottom: 1.25rem; }
.modal-actions { display: flex; gap: 0.75rem; }
.modal-actions .btn-cancel {
  flex: 1; padding: 0.75rem; border-radius: 10px;
  background: var(--surface2); border: 1.5px solid var(--border);
  color: var(--text); font-weight: 600; cursor: pointer;
  transition: all 0.2s ease;
}
.modal-actions .btn-cancel:hover { border-color: var(--accent); }
.modal-actions .btn-confirm {
  flex: 1; padding: 0.75rem; border-radius: 10px;
  background: var(--accent); border: none;
  color: #fff; font-weight: 600; cursor: pointer;
  transition: opacity 0.2s ease;
}
.modal-actions .btn-confirm.danger { background: var(--wrong); }
.modal-actions .btn-confirm:hover { opacity: 0.85; }

.dash-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%;
  max-width: 680px;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

.dash-header {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.dash-header h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  flex: 1;
}
.dash-close-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  
}
.dash-close-btn:hover { color: var(--text); border-color: var(--accent); }

.dash-scope-bar {
  display: flex; gap: 0; padding: 0 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  justify-content: center;
}
.dash-scope-tab {
  padding: 0.6rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  
  background: none; border-top: none; border-left: none; border-right: none;
}
.dash-scope-tab:hover { color: var(--text); }
.dash-scope-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.dash-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.dash-stat {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem;
  text-align: center;
}
.dash-stat .ds-val { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.dash-stat .ds-lbl { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 0.2rem; }
.ds-val.red { color: var(--wrong); }
.ds-val.blue { color: var(--flagged); }
.ds-val.green { color: var(--correct); }

.dash-body { flex: 1; overflow-y: auto; padding: 1.5rem; min-height: 0; display: flex; flex-direction: column; }
.dash-body::-webkit-scrollbar { width: 6px; }
.dash-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.dash-folder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
}
.dash-folder-header:first-child {
  margin-top: 0;
}
.dash-folder-content.collapsed + .dash-folder-header {
  margin-top: 0.15rem;
  margin-bottom: 0.15rem;
}
.dash-folder-title {
  font-family: "Playfair Display", serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
  padding: 0.4rem 0 0.25rem;
  margin-bottom: 0.15rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  user-select: none;
}
.dash-folder-title:hover { opacity: 0.85; }
.dash-folder-toggle {
  font-size: 0.9rem;
  transition: transform 0.2s ease;
  display: inline-block;
}
.dash-folder-toggle.collapsed { transform: rotate(-90deg); }
.dash-folder-content {
  transition: max-height 0.3s ease, opacity 0.25s ease;
  overflow: visible;
  max-height: none;
  opacity: 1;
  padding-bottom: 0.25rem;
  flex: 1;
}
.dash-folder-content.collapsed { 
  max-height: 0; 
  opacity: 0; 
  overflow: hidden;
  margin-bottom: 0;
  padding-bottom: 0;
}
.dash-folder-select {
  margin-left: auto;
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
}

.dash-quiz-group { margin-bottom: 0.5rem; }
.dash-quiz-title {
  font-weight: 700; font-size: 0.9rem; color: var(--text);
  margin-bottom: 0.4rem; display: flex; align-items: center; gap: 0.5rem;
}
.dash-quiz-title .quiz-badge { font-size: 0.65rem; padding: 0.15rem 0.5rem; border-radius: 5px; font-weight: 600; }
.dash-quiz-title .quiz-badge.wrong-badge { background: var(--wrong-bg); color: var(--wrong); }
.dash-quiz-title .quiz-badge.flag-badge { background: var(--flagged-bg); color: var(--flagged); }

.dash-q-item {
  display: flex; align-items: flex-start; gap: 0.5rem;
  padding: 0.5rem 0.65rem; border-radius: 8px; margin-bottom: 0.25rem;
  border: 1px solid var(--border); background: var(--surface2);
}
.dash-q-item:last-child { margin-bottom: 0; }
.dash-q-item:hover { border-color: var(--accent); }
.dash-q-icon {
  width: 24px; height: 24px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700; flex-shrink: 0; margin-top: 0.1rem;
}
.dash-q-icon.wrong { background: var(--wrong-bg); color: var(--wrong); }
.dash-q-icon.flagged { background: var(--flagged-bg); color: var(--flagged); }
.dash-q-content { flex: 1; min-width: 0; }
.dash-q-num { font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.dash-q-text { font-size: 0.85rem; font-weight: 500; line-height: 1.4; color: var(--text); word-wrap: break-word; }
.dash-q-remove {
  width: 22px; height: 22px; border-radius: 5px;
  background: transparent; border: 1px solid transparent;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 0.75rem; cursor: pointer;
   flex-shrink: 0;
}
.dash-q-remove:hover { border-color: var(--wrong); color: var(--wrong); background: var(--wrong-bg); }

.dash-footer {
  padding: 1rem 1.5rem; border-top: 1px solid var(--border);
  display: flex; gap: 0.75rem; flex-shrink: 0;
}
.btn-dash-action {
  padding: 0.65rem 1.25rem; border-radius: 8px;
  background: var(--surface2); border: 1.5px solid var(--border);
  color: var(--text); font-weight: 600; font-size: 0.85rem;
  cursor: pointer; 
}
.btn-dash-action:hover { border-color: var(--accent); color: var(--accent); }
.btn-dash-danger { border-color: var(--wrong); color: var(--wrong); }
.btn-dash-danger:hover { border-color: var(--wrong); color: var(--wrong); background: rgba(220, 38, 38, 0.08); }
.btn-dash-close {
  flex: 1; padding: 0.65rem 1.25rem; border-radius: 8px;
  background: var(--accent); border: 1.5px solid var(--accent);
  color: #000; font-weight: 700; font-size: 0.85rem;
  cursor: pointer; 
}
.btn-dash-close:hover { opacity: 0.85; }

.dash-empty { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); }
.dash-empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.5; }
.dash-empty p { font-size: 0.9rem; line-height: 1.5; }

@media (max-width: 480px) {
  .dash-modal { max-height: 90vh; border-radius: 16px; }
  .dash-summary { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; padding: 1rem; }
  .dash-stat { padding: 0.6rem; }
  .dash-stat .ds-val { font-size: 1.2rem; }
  .dash-body { padding: 0.75rem 1rem; }
}
