:root {
  --navy: #16324f;
  --navy-deep: #0e2338;
  --sky: #2f9fe0;
  --ok: #1e88e5;
  --ng: #e0453a;
  --amber: #f2a03d;
  --paper: #f5f8fa;
  --card: #ffffff;
  --ink: #1b2a3a;
  --ink-soft: #5a6b7c;
  --line: #dde6ec;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(14, 35, 56, .08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
main { max-width: 720px; margin: 0 auto; padding: 0 16px 48px; }

/* ===== ヘッダー ===== */
.site-head {
  display: flex; align-items: baseline; gap: 10px;
  padding: 14px 16px 10px;
  max-width: 720px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--navy); }
.brand-mark { width: 30px; height: 30px; }
.brand-name { font-size: 22px; font-weight: 800; letter-spacing: .04em; }
.brand-tag { margin: 0; font-size: 12px; color: var(--ink-soft); font-weight: 600; }

/* ===== ヒーロー ===== */
.hero { text-align: center; padding: 20px 0 8px; }
.hero h1 {
  font-size: clamp(28px, 7.5vw, 40px);
  font-weight: 800; line-height: 1.3; margin: 8px 0 16px;
  color: var(--navy);
}
.hero h1 em { font-style: normal; color: var(--ng); }
.hero-fact {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px; font-size: 15px; margin: 0 0 14px;
}
.hero-fact .alert { color: var(--ng); font-size: 18px; }
.hero-lead { font-size: 14px; color: var(--ink-soft); margin: 0 0 22px; }

.search { display: flex; gap: 8px; margin-bottom: 10px; }
.search input {
  flex: 1; min-width: 0;
  font-size: 16px; padding: 13px 14px;
  border: 2px solid var(--navy); border-radius: 12px;
  background: #fff; color: var(--ink);
}
.search input:focus { outline: 3px solid rgba(47, 159, 224, .35); }
.search-msg { min-height: 1.4em; font-size: 13px; color: var(--ng); font-weight: 600; margin: 6px 0 0; }
.cand-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }

.btn {
  font-size: 15px; font-weight: 700; font-family: inherit;
  padding: 12px 18px; border-radius: 12px; border: none; cursor: pointer;
  text-decoration: none; display: inline-block;
  transition: transform .08s ease, box-shadow .08s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--navy); color: #fff; box-shadow: var(--shadow); }
.btn-ghost { background: transparent; color: var(--navy); border: 1.5px solid var(--line); background: #fff; }
.btn-sm { font-size: 13px; padding: 8px 12px; }
.btn-wide { width: 100%; }

.steps {
  list-style: none; display: flex; gap: 8px; justify-content: center;
  padding: 0; margin: 28px 0 0; flex-wrap: wrap;
}
.steps li {
  flex: 1; min-width: 130px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 10px; font-size: 12.5px; color: var(--ink-soft);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.steps b {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--sky); color: #fff; font-size: 14px;
  display: grid; place-items: center;
}

/* ===== 結果 ===== */
.result-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin: 14px 0 10px;
}
.result-head h2 { font-size: 18px; margin: 0; color: var(--navy); word-break: break-all; }

.hazard-tabs {
  display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.hazard-tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; font-size: 13.5px; font-weight: 700; font-family: inherit;
  padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--line);
  background: #fff; color: var(--ink-soft); cursor: pointer; white-space: nowrap;
}
.tab.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }

.map {
  height: 46vh; min-height: 300px;
  border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.map-legend {
  display: flex; gap: 14px; flex-wrap: wrap;
  font-size: 12px; color: var(--ink-soft);
  padding: 8px 4px 0;
}
.map-legend .dot {
  display: inline-block; width: 11px; height: 11px; border-radius: 50%;
  margin-right: 4px; border: 2px solid #fff; box-shadow: 0 0 2px rgba(0,0,0,.4);
  vertical-align: -1px;
}
.map-legend .dot.ok { background: var(--ok); }
.map-legend .dot.ng { background: var(--ng); }
.map-legend .swatch {
  display: inline-block; width: 11px; height: 11px;
  background: rgba(255, 145, 145, .85); margin-right: 4px; vertical-align: -1px;
}

/* ===== 浸水深パネル ===== */
.depth-panel {
  display: flex; gap: 14px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; margin-top: 14px;
}
.depth-visual { flex: 0 0 96px; }
.depth-visual svg { width: 96px; height: auto; display: block; }
.depth-text h3 { margin: 0 0 4px; font-size: 16px; color: var(--navy); }
.depth-text p { margin: 0; font-size: 13.5px; }
.depth-note { color: var(--ink-soft); font-size: 11px !important; margin-top: 6px !important; }
.depth-wide {
  background: #fff7ec; border: 1px solid #f4ddbd; border-radius: 8px;
  padding: 8px 10px; color: #7a5a2e;
  font-size: 12px !important; margin-top: 8px !important;
}
.depth-panel.is-danger h3 { color: var(--ng); }

/* ===== 避難場所リスト ===== */
.list-head h3 { font-size: 16px; color: var(--navy); margin: 22px 0 4px; }
.list-head small { font-weight: 400; color: var(--ink-soft); }
.list-caution { font-size: 12px; color: var(--ink-soft); margin: 0 0 10px; }
.shelter-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.shelter {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 14px;
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px;
  cursor: pointer;
}
.shelter.is-ng { border-left: 4px solid var(--ng); }
.shelter.is-ok { border-left: 4px solid var(--ok); }
.shelter.is-best { border: 2px solid var(--ok); border-left-width: 4px; }
.shelter.is-note { border-left: 4px solid var(--amber); background: #fffaf1; cursor: default; }
.shelter-best {
  grid-column: 1 / -1;
  font-size: 12px; font-weight: 800; color: var(--ok);
  background: rgba(30, 136, 229, .08);
  border-radius: 6px; padding: 3px 8px; justify-self: start;
}
.shelter-name { font-weight: 700; font-size: 15px; }
.shelter-dist { font-size: 13px; color: var(--ink-soft); text-align: right; white-space: nowrap; }
.shelter-muni { grid-column: 1; font-size: 11.5px; color: var(--ink-soft); }
.shelter-muni b { color: var(--sky); font-weight: 800; }
.shelter-verdict { font-size: 13px; font-weight: 700; grid-column: 1 / -1; }
.shelter.is-ok .shelter-verdict { color: var(--ok); }
.shelter.is-ng .shelter-verdict { color: var(--ng); }
.shelter-flags { grid-column: 1 / -1; font-size: 11.5px; color: var(--ink-soft); }
.shelter-actions { grid-column: 1 / -1; margin-top: 6px; }
.shelter-actions .btn { font-size: 12.5px; padding: 7px 12px; margin-right: 6px; }

/* ===== プランナー ===== */
.planner-lead { font-size: 15px; }
.planner-warn {
  background: rgba(224, 69, 58, .07); border: 1.5px solid rgba(224, 69, 58, .4);
  border-radius: 10px; padding: 10px 12px;
  color: var(--ng); font-size: 13.5px; font-weight: 600;
}
.family {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); padding: 12px 14px; margin: 0 0 12px;
  display: flex; flex-wrap: wrap; gap: 6px 16px;
}
.family legend { font-size: 13px; font-weight: 700; color: var(--navy); padding: 0 4px; }
.family label { font-size: 14px; display: flex; align-items: center; gap: 6px; }
.family input { width: 18px; height: 18px; accent-color: var(--navy); }
.meet { display: block; font-size: 13px; font-weight: 700; color: var(--navy); margin: 0 0 14px; }
.meet input {
  display: block; width: 100%; margin-top: 6px;
  font-size: 15px; font-weight: 400; padding: 11px 12px;
  border: 1.5px solid var(--line); border-radius: 10px;
}

.card-wrap { margin-top: 18px; text-align: center; }
#cardCanvas {
  width: 100%; max-width: 420px; height: auto;
  border-radius: var(--radius); box-shadow: 0 6px 24px rgba(14, 35, 56, .18);
}
.card-actions { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
.card-hint { font-size: 12.5px; color: var(--ink-soft); }

.kit { margin-top: 22px; }
.kit h3 { font-size: 16px; color: var(--navy); margin: 0 0 8px; }
.kit ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.kit li { font-size: 13.5px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.kit li a { color: var(--sky); text-decoration: none; font-weight: 700; white-space: nowrap; }
.kit-note { font-size: 11.5px; color: var(--ink-soft); }

/* ===== フッター ===== */
.site-foot {
  max-width: 720px; margin: 0 auto; padding: 20px 16px 40px;
  border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-soft);
}
.disclaimer {
  background: #fff7ec; border: 1px solid #f4ddbd; border-radius: 10px;
  padding: 10px 12px; color: #7a5a2e;
}
.credits a { color: var(--sky); }

/* トースト */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(10px);
  background: var(--navy-deep); color: #fff;
  font-size: 13.5px; font-weight: 700;
  padding: 10px 18px; border-radius: 999px;
  box-shadow: 0 4px 16px rgba(14, 35, 56, .35);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 2000;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 状態切り替え */
body[data-state="result"] #hero,
body[data-state="planner"] #hero { display: none; }

@media (max-width: 480px) {
  .site-head { flex-direction: column; align-items: flex-start; gap: 0; padding-bottom: 6px; }
  .brand-tag { margin-left: 38px; margin-top: -2px; }
}
@media (max-width: 400px) {
  .kit ul { grid-template-columns: 1fr; }
  .depth-visual { flex-basis: 80px; }
}
