/* ============================================================
   安住マップ — デザイントークン
   色・角丸・影・イージングはここだけで定義し、以降は var() で参照する。
   dark は「同じトークン名を差し替える」ことで表現し、テーマ分岐を
   コンポーネント側に持ち込まない。
   ============================================================ */

:root {
  color-scheme: light;

  --font: "Inter", "Noto Sans JP", system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", sans-serif;

  --bg: #eef1f5;
  --surface: rgba(255, 255, 255, 0.84);
  --surface-solid: #fff;
  --surface-2: #f4f6f9;

  --text: #0f172a;
  --muted: #64748b;
  --border: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.16);

  --accent: #0f766e;
  --accent-ink: #fff;
  --accent-soft: rgba(15, 118, 110, 0.12);

  --ok: #059669;
  --warn: #d97706;
  --danger: #dc2626;

  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 8px;

  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 12px 32px -12px rgba(15, 23, 42, 0.25);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.08);
  --blur: saturate(1.5) blur(18px);

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --fast: 140ms;
  --base: 240ms;

  --topbar-h: 56px;
  --panel-left-w: 360px;
  --panel-right-w: 380px;
  --gutter: 16px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1220;
    --surface: rgba(17, 24, 39, 0.82);
    --surface-solid: #111827;
    --surface-2: #1f2937;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --accent: #2dd4bf;
    --accent-ink: #052e2b;
    --accent-soft: rgba(45, 212, 191, 0.14);
    --ok: #34d399;
    --warn: #fbbf24;
    --danger: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px -14px rgba(0, 0, 0, 0.75);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220;
  --surface: rgba(17, 24, 39, 0.82);
  --surface-solid: #111827;
  --surface-2: #1f2937;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --accent: #2dd4bf;
  --accent-ink: #052e2b;
  --accent-soft: rgba(45, 212, 191, 0.14);
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px -14px rgba(0, 0, 0, 0.75);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* ============================================================
   ベース
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3,
p,
figure {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

a {
  color: var(--accent);
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-color: currentColor;
}

button {
  font: inherit;
  color: inherit;
}

svg {
  display: block;
  width: 100%;
  height: 100%;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::selection {
  background: var(--accent-soft);
}

.tabular,
.card-num,
.card-rank,
.legend-ends,
.md-value,
.tile-value,
.dist-value,
.chip-count,
.result-count {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* スクロール領域は共通の細いスクロールバーにする */
.scroll-y {
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.scroll-y::-webkit-scrollbar {
  width: 8px;
}

.scroll-y::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

/* ============================================================
   共通プリミティブ
   ============================================================ */

.glass {
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background var(--fast) var(--ease),
    color var(--fast) var(--ease),
    border-color var(--fast) var(--ease),
    transform var(--fast) var(--ease);
}

.pill:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.pill:active {
  transform: scale(0.97);
}

.pill[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 600;
}

.pill[aria-pressed="true"]:hover {
  background: color-mix(in srgb, var(--accent) 88%, var(--text));
}

.pill-preset {
  height: 34px;
  padding: 0 14px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  cursor: pointer;
  transition:
    background var(--fast) var(--ease),
    color var(--fast) var(--ease);
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.icon-btn:active {
  transform: scale(0.94);
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: transparent;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background var(--fast) var(--ease),
    border-color var(--fast) var(--ease);
}

.chip-btn:hover {
  background: var(--surface-2);
}

.chip-icon {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.chip-count {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.text-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--muted);
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.text-btn:hover {
  color: var(--text);
}

.badge {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition:
    transform var(--fast) var(--ease),
    filter var(--fast) var(--ease);
}

.btn-primary svg {
  width: 16px;
  height: 16px;
}

.btn-primary:hover {
  filter: brightness(1.06);
}

.btn-primary:active {
  transform: scale(0.985);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  text-decoration: none;
}

.btn-ghost:hover {
  background: var(--surface-2);
}

/* ============================================================
   地図（ヒーロー）
   ============================================================ */

.app-page {
  height: 100dvh;
  overflow: hidden;
}

.map {
  position: fixed;
  inset: 0;
  background: var(--bg);
}

/* ============================================================
   トップバー
   ============================================================ */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 var(--gutter);
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  text-decoration: none;
  flex: 0 0 auto;
}

.brand-mark {
  display: block;
  width: 26px;
  height: 26px;
  color: var(--accent);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-tagline {
  display: none;
  font-size: 10.5px;
  color: var(--muted);
}

@media (min-width: 1200px) {
  .brand-tagline {
    display: block;
  }
}

/* --- 検索 --- */

.search {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
}

.search-icon {
  position: absolute;
  left: calc(50% - min(420px, 40vw) / 2 + 12px);
  top: 50%;
  translate: 0 -50%;
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}

.search-input {
  width: min(420px, 40vw);
  height: 36px;
  padding: 0 12px 0 36px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-solid);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  transition:
    border-color var(--fast) var(--ease),
    box-shadow var(--fast) var(--ease);
}

.search-input::placeholder {
  color: var(--muted);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.search-list {
  position: absolute;
  top: calc(100% + 8px);
  width: min(420px, 40vw);
  max-height: 60dvh;
  overflow-y: auto;
  padding: 6px;
  border-radius: var(--radius);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 40;
}

.search-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.search-list li[aria-selected="true"],
.search-list li:hover {
  background: var(--accent-soft);
}

.opt-pref {
  margin-right: 6px;
  color: var(--muted);
  font-size: 11.5px;
}

.opt-name {
  font-weight: 600;
}

.opt-value {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* --- 右のアクション --- */

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.topbar-about {
  width: auto;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
}

/* 言語切り替え。狭い画面でも隠さない（英語圏の利用者が最初に探すため） */
.lang-btn {
  width: auto;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* --- 候補ポップオーバー --- */

.fav-popover {
  margin: 0;
  padding: 10px;
  width: min(320px, calc(100vw - 24px));
  max-height: 60dvh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-solid);
  box-shadow: var(--shadow);
  color: var(--text);
}

.fav-popover:popover-open {
  position: fixed;
  inset: auto var(--gutter) auto auto;
  top: calc(var(--topbar-h) + 8px);
}

.fav-popover::backdrop {
  background: transparent;
}

.fav-head {
  padding: 2px 6px 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.fav-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.fav-go {
  flex: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  text-align: left;
  cursor: pointer;
}

.fav-go:hover {
  background: var(--surface-2);
}

.fav-pref {
  margin-right: 6px;
  color: var(--muted);
  font-size: 11.5px;
}

.fav-name {
  font-weight: 600;
}

.fav-value {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.fav-remove {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.fav-remove:hover {
  background: var(--surface-2);
  color: var(--danger);
}

.fav-empty {
  padding: 12px 10px 14px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.7;
}

/* ============================================================
   浮かぶパネル
   ============================================================ */

.panel {
  position: fixed;
  top: calc(var(--topbar-h) + var(--gutter));
  bottom: var(--gutter);
  z-index: 20;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-left {
  left: var(--gutter);
  width: var(--panel-left-w);
}

.panel-right {
  right: var(--gutter);
  width: var(--panel-right-w);
}

.filter-form,
.results-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.filter-form::-webkit-scrollbar,
.results-body::-webkit-scrollbar,
.drawer-body::-webkit-scrollbar,
.sheet-pane::-webkit-scrollbar {
  width: 8px;
}

.filter-form::-webkit-scrollbar-thumb,
.results-body::-webkit-scrollbar-thumb,
.drawer-body::-webkit-scrollbar-thumb,
.sheet-pane::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

/* ============================================================
   フィルタフォーム
   ============================================================ */

.filter-form {
  padding: 16px;
}

.fsec + .fsec {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.fsec-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: none;
}

.fsec-title .text-btn {
  margin-left: auto;
}

.fsec-hint,
.fsec-note {
  margin-top: 8px;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--muted);
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pills-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.pills-seg {
  display: inline-flex;
  gap: 0;
  padding: 2px;
  margin-bottom: 6px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
}

.pills-seg .pill {
  height: 26px;
  border: 0;
  padding: 0 14px;
}

.pills-seg .pill[aria-pressed="true"] {
  box-shadow: var(--shadow-sm);
}

.frow + .frow {
  margin-top: 14px;
}

.frow-label {
  margin-bottom: 6px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
}

.select {
  width: 100%;
  height: 36px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-solid);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 15px center, right 10px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
  transition: border-color var(--fast) var(--ease);
}

.select:hover {
  border-color: var(--accent);
}

.pill-hazard .hz-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background var(--fast) var(--ease);
}

.pill-hazard[aria-pressed="true"] .hz-dot {
  background: var(--accent-ink);
}

.pill-hazard[aria-pressed="true"] .hz-dot[data-hz="flood"] {
  background: #60a5fa;
}

.pill-hazard[aria-pressed="true"] .hz-dot[data-hz="tsunami"] {
  background: #38bdf8;
}

.pill-hazard[aria-pressed="true"] .hz-dot[data-hz="sediment-flow"] {
  background: #f59e0b;
}

.pill-hazard[aria-pressed="true"] .hz-dot[data-hz="sediment-steep"] {
  background: #ef4444;
}

.ad-wrap {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.ad-slot {
  display: block;
  width: 100%;
}

.ad-slot-empty {
  min-height: 250px;
}

/* ============================================================
   結果一覧
   ============================================================ */

.results-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 14px 16px 10px;
  background: linear-gradient(to bottom, var(--surface) 72%, transparent);
  backdrop-filter: blur(6px);
}

.result-count {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.result-sort {
  margin-top: 1px;
  font-size: 11.5px;
  color: var(--muted);
}

.cards {
  padding: 0 10px 16px;
}

.card {
  position: relative;
  border-radius: var(--radius);
  transition:
    transform var(--fast) var(--ease),
    box-shadow var(--fast) var(--ease),
    background var(--fast) var(--ease);
}

.card + .card {
  margin-top: 2px;
}

.card-main {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  grid-template-areas:
    "rank id num"
    "rank bar bar"
    "rank pips pips";
  align-items: center;
  gap: 2px 10px;
  width: 100%;
  padding: 10px 34px 10px 8px;
  border: 0;
  border-radius: var(--radius);
  background: none;
  text-align: left;
  cursor: pointer;
}

.card-rank {
  grid-area: rank;
  align-self: start;
  padding-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  text-align: right;
}

.card-id {
  grid-area: id;
  min-width: 0;
}

.card-pref {
  margin-right: 6px;
  color: var(--muted);
  font-size: 11px;
}

.card-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.card-num {
  grid-area: num;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

.card-bar {
  grid-area: bar;
  display: block;
  height: 3px;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.card-bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width var(--base) var(--ease);
}

.pips {
  grid-area: pips;
  display: flex;
  gap: 4px;
  margin-top: 7px;
}

.pip {
  width: 14px;
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
}

.pip-ok {
  background: var(--ok);
}

.pip-warn {
  background: var(--warn);
}

.pip-danger {
  background: var(--danger);
}

.pip-none {
  background: var(--border-strong);
  opacity: 0.6;
}

.card:hover,
.card.is-hover {
  background: var(--surface-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.card.is-selected {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.star-btn {
  position: absolute;
  top: 6px;
  right: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 6px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  opacity: 0.55;
  transition:
    opacity var(--fast) var(--ease),
    color var(--fast) var(--ease),
    background var(--fast) var(--ease);
}

.card:hover .star-btn,
.star-btn:focus-visible {
  opacity: 1;
}

.star-btn:hover {
  background: var(--surface-solid);
  color: var(--warn);
}

.star-btn[aria-pressed="true"] {
  opacity: 1;
  color: var(--warn);
}

.card-skeleton {
  height: 74px;
  margin: 2px 0;
  border-radius: var(--radius);
  background: linear-gradient(
    100deg,
    var(--surface-2) 30%,
    color-mix(in srgb, var(--surface-2) 55%, var(--surface-solid)) 50%,
    var(--surface-2) 70%
  );
  background-size: 300% 100%;
  animation: shimmer 1.2s var(--ease) infinite;
}

@keyframes shimmer {
  from {
    background-position: 150% 0;
  }
  to {
    background-position: -150% 0;
  }
}

/* ============================================================
   凡例
   ============================================================ */

.legend {
  position: fixed;
  left: calc(var(--gutter) + var(--panel-left-w) + var(--gutter));
  bottom: var(--gutter);
  z-index: 15;
  width: 220px;
  padding: 10px 12px 11px;
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.legend-title {
  font-size: 11.5px;
  font-weight: 600;
}

.legend-bar {
  height: 8px;
  margin: 7px 0 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.legend-ends {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--muted);
}

.legend-hint {
  margin-top: 5px;
  font-size: 10.5px;
  color: var(--muted);
}

/* ============================================================
   詳細ドロワー
   ============================================================ */

.drawer {
  position: fixed;
  top: calc(var(--topbar-h) + var(--gutter));
  right: var(--gutter);
  bottom: var(--gutter);
  z-index: 35;
  width: 440px;
  max-width: calc(100vw - 2 * var(--gutter));
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  translate: 100% 0;
  opacity: 0;
  transition:
    translate var(--base) var(--ease),
    opacity var(--base) var(--ease);
}

.drawer.is-open {
  translate: 0 0;
  opacity: 1;
}

.drawer-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-solid);
}

.drawer-bar-spacer {
  flex: 1;
}

.drawer-back {
  display: none;
}

.drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 20px 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

/* ============================================================
   詳細本文（ドロワーと SSR ページで共有）
   ============================================================ */

.md-head {
  margin-bottom: 18px;
}

.md-pref {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.md-name {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.md-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.md-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tile {
  position: relative;
  padding: 11px 12px 13px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}

.tile::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--tile-color, var(--border-strong));
}

.tile-label {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 30px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--muted);
}

.tile-value {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--tile-color, var(--text));
}

.tile-rank {
  font-size: 10.5px;
  color: var(--muted);
}

.tile-rank-empty {
  min-height: 1em;
}

.tile-track {
  position: relative;
  height: 3px;
  margin-top: 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tile-color, var(--muted)) 22%, transparent);
}

.tile-track span {
  position: absolute;
  top: 50%;
  width: 7px;
  height: 7px;
  translate: -50% -50%;
  border-radius: 999px;
  background: var(--tile-color, var(--text));
  box-shadow: 0 0 0 2px var(--surface-2);
}

.md-block {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.md-block h2 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.md-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.md-rank,
.md-note {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted);
}

.climate-chart {
  display: block;
  width: 100%;
  height: 100px;
  margin: 4px 0 6px;
  -webkit-tap-highlight-color: transparent;
}

/* 各月の棒。PC は hover、モバイルはタップ（focus）で数値ラベルを出す。JS は使わない */
.chart-bar {
  cursor: pointer;
  outline: none;
}

.chart-hit {
  fill: transparent;
}

.chart-value {
  fill: var(--text);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.chart-bar:hover .chart-value,
.chart-bar:focus .chart-value {
  opacity: 1;
}

.chart-bar:hover rect:not(.chart-hit),
.chart-bar:focus rect:not(.chart-hit) {
  stroke: var(--text);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.chart-zero {
  stroke: var(--border-strong);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  vector-effect: non-scaling-stroke;
}

.chart-month {
  fill: var(--muted);
  font-size: 10px;
  font-family: var(--font);
}

.dist-row {
  display: grid;
  grid-template-columns: 62px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
}

.dist-label {
  font-size: 12px;
  color: var(--muted);
}

.dist-bar {
  display: block;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.dist-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0.75;
}

.dist-value {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.hazard-note {
  margin-top: 10px;
  font-size: 11px;
  line-height: 1.65;
  color: var(--muted);
}

.hazard-note a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.hazard-note svg,
.source-title svg {
  width: 12px;
  height: 12px;
}

.md-cta {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.md-cta .btn-primary {
  width: 100%;
}

.nationwide {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--muted);
}

.nationwide a {
  margin-right: 6px;
}

.flags {
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--muted);
}

.flags li {
  position: relative;
  padding-left: 14px;
}

.flags li::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 0.75em;
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: var(--warn);
}

.back-to-map {
  margin-top: 22px;
}

.ad-below {
  margin-top: 22px;
}

/* --- 出典チップ --- */

.src-chip {
  flex: 0 0 auto;
  padding: 0 7px;
  height: 18px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-solid);
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  transition:
    color var(--fast) var(--ease),
    border-color var(--fast) var(--ease);
}

.src-chip:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.src-popover {
  max-width: min(360px, calc(100vw - 32px));
  margin: auto;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow);
}

.src-popover::backdrop {
  background: rgba(15, 23, 42, 0.28);
}

.src-popover p {
  margin: 3px 0;
  font-size: 12px;
  line-height: 1.65;
}

.src-title {
  font-weight: 700;
  font-size: 13px !important;
}

.src-meta,
.src-method {
  color: var(--muted);
}

.src-popover a {
  display: inline-block;
  margin-top: 6px;
  font-size: 11.5px;
  word-break: break-all;
}

.stale-note {
  margin-top: 8px !important;
  color: var(--danger);
}

/* ============================================================
   モバイルのボトムシート
   ============================================================ */

.sheet {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  flex-direction: column;
  height: 96px;
  padding-bottom: env(safe-area-inset-bottom);
  border-radius: 20px 20px 0 0;
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 32px -12px rgba(15, 23, 42, 0.3);
  transition: height var(--base) var(--ease);
  overflow: hidden;
}

.sheet.is-dragging {
  transition: none;
}

/* peek ではタブまでを見せ、中身がはみ出して切れた見た目にならないようにする */
.sheet[data-state="peek"] .sheet-panes {
  visibility: hidden;
}

.sheet[data-state="half"] {
  height: 50dvh;
}

.sheet[data-state="full"] {
  height: calc(100dvh - 64px);
}

.sheet-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 22px;
  padding: 0;
  border: 0;
  background: none;
  cursor: grab;
  touch-action: none;
}

.sheet-handle span {
  display: block;
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
}

.sheet-handle:active {
  cursor: grabbing;
}

.sheet-tabs {
  display: flex;
  gap: 6px;
  padding: 0 12px 8px;
  border-bottom: 1px solid var(--border);
}

.sheet-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--fast) var(--ease);
}

.sheet-tab[aria-selected="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 600;
}

.sheet-tab[aria-selected="true"] .chip-count {
  background: color-mix(in srgb, var(--accent-ink) 22%, transparent);
  color: var(--accent-ink);
}

.sheet-panes {
  flex: 1;
  min-height: 0;
  display: flex;
}

.sheet-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ============================================================
   トースト
   ============================================================ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  z-index: 60;
  translate: -50% 8px;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity var(--base) var(--ease),
    translate var(--base) var(--ease);
}

.toast.is-visible {
  opacity: 1;
  translate: -50% 0;
}

/* ============================================================
   MapLibre の上書き
   ============================================================ */

.maplibregl-ctrl-bottom-right {
  right: calc(var(--panel-right-w) + 2 * var(--gutter));
  bottom: var(--gutter);
}

.maplibregl-ctrl-group {
  border-radius: var(--radius-sm) !important;
  background: var(--surface-solid) !important;
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow-sm) !important;
}

.maplibregl-ctrl-group button + button {
  border-top: 1px solid var(--border) !important;
}

.maplibregl-ctrl-group button .maplibregl-ctrl-icon {
  filter: var(--ctrl-icon-filter, none);
}

:root[data-theme="dark"] .maplibregl-ctrl-group button .maplibregl-ctrl-icon {
  filter: invert(1) hue-rotate(180deg);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .maplibregl-ctrl-group button .maplibregl-ctrl-icon {
    filter: invert(1) hue-rotate(180deg);
  }
}

.maplibregl-ctrl-attrib {
  font-size: 10px !important;
  border-radius: var(--radius-sm) 0 0 0 !important;
}

.maplibregl-popup-content {
  padding: 8px 12px !important;
  border-radius: 10px !important;
  background: var(--surface-solid) !important;
  color: var(--text) !important;
  border: 1px solid var(--border);
  box-shadow: var(--shadow) !important;
  font-family: var(--font) !important;
}

.maplibregl-popup-tip {
  display: none;
}

.muni-tip .tip-name {
  font-size: 13px;
  font-weight: 700;
}

.muni-tip .tip-name span {
  margin-right: 5px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
}

.muni-tip .tip-value {
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.muni-tip .tip-value b {
  color: var(--text);
}

/* 選択中マーカーの脈動リング */
.pulse-ring {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 2px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  pointer-events: none;
}

.pulse-ring::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 999px;
  border: 2px solid var(--accent);
  animation: pulse 1.6s var(--ease) infinite;
}

@keyframes pulse {
  from {
    opacity: 0.7;
    scale: 1;
  }
  to {
    opacity: 0;
    scale: 2.1;
  }
}

/* ============================================================
   SSR ページ（/m/{code}, /about）
   ============================================================ */

.doc-page {
  min-height: 100dvh;
  background: var(--bg);
}

.doc-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--topbar-h);
  padding: 0 var(--gutter);
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--border);
}

.doc-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.doc-topbar .brand-logo {
  width: 26px;
  height: 26px;
  color: var(--accent);
}

.doc-main {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px var(--gutter) 48px;
}

.doc-card {
  padding: 28px;
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.doc-footer {
  padding: 0 var(--gutter) 40px;
  text-align: center;
  font-size: 12px;
}

.about h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.about h2 {
  margin: 26px 0 10px;
  font-size: 15px;
  font-weight: 700;
}

.about p {
  margin: 10px 0;
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--muted);
}

.source-item {
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.source-title a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  font-size: 13.5px;
}

.source-meta {
  margin-top: 2px !important;
  font-size: 12px !important;
}

.source-item .src-method {
  margin-top: 4px !important;
  font-size: 12px !important;
  line-height: 1.7;
}

/* --- パンくず（/m/{code}, /pref/{code}, /about） --- */

.breadcrumb {
  margin-bottom: 16px;
}

.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.breadcrumb li + li::before {
  content: "/";
  margin-right: 6px;
  color: var(--border-strong);
}

.breadcrumb [aria-current="page"] {
  color: var(--text);
  font-weight: 600;
}

/* --- 都道府県ハブの一覧表（/pref/{code}） --- */

.pref-table-wrap {
  margin: 18px 0 8px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.pref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  white-space: nowrap;
}

.pref-table th,
.pref-table td {
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

.pref-table thead th abbr {
  text-decoration: none;
}

.pref-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
  font-size: 11.5px;
}

.pref-table tbody tr:last-child th,
.pref-table tbody tr:last-child td {
  border-bottom: 0;
}

.pref-table th[scope="row"] {
  text-align: left;
  font-weight: 600;
}

.pref-table tbody tr:hover {
  background: var(--accent-soft);
}

/* --- 近隣の市区町村（/m/{code}） --- */

.neighbor-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.neighbor-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.neighbor-item:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.neighbor-pref {
  margin-right: 5px;
  color: var(--muted);
  font-size: 11.5px;
}

.neighbor-dist {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.to-pref {
  margin-top: 10px;
  text-align: center;
  font-size: 13px;
}

/* --- 都道府県ナビ（404 ページ・トップのクローラー向けセクション） --- */

.pref-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.pref-nav a {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 12.5px;
  text-decoration: none;
  color: var(--text);
}

.pref-nav a:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* ============================================================
   トップのクローラー向けセクション
   結果一覧パネルの最下部（モバイルではボトムシートの「結果」タブ内）に置く。
   視覚的には隠さず、一覧をスクロールし切った先で実際に読める。
   ============================================================ */

.seo-intro {
  margin-top: 12px;
  padding: 16px 14px 20px;
  border-top: 1px solid var(--border);
}

.seo-intro h1 {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.6;
  letter-spacing: -0.01em;
}

.seo-intro h2 {
  margin: 18px 0 0;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
}

.seo-intro p {
  margin-top: 8px;
  font-size: 12.5px;
  line-height: 1.85;
  color: var(--muted);
}

.seo-intro .pref-nav a {
  padding: 4px 9px;
  font-size: 12px;
}

/* ============================================================
   モバイル
   ============================================================ */

@media (max-width: 959px) {
  .panel-left,
  .panel-right,
  .legend-hint,
  .legend-title {
    display: none;
  }

  .sheet {
    display: flex;
  }

  .topbar {
    gap: 8px;
    padding: 0 10px;
  }

  .brand-name {
    display: none;
  }

  .search {
    justify-content: stretch;
  }

  .search-input,
  .search-list {
    width: 100%;
  }

  .search-icon {
    left: 12px;
  }

  .search-list {
    left: 0;
  }

  .topbar-about {
    display: none;
  }

  .legend {
    left: 12px;
    right: auto;
    top: calc(var(--topbar-h) + 8px);
    bottom: auto;
    width: 168px;
    padding: 7px 9px 8px;
  }

  .legend-bar {
    margin: 0 0 3px;
  }

  .maplibregl-ctrl-bottom-right {
    right: var(--gutter);
    bottom: 104px;
  }

  .maplibregl-ctrl-bottom-left {
    bottom: 100px;
  }

  .results-head {
    padding: 12px 14px 8px;
  }

  .results-body,
  .filter-form {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }

  .filter-form {
    padding: 14px 14px 28px;
  }

  .pill {
    height: 36px;
    padding: 0 14px;
    font-size: 13px;
  }

  .pills-seg .pill {
    height: 30px;
  }

  .icon-btn {
    width: 44px;
    height: 44px;
    padding: 12px;
  }

  /* タップ領域は広げつつ、言語名が読めるよう幅は内容に合わせる */
  .lang-btn {
    width: auto;
    padding: 0 12px;
  }

  /* 言語ボタンのぶんトップバーが詰まるので、候補チップは星と件数だけにする
     （"Shortlist" のように語が長い言語ほど検索欄が痩せるため） */
  .chip-label {
    display: none;
  }

  .chip-btn {
    padding: 0 10px;
  }

  .star-btn {
    width: 44px;
    height: 44px;
    padding: 13px;
    top: 0;
    right: 0;
    opacity: 1;
  }

  .card-main {
    padding: 12px 46px 12px 8px;
  }

  .drawer {
    inset: 0;
    width: 100%;
    max-width: none;
    border-radius: 0;
    translate: 0 100%;
  }

  .drawer-back {
    display: inline-flex;
  }

  .drawer-close {
    display: none;
  }

  .drawer-body {
    padding: 16px 16px 40px;
  }

  .md-tiles {
    gap: 6px;
  }

  .md-name {
    font-size: 23px;
  }

  .doc-card {
    padding: 20px 16px;
  }

  .toast {
    bottom: 116px;
  }
}

@media (max-width: 400px) {
  .md-tiles {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   モーション低減
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .pulse-ring::after {
    display: none;
  }
}

/* 読み上げ専用（視覚的には隠すがアクセシビリティツリーには残す） */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
