/* 住民AIインタビュー（アンドウSP） — スマホ最優先。装飾より読みやすさと押しやすさ。 */

:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #22282a;
  --ink-soft: #5c6569;
  --line: #e0dbd1;
  --accent: #2f6f5e;
  --accent-dark: #245a4c;
  --accent-soft: #eaf1ed;
  --warn-bg: #fbf3e4;
  --warn-line: #e6d3a8;
  --radius: 12px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
               "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  font-size: 17px;
  line-height: 1.75;
}

a { color: var(--accent); }

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 18px 40px;
}

/* ---------- ヘッダー ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header .wrap {
  padding: 12px 18px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.site-header .org {
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: .04em;
}
.site-header .org { text-decoration: none; }
.site-header .page-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  flex: 1;
  min-width: 0;
}
.site-header .nav-top {
  font-size: 14px;
  white-space: nowrap;
}

/* ---------- 見出し・文章 ---------- */
h1 { font-size: 23px; line-height: 1.5; margin: 4px 0 16px; }
h2 { font-size: 19px; margin: 32px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
h3 { font-size: 17px; margin: 24px 0 8px; }
p  { margin: 0 0 14px; }
ul, ol { padding-left: 1.3em; margin: 0 0 14px; }
li { margin-bottom: 6px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }

.lead { font-size: 17px; margin-bottom: 24px; }
.muted { color: var(--ink-soft); font-size: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 18px;
}

.notice {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 18px;
}

/* ---------- ボタン ---------- */
.btn {
  display: block;
  width: 100%;
  min-height: 56px;
  padding: 14px 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  -webkit-appearance: none;
}
.btn:active { opacity: .85; }
.btn:disabled { opacity: .45; cursor: default; }

.btn-secondary {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn-row { margin-top: 14px; }

.link-row {
  margin-top: 22px;
  text-align: center;
  font-size: 15px;
}

/* ---------- チャット ---------- */
.chat {
  padding: 16px 14px 240px;
  max-width: 720px;
  margin: 0 auto;
}

.msg { margin-bottom: 18px; display: flex; flex-direction: column; }
.msg .who { font-size: 12px; color: var(--ink-soft); margin-bottom: 4px; }
.msg .bubble {
  border-radius: var(--radius);
  padding: 13px 15px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.msg.assistant .bubble {
  background: var(--surface);
  border: 1px solid var(--line);
  align-self: flex-start;
  max-width: 92%;
}
.msg.user { align-items: flex-end; }
.msg.user .who { text-align: right; }
.msg.user .bubble {
  background: var(--accent-soft);
  border: 1px solid #cfe0d8;
  max-width: 88%;
}

.typing { color: var(--ink-soft); font-size: 14px; padding: 4px 2px 0; }

/* クイックリプライ */
.quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.quick button {
  min-height: 46px;
  padding: 10px 16px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
}
.quick button:active { background: var(--accent-soft); }

/* ---------- 入力欄 ---------- */
.composer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
}
.composer-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.composer textarea {
  flex: 1;
  min-height: 52px;
  max-height: 168px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 17px;
  font-family: inherit;
  line-height: 1.6;
  resize: none;
  overflow-y: auto;
  background: #fff;
  color: var(--ink);
}
.composer textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.composer .send {
  min-width: 78px;
  min-height: 52px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.composer .send:disabled { opacity: .45; cursor: default; }
.composer .hint { font-size: 12px; color: var(--ink-soft); margin: 6px 2px 0; }

.finish-bar {
  max-width: 720px;
  margin: 0 auto 10px;
}

.composer-foot {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.quit-link {
  border: 0;
  background: none;
  padding: 6px 2px 0;
  color: var(--ink-soft);
  font-size: 13px;
  font-family: inherit;
  text-decoration: underline;
  cursor: pointer;
  white-space: nowrap;
}
.quit-link:disabled { opacity: .45; cursor: default; }
.quit-confirm {
  max-width: 720px;
  margin: 10px auto 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.quit-confirm p { font-size: 15px; margin-bottom: 10px; }
.quit-actions { display: flex; gap: 10px; }
.quit-actions .btn { min-height: 48px; font-size: 16px; }

.error-box {
  background: #fdecec;
  border: 1px solid #f0c2c2;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 12px 0;
  font-size: 15px;
}

/* ---------- レポート ---------- */
.meta-list { list-style: none; padding: 0; margin: 0; }
.meta-list li { display: flex; gap: 10px; font-size: 15px; }
.meta-list .k { color: var(--ink-soft); min-width: 6.5em; }

.insight-group { margin-bottom: 18px; }
.insight-group h3 { margin: 0 0 6px; font-size: 16px; }

.log-entry {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}
.log-entry:first-child { border-top: 0; }
.log-entry .head {
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.log-entry .body { white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
.log-entry.user .body { color: var(--ink); font-weight: 500; }

.closing-note {
  margin-top: 28px;
  padding: 16px;
  background: var(--accent-soft);
  border-radius: var(--radius);
  font-size: 16px;
  text-align: center;
}

/* ---------- 透明性ページ ---------- */
.prose { overflow-wrap: anywhere; }
.prose strong { font-weight: 600; }
.codeblock {
  background: #23282a;
  color: #e9e6df;
  border-radius: var(--radius);
  padding: 14px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
  -webkit-text-size-adjust: 100%;
}
.codeblock code { white-space: pre; }

.footer {
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-soft);
  text-align: center;
}

/* ---------- 公開ダッシュボード ---------- */
.bar-row { margin-bottom: 14px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 15px;
  margin-bottom: 5px;
}
.bar-count { color: var(--ink-soft); font-size: 13px; font-variant-numeric: tabular-nums; }
.bar-track {
  height: 10px;
  border-radius: 999px;
  background: #ece8e0;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #9fd3c1 0%, #4f9a84 55%, var(--accent-dark) 100%);
  transform-origin: left center;
  animation: bar-grow .9s cubic-bezier(.22, .8, .3, 1) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}
@keyframes bar-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) { .bar-fill, .day-fill { animation: none; } }

/* 個票：テーマごとに色を変えて見分けやすくする */
.theme-block {
  margin: 0 0 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border-left: 5px solid var(--theme-line);
  background: var(--theme-bg);
}
.theme-block h3 { margin: 0 0 6px; font-size: 16px; color: var(--theme-ink); }
.theme-block p { margin: 0; }
.theme-block ul { margin: 0; padding-left: 1.2em; }
.theme-0 { --theme-bg: #eaf3ee; --theme-line: #4f9a84; --theme-ink: #245a4c; }
.theme-1 { --theme-bg: #fbf1e1; --theme-line: #d9a04a; --theme-ink: #7a5212; }
.theme-2 { --theme-bg: #eaf0f8; --theme-line: #5b84bf; --theme-ink: #2c4a77; }
.theme-3 { --theme-bg: #f8ecef; --theme-line: #c9707f; --theme-ink: #7d3341; }

.chip-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 6px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  font-size: 15px;
}
.chip-count {
  color: var(--ink-soft);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.word-list { list-style: none; padding: 0; margin: 0; }
.word-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  margin: 0;
}
.word-list li:first-child { border-top: 0; }
.word { font-size: 16px; }
.word-date { color: var(--ink-soft); font-size: 12px; white-space: nowrap; }

.voice {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}
.voice:first-child { border-top: 0; }
.voice-head { font-size: 12px; color: var(--ink-soft); margin-bottom: 3px; }
.voice-body { font-size: 15px; }

/* ---------- 運営（首長側）画面 ---------- */
/* 住民向けとは別の見え方にして、取り違えないようにする */
.admin { --line2: #d8d3c9; }
.admin .wrap.wide { max-width: 1180px; }

.admin-nav {
  background: #22282a;
  color: #e9e6df;
}
.admin-nav .wrap {
  display: flex;
  gap: 20px;
  padding: 10px 18px;
  max-width: 1180px;
}
.admin-nav a { color: #cfe0d8; font-size: 14px; text-decoration: none; }
.admin-nav a:hover { text-decoration: underline; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.kpi-label { font-size: 12px; color: var(--ink-soft); margin-bottom: 4px; }
.kpi-value { font-size: 28px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-value.ok { color: #2f7a4f; }
.kpi-value.info { color: #2a5f9e; }
.kpi-value.warn { color: #9a6a1f; }
.kpi-value.accent { color: #6b4a9a; }
.kpi-sub { font-size: 13px; color: var(--ink-soft); margin-bottom: 24px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 15px;
}
.panel-action { font-size: 13px; font-weight: 400; }
.panel-body { padding: 16px; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--surface);
}
.data-table th, .data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}
.data-table thead th {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 600;
  background: var(--bg);
}
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.data-table .strong { font-weight: 600; }
.data-table .sub { font-size: 12px; color: var(--ink-soft); }
.data-table td.ok, .data-table .num.ok { color: #2f7a4f; }
.data-table td.info, .data-table .num.info { color: #2a5f9e; }
.data-table td.warn, .data-table .num.warn { color: #9a6a1f; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
}
.badge.ok { background: #e4f1e8; color: #2f7a4f; }
.badge.info { background: #e4ecf6; color: #2a5f9e; }
.badge.warn { background: #f6eddc; color: #9a6a1f; }

/* 分析レポート */
.headline-box {
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 8px;
}
.headline { font-size: 19px; font-weight: 700; line-height: 1.6; margin: 0 0 10px; }
.overview { margin: 0; }

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.tag.sev-高 { background: #f7e0e0; color: #a33; }
.tag.sev-中 { background: #f6eddc; color: #8a6318; }
.tag.sev-低 { background: #e9e7e1; color: #5c6569; }
.tag.horizon { background: #e4ecf6; color: #2a5f9e; }

.issue {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.issue-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}
.issue-head h3 { margin: 0; font-size: 17px; }
.issue .chip-list { margin-top: 10px; }
.chip-cat { background: var(--accent-soft); border-color: #cfe0d8; }

.evidence {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.evidence-label { font-size: 12px; color: var(--ink-soft); margin-bottom: 6px; }
.evidence blockquote {
  margin: 0 0 8px;
  padding-left: 12px;
  border-left: 3px solid var(--accent-soft);
  font-size: 15px;
}

.issue-brief { list-style: none; padding: 0; margin: 12px 0 0; }
.issue-brief li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
}
.issue-brief li:first-child { border-top: 0; }
.issue-title { font-weight: 600; }

.tension {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.tension h3 { margin: 0 0 10px; font-size: 16px; }
.tension-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tension .side { background: var(--bg); border-radius: 8px; padding: 12px; }
.tension .side-label { font-size: 12px; color: var(--ink-soft); margin-bottom: 4px; }
.tension .side p { margin: 0; font-size: 15px; }
.tension-note { margin: 12px 0 0; font-size: 14px; color: var(--ink-soft); }

.signal { padding: 10px 0; border-top: 1px solid var(--line); }
.signal:first-child { border-top: 0; }
.signal-text { margin: 0 0 3px; font-size: 15px; }

/* ヒートマップ */
.data-table.heat td.cell {
  text-align: center;
  font-variant-numeric: tabular-nums;
  min-width: 44px;
}
.data-table.heat th.rot { font-size: 11px; white-space: normal; max-width: 76px; }
.heat .lv0 { background: transparent; color: transparent; }
.heat .lv1 { background: #eaf1ed; }
.heat .lv2 { background: #cfe0d8; }
.heat .lv3 { background: #9fc3b3; }
.heat .lv4 { background: #6da58e; color: #fff; }

.cat-row { padding: 10px 0; border-top: 1px solid var(--line); }
.cat-row:first-child { border-top: 0; }
.cat-head { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; margin-bottom: 5px; }
.cat-places { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cat-places .chip { font-size: 13px; padding: 3px 10px; }

.day-row { display: flex; align-items: center; gap: 10px; padding: 3px 0; font-size: 13px; }
.day-label { min-width: 8.5em; color: var(--ink-soft); }
.day-bar { flex: 1; height: 8px; background: #ece8e0; border-radius: 999px; overflow: hidden; }
.day-fill { display: block; height: 100%; background: linear-gradient(90deg, #9fd3c1, var(--accent)); transform-origin: left center; animation: bar-grow .9s cubic-bezier(.22, .8, .3, 1) both; animation-delay: calc(var(--i, 0) * 40ms); }
.day-count { min-width: 2em; text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .tension-sides { grid-template-columns: 1fr; }
}

/* ---------- トップ：お題の選択 ---------- */
.topic-card .topic-label {
  font-size: 19px;
  max-width: 720px;
  margin: 0 auto 6px;
  padding: 0;
  border: 0;
}
.topic-card .topic-desc {
  color: var(--ink-soft);
  font-size: 15px;
  margin-bottom: 14px;
}
.topic-card .topic-status { font-size: 15px; margin-bottom: 10px; }
.topic-card .error-box { margin-top: 12px; }

/* ---------- ダッシュボード：お題の切り替え ---------- */
.topic-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}
.topic-tabs li { margin: 0; }
.topic-tabs a {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-size: 15px;
  text-decoration: none;
  background: var(--surface);
}
.topic-tabs a[aria-current="page"] {
  background: var(--accent);
  color: #fff;
}

/* 運営ダッシュボードの分析サマリー */
.brief-headline {
  background: linear-gradient(135deg, #eaf3ee 0%, #f3f7f4 100%);
  border-left: 5px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.brief-label { font-size: 12px; font-weight: 700; color: var(--accent); letter-spacing: .08em; }
.brief-headline .headline { margin: 4px 0 6px; }
.brief-meta { font-size: 13px; color: var(--ink-soft); }
.brief-legend {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px;
  margin: 18px 0 6px; font-size: 13px; color: var(--ink-soft);
}
.brief-legend > span:first-child { font-weight: 700; color: var(--ink); }
.brief-legend .tag { padding: 0 6px; margin-right: 2px; }
.issue-rank { list-style: none; padding: 0; margin: 0; }
.issue-rank li {
  display: flex; gap: 14px; align-items: center;
  padding: 12px 12px 12px 10px;
  border-top: 1px solid var(--line);
  border-left: 4px solid transparent;
}
.issue-rank li:first-child { border-top: 0; }
.issue-rank li.sev-line-高 { border-left-color: #d98a8a; }
.issue-rank li.sev-line-中 { border-left-color: #e3bf7a; }
.issue-rank li.sev-line-低 { border-left-color: #c9c5bb; }
.rank-no {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-dark);
  font-weight: 700; font-size: 15px;
}
.issue-rank li:nth-child(-n+3) .rank-no { background: var(--accent); color: #fff; }
.rank-main { flex: 1; min-width: 0; }
.rank-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 10px; }
.rank-tags { display: flex; gap: 6px; }
.rank-bar { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.rank-bar .bar-track { flex: 1; }
.rank-count { flex: none; min-width: 3.2em; text-align: right; font-size: 13px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.rank-count b { font-size: 17px; color: var(--ink); }

/* 入力欄の上の個人情報の注意書き */
.privacy-note {
  max-width: 720px;
  margin: 0 auto 6px;
  font-size: 13px;
  line-height: 1.5;
  color: #8a6318;
}
