/* ===== 防災リスクナビ v07 — style.css (モバイルUI改善) ===== */
:root {
  --bg-dark: #0a0e17;
  --bg-panel: #111827;
  --bg-card: #1a2332;
  --border: #2a3444;
  --text-primary: #e8ecf4;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-green: #00FF9F;
  --accent-cyan: #00CFFF;
  --accent-red: #FF3B5C;
  --accent-orange: #FF6B35;
  --accent-yellow: #FBBF24;
  --accent-blue: #3B82F6;
  --accent-purple: #A855F7;
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
}

/* ===== Header ===== */
#app-header {
  display: flex; justify-content: space-between; align-items: center;
  height: 58px; padding: 0 18px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  border-bottom: 1px solid var(--border);
  z-index: 1000; position: relative;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.logo-icon { height: 36px; width: auto; object-fit: contain; }
.title-group { display: flex; flex-direction: column; justify-content: center; line-height: 1.2; }
.logo-text { font-size: 1.25rem; font-weight: 700; letter-spacing: 0.5px;
  background: linear-gradient(135deg, var(--accent-green), var(--accent-cyan));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; 
  display: flex; align-items: center; gap: 8px; }
.subtitle { font-size: 0.78rem; color: var(--text-secondary); margin-top: 2px; }
.badge-beta {
  font-size: 0.72rem; font-weight: 700; padding: 3px 8px; border-radius: 4px;
  background: var(--accent-cyan); color: #0a0e17;
  -webkit-text-fill-color: #0a0e17;
}
.header-right { display: flex; gap: 6px; }
.header-btn {
  background: rgba(255,255,255,0.06); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 8px; cursor: pointer; color: var(--text-secondary);
  transition: all 0.2s;
}
.header-btn:hover { background: rgba(255,255,255,0.12); color: var(--text-primary); }

/* ===== Layout ===== */
#app-container {
  display: flex; height: calc(100vh - 58px);
}
#panel {
  width: 380px; min-width: 380px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
#map { flex: 1; z-index: 1; }

/* ===== Panel Sections ===== */
.panel-section {
  padding: 16px; border-bottom: 1px solid var(--border);
}
.section-title {
  font-size: 1.05rem; font-weight: 700; margin-bottom: 14px;
  color: var(--text-primary);
}

/* ===== Search ===== */
.search-box {
  display: flex; gap: 6px;
}
.search-box input {
  flex: 1; padding: 12px 14px; border-radius: var(--radius);
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-primary); font-size: 1rem; font-family: inherit;
  outline: none; transition: border-color 0.2s;
}
.search-box input:focus { border-color: var(--accent-cyan); }
.search-box input::placeholder { color: var(--text-muted); }
.search-box button {
  padding: 12px 16px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-green));
  border: none; cursor: pointer; font-size: 1.15rem;
  transition: transform 0.15s;
}
.search-box button:hover { transform: scale(1.05); }

.search-actions { display: flex; gap: 8px; margin-top: 8px; }
.action-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px; border-radius: 8px; font-size: 0.92rem; font-weight: 600;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-secondary); cursor: pointer; font-family: inherit;
  transition: all 0.2s;
}
.action-btn:hover { border-color: var(--accent-cyan); color: var(--accent-cyan); }
.action-btn.active { border-color: var(--accent-green); color: var(--accent-green); background: rgba(0,255,159,0.08); }

.selected-loc {
  margin-top: 10px; padding: 10px 14px; border-radius: 8px;
  background: rgba(0,255,159,0.06); border: 1px solid rgba(0,255,159,0.2);
  font-size: 0.95rem; color: var(--accent-green); font-weight: 600;
}
.loc-coords { display: block; font-size: 0.82rem; color: var(--text-muted); font-weight: 400; margin-top: 2px; }

/* ===================================================================
   JMA Real-time Section — 気象庁リアルタイム情報
   =================================================================== */
#jma-section {
  padding: 12px 16px;
  background: linear-gradient(180deg, rgba(168,85,247,0.04) 0%, transparent 100%);
}
.jma-title {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.jma-update-time {
  font-size: 0.72rem; font-weight: 400; color: var(--text-muted);
}

/* Accordion Block */
.jma-block {
  margin-bottom: 6px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: border-color 0.2s;
}
.jma-block:hover { border-color: rgba(168,85,247,0.3); }

.jma-block-header {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 10px 12px;
  background: transparent; border: none;
  color: var(--text-primary); cursor: pointer;
  font-family: inherit; font-size: 0.9rem; font-weight: 600;
  text-align: left; transition: background 0.15s;
}
.jma-block-header:hover { background: rgba(255,255,255,0.03); }
.jma-block-icon { font-size: 1.1rem; flex-shrink: 0; }
.jma-block-label { flex: 1; }
.jma-badge {
  font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 10px;
  background: rgba(255,255,255,0.06); color: var(--text-muted);
  min-width: 24px; text-align: center;
}
.jma-badge.has-data { background: rgba(0,207,255,0.15); color: var(--accent-cyan); }
.jma-badge.alert { background: rgba(255,59,92,0.2); color: var(--accent-red); animation: badge-pulse 2s ease-in-out infinite; }
@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.jma-chevron {
  flex-shrink: 0; color: var(--text-muted);
  transition: transform 0.25s ease;
}
.jma-block-body {
  max-height: 0; overflow: hidden;
  transition: max-height 0.35s ease, padding 0.25s ease;
  padding: 0 12px;
}
.jma-block-body.jma-open {
  max-height: 600px; padding: 0 12px 10px;
  overflow-y: auto;
}
.jma-block-header[aria-expanded="true"] .jma-chevron {
  transform: rotate(180deg);
}

/* JMA List Items */
.jma-list { display: flex; flex-direction: column; gap: 5px; }
.jma-loading, .jma-empty {
  font-size: 0.82rem; color: var(--text-muted); padding: 6px 0; text-align: center;
}
.jma-empty { font-style: italic; }

/* Quake Card */
.jma-quake-card {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 8px 10px; border-radius: 8px;
  background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.05);
  transition: background 0.15s, border-color 0.15s;
}
.jma-quake-card:hover { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); }
.jma-quake-card[onclick] { cursor: pointer; }
.jma-quake-card[onclick]:hover { background: rgba(255,255,255,0.08); border-color: rgba(0,207,255,0.25); }

/* Quake Epicenter Marker on Map */
.quake-pulse {
  animation: quakePulse 2.5s ease-out infinite;
}
@keyframes quakePulse {
  0%   { stroke-opacity: 0.6; fill-opacity: 0.15; r: 14; }
  50%  { stroke-opacity: 0.2; fill-opacity: 0.04; r: 22; }
  100% { stroke-opacity: 0.6; fill-opacity: 0.15; r: 14; }
}
.quake-loc-hint {
  font-size: 0.7rem; margin-left: 4px; opacity: 0.6;
}
.quake-epicenter-popup .leaflet-popup-content-wrapper {
  background: rgba(15,18,30,0.92); color: #e8ecf4;
  border-radius: 10px; border: 1px solid rgba(255,255,255,0.12);
}
.quake-epicenter-popup .leaflet-popup-tip { background: rgba(15,18,30,0.92); }
.jma-quake-intensity {
  width: 40px; height: 40px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem; font-weight: 900; color: #fff; flex-shrink: 0;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.jma-quake-info { flex: 1; min-width: 0; }
.jma-quake-epi { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jma-quake-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.jma-quake-meta span { white-space: nowrap; }

/* Intensity Distribution */
.jma-dist-toggle {
  display: flex; align-items: center; gap: 5px;
  margin-top: 5px; padding: 3px 0;
  font-size: 0.75rem; color: var(--accent-cyan); cursor: pointer;
  user-select: none; transition: color 0.15s;
}
.jma-dist-toggle:hover { color: var(--accent-green); }
.jma-dist-arrow {
  font-size: 0.6rem; transition: transform 0.25s;
  display: inline-block;
}
.jma-dist-arrow.open { transform: rotate(90deg); }
.jma-dist-body {
  max-height: 0; overflow: hidden;
  transition: max-height 0.3s ease, padding 0.2s ease;
  padding: 0;
}
.jma-dist-body.jma-open {
  max-height: 300px; padding: 4px 0;
}
.jma-dist-row {
  display: flex; align-items: center; gap: 6px;
  padding: 2px 0; font-size: 0.78rem;
}
.jma-dist-int {
  width: 22px; height: 18px; border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.68rem; font-weight: 800; color: #fff;
  flex-shrink: 0; text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.jma-dist-pref {
  color: var(--text-secondary); font-size: 0.78rem;
}

/* Typhoon Card */
.jma-typhoon-card {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border-radius: 8px;
  background: rgba(168,85,247,0.06); border: 1px solid rgba(168,85,247,0.15);
  transition: background 0.15s, border-color 0.15s;
}
.jma-typhoon-card:hover { background: rgba(168,85,247,0.1); border-color: rgba(168,85,247,0.3); }
.jma-typhoon-icon { font-size: 1.8rem; flex-shrink: 0; animation: typhoon-spin 3s linear infinite; }
@keyframes typhoon-spin { to { transform: rotate(360deg); } }
.jma-typhoon-info { flex: 1; min-width: 0; }
.jma-typhoon-name {
  font-size: 0.92rem; font-weight: 700; color: var(--accent-purple);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.jma-typhoon-cat {
  font-size: 0.65rem; font-weight: 700; padding: 2px 8px; border-radius: 4px;
  color: #fff; white-space: nowrap;
}
.jma-typhoon-detail {
  font-size: 0.75rem; color: var(--text-secondary); margin-top: 3px;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.jma-typhoon-detail span { white-space: nowrap; }
.jma-typhoon-summary {
  font-size: 0.78rem; color: var(--text-secondary); margin-top: 4px;
  line-height: 1.5;
}
.jma-typhoon-meta {
  font-size: 0.72rem; color: var(--text-muted); margin-top: 4px;
}

/* Typhoon Map Marker */
.typhoon-marker { background: none !important; border: none !important; }
.typhoon-popup .leaflet-popup-content-wrapper {
  background: rgba(10,14,23,0.95); border: 1px solid rgba(168,85,247,0.4);
}
.typhoon-popup .leaflet-popup-tip { background: rgba(10,14,23,0.95); }

/* Warning Card */
.jma-warning-card {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 8px;
  font-size: 0.82rem; font-weight: 600;
}
.jma-warning-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}

/* Flood Card (v05 legacy) */
.jma-flood-card {
  padding: 7px 10px; border-radius: 8px;
  background: rgba(59,130,246,0.06); border: 1px solid rgba(59,130,246,0.15);
  font-size: 0.82rem;
}
.jma-flood-river { font-weight: 600; color: var(--accent-blue); }
.jma-flood-level { color: var(--text-secondary); margin-top: 2px; }

/* Flood Card v2 (Step 3: XML詳細版) */
.jma-flood-card-v2 {
  padding: 8px 10px; border-radius: 8px;
  background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.05);
  transition: background 0.15s, border-color 0.15s;
}
.jma-flood-card-v2:hover { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); }
.jma-flood-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.jma-flood-level-badge {
  font-size: 0.68rem; font-weight: 700; padding: 2px 8px; border-radius: 4px;
  white-space: nowrap; flex-shrink: 0;
}
.jma-flood-river-name { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); }
.jma-flood-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 3px; }
.jma-flood-summary { font-size: 0.78rem; color: var(--text-secondary); margin-top: 4px; line-height: 1.5; }

/* 観測所水位 展開 */
.flood-stations-toggle {
  display: flex; align-items: center; gap: 5px;
  margin-top: 5px; padding: 3px 0;
  font-size: 0.75rem; color: var(--accent-cyan); cursor: pointer;
  user-select: none; transition: color 0.15s;
}
.flood-stations-toggle:hover { color: var(--accent-green); }
.flood-stations-body {
  max-height: 0; overflow: hidden;
  transition: max-height 0.3s ease, padding 0.2s ease;
  padding: 0;
}
.flood-stations-body.jma-open {
  max-height: 400px; padding: 4px 0;
}

/* 観測所水位の各行 */
.flood-station {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 3px 0; font-size: 0.78rem; border-bottom: 1px solid rgba(255,255,255,0.04);
}
.flood-station:last-child { border-bottom: none; }
.flood-station-name { font-weight: 600; color: var(--text-primary); min-width: 50px; }
.flood-station-wl { font-weight: 700; color: var(--accent-cyan); }
.flood-station-cond { font-size: 0.7rem; color: var(--accent-yellow); }
.flood-station-ref { font-size: 0.68rem; color: var(--text-muted); }

/* 水位バー */
.flood-bar-track {
  flex: 1; height: 4px; border-radius: 2px;
  background: rgba(255,255,255,0.08); min-width: 60px;
}
.flood-bar-fill {
  height: 100%; border-radius: 2px; transition: width 0.6s ease;
}

/* Overview text */
.jma-overview {
  font-size: 0.8rem; color: var(--text-secondary); line-height: 1.6;
  padding: 8px 10px; border-radius: 8px;
  background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.05);
  margin-bottom: 6px;
}

/* Phase 2: Alert Card (津波・噴火・土砂災害・竜巻・記録的大雨) */
.jma-alert-card {
  padding: 8px 10px; border-radius: 8px;
  background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.05);
  transition: background 0.15s, border-color 0.15s;
}
.jma-alert-card:hover { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); }

.jma-alert-header {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.jma-alert-level {
  font-size: 0.68rem; font-weight: 700; padding: 2px 8px; border-radius: 4px;
  white-space: nowrap; flex-shrink: 0;
}
.jma-alert-title {
  font-size: 0.85rem; font-weight: 600; color: var(--text-primary);
}
.jma-alert-meta {
  font-size: 0.75rem; color: var(--text-muted); margin-top: 3px;
  display: flex; gap: 10px; flex-wrap: wrap;
}
.jma-alert-content {
  font-size: 0.78rem; color: var(--text-secondary); margin-top: 4px;
  line-height: 1.5; word-break: break-all;
}
.jma-alert-expand {
  background: none; border: none; color: var(--accent-cyan);
  font-size: 0.75rem; cursor: pointer; font-family: inherit;
  padding: 2px 0; margin-left: 4px; text-decoration: underline;
}
.jma-alert-expand:hover { color: var(--accent-green); }

/* ===== Gauge ===== */
.gauge-container { display: flex; flex-direction: column; align-items: center; padding: 8px 0; }
.gauge-score-text { font-size: 2.6rem; font-weight: 900; fill: var(--accent-green); }
.gauge-label-text { font-size: 0.95rem; fill: var(--text-muted); }
#gauge-arc { transition: stroke-dashoffset 1.2s ease, stroke 0.5s ease; }
.risk-level-badge {
  margin-top: 8px; padding: 5px 20px; border-radius: 20px;
  font-size: 0.98rem; font-weight: 700;
  border: 1px solid rgba(0,255,159,0.3); color: var(--accent-green);
  background: rgba(0,255,159,0.08);
}

/* ===== Score Bars ===== */
.score-bars { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.score-bar-item {}
.bar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; font-size: 0.95rem; }
.bar-val { font-weight: 700; color: var(--accent-red); }
.bar-track { height: 8px; border-radius: 4px; background: rgba(255,255,255,0.06); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--accent-red); transition: width 1s ease; }
.bar-fill.bar-blue { background: var(--accent-blue); }
.bar-fill.bar-yellow { background: var(--accent-yellow); }
.bar-fill.bar-orange { background: var(--accent-orange); }
.bar-detail { font-size: 0.82rem; color: var(--text-muted); margin-top: 3px; }

/* ===== Location Meta ===== */
.location-meta {
  margin-top: 12px; padding: 12px; border-radius: 8px;
  background: var(--bg-card); font-size: 0.88rem; color: var(--text-secondary);
  line-height: 1.7;
}

/* ===== AI Advice ===== */
.advice-box {
  padding: 14px; border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(0,207,255,0.06), rgba(0,255,159,0.06));
  border: 1px solid rgba(0,207,255,0.15);
  font-size: 0.95rem; line-height: 1.8; color: var(--text-primary);
}
.advice-box ul { padding-left: 20px; margin-top: 8px; }
.advice-box li { margin-bottom: 5px; }
.advice-box .advice-header { font-weight: 700; color: var(--accent-cyan); margin-bottom: 8px; }

/* ===== Shelter Filter ===== */
.shelter-filter {
  display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px;
}
.filter-btn {
  padding: 7px 13px; border-radius: 6px; font-size: 0.85rem; font-weight: 600;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-secondary); cursor: pointer; font-family: inherit;
  transition: all 0.2s;
}
.filter-btn:hover { border-color: var(--accent-cyan); color: var(--accent-cyan); }
.filter-btn.active {
  background: rgba(0,207,255,0.15); border-color: var(--accent-cyan);
  color: var(--accent-cyan); font-weight: 700;
}

/* ===== Shelter List ===== */
.shelter-list { display: flex; flex-direction: column; gap: 8px; }
.shelter-card {
  padding: 10px 12px; border-radius: var(--radius);
  background: var(--bg-card); border: 1px solid var(--border);
  cursor: pointer; transition: all 0.2s;
}
.shelter-card:hover { border-color: var(--accent-cyan); transform: translateX(3px); }
.shelter-name { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.shelter-info { font-size: 0.85rem; color: var(--text-secondary); margin-top: 3px; }
.shelter-dist { font-size: 0.92rem; font-weight: 700; color: var(--accent-cyan); margin-top: 4px; }
.shelter-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.shelter-tag {
  font-size: 0.78rem; padding: 2px 8px; border-radius: 4px;
  background: rgba(0,207,255,0.1); border: 1px solid rgba(0,207,255,0.2);
  color: var(--accent-cyan);
}
.dist-band-header {
  font-size: 0.95rem; font-weight: 700; padding: 8px 0 4px;
  border-bottom: 1px solid var(--border); margin-bottom: 6px;
}
.page-info {
  font-size: 0.85rem; color: var(--text-muted); margin-bottom: 8px;
  text-align: center;
}
.pagination {
  display: flex; gap: 8px; margin-top: 10px; justify-content: center;
}
.page-btn {
  padding: 10px 22px; border-radius: 8px; font-size: 0.95rem; font-weight: 700;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-primary); cursor: pointer; font-family: inherit;
  transition: all 0.2s;
}
.page-btn:hover { border-color: var(--accent-cyan); color: var(--accent-cyan); }
.page-btn-next { background: linear-gradient(135deg, rgba(0,207,255,0.1), rgba(0,255,159,0.1)); }
.btn-route {
  margin-top: 6px; padding: 7px 14px; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-green));
  border: none; color: #0a0e17; font-size: 0.88rem; font-weight: 700;
  cursor: pointer; font-family: inherit; transition: transform 0.15s;
}
.btn-route:hover { transform: scale(1.03); }

/* ===== Credits ===== */
.credits { font-size: 0.82rem; color: var(--text-muted); }
.credits a { color: var(--accent-cyan); text-decoration: none; }
.credits ul { list-style: none; padding: 0; margin-top: 4px; }
.credits li::before { content: "・"; }
.disclaimer { margin-top: 8px; font-size: 0.78rem; color: var(--text-muted); opacity: 0.7; }

/* ===== Modal ===== */
.modal {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6); z-index: 2000;
  display: flex; align-items: center; justify-content: center;
}
.modal-content {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; max-width: 420px; width: 90%;
  color: var(--text-primary);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-content h3 { margin-bottom: 14px; font-size: 1rem; }
.modal-content h3 + h3 { margin-top: 10px; }
.modal-content ol { padding-left: 20px; font-size: 0.85rem; line-height: 1.8; }
.radar-time-label {
  font-size: 0.7rem; color: var(--accent-cyan); margin-left: 6px; font-weight: 400;
}
.layer-toggle {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; font-size: 0.85rem; cursor: pointer;
}
.layer-toggle input { accent-color: var(--accent-cyan); width: 16px; height: 16px; }
.modal-content hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.modal-close {
  margin-top: 14px; width: 100%; padding: 10px;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-primary);
  cursor: pointer; font-family: inherit; font-size: 0.85rem;
  transition: all 0.2s;
}
.modal-close:hover { border-color: var(--accent-cyan); }

/* ===== Loading ===== */
.loading-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(10,14,23,0.85); z-index: 3000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.spinner {
  width: 40px; height: 40px; border: 3px solid var(--border);
  border-top-color: var(--accent-cyan); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay p { margin-top: 14px; font-size: 0.9rem; color: var(--text-secondary); }

/* ===== Leaflet overrides ===== */
.leaflet-popup-content-wrapper {
  background: var(--bg-panel); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.leaflet-popup-tip { background: var(--bg-panel); }
.leaflet-popup-content { font-family: 'Noto Sans JP', sans-serif; font-size: 0.82rem; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  #app-container { flex-direction: column-reverse; height: calc(100vh - 52px); }
  #panel {
    width: 100%; min-width: auto;
    max-height: 40vh;
    border-right: none; border-top: 1px solid var(--border);
  }
  #map { height: 60vh; }

  /* 凡例: モバイルではさらに小さく */
  #map-legend { bottom: 10px; right: auto; left: 6px; }
  .legend-toggle { width: 30px; height: 30px; font-size: 0.7rem; border-radius: 8px; }
  .legend-body { padding: 8px 10px; min-width: 120px; max-width: 155px; }
  .legend-title { font-size: 0.65rem; margin-bottom: 3px; padding-bottom: 2px; }
  .legend-label { font-size: 0.6rem; }
  .legend-swatch { width: 12px; height: 9px; }
  .legend-row { gap: 4px; margin-bottom: 2px; }
  .legend-section { margin-bottom: 5px; }

  /* Header */
  #app-header { height: 52px; padding: 0 12px; }
  .logo-text { font-size: 1.05rem; }
  .subtitle { font-size: 0.68rem; }
  .logo-icon { height: 30px; }
  .header-left { gap: 8px; }

  /* パネルセクション */
  .panel-section { padding: 10px 12px; }
  .section-title { font-size: 0.88rem; margin-bottom: 8px; }

  /* 検索 */
  .search-box input { padding: 10px 12px; font-size: 0.9rem; }
  .search-box button { padding: 10px 14px; font-size: 1rem; }
  .action-btn { padding: 10px 8px; font-size: 0.85rem; }
  .filter-btn { padding: 8px 11px; font-size: 0.8rem; }

  /* ボタン */
  .header-btn { padding: 7px 8px; }
  .btn-route { padding: 8px 14px; font-size: 0.85rem; }

  /* JMA section: コンパクト化 */
  #jma-section { padding: 8px 10px; }
  .jma-title { margin-bottom: 6px; }
  .jma-title span:first-child { font-size: 0.88rem; }
  .jma-block { margin-bottom: 4px; }
  .jma-block-header { padding: 7px 9px; font-size: 0.8rem; gap: 6px; }
  .jma-block-icon { font-size: 0.95rem; }
  .jma-badge { font-size: 0.65rem; padding: 2px 6px; min-width: 20px; }
  .jma-block-body.jma-open { max-height: 400px; padding: 0 9px 8px; }

  /* 地震カード */
  .jma-quake-card { padding: 6px 8px; gap: 8px; }
  .jma-quake-intensity { width: 32px; height: 32px; font-size: 0.85rem; border-radius: 6px; }
  .jma-quake-epi { font-size: 0.78rem; }
  .jma-quake-meta { font-size: 0.68rem; gap: 6px; }

  /* アラートカード */
  .jma-alert-card { padding: 6px 8px; }
  .jma-alert-header { gap: 6px; }
  .jma-alert-level { font-size: 0.62rem; padding: 2px 6px; }
  .jma-alert-title { font-size: 0.78rem; }
  .jma-alert-meta { font-size: 0.68rem; gap: 6px; }
  .jma-alert-content { font-size: 0.72rem; }

  /* 台風カード */
  .jma-typhoon-card { padding: 8px 10px; gap: 8px; }
  .jma-typhoon-icon { font-size: 1.4rem; }
  .jma-typhoon-name { font-size: 0.82rem; gap: 6px; }
  .jma-typhoon-cat { font-size: 0.6rem; padding: 1px 6px; }
  .jma-typhoon-detail { font-size: 0.68rem; gap: 6px; }
  .jma-typhoon-meta { font-size: 0.65rem; }

  /* 洪水カード */
  .jma-flood-card-v2 { padding: 6px 8px; }
  .jma-flood-level-badge { font-size: 0.62rem; padding: 2px 6px; }
  .jma-flood-river-name { font-size: 0.78rem; }
  .jma-flood-meta { font-size: 0.68rem; }
  .jma-flood-summary { font-size: 0.7rem; }

  /* 避難所カード */
  .shelter-card { padding: 8px 10px; }
  .shelter-name { font-size: 0.88rem; }
  .shelter-info { font-size: 0.78rem; }
  .shelter-dist { font-size: 0.82rem; }
  .shelter-tag { font-size: 0.7rem; padding: 1px 6px; }

  /* リスクスコア */
  .bar-header { font-size: 0.85rem; }
  .bar-detail { font-size: 0.75rem; }

  /* モーダル */
  .modal-content { padding: 14px; width: 95%; max-height: 95vh; }
  .modal-content h3 { font-size: 0.9rem; margin-bottom: 8px; }
  .modal-content ol { font-size: 0.78rem; line-height: 1.55; }
  .modal-close { padding: 12px; font-size: 0.85rem; }

  /* ページネーション */
  .page-btn { padding: 8px 18px; font-size: 0.85rem; }
  .dist-band-header { font-size: 0.85rem; padding: 6px 0 3px; }
  .page-info { font-size: 0.78rem; }
}

@media (max-width: 420px) {
  #app-header { height: 48px; padding: 0 10px; }
  .logo-text { font-size: 0.95rem; }
  .subtitle { font-size: 0.62rem; }
  .logo-icon { height: 26px; }
  .badge-beta { font-size: 0.6rem; padding: 2px 6px; }
  #app-container { height: calc(100vh - 48px); }
  #panel { max-height: 42vh; }
  #map { height: 58vh; }

  #map-legend { left: 4px; bottom: 8px; }
  #map-legend .legend-toggle { width: 28px; height: 28px; font-size: 0.7rem; }

  .panel-section { padding: 8px 10px; }
  .section-title { font-size: 0.82rem; margin-bottom: 6px; }
  .search-box input { padding: 9px 10px; font-size: 0.85rem; }
  .action-btn { padding: 8px 6px; font-size: 0.8rem; }

  /* JMA: さらにコンパクト */
  #jma-section { padding: 6px 8px; }
  .jma-block-header { padding: 6px 8px; font-size: 0.75rem; }
  .jma-block-icon { font-size: 0.85rem; }
}

/* ===== Hazard Legend (折りたたみ式) ===== */
#map { position: relative; }
#map-legend {
  position: absolute;
  bottom: 28px; right: 12px;
  z-index: 500;
  pointer-events: auto;
  font-family: 'Noto Sans JP', sans-serif;
  animation: legendFadeIn 0.25s ease;
}
/* 凡例トグルボタン（全画面サイズで表示） */
.legend-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(10,14,23,0.9); border: 1px solid rgba(255,255,255,0.18);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: var(--text-secondary); font-size: 0.8rem; font-weight: 700;
  cursor: pointer; box-shadow: 0 2px 12px rgba(0,0,0,0.5);
  margin-left: auto;
  transition: all 0.2s;
}
.legend-toggle:hover { background: rgba(10,14,23,1); border-color: var(--accent-cyan); color: var(--accent-cyan); }
/* 展開時は「凡」ボタンを隠す */
.legend-open .legend-toggle { display: none; }

/* 凡例閉じるボタン */
.legend-close {
  position: absolute; top: 6px; right: 6px;
  width: 24px; height: 24px; border-radius: 6px;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
  color: var(--text-secondary); font-size: 0.8rem; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; line-height: 1;
}
.legend-close:hover { background: rgba(255,59,92,0.2); border-color: var(--accent-red); color: var(--accent-red); }

/* 凡例本体（デフォルト非表示、.legend-openで展開） */
.legend-body {
  display: none; margin-top: 6px;
  position: relative;
  background: rgba(10,14,23,0.92);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 140px; max-width: 200px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
#map-legend.legend-open .legend-body { display: block; }

@keyframes legendFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.legend-section { margin-bottom: 8px; }
.legend-section:last-child { margin-bottom: 0; }
.legend-title {
  font-size: 0.72rem; font-weight: 700;
  color: #94a3b8; letter-spacing: 0.5px;
  margin-bottom: 5px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.legend-row {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 3px;
}
.legend-swatch {
  width: 16px; height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.15);
}
.legend-label {
  font-size: 0.7rem; color: #e8ecf4; line-height: 1.3;
}
