/* === Variables === */
:root {
  --primary: #1565C0;
  --accent: #0288D1;
  --bg: #F5F7FA;
  --surface: #fff;
  --text: #212121;
  --text-secondary: #616161;
  --border: #E0E0E0;
  --correct: #2E7D32;
  --correct-bg: #E8F5E9;
  --wrong: #C62828;
  --wrong-bg: #FFEBEE;
  --unverified: #00838F;
  --unverified-bg: #E0F2F1;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 12px;
}

.dark {
  --primary: #42A5F5;
  --accent: #4FC3F7;
  --bg: #121212;
  --surface: #1E1E1E;
  --text: #E0E0E0;
  --text-secondary: #9E9E9E;
  --border: #333;
  --correct-bg: #1B3B1F;
  --wrong-bg: #3B1B1B;
  --unverified-bg: #1A3B3B;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

/* === Header === */
header {
  background: var(--primary);
  color: #fff;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

header h1 { font-size: 1.3rem; font-weight: 700; }
.subtitle { font-size: 0.85rem; opacity: 0.85; }

.icon-btn {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.2s;
}
.icon-btn:hover { background: rgba(255,255,255,0.15); }

/* === Main === */
main { max-width: 720px; margin: 0 auto; padding: 16px; }
.screen { display: block; }
.hidden { display: none !important; }

/* === Cards === */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

/* === FB Select (top tabs) === */
.fb-select {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.fb-btn {
  flex: 1;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.fb-btn.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.fb-btn:hover:not(.selected) { border-color: var(--accent); }

/* === Start Cards === */
.start-card h3 {
  font-size: 1.1rem;
  margin-bottom: 12px;
}

/* Split layout (Theorie üben) */
.split-row {
  display: flex;
  gap: 0;
}

.split-col {
  flex: 1;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
}

.split-col:first-child { padding-left: 0; }
.split-col:last-child { padding-right: 0; }

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

.split-label {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.split-info {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  flex: 1;
}

.split-col .count-row { margin-bottom: 12px; flex: 1; }

@media (max-width: 480px) {
  .split-row { flex-direction: column; gap: 16px; }
  .split-divider { width: 100%; height: 1px; }
  .split-col { padding: 0 !important; }
}

.card-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.card-info {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.card-hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 12px;
}

.count-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.count-row label {
  font-size: 0.9rem;
  font-weight: 500;
}

.count-row input[type="number"] {
  width: 70px;
  padding: 6px 10px;
  border: 2px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
}

.count-row input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
}

#practice-max {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.scenario-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.scenario-row label {
  font-size: 0.9rem;
  font-weight: 500;
}

.scenario-row select {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  background: var(--surface);
  color: var(--text);
}

.scenario-row select:focus {
  outline: none;
  border-color: var(--primary);
}

.start-card .primary-btn {
  margin-top: 4px;
}

/* === Primary Button === */
.primary-btn {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.primary-btn:hover { opacity: 0.9; }
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* === Section Badge Colors === */
.badge-A, .badge-F { background: #1565C0; }
.badge-B, .badge-M { background: #546E7A; }
.badge-C, .badge-K { background: #2E7D32; }
.badge-D { background: #C62828; }
.badge-E { background: #E65100; }
.badge-S { background: #00838F; }
.badge-G { background: #00695C; }
.badge-P { background: #D84315; }

/* === Progress Bar === */
.progress-bar-wrap {
  background: var(--border);
  border-radius: 6px;
  height: 8px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 6px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-text {
  position: absolute;
  right: 0;
  top: 12px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* === Question === */
.question-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.section-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 4px;
  color: #fff;
}

.fb-tag {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.fb-tag.fb-both { background: #E8F5E9; color: #2E7D32; }
.fb-tag.fb-only2 { background: #E3F2FD; color: #1565C0; }
.dark .fb-tag.fb-both { background: #1B3B1F; }
.dark .fb-tag.fb-only2 { background: #1A2B3D; }

.unverified-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--unverified-bg);
  color: var(--unverified);
  font-weight: 600;
}

.answer-hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 4px;
}

.question-text {
  font-size: 1.1rem;
  margin-bottom: 16px;
  line-height: 1.5;
}

/* === Answers === */
.answers-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.answer-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
}

.answer-btn:hover:not(.locked) { border-color: var(--accent); }

.answer-btn.selected {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
}

.answer-btn .indicator {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  transition: all 0.2s;
  font-size: 0.75rem;
}

.answer-btn.selected .indicator {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

/* Answer results */
.answer-btn.correct-answer { border-color: var(--correct); background: var(--correct-bg); }
.answer-btn.correct-answer .indicator { border-color: var(--correct); background: var(--correct); color: #fff; }

.answer-btn.unverified-correct { border-color: var(--unverified); background: var(--unverified-bg); }
.answer-btn.unverified-correct .indicator { border-color: var(--unverified); background: var(--unverified); color: #fff; }

.answer-btn.wrong-answer { border-color: var(--wrong); background: var(--wrong-bg); }
.answer-btn.wrong-answer .indicator { border-color: var(--wrong); background: var(--wrong); color: #fff; }

.answer-btn.missed { border-color: var(--correct); border-style: dashed; background: rgba(46,125,50,0.04); }
.answer-btn.missed .indicator { border-color: var(--correct); border-style: dashed; }

.answer-btn.unverified-missed { border-color: var(--unverified); border-style: dashed; background: var(--unverified-bg); }
.answer-btn.unverified-missed .indicator { border-color: var(--unverified); border-style: dashed; }

.answer-btn.locked { cursor: default; pointer-events: none; }

/* === Feedback Banner === */
.feedback-banner {
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 12px;
}
.feedback-correct { background: var(--correct-bg); color: var(--correct); }
.feedback-incorrect { background: var(--wrong-bg); color: var(--wrong); }
.feedback-placeholder { visibility: hidden; }

/* === Question Actions === */
.question-actions { display: flex; gap: 8px; }
.question-actions .primary-btn { flex: 1; }

/* === Scenario Panel === */
.scenario-panel {
  border-left: 4px solid var(--accent);
  position: sticky;
  top: 60px;
  z-index: 50;
}

.scenario-header h3 { font-size: 1rem; color: var(--primary); margin-bottom: 4px; }
.scenario-hint { font-size: 0.8rem; color: var(--text-secondary); font-style: italic; margin-bottom: 8px; }

#scenario-text { font-size: 0.9rem; line-height: 1.6; }
#scenario-text .scenario-section { margin-bottom: 8px; padding: 8px 0; white-space: pre-line; }
#scenario-text .scenario-section:not(:last-child) { border-bottom: 1px dashed var(--border); }
#scenario-text .scenario-new {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  padding: 8px;
  border-radius: 6px;
}

/* === Result Screen === */
.result-score { font-size: 2.5rem; font-weight: 700; text-align: center; margin: 16px 0; }

.result-pass {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 600;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 8px;
}
.result-pass.passed { background: var(--correct-bg); color: var(--correct); }
.result-pass.failed { background: var(--wrong-bg); color: var(--wrong); }

.section-result-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.section-result-row:last-child { border-bottom: none; }
.section-result-row .badge { font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 4px; color: #fff; }
.section-result-row .name { flex: 1; }
.section-result-row .score { font-weight: 600; min-width: 60px; text-align: right; }
.section-result-row .bar-bg { width: 80px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.section-result-row .bar-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }

/* === Review List === */
.review-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.review-item:last-child { border-bottom: none; }
.review-item-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; cursor: pointer; list-style: none; }
.review-item-header::-webkit-details-marker { display: none; }
.review-item .result-icon { font-size: 1.1rem; }
.review-item .question { font-weight: 500; flex: 1; }

.review-answers-list { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }

.review-answer {
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.review-answer.review-correct { border-color: var(--correct); background: var(--correct-bg); }
.review-answer.review-unverified-correct { border-color: var(--unverified); background: var(--unverified-bg); }
.review-answer.review-missed { border-color: var(--correct); border-style: dashed; background: rgba(46,125,50,0.04); }
.review-answer.review-unverified-missed { border-color: var(--unverified); border-style: dashed; background: var(--unverified-bg); }
.review-answer.review-wrong-answer { border-color: var(--wrong); background: var(--wrong-bg); }

.review-marker {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* === Mobile === */
@media (max-width: 480px) {
  header h1 { font-size: 1.1rem; }
  .subtitle { font-size: 0.75rem; }
  main { padding: 12px; }
  .card { padding: 16px; }
  .question-text { font-size: 1rem; }
  .answer-btn { padding: 10px 12px; font-size: 0.9rem; }
  .scenario-panel { position: relative; top: 0; }
  .fb-btn { padding: 10px 6px; font-size: 0.9rem; }
}
