:root {
  --bg: #0e1118;
  --panel: rgba(17, 21, 30, 0.92);
  --line: rgba(255, 255, 255, 0.09);
  --text: #e8ecf3;
  --muted: #93a0b4;
  --accent: #ffa04d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

#map { position: absolute; inset: 0; background: var(--bg); }

/* ---------- панель ---------- */

#panel {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1000;
  width: 330px;
  max-height: calc(100% - 24px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  scrollbar-width: thin;
}

#panel h1 { margin: 0 0 4px; font-size: 19px; letter-spacing: 0.2px; }
#panel .sub { margin: 0 0 12px; font-size: 12.5px; line-height: 1.45; color: var(--muted); }

.row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.row.grow { flex: 1; }

input[type='search'], input[type='date'], select, button {
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 9px;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); }

input[type='search'] { flex: 1; min-width: 0; }
input[type='date'] { color-scheme: dark; }

button { cursor: pointer; }
button:hover { background: rgba(255, 255, 255, 0.12); }

.ctl-label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); flex: 1; }
.ctl-label select, .ctl-label input { width: 100%; }

.wide { width: 100%; margin-bottom: 8px; border-radius: 8px; padding: 8px; background: rgba(255, 160, 77, 0.14); border-color: rgba(255, 160, 77, 0.35); }
.wide:hover { background: rgba(255, 160, 77, 0.24); }

/* сегментный переключатель закат/рассвет */
.seg { display: flex; flex: 1; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { flex: 1; border: 0; border-radius: 0; background: transparent; padding: 6px 4px; font-size: 13px; }
.seg button.on { background: rgba(255, 160, 77, 0.2); color: var(--accent); font-weight: 600; }

#searchResults { margin: -4px 0 8px; display: flex; flex-direction: column; gap: 4px; }
.search-item { text-align: left; font-size: 12.5px; padding: 6px 9px; }

.muted { color: var(--muted); font-size: 12px; line-height: 1.5; }

#status { min-height: 18px; margin: 6px 0 10px; }

/* ---------- легенда ---------- */

.legend { margin: 4px 0 10px; }
.legend-title { font-size: 12px; color: var(--muted); margin-bottom: 5px; }
#legendBar { height: 12px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, 0.15); }
.legend-months { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin-top: 3px; }

/* ---------- раскрывашка и футер ---------- */

details { margin-bottom: 8px; font-size: 12.5px; }
summary { cursor: pointer; color: var(--accent); }
.about { margin-top: 8px; }
.about p { margin: 0 0 8px; line-height: 1.5; }

#panel footer { border-top: 1px solid var(--line); padding-top: 8px; }
#panel footer a { color: var(--muted); }

/* ---------- попап ---------- */

.leaflet-popup-content-wrapper {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.leaflet-popup-tip { background: var(--panel); }
.leaflet-popup-content { margin: 12px 14px; font: 13px/1.45 system-ui, sans-serif; }

.pp-name { font-weight: 700; font-size: 15px; margin-bottom: 2px; }
.pp-meta { color: var(--muted); font-size: 11.5px; margin-bottom: 8px; }
.pp-sec { font-weight: 600; margin: 7px 0 3px; }
.pp-list { margin: 0; padding-left: 18px; }
.pp-list li { margin: 1px 0; }
.pp-none { color: var(--muted); font-size: 12px; }
.pp-tol { color: var(--muted); font-size: 11px; margin-top: 7px; }
.pp-next { margin-top: 8px; padding: 7px 9px; border-radius: 8px; background: rgba(255, 160, 77, 0.13); }

/* ---------- оверлеи ---------- */

#loading {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
}
#loading.hidden { display: none; }

.spin {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#toast {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  z-index: 1300;
  background: #2b1c10;
  border: 1px solid rgba(255, 160, 77, 0.5);
  color: #ffd9b3;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  max-width: min(90vw, 480px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Leaflet-контролы в тёмной теме */
.leaflet-control-zoom a, .leaflet-control-attribution { background: rgba(17, 21, 30, 0.85) !important; color: var(--muted) !important; }
.leaflet-control-zoom a:hover { background: rgba(40, 48, 64, 0.95) !important; }
.leaflet-control-attribution a { color: #b8c4d6 !important; }
.leaflet-control-scale-line { background: rgba(17, 21, 30, 0.7) !important; color: var(--text) !important; border-color: var(--muted) !important; }

/* Светлые тайлы OSM, тонированные под тёмную тему карты */
.leaflet-tile-pane {
  filter: invert(1) hue-rotate(185deg) brightness(0.92) contrast(0.9) saturate(0.35) brightness(0.82);
}

/* ---------- мобильная версия ---------- */

@media (max-width: 640px) {
  #panel {
    top: auto;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 46vh;
    border-radius: 14px 14px 0 0;
  }
  .leaflet-control-attribution { font-size: 9px; }
}
