:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #5c5c5c;
  --accent: #7a1f2b;
  --accent-contrast: #ffffff;
  --border: #e5e5e5;
  --correct: #2d7a3e;
  --correct-bg: #eaf4ec;
  --wrong: #b3261e;
  --wrong-bg: #fbeae9;
  --focus: #7a1f2b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] {
  --bg: #121212;
  --surface: #1c1c1e;
  --text: #ededed;
  --text-muted: #a0a0a0;
  --accent: #d98592;
  --accent-contrast: #1a1a1a;
  --border: #34343a;
  --correct: #6cc187;
  --correct-bg: #15301d;
  --wrong: #f08a83;
  --wrong-bg: #3a1715;
  --focus: #d98592;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 10px 16px;
  z-index: 100;
}
.skip-link:focus { left: 8px; top: 8px; }

/* Top bar */
.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topbar-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--accent);
}
.theme-toggle {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.theme-toggle::before {
  content: "\263E"; /* moon */
  font-size: 15px;
  line-height: 1;
}
[data-theme="dark"] .theme-toggle::before {
  content: "\2600"; /* sun */
}
[data-theme="dark"] .theme-toggle .theme-toggle-label::after {
  content: " (ενεργή)";
}
.theme-toggle:hover { border-color: var(--accent); }

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

.screen { animation: fade 0.18s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.title {
  font-size: 28px;
  margin: 8px 0 4px;
  color: var(--text);
}
.subtitle {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 16px;
}

.card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 12px;
  font-weight: 600;
}

/* Mode buttons */
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.mode-btn {
  text-align: left;
  border: 1.5px solid var(--border);
  background: var(--bg);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text);
}
.mode-btn-title { font-weight: 600; font-size: 16px; }
.mode-btn-desc { font-size: 13px; color: var(--text-muted); }
.mode-btn[aria-checked="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
}
.mode-btn[aria-checked="true"] .mode-btn-desc { color: var(--accent-contrast); opacity: 0.85; }

/* Chapter list */
.chapter-actions { display: flex; gap: 16px; margin-bottom: 10px; }
.chapter-list { display: flex; flex-direction: column; gap: 2px; }
.chapter-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 4px;
  cursor: pointer;
  font-size: 15px;
}
.chapter-item input { width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; }
.chapter-count { color: var(--text-muted); font-size: 13px; margin-left: auto; }

/* Count buttons */
.count-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.count-btn {
  border: 1.5px solid var(--border);
  background: var(--bg);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.count-btn[aria-checked="true"] { border-color: var(--accent); background: var(--accent); color: var(--accent-contrast); }

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  cursor: pointer;
}
.switch-row input { width: 18px; height: 18px; accent-color: var(--accent); }

.pool-info { color: var(--text-muted); font-size: 14px; margin: 4px 0 14px; min-height: 1.2em; }

/* Buttons */
.primary-btn {
  width: 100%;
  border: none;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 17px;
  font-weight: 600;
  padding: 15px;
  border-radius: 10px;
  cursor: pointer;
}
.primary-btn:hover { filter: brightness(1.06); }
.secondary-btn {
  width: 100%;
  border: 1.5px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 16px;
  font-weight: 600;
  padding: 13px;
  border-radius: 10px;
  cursor: pointer;
}
.secondary-btn:hover { background: var(--accent); color: var(--accent-contrast); }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
}
.link-btn.danger { color: var(--wrong); }

.overall-stats { color: var(--text-muted); font-size: 14px; margin: 20px 0 6px; text-align: center; }

/* Progress */
.progress-wrap { margin-bottom: 18px; }
.progress-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.progress-text { font-size: 14px; color: var(--text-muted); font-weight: 600; }
.progress-bar { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.25s ease; }

.chapter-tag {
  display: inline-block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 4px 10px;
  margin-bottom: 14px;
  font-weight: 600;
}

.question { font-size: 22px; line-height: 1.4; margin: 0 0 22px; }
.question:focus { outline: none; }

/* Choices */
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  font-size: 16px;
  color: var(--text);
  width: 100%;
}
.choice:hover:not(:disabled) { border-color: var(--accent); }
.choice:disabled { cursor: default; }
.choice-letter {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}
.choice.correct { border-color: var(--correct); background: var(--correct-bg); }
.choice.correct .choice-letter { border-color: var(--correct); background: var(--correct); color: #fff; }
.choice.wrong { border-color: var(--wrong); background: var(--wrong-bg); }
.choice.wrong .choice-letter { border-color: var(--wrong); background: var(--wrong); color: #fff; }

.explanation {
  margin-top: 16px;
  padding: 14px 16px;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 6px;
  font-size: 15px;
  color: var(--text);
}
.explanation strong { color: var(--accent); }

/* Q&A */
.qa-answer {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 17px;
  background: var(--surface);
}
.qa-answer .qa-extra {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-muted);
}
.qa-rate { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.rate-btn {
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
}
.rate-btn.knew { border-color: var(--correct); color: var(--correct); }
.rate-btn.knew:hover { background: var(--correct); color: #fff; }
.rate-btn.didnt { border-color: var(--wrong); color: var(--wrong); }
.rate-btn.didnt:hover { background: var(--wrong); color: #fff; }

#next-btn { margin-top: 18px; }
.hint { text-align: center; color: var(--text-muted); font-size: 13px; margin-top: 14px; }

/* Summary */
.score-card { text-align: center; }
.score-big { font-size: 40px; font-weight: 700; color: var(--accent); margin: 4px 0; }
.score-sub { color: var(--text-muted); font-size: 15px; }

.review-heading { font-size: 15px; font-weight: 600; margin: 24px 0 12px; }
.review-item {
  border: 1px solid var(--border);
  border-left: 3px solid var(--wrong);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 10px;
  background: var(--surface);
}
.review-q { font-weight: 600; margin-bottom: 8px; }
.review-a { font-size: 15px; }
.review-a .label { color: var(--correct); font-weight: 600; }

.summary-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; }

/* Focus visibility */
button:focus-visible,
input:focus-visible,
a:focus-visible,
.choice:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  body { font-size: 16px; }
  .mode-grid { grid-template-columns: 1fr; }
  .summary-actions { grid-template-columns: 1fr; }
  .title { font-size: 24px; }
  .question { font-size: 20px; }
  .theme-toggle-label { display: none; }
  .theme-toggle { padding: 8px 10px; }
}
