:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --ink: #1c2530;
  --muted: #5c6b7a;
  --border: #dbe1e8;
  --accent: #1b6ec2;
  --iso: #d7191c;
  --start: #f5a623;
  --warn-bg: #fff3f2;
  --warn-ink: #a01818;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

#sidebar {
  width: 380px;
  min-width: 380px;
  height: 100%;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 18px 18px 28px;
}

#map {
  flex: 1;
  height: 100%;
}

header h1 {
  font-size: 18px;
  margin: 0 0 4px;
}
.subtitle {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}
/* 何を根拠にしたナビなのかの補足（旧サブタイトル「道路寸断・孤立リスク解析」を含む）。 */
.app-desc {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

section { margin-bottom: 18px; }
h2 {
  font-size: 13px;
  text-transform: none;
  letter-spacing: .02em;
  margin: 0 0 8px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field span { font-size: 12px; color: var(--muted); }
select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
}

.buttons { display: flex; gap: 8px; }
button {
  flex: 1;
  padding: 9px 10px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
button.secondary {
  background: #fff;
  color: var(--muted);
  border-color: var(--border);
}
button:hover { filter: brightness(1.05); }

.hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; line-height: 1.6; }

.status { font-size: 13px; line-height: 1.6; }
.status .badge {
  display: inline-block;
  padding: 8px 10px;
  border-radius: 8px;
  width: 100%;
}
.status .ok { background: #eef6ee; color: #226b22; }
.status .warn { background: var(--warn-bg); color: var(--warn-ink); }
.status .info { background: #eef3fb; color: #1b4f8a; }
.status .loading { background: #f0f2f5; color: var(--muted); }

#candidate-list { list-style: none; margin: 0; padding: 0; }
.cand {
  border: 1px solid var(--border);
  border-left-width: 6px;
  border-radius: 8px;
  padding: 9px 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: box-shadow .12s, transform .12s;
}
.cand:hover, .cand.active {
  box-shadow: 0 2px 10px rgba(0,0,0,.12);
  transform: translateY(-1px);
}
.cand.selected {
  box-shadow: 0 3px 14px rgba(0,0,0,.2);
  outline: 2px solid rgba(0,0,0,.12);
}
.cand.faded { opacity: 0.45; }
.cand .cat-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  border-radius: 5px;
  padding: 1px 7px;
}
.cand .cand-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.cand .cand-id { font-weight: 700; font-size: 12px; margin-left: auto; }
.cand .cand-dest { font-size: 13px; font-weight: 600; margin-top: 5px; }
.cand .metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 6px;
  font-size: 12px;
}
.cand .metrics b { font-weight: 700; }

/* 候補の位置づけ（第1案／迂回路／別の避難場所）。危険度バッジとは別軸なので枠線で表す。 */
.cand .role-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  border-radius: 5px;
  padding: 1px 7px;
  border: 1px solid currentColor;
}
.cand .role-first { color: #1b4f8a; background: #eef3fb; }
.cand .role-detour { color: #7a5a12; background: #fdf6e6; }
.cand .role-alt { color: #4a5a6a; background: #f1f4f7; }

/* 「〇〇が通れない場合の迂回路（+565m ／ 通常 +8分）」の1行。 */
.cand .detour {
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.5;
  color: #7a5a12;
  background: #fdf6e6;
  border-radius: 6px;
  padding: 5px 8px;
}

/* 初期化に失敗したときだけ出る全画面の警告（通常は display:none）。 */
#fatal-error {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 9999;
  background: var(--warn-bg);
  color: var(--warn-ink);
  border-bottom: 3px solid var(--iso);
  padding: 14px 18px;
  font-size: 13px;
  line-height: 1.7;
}
#fatal-error .fe-msg {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  margin: 6px 0;
  overflow-wrap: anywhere;
}
#fatal-error .fe-act { font-size: 12px; }
#fatal-error button {
  margin-left: 8px;
  padding: 5px 10px;
  border: 1px solid var(--iso);
  background: #fff;
  color: var(--warn-ink);
  border-radius: 6px;
  cursor: pointer;
  flex: none;
}

/* 免責。避難判断を誤らせないため折りたたまず常時表示する。 */
.disclaimer {
  font-size: 11.5px;
  line-height: 1.6;
  background: #fff8e6;
  border: 1px solid #e8cf90;
  border-left: 4px solid #d99a1c;
  border-radius: 8px;
  padding: 8px 10px;
  margin: 0 0 12px;
  color: #6b4d0c;
}
.disclaimer a { color: var(--accent); }

/* 背景レイヤの切り替え。 */
.toggles { list-style: none; margin: 0; padding: 0; }
.toggles li { margin-bottom: 9px; }
.toggles .toggle { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.toggles .toggle.na { opacity: .55; }
.toggles .tg-name { font-weight: 600; }
.toggles .tg-note {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
  margin: 2px 0 0 22px;
}
.toggles .tg-attr { display: block; }
.toggles .tg-na { display: block; color: var(--warn-ink); }

/* 公式情報リンクと使用データ一覧。 */
.links { list-style: none; margin: 0 0 8px; padding: 0; font-size: 12px; }
.links li { margin-bottom: 4px; line-height: 1.5; }
.links a { color: var(--accent); }
.datasource-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 10px;
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
}
.datasource-list dt { color: var(--muted); }
.datasource-list dd { margin: 0; overflow-wrap: anywhere; }

/* 通信状態。災害時は「今つながっているか」が判断に直結するので常時表示する。 */
.net-status {
  font-size: 12px;
  line-height: 1.5;
  border-radius: 8px;
  padding: 7px 10px;
  margin-bottom: 12px;
}
.net-status .dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
}
.net-status.on { background: #eef6ee; color: #226b22; }
.net-status.on .dot { background: #2e9e3f; }
.net-status.off { background: var(--warn-bg); color: var(--warn-ink); }
.net-status.off .dot { background: var(--iso); }

/* オフライン準備（保存状況とタイル取得）。 */
.offline-state {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 10px;
  margin: 0 0 10px;
  font-size: 12px;
}
.offline-state dt { color: var(--muted); }
.offline-state dd { margin: 0; font-weight: 600; }
.tile-progress { font-size: 12px; color: var(--muted); margin: 8px 0 0; min-height: 1.2em; }
.zone-sediment { background: #e0a24a; opacity: .8; }

/* 危険区域への進入時刻（避難中の時間経過）。進入が遅い候補は赤系で注意を促す。 */
.cand .hazard-time {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.5;
  border-radius: 6px;
  padding: 6px 8px;
  background: #fff6ea;
  color: #7a4a12;
  border-left: 3px solid #f08c00;
}
.cand .hazard-time.late {
  background: var(--warn-bg);
  color: var(--warn-ink);
  border-left-color: var(--iso);
}
.cand .hazard-time .ht-head b { font-size: 13px; }
.cand .hazard-time .ht-note { margin-top: 3px; }
.cand .hazard-time .ht-basis { margin-top: 3px; font-size: 10px; opacity: .8; }

/* 歩行速度セレクタ（自動車のときは無効）。 */
.field.disabled { opacity: .45; }
.field.disabled select { cursor: not-allowed; }

/* アルゴリズム名・内部パラメータの置き場（消さずに隠す）。 */
.cand details.tech { margin-top: 6px; }
.cand details.tech summary {
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  list-style: revert;
}
.cand details.tech dl {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--muted);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 8px;
  line-height: 1.5;
}
.cand details.tech dt { font-weight: 600; }
.cand details.tech dd { margin: 0; overflow-wrap: anywhere; }

/* 差が小さい候補のまとめ（既定は閉じる。開くと地図の線も通常の濃さに戻る）。 */
.minor-wrap { list-style: none; margin-bottom: 8px; }
.minor-wrap > details > summary {
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  padding: 6px 2px;
}
.minor-wrap .minor-list { list-style: none; margin: 4px 0 0; padding: 0; }
.minor-wrap .hint { margin: 0 0 6px; }
.cand .cand-warn {
  margin-top: 6px;
  font-size: 12px;
  background: var(--warn-bg);
  color: var(--warn-ink);
  border-radius: 6px;
  padding: 6px 8px;
  line-height: 1.5;
}

.legend ul { list-style: none; margin: 0; padding: 0; font-size: 12px; }
.legend li { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; line-height: 1.4; }
.swatch { flex: 0 0 auto; width: 18px; height: 12px; border-radius: 3px; display: inline-block; }
.line-route { height: 6px; border-radius: 3px; box-shadow: 0 0 0 1.5px #22303f; }
.line-route.safe { background: #2e9e3f; }
.line-route.caution { background: #f08c00; }
.line-route.warn { background: #d7191c; }
.line-iso { background: var(--iso); height: 5px; opacity: 0.5; }
.road-major { background: #4e5a67; height: 5px; border-radius: 3px; }
.road-second { background: #6f7b88; height: 3.5px; border-radius: 2px; }
.road-minor { background: #8b95a2; height: 2.5px; border-radius: 2px; }
.road-foot {
  height: 2px; border-radius: 1px;
  background: repeating-linear-gradient(90deg, #a3acb8 0 3px, transparent 3px 6px);
}
.dot-shelter-on { width: 12px; height: 12px; border-radius: 50%; background: #2e7d32; }
.dot-shelter-off { width: 12px; height: 12px; border-radius: 50%; background: #b9c2cc; }
.dot-start { width: 12px; height: 12px; border-radius: 50%; background: var(--start); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--start); }

.notes { font-size: 11px; color: var(--muted); line-height: 1.6; border-top: 1px solid var(--border); padding-top: 10px; }
.notes p { margin: 0 0 6px; }
.notes a { color: var(--accent); }

@media (max-width: 720px) {
  #app { flex-direction: column; }
  #sidebar { width: 100%; min-width: 0; height: auto; max-height: 45vh; }
  #map { height: 55vh; }
}

/* 河川（増水時の危険箇所として重要な目印）。 */
.line-river { background: #5b9bd5; height: 4px; border-radius: 2px; opacity: .8; }
.zone-sea { background: #a9d3ea; }

/* 気象庁の警報バナー。災害時の判断に直結するので、免責の直下に常時表示する。 */
.jma-alert {
  font-size: 12px;
  line-height: 1.6;
  border-radius: 8px;
  padding: 8px 10px;
  margin: 0 0 10px;
}
.jma-alert.calm { background: #eef6ee; color: #226b22; }
.jma-alert.warn { background: #fff6ea; color: #7a4a12; border-left: 4px solid #f08c00; }
.jma-alert.severe { background: var(--warn-bg); color: var(--warn-ink); border-left: 4px solid var(--iso); }
.jma-alert ul { margin: 5px 0 0; padding-left: 1.2em; }
.jma-alert li { margin-bottom: 2px; }
/* 取得からの経過時間。古い情報を最新のように見せないため必ず添える。 */
.jma-age { font-size: 11px; opacity: .85; }
.jma-age.old { color: var(--warn-ink); font-weight: 700; opacity: 1; }
.jma-note { margin-top: 5px; font-size: 11px; }

/* 気象庁の観測・発表の詳細。 */
.w-block { margin-bottom: 12px; }
.w-block h3 {
  font-size: 12px; margin: 0 0 4px; color: var(--ink);
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.w-when { font-size: 10px; font-weight: 400; color: var(--muted); }
.w-head { font-size: 11px; color: var(--muted); margin: 0 0 5px; line-height: 1.5; }
.w-list { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; font-size: 11px; }
.w-list dt { color: var(--muted); }
.w-list dd { margin: 0; }
.w-rain { width: 100%; border-collapse: collapse; font-size: 11px; }
.w-rain th, .w-rain td { padding: 2px 4px; text-align: right; }
.w-rain thead th { color: var(--muted); font-weight: 400; border-bottom: 1px solid var(--border); }
.w-rain tbody th { text-align: left; font-weight: 600; }

/* 候補カードに出す「どの警報で評価を変えたか」。 */
.cand .cand-alert {
  margin-top: 6px; font-size: 12px; line-height: 1.5;
  background: var(--warn-bg); color: var(--warn-ink);
  border-left: 3px solid var(--iso); border-radius: 6px; padding: 6px 8px;
}
.cand .cand-alert .ca-src { margin-top: 3px; font-size: 10px; opacity: .9; }

/* 気象情報の時刻表示。発表時刻・取得時刻・観測時刻は意味も粒度も違うので、
   ラベル付きで並べて取り違えを防ぐ。 */
.w-times {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  margin: 0 0 6px;
  font-size: 11px;
}
.w-times dt { color: var(--muted); }
.w-times dd { margin: 0; font-weight: 600; }
.w-times dd.w-old { color: var(--warn-ink); }

/* 「発表時刻は内容変更時のみ更新」など、誤解を防ぐための注記。 */
.w-caveat {
  font-size: 10.5px;
  line-height: 1.6;
  color: #6b4d0c;
  background: #fff8e6;
  border-left: 3px solid #d99a1c;
  border-radius: 5px;
  padding: 5px 7px;
  margin: 0 0 6px;
}

/* 警報名の後ろに付ける状態（発表／継続 など）。 */
.w-status {
  display: inline-block;
  margin-left: 3px;
  padding: 0 4px;
  font-size: 10px;
  border-radius: 3px;
  background: #eef3fb;
  color: #1b4f8a;
}
/* 状態の意味の凡例。 */
.w-legend {
  font-size: 10px;
  line-height: 1.6;
  color: var(--muted);
  margin: 5px 0 0;
}

/* 降水ナウキャストのパネル。 */
.rain-when { font-size: 12px; margin: 6px 0 0; }
.rain-off {
  font-size: 11px; line-height: 1.6;
  background: var(--warn-bg); color: var(--warn-ink);
  border-left: 3px solid var(--iso); border-radius: 5px;
  padding: 6px 8px; margin: 6px 0 0;
}
/* 気象庁の降水強度の色階級。タイルの着色は気象庁側で、ここでは凡例を出すだけ。 */
.rain-legend {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 3px 8px; margin: 7px 0 0; font-size: 10px; color: var(--muted);
}
.rain-legend span { display: inline-flex; align-items: center; gap: 3px; }
.rain-legend i {
  width: 13px; height: 10px; border-radius: 2px;
  border: 1px solid rgba(0,0,0,.15);
}
.rain-legend .rain-unit { font-weight: 600; }

/* 案内文の中に差し込む小さなボタン（経路探索データの保存・再試行）。 */
.inline-btn {
  flex: none;
  margin-left: 6px;
  padding: 3px 9px;
  font-size: 11px;
  border-radius: 5px;
  border: 1px solid currentColor;
  background: #fff;
  color: inherit;
  cursor: pointer;
}
