:root {
  color-scheme: light;
  --bg: oklch(97% 0.018 92);
  --surface: oklch(99% 0.012 92);
  --surface-2: oklch(94.5% 0.018 92);
  --ink: oklch(24% 0.025 78);
  --muted: oklch(48% 0.025 78);
  --line: oklch(84% 0.025 82);
  --accent: oklch(58% 0.15 38);
  --accent-2: oklch(62% 0.13 178);
  --success: oklch(57% 0.13 142);
  --danger: oklch(58% 0.17 25);
  --focus: oklch(70% 0.16 80);
  --shadow: 0 18px 50px color-mix(in oklch, var(--ink), transparent 88%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 14% 12%, oklch(95% 0.06 85), transparent 28%),
    linear-gradient(145deg, var(--bg), oklch(95% 0.025 170));
  color: var(--ink);
}

button, select, input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 74px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: var(--ink);
  color: oklch(96% 0.015 92);
  font-weight: 850;
  letter-spacing: 0;
}

.brand h1, .brand p, .topbar h2, .topbar p, .panel h2 {
  margin: 0;
}

.brand h1 {
  font-size: 1.28rem;
}

.brand p, .eyebrow {
  color: var(--muted);
  font-size: .9rem;
}

.panel, .practice-board, .review-panel {
  background: color-mix(in oklch, var(--surface), transparent 4%);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.panel h2, .review-header h2 {
  font-size: 1rem;
  margin-bottom: 12px;
}

.settings-panel {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: .9rem;
}

select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--ink);
}

.book-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.book-choice {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: .9rem;
  font-weight: 650;
}

.book-choice:first-child {
  grid-column: 1 / -1;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.seg-btn {
  min-height: 34px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
}

.seg-btn.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 8px color-mix(in oklch, var(--ink), transparent 90%);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.hint-meter {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 8px;
  background: color-mix(in oklch, var(--accent-2), var(--surface) 84%);
  color: var(--ink);
}

.hint-meter span {
  color: var(--muted);
  font-size: .9rem;
}

.primary-btn, .ghost-btn, .option-btn, .sound-btn, .save-btn {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 750;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.primary-btn {
  width: 100%;
  background: var(--accent);
  color: oklch(98% 0.008 80);
}

.primary-btn:hover, .option-btn:hover, .ghost-btn:hover, .sound-btn:hover, .save-btn:hover {
  transform: translateY(-1px);
}

.ghost-btn {
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.training-area {
  display: grid;
  grid-template-rows: auto minmax(430px, 1fr) auto;
  gap: 14px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  min-height: 74px;
}

.topbar h2 {
  font-size: 1.55rem;
  line-height: 1.2;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(74px, 1fr));
  gap: 8px;
}

.stats-strip div {
  min-width: 78px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
}

.stats-strip strong {
  display: block;
  font-size: 1.35rem;
}

.stats-strip span {
  color: var(--muted);
  font-size: .78rem;
}

.practice-board {
  display: grid;
  align-items: center;
  padding: 24px;
  min-height: 430px;
}

.empty-state {
  max-width: 620px;
}

.empty-state h2 {
  margin: 0 0 10px;
  font-size: 2rem;
  line-height: 1.15;
}

.empty-state p {
  max-width: 60ch;
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.7;
}

.question-card {
  display: grid;
  gap: 18px;
  max-width: 850px;
  width: 100%;
  margin: 0 auto;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
}

.prompt {
  display: grid;
  gap: 10px;
}

.prompt-label {
  color: var(--muted);
  font-size: .95rem;
}

.prompt-main {
  font-size: 2.1rem;
  line-height: 1.18;
  font-weight: 840;
  overflow-wrap: anywhere;
}

.prompt-sub {
  color: var(--muted);
  font-size: 1.05rem;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.option-btn {
  min-height: 64px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  line-height: 1.35;
}

.option-btn.correct {
  border-color: color-mix(in oklch, var(--success), var(--line) 30%);
  background: color-mix(in oklch, var(--success), var(--surface) 82%);
}

.option-btn.wrong {
  border-color: color-mix(in oklch, var(--danger), var(--line) 20%);
  background: color-mix(in oklch, var(--danger), var(--surface) 88%);
}

.answer-input {
  width: 100%;
  min-height: 54px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 1.2rem;
}

.question-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.small-note {
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.55;
}

.sound-btn, .save-btn {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.feedback {
  min-height: 28px;
  font-weight: 700;
}

.feedback.good { color: var(--success); }
.feedback.bad { color: var(--danger); }

.finish-card {
  display: grid;
  gap: 16px;
  max-width: 620px;
  margin: 0 auto;
}

.finish-card h2 {
  margin: 0;
  font-size: 2rem;
}

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

.finish-grid div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.finish-grid strong {
  display: block;
  font-size: 1.45rem;
}

.review-panel {
  padding: 14px 16px;
}

.review-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mistake-list, .score-list {
  display: grid;
  gap: 8px;
}

.mistake-item, .score-item {
  display: grid;
  gap: 2px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
}

.mistake-item strong, .score-item strong {
  overflow-wrap: anywhere;
}

.mistake-item span, .score-item span {
  color: var(--muted);
  font-size: .85rem;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .options-grid, .finish-grid {
    grid-template-columns: 1fr;
  }

  .prompt-main {
    font-size: 1.65rem;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 10px;
    gap: 12px;
  }

  .brand {
    min-height: auto;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 10px;
  }

  .book-picker,
  .stats-strip {
    grid-template-columns: 1fr;
  }

  .book-choice:first-child {
    grid-column: auto;
  }

  .topbar h2 {
    font-size: 1.25rem;
  }

  .practice-board {
    min-height: 380px;
    padding: 16px;
  }

  .empty-state h2,
  .finish-card h2 {
    font-size: 1.45rem;
  }

  .prompt-main {
    font-size: 1.38rem;
  }

  .option-btn {
    min-height: 58px;
  }

  .question-actions {
    align-items: stretch;
  }

  .question-actions > button {
    flex: 1 1 140px;
  }
}
