:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1e222b;
  --border: #2a2f3a;
  --text: #e8eaf0;
  --text-dim: #9aa1af;
  --accent: #4f7cff;
  --accent-soft: rgba(79, 124, 255, 0.14);
  --green: #2ecc71;
  --green-soft: rgba(46, 204, 113, 0.14);
  --red: #e74c3c;
  --red-soft: rgba(231, 76, 60, 0.14);
  --amber: #f5b041;
  --radius: 14px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(15, 17, 21, 0.92);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.brand {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
}
.brand span { color: var(--accent); }

.topbar-right { color: var(--text-dim); font-size: 0.9rem; font-variant-numeric: tabular-nums; }

#app { max-width: 680px; margin: 0 auto; padding: 20px 16px 60px; }

.screen.hidden, .hidden { display: none !important; }

.section-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-dim);
  margin: 26px 0 12px;
}

/* Ana ekran */
.stats-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}
.stat-card .value { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-card .label { font-size: 0.75rem; color: var(--text-dim); margin-top: 4px; }
.stat-card.good .value { color: var(--green); }
.stat-card.bad .value { color: var(--red); }

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.category-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.15s, transform 0.1s;
}
.category-card:hover { border-color: var(--accent); }
.category-card:active { transform: scale(0.98); }
.category-card .cat-name { font-size: 1.05rem; font-weight: 700; }
.category-card .cat-info { font-size: 0.8rem; color: var(--text-dim); margin-top: 6px; }
.category-card .cat-score { font-size: 0.8rem; margin-top: 4px; font-weight: 600; }
.category-card.wrong-cat { border-color: rgba(231, 76, 60, 0.45); }
.category-card.wrong-cat .cat-name { color: var(--red); }

.study-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.15s, transform 0.1s;
}
.study-card:hover { border-color: var(--amber); }
.study-card:active { transform: scale(0.98); }
.study-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(245, 176, 65, 0.14);
  border: 1px solid rgba(245, 176, 65, 0.35);
  font-size: 1.25rem;
  flex-shrink: 0;
}
.study-text { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.study-title { font-size: 1.02rem; font-weight: 700; }
.study-sub { font-size: 0.8rem; color: var(--text-dim); }
.study-arrow { font-size: 1.6rem; color: var(--text-dim); font-weight: 300; line-height: 1; }

.btn-reset {
  display: block;
  margin: 34px auto 0;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  padding: 10px 16px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}
.btn-reset:hover { color: var(--red); background: var(--red-soft); }

.codes-filter { display: flex; gap: 8px; margin-bottom: 16px; }
.filter-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-dim);
  padding: 7px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.filter-chip.selected { border-color: var(--amber); color: var(--amber); background: rgba(245, 176, 65, 0.12); }

.codes-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.code-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  border-radius: 12px;
  padding: 14px 16px;
}
.code-card .c-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.code-card .c-code { font-size: 1.05rem; font-weight: 800; color: var(--amber); letter-spacing: 0.5px; }
.code-card .c-ders { font-size: 0.72rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }
.code-card .c-konu { font-size: 0.9rem; font-weight: 600; margin-top: 4px; }
.code-card .c-acilim { font-size: 0.88rem; color: var(--text); margin-top: 8px; line-height: 1.55; }
.code-card .c-detay { font-size: 0.82rem; color: var(--text-dim); margin-top: 6px; line-height: 1.5; }

.booklet-link {
  display: block;
  text-decoration: none;
  color: var(--text);
  border-left-color: var(--accent);
  transition: border-color 0.15s;
}
.booklet-link:hover { border-color: var(--accent); }
.booklet-link .c-code { color: var(--accent); }

.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.88rem;
}
.history-item .h-cat { font-weight: 600; }
.history-item .h-date { color: var(--text-dim); font-size: 0.78rem; margin-top: 2px; }
.history-item .h-score { font-weight: 700; font-variant-numeric: tabular-nums; }
.history-empty { color: var(--text-dim); font-size: 0.88rem; padding: 8px 2px; }

/* Kurulum */
.setup-title { font-size: 1.4rem; margin-top: 10px; }
.setup-sub { color: var(--text-dim); margin: 6px 0 20px; font-size: 0.9rem; }
.count-options { display: flex; gap: 10px; margin-bottom: 18px; }
.count-btn {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 14px 0;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.count-btn.selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  color: var(--text-dim);
  margin-bottom: 24px;
  cursor: pointer;
}
.check-row input { width: 18px; height: 18px; accent-color: var(--accent); }

/* Butonlar */
.btn-primary {
  display: block;
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 15px;
  font-size: 1.02rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.15s;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost {
  display: block;
  width: 100%;
  background: none;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
  margin-top: 10px;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); }

/* Soru ekranı */
.quiz-meta { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.topic-chip {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.progress-track {
  flex: 1;
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.25s ease;
}

.question-text {
  font-size: 1.08rem;
  line-height: 1.65;
  margin-bottom: 20px;
  white-space: pre-wrap;
}

.options { display: flex; flex-direction: column; gap: 10px; }
.option-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  padding: 13px 14px;
  font-size: 0.98rem;
  line-height: 1.5;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.12s, background 0.12s;
}
.option-btn:hover:not(:disabled) { border-color: var(--accent); }
.option-btn:disabled { cursor: default; }
.option-btn .opt-letter {
  font-weight: 800;
  color: var(--text-dim);
  min-width: 20px;
}
.option-btn.correct {
  background: var(--green-soft);
  border-color: var(--green);
}
.option-btn.correct .opt-letter { color: var(--green); }
.option-btn.wrong {
  background: var(--red-soft);
  border-color: var(--red);
}
.option-btn.wrong .opt-letter { color: var(--red); }
.option-btn.dimmed { opacity: 0.45; }

.explanation {
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  border-radius: 10px;
  padding: 13px 15px;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-dim);
}
.explanation strong { color: var(--amber); }

.quiz-actions { display: flex; gap: 10px; margin-top: 22px; }
.quiz-actions .btn-ghost { flex: 1; margin-top: 0; }
.quiz-actions .btn-primary { flex: 2; }

/* Sonuç */
.result-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  margin-bottom: 16px;
}
.result-hero .big-score { font-size: 2.6rem; font-weight: 800; }
.result-hero .big-score.good { color: var(--green); }
.result-hero .big-score.mid { color: var(--amber); }
.result-hero .big-score.bad { color: var(--red); }
.result-hero .score-detail { color: var(--text-dim); margin-top: 6px; font-size: 0.92rem; }

.result-topics { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.topic-row {
  display: flex;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.88rem;
}
.topic-row .t-score { font-variant-numeric: tabular-nums; color: var(--text-dim); }

.result-review { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.review-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: 10px;
  padding: 13px 15px;
  font-size: 0.88rem;
  line-height: 1.55;
}
.review-item .r-q { font-weight: 600; margin-bottom: 6px; }
.review-item .r-a { color: var(--text-dim); }
.review-item .r-a b { color: var(--green); font-weight: 600; }
.review-item .r-a s { color: var(--red); }

@media (max-width: 480px) {
  .stats-summary { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat-card .value { font-size: 1.2rem; }
  .category-grid { grid-template-columns: 1fr 1fr; }
}
