:root {
  --bg: #f4f6f9; --panel: #ffffff; --ink: #1b2430; --muted: #5d6b7c; --line: #dde3ea;
  --sea: #dfeaf5; --land: #f7f5ef; --coast: #8c9aa8; --accent: #1f6feb;
  --major: #9b1fe8; --warn: #e8261c; --adv: #f2d600; --fc: #2fa7e8;
  --shadow: 0 1px 2px rgba(20,30,50,.06), 0 4px 16px rgba(20,30,50,.06);
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f141b; --panel: #161d26; --ink: #e6edf5; --muted: #9aa8b8; --line: #263241;
    --sea: #12263a; --land: #2a3138; --coast: #6d7d8e; --accent: #4c9bff; --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
/* 想定の計算の画面: 見出しが折り返して高くなっても地図と表が画面からはみ出さないよう、縦に並べて残りを .layout に渡す
   (style.css は「いまの地震・津波」と本人用のページも使うので、この画面だけに付ける) */
body.scenario { display: flex; flex-direction: column; }
.top { display: flex; gap: 16px; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand h1 { margin: 0; font-size: 19px; letter-spacing: .02em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.note-chip { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; white-space: nowrap; }
.layout { display: grid; grid-template-columns: 1fr 420px; flex: 1; min-height: 0; }
.mapwrap { position: relative; overflow: hidden; min-height: 0; }
.zoom { position: absolute; left: 12px; top: 12px; display: flex; flex-direction: column; gap: 4px; }
.zoom button { min-width: 40px; min-height: 40px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); font-size: 16px; cursor: pointer; box-shadow: var(--shadow); }
.zoom button#zreset { font-size: 12px; }
.zoom button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
td.nw { white-space: nowrap; }
.legend-toggle { display: none; position: absolute; right: 8px; top: 8px; min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); font-size: 13px; box-shadow: var(--shadow); cursor: pointer; }
.legend-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.kv .note { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.5; margin-top: 2px; }
#map { width: 100%; height: 100%; display: block; cursor: crosshair; background: var(--sea); }
.map-hint { position: absolute; left: 12px; bottom: 10px; font-size: 12px; color: var(--muted); background: color-mix(in srgb, var(--panel) 85%, transparent); padding: 4px 8px; border-radius: 6px; }
.map-legend { position: absolute; right: 12px; top: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 12px; box-shadow: var(--shadow); min-width: 150px; }
.map-legend h4 { margin: 0 0 6px; font-size: 12px; }
.map-legend .it { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
.map-legend .sw { width: 22px; height: 10px; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); }
/* 揺れの点の種類: 10 km 格子 (四角) と気象庁の震度観測点 (縁取りした丸) */
.map-legend .sw.sq { width: 10px; height: 10px; border-radius: 0; background: var(--muted); }
.map-legend .sw.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); border-color: rgba(0,0,0,.6); }
.map-legend label.lay { cursor: pointer; min-height: 32px; margin-top: 4px; }
.map-legend label.lay input { width: 18px; height: 18px; margin: 0; }
@media (pointer: coarse) { .map-legend label.lay { min-height: 44px; } }
#stations caption { text-align: left; font-size: 12px; color: var(--muted); padding: 2px 0 6px; }
.tooltip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow); max-width: 300px; line-height: 1.5; }
.panel { overflow-y: auto; border-left: 1px solid var(--line); background: var(--panel); padding: 14px 16px 40px; }
.controls .row { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 4px 10px; margin-bottom: 10px; }
.controls label { font-size: 13px; color: var(--muted); }
.controls .help { grid-column: 2; color: var(--muted); font-size: 11px; }
.pair { display: grid; grid-template-columns: 1fr 92px; gap: 8px; align-items: center; }
input[type=number] { width: 100%; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font-size: 14px; font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.epi output { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); display: block; margin-top: 4px; }
.epi-in { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.segmented button { border: 0; background: transparent; color: var(--ink); padding: 7px 12px; font-size: 13px; cursor: pointer; min-height: 34px; }
.segmented button.on { background: var(--accent); color: #fff; }
.segmented button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.status { font-size: 12px; color: var(--muted); margin: 4px 0 12px; min-height: 18px; }
.status.err { color: var(--warn); }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.card { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.card .k { font-size: 11.5px; color: var(--muted); }
.card .v { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.card .v.v-sm { font-size: 17px; }
.card .s { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.shindo-chip { display: inline-block; min-width: 46px; text-align: center; padding: 2px 8px; border-radius: 6px; font-weight: 800; }
.bulletin h3 { font-size: 14px; margin: 14px 0 6px; display: flex; align-items: center; gap: 8px; }
.bulletin h3 .bar { width: 6px; height: 18px; border-radius: 3px; }
.bulletin .first { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.bulletin table, #stations table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.bulletin td, .bulletin th, #stations td, #stations th { padding: 5px 4px; border-bottom: 1px solid var(--line); text-align: left; font-variant-numeric: tabular-nums; }
.bulletin th, #stations th { color: var(--muted); font-weight: 500; font-size: 11.5px; }
.bulletin .none { color: var(--muted); font-size: 13px; padding: 6px 0; }
td.num, th.num { text-align: right; }
.box { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-top: 12px; }
.box summary { cursor: pointer; font-size: 13.5px; font-weight: 600; padding: 4px 0; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 3px 10px; font-size: 12.5px; margin: 6px 0; }
.kv div:nth-child(odd) { color: var(--muted); }
.limits { font-size: 12px; color: var(--muted); padding-left: 18px; line-height: 1.6; }
.flag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line); color: var(--muted); margin-left: 4px; }
@media (max-width: 900px) {
  body.scenario { display: block; }
  .layout { grid-template-columns: 1fr; height: auto; }
  .mapwrap { height: 60vh; min-height: 320px; }
  .panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .note-chip { display: none; }
}
@media (max-width: 600px) {
  .scenario .top { padding: 10px 12px; }
  .scenario .brand p { font-size: 11.5px; }
  /* 凡例は地図の大事な所 (震央) を覆うので、ボタンで開閉する */
  .legend-toggle { display: block; }
  .map-legend { display: none; padding: 6px 8px; font-size: 11px; min-width: 0; right: 8px; top: 54px; }
  .map-legend.open { display: block; }
  .map-legend .it { margin: 1px 0; gap: 6px; }
  .map-legend .sw { width: 16px; height: 9px; }
  .map-hint { left: 8px; right: 8px; bottom: 8px; font-size: 11px; }
  .panel { padding: 12px 12px 32px; }
  .controls .row { grid-template-columns: 84px 1fr; }
  .pair { grid-template-columns: 1fr 84px; }
  .cards { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 104px 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* app.js が style 属性の代わりに使う (CSP で style 属性は効かない) */
/* .map-legend h4 と .bulletin .first の margin より強くするため、置き場所ごとに書く */
.map-legend h4.mt8, .bulletin .first.mt8 { margin-top: 8px; }
small.muted { color: var(--muted); }
