:root {
  --bg: #081523;
  --panel: rgba(7, 22, 38, 0.82);
  --panel-border: rgba(168, 197, 255, 0.16);
  --text: #ecf5ff;
  --muted: #a8bfd7;
  --accent: #2cb2ff;
  --accent-2: #42d39b;
  --danger: #f26a5f;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  --map-height: clamp(420px, calc(100vh - 270px), 860px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Noto Sans Thai", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(53, 144, 255, 0.22), transparent 26%),
    radial-gradient(circle at top right, rgba(50, 190, 160, 0.16), transparent 24%),
    linear-gradient(180deg, #0e2c47 0%, #081523 45%, #06111d 100%);
}

body {
  min-height: 100vh;
}

.app-shell {
  padding: 12px;
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 8px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(11, 57, 97, 0.92), rgba(13, 89, 156, 0.86));
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 3px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #98dcff;
}

.topbar h1 {
  margin: 0;
  /* 1.45vw: ที่จอ 1400px ชื่อระบบยังอยู่บรรทัดเดียว เหลือที่ให้แถบเล่นเรดาร์ตรงกลาง */
  font-size: clamp(16px, 1.45vw, 24px);
  line-height: 1.08;
}

.subcopy {
  margin: 3px 0 0;
  font-size: 11px;
  color: #d3e7fb;
}

.topbar-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

.nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(4, 18, 32, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--text);
  text-decoration: none;
  backdrop-filter: blur(10px);
}

.nav-button:hover {
  background: rgba(52, 171, 255, 0.18);
}

.sidebar-controls {
  display: flex;
  justify-content: flex-end;
}

.sidebar-toggle-button {
  width: 46px;
  height: 46px;
  padding: 0;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid rgba(125, 215, 255, 0.42);
  border-radius: 999px;
  background: rgba(44, 178, 255, 0.2);
  color: var(--text);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
  backdrop-filter: blur(12px);
}

.sidebar-toggle-button:hover {
  background: rgba(44, 178, 255, 0.26);
  border-color: rgba(168, 226, 255, 0.78);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.34);
  transform: translateY(-1px);
}

.sidebar-toggle-button:focus-visible {
  outline: 3px solid rgba(66, 211, 155, 0.55);
  outline-offset: 3px;
}

.sidebar-toggle-button span {
  display: block;
  width: 19px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.app-shell.sidebar-collapsed .sidebar-toggle-button {
  background: rgba(44, 178, 255, 0.32);
  border-color: rgba(66, 211, 155, 0.66);
}

.pill {
  min-width: 138px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(4, 18, 32, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
}

.pill-label {
  display: block;
  font-size: 11px;
  color: #9fc4e8;
  margin-bottom: 2px;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin: 8px 0 10px;
  transition: grid-template-columns 220ms ease;
}

.stat-card,
.panel,
.map-panel {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 10px 12px;
  border-radius: 14px;
}

.stat-card .label {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stat-card .value {
  display: block;
  margin-top: 2px;
  font-size: 22px;
  line-height: 1.1;
}

.content-grid {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  transition: grid-template-columns 220ms ease;
}

.sidebar {
  display: grid;
  gap: 10px;
  align-content: start;
  max-height: var(--map-height);
  overflow: auto;
}

.app-shell.sidebar-collapsed .content-grid {
  grid-template-columns: 56px minmax(0, 1fr);
}

.app-shell.sidebar-collapsed .sidebar {
  max-height: none;
  overflow: visible;
}

.app-shell.sidebar-collapsed .sidebar .panel {
  display: none;
}

.app-shell.sidebar-collapsed .sidebar-controls {
  justify-content: center;
}

/* เมนูการค้นหาแบบ Tab */
.sidebar-tabs {
  display: flex;
  gap: 6px;
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 4px;
  border-radius: 12px;
  background: rgba(7, 22, 38, 0.85);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
}

.sidebar-tab {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px 6px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #b9d6ee;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.sidebar-tab:hover {
  color: #ecf5ff;
  background: rgba(44, 178, 255, 0.12);
}

.sidebar-tab.is-active {
  color: #ecf5ff;
  background: rgba(44, 178, 255, 0.2);
  border-color: rgba(125, 215, 255, 0.42);
}

.sidebar-tab:focus-visible {
  outline: 3px solid rgba(66, 211, 155, 0.55);
  outline-offset: 2px;
}

.tab-pane:not(.is-active) {
  display: none;
}

.app-shell.sidebar-collapsed .sidebar-tabs {
  display: none;
}

.app-footer {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 5px 12px;
  padding: 10px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(7, 22, 38, 0.78), rgba(11, 57, 97, 0.68));
  color: #d4e6f8;
  font-size: 13px;
  text-align: center;
  box-shadow: var(--shadow);
}

.app-footer p {
  margin: 0;
}

.footer-credit {
  color: #ecf5ff;
  font-weight: 800;
}

.footer-org {
  margin-top: 0 !important;
  color: #b9d6ee;
}

.app-footer a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0;
  padding: 5px 10px;
  border: 1px solid rgba(125, 215, 255, 0.24);
  border-radius: 999px;
  background: rgba(44, 178, 255, 0.09);
  color: #7dd7ff;
  text-decoration: none;
}

.app-footer a:hover {
  background: rgba(44, 178, 255, 0.16);
  color: #bdeeff;
}

.panel {
  padding: 12px;
  border-radius: 14px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 16px;
}

.ghost-button,
.toolbar-button {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease;
}

.ghost-button {
  padding: 6px 10px;
}

.toolbar-button {
  padding: 8px 12px;
}

.ghost-button:hover,
.toolbar-button:hover,
.toolbar-button.active {
  background: rgba(52, 171, 255, 0.18);
  transform: translateY(-1px);
}

.filter-list,
.quick-actions,
.system-list {
  display: grid;
  gap: 10px;
}

.search-field {
  display: block;
}

.search-field input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  background: rgba(4, 18, 32, 0.56);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.search-field input::placeholder {
  color: #86a7c8;
}

.search-field input:focus {
  border-color: rgba(65, 181, 255, 0.82);
  box-shadow: 0 0 0 3px rgba(44, 178, 255, 0.18);
}

.search-help {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.search-results {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.search-empty {
  margin: 0;
  border-radius: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
}

.search-result-item {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  width: 100%;
  padding: 9px 10px;
}

.search-result-item:hover {
  background: rgba(44, 178, 255, 0.16);
}

.search-result-main {
  display: grid;
  gap: 3px;
}

.search-result-name {
  font-size: 14px;
  font-weight: 600;
}

.search-result-meta {
  font-size: 12px;
  color: var(--muted);
}

.search-result-badge {
  display: inline-flex;
  align-items: center;
  margin-top: 4px;
  width: fit-content;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.08);
}

.filter-item,
.quick-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.filter-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.count-chip {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 12px;
}

.quick-action {
  cursor: pointer;
}

.quick-action strong {
  font-size: 14px;
}

.quick-action span {
  color: var(--muted);
  font-size: 12px;
}

.region-list {
  display: grid;
  gap: 8px;
}

.region-filter-active {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 12px;
}

.region-group {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
}

.region-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.region-header:hover {
  background: rgba(44, 178, 255, 0.1);
}

.region-name-en,
.province-name-en {
  color: var(--muted);
  font-size: 11px;
  margin-left: 4px;
}

.region-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.region-caret {
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 140ms ease;
}

.region-group.is-expanded .region-caret {
  transform: rotate(45deg);
}

.province-list {
  display: none;
  gap: 6px;
  padding: 0 8px 8px;
}

.region-group.is-expanded .province-list {
  display: grid;
  padding-top: 2px;
}

.province-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 7px 9px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-size: 12.5px;
}

.province-item:hover:not(:disabled) {
  background: rgba(44, 178, 255, 0.14);
}

.province-item.is-active {
  border-color: rgba(65, 181, 255, 0.82);
  background: rgba(44, 178, 255, 0.22);
}

.province-item:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.map-panel {
  position: relative;
  min-height: var(--map-height);
  border-radius: 16px;
  overflow: hidden;
}

.map-toolbar {
  position: absolute;
  z-index: 500;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toolbar-group,
.map-actions,
.radar-toggle,
.map-toggle-button {
  pointer-events: auto;
}

.toolbar-group {
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(7, 22, 38, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
}

.radar-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(7, 22, 38, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  transition: opacity 140ms ease;
}

.radar-toggle:has(input:disabled) {
  opacity: 0.45;
  cursor: not-allowed;
}

.map-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* ── เมนูชั้นแผนที่ (ปุ่มเดียว แบบหน้า sim) ───────────────────────────── */
.layer-menu {
  pointer-events: auto;
  margin-left: auto;
}

.layer-menu-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  background: rgba(7, 22, 38, 0.82);
  backdrop-filter: blur(12px);
  font-weight: 700;
  white-space: nowrap;
}

.layer-menu-summary {
  font-weight: 500;
  font-size: 12px;
  color: var(--muted, rgba(255, 255, 255, 0.7));
}

.layer-menu-summary:empty {
  display: none;
}

.layer-menu-panel {
  position: absolute;
  right: 10px;
  z-index: 600;
  width: min(300px, calc(100% - 20px));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px;
  border-radius: 14px;
  background: rgba(7, 22, 38, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
  pointer-events: auto;
  /* แผงถูกย้ายออกมาไว้ใต้ .map-panel (ไม่ได้อยู่ในแถบเครื่องมือแล้ว) ต้องกำหนดสีตัวอักษรเอง */
  color: var(--text);
}

.layer-menu-panel[hidden] {
  display: none;
}

.layer-menu-panel .layer-menu-section {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  width: 100%;
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.layer-menu-panel .layer-menu-section:first-child {
  padding-top: 0;
  border-top: 0;
}

.layer-menu-title {
  margin: 0 2px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.6);
}

.layer-menu-panel .toolbar-group {
  width: 100%;
  flex-wrap: wrap;
  justify-content: flex-start;
  padding: 0;
  border: 0;
  background: none;
  backdrop-filter: none;
}

.layer-menu-panel .radar-toggle {
  width: 100%;
  justify-content: flex-start;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border-color: transparent;
  backdrop-filter: none;
  white-space: normal;
  cursor: pointer;
}

.layer-menu-panel .radar-toggle:hover {
  background: rgba(52, 171, 255, 0.14);
}

.layer-menu-panel .radar-toggle:has(input:checked) {
  background: rgba(52, 171, 255, 0.18);
  border-color: rgba(52, 171, 255, 0.35);
}

.layer-menu-panel .radar-toggle--alert:has(input:checked) {
  background: rgba(239, 68, 68, 0.22);
  border-color: rgba(255, 120, 120, 0.5);
}

.map-toggle-button {
  min-height: 40px;
  padding: 8px 12px;
  background: rgba(7, 22, 38, 0.72);
  border-color: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
}

#map {
  width: 100%;
  height: var(--map-height);
}

/* แถบเล่นเรดาร์อยู่ในแถบหัวเรื่อง ระหว่างชื่อระบบกับ pill ด้านขวา
   margin auto ทั้งสองข้างให้อยู่กึ่งกลางช่องว่างที่เหลือ · ไม่บังแผนที่อีก */
.radar-playback {
  flex: 0 1 320px;
  min-width: 220px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: rgba(4, 18, 32, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
}

.radar-playback[hidden] {
  display: none;
}

.radar-play-btn {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  box-shadow: 0 4px 12px rgba(44, 178, 255, 0.35);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.radar-play-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(44, 178, 255, 0.45);
}

.radar-play-icon {
  position: relative;
  display: block;
  width: 14px;
  height: 14px;
}

.radar-play-icon::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-42%, -50%);
  border-style: solid;
  border-width: 7px 0 7px 12px;
  border-color: transparent transparent transparent #052236;
}

.radar-play-icon::after {
  content: "";
  display: none;
}

.radar-play-btn.is-playing .radar-play-icon::before {
  border: none;
  width: 4px;
  height: 14px;
  border-radius: 1px;
  background: #052236;
  transform: translate(-50%, -50%) translateX(-4px);
}

.radar-play-btn.is-playing .radar-play-icon::after {
  content: "";
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 14px;
  border-radius: 1px;
  background: #052236;
  transform: translate(-50%, -50%) translateX(4px);
}

.radar-playback-track {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.radar-playback-caption {
  font-size: 10px;
  color: #d3e7fb;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.radar-timeline {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(168, 197, 255, 0.25);
  outline: none;
  cursor: pointer;
}

.radar-timeline:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.radar-timeline::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-2);
  border: 2px solid #052236;
  box-shadow: 0 0 0 3px rgba(66, 211, 155, 0.25);
  cursor: pointer;
}

.radar-timeline::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-2);
  border: 2px solid #052236;
  box-shadow: 0 0 0 3px rgba(66, 211, 155, 0.25);
  cursor: pointer;
}

.radar-playback-readout {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  min-width: 44px;
}

.radar-playback-readout strong {
  font-size: 13px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.radar-frame-kind {
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--muted);
  white-space: nowrap;
}

.radar-frame-kind[data-kind="latest"] {
  color: #052236;
  background: var(--accent-2);
  border-color: transparent;
}

.radar-frame-kind[data-kind="nowcast"] {
  color: #052236;
  background: #ffcf5c;
  border-color: transparent;
}

/* จอกว้าง: ชื่อ | แถบเรดาร์ | pill อยู่แถวเดียว ห้าม pill ห่อลงบรรทัดใหม่จนหัวเรื่องสูงขึ้น */
@media (min-width: 1361px) {
  .topbar-meta {
    flex-wrap: nowrap;
  }
}

/* จอแคบ: ชื่อระบบ + pill กินที่หมด ให้แถบเรดาร์ลงบรรทัดใหม่ กึ่งกลาง ไม่ยืดสุดจอ */
@media (max-width: 1360px) {
  .topbar {
    flex-wrap: wrap;
  }

  .radar-playback {
    order: 3;
    flex: 1 1 100%;
    max-width: 420px;
  }
}

.leaflet-control-zoom {
  margin-left: 12px !important;
  margin-bottom: 12px !important;
}

.leaflet-tile {
  color: transparent;
  font-size: 0;
}

.map-legend {
  position: absolute;
  z-index: 500;
  right: 10px;
  bottom: 10px;
  width: min(240px, calc(100% - 20px));
  padding: 10px;
  border-radius: 14px;
  background: rgba(7, 22, 38, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  transition: width 160ms ease, padding 160ms ease, transform 160ms ease;
}

.map-legend.is-collapsed {
  width: auto;
  padding: 8px;
}

.legend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.legend-header h3 {
  margin: 0;
  font-size: 13px;
}

.legend-body {
  margin-top: 8px;
}

.legend-toggle-button {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 1px solid rgba(125, 215, 255, 0.42);
  border-radius: 999px;
  background: rgba(44, 178, 255, 0.18);
  color: var(--text);
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
  backdrop-filter: blur(12px);
}

.legend-toggle-button:hover {
  background: rgba(44, 178, 255, 0.28);
  border-color: rgba(168, 226, 255, 0.78);
  transform: translateY(-1px);
}

.legend-toggle-button:focus-visible {
  outline: 3px solid rgba(66, 211, 155, 0.55);
  outline-offset: 3px;
}

.legend-toggle-button span {
  display: block;
  width: 15px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.map-legend.is-collapsed .legend-header {
  justify-content: center;
}

.map-legend.is-collapsed .legend-header h3,
.map-legend.is-collapsed .legend-body {
  display: none;
}

.legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: #d9e8f6;
}

.legend-row + .legend-row {
  margin-top: 6px;
}

.legend-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.marker-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #091521;
  color: var(--text);
}

.popup-card {
  width: 280px;
}

.popup-card img,
.popup-media,
.popup-card iframe,
.popup-card video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  margin: 10px 0;
  background: #02070d;
}

.popup-card img,
.popup-card video {
  object-fit: cover;
}

.popup-card iframe {
  border: 0;
}

.popup-media-shell {
  position: relative;
}

.popup-media-badge {
  position: absolute;
  top: 18px;
  left: 10px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(5, 18, 31, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 11px;
  color: #a7d8ff;
}

.popup-card .popup-fallback {
  display: grid;
  place-items: center;
  padding: 24px 12px;
  color: #a8bfd7;
  font-size: 13px;
  text-align: center;
}

.popup-card h4 {
  margin: 0;
  font-size: 16px;
}

.popup-card p {
  margin: 8px 0 0;
  color: #c7ddf2;
  font-size: 13px;
}

.popup-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.08);
}

.popup-meta {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  font-size: 13px;
}

.popup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 12px;
}

.popup-link {
  display: inline-block;
  color: #76d6ff;
}

.popup-link.is-disabled {
  opacity: 0.55;
  pointer-events: none;
  text-decoration: none;
}

.custom-marker {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.06), 0 6px 16px rgba(0, 0, 0, 0.45);
}

@media (max-width: 1120px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: none;
    overflow: visible;
  }

  .map-panel,
  #map {
    min-height: clamp(420px, calc(100vh - 285px), 720px);
    height: clamp(420px, calc(100vh - 285px), 720px);
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    padding: 9px 12px;
    border-radius: 14px;
    flex-direction: column;
  }

  .eyebrow,
  .subcopy {
    display: none;
  }

  .stats-strip {
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
  }

  .stat-card {
    flex: 0 0 136px;
    padding: 8px 10px;
  }

  .stat-card .value {
    font-size: 18px;
  }

  .topbar-meta {
    width: 100%;
    justify-content: stretch;
  }

  .pill {
    flex: 1 1 0;
    min-width: 0;
  }

  .map-toolbar {
    top: 12px;
    left: 12px;
    right: 12px;
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-group {
    width: 100%;
    justify-content: space-between;
  }

  .radar-toggle {
    justify-content: center;
  }

  .map-actions {
    width: 100%;
    flex-direction: column;
  }

  .map-toggle-button,
  .radar-toggle {
    width: 100%;
    justify-content: center;
  }

  .map-panel,
  #map {
    min-height: clamp(280px, calc(100vh - 520px), 360px);
    height: clamp(280px, calc(100vh - 520px), 360px);
  }
}

/* ── พยากรณ์อากาศ 48 ชม. ในป๊อปอัป (MET Norway) ───────────────────── */
/* ใช้จานสีของธีมมืด (--text, --muted, --accent) ให้กลืนกับป๊อปอัปเดิม */
.popup-forecast {
  margin-top: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(44, 178, 255, 0.08);
  border: 1px solid rgba(168, 197, 255, 0.18);
  font-size: 12px;
  color: var(--muted);
}

.forecast-status {
  color: var(--muted);
  text-align: center;
  padding: 6px 0;
}

.forecast-status.is-error {
  color: var(--danger);
}

.fc-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.fc-icon {
  font-size: 20px;
  line-height: 1;
}

.fc-temp {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.fc-desc {
  color: #c7ddf2;
}

.fc-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px 10px;
}

.fc-grid .fc-wide {
  grid-column: span 2;
}

.fc-grid strong {
  color: var(--text);
  font-weight: 600;
}

.fc-chart {
  display: flex;
  align-items: flex-end;
  gap: 1px;
  height: 40px;
  margin-top: 9px;
  padding: 3px;
  border-radius: 8px;
  background: rgba(2, 7, 13, 0.55);
}

.fc-bar {
  flex: 1 1 0;
  min-width: 0;
  border-radius: 1px;
  background: rgba(168, 197, 255, 0.22);
}

.fc-bar.has-rain {
  background: var(--accent);
}

.fc-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px;
  margin-top: 7px;
  font-size: 11px;
  color: #8fa9c2;
}

.fc-stale {
  color: #f0b429;
}

/* ── ตัวนับบนปุ่มเลือกโหมด (กล้อง / สถานีวัด) ─────────────────────── */
.mode-count {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  vertical-align: 1px;
}

.toolbar-button.active .mode-count {
  background: rgba(0, 0, 0, 0.22);
}

/* ── ป้ายชื่อเขต และคำอธิบายสีฝน ─────────────────────────────────── */
.leaflet-tooltip.boundary-tip {
  background: rgba(9, 21, 33, 0.94);
  border: 1px solid rgba(168, 197, 255, 0.28);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.leaflet-tooltip.boundary-tip::before {
  border-top-color: rgba(9, 21, 33, 0.94);
}

.rain-legend {
  position: absolute;
  right: 12px;
  bottom: 28px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(9, 21, 33, 0.9);
  border: 1px solid rgba(168, 197, 255, 0.2);
  font-size: 11px;
  color: var(--muted);
  pointer-events: none;
}

.rain-legend strong {
  color: var(--text);
  font-size: 11px;
  margin-bottom: 2px;
}

.rain-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rain-legend i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex: none;
}

.rain-legend .rain-legend-source {
  max-width: 190px;
  margin-top: 4px;
  font-size: 10px;
  line-height: 1.4;
  opacity: 0.8;
}

/* ── แจ้งเตือนพื้นที่เสี่ยงน้ำท่วม ───────────────────────────────────── */
.radar-toggle--alert {
  border-color: rgba(239, 68, 68, 0.45);
}

.radar-toggle--alert:has(input:checked) {
  background: rgba(239, 68, 68, 0.22);
  border-color: rgba(239, 68, 68, 0.7);
}

.flood-alert-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.65));
  animation: flood-alert-pulse 1.4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes flood-alert-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

.leaflet-tooltip.flood-alert-tooltip {
  background: rgba(127, 15, 15, 0.95);
  border: 1px solid rgba(255, 120, 120, 0.6);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

.leaflet-tooltip.flood-alert-tooltip::before {
  border-top-color: rgba(127, 15, 15, 0.95);
}

.flood-alert-banner {
  position: absolute;
  top: 64px;
  left: 12px;
  right: 12px;
  z-index: 490;
  max-width: 420px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(80, 10, 10, 0.92);
  border: 1px solid rgba(255, 120, 120, 0.55);
  color: #fff;
  font-size: 12px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
  /* ต้องรับเมาส์/นิ้วได้ ไม่งั้นรายการที่ยาวเกินกรอบจะเลื่อนดูไม่ได้
     (กรอบนี้อยู่นอก #map จึงไม่แย่ง scroll-zoom ของแผนที่) */
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  max-height: calc(100% - 140px);
  animation: flood-alert-banner-glow 2s ease-in-out infinite;
}

.flood-alert-banner.is-clear {
  background: rgba(9, 21, 33, 0.9);
  border-color: rgba(168, 197, 255, 0.28);
  animation: none;
}

.flood-alert-banner > strong {
  display: block;
  margin-bottom: 4px;
}

.flood-alert-banner .flood-alert-source {
  display: block;
  margin-bottom: 6px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 11px;
}

/* สรุปจำนวนจังหวัดเสี่ยงรายภาค (แถวชิปด้านบน) */
.flood-alert-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.flood-alert-chip {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.35);
  border: 1px solid rgba(255, 140, 140, 0.5);
  font-size: 11px;
  white-space: nowrap;
}

.flood-alert-chip.is-zero {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.6);
}

/* รายการแยกภาค — เลื่อนดูได้ในกรอบ */
.flood-alert-regions {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 360px;
  padding-right: 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 150, 150, 0.6) transparent;
}

.flood-alert-region {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.flood-alert-region summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 2px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.flood-alert-region summary::-webkit-details-marker {
  display: none;
}

.flood-alert-region summary::before {
  content: "▸";
  margin-right: 2px;
  transition: transform 0.15s ease;
}

.flood-alert-region[open] summary::before {
  transform: rotate(90deg);
}

.flood-alert-region summary > span:first-child {
  flex: 1 1 auto;
}

.flood-alert-count {
  flex-shrink: 0;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.45);
  font-size: 11px;
  font-weight: 700;
}

.flood-alert-region.is-zero summary {
  color: rgba(255, 255, 255, 0.55);
  font-weight: 500;
}

.flood-alert-region.is-zero .flood-alert-count {
  background: rgba(255, 255, 255, 0.08);
}

.flood-alert-region ul {
  margin: 0 0 6px;
  padding: 0 4px 0 18px;
}

.flood-alert-region li {
  margin-bottom: 3px;
  line-height: 1.45;
}

.flood-alert-none {
  margin: 0 0 6px 16px;
  color: rgba(255, 255, 255, 0.55);
}

@keyframes flood-alert-banner-glow {
  0%, 100% { box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4); }
  50% { box-shadow: 0 8px 26px rgba(239, 68, 68, 0.55); }
}

/* ── วงรวมหมุด (marker cluster) ───────────────────────────────────── */
/* ปิดสไตล์เริ่มต้นของ MarkerCluster.Default.css ที่เป็นสีฟ้าอ่อนบนพื้นสว่าง
   แล้วใช้สีของหมวดแทน ให้กลืนกับธีมมืดของระบบ */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large,
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background: transparent;
}

.cluster-bubble {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
  color: #04121f;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.leaflet-marker-icon .cluster-bubble {
  cursor: pointer;
}

.cluster-bubble.is-mixed {
  /* ในวงมีหลายหมวด — ขอบประบอกว่าสีเป็นแค่หมวดที่มากสุด */
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.65);
}

/* ── แผงเลือกประเทศ ──────────────────────────────────────────────── */
.filter-item.is-busy {
  opacity: 0.6;
  cursor: progress;
}

/* ── ปุ่มเลือก/ยกเลิกทุกประเทศ ────────────────────────────────────── */
.country-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.country-actions .ghost-button {
  flex: 1 1 0;
}

.country-actions .ghost-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── จอมือถือ ─────────────────────────────────────────────────────────────
   วางไว้ท้ายไฟล์โดยตั้งใจ และใช้ specificity เท่ากับกฎเดิม
   เพราะ .app-shell.sidebar-collapsed .content-grid (สองคลาส) ชนะกฎใน
   media query ที่เขียน .content-grid เฉย ๆ — specificity สำคัญกว่าลำดับ
   ผลคือจอ 390px ยังถูกจัดเป็น 2 คอลัมน์ แผนที่จึงเหลือกว้างแค่ 298px
   ────────────────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .content-grid,
  .app-shell.sidebar-collapsed .content-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  /* แถบเครื่องมือ: เดิมเรียงลงเป็นแนวตั้งจนสูง 507px ทับแผนที่ทั้งผืน
     เปลี่ยนเป็นแถวเดียวเลื่อนซ้ายขวา สูงราว 48px */
  .map-toolbar {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
    pointer-events: auto;          /* ต้องรับเมาส์เองจึงจะเลื่อนได้ */
    scrollbar-width: none;
  }

  .map-toolbar::-webkit-scrollbar {
    display: none;
  }

  .map-toolbar > * {
    flex: 0 0 auto;
  }

  .toolbar-group,
  .map-actions {
    width: auto;
    flex-direction: row;
    justify-content: flex-start;
  }

  .map-toggle-button,
  .radar-toggle {
    width: auto;
    white-space: nowrap;
  }

  /* แผนที่ต้องสูงพอใช้งาน — เดิม 324px ซึ่งเล็กเกินไปเมื่อมีแถบเครื่องมือทับ */
  .map-panel,
  #map {
    min-height: min(62vh, 560px);
    height: min(62vh, 560px);
  }

  /* แท็บเมนูซ้าย 4 อัน แคบเกินจนชื่อถูกตัด — ให้เลื่อนแทนการบีบ */
  .sidebar-tabs {
    overflow-x: auto;
    scrollbar-width: none;
  }

  .sidebar-tabs::-webkit-scrollbar {
    display: none;
  }

  .sidebar-tab {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .rain-legend {
    font-size: 10px;
  }

  .flood-alert-banner {
    top: 56px;
    max-width: none;
    font-size: 11px;
  }

  .flood-alert-regions {
    max-height: 30vh;
  }

  /* แถบหัวเรื่อง: pill มี min-width 138px + เนื้อหายาว ทำให้ล้นออกนอกกรอบ
     ให้ห่อลงบรรทัดใหม่แทนการบีบจนตัวอักษรทะลุขอบ */
  .topbar-meta {
    width: 100%;
    justify-content: flex-start;
  }

  .pill {
    flex: 1 1 150px;
    min-width: 0;
    overflow: hidden;
  }

  .pill strong,
  .pill .pill-label {
    overflow-wrap: anywhere;
  }

}
/* ── มุมมอง 3 มิติ (map3d.js) ─────────────────────────────────────────── */
.toolbar-button--3d {
  font-weight: 700;
  letter-spacing: 0.04em;
}

.map3d-overlay {
  position: absolute;
  inset: 0;
  z-index: 1000; /* เหนือแถบเครื่องมือ กรอบแจ้งเตือน และปุ่มของ Leaflet */
  border-radius: inherit;
  overflow: hidden;
  /* ท้องฟ้าด้านหลังเมื่อเอียงแผนที่มากจนเห็นขอบฟ้า */
  background: linear-gradient(180deg, #0b2a4a 0%, #3a78b5 55%, #9cc7ea 100%);
}

.map3d-overlay[hidden] {
  display: none;
}

.map3d-overlay .map3d-canvas {
  /* maplibre-gl.css (โหลดทีหลัง) ตั้ง .maplibregl-map { position: relative } ทับ
     จึงต้องใช้ selector ที่เจาะจงกว่า และกำหนดขนาดตรง ๆ ไม่งั้นแคนวาสสูงแค่ 300px */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map3d-panel {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  width: 230px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(7, 22, 38, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 12px;
}

.map3d-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.map3d-panel-head strong {
  font-size: 13px;
}

.map3d-close {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.map3d-close:hover {
  background: rgba(239, 68, 68, 0.35);
}

.map3d-range {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.map3d-range span {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
}

.map3d-range b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.map3d-range input {
  width: 100%;
  accent-color: var(--accent-2);
}

.map3d-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.map3d-check input {
  accent-color: var(--accent);
}

/* ── เฝ้าระวังน้ำท่วม 3D ── */
.map3d-panel {
  width: 262px;
  max-height: calc(100% - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.map3d-watch {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.map3d-watch > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  list-style: none;
}

.map3d-watch > summary::-webkit-details-marker {
  display: none;
}

.map3d-watch > summary::before {
  content: "▸";
  transition: transform 0.15s ease;
}

.map3d-watch[open] > summary::before {
  transform: rotate(90deg);
}

/* แท็บเลือกโหมด 3D (แสดงทีละโหมดเพื่อให้แผนที่ลื่น) */
.map3d-modes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 3px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
}

.map3d-modes button {
  padding: 6px 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

.map3d-modes button:hover {
  color: var(--text);
}

.map3d-modes button.active {
  background: #1565c0;
  color: #fff;
}

.map3d-watch[hidden] {
  display: none;
}

.map3d-section-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 12.5px;
}

.map3d-watch-count {
  margin-left: auto;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.45);
  font-size: 11px;
}

.map3d-watch-count:empty {
  display: none;
}

.map3d-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 11px;
  color: var(--muted);
}

.map3d-legend i,
.map3d-watch-list i {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 4px;
  border-radius: 3px;
  vertical-align: -1px;
  flex-shrink: 0;
}

.map3d-tour {
  padding: 7px 10px;
  border: 1px solid rgba(239, 68, 68, 0.55);
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.2);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.map3d-tour:hover {
  background: rgba(239, 68, 68, 0.35);
}

.map3d-watch-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 240px;
  overflow-y: auto;
  scrollbar-width: thin;
  counter-reset: watch;
}

.map3d-watch-list button {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  column-gap: 4px;
  width: 100%;
  padding: 5px 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  counter-increment: watch;
}

.map3d-watch-list button::before {
  content: counter(watch) ".";
  min-width: 18px;
  color: var(--muted);
  font-size: 10.5px;
}

.map3d-watch-list button:hover,
.map3d-watch-list button.active {
  background: rgba(52, 171, 255, 0.16);
  border-color: rgba(52, 171, 255, 0.4);
}

.map3d-watch-list small {
  grid-column: 2 / -1;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.35;
}

.map3d-watch-empty {
  color: var(--muted);
}

/* ── จำลองน้ำท่วมล่วงหน้า 3D (map3d-sim.js) ── */
.sim3d-timeline {
  position: absolute;
  left: 286px;
  right: 12px;
  bottom: 30px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(7, 22, 38, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  color: var(--text);
}

.sim3d-timeline[hidden] {
  display: none;
}

.sim3d-play {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: #1565c0;
  color: #fff;
  cursor: pointer;
}

.sim3d-tl-body {
  flex: 1;
  min-width: 0;
}

.sim3d-tl-label {
  font-size: 12.5px;
}

.sim3d-tl-label span {
  color: var(--muted);
}

#sim3dSlider {
  width: 100%;
  margin: 2px 0 0;
  accent-color: #34abff;
}

.sim3d-ticks {
  position: relative;
  height: 14px;
  font-size: 10px;
  color: var(--muted);
}

.sim3d-ticks span {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}

.sim3d-ticks span.today {
  color: #7dd3fc;
  font-weight: 700;
}

.sim3d-speed {
  flex: none;
  min-width: 48px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.sim3d-focus {
  position: absolute;
  top: 12px;
  left: 286px;
  right: 60px;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 640px;
  padding: 8px 8px 8px 12px;
  border-left: 5px solid #1565c0;
  border-radius: 10px;
  background: rgba(7, 22, 38, 0.92);
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.5;
  box-shadow: var(--shadow);
}

.sim3d-focus[hidden] {
  display: none;
}

.sim3d-focus > div {
  flex: 1;
  min-width: 0;
}

.sim3d-focus a {
  color: #7dd3fc;
}

.sim3d-focus button,
.sim3d-popup-btn {
  flex: none;
  padding: 4px 10px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #0f2b46;
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

.sim3d-popup-btn {
  margin-top: 6px;
  background: #1565c0;
  color: #fff;
}

.sim3d-badge {
  display: inline-block;
  padding: 0 7px;
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.sim3d-muted {
  color: var(--muted);
  font-size: 11px;
}

.sim3d-strip {
  display: flex;
  gap: 2px;
  margin: 6px 0 2px;
}

.sim3d-strip i {
  flex: 1;
  height: 10px;
  border-radius: 2px;
}

.sim3d-strip i.today {
  outline: 2px solid #fff;
  outline-offset: 1px;
}

/* ป้ายชื่อที่ฐานแท่งจังหวัด */
.map3d-column-label {
  padding: 2px 8px;
  border: 2px solid;
  border-radius: 999px;
  background: rgba(7, 22, 38, 0.88);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.map3d-column-label b {
  margin-right: 3px;
  color: #fecaca;
}

.map3d-column-label[hidden] {
  display: none;
}

.map3d-hint,
.map3d-status {
  margin: 0;
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--muted);
}

.map3d-status:empty {
  display: none;
}

.map3d-popup .maplibregl-popup-content {
  background: rgba(7, 22, 38, 0.95);
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
  padding: 10px 26px 10px 12px;
  border-radius: 10px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
}

.map3d-popup .maplibregl-popup-close-button {
  color: var(--text);
  font-size: 16px;
}

.map3d-popup.maplibregl-popup-anchor-bottom .maplibregl-popup-tip,
.map3d-popup.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
.map3d-popup.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {
  border-top-color: rgba(7, 22, 38, 0.95);
}

.map3d-popup.maplibregl-popup-anchor-top .maplibregl-popup-tip,
.map3d-popup.maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
.map3d-popup.maplibregl-popup-anchor-top-right .maplibregl-popup-tip {
  border-bottom-color: rgba(7, 22, 38, 0.95);
}

@media (max-width: 720px) {
  .map3d-panel {
    top: 8px;
    left: 8px;
    right: 60px; /* เว้นที่ให้ปุ่มเข็มทิศ/ซูมด้านขวา */
    width: auto;
    max-height: 58%; /* แผงยาวขึ้นเพราะมีรายการเฝ้าระวัง — เว้นแผนที่ไว้ให้เห็นแท่ง 3 มิติ */
    gap: 6px;
    padding: 8px 10px;
  }

  .map3d-watch-list {
    max-height: 150px;
  }

  /* แถบเวลาเต็มความกว้างด้านล่าง, ชิปเส้นทางอยู่เหนือแถบเวลา (แผงอยู่ด้านบนแล้ว) */
  .sim3d-timeline {
    left: 8px;
    right: 8px;
    bottom: 26px;
    gap: 8px;
    padding: 6px 10px;
  }

  .sim3d-focus {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 100px;
    font-size: 11.5px;
  }

  .map3d-hint {
    display: none;
  }
}

/* ── ฝุ่น PM2.5 (pm25.js) ───────────────────────────────────────────── */
.pm25-legend { right: auto; left: 12px; }
.pm25-legend .pm25-est { background: transparent; border: 1.5px dashed #9fb3c8; }
.pm25-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 3px; vertical-align: -1px; border: 1px solid rgba(0, 0, 0, 0.25); }
.leaflet-tooltip.pm25-tip {
  /* tooltip ของ Leaflet ไม่มีความกว้าง ถ้าให้ตัดบรรทัดเฉย ๆ กล่องจะหดเท่าคำเดียว — กำหนดกรอบความกว้างให้ */
  width: max-content;
  min-width: 230px;
  max-width: min(320px, 85vw);
  white-space: normal;
  padding: 10px 12px;
  background: rgba(9, 21, 33, 0.96);
  border: 1px solid rgba(168, 197, 255, 0.3);
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
}
.leaflet-tooltip.pm25-tip::before { border-top-color: rgba(9, 21, 33, 0.96); }
.pm25-card-title { font-size: 14px; font-weight: 700; color: #fff; }
.pm25-card-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.pm25-card-value { display: flex; align-items: center; gap: 10px; margin: 8px 0 6px; }
.pm25-badge { min-width: 58px; padding: 4px 8px; border-radius: 8px; text-align: center; font-size: 20px; font-weight: 800; color: #111; line-height: 1.2; }
.pm25-badge.lv5 { color: #fff; }
.pm25-card-unit { font-size: 11.5px; color: var(--muted); line-height: 1.35; }
.pm25-card-unit b { display: block; color: #fff; font-size: 13px; }
.pm25-card-rows { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0; font-size: 12px; }
.pm25-card-rows dt { color: var(--muted); white-space: nowrap; }
.pm25-card-rows dd { margin: 0; color: var(--text); }
.pm25-card-warn { margin-top: 8px; padding: 6px 8px; border-radius: 6px; background: rgba(255, 162, 0, 0.15); border-left: 3px solid #ffa200; font-size: 12px; }
.pm25-card-note { margin-top: 6px; font-size: 10.5px; color: var(--muted); }
.pm25-banner {
  position: absolute;
  top: 64px;
  right: 12px;
  z-index: 491;
  width: min(340px, calc(100% - 24px));
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(66, 34, 0, 0.94);
  border: 1px solid rgba(255, 162, 0, 0.6);
  color: #fff;
  font-size: 12px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pm25-banner.is-red { background: rgba(90, 12, 12, 0.94); border-color: rgba(240, 70, 70, 0.7); }
.pm25-banner.is-clear { background: rgba(9, 21, 33, 0.9); border-color: rgba(168, 197, 255, 0.28); }
.pm25-banner-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pm25-collapse { background: rgba(255, 255, 255, 0.12); border: 0; color: #fff; border-radius: 6px; width: 26px; height: 22px; cursor: pointer; }
.pm25-banner-source { display: block; margin: 3px 0 6px; color: rgba(255, 255, 255, 0.7); font-size: 10.5px; line-height: 1.4; }
.pm25-banner-body { overflow-y: auto; min-height: 0; }
.pm25-banner.is-collapsed .pm25-banner-body, .pm25-banner.is-collapsed .pm25-banner-source { display: none; }
.pm25-group + .pm25-group { margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, 0.15); }
.pm25-group-head { font-weight: 600; margin-bottom: 4px; }
.pm25-group ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.pm25-group li button { background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.18); color: #fff; border-radius: 8px; padding: 3px 8px; font: inherit; cursor: pointer; }
.pm25-group li button:hover { background: rgba(255, 255, 255, 0.22); }
.pm25-region { opacity: 0.7; font-size: 10.5px; }
.pm25-advice { margin: 6px 0 0; color: rgba(255, 255, 255, 0.85); font-size: 11px; line-height: 1.45; }
.pm25-alert-marker, .pm25-station { background: none; border: 0; }
.pm25-alert-marker span {
  display: inline-block; padding: 2px 7px; border-radius: 12px; font-weight: 700; font-size: 12px; color: #111; white-space: nowrap;
  border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45); animation: pm25-pulse 2s ease-in-out infinite;
}
@keyframes pm25-pulse { 50% { transform: scale(1.12); } }
.pm25-station span {
  display: inline-block; min-width: 26px; padding: 1px 4px; border-radius: 9px; text-align: center; font-size: 11px; font-weight: 700; color: #111;
  border: 1.5px solid rgba(255, 255, 255, 0.95); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
.pm25-station.is-stale span { color: #fff; opacity: 0.75; }
@media (max-width: 720px) {
  .pm25-legend { bottom: 28px; max-width: 46%; }
}
/* คำอธิบายสี PM2.5 อยู่ขวาของปุ่มซูม (มุมล่างซ้าย) ไม่ทับกัน */
.pm25-legend { left: 56px; bottom: 22px; }
@media (max-width: 720px) {
  /* มือถือ: แถบสีแนวนอนบาง ๆ ด้านล่าง ป้ายแจ้งเตือนอยู่เหนือแถบ */
  .pm25-legend { left: 8px; right: 8px; bottom: 22px; max-width: none; flex-direction: row; flex-wrap: wrap; gap: 4px 8px; padding: 6px 8px; font-size: 10px; }
  .pm25-legend strong, .pm25-legend .rain-legend-source { flex-basis: 100%; margin: 0; }
}
@media (max-width: 720px) {
  .pm25-legend { left: 50px; }
}

/* ── จุดบนแผนที่ในเมนูชั้นข้อมูล (แทนแท็บ "เลเยอร์ข้อมูล" ซ้าย + ชิป กล้อง/สถานีวัด) ── */
.layer-menu-panel {
  width: min(330px, calc(100% - 20px));
}

.layer-groups {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.layer-group-head {
  display: flex;
  align-items: stretch;
  gap: 4px;
}

.layer-menu-panel .layer-group-toggle {
  flex: 1;
  min-width: 0;
  font-weight: 700;
}

.layer-menu-panel .layer-group-toggle[data-state="some"] {
  background: rgba(52, 171, 255, 0.1);
  border-color: rgba(52, 171, 255, 0.25);
}

.layer-icon {
  display: inline-flex;
  flex: none;
  color: #7cc4ff;
}

.layer-name {
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}

.layer-count {
  flex: none;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.78);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.layer-group-expand {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.7);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.layer-group-expand:hover,
.layer-group.is-open .layer-group-expand {
  background: rgba(52, 171, 255, 0.14);
  color: #fff;
}

.layer-group-expand svg {
  transition: transform 140ms ease;
}

.layer-group.is-open .layer-group-expand svg {
  transform: rotate(180deg);
}

.layer-group-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 2px 0 4px 14px;
  padding-left: 8px;
  border-left: 2px solid rgba(255, 255, 255, 0.1);
}

.layer-group-items[hidden] {
  display: none;
}

.layer-menu-panel .layer-item {
  padding: 5px 8px;
  font-size: 13px;
}

.layer-item .swatch {
  flex: none;
  width: 10px;
  height: 10px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12);
}

.layer-group-toggle .layer-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer-group-sub {
  font-variant-numeric: tabular-nums;
}

/* ── คำอธิบายสีพยากรณ์ฝน (โผล่เฉพาะตอนแถบเรดาร์อยู่ที่เฟรมพยากรณ์) ── */
.rain-forecast-legend {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 520;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: calc(100% - 24px);
  padding: 7px 10px;
  border-radius: 12px;
  background: rgba(7, 22, 38, 0.86);
  border: 1px solid rgba(255, 207, 92, 0.45);
  backdrop-filter: blur(10px);
  color: var(--muted);
  font-size: 10px;
  pointer-events: none;
}

.rain-forecast-legend[hidden] {
  display: none;
}

.rain-forecast-legend-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
}

.rain-forecast-legend-head strong {
  color: #ffcf5c;
  font-size: 12px;
}

.rain-forecast-legend-scale {
  display: flex;
  gap: 2px;
}

.rain-forecast-legend-scale span {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 26px;
  font-variant-numeric: tabular-nums;
}

.rain-forecast-legend-scale i {
  display: block;
  width: 100%;
  height: 8px;
  border-radius: 2px;
}

.leaflet-image-layer.rain-forecast-image {
  image-rendering: auto;
}

/* ── กล้อง Windy ในป๊อปอัป ───────────────────────────────────────────── */
.popup-media-badge--windy {
  color: #04201c;
  background: #14b8a6;
}

.windy-media iframe.popup-media,
.windy-media img.popup-media {
  display: block;
}

.windy-media img[hidden] {
  display: none;
}

.windy-tabs {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.windy-tab {
  flex: 1;
  padding: 4px 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: inherit;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.windy-tab.is-active {
  background: rgba(20, 184, 166, 0.25);
  border-color: rgba(20, 184, 166, 0.6);
}

.windy-credit {
  margin-top: 4px;
  font-size: 10px;
  color: var(--muted);
}

.windy-credit a {
  color: #5eead4;
}

/* ปุ่มในเมนูชั้นข้อมูล (ไม่ใช่สวิตช์) */
.layer-menu-panel .layer-menu-action {
  color: inherit;
  font: inherit;
  text-align: left;
}

/* ── หน้าต่างแผนที่ Windy ─────────────────────────────────────────────── */
.windy-embed-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(2, 10, 20, 0.7);
}

.windy-embed-modal[hidden] {
  display: none;
}

.windy-embed-dialog {
  display: flex;
  flex-direction: column;
  width: min(1100px, 100%);
  height: min(760px, 100%);
  border-radius: 14px;
  overflow: hidden;
  background: #071626;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  color: var(--text);
}

.windy-embed-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}

.windy-embed-overlays {
  display: flex;
  flex: 1;
  gap: 4px;
  overflow-x: auto;
}

.windy-embed-overlays .toolbar-button {
  padding: 5px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.windy-embed-close {
  flex: none;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: inherit;
  font-size: 15px;
  cursor: pointer;
}

.windy-embed-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #0b1a2a;
}

.windy-embed-foot {
  padding: 5px 10px;
  font-size: 11px;
  color: var(--muted);
}

.windy-embed-foot a {
  color: #5eead4;
}

@media (max-width: 720px) {
  .windy-embed-modal {
    padding: 0;
  }

  .windy-embed-dialog {
    height: 100%;
    border-radius: 0;
  }

  .windy-embed-head {
    flex-wrap: wrap;
  }

  .windy-embed-head strong {
    flex: 1;
  }

  .windy-embed-overlays {
    order: 3;
    flex-basis: 100%;
  }
}

/* ── มุมมองลูกโลก (globe.js) ────────────────────────────────────────── */
.view-type-group {
  margin-left: auto;
}

.view-type-group + .layer-menu {
  margin-left: 0;
}

.globe-view {
  position: absolute;
  inset: 0;
  z-index: 480;
  overflow: hidden;
  border-radius: inherit;
  background: #020a14;
}

.globe-view[hidden] {
  display: none;
}

.globe-canvas {
  position: absolute;
  inset: 0;
}

.globe-status {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(7, 22, 38, 0.85);
  color: var(--text);
  font-size: 13px;
}

.globe-status[hidden] {
  display: none;
}

.globe-controls {
  position: absolute;
  left: 10px;
  bottom: 34px;
  display: flex;
  gap: 6px;
}

.globe-controls .toolbar-button {
  padding: 6px 12px;
  font-size: 12px;
  background: rgba(7, 22, 38, 0.82);
  backdrop-filter: blur(10px);
}

.globe-info {
  position: absolute;
  left: 12px;
  bottom: 10px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.6);
  text-shadow: 0 1px 2px #000;
}

.globe-label {
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(7, 22, 38, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font: 12px/1.4 inherit;
}

.globe-card {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  width: min(340px, calc(100% - 20px));
  overflow: hidden;
  border-radius: 14px;
  background: rgba(7, 22, 38, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  color: var(--text);
}

.globe-card[hidden] {
  display: none;
}

.globe-card-img {
  width: 110px;
  object-fit: cover;
  flex: none;
}

.globe-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 10px 34px 10px 12px;
  font-size: 12px;
}

.globe-card-body strong {
  font-size: 14px;
  line-height: 1.3;
}

.globe-card-body > span {
  color: var(--muted);
}

.globe-card-cat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
}

.globe-card-cat i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.globe-card-open {
  align-self: flex-start;
  margin-top: 4px;
  padding: 5px 10px;
  font-size: 12px;
}

.globe-card-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: inherit;
  cursor: pointer;
}

/* โหมดลูกโลก: ซ่อนคำอธิบาย/ป้ายของชั้นข้อมูลแผนที่ (ชั้นเหล่านั้นไม่ได้วางบนลูกโลก) */
.map-panel.is-globe .map-legend,
.map-panel.is-globe .pm25-legend,
.map-panel.is-globe .pm25-banner,
.map-panel.is-globe .rain-legend,
.map-panel.is-globe .rain-forecast-legend {
  display: none !important;
}

.map-panel.is-globe .leaflet-control-container {
  display: none;
}

/* ภาพย่อในผลค้นหา (มีเฉพาะจุดที่มีภาพจริง — กล้อง Windy, ภาพสด ฯลฯ) */
.search-result-item:has(.search-result-thumb) {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-result-thumb {
  flex: none;
  width: 64px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.06);
}
/* ── เน้นสถานีเสี่ยง (ฝนเกินเกณฑ์ / ระดับน้ำน้ำมาก-ล้นตลิ่ง) ───────────────── */
.risk-marker {
  --risk: #f59e0b;
  position: relative;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.risk-marker.risk-alert { --risk: #ef4444; }
.risk-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--risk);
  opacity: 0.35;
  animation: risk-pulse 1.8s ease-out infinite;
}
.risk-alert .risk-pulse { animation-duration: 1.1s; }
.risk-dot {
  position: relative;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid var(--risk);
  box-shadow: 0 0 0 2px #fff, 0 6px 16px rgba(0, 0, 0, 0.5);
}
.risk-glyph {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--risk);
  color: #fff;
  font: 800 11px/16px system-ui, sans-serif;
  text-align: center;
  box-shadow: 0 0 0 2px #fff;
}
@keyframes risk-pulse {
  0% { transform: scale(0.55); opacity: 0.55; }
  100% { transform: scale(1.35); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .risk-pulse { animation: none; transform: scale(1.1); opacity: 0.3; }
}

.cluster-bubble { position: relative; }
.cluster-bubble.has-risk { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.45), 0 3px 10px rgba(0, 0, 0, 0.45); }
.cluster-risk {
  position: absolute;
  top: -9px;
  right: -14px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 16px;
  color: #fff;
  white-space: nowrap;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}
.cluster-risk.risk-alert { background: #ef4444; }
.cluster-risk.risk-watch { background: #f59e0b; }

.popup-risk {
  margin: 6px 0 8px;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.45;
  border: 1px solid;
}
.popup-risk.risk-alert { background: rgba(239, 68, 68, 0.14); border-color: rgba(239, 68, 68, 0.55); color: #fecaca; }
.popup-risk.risk-watch { background: rgba(245, 158, 11, 0.14); border-color: rgba(245, 158, 11, 0.55); color: #fde68a; }
.popup-risk strong { margin-right: 4px; }
