/* 対象範囲のブランドカラー（Issue #41）。アクセントは CSS 変数にまとめ、<html data-ministry="…"> で対象範囲ごとに差し替える
   （`/` の熊本県は :root の既定。/mlit/ 等はサーバーが属性を付け、ministry.js も同じ値を再設定する）。
   --brand-strong … 白文字（--on-accent）を載せる面（選択中タブ・主ボタン）。白とのコントラスト 4.5:1 以上
   --brand … 濃い文字（--on-brand）を載せる面（ツリーマップ等）。#111 とのコントラスト 4.5:1 以上
   --brand-link … 紙色の上の文字（リンク・枠・強調数字）。ライトは --brand-strong と同じ、ダークは明るい色
   --brand-tint / --brand-tint-2 … 薄い背景・強調背景
   対象範囲のロゴ・紋章・公式ロゴ書体は使わない（公式ツールに見せない）。免責の表示は残す */
:root, [data-ministry="maff"] {
  /* 熊本県: 熊本城の墨黒＋朱（火の国）（Issue #14）。生成り色の薄い面。コントラストは白/朱 6.57、朱/生成り 5.85、#111/--brand 7.60 */
  --brand: #e0907c;
  --brand-strong: #b02a1e;
  --brand-stronger: #8c1f16;
  --brand-tint: #f7f1e8;
  --brand-tint-2: #ecdfcc;
  --brand-link: #b02a1e;
  --brand-link-hover: #8c1f16;
  /* 見出しの帯（熊本城の墨黒）と帯の上の文字 */
  --castle: #1f1c1a;
  --on-castle: #f3eee6;
  --on-castle-muted: #cfc6ba;
}
[data-ministry="cao"] {
  /* 内閣府: 紫 */
  --brand: #b39ddb;
  --brand-strong: #6b4fa1;
  --brand-stronger: #553f83;
  --brand-tint: #f1eaf9;
  --brand-tint-2: #e2d4f3;
  --brand-link: #6b4fa1;
  --brand-link-hover: #553f83;
}
[data-ministry="soumu"] {
  /* 総務: 朱 */
  --brand: #d98a7d;
  --brand-strong: #b3402a;
  --brand-stronger: #8f3421;
  --brand-tint: #faecea;
  --brand-tint-2: #f4d6d0;
  --brand-link: #b3402a;
  --brand-link-hover: #8f3421;
}
[data-ministry="mlit"] {
  /* 国交: 青 */
  --brand: #8bb4de;
  --brand-strong: #1c5da6;
  --brand-stronger: #174a84;
  --brand-tint: #eaf2fa;
  --brand-tint-2: #d5e5f4;
  --brand-link: #1c5da6;
  --brand-link-hover: #174a84;
}
:root {
  --on-brand: #111;   /* --brand の面に載せる文字（中間色の上なので全モードで濃い文字） */
  --on-accent: #fff;  /* --brand-strong の面に載せる文字 */
  --ink: #111;
  --paper: #fff;
  --gray-1: #f4f4f4;
  --gray-2: #ddd;
  --gray-3: #888;
  --gray-4: #444;
  --row-alt: #fafcf5;     /* 表の縞 */
  --mark-bg: #fff4d6;     /* 要確認マーカー */
  --mark-border: #b7791f;
}

/* ダークモード（Issue #41）: 紙・墨・グレーと、対象範囲色のリンク・薄い背景だけ暗い値に差し替える。
   --brand-strong 系（白文字を載せる面）は共通の値で、白とのコントラストはライトと同じ */
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e6e8ea;
    --paper: #14161a;
    --gray-1: #1d2024;
    --gray-2: #34393f;
    --gray-3: #9aa0a8;
    --gray-4: #c9ced4;
    --row-alt: #1b1e22;
    --mark-bg: #4a3d16;
    --mark-border: #d6a94e;
  }
  :root, [data-ministry="maff"] { --brand-tint: #2b1c18; --brand-tint-2: #3b2620; --brand-link: #f2a593; --brand-link-hover: #f8c6ba; }
  [data-ministry="cao"] { --brand-tint: #22172f; --brand-tint-2: #312145; --brand-link: #c9a8e8; --brand-link-hover: #ddc7f2; }
  [data-ministry="soumu"] { --brand-tint: #2a1712; --brand-tint-2: #3c211a; --brand-link: #eda393; --brand-link-hover: #f5c2b5; }
  [data-ministry="mlit"] { --brand-tint: #16222f; --brand-tint-2: #1e3044; --brand-link: #9cc3ee; --brand-link-hover: #bdd8f5; }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  accent-color: var(--brand-strong);
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", sans-serif;
  font-size: 16px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
a { color: var(--brand-link); text-decoration: underline; }
a:hover { color: var(--brand-link-hover); }
h1, h2, h3 { line-height: 1.4; margin: 0 0 8px; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 8px; }
.muted { color: var(--gray-4); font-size: 0.9rem; }

.banner {
  background: var(--brand-tint);
  color: var(--ink);
  text-align: center;
  padding: 8px 16px;
  font-weight: bold;
  border-bottom: 3px solid var(--brand);
}
#app { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
/* 見出しの帯（Issue #41）: 対象範囲色の薄い面＋濃い下線 */
/* 対象範囲タブは帯の下端に置き、選択中のタブが下線とつながる（Issue #41 レビュー）。タブが無い画面（管理）は下に余白を残す */
/* 熊本らしさ（Issue #14）: 帯は熊本城の墨黒、下端に石垣の「武者返し」を思わせる反りの曲線（朱の線）を1本。
   画像・公式ロゴ・キャラクターは使わない（非公式ツールの表示は維持） */
.site-header { position: relative; padding: 16px 16px 0; margin: 0 -16px 18px; background: var(--castle); color: var(--on-castle); }
.site-header::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -18px; height: 18px; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 18' preserveAspectRatio='none'%3E%3Cpath d='M0 0H100C64 0 30 5 0 18Z' fill='%231f1c1a'/%3E%3Cpath d='M0 18C30 5 64 0 100 0' fill='none' stroke='%23b02a1e' stroke-width='3' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E") no-repeat;
  background-size: 100% 100%;
}
.site-header a { color: var(--on-castle); }
.site-header h1 { display: flex; align-items: center; gap: 10px; }
/* 落款のような朱の角印（装飾。読み上げない） */
.site-header h1::before { content: ""; flex: 0 0 auto; width: 0.75em; height: 0.75em; background: var(--brand-strong); border-radius: 2px; }
.site-header > :last-child { margin-bottom: 16px; }
.site-header > .ministry-nav:last-child { margin-bottom: 0; }
.subtitle { font-weight: bold; color: var(--gray-4); margin: 0 0 4px; }
.lead { color: var(--gray-4); font-size: 0.95rem; margin: 0; }
.site-header .subtitle { color: var(--on-castle); }
.site-header .lead { color: var(--on-castle-muted); }

.layout { display: flex; gap: 24px; align-items: flex-start; padding: 16px 0; }
.main { flex: 1 1 auto; min-width: 0; }
.sidebar { flex: 0 0 300px; min-width: 0; border: 1px solid var(--brand); border-top: 4px solid var(--brand); padding: 12px; background: var(--paper); }

/* 機能タブは下線型（Issue #41 レビュー）。対象範囲タブ（塗りの面）と見た目を分け、上位の切り替えと区別する */
.tabs { display: flex; flex-wrap: wrap; gap: 0 4px; border-bottom: 1px solid var(--gray-3); }
.tabs button {
  font: inherit; cursor: pointer;
  background: none; color: var(--gray-4);
  border: 0; border-bottom: 4px solid transparent;
  padding: 8px 12px 6px; margin: 0 0 -1px;
}
.tabs button:hover { color: var(--ink); border-bottom-color: var(--gray-3); }
.tabs button[aria-selected="true"] { color: var(--brand-link); border-bottom-color: var(--brand-link); font-weight: 700; }
.panel { padding: 16px 0; }
.panel[hidden], [hidden] { display: none !important; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
label { display: block; font-size: 0.9rem; font-weight: bold; }
label.inline { display: inline-block; margin-right: 16px; font-weight: normal; }
label.block { margin-bottom: 12px; }
input[type="text"], input[type="date"], select, textarea {
  display: block; width: 100%; max-width: 100%;
  font: inherit; font-weight: normal;
  color: var(--ink); background: var(--paper);
  border: 1px solid var(--gray-3); border-radius: 0;
  padding: 6px 8px; margin-top: 4px;
}
input[type="checkbox"], input[type="radio"] { margin-right: 6px; }
textarea { resize: vertical; }
fieldset { border: 1px solid var(--gray-2); margin: 0 0 12px; padding: 8px 12px; min-width: 0; }
legend { font-size: 0.9rem; font-weight: bold; padding: 0 4px; }
.hp-field { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; }

.btn {
  font: inherit; cursor: pointer;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--ink); border-radius: 0;
  padding: 6px 14px;
}
.btn:hover { background: var(--brand-tint); }
.btn.primary { background: var(--brand-strong); color: var(--on-accent); border-color: var(--brand-strong); }
.btn.primary:hover { background: var(--brand-stronger); border-color: var(--brand-stronger); }
.btn[aria-pressed="true"] { background: var(--brand-strong); color: var(--on-accent); border-color: var(--brand-strong); }
.btn.small { padding: 2px 10px; font-size: 0.85rem; }
.btn:disabled { background: var(--gray-2); color: var(--gray-3); border-color: var(--gray-3); cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--gray-4); outline-offset: 2px;
}

.status:empty { display: none; }
.status, .notice, .note-box {
  background: var(--gray-1); border: 1px solid var(--gray-3);
  padding: 8px 12px; margin: 8px 0;
}
.error-box { background: var(--gray-1); border: 2px solid var(--ink); padding: 8px 12px; margin: 8px 0; }

.result-item { border-bottom: 1px solid var(--gray-2); padding: 12px 0; }
.result-meta { font-weight: bold; font-size: 0.95rem; }
.result-sub { color: var(--gray-4); font-size: 0.9rem; }
.excerpt { margin: 4px 0 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.pager { display: flex; gap: 12px; align-items: center; margin: 12px 0; }

.meeting-row {
  display: block; width: 100%; text-align: left; font: inherit; cursor: pointer;
  background: var(--paper); color: var(--ink);
  border: none; border-bottom: 1px solid var(--gray-2); padding: 10px 4px;
}
.meeting-row:hover { background: var(--gray-1); }

.speech { border-bottom: 1px solid var(--gray-2); padding: 12px 0; }
.speech-text { white-space: pre-wrap; margin: 6px 0; }

.toggle { display: flex; gap: 8px; margin-bottom: 8px; }
.rank-item { border-top: 1px solid var(--gray-2); padding: 8px 0; font-size: 0.9rem; }
.rank-no { display: inline-block; min-width: 1.6em; font-weight: bold; }

.sources { margin: 16px 0; }
.source-item { border: 1px solid var(--gray-2); padding: 8px 12px; margin-bottom: 8px; }
.source-item.hl { background: var(--brand-tint-2); border: 2px solid var(--brand-link); }
.answers { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.answer-card { border: 1px solid var(--brand-link); border-top: 4px solid var(--brand); padding: 12px; min-width: 0; background: var(--paper); }
.answer-head { font-weight: bold; border-bottom: 1px solid var(--gray-2); margin-bottom: 8px; padding-bottom: 4px; font-size: 0.95rem; }
.answer-text p { white-space: pre-wrap; }
.warn-box { background: var(--gray-1); border: 1px solid var(--gray-3); color: var(--gray-4); padding: 6px 10px; margin-top: 8px; font-size: 0.85rem; }
.warn-box ul { margin: 0; padding-left: 1.2em; }
.fixed-note { font-size: 0.85rem; color: var(--gray-4); margin-top: 8px; margin-bottom: 0; }

.site-footer { border-top: 4px solid var(--brand); padding: 16px 0 32px; font-size: 0.9rem; color: var(--gray-4); }

dialog {
  width: min(720px, calc(100vw - 32px)); max-height: 90vh; overflow: auto;
  border: 2px solid var(--ink); padding: 0; background: var(--paper); color: var(--ink);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.dialog-inner { padding: 16px; }
.dialog-actions { margin-top: 12px; text-align: right; }

.expired { padding: 64px 16px; text-align: center; }

@media (max-width: 899px) {
  .layout { flex-direction: column; }
  .sidebar { flex: 1 1 auto; width: 100%; }
}
@media (max-width: 560px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .answers { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- 答弁案・想定問答（Issue #7） ---------- */
.answer-text strong { font-weight: bold; }
.cite { white-space: nowrap; }
.copy-state { font-size: 0.85rem; color: var(--gray-4); }
.policy-item { border: 1px solid var(--gray-2); padding: 8px 12px; margin-bottom: 8px; }
.policy-item.hl { background: var(--brand-tint-2); border: 2px solid var(--brand-link); }
.q-items { margin: 8px 0 16px; }
.q-item { border: 1px solid var(--gray-2); padding: 8px 12px; margin-bottom: 8px; }
.q-check { display: inline-block; }
.q-refs { margin: 4px 0 0; }
.qa-actions { margin: 8px 0; }
.qa-set { margin-top: 12px; }
.qa-item { border: 1px solid var(--ink); padding: 12px; margin-bottom: 16px; min-width: 0; }
.qa-q { border-bottom: 1px solid var(--gray-2); padding-bottom: 6px; margin-bottom: 8px; }
.qa-label { font-weight: bold; margin: 8px 0 4px; }
.qa-a .answer-text p { white-space: pre-wrap; }
.qa-sources { border-top: 1px solid var(--gray-2); margin-top: 8px; }
.qa-sources .source-item, .qa-sources .policy-item { font-size: 0.9rem; }
.warn-box .btn { margin-top: 4px; }

/* ---------- ダッシュボード・テンプレート・管理画面（Issue #9） ---------- */
.tpl-details { margin: -4px 0 12px; }
.tpl-preview { white-space: pre-wrap; border: 1px solid var(--gray-3); background: var(--gray-1); padding: 8px 12px; margin: 4px 0 0; font: inherit; font-size: 0.9rem; max-height: 240px; overflow: auto; }
label.inline.policy-check { display: block; margin-right: 0; }

.dash-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.dash-card { border: 1px solid var(--ink); padding: 12px; background: var(--paper); }
.dash-card-label { font-size: 0.9rem; color: var(--gray-4); font-weight: bold; }
.dash-card-value { font-size: 1.6rem; font-weight: bold; line-height: 1.3; }
.dash-block { margin: 16px 0; }

/* ツリーマップとジャンルのドリルダウン（Issue #21）。濃い緑は白文字、黄緑・薄い緑は黒文字 */
.treemap { position: relative; width: 100%; height: 360px; background: var(--gray-1); overflow: hidden; }
.treemap-tile { position: absolute; margin: 0; padding: 4px 6px; border: 1px solid var(--paper); border-radius: 0; font: inherit; font-size: 0.85rem; line-height: 1.25; text-align: left; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 2px; }
.treemap-tile[hidden] { display: none; }
.treemap-tile.tone-0 { background: var(--brand-strong); color: var(--on-accent); }
.treemap-tile.tone-1 { background: var(--brand); color: var(--on-brand); }
.treemap-tile.tone-2 { background: var(--brand-tint-2); color: var(--ink); }
.treemap-tile.rest { border: 1px dashed var(--gray-4); }
.treemap-tile:hover, .treemap-tile:focus-visible { outline: 3px solid var(--ink); outline-offset: -3px; z-index: 1; }
.treemap-tile .tm-name { font-weight: bold; }
.treemap-tile.small { padding: 1px; align-items: center; justify-content: center; font-size: 0.75rem; }
.treemap-tile.small .tm-name { display: none; }
.treemap-tile.tiny .tm-count { display: none; }
.link-btn { font: inherit; padding: 0; margin: 0; border: 0; background: none; color: var(--brand-link); text-decoration: underline; cursor: pointer; text-align: left; min-height: 28px; }
.link-btn:hover { color: var(--ink); }
.genre-table .dash-table { max-width: 520px; }
.genre-panel { border: 2px solid var(--brand-link); padding: 12px; margin: 16px 0; background: var(--paper); scroll-margin-top: 8px; }
.genre-panel[hidden] { display: none; }
.genre-panel-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.genre-panel-head h3 { margin: 0; font-size: 1.1rem; }
.genre-qa { border: 1px solid var(--gray-3); padding: 12px; margin-bottom: 12px; min-width: 0; }
.genre-answers { margin-top: 12px; padding: 8px 12px; background: var(--brand-tint); border-left: 4px solid var(--brand); }
.genre-answers-label { font-weight: bold; font-size: 0.9rem; margin-bottom: 4px; }
.genre-answer { padding: 8px 0; border-top: 1px dashed var(--gray-3); font-size: 0.95rem; }
.genre-answers-label + .genre-answer { border-top: 0; }
@media (max-width: 560px) {
  .treemap { height: 280px; }
}

.kanban { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; align-items: start; }
.kanban-col { border: 1px solid var(--brand); border-top: 4px solid var(--brand-strong); padding: 8px; min-width: 0; background: var(--brand-tint); }
.kanban-card { border: 1px solid var(--gray-3); background: var(--paper); padding: 8px; margin-bottom: 8px; font-size: 0.9rem; }

.dash-tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.dash-popular { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.dash-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.dash-table th, .dash-table td { border: 1px solid var(--gray-3); padding: 4px 8px; text-align: left; }
.dash-table th { background: var(--gray-1); }
.dash-table .num { text-align: right; white-space: nowrap; }

.admin-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--gray-2); padding: 8px 0; }
.admin-row-main { flex: 1 1 300px; min-width: 0; }
.admin-log { border: 1px solid var(--gray-3); background: var(--gray-1); padding: 8px 12px; font-size: 0.85rem; max-height: 280px; overflow: auto; }
.admin-log div { border-bottom: 1px solid var(--gray-2); padding: 2px 0; }
.admin-section { margin: 24px 0; }

@media (max-width: 560px) {
  .kanban { grid-template-columns: minmax(0, 1fr); }
}

/* 参考資料（政策文書）の表（Issue #11）: 文書名を切らずに折り返す */
.policy-tools { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 8px; }
.policy-table-wrap { max-height: 360px; overflow-y: auto; border: 1px solid var(--brand); }
.policy-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; table-layout: auto; }
.policy-table th { position: sticky; top: 0; background: var(--brand-tint); text-align: left; font-weight: bold; padding: 6px 8px; border-bottom: 2px solid var(--brand); white-space: nowrap; }
.policy-table td { padding: 6px 8px; border-bottom: 1px solid var(--gray-2); vertical-align: top; }
.policy-table tr:nth-child(even) td { background: var(--row-alt); }
.policy-table td.c-check { width: 2.5em; text-align: center; }
.policy-table td.c-id { width: 3.5em; font-weight: bold; white-space: nowrap; }
.policy-table td.c-title { white-space: normal; overflow-wrap: anywhere; }
.policy-table td.c-title label { display: inline; font-weight: normal; font-size: inherit; cursor: pointer; }
.policy-table td.c-title .issuer { display: block; color: var(--gray-4); font-size: 0.8rem; }
.policy-table td.c-title .policy-kind { display: inline-block; margin-top: 2px; padding: 0 6px; border-radius: 3px; font-size: 0.75rem; border: 1px solid var(--brand-link); color: var(--brand-link); }
.policy-table td.c-title .policy-kind.pref { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--on-accent, #fff); }
.policy-table td.c-date { white-space: nowrap; }
.policy-table tr.off td { color: var(--gray-3); }
@media (max-width: 600px) {
  .policy-table td.c-date, .policy-table th.c-date { display: none; }
}

/* ---------- 質問要旨・問とり（Issue #13） ---------- */
.q-basis { margin: 4px 0 0; }
.q-followups { margin: 2px 0 0; padding-left: 1.4em; font-size: 0.9rem; }
.badge { display: inline-block; font-size: 0.8rem; font-weight: bold; padding: 0 8px; border: 1px solid var(--gray-3); margin-top: 4px; }
.badge-high { background: var(--brand-strong); color: var(--on-accent); border-color: var(--brand-strong); }
.badge-mid { background: var(--brand-tint-2); color: var(--ink); border-color: var(--brand); }
.badge-low { background: var(--gray-1); color: var(--gray-4); border-color: var(--gray-3); }
.text-count { font-size: 0.9rem; color: var(--gray-4); margin: 2px 0 8px; }
.text-count.over { color: var(--ink); font-weight: bold; border-left: 4px solid var(--ink); padding-left: 8px; }
.privacy-note { border-left: 4px solid var(--brand-strong); background: var(--brand-tint); }
.file-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 0 0 8px; }
.file-btn { position: relative; display: inline-block; cursor: pointer; border: 1px solid var(--ink); background: var(--paper); padding: 6px 14px; }
.file-btn:hover { background: var(--brand-tint); }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file-btn:focus-within { outline: 3px solid var(--gray-4); outline-offset: 2px; }

/* 質問の組み立て（テーマ×聞き方）と更問（Issue #15） */
.composer { margin-bottom: 12px; }
.chip-group { margin-bottom: 8px; }
.chip-label { font-weight: bold; font-size: 0.9rem; margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; padding: 6px 14px; font: inherit; cursor: pointer; border: 1px solid var(--brand-link); background: var(--paper); color: var(--brand-link); border-radius: 0; }
.chip:hover { background: var(--brand-tint); }
.chip[aria-pressed="true"] { background: var(--brand-strong); color: var(--on-accent); border-color: var(--brand-strong); }
.fu-block { margin-top: 8px; }
.fu-item { border-left: 4px solid var(--brand); background: var(--brand-tint); padding: 8px 12px; margin: 8px 0; }
.fu-q { font-weight: bold; }
.fu-aim { font-size: 0.9rem; color: var(--gray-4); }
.fu-answer { margin-top: 8px; background: var(--paper); }

/* 根拠で答えられない点の印（Issue #19） */
mark.need-check { background: var(--mark-bg); color: var(--ink); border: 1px dashed var(--mark-border); padding: 0 4px; font-weight: bold; }

/* 対応づけの理由（Issue #23） */
.match-reason { font-size: 0.8rem; margin: 2px 0 4px; }

/* ---------- 議員分析（Issue #30） ---------- */
.member-table td.c-group { overflow-wrap: anywhere; }
.member-steps { margin: 8px 0; padding-left: 1.6em; }
.member-steps .step-state { font-weight: bold; }
.member-collect { margin: 8px 0; }
.member-genres { max-width: 28em; }
.member-sources { margin: 8px 0; }
.member-sources summary { cursor: pointer; font-weight: bold; }
.member-form { margin: 12px 0; }
.member-profile-sec { margin: 8px 0; }
.member-profile-list { margin: 4px 0; padding-left: 1.4em; }
.ai-tag { font-size: 0.75rem; font-weight: normal; color: var(--gray-4); border: 1px solid var(--gray-3); padding: 0 6px; }
.member-q { border-left: 4px solid var(--brand); background: var(--brand-tint); padding: 8px 12px; margin: 8px 0; }
.member-q p { margin: 4px 0; }
.member-q .q-head { font-weight: bold; }
@media (max-width: 600px) {
  .member-table td.c-latest, .member-table th.c-latest { display: none; }
  .member-table th, .member-table td { padding: 4px 6px; }
}

/* 管理画面「利用状況」（Issue #32）。色は既存の変数だけ */
.usage-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 12px 0; }
.usage-card { border: 1px solid var(--gray-3); border-top: 4px solid var(--brand); padding: 8px 12px; background: var(--paper); }
.usage-card h3 { margin: 0 0 4px; font-size: 1rem; }
.usage-cost { margin: 0 0 4px; }
.usage-cost-main { font-size: 1.6rem; font-weight: bold; color: var(--brand-link); }
.usage-cost-sub { color: var(--gray-4); }
.usage-card-list { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0; font-size: 0.9rem; }
.usage-card-list dt { color: var(--gray-4); }
.usage-card-list dd { margin: 0; text-align: right; }
.usage-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.85rem; margin: 8px 0 0; }
.usage-swatch { display: inline-block; width: 12px; height: 12px; margin-right: 4px; vertical-align: -1px; border: 1px solid var(--gray-3); }
.usage-chart-wrap { overflow-x: auto; border: 1px solid var(--gray-2); background: var(--paper); }
.usage-chart { display: block; width: 100%; min-width: 480px; height: auto; }
.usage-table-wrap { overflow-x: auto; margin: 8px 0 16px; }
.usage-table-wrap .dash-table { min-width: 480px; }
.usage-table-wrap .dash-table th, .usage-table-wrap .dash-table td { white-space: nowrap; }

/* 対象範囲の切り替えタブ（Issue #41・#36 の切り替えをタブ化）。各タブの上端の線はその対象範囲のブランド色、
   選択中（aria-current）は対象範囲色の面＋白文字。ロゴ・画像は使わない。タブは /api/ministries の順（件数順） */
.ministry-nav { display: flex; flex-wrap: wrap; gap: 4px; margin: 12px 0 0; }
.ministry-nav:empty { display: none; }
.ministry-tab {
  --tab-accent: var(--brand-strong);
  display: inline-block; padding: 6px 16px; min-height: 44px; line-height: 1.7;
  font: inherit; color: var(--ink); text-decoration: none;
  background: var(--paper);
  border: 1px solid var(--gray-3); border-bottom: 0; border-top: 4px solid var(--tab-accent);
}
.ministry-tab:hover { background: var(--brand-tint); }
.ministry-tab[aria-current="page"] { background: var(--tab-accent); color: var(--on-accent); border-color: var(--tab-accent); font-weight: 700; }
.ministry-tab[data-ministry="cao"] { --tab-accent: #6b4fa1; }
.ministry-tab[data-ministry="soumu"] { --tab-accent: #b3402a; }
.ministry-tab[data-ministry="mlit"] { --tab-accent: #1c5da6; }
.ministry-tab[data-ministry="maff"] { --tab-accent: #4e7a1c; }
/* 360px でも対象範囲タブを1行に収める（4つを等幅で並べる）。機能タブは詰めて折り返す（Issue #41 レビュー） */
@media (max-width: 560px) {
  .ministry-nav { flex-wrap: nowrap; }
  .ministry-tab { flex: 1 1 0; min-width: 0; padding: 6px 4px; text-align: center; }
  .tabs button { padding: 8px 8px 6px; }
}

.materials-box { margin-bottom: .75rem; }
#materials-results .cards { display: grid; gap: .75rem; margin-bottom: 1rem; }
#materials-results .card h3 { font-size: 1rem; margin: 0 0 .25rem; }
