/* ── Base ──────────────────────────────────────────────────── */
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 12px;
  background: #050e18;
  color: #c0d0f0;
}

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

/* ── Leaflet dark overrides ────────────────────────────────── */
.leaflet-popup-content-wrapper {
  background: rgba(8, 16, 32, 0.95);
  border: 1px solid #1a3a70;
  border-radius: 8px;
  color: #c0d0f0;
  box-shadow: 0 4px 20px rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
}
.leaflet-popup-tip-container { display: none; }
.leaflet-popup-close-button { color: #4a6a90 !important; font-size: 16px !important; top: 6px !important; right: 8px !important; }
.leaflet-popup-close-button:hover { color: #c0d0f0 !important; background: none !important; }
.leaflet-popup-content { margin: 10px 14px 10px; }
.leaflet-control-attribution {
  background: rgba(5,10,20,0.8) !important;
  color: #3a5a80 !important;
  font-size: 9px !important;
  border-top-left-radius: 4px !important;
}
.leaflet-control-attribution a { color: #4a6a90 !important; }
.leaflet-bar { border: 1px solid #1a3060 !important; border-radius: 6px !important; overflow: hidden; }
.leaflet-bar a {
  background: rgba(8,16,32,0.92) !important;
  border-bottom: 1px solid #1a3060 !important;
  color: #a0c0f0 !important;
  font-size: 16px !important;
  width: 32px !important; height: 32px !important;
  line-height: 32px !important;
  transition: background 0.15s;
}
.leaflet-bar a:last-child { border-bottom: none !important; }
.leaflet-bar a:hover { background: rgba(26,45,80,0.95) !important; color: #e0f0ff !important; }
.leaflet-bar a.leaflet-disabled { color: #2a3a50 !important; }

/* ── Floating button base ──────────────────────────────────── */
.mc-btn {
  box-sizing: border-box;
  width: 34px; height: 34px;
  padding: 0; margin: 0;
  -webkit-appearance: none; appearance: none;
  background: rgba(8,16,32,0.92);
  border: 1px solid #1a3a70;
  border-radius: 6px;
  color: #a0c0f0;
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
  backdrop-filter: blur(6px);
  line-height: 1;
}
.mc-btn:hover { background: rgba(20,40,80,0.95); color: #e8f4ff; }
.mc-btn-sm { width: 28px; height: 34px; }
.mc-link { color: #a0c0f0; }

/* ── Sidebar ───────────────────────────────────────────────── */
#ms-sidebar {
  position: fixed;
  top: 10px; left: 10px;
  z-index: 500;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  pointer-events: none;
}
#ms-sidebar > * { pointer-events: auto; }

#ms-toggle {
  width: 34px; height: 34px;
  background: rgba(8,16,32,0.92);
  border: 1px solid #1a3a70;
  border-radius: 6px;
  color: #a0c0f0;
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
  backdrop-filter: blur(6px);
  line-height: 1;
}
#ms-toggle:hover { background: rgba(20,40,80,0.95); color: #e8f4ff; }

.ms-panel {
  width: 0; opacity: 0; overflow: hidden;
  transition: width 0.22s ease, opacity 0.18s ease;
  background: rgba(6,12,26,0.94);
  border: 1px solid #1a3060;
  border-radius: 8px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
}
#ms-sidebar.open .ms-panel {
  width: 210px; opacity: 1; overflow-y: auto;
}

.ms-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px 9px;
  border-bottom: 1px solid #0e1e3a;
  flex-shrink: 0;
}
.ms-hub-link { display: flex; align-items: center; opacity: 0.85; }
.ms-hub-link:hover { opacity: 1; filter: drop-shadow(0 0 4px #00EE55); }
.ms-title {
  font-size: 11px; font-weight: 700; color: #b0d0f8;
  letter-spacing: 0.4px; text-shadow: 0 0 8px rgba(80,140,255,0.4);
}

.ms-section-lbl {
  font-size: 8.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: #2a4a70;
  padding: 8px 12px 3px;
  flex-shrink: 0;
}

.ms-layers {
  padding: 0 8px 6px;
  display: flex; flex-direction: column; gap: 1px;
}
.ms-layer-row {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 6px;
  border-radius: 5px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
}
.ms-layer-row:hover { background: rgba(20,50,110,0.4); }
.ms-layer-row input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 13px; height: 13px;
  border: 1px solid #2a4a80;
  border-radius: 2px;
  background: #06101e;
  cursor: pointer; flex-shrink: 0;
  position: relative;
  transition: background 0.1s, border-color 0.1s;
}
.ms-layer-row input:checked { background: #1044BB; border-color: #4a8aee; }
.ms-layer-row input:checked::after {
  content: '✓'; position: absolute; top: -2px; left: 1px;
  font-size: 11px; color: #fff; line-height: 1;
}
.ms-layer-icon { font-size: 13px; flex-shrink: 0; line-height: 1; }
.ms-layer-name { flex: 1; font-size: 11px; color: #8aaace; }
.ms-layer-badge {
  font-size: 9px; color: #3a5a80;
  min-width: 20px; text-align: right; flex-shrink: 0;
}
.ms-layer-badge.live { color: #22bb44; }

.ms-legend {
  padding: 0 12px 6px;
  display: flex; flex-direction: column; gap: 4px;
}
.ms-leg-row {
  display: flex; align-items: center; gap: 7px;
  font-size: 10px; color: #5a7a9a;
}
.ms-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0; opacity: 0.85;
}
.ms-swatch {
  width: 14px; height: 7px; border-radius: 2px;
  flex-shrink: 0; opacity: 0.7;
}

.ms-tip {
  font-size: 9.5px; color: #3a5a70;
  padding: 6px 12px 4px;
  line-height: 1.5;
  font-style: italic;
}

.ms-attr {
  padding: 8px 12px 10px;
  font-size: 8.5px; color: #2a4060;
  border-top: 1px solid #0a1428;
  margin-top: auto;
  line-height: 1.9;
}
.ms-attr a { color: #3a5a80; text-decoration: none; }
.ms-attr a:hover { color: #6a90c0; }

/* ── Search (top-right) ────────────────────────────────────── */
#mc-search {
  position: fixed;
  top: 10px; right: 10px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.mc-search-row {
  display: flex; align-items: center; gap: 4px;
}
#search-input {
  width: 210px; height: 34px;
  padding: 0 10px;
  background: rgba(8,16,32,0.92);
  border: 1px solid #1a3a70;
  border-radius: 6px;
  color: #c0d0f0;
  font-size: 11px; font-family: inherit;
  outline: none;
  backdrop-filter: blur(6px);
  transition: border-color 0.15s;
}
#search-input:focus { border-color: #4a8aee; }
#search-input::placeholder { color: #2a4060; }
.mc-search-results {
  width: 252px;
  background: rgba(6,12,26,0.96);
  border: 1px solid #1a3060;
  border-radius: 6px;
  overflow: hidden;
  backdrop-filter: blur(12px);
}
.mc-search-results:empty { display: none; }
.mc-result {
  padding: 7px 10px;
  font-size: 10.5px; color: #8aaace;
  cursor: pointer;
  border-bottom: 1px solid #0a1428;
  line-height: 1.4;
  transition: background 0.1s;
}
.mc-result:hover { background: rgba(20,50,100,0.6); color: #d0e4fc; }
.mc-result:last-child { border-bottom: none; }
.mc-search-msg {
  padding: 8px 10px;
  font-size: 10px; color: #3a5a70;
  font-style: italic;
}

/* ── Bottom-left controls ──────────────────────────────────── */
#mc-controls {
  position: fixed;
  bottom: 34px; left: 10px;
  z-index: 500;
  display: flex; flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

/* ── Click popup ────────────────────────────────────────────── */
.mp-ll { font-size: 9px; color: #3a5a80; margin-bottom: 6px; font-family: monospace; }
.mp-temp { font-size: 22px; font-weight: 700; color: #e8f4ff; }
.mp-wx-row { font-size: 11px; color: #90b0d0; line-height: 1.6; margin-top: 2px; }
.mp-marine { font-size: 11px; color: #40b8d8; margin-top: 6px; padding-top: 6px; border-top: 1px solid #0e2040; }
.mp-loading { font-size: 11px; color: #3a5a70; font-style: italic; padding: 4px 0; }

/* ── Globe overlay ──────────────────────────────────────────── */
#globe-wrap {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #050e18;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.55s ease;
  overflow: hidden;
}
#globe-wrap.globe-active {
  opacity: 1;
  pointer-events: auto;
}
#globe-wrap canvas { display: block; }

/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 600px) {
  #search-input { width: 150px; }
  .mc-search-results { width: 186px; }
  #ms-sidebar.open .ms-panel { width: min(180px, calc(100vw - 70px)); }
}
