:root {
  --blue: #1565c0;
  --blue-bg: #e3f0ff;
  --red: #d32f2f;
  --red-bg: #fdecec;
  --text: #222;
  --muted: #666;
  --border: #dde1e6;
  --bg: #f4f6f9;
  --card: #fff;
  --accent: #2e3a59;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: var(--accent);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.logo { font-size: 1.15rem; margin: 0; cursor: pointer; }
.nav-btn {
  background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.5);
  padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: .9rem; margin-left: 6px;
}
.nav-btn:hover { background: rgba(255,255,255,.15); }

main { max-width: 820px; margin: 0 auto; padding: 20px 16px 60px; }

.hidden { display: none !important; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 18px;
}
.card h2 { margin-top: 0; font-size: 1.1rem; }
.section-title { font-size: 1.1rem; margin: 26px 0 12px; }

.app-footer { text-align: center; font-size: .78rem; color: var(--muted); padding: 20px 16px 40px; }
.source { font-size: .78rem; color: var(--muted); text-align: right; margin: 4px 0 12px; }
.q-images { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: #fff; }
.q-images img { display: block; width: 100%; height: auto; }
.choose-label { font-size: .9rem; color: var(--muted); margin: 8px 0 6px; }
.choices.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.choices.grid4 .choice { justify-content: center; font-size: 1.4rem; font-weight: bold; padding: 14px 0; }
.exam-group { font-size: .95rem; color: var(--muted); margin: 18px 0 8px; }
.tag-exp { font-size: .72rem; padding: 1px 8px; border-radius: 999px; background: #e8f5e9; color: #2e7d32; margin-left: 6px; font-weight: normal; }
.tag-noexp { font-size: .72rem; padding: 1px 8px; border-radius: 999px; background: #eee; color: #777; margin-left: 6px; font-weight: normal; }
.review-body .q-images { margin: 10px 0; }
.answer-line { margin: 8px 0; }
.answer-line .ans { color: var(--blue); font-weight: bold; }
.answer-line .mine { color: var(--red); font-weight: bold; }
.notice {
  font-size: .85rem; color: var(--muted); background: #fff8e1;
  border: 1px solid #ffe08a; border-radius: 8px; padding: 8px 12px;
}

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.form-grid label { display: flex; flex-direction: column; font-size: .85rem; color: var(--muted); gap: 4px; }
select {
  font-size: 1rem; padding: 8px; border: 1px solid var(--border); border-radius: 6px; background: #fff;
}
.count-info { font-size: .9rem; color: var(--muted); margin: 12px 0; }

.btn {
  font-size: .95rem; padding: 10px 18px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; cursor: pointer; color: var(--text);
}
.btn:hover { background: #f0f2f5; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { opacity: .9; }
.btn.primary:disabled { opacity: .4; cursor: not-allowed; }
.btn.small { padding: 5px 12px; font-size: .85rem; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: var(--red); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* 試験一覧 */
.exam-list { display: grid; gap: 12px; }
.exam-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.exam-card h3 { margin: 0 0 4px; font-size: 1rem; }
.exam-card .stat { font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
.exam-card .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: .82rem; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border);
  background: #f7f8fa; cursor: pointer;
}
.chip:hover { background: #e9edf3; }
.chip.all { background: var(--accent); color: #fff; border-color: var(--accent); }

/* 問題 */
.quiz-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.progress-bar { height: 6px; background: #dfe3ea; border-radius: 3px; margin-bottom: 14px; overflow: hidden; }
#progress-fill { height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.q-meta { font-size: .82rem; color: var(--muted); margin-bottom: 8px; }
.q-text { font-size: 1.05rem; font-weight: bold; margin: 0 0 16px; }
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  text-align: left; font-size: 1rem; padding: 12px 14px; border: 2px solid var(--border);
  border-radius: 8px; background: #fff; cursor: pointer; display: flex; gap: 10px; line-height: 1.5;
}
.choice:hover:not(:disabled) { border-color: var(--accent); background: #f6f8fc; }
.choice:disabled { cursor: default; color: var(--text); }
.choice .label { font-weight: bold; min-width: 1.4em; }
.choice.correct { border-color: var(--blue); background: var(--blue-bg); }
.choice.wrong { border-color: var(--red); background: var(--red-bg); }

.judge {
  margin-top: 18px; padding: 14px; border-radius: 8px; text-align: center;
  font-size: 1.6rem; font-weight: bold;
}
.judge small { display: block; font-size: .95rem; font-weight: normal; color: var(--text); margin-top: 2px; }
.judge.ok { color: var(--blue); background: var(--blue-bg); border: 2px solid var(--blue); }
.judge.ng { color: var(--red); background: var(--red-bg); border: 2px solid var(--red); }

#after-answer { margin-top: 16px; }
.explanation {
  margin-top: 12px; padding: 14px; background: #f7f8fa; border-left: 4px solid var(--accent);
  border-radius: 4px; white-space: pre-wrap;
}
.explanation h4 { margin: 0 0 6px; }
.next-row { margin-top: 16px; text-align: right; }

/* 結果 */
.result-card { text-align: center; }
.score { font-size: 2.2rem; font-weight: bold; margin: 0; }
.muted { color: var(--muted); }

.review-list { display: flex; flex-direction: column; gap: 10px; }
.review-item { background: #fff; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.review-item summary {
  list-style: none; cursor: pointer; padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start;
}
.review-item summary::-webkit-details-marker { display: none; }
.review-item .mark { font-weight: bold; min-width: 4.5em; }
.review-item .mark.ok { color: var(--blue); }
.review-item .mark.ng { color: var(--red); }
.review-item .sum-text { flex: 1; }
.review-item .sum-meta { font-size: .8rem; color: var(--muted); }
.review-body { padding: 0 14px 14px; border-top: 1px dashed var(--border); }
.review-body ol { padding-left: 0; list-style: none; }
.review-body li { padding: 2px 0; }
.review-body li.ans { color: var(--blue); font-weight: bold; }
.review-body li.mine { color: var(--red); }
.badge { font-size: .75rem; padding: 1px 8px; border-radius: 999px; background: var(--red-bg); color: var(--red); margin-left: 6px; }

/* 履歴 */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab {
  flex: 1; padding: 10px; border: 1px solid var(--border); background: #fff; border-radius: 8px;
  cursor: pointer; font-size: .95rem;
}
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.session-item { padding: 12px 14px; }
.wrong-nos { font-size: .85rem; color: var(--red); }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }
.danger-zone { margin-top: 30px; text-align: right; }

@media (max-width: 520px) {
  .logo { font-size: 1rem; }
  .nav-btn { padding: 5px 10px; }
}

/* このサイトについて */
a.nav-btn { display: inline-block; text-decoration: none; }
a.btn { display: inline-block; text-decoration: none; }
.logo-link { color: inherit; text-decoration: none; }
.page-title { font-size: 1.3rem; margin: 8px 0 16px; }
.about p { margin: 0 0 10px; }
.about ul { margin: 0; padding-left: 1.3em; }
.about li { margin-bottom: 6px; }
.about a:not(.btn) { color: var(--blue); }
.about .example {
  font-size: .9rem; background: #f7f8fa; border-left: 4px solid var(--accent);
  padding: 6px 12px; border-radius: 4px;
}
.small { font-size: .85rem; }
.app-footer a { color: var(--muted); }

/* ヘッダーのボタンが多いので、狭い画面では2段に折り返す */
@media (max-width: 640px) {
  .app-header { flex-wrap: wrap; row-gap: 8px; }
  .app-header nav { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
  .app-header .nav-btn { margin-left: 0; font-size: .82rem; padding: 5px 10px; }
}
