/* ============================================
   高圧ガス販売主任者 学習アプリ — スタイルシート
   スマホファースト・ダーク/ライト両対応
   ============================================ */

:root {
  --font-size: 16px;
  --bg: #ffffff;
  --bg-card: #ffffff;
  --bg-soft: #f5f9ff;
  --bg-header: #1f4e79;
  --text: #1f2933;
  --text-soft: #52606d;
  --text-muted: #829ab1;
  --border: #d9e2ec;
  --border-strong: #bcccdc;
  --primary: #1f4e79;
  --primary-soft: #e8f1fb;
  --accent: #2f80ed;
  --correct: #16a34a;
  --correct-soft: rgba(22, 163, 74, 0.1);
  --incorrect: #dc2626;
  --incorrect-soft: rgba(220, 38, 38, 0.1);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

[data-theme="dark"] {
  --bg: #0f1620;
  --bg-card: #1a2433;
  --bg-soft: #243144;
  --bg-header: #0a1828;
  --text: #e7eaf0;
  --text-soft: #a5b1c4;
  --text-muted: #6b7a8f;
  --border: #2c3a4d;
  --border-strong: #3d4d63;
  --primary: #5b9dd9;
  --primary-soft: #1e2c40;
  --accent: #6ba6e8;
  --correct: #4ade80;
  --correct-soft: rgba(74, 222, 128, 0.12);
  --incorrect: #f87171;
  --incorrect-soft: rgba(248, 113, 113, 0.12);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html {
  font-size: var(--font-size);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic",
    "YuGothic", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: 60px;
}

/* ===== ヘッダー ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-header);
  color: white;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
}

.app-header h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.header-actions {
  display: flex;
  gap: 6px;
}

.header-actions button {
  background: rgba(255, 255, 255, 0.18);
  color: white;
  border: 0;
  padding: 7px 11px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  min-width: 36px;
  transition: background 0.15s;
}

.header-actions button:hover,
.header-actions button:focus {
  background: rgba(255, 255, 255, 0.3);
}

.header-actions button:active { transform: scale(0.95); }

/* ===== タブバー ===== */
.tab-bar {
  position: sticky;
  top: 47px;
  z-index: 99;
  background: var(--bg-card);
  display: flex;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.tab {
  flex: 1;
  background: transparent;
  border: 0;
  padding: 12px 6px;
  font-size: 13px;
  color: var(--text-soft);
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-weight: 600;
  transition: color 0.15s;
}

.tab:hover { color: var(--text); }
.tab:active { background: var(--bg-soft); }

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ===== メインコンテンツ ===== */
#content {
  padding: 14px;
  max-width: 820px;
  margin: 0 auto;
}

/* ===== 教科書 ===== */
.part-selector {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.part-btn {
  padding: 10px 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}

.part-btn:active { transform: scale(0.98); }

.part-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.toc {
  background: var(--bg-soft);
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.toc summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--primary);
  font-size: 14px;
  padding: 4px 0;
  user-select: none;
}

.toc summary:hover { color: var(--accent); }

.toc-list {
  margin: 10px 0 4px 0;
  padding-left: 0;
  list-style: none;
}

.toc-list li {
  margin: 2px 0;
  line-height: 1.6;
}

.toc-list a {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  display: block;
  padding: 4px 0;
}

.toc-list a:hover,
.toc-list a:focus {
  text-decoration: underline;
}

.textbook-content {
  font-size: 0.95em;
}

.textbook-content h1,
.textbook-content h2,
.textbook-content h3,
.textbook-content h4 {
  color: var(--primary);
  line-height: 1.4;
  margin-top: 28px;
  margin-bottom: 8px;
  scroll-margin-top: 110px;
}

.textbook-content h1 { font-size: 1.4em; border-bottom: 2px solid var(--primary); padding-bottom: 6px; }
.textbook-content h2 { font-size: 1.2em; border-bottom: 1px solid var(--border-strong); padding-bottom: 4px; }
.textbook-content h3 { font-size: 1.05em; }
.textbook-content h4 { font-size: 0.95em; }

.textbook-content p { margin: 8px 0; }
.textbook-content ul,
.textbook-content ol { padding-left: 24px; }
.textbook-content li { margin: 4px 0; }

.textbook-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.9em;
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}

.textbook-content th,
.textbook-content td {
  border: 1px solid var(--border-strong);
  padding: 6px 9px;
  text-align: left;
  vertical-align: top;
  white-space: normal;
}

.textbook-content th {
  background: var(--primary-soft);
  color: var(--text);
  font-weight: 700;
}

.textbook-content tr:nth-child(even) td { background: var(--bg-soft); }

.textbook-content blockquote {
  border-left: 4px solid var(--accent);
  background: var(--bg-soft);
  padding: 10px 14px;
  margin: 12px 0;
  border-radius: 4px;
  font-size: 0.95em;
}

.textbook-content code {
  background: var(--bg-soft);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.textbook-content hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.textbook-content strong {
  color: var(--primary);
  font-weight: 700;
}

[data-theme="dark"] .textbook-content strong {
  color: var(--accent);
}

/* ===== 教科書: 過去出題セクション ===== */
.textbook-section {
  margin: 8px 0;
}

.textbook-section.has-questions {
  background: rgba(255, 200, 200, 0.32);
  border-left: 4px solid #ef9a9a;
  padding: 10px 14px 4px 14px;
  margin: 16px -6px;
  border-radius: 0 8px 8px 0;
  position: relative;
}

[data-theme="dark"] .textbook-section.has-questions {
  background: rgba(220, 38, 38, 0.14);
  border-left-color: rgba(248, 113, 113, 0.55);
}

/* 過去出題バッジ＋折りたたみ */
.question-ref-details {
  margin-bottom: 10px;
}

.question-ref-details summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: inline-block;
}

.question-ref-details summary::-webkit-details-marker { display: none; }

.question-ref-summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #d32f2f;
  color: white;
  font-size: 11px;
  padding: 4px 11px;
  border-radius: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s;
}

.question-ref-summary::after {
  content: " ▸";
  font-size: 10px;
  margin-left: 2px;
}

.question-ref-details[open] .question-ref-summary::after {
  content: " ▾";
}

.question-ref-summary:hover { background: #b71c1c; }
.question-ref-details summary:active .question-ref-summary { transform: scale(0.97); }

[data-theme="dark"] .question-ref-summary {
  background: #ef5350;
  color: #1a0808;
}

[data-theme="dark"] .question-ref-summary:hover {
  background: #f97373;
}

/* 過去出題プレビュー（展開後の問題カード） */
.question-preview-list {
  margin-top: 10px;
}

.question-preview-action-all {
  display: block;
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 12px;
  transition: opacity 0.15s, transform 0.1s;
}

.question-preview-action-all:hover { opacity: 0.92; }
.question-preview-action-all:active { transform: scale(0.99); }

.question-preview {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-left: 4px solid #d32f2f;
  border-radius: 8px;
  padding: 12px 14px;
  margin: 0 0 10px 0;
  font-size: 13px;
  box-shadow: var(--shadow);
}

[data-theme="dark"] .question-preview {
  border-left-color: #ef5350;
}

.question-preview-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}

.question-preview-title {
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
  font-size: 13px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border);
}

[data-theme="dark"] .question-preview-title {
  color: var(--accent);
}

.question-preview-body {
  white-space: pre-wrap;
  margin-bottom: 10px;
  line-height: 1.65;
  word-break: break-word;
}

.question-preview-options {
  list-style: none;
  padding: 0;
  margin: 6px 0 10px 0;
}

.question-preview-options li {
  padding: 5px 8px;
  font-size: 12.5px;
  color: var(--text-soft);
  border-radius: 4px;
  margin: 2px 0;
  line-height: 1.55;
}

/* 答え表示エリア（初期は非表示） */
.question-preview-answers {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  border-left: 3px solid var(--correct);
}

.question-preview-answers.is-hidden {
  display: none;
}

.question-preview-answer {
  background: var(--correct-soft);
  color: var(--correct);
  padding: 5px 11px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  display: inline-block;
  margin-bottom: 8px;
}

/* 「答えを見る／隠す」「演習する」ボタン群 */
.question-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.question-preview-toggle-answer {
  flex: 1 1 auto;
  min-width: 130px;
  padding: 9px;
  background: transparent;
  color: #d32f2f;
  border: 1px solid #d32f2f;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.question-preview-toggle-answer:hover {
  background: #d32f2f;
  color: white;
}

[data-theme="dark"] .question-preview-toggle-answer {
  color: #ef5350;
  border-color: #ef5350;
}

[data-theme="dark"] .question-preview-toggle-answer:hover {
  background: #ef5350;
  color: #1a0808;
}

.question-preview-toggle-answer.is-revealed {
  background: #d32f2f;
  color: white;
}

[data-theme="dark"] .question-preview-toggle-answer.is-revealed {
  background: #ef5350;
  color: #1a0808;
}

.question-preview-judgment {
  font-size: 11px;
  color: var(--text-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  margin-bottom: 8px;
}

.question-preview-explanation {
  font-size: 12.5px;
  background: var(--bg-soft);
  padding: 9px 11px;
  border-radius: 6px;
  line-height: 1.7;
  color: var(--text);
}

.question-preview-explanation strong { color: var(--primary); }
[data-theme="dark"] .question-preview-explanation strong { color: var(--accent); }

.question-preview-action {
  flex: 1 1 auto;
  min-width: 130px;
  padding: 9px;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.question-preview-action:hover {
  background: var(--accent);
  color: white;
}

.question-preview-action:active { transform: scale(0.99); }

/* ===== 問題集 ===== */
.quiz-mode-selector {
  margin-bottom: 16px;
}

.quiz-mode-selector h2 {
  font-size: 18px;
  margin: 4px 0 14px 0;
  color: var(--primary);
}

.mode-btn {
  display: block;
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 8px;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
}

.mode-btn:hover { border-color: var(--accent); }
.mode-btn:active { transform: scale(0.99); background: var(--primary-soft); }

.mode-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.mode-btn .mode-sub {
  display: block;
  font-size: 12px;
  color: var(--text-soft);
  font-weight: 400;
  margin-top: 3px;
}

.mode-btn .mode-badge {
  display: inline-block;
  background: var(--accent);
  color: white;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
  font-weight: 700;
  vertical-align: middle;
}

.mode-btn.due-now .mode-badge {
  background: #d32f2f;
  animation: pulse-badge 1.6s ease-in-out infinite;
}

[data-theme="dark"] .mode-btn.due-now .mode-badge {
  background: #ef5350;
}

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.review-summary {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.7;
}

.review-summary strong {
  color: var(--primary);
}

[data-theme="dark"] .review-summary strong {
  color: var(--accent);
}

.review-summary .due-now {
  color: #d32f2f;
  font-weight: 700;
}

[data-theme="dark"] .review-summary .due-now {
  color: #ef5350;
}

.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin: 4px 0 6px 0;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.progress-info {
  font-size: 12px;
  color: var(--text-soft);
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
}

.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.question-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: none;
  letter-spacing: 0.02em;
}

.question-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--primary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}

.question-body {
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.option-btn {
  padding: 12px 14px;
  background: var(--bg-card);
  color: var(--text);
  border: 2px solid var(--border-strong);
  border-radius: 10px;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 500;
}

.option-btn:hover:not(:disabled) { border-color: var(--accent); }
.option-btn:active:not(:disabled) { transform: scale(0.99); }

.option-btn.selected {
  border-color: var(--accent);
  background: var(--primary-soft);
}

.option-btn.correct {
  background: var(--correct-soft);
  border-color: var(--correct);
  color: var(--correct);
  font-weight: 700;
}

.option-btn.incorrect {
  background: var(--incorrect-soft);
  border-color: var(--incorrect);
  color: var(--incorrect);
  font-weight: 700;
}

.option-btn:disabled { cursor: not-allowed; }

.answer-area {
  margin-top: 16px;
  padding: 14px;
  border-radius: 10px;
  display: none;
  border: 1px solid;
}

.answer-area.show { display: block; }

.answer-area.correct {
  background: var(--correct-soft);
  border-color: var(--correct);
}

.answer-area.incorrect {
  background: var(--incorrect-soft);
  border-color: var(--incorrect);
}

.answer-result {
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 15px;
}

.answer-result.correct { color: var(--correct); }
.answer-result.incorrect { color: var(--incorrect); }

.judgment {
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--text-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.explanation {
  font-size: 13px;
  line-height: 1.7;
  background: var(--bg-card);
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.explanation strong { color: var(--primary); }
[data-theme="dark"] .explanation strong { color: var(--accent); }

.action-bar {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.action-bar button {
  flex: 1;
  padding: 13px;
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.action-bar button:hover:not(:disabled) { opacity: 0.92; }
.action-bar button:active:not(:disabled) { transform: scale(0.98); }

.action-bar button:disabled {
  background: var(--text-muted);
  opacity: 0.5;
  cursor: not-allowed;
}

.action-bar .secondary {
  background: transparent;
  color: var(--text-soft);
  border: 1px solid var(--border-strong);
  flex: 0 0 auto;
  min-width: 88px;
}

.action-bar .secondary:hover:not(:disabled) {
  background: var(--bg-soft);
  opacity: 1;
}

/* 結果画面 */
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 32px 20px;
  margin-bottom: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}

.result-card h2 { margin: 0 0 8px 0; color: var(--primary); }

.result-score {
  font-size: 32px;
  font-weight: 800;
  color: var(--primary);
  margin: 16px 0 8px 0;
}

.result-rate {
  font-size: 14px;
  color: var(--text-soft);
  margin-bottom: 20px;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
  margin: 0 auto;
}

.result-actions button {
  padding: 13px;
  border: 0;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.result-actions button:active { transform: scale(0.98); }

.result-actions .retry-wrong {
  background: #d32f2f;
  color: white;
}

.result-actions .retry-wrong:hover { background: #b71c1c; }

[data-theme="dark"] .result-actions .retry-wrong {
  background: #ef5350;
}

[data-theme="dark"] .result-actions .retry-wrong:hover {
  background: #f97373;
}

.result-actions .restart {
  background: var(--accent);
  color: white;
}

.result-actions .back-mode {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.next-review-info {
  margin-top: 8px;
  padding: 6px 10px;
  background: var(--bg-soft);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-soft);
  text-align: center;
}

/* ===== 条文タブ ===== */
.law-selector {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

@media (min-width: 640px) {
  .law-selector { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1024px) {
  .law-selector { grid-template-columns: repeat(6, 1fr); }
}

.law-btn {
  padding: 12px 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  line-height: 1.4;
}

.law-btn:active { transform: scale(0.98); }

.law-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.law-btn .law-btn-sub {
  display: block;
  font-size: 10px;
  font-weight: 400;
  opacity: 0.8;
  margin-top: 2px;
}

.law-btn.out-of-scope {
  opacity: 0.65;
}

.law-btn.out-of-scope::after {
  content: " (参考)";
  font-size: 10px;
  font-weight: 400;
  color: var(--text-muted);
}

.law-btn.active.out-of-scope { opacity: 1; }

.law-search-box {
  margin-bottom: 12px;
  position: relative;
}

.law-search-input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.law-search-input::placeholder { color: var(--text-muted); }

.law-search-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.law-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.law-search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--text-muted);
  color: white;
  border: 0;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 14px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.law-search-clear.show { display: flex; }

.law-info-banner {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.6;
}

.law-info-banner strong { color: var(--primary); }
[data-theme="dark"] .law-info-banner strong { color: var(--accent); }

.law-search-results {
  margin-bottom: 14px;
}

.law-search-result {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s;
}

.law-search-result:hover { background: var(--bg-soft); }
.law-search-result:active { transform: scale(0.99); }

.law-search-result-title {
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
  font-size: 13px;
}

[data-theme="dark"] .law-search-result-title { color: var(--accent); }

.law-search-result-snippet {
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.55;
}

.law-search-result-snippet mark {
  background: rgba(255, 235, 59, 0.5);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 600;
}

[data-theme="dark"] .law-search-result-snippet mark {
  background: rgba(255, 235, 59, 0.25);
  color: var(--text);
}

.law-content {
  font-size: 0.92em;
}

.law-content h1, .law-content h2, .law-content h3 {
  color: var(--primary);
  line-height: 1.4;
  scroll-margin-top: 110px;
}

.law-content h1 { font-size: 1.3em; border-bottom: 2px solid var(--primary); padding-bottom: 6px; margin: 28px 0 12px; }
.law-content h2 { font-size: 1.1em; border-bottom: 1px solid var(--border-strong); padding-bottom: 4px; margin: 24px 0 10px; }
.law-content h3 { font-size: 1.0em; margin: 18px 0 8px; }

.law-content ul { padding-left: 22px; margin: 6px 0; }
.law-content li { margin: 3px 0; line-height: 1.7; }

.law-content strong { color: var(--primary); }
[data-theme="dark"] .law-content strong { color: var(--accent); }

.law-content p { margin: 6px 0; }

.law-loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.law-content-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

/* ===== 進捗タブ ===== */
.progress-summary {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.progress-summary h2,
.progress-summary h3 {
  margin: 0 0 12px 0;
  color: var(--primary);
}

.progress-summary h2 { font-size: 18px; }
.progress-summary h3 { font-size: 15px; }

.stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.stat:last-child { border-bottom: 0; }

.stat-label {
  color: var(--text-soft);
}

.stat-value {
  font-weight: 700;
  font-size: 16px;
}

.stat-value.correct { color: var(--correct); }
.stat-value.incorrect { color: var(--incorrect); }

.danger-btn {
  width: 100%;
  padding: 12px;
  background: var(--bg-card);
  color: var(--incorrect);
  border: 1px solid var(--incorrect);
  border-radius: 10px;
  margin-top: 16px;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
}

.danger-btn:hover { background: var(--incorrect-soft); }

/* ===== フッター ===== */
.app-footer {
  text-align: center;
  padding: 18px 14px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.6;
  border-top: 1px solid var(--border);
  margin-top: 32px;
}

.app-footer p { margin: 0; }

/* ===== レスポンシブ（タブレット以上） ===== */
@media (min-width: 640px) {
  .app-header h1 { font-size: 18px; }
  .tab { font-size: 14px; padding: 14px 12px; }
  .part-selector { grid-template-columns: repeat(4, 1fr); }
  .part-btn { font-size: 13px; padding: 12px 8px; }
  #content { padding: 20px; }
  .question-card { padding: 20px; }
  .question-body { font-size: 15px; }
  .option-btn { font-size: 15px; padding: 14px 16px; }
}

@media (min-width: 1024px) {
  #content { padding: 24px; }
  .textbook-content { font-size: 1em; }
}

/* スクロールバーをやさしく */
.textbook-content table::-webkit-scrollbar { height: 8px; }
.textbook-content table::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}
