/* 問題集 共通スタイル — 論点まとめのデザイン言語に合わせた素のHTML/JS版 */

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Hiragino Sans', 'Meiryo', sans-serif;
  background: #f8fafc;
  color: #1e293b;
  line-height: 1.65;
  font-size: 14px;
  padding-bottom: 40px;
}
button { cursor: pointer; font-family: inherit; font-size: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
p { margin: 0; }
ul, ol { padding-left: 0; list-style: none; }

/* ========== レイアウト ========== */
.app {
  max-width: 980px; margin: 0 auto;
  padding: 0 calc(16px + env(safe-area-inset-right)) 0 calc(16px + env(safe-area-inset-left));
}

/* ========== 戻るリンク（共通：左上固定） ========== */
.app-home {
  position: fixed; top: 14px; left: 14px;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 7px 12px; font-size: 12px; color: #475569;
  text-decoration: none; box-shadow: 0 2px 6px rgba(0,0,0,.06);
  z-index: 9999; transition: all .12s;
}
.app-home:hover {
  background: #f8fafc; border-color: #94a3b8; color: #0f172a;
  transform: translateY(-1px); box-shadow: 0 3px 8px rgba(0,0,0,.08);
}

/* ========== ヘッダー ========== */
.app-header {
  padding: 28px 0 18px;
  text-align: center;
}
.app-header-top { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 4px; }
.app-header h1 {
  font-size: 22px; font-weight: 700; color: var(--accent, #1e40af);
}
.btn-settings {
  background: none; border: 1px solid #cbd5e1; color: #475569;
  width: 32px; height: 32px; border-radius: 6px; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .12s;
}
.btn-settings:hover { background: var(--accent-soft, #eff6ff); border-color: var(--accent, #1e40af); color: var(--accent, #1e40af); }

.subject-meta {
  font-size: 12px; color: #64748b; margin-bottom: 14px;
}

.overall-stats {
  display: flex; gap: 16px; justify-content: center; align-items: center;
  font-size: 12px; color: #64748b; flex-wrap: wrap;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 10px 16px; margin: 0 auto; max-width: 720px;
}
.overall-stats .stat-strong { color: var(--accent, #1e40af); font-weight: 700; }
.overall-stats .stat-skipped { color: #047857; }
.btn-text-small {
  background: none; border: none; color: #b91c1c;
  font-size: 12px; padding: 2px 6px; text-decoration: underline;
  margin-left: auto;
}

/* ========== セクションカード ========== */
.section-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  padding: 18px 20px; margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.section-card h2 {
  font-size: 14px; font-weight: 700; color: #0f172a;
  margin-bottom: 12px; display: flex; align-items: center; gap: 8px;
}
.section-selected-count { font-size: 11px; color: var(--accent, #1e40af); font-weight: 600; }

/* ========== 章選択グリッド ========== */
.chapter-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.chapter-btn {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px 14px; background: #f8fafc; border: 1.5px solid #e2e8f0;
  border-radius: 8px; text-align: left; transition: all .12s;
  position: relative;
}
.chapter-btn:hover { background: #fff; border-color: #94a3b8; }
.chapter-btn.active {
  background: var(--accent-soft, #eff6ff);
  border-color: var(--accent, #1e40af);
}
.chapter-btn .chapter-name {
  font-size: 13px; font-weight: 600; color: #1e293b; line-height: 1.3;
}
.chapter-btn.active .chapter-name { color: var(--accent, #1e40af); }
.chapter-count-row {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 11px;
}
.chapter-count { color: #64748b; }
.chapter-rate {
  padding: 1px 6px; border-radius: 3px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.chapter-rate.rate-great { background: #d1fae5; color: #047857; }
.chapter-rate.rate-good  { background: #fef3c7; color: #92400e; }
.chapter-rate.rate-poor  { background: #fee2e2; color: #b91c1c; }
.chapter-skipped { color: #047857; font-weight: 600; }
.progress-bar {
  height: 4px; background: #e2e8f0; border-radius: 2px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--accent, #1e40af);
  transition: width .2s;
}

/* 章カードを正答率で薄く色付け（未選択時） */
.chapter-btn.rate-great:not(.active) { border-color: #a7f3d0; }
.chapter-btn.rate-good:not(.active)  { border-color: #fcd34d; }
.chapter-btn.rate-poor:not(.active)  { border-color: #fca5a5; }

/* ========== 節選択 ========== */
.section-list {
  display: flex; flex-direction: column; gap: 4px;
}
.section-btn {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 6px; text-align: left; transition: all .12s;
  font-size: 13px;
}
.section-btn:hover { background: #fff; border-color: #94a3b8; }
.section-btn.active {
  background: var(--accent-soft, #eff6ff);
  border-color: var(--accent, #1e40af);
  color: var(--accent, #1e40af); font-weight: 600;
}
.section-btn-right { display: flex; align-items: center; gap: 8px; font-size: 11px; color: #64748b; }

/* ========== フィルタ行 ========== */
.filter-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0;
}
.filter-label { font-size: 12px; color: #64748b; min-width: 60px; }
.toggle-group { display: flex; gap: 6px; }
.toggle-btn {
  padding: 6px 12px; background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 6px; font-size: 12px; color: #64748b; transition: all .12s;
}
.toggle-btn:hover { background: #fff; border-color: #94a3b8; }
.toggle-btn.importance-A.active { background: #ede9fe; border-color: #7c3aed; color: #7c3aed; font-weight: 700; }
.toggle-btn.importance-B.active { background: #dbeafe; border-color: #0369a1; color: #0369a1; font-weight: 700; }
.toggle-btn.importance-C.active { background: #f3f4f6; border-color: #6b7280; color: #4b5563; font-weight: 700; }

.checkbox-label {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 13px; color: #334155;
}
.checkbox-label input[type="checkbox"] {
  width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent, #1e40af);
}
.filter-sub { font-size: 11px; color: #64748b; }

/* ========== スタートエリア ========== */
.start-area {
  text-align: center; padding: 18px 0;
}
.target-count {
  font-size: 13px; color: #64748b; margin-bottom: 12px;
}
.target-count strong {
  font-size: 18px; color: var(--accent, #1e40af); font-weight: 700;
  margin: 0 4px;
}
.btn-primary {
  background: var(--accent, #1e40af); color: #fff; border: none;
  border-radius: 10px; padding: 14px 48px; font-size: 16px; font-weight: 700;
  transition: all .12s; min-width: 240px;
}
.btn-primary:hover { background: var(--accent-hover, #1e3a8a); transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0,0,0,.12); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-secondary {
  background: #fff; color: var(--accent, #1e40af);
  border: 1.5px solid var(--accent, #1e40af);
  border-radius: 10px; padding: 12px 36px; font-size: 14px; font-weight: 600;
  transition: all .12s;
}
.btn-secondary:hover { background: var(--accent-soft, #eff6ff); }

/* ========== 学習画面 ========== */
.study-header {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 0 10px;
}
.btn-back {
  background: none; border: 1px solid #cbd5e1; color: #475569;
  padding: 6px 12px; border-radius: 6px; font-size: 13px; transition: all .12s;
}
.btn-back:hover { background: #fff; border-color: #94a3b8; color: #0f172a; }
.study-progress-text {
  font-size: 13px; color: #64748b; font-variant-numeric: tabular-nums;
  margin-left: auto;
}
.study-progress-bar {
  height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden;
  margin-bottom: 16px;
}
.study-progress-fill {
  height: 100%; background: var(--accent, #1e40af); transition: width .2s;
}

/* 前後の問題へ移動（左端＝前へ / 右端＝次へ） */
.study-nav {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.study-nav-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; min-width: 56px;
  background: #fff; border: 1px solid #cbd5e1; border-radius: 8px;
  color: #475569; font-size: 18px; line-height: 1; font-family: inherit;
  cursor: pointer; transition: all .12s;
  -webkit-tap-highlight-color: transparent;
}
.study-nav-btn:hover:not(:disabled) {
  background: #f1f5f9; border-color: #94a3b8; color: #1e293b;
}
.study-nav-btn:disabled { opacity: .35; cursor: default; }

.question-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 11px; color: #64748b; margin-bottom: 10px;
}
.importance-badge {
  padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700;
}
.imp-A { background: #ede9fe; color: #7c3aed; }
.imp-B { background: #dbeafe; color: #0369a1; }
.imp-C { background: #f3f4f6; color: #6b7280; }
.past-exam-badge { background: #fef3c7; color: #92400e; padding: 2px 8px; border-radius: 4px; font-weight: 700; }
.skip-badge { background: #d1fae5; color: #047857; padding: 2px 8px; border-radius: 4px; font-weight: 700; }
.tag-badge { padding: 2px 8px; border-radius: 4px; font-weight: 700; font-size: 12px; }
.tag-badge.tag-unclear { background: #fee2e2; color: #b91c1c; }
.tag-badge.tag-fuzzy { background: #fef3c7; color: #b45309; }
.tag-badge.tag-understood { background: #d1fae5; color: #047857; }
.section-text { color: #64748b; }

/* 直近5回履歴ドット */
.history-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  font-size: 10px;
  margin-left: auto;
}
.history-label {
  font-size: 10px; color: #94a3b8; font-weight: 600;
  margin-right: 2px;
}
.history-dot {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.history-dot.correct { background: #10b981; }
.history-dot.incorrect { background: #ef4444; }
.history-dot.empty {
  background: transparent;
  border: 1px dashed #cbd5e1;
  width: 8px; height: 8px;
}
.wrong-item .history-dots {
  margin-left: 0;
  background: #fff;
}

.question-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  padding: 24px 28px; margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.question-text {
  font-size: 16px; line-height: 1.85; color: #1e293b;
  white-space: pre-wrap; word-wrap: break-word;
}

.reveal-area {
  text-align: center; padding: 24px 0;
}
.reveal-hint { font-size: 13px; color: #64748b; margin-bottom: 14px; }
.btn-reveal {
  background: var(--accent, #1e40af); color: #fff; border: none;
  border-radius: 10px; padding: 14px 40px; font-size: 16px; font-weight: 700;
  transition: all .12s; min-width: 240px;
}
.btn-reveal:hover { background: var(--accent-hover, #1e3a8a); transform: translateY(-1px); }
.key-hint { font-size: 11px; color: #94a3b8; margin-top: 10px; }

.answer-area { padding: 6px 0; }
.answer-badge {
  display: inline-block; font-size: 18px; font-weight: 700;
  padding: 10px 24px; border-radius: 10px; margin-bottom: 18px;
}
.answer-badge.correct { background: #d1fae5; color: #047857; border: 1.5px solid #10b981; }
.answer-badge.incorrect { background: #fee2e2; color: #b91c1c; border: 1.5px solid #ef4444; }
.answer-badge.answer-number { background: #dbeafe; color: #0369a1; border: 1.5px solid #3b82f6; }

.explanation {
  background: #f8fafc; border-left: 3px solid var(--accent, #1e40af);
  padding: 14px 18px; border-radius: 6px; margin-bottom: 22px;
}
.explanation h3 { font-size: 13px; color: var(--accent, #1e40af); margin-bottom: 6px; font-weight: 700; }
.explanation p { font-size: 14px; line-height: 1.75; color: #334155; white-space: pre-wrap; word-wrap: break-word; }

.topics-jump-area {
  text-align: right; margin: -8px 0 14px;
}
.topics-jump-link {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; text-decoration: none;
  color: var(--accent, #1e40af); padding: 6px 12px;
  border: 1px solid var(--accent, #1e40af); border-radius: 6px;
  background: #fff; transition: all .12s;
}
.topics-jump-link:hover {
  background: var(--accent-soft, #eff6ff);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,.08);
}

/* Claude Code 連携ボタン群 */
.ai-action-area {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  flex-wrap: wrap; margin: -8px 0 14px;
}
.ai-action-area .topics-jump-link {
  margin-right: 0;
}
.btn-ai-explain {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600;
  color: #fff; padding: 6px 12px;
  border: 1px solid #d97706; border-radius: 6px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  cursor: pointer; transition: all .12s;
  font-family: inherit;
}
.btn-ai-explain:hover {
  background: linear-gradient(135deg, #d97706, #b45309);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(217, 119, 6, .25);
}

/* Claude Code 連携用のトースト通知 */
.ai-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  background: rgba(15, 23, 42, 0.95);
  color: #fff;
  padding: 16px 24px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  max-width: calc(100vw - 60px);
  text-align: center;
  line-height: 1.6;
  font-family: 'Hiragino Sans', 'Meiryo', sans-serif;
}
.ai-toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.ai-toast.error {
  background: rgba(185, 28, 28, 0.95);
  border: 1px solid #f87171;
}

.self-judge {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 10px;
  padding: 16px 20px;
}
.self-judge > p {
  font-size: 13px; color: #64748b; margin-bottom: 12px; text-align: center;
}
.viewonly-hint {
  font-size: 13px; color: #b45309; font-weight: 700;
  background: #fffbeb; border: 1px dashed #fcd34d;
  border-radius: 6px; padding: 8px 12px; margin-bottom: 12px;
  text-align: center;
}
.judge-buttons {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px;
}
.btn-correct, .btn-incorrect {
  padding: 14px; border: 1.5px solid; border-radius: 8px;
  font-size: 15px; font-weight: 700; transition: all .12s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-correct { background: #d1fae5; color: #047857; border-color: #10b981; }
.btn-correct:hover { background: #a7f3d0; }
.btn-incorrect { background: #fee2e2; color: #b91c1c; border-color: #ef4444; }
.btn-incorrect:hover { background: #fecaca; }
.btn-skip.active { background: #d1fae5; color: #047857; border-color: #10b981; }
/* 3段階タグボタン */
.tag-prompt { font-size: 12px; color: #64748b; margin: 8px 0 4px; }
.tag-buttons { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.btn-tag {
  padding: 10px 6px; background: #f8fafc; border: 1.5px solid #cbd5e1;
  border-radius: 8px; font-size: 13px; font-weight: 600; color: #475569; transition: all .12s;
  display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap;
}
.btn-tag:hover { background: #fff; border-color: #94a3b8; }
.btn-tag.tag-unclear.active { background: #fee2e2; color: #b91c1c; border-color: #ef4444; }
.btn-tag.tag-fuzzy.active { background: #fef3c7; color: #b45309; border-color: #f59e0b; }
.btn-tag.tag-understood.active { background: #d1fae5; color: #047857; border-color: #10b981; }

/* キーボードのカーソル位置を明示（Enter/←→操作のため） */
.btn-tag:focus-visible,
.judge-buttons button:focus-visible {
  outline: 3px solid #2563eb; outline-offset: 2px;
}
/* ○×は理解度を選ぶまで無効 */
.judge-buttons button:disabled { opacity: .4; cursor: default; }
.judge-buttons button:disabled:hover { background: #d1fae5; }
.btn-incorrect:disabled:hover { background: #fee2e2; }
.judge-disabled-hint { color: #94a3b8 !important; }
/* 復習ゾーン（トップ） */
.review-zone { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; margin-bottom: 18px; }
.review-side { display: flex; flex-direction: column; gap: 12px; }
.review-cta.ahead { background: #f0fdf4; border-color: #22c55e; }
.review-cta.ahead:not(:disabled):hover { background: #dcfce7; }
.review-cta.ahead .review-cta-main { font-size: 14px; }
.plan-settings {
  grid-column: 1 / -1; display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  font-size: 13px; color: #475569; background: #f8fafc; border: 1px solid var(--dash-border, #e2e8f0);
  border-radius: 8px; padding: 8px 12px;
}
.plan-settings input { width: 56px; padding: 4px 6px; border: 1px solid #cbd5e1; border-radius: 6px;
  font-size: 13px; text-align: right; margin: 0 2px; }
.plan-hint { font-size: 11px; color: #94a3b8; }
.review-cta {
  text-align: left; padding: 14px 16px; border-radius: 12px; border: 1.5px solid;
  display: flex; flex-direction: column; gap: 2px; transition: all .12s; cursor: pointer;
}
.review-cta:disabled { opacity: .55; cursor: default; }
.review-cta.primary { background: #eef2ff; border-color: #6366f1; }
.review-cta.primary:not(:disabled):hover { background: #e0e7ff; }
.review-cta.mishit { background: #fff7ed; border-color: #f97316; }
.review-cta.mishit:not(:disabled):hover { background: #ffedd5; }
.review-cta-main { font-size: 16px; font-weight: 800; color: #1e293b; }
.review-cta-count { font-size: 22px; font-weight: 800; color: #4338ca; }
.review-cta.mishit .review-cta-count { color: #c2410c; }
.review-cta-sub { font-size: 11px; color: #64748b; }
.review-note {
  grid-column: 1 / -1; font-size: 12px; color: #b91c1c;
  background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px; padding: 8px 12px;
}
.toggle-btn.tag-chip.active.tag-unclear { background: #fee2e2; border-color: #ef4444; color: #b91c1c; }
.toggle-btn.tag-chip.active.tag-fuzzy { background: #fef3c7; border-color: #f59e0b; color: #b45309; }
.toggle-btn.tag-chip.active.tag-understood { background: #d1fae5; border-color: #10b981; color: #047857; }
.toggle-btn.tag-chip.active.tag-none { background: #e2e8f0; border-color: #94a3b8; color: #334155; }
.filter-tags { flex-wrap: wrap; }
.key-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.08); padding: 1px 6px; border-radius: 3px;
  font-size: 10px; font-family: monospace; min-width: 18px;
}

/* ========== 結果画面 ========== */
.result-header { padding: 28px 0 16px; text-align: center; }
.result-header h1 { font-size: 22px; color: #0f172a; }
.result-score {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 16px 0 24px;
}
.score-circle {
  width: 140px; height: 140px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 6px solid;
}
.score-circle.great { background: #ecfdf5; border-color: #10b981; }
.score-circle.good  { background: #fffbeb; border-color: #f59e0b; }
.score-circle.poor  { background: #fef2f2; border-color: #ef4444; }
.score-num { font-size: 36px; font-weight: 700; color: #0f172a; }
.score-label { font-size: 11px; color: #64748b; }
.score-detail { font-size: 14px; color: #475569; }

.result-actions {
  display: flex; gap: 10px; justify-content: center; margin-bottom: 24px; flex-wrap: wrap;
}

.wrong-list {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  padding: 18px 20px; margin-top: 16px;
}
.wrong-list h2 {
  font-size: 14px; font-weight: 700; color: #b91c1c; margin-bottom: 14px;
}
.wrong-item {
  border-left: 3px solid #ef4444; padding: 10px 14px; margin-bottom: 10px;
  background: #fef2f2; border-radius: 4px;
}
.wrong-item:last-child { margin-bottom: 0; }
.wrong-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 11px; }
.wrong-section { color: #64748b; }
.wrong-text { font-size: 13px; color: #1e293b; margin-bottom: 6px; line-height: 1.6; }
.wrong-item .answer-badge { font-size: 12px; padding: 3px 10px; margin-bottom: 6px; }
.wrong-explanation { font-size: 12px; color: #64748b; line-height: 1.6; white-space: pre-wrap; }

/* ========== モーダル ========== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 10000; padding: 20px;
}
.modal {
  background: #fff; border-radius: 12px; width: 100%; max-width: 480px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  display: flex; flex-direction: column; max-height: 90vh;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid #e2e8f0;
}
.modal-header h2 { font-size: 16px; font-weight: 700; color: #0f172a; }
.modal-close {
  background: none; border: none; font-size: 18px; color: #64748b;
  width: 28px; height: 28px; border-radius: 4px; transition: all .12s;
}
.modal-close:hover { background: #f1f5f9; color: #0f172a; }
.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 12px 20px; border-top: 1px solid #e2e8f0;
}

.keybinding-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid #f1f5f9;
}
.keybinding-row:last-child { border-bottom: none; }
.keybinding-label { flex: 1; font-size: 13px; color: #1e293b; }
.keybinding-key {
  background: #f1f5f9; padding: 4px 10px; border-radius: 4px;
  font-family: monospace; font-size: 12px; font-weight: 700; color: #1e293b;
  min-width: 60px; text-align: center;
}
.keybinding-capturing {
  color: var(--accent, #1e40af); font-size: 12px; min-width: 100px;
}
.keybinding-btn {
  background: #f8fafc; border: 1px solid #cbd5e1; color: #475569;
  padding: 5px 10px; border-radius: 4px; font-size: 11px; transition: all .12s;
}
.keybinding-btn:hover { background: #fff; border-color: #94a3b8; }
.keybinding-btn.capturing { background: #fef3c7; border-color: #f59e0b; color: #92400e; }
.keybinding-conflict {
  color: #b91c1c; font-size: 12px; padding: 8px 0; text-align: center;
}

/* ========== 教科色テーマ ========== */
.theme-aud  { --accent: #2563eb; --accent-hover: #1d4ed8; --accent-soft: #eff6ff; }
.theme-mgmt   { --accent: #d97706; --accent-hover: #b45309; --accent-soft: #fffbeb; }
.theme-fa     { --accent: #059669; --accent-hover: #047857; --accent-soft: #ecfdf5; }
.theme-corp  { --accent: #7c3aed; --accent-hover: #6d28d9; --accent-soft: #f5f3ff; }

/* ========== 画面切替 ========== */
.screen { display: none; }
.screen.active { display: block; }

/* ========== レスポンシブ ========== */
@media (max-width: 600px) {
  body { font-size: 13px; }
  .app {
    padding: 0 calc(12px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
  }
  .app-home {
    top: calc(8px + env(safe-area-inset-top)); left: calc(8px + env(safe-area-inset-left));
    padding: 10px 14px; font-size: 13px; min-height: 44px; display: inline-flex; align-items: center;
  }
  .chapter-grid { grid-template-columns: 1fr; }
  .judge-buttons { grid-template-columns: 1fr; gap: 10px; }
  .judge-buttons button { min-height: 52px; font-size: 16px; }
  .question-card { padding: 18px 16px; }
  .question-text { font-size: 15px; }
  .score-circle { width: 110px; height: 110px; }
  .score-num { font-size: 28px; }
  .btn-memo-add, .btn-memo-toggle, .btn-ai-explain { min-height: 44px; }
  .toggle-btn, .btn-tag { min-height: 40px; }
}

/* ===== Memo section ===== */
.memo-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed #e2e8f0;
}
.btn-memo-add,
.btn-memo-toggle {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-memo-add:hover,
.btn-memo-toggle:hover {
  background: #fff;
  border-color: #94a3b8;
  color: #1e293b;
}
.memo-header {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 6px;
  font-weight: 600;
}
.memo-textarea {
  width: 100%;
  min-height: 100px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  box-sizing: border-box;
}
.memo-textarea:focus {
  outline: none;
  border-color: #2563eb;
}
.memo-textarea.over-limit {
  border-color: #b91c1c;
  background: #fef2f2;
}
.memo-hint {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 4px;
}

/* ===== Sticky question header (meta + card stays at top while scrolling) ===== */
.question-sticky {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #f8fafc;     /* body と同じ背景で透けないように */
  margin-top: 0;
  padding-top: 8px;
  padding-bottom: 8px;
  box-shadow: 0 4px 8px -4px rgba(0, 0, 0, 0.08);  /* 解説との境界に軽い影 */
}
.question-sticky .question-meta { margin-bottom: 8px; }
.question-sticky .question-card { margin-bottom: 0; }
