:root {
  --bg: #0b1020;
  --panel: #131a2d;
  --panel-2: #18213a;
  --border: rgba(255,255,255,0.08);
  --text: #edf2ff;
  --muted: #aab6d3;
  --accent: #79a8ff;
  --danger: #ff7f7f;
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.26);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button, input {
  font: inherit;
}

.layout {
  display: grid;
  grid-template-columns: 390px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #0d1324 0%, #10182c 100%);
  border-right: 1px solid var(--border);
  padding: 18px;
  overflow: auto;
}

.panel {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 1.7rem; margin-bottom: 10px; }
h2 { font-size: 1.05rem; margin-bottom: 12px; }
.muted { color: var(--muted); line-height: 1.55; }
.small-print ul { margin: 0; padding-left: 18px; color: var(--muted); }
.small-print li + li { margin-top: 8px; }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.toolbar.compact { margin-bottom: 0; }
button {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--accent);
  color: #08111f;
  font-weight: 700;
  cursor: pointer;
}
button:hover { filter: brightness(1.05); }
button.danger {
  background: rgba(255, 127, 127, 0.2);
  color: #ffd4d4;
  border: 1px solid rgba(255,127,127,0.35);
}
button.ghost {
  background: rgba(255,255,255,0.06);
  color: var(--text);
}
button.small {
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 0.92rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.manual-form {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.form-row,
.form-grid {
  margin-bottom: 12px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
label {
  display: block;
  font-size: 0.92rem;
  color: var(--muted);
}
input[type="text"],
input[type="number"] {
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--text);
  padding: 11px 12px;
}

.points-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.badge {
  min-width: 32px;
  height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(121, 168, 255, 0.15);
  color: #bfd3ff;
  font-weight: 700;
}
.points-list.empty {
  color: var(--muted);
}
.point-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255,255,255,0.03);
}
.point-card + .point-card {
  margin-top: 12px;
}
.point-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.point-title strong {
  display: block;
  font-size: 1rem;
}
.point-meta {
  color: var(--muted);
  font-size: 0.88rem;
}
.point-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}
.stat {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: rgba(0,0,0,0.15);
}
.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 4px;
}
.stat-value {
  font-size: 1rem;
  font-weight: 700;
}
.point-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.map-shell {
  position: relative;
  min-height: 100vh;
}
#map {
  width: 100%;
  height: 100vh;
}
.legend,
.status-banner {
  position: absolute;
  z-index: 500;
  backdrop-filter: blur(10px);
  background: rgba(11, 16, 32, 0.8);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.legend {
  right: 16px;
  bottom: 16px;
  padding: 12px 14px;
  font-size: 0.92rem;
}
.legend > div + div { margin-top: 8px; }
.status-banner {
  top: 16px;
  right: 16px;
  left: 16px;
  padding: 12px 14px;
}
.hidden { display: none; }
.legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  margin-right: 8px;
}
.legend-dot.moon { background: #f8f1b5; }
.legend-dot.cloud { background: #93a2c8; }
.legend-dot.wind { background: #79a8ff; }
.legend-dot.sun { background: #ffd166; }
.legend-separator {
  margin: 10px 0 8px;
  height: 1px;
  background: rgba(255,255,255,0.12);
}
.legend-heading {
  margin-bottom: 6px;
  font-weight: 700;
  color: #fff2be;
}
.legend-sun-times {
  line-height: 1.45;
  color: var(--muted);
}
.legend-sun-times strong {
  color: var(--text);
}

.wind-arrow-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 2px solid rgba(121, 168, 255, 0.9);
  background: rgba(11, 16, 32, 0.9);
  box-shadow: 0 0 0 4px rgba(121, 168, 255, 0.16);
}
.wind-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  font-size: 22px;
  line-height: 22px;
  color: #dbe6ff;
  transform-origin: center center;
}
.point-label {
  margin-top: 6px;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.75);
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.leaflet-div-icon {
  background: transparent;
  border: 0;
}
.popup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.popup-item {
  border: 1px solid #e1e6f0;
  border-radius: 10px;
  padding: 8px;
}
.popup-item b {
  display: block;
  font-size: 0.8rem;
  color: #4b5f83;
  margin-bottom: 4px;
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    max-height: 48vh;
  }
  #map,
  .map-shell { min-height: 52vh; height: 52vh; }
}


.mobile-topbar,
.sidebar-backdrop,
.mobile-close-btn {
  display: none;
}

.mobile-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1200;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(11, 16, 32, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.mobile-menu-btn,
.mobile-close-btn {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.07);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 700;
}

.mobile-topbar-title {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

@media (max-width: 980px) {
  body {
    overflow: hidden;
  }

  .mobile-topbar {
    display: flex;
  }

  .layout {
    display: block;
    min-height: 100dvh;
  }

  .sidebar {
    position: fixed;
    z-index: 1300;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(92vw, 420px);
    max-height: 100dvh;
    transform: translateX(-102%);
    transition: transform 0.25s ease;
    border-right: 1px solid var(--border);
    border-bottom: 0;
    padding: 14px;
    overscroll-behavior: contain;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1250;
    background: rgba(0,0,0,0.45);
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .mobile-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    flex: 0 0 auto;
  }

  .map-shell,
  #map {
    min-height: 100dvh;
    height: 100dvh;
  }

  .map-shell {
    padding-top: 58px;
  }

  #map {
    height: calc(100dvh - 58px);
  }

  .status-banner {
    top: 70px;
    left: 10px;
    right: 10px;
    padding: 10px 12px;
    font-size: 0.92rem;
  }

  .legend {
    right: 10px;
    left: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    font-size: 0.86rem;
    padding: 10px 12px;
  }

  .toolbar {
    gap: 8px;
  }

  .toolbar button,
  .manual-form button,
  .point-actions button {
    min-height: 44px;
  }

  .toolbar button {
    flex: 1 1 calc(50% - 8px);
  }

  .form-grid,
  .point-stats,
  .popup-grid {
    grid-template-columns: 1fr;
  }

  .point-card {
    padding: 12px;
  }

  .point-title {
    align-items: center;
  }

  .point-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .point-actions button {
    width: 100%;
  }

  .leaflet-control-zoom {
    margin-top: 70px !important;
  }
}

@media (max-width: 560px) {
  .toolbar button,
  .point-actions {
    grid-template-columns: 1fr;
    flex-basis: 100%;
  }

  .toolbar button {
    flex: 1 1 100%;
  }

  .sidebar {
    width: 100vw;
    border-right: 0;
  }

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

  h1 {
    font-size: 1.35rem;
  }
}

.legend-hidden {
  display: none;
}
