:root {
  --bg: #0e1a2b;
  --panel: #16283f;
  --panel-2: #1d3350;
  --border: #2b4a6f;
  --text: #e6f0fa;
  --muted: #8fa8c4;
  --accent: #ffd166;
  --danger: #ef476f;
  --ok: #06d6a0;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== Header ===== */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border-bottom: 1px solid var(--border);
  z-index: 1000;
  position: relative;
}

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

.logo-emoji { font-size: 2rem; }

.logo h1 {
  font-size: 1.15rem;
  letter-spacing: 0.05em;
}

.tagline {
  font-size: 0.7rem;
  color: var(--muted);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 14px;
}

.status-pill {
  font-size: 0.75rem;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
}

.status-pill.ok { border-color: var(--ok); color: var(--ok); }
.status-pill.err { border-color: var(--danger); color: var(--danger); }

/* Toggle switch */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  user-select: none;
}

.toggle input { display: none; }

.slider {
  width: 42px;
  height: 22px;
  background: #3a5578;
  border-radius: 999px;
  position: relative;
  transition: background 0.25s;
}

.slider::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 2px;
  transition: transform 0.25s;
}

.toggle input:checked + .slider { background: var(--accent); }
.toggle input:checked + .slider::after { transform: translateX(20px); }

.toggle-label { color: var(--muted); min-width: 68px; }

/* ===== Map ===== */
.map-wrap {
  flex: 1;
  position: relative;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* ===== Legend ===== */
.legend {
  position: absolute;
  top: 74px;
  right: 14px;
  z-index: 500;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.75rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  width: 210px;
}

.legend h3 {
  font-size: 0.8rem;
  margin-bottom: 8px;
  color: var(--accent);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.sw-rain { background: #00b4d8; }
.sw-temp { background: linear-gradient(90deg, #ef476f, #ffd166); }
.sw-fake { background: #9b5de5; }

.legend-note {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  color: var(--muted);
  line-height: 1.5;
}

/* ===== Popup ===== */
.popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(340px, 90vw);
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 14px;
  padding: 20px;
  z-index: 2000;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}

.popup.hidden { display: none; }

.popup-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.popup-close:hover { color: var(--danger); }

.popup h2 {
  font-size: 1.05rem;
  margin-bottom: 6px;
  padding-right: 20px;
}

.popup .city-flag {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.popup .big-fake {
  font-size: 1.6rem;
  font-weight: bold;
  color: var(--accent);
  margin: 10px 0;
}

.popup .real-note {
  font-size: 0.75rem;
  color: var(--muted);
  border-top: 1px dashed var(--border);
  padding-top: 10px;
  margin-top: 10px;
  line-height: 1.6;
}

.popup .stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.popup .stat {
  background: var(--panel-2);
  border-radius: 8px;
  padding: 8px 10px;
}

.popup .stat .label { font-size: 0.65rem; color: var(--muted); }
.popup .stat .value { font-size: 1rem; font-weight: bold; }

/* ===== Footer ===== */
.site-footer {
  padding: 8px 16px;
  font-size: 0.7rem;
  color: var(--muted);
  background: var(--panel);
  border-top: 1px solid var(--border);
  z-index: 1000;
  line-height: 1.6;
}

/* ===== Leaflet custom ===== */
.leaflet-container {
  background: #0d1b2a;
  font-family: inherit;
}

.leaflet-tile { filter: saturate(0.5) brightness(0.85) sepia(0.25); }

/* Custom marker */
.city-marker {
  width: 34px;
  height: 34px;
}

.city-dot {
  width: 34px;
  height: 34px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  font-size: 16px;
}

.city-dot.rain { background: #00b4d8; }
.city-dot.sunny-true { background: #f6b93b; }
.city-dot.cold { background: #8db9e8; }
.city-dot.hot { background: #ef476f; }
.city-dot.mixed { background: #9b5de5; }

.city-dot span {
  transform: rotate(45deg);
}

.leaflet-popup-content-wrapper {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.leaflet-popup-tip {
  background: var(--panel-2);
  border: 1px solid var(--border);
}

.leaflet-popup-content { margin: 12px 14px; line-height: 1.4; }
.leaflet-popup-content a { color: var(--accent); }

/* mobile */
@media (max-width: 640px) {
  .legend { display: none; }
  .logo h1 { font-size: 1rem; }
  .tagline { display: none; }
}