/* ─── TOKENS ─── */
:root {
  --bg: #0d0d0f;
  --surface: #16161a;
  --surface2: #1e1e24;
  --border: #2a2a35;
  --accent: #c8f060;
  --accent2: #60d0f0;
  --accent3: #f060a8;
  --text: #f0f0f5;
  --text-muted: #7a7a8c;
  --text-dim: #3a3a4a;
  --radius: 12px;
  --font-display: 'Syne', sans-serif;
  --font-mono: 'DM Mono', monospace;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(200,240,96,0.04) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(96,208,240,0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ─── SCREENS ─── */
.screen { display: none; min-height: 100vh; position: relative; z-index: 1; }
.screen.active { display: flex; flex-direction: column; }

/* ─── HEADER ─── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
}

.logo { font-size: 18px; font-weight: 800; letter-spacing: -0.5px; }
.logo span { color: var(--accent); }

.header-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* ─── HOME SCREEN ─── */
#home-screen .hero {
  padding: 48px 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.hero h1 {
  font-size: clamp(36px, 8vw, 52px);
  font-weight: 800;
  line-height: 1.0;
  letter-spacing: -2px;
}

.hero h1 em { font-style: normal; color: var(--accent); }

.hero p {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 340px;
}

/* Stats row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 28px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-card .val { font-size: 26px; font-weight: 800; letter-spacing: -1px; }
.stat-card .lbl {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-card:nth-child(1) .val { color: var(--accent); }
.stat-card:nth-child(2) .val { color: var(--accent2); }
.stat-card:nth-child(3) .val { color: var(--accent3); }

/* Deck list */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  margin-bottom: 14px;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.btn-text {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  letter-spacing: 0.5px;
}

.deck-list {
  padding: 0 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.deck-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: border-color 0.2s, transform 0.15s;
  position: relative;
  overflow: hidden;
}

.deck-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: 3px 0 0 3px;
}

.deck-card.c1::before { background: var(--accent); }
.deck-card.c2::before { background: var(--accent2); }
.deck-card.c3::before { background: var(--accent3); }
.deck-card.c4::before { background: #f0a060; }
.deck-card.c5::before { background: #a060f0; }

.deck-card:hover {
  border-color: rgba(255,255,255,0.15);
  transform: translateX(3px);
}

.deck-info h3 { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.deck-info .meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

.deck-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.deck-progress {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.progress-bar {
  width: 60px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.5s;
}

.deck-card.c2 .progress-fill { background: var(--accent2); }
.deck-card.c3 .progress-fill { background: var(--accent3); }
.deck-card.c4 .progress-fill { background: #f0a060; }
.deck-card.c5 .progress-fill { background: #a060f0; }

.pct { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

.btn-icon {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-icon:hover { border-color: var(--accent); color: var(--accent); }

/* Bottom nav */
.bottom-nav { display: flex; border-top: 1px solid var(--border); margin-top: 28px; }

.nav-btn {
  flex: 1;
  padding: 18px 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: color 0.2s;
}

.nav-btn.active, .nav-btn:hover { color: var(--accent); }
.nav-btn svg { width: 20px; height: 20px; }

/* ─── FLASH SCREEN ─── */
#flash-screen { padding: 0; }

.flash-header {
  display: flex;
  align-items: center;
  padding: 20px 24px;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.btn-back {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  transition: border-color 0.2s;
}

.btn-back:hover { border-color: var(--accent); }

.flash-title { flex: 1; }
.flash-title h2 { font-size: 16px; font-weight: 700; }
.flash-title span { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

.progress-track { display: flex; gap: 4px; padding: 16px 24px; }

.progress-pip {
  flex: 1;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  transition: background 0.3s;
}

.progress-pip.done { background: var(--accent); }
.progress-pip.current { background: rgba(200,240,96,0.4); }

.card-area {
  padding: 0 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.flashcard-wrap { width: 100%; perspective: 1200px; cursor: pointer; }

.flashcard {
  width: 100%;
  min-height: 260px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}

.flashcard.flipped { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 16px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.card-front { background: var(--surface); border: 1px solid var(--border); }
.card-back {
  background: linear-gradient(135deg, #1a2010, #0d1a10);
  border: 1px solid rgba(200,240,96,0.3);
  transform: rotateY(180deg);
}

.card-face-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 20px;
  align-self: flex-start;
}

.card-back .card-face-label { color: rgba(200,240,96,0.5); }

.card-question { font-size: 20px; font-weight: 700; line-height: 1.3; letter-spacing: -0.5px; }
.card-answer { font-size: 17px; font-weight: 600; line-height: 1.4; color: var(--accent); }

.flip-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.rating-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  width: 100%;
  padding: 0 24px 32px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.rating-row.visible { opacity: 1; pointer-events: all; }

.rating-btn {
  padding: 14px 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.rating-btn .emoji { font-size: 18px; }
.rating-btn .lbl { font-size: 10px; font-family: var(--font-mono); color: var(--text-muted); }

.rating-btn.hard:hover { background: rgba(240,96,96,0.15); border-color: #f06060; color: #f06060; }
.rating-btn.ok:hover { background: rgba(240,200,96,0.15); border-color: #f0c860; color: #f0c860; }
.rating-btn.easy:hover { background: rgba(200,240,96,0.15); border-color: var(--accent); color: var(--accent); }

/* ─── QUIZ SCREEN ─── */
#quiz-screen { padding: 0; }

.quiz-header {
  display: flex;
  align-items: center;
  padding: 20px 24px;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.quiz-header h2 { font-size: 16px; font-weight: 700; flex: 1; }

.quiz-score-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
}

.quiz-body { flex: 1; padding: 24px; display: flex; flex-direction: column; gap: 20px; }

.question-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.question-text { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; line-height: 1.2; }

.answers-grid { display: flex; flex-direction: column; gap: 10px; flex: 1; }

.answer-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  text-align: left;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 14px;
}

.answer-btn .idx {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.answer-btn:hover:not(:disabled) {
  border-color: rgba(200,240,96,0.4);
  background: rgba(200,240,96,0.05);
}

.answer-btn.correct { border-color: var(--accent); background: rgba(200,240,96,0.1); color: var(--accent); }
.answer-btn.correct .idx { background: var(--accent); color: #000; }
.answer-btn.wrong { border-color: #f06060; background: rgba(240,96,96,0.08); color: #f06060; }
.answer-btn.wrong .idx { background: #f06060; color: #fff; }
.answer-btn:disabled { cursor: default; }

.next-btn {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: 16px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: opacity 0.2s, transform 0.15s;
  display: none;
}

.next-btn.visible { display: block; }
.next-btn:hover { opacity: 0.9; transform: translateY(-1px); }

/* ─── RESULTS SCREEN ─── */
#results-screen {
  justify-content: center;
  align-items: center;
  padding: 40px 28px;
  gap: 24px;
  text-align: center;
}

.result-ring { width: 140px; height: 140px; position: relative; }
.result-ring svg { transform: rotate(-90deg); }

.result-ring .pct-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.result-ring .pct-num { font-size: 36px; font-weight: 800; letter-spacing: -2px; color: var(--accent); }
.result-ring .pct-lbl { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); }
.result-title { font-size: 32px; font-weight: 800; letter-spacing: -1px; line-height: 1.1; }
.result-sub { font-family: var(--font-mono); font-size: 13px; color: var(--text-muted); line-height: 1.6; }

.result-breakdown { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }

.breakdown-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.breakdown-item .num { font-size: 28px; font-weight: 800; letter-spacing: -1px; }
.breakdown-item:nth-child(1) .num { color: var(--accent); }
.breakdown-item:nth-child(2) .num { color: #f06060; }
.breakdown-item .dsc { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

.cta-row { display: flex; gap: 10px; width: 100%; }

.btn-primary {
  flex: 1;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: 16px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-primary:hover { opacity: 0.9; }

.btn-secondary {
  flex: 1;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.2s;
}

.btn-secondary:hover { border-color: rgba(255,255,255,0.3); }

/* ─── PROGRESS SCREEN ─── */
#progress-screen { padding: 0; }

.progress-hero { padding: 32px 28px 24px; }
.progress-hero h2 { font-size: 28px; font-weight: 800; letter-spacing: -1px; margin-top: 8px; }

.heatmap-section { padding: 0 28px 24px; }

.heatmap-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.heatmap { display: grid; grid-template-columns: repeat(14, 1fr); gap: 3px; }

.hmap-cell {
  aspect-ratio: 1;
  border-radius: 2px;
  background: var(--surface);
  transition: background 0.2s;
}

.hmap-cell.l1 { background: rgba(200,240,96,0.2); }
.hmap-cell.l2 { background: rgba(200,240,96,0.4); }
.hmap-cell.l3 { background: rgba(200,240,96,0.7); }
.hmap-cell.l4 { background: var(--accent); }

.weak-section { padding: 0 28px 24px; }

.weak-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.weak-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(240,96,168,0.15);
  border: 1px solid rgba(240,96,168,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.weak-info { flex: 1; }
.weak-info .name { font-size: 14px; font-weight: 700; }
.weak-info .hint { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.weak-pct { font-family: var(--font-mono); font-size: 13px; color: var(--accent3); font-weight: 400; }

/* ─── MODAL ─── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 100;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 0 0 32px;
  animation: slideUp 0.3s cubic-bezier(0.4,0,0.2,1);
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 18px; font-weight: 800; letter-spacing: -0.5px; }

.btn-close {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 18px;
  transition: all 0.2s;
}

.btn-close:hover { border-color: #f06060; color: #f06060; }

.modal-tabs {
  display: flex;
  padding: 16px 24px 0;
  gap: 6px;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 8px 8px 0 0;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: all 0.2s;
  position: relative;
  bottom: -1px;
}

.tab-btn.active {
  color: var(--accent);
  border-color: var(--border);
  border-bottom-color: var(--surface);
  background: var(--surface);
}

.tab-pane { display: none; padding: 20px 24px 0; }
.tab-pane.active { display: block; }

/* Form elements */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  appearance: none;
}

.form-textarea { resize: vertical; min-height: 80px; line-height: 1.5; }

.form-input:focus,
.form-textarea:focus,
.form-select:focus { border-color: var(--accent); }

.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-dim); font-weight: 400; }

.color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}

.color-swatch.selected { border-color: #fff; transform: scale(1.15); }

.btn-full {
  width: 100%;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: 16px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: opacity 0.2s, transform 0.15s;
  margin-top: 8px;
}

.btn-full:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-danger {
  background: rgba(240,96,96,0.15);
  color: #f06060;
  border: 1px solid rgba(240,96,96,0.3);
}

.btn-danger:hover { background: rgba(240,96,96,0.25); opacity: 1; }

/* Card list inside modal */
.card-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }

.card-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.card-item-content { flex: 1; min-width: 0; }

.card-item-q {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-item-a {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 16px;
  padding: 0 2px;
  transition: color 0.15s;
  flex-shrink: 0;
}

.btn-remove:hover { color: #f06060; }

.empty-state {
  text-align: center;
  padding: 28px 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 10px 20px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  z-index: 200;
  opacity: 0;
  transition: all 0.3s;
  white-space: nowrap;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── ANIMATIONS ─── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.screen.active > * { animation: fadeUp 0.4s ease both; }
.screen.active > *:nth-child(1) { animation-delay: 0.0s; }
.screen.active > *:nth-child(2) { animation-delay: 0.05s; }
.screen.active > *:nth-child(3) { animation-delay: 0.1s; }
.screen.active > *:nth-child(4) { animation-delay: 0.15s; }
.screen.active > *:nth-child(5) { animation-delay: 0.2s; }
