:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --text: #17191c;
  --muted: #68707d;
  --line: #dfe3e8;
  --primary: #1463ff;
  --primary-dark: #0d49bf;
  --good: #0f8f4f;
  --bad: #c9362c;
  --panel: #ffffff;
}

* {
  box-sizing: border-box;
}

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

button, select {
  font: inherit;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-weight: 700;
  touch-action: manipulation;
}

button:active {
  background: var(--primary-dark);
}

button.ghost {
  background: #eef2f6;
  color: var(--text);
}

.icon-btn {
  width: 44px;
  min-height: 44px;
  background: #eef2f6;
  color: var(--text);
  font-size: 22px;
}

#app {
  max-width: 680px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
}

.page {
  display: none;
  min-height: 100vh;
  padding: 18px;
}

.page.active {
  display: block;
}

.top {
  padding: 14px 0 18px;
}

h1 {
  margin: 0 0 8px;
  font-size: 30px;
}

.top p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

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

.grid-actions button {
  min-height: 72px;
  font-size: 18px;
}

.panel {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

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

select {
  width: 100%;
  min-height: 48px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 0 12px;
  font-size: 17px;
}

.panel > button {
  width: 100%;
}

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 8px;
  margin: -18px -18px 16px;
  padding: 12px 18px;
  background: rgba(247, 248, 250, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.bar strong {
  font-size: 18px;
}

.bar span {
  color: var(--muted);
  font-size: 15px;
}

.question-box {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.jump-box {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 84px;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.jump-box label {
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
}

.jump-box input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  font: inherit;
  font-size: 17px;
}

.jump-box button {
  min-height: 44px;
  font-size: 16px;
}

.answer-mode-box {
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid #b8ccff;
  border-radius: 8px;
  background: #edf4ff;
}

.answer-mode-box label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 17px;
}

.answer-mode-box input {
  width: 22px;
  height: 22px;
  accent-color: var(--primary);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.meta-row span {
  padding: 5px 9px;
  border-radius: 999px;
  background: #eef2f6;
  color: var(--muted);
  font-size: 13px;
}

.meta-row .wrong-count-tag {
  background: #fff0ef;
  color: var(--bad);
  border: 1px solid #f2b8b4;
  font-weight: 800;
}

.question-box h2 {
  margin: 0 0 18px;
  font-size: 22px;
  line-height: 1.48;
  font-weight: 750;
}

.options {
  display: grid;
  gap: 12px;
}

.option {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: start;
  min-height: 58px;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  text-align: left;
  font-size: 19px;
  line-height: 1.38;
}

.option .key {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #eef2f6;
  font-weight: 800;
}

.option.selected {
  border-color: var(--primary);
  background: #edf4ff;
}

.option.correct {
  border-color: var(--good);
  background: #eefaf3;
}

.option.wrong {
  border-color: var(--bad);
  background: #fff0ef;
}

.result {
  margin: 0 0 16px;
  padding: 14px;
  border-radius: 8px;
  background: white;
  border: 2px solid var(--line);
  font-size: 18px;
  line-height: 1.6;
}

.result.good {
  border-color: var(--good);
  color: var(--good);
  background: #eefaf3;
}

.result.bad {
  border-color: var(--bad);
  color: var(--bad);
  background: #fff0ef;
}

.result.answer-mode-result {
  border-color: #b8ccff;
  color: var(--primary-dark);
  background: #edf4ff;
}

.result strong {
  font-size: 22px;
}


.bottom-actions {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px -18px -18px;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  background: rgba(247, 248, 250, 0.97);
  border-top: 1px solid var(--line);
}

.bottom-actions button {
  min-width: 0;
  padding: 0 10px;
  font-size: 17px;
}

.bottom-actions button:disabled {
  opacity: 0.45;
}

.hidden {
  display: none !important;
}

.stats {
  display: grid;
  gap: 12px;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.stat b {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.category-rate {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

@media (max-width: 380px) {
  .page {
    padding: 14px;
  }

  .grid-actions {
    grid-template-columns: 1fr;
  }

  .chips {
    grid-template-columns: 1fr;
  }

  .question-box h2 {
    font-size: 20px;
  }

  .option {
    font-size: 18px;
  }
}
