:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e2e6ef;
  --text: #1c2333;
  --muted: #6b7385;
  --accent: #3d5afe;
  --accent-soft: #e8ebff;
  --correct: #1b8a4c;
  --correct-bg: #e5f7ec;
  --wrong: #d5372f;
  --wrong-bg: #fdeceb;
  --shadow: 0 8px 24px rgba(30, 40, 70, 0.08);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161f;
    --surface: #1c1f2b;
    --border: #2c3040;
    --text: #eef0f6;
    --muted: #9aa1b4;
    --accent: #7c8dff;
    --accent-soft: #2a2f56;
    --correct: #55d98d;
    --correct-bg: #163326;
    --wrong: #ff6b62;
    --wrong-bg: #3a1e1e;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #14161f;
  --surface: #1c1f2b;
  --border: #2c3040;
  --text: #eef0f6;
  --muted: #9aa1b4;
  --accent: #7c8dff;
  --accent-soft: #2a2f56;
  --correct: #55d98d;
  --correct-bg: #163326;
  --wrong: #ff6b62;
  --wrong-bg: #3a1e1e;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}

.title { font-size: 1.15rem; font-weight: 700; }

.stats { font-size: 0.9rem; color: var(--muted); }
.stats .sep { margin: 0 8px; opacity: 0.5; }
#statDone { color: var(--correct); font-weight: 600; }
#statWrong { color: var(--wrong); font-weight: 600; }

.themeBtn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  flex-shrink: 0;
}
.themeBtn:hover { border-color: var(--accent); }

.pagetabs {
  display: flex;
  gap: 4px;
  padding: 8px 24px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.pageTabBtn {
  display: inline-block;
  border: none;
  background: none;
  color: var(--muted);
  text-decoration: none;
  padding: 10px 16px;
  font-size: 0.92rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.pageTabBtn:hover { color: var(--accent); }
.pageTabBtn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.progressbar {
  height: 4px;
  background: var(--border);
}
.progressfill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.25s ease;
}

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

.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

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

.modeBtn, .jump button, .navrow button, #resetBtn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.modeBtn:hover, .jump button:hover, .navrow button:hover, #resetBtn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.modeBtn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.jump { display: flex; gap: 8px; }
.jump input {
  width: 90px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow);
  min-height: 260px;
}

.cardHead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.cardIndex {
  font-weight: 700;
  color: var(--accent);
  font-size: 0.95rem;
}

.starBtn {
  border: none;
  background: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  padding: 2px 6px;
}
.starBtn.on { color: #f5a623; }

.question {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 16px;
  white-space: pre-wrap;
}

.images {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.images img {
  max-width: 100%;
  max-height: 260px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option {
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1.45;
  transition: all 0.15s ease;
  display: flex;
  gap: 10px;
}
.option:hover { border-color: var(--accent); }
.option .idx {
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
}

.option.selected { border-color: var(--accent); background: var(--accent-soft); }
.option.correct { border-color: var(--correct); background: var(--correct-bg); color: var(--correct); }
.option.wrong { border-color: var(--wrong); background: var(--wrong-bg); color: var(--wrong); }
.option.disabled { cursor: default; }

.explanation {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.5;
}
.explanation.hidden { display: none; }

.navrow {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
}
.navrow button { flex: 1; }

.hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 14px;
}

@media (max-width: 480px) {
  .navrow { flex-wrap: wrap; }
  .navrow button { flex: 1 1 45%; }
}

.listSearch {
  flex: 1 1 240px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
}

#listContainer {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.listItem { scroll-margin-top: 90px; }
.listItem.filteredOut { display: none; }

.listItem .options { gap: 8px; }
.listItem .option { padding: 10px 12px; font-size: 0.95rem; }
.listItem .question { font-size: 1.05rem; }

.listEmpty {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}
