:root {
  --bg: #f4f5f2;
  --paper: #ffffff;
  --ink: #202522;
  --muted: #68706b;
  --line: #dfe3df;
  --accent: #245b78;
  --accent-soft: #edf5f8;
  --green: #2d6a4f;
  --green-soft: #f0f7f3;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "BIZ UDPGothic", "Hiragino Sans", "Yu Gothic", sans-serif;
  line-height: 1.7;
}
header {
  width: min(100% - 32px, 920px);
  margin: 0 auto;
  padding: 52px 0 28px;
  display: flex;
  justify-content: space-between;
  gap: 32px;
  align-items: flex-end;
  border-bottom: 1px solid var(--line);
}
h1 {
  margin: 0;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.2;
  letter-spacing: -.04em;
}
.lead { margin: 10px 0 0; color: var(--muted); max-width: 40rem; font-size: .93rem; }
.stats { display: flex; gap: 22px; flex: 0 0 auto; }
.stat { min-width: 64px; color: var(--muted); font-size: .78rem; text-align: right; }
.stat b { display: block; color: var(--ink); font-size: 1.5rem; line-height: 1.2; font-weight: 600; }
.toolbar {
  width: min(100% - 32px, 920px);
  margin: 22px auto 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  display: grid;
  grid-template-columns: minmax(200px, 1fr) auto auto;
  gap: 10px;
}
input, select, button { font: inherit; }
.search, select, .toggle-all {
  min-height: 42px;
  border: 1px solid #cfd5d1;
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
}
.search { width: 100%; padding: 9px 12px; outline: none; }
.search:focus, select:focus, button:focus-visible { outline: 2px solid #8ab4c7; outline-offset: 2px; }
select, .toggle-all { padding: 8px 12px; cursor: pointer; }
.toggle-all { color: var(--accent); }
.chips { grid-column: 1 / -1; display: flex; gap: 6px; overflow-x: auto; padding-top: 4px; }
.chip {
  white-space: nowrap;
  border: 0;
  border-radius: 999px;
  background: #eef0ed;
  color: #59615c;
  padding: 6px 11px;
  font-size: .8rem;
  cursor: pointer;
}
.chip:hover { background: #e3e7e3; }
.chip.active { background: var(--accent); color: #fff; }
main { width: min(100% - 32px, 920px); margin: 0 auto; padding: 22px 0 64px; }
.grid { display: grid; gap: 12px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.card-head { padding: 18px 20px 5px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.badge { font-size: .75rem; color: var(--muted); }
.badge + .badge::before { content: "·"; margin-right: 8px; color: #adb3af; }
.badge.cat { color: var(--accent); }
.qtext { padding: 8px 20px 14px; font-size: 1rem; line-height: 1.8; font-weight: 600; white-space: pre-wrap; }
.qimage { margin: 16px 0 4px; padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: #fafbf9; text-align: center; white-space: normal; }
.qimage img { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.qimage figcaption { color: var(--muted); font-size: .86rem; font-weight: 400; }
.qimage code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; }
.qimage a { color: var(--accent); }
.choices { margin: 0; padding: 0 20px 8px; list-style: none; display: grid; gap: 6px; }
.choice { border-radius: 4px; background: #f6f7f5; line-height: 1.6; overflow: hidden; }
.choice.correct { padding: 8px 11px; color: var(--green); background: var(--green-soft); }
.choice-note summary { padding: 8px 11px; display: flex; gap: 10px; justify-content: space-between; align-items: flex-start; cursor: pointer; list-style: none; }
.choice-note summary::-webkit-details-marker { display: none; }
.choice-note summary::after { content: "+"; flex: 0 0 auto; color: var(--muted); font-size: 1.1rem; line-height: 1.4; }
.choice-note[open] summary::after { content: "−"; }
.choice-note summary:hover { background: #eef1ee; }
.choice-note summary:focus-visible { outline: 2px solid #8ab4c7; outline-offset: -2px; }
.choice-explanation { padding: 10px 12px 12px; border-top: 1px solid var(--line); color: var(--muted); background: #fff; font-size: .88rem; }
.answer { margin: 10px 20px 20px; border-top: 1px solid var(--line); }
.answer summary { cursor: pointer; padding: 12px 0 4px; font-weight: 600; color: var(--accent); }
.answer-body { padding-top: 10px; line-height: 1.75; white-space: pre-wrap; }
.explain { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: .92rem; }
.ai-explain { margin-top: 16px; padding: 14px 16px; border-left: 3px solid var(--accent); border-radius: 0 5px 5px 0; background: var(--accent-soft); white-space: normal; }
.ai-explain h3 { margin: 0 0 6px; color: var(--accent); font-size: .88rem; letter-spacing: .04em; }
.ai-explain p { margin: 0; color: #334851; font-size: .92rem; white-space: pre-line; }
.empty { padding: 40px; text-align: center; color: var(--muted); border: 1px dashed #c8ceca; border-radius: 8px; background: var(--paper); }
mark { background: #fff0a8; color: inherit; padding: 0 .1em; }
@media (max-width: 680px) {
  header { padding-top: 32px; display: block; }
  .stats { margin-top: 20px; justify-content: flex-start; }
  .stat { text-align: left; }
  .toolbar { grid-template-columns: 1fr; }
  .chips { grid-column: 1; }
  .card-head, .qtext { padding-left: 16px; padding-right: 16px; }
  .choices { padding-left: 16px; padding-right: 16px; }
  .answer { margin-left: 16px; margin-right: 16px; }
}
