:root {
  color-scheme: dark;
  --background: #111525;
  --panel: #1d2239;
  --panel-soft: #252c48;
  --text: #f7f8ff;
  --muted: #aab1c9;
  --accent: #a7eb78;
  --accent-deep: #70c74e;
  --line: rgba(197, 230, 178, 0.23);
  --danger: #ff9b9b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--background);
}

button, input { font: inherit; }
button { cursor: pointer; }

.app-shell {
  display: grid;
  grid-template-columns: minmax(330px, 400px) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: relative;
  z-index: 2;
  overflow-y: auto;
  padding: 26px 22px 32px;
  background: linear-gradient(160deg, #202640 0%, #171b2d 100%);
  box-shadow: 8px 0 28px rgba(0, 0, 0, 0.24);
}

.brand-row, .section-heading, .button-row, .location-list-item, .nearby-list-item {
  display: flex;
  align-items: center;
}

.brand-row { justify-content: space-between; margin-bottom: 22px; }
.section-heading { justify-content: space-between; gap: 12px; }
.compact-heading { align-items: flex-start; }

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.14em;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.7rem, 4vw, 2.25rem); letter-spacing: -0.045em; }
h2 { margin-bottom: 0; font-size: 1rem; letter-spacing: -0.018em; }

.location-count {
  min-width: 32px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
}

.location-card, .nearby-section, .all-locations-section {
  margin-top: 16px;
  padding-top: 17px;
  border-top: 1px solid var(--line);
}

.location-card:first-of-type { margin-top: 0; }

.muted, .popup-category, .popup-distance { color: var(--muted); }
.muted { margin: 12px 0; font-size: 0.83rem; line-height: 1.45; }

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #7c849b;
  box-shadow: 0 0 0 4px rgba(124, 132, 155, 0.14);
}
.status-dot.is-active { background: var(--accent); box-shadow: 0 0 0 4px rgba(167, 235, 120, 0.17); }
.status-dot.is-error { background: var(--danger); box-shadow: 0 0 0 4px rgba(255, 155, 155, 0.15); }

.button-row { gap: 12px; }
.primary-button, .secondary-button, .text-button {
  border: 0;
  border-radius: 10px;
  font-weight: 700;
  transition: transform 160ms ease, background 160ms ease;
}
.primary-button, .secondary-button { padding: 10px 13px; }
.primary-button { color: #173013; background: var(--accent); }
.primary-button:hover { background: #c0f79a; transform: translateY(-1px); }
.secondary-button { color: var(--text); background: var(--panel-soft); border: 1px solid var(--line); }
.secondary-button:hover { background: #303755; }
.text-button { padding: 5px 0; color: var(--muted); background: transparent; font-size: 0.78rem; }
.text-button:hover { color: var(--text); }
.full-width { width: 100%; }

.nearby-list, .location-list { padding: 0; margin: 12px 0 0; list-style: none; }
.nearby-list { display: grid; gap: 8px; }
.nearby-list-item, .location-list-item { gap: 10px; }
.nearby-list-item { padding: 9px 0; border-bottom: 1px solid rgba(197, 230, 178, 0.12); }
.nearby-list-item:last-child { border-bottom: 0; }
.nearby-number {
  display: grid;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  color: #173013;
  background: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
}
.nearby-name { flex: 1; font-size: 0.88rem; font-weight: 700; }
.nearby-distance { color: var(--accent); font-size: 0.81rem; font-variant-numeric: tabular-nums; }
.empty-state { color: var(--muted); font-size: 0.82rem; line-height: 1.45; }

.add-card .muted { margin-bottom: 11px; }
.add-form { display: grid; gap: 11px; margin-top: 12px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 0.73rem; font-weight: 700; }
input {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid rgba(197, 230, 178, 0.25);
  border-radius: 8px;
  color: var(--text);
  background: #171c30;
  outline: none;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(167, 235, 120, 0.12); }
.coordinate-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

.all-locations-section { padding-bottom: 4px; }
.location-list { display: grid; gap: 2px; }
.location-list-item {
  justify-content: space-between;
  min-height: 31px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(197, 230, 178, 0.08);
}
.location-link {
  overflow: hidden;
  padding: 0;
  border: 0;
  color: var(--text);
  background: none;
  font-size: 0.8rem;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.location-link:hover { color: var(--accent); }
.list-distance { flex: 0 0 auto; margin-left: 10px; color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.custom-mark { color: var(--accent); }

.map-panel { position: relative; height: 100vh; min-height: 600px; }
#map { width: 100%; height: 100%; background: #dce2e7; }
.map-hint, .pick-banner {
  position: absolute;
  z-index: 500;
  left: 18px;
  color: #29313c;
  background: rgba(255, 255, 255, 0.93);
  box-shadow: 0 7px 20px rgba(22, 31, 44, 0.18);
  backdrop-filter: blur(8px);
}
.map-hint { bottom: 22px; padding: 9px 12px; border-radius: 8px; font-size: 0.75rem; }
.pick-banner { top: 18px; display: flex; align-items: center; gap: 16px; padding: 10px 10px 10px 14px; border-radius: 9px; font-size: 0.82rem; font-weight: 700; }
.pick-banner button { width: 24px; height: 24px; border: 0; border-radius: 6px; color: #29313c; background: #e7edf0; font-size: 1.2rem; line-height: 1; }

/* Leaflet alapstílusok helyben: a térkép akkor is egyben marad, ha egy külső CDN-stílus nem töltődik be. */
.leaflet-container {
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
  outline-offset: 1px;
}
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  top: 0;
  left: 0;
}
.leaflet-pane { z-index: 400; }
.leaflet-tile-pane { z-index: 200; }
.leaflet-overlay-pane { z-index: 400; }
.leaflet-shadow-pane { z-index: 500; }
.leaflet-marker-pane { z-index: 600; }
.leaflet-tooltip-pane { z-index: 650; }
.leaflet-popup-pane { z-index: 700; }
.leaflet-map-pane svg,
.leaflet-map-pane canvas,
.leaflet-zoom-box { z-index: 200; }
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}
.leaflet-container .leaflet-tile {
  max-width: none !important;
  max-height: none !important;
  width: auto;
  padding: 0;
}
.leaflet-tile { visibility: hidden; }
.leaflet-tile-loaded { visibility: inherit; }
.leaflet-zoom-animated { transform-origin: 0 0; }
.leaflet-control { position: relative; z-index: 800; pointer-events: auto; }
.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}
.leaflet-top { top: 0; }
.leaflet-right { right: 0; }
.leaflet-bottom { bottom: 0; }
.leaflet-left { left: 0; }
.leaflet-top .leaflet-control,
.leaflet-bottom .leaflet-control { margin: 12px; }
.leaflet-control-zoom {
  overflow: hidden;
  border: 1px solid rgba(28, 45, 55, 0.2);
  border-radius: 7px;
  box-shadow: 0 2px 7px rgba(19, 31, 38, 0.18);
}
.leaflet-control-zoom a {
  display: block;
  width: 30px;
  height: 30px;
  border-bottom: 1px solid rgba(28, 45, 55, 0.14);
  color: #27343f;
  background: rgba(255, 255, 255, 0.94);
  font-size: 20px;
  line-height: 28px;
  text-align: center;
  text-decoration: none;
}
.leaflet-control-zoom a:last-child { border-bottom: 0; }
.leaflet-control-attribution {
  padding: 2px 5px;
  color: #374550;
  background: rgba(255, 255, 255, 0.75);
  font-size: 10px;
}
.leaflet-control-attribution a { color: inherit; }
.leaflet-popup { position: absolute; text-align: center; }
.leaflet-popup-content-wrapper { border-radius: 8px; }
.leaflet-popup-content { line-height: 1.4; }
.leaflet-popup-tip-container {
  position: absolute;
  left: 50%;
  width: 40px;
  height: 20px;
  margin-left: -20px;
  overflow: hidden;
  pointer-events: none;
}
.leaflet-popup-tip {
  width: 17px;
  height: 17px;
  margin: -10px auto 0;
  transform: rotate(45deg);
}
.leaflet-popup-close-button {
  position: absolute;
  top: 0;
  right: 0;
  padding: 4px 6px 0 0;
  border: 0;
  background: transparent;
  font: 16px/14px Tahoma, Verdana, sans-serif;
  text-decoration: none;
}
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #1d2239; color: var(--text); }
.leaflet-popup-content { min-width: 155px; margin: 13px 15px; }
.leaflet-popup-close-button { color: var(--text) !important; }
.popup-content p { margin-bottom: 5px; }
.popup-content h3 { margin-bottom: 7px; font-size: 0.98rem; }
.popup-category { font-size: 0.67rem; font-weight: 700; letter-spacing: 0.08em; }
.popup-distance { margin-bottom: 0 !important; font-size: 0.78rem; }

.place-marker, .user-marker { position: absolute; background: transparent; border: 0; }
.place-pin {
  display: grid;
  position: relative;
  width: 18px;
  height: 18px;
  place-items: center;
  border: 3px solid #29304a;
  border-radius: 50% 50% 50% 0;
  background: #f9fbfb;
  box-shadow: 0 2px 5px rgba(26, 39, 48, 0.32);
  transform: rotate(-45deg);
}
.place-pin::after { width: 4px; height: 4px; border-radius: 50%; background: var(--accent-deep); content: ""; }
.place-marker.is-nearest .place-pin { width: 26px; height: 26px; border-color: #1b3030; background: var(--accent); }
.place-marker.is-nearest .place-pin::after { display: none; }
.nearest-number { color: #173013; font-size: 0.76rem; font-weight: 900; transform: rotate(45deg); }
.distance-label {
  position: absolute;
  top: -19px;
  left: 50%;
  padding: 2px 4px;
  border-radius: 4px;
  color: #202a33;
  background: rgba(255, 255, 255, 0.91);
  box-shadow: 0 1px 3px rgba(26, 39, 48, 0.16);
  font-size: 9px;
  font-weight: 800;
  line-height: 1.1;
  transform: translateX(-50%);
  white-space: nowrap;
}
.user-marker-dot {
  width: 19px;
  height: 19px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #2477d6;
  box-shadow: 0 0 0 7px rgba(36, 119, 214, 0.2), 0 2px 7px rgba(0, 0, 0, 0.25);
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { max-height: none; padding: 20px 18px 24px; overflow: visible; }
  .map-panel { height: 64vh; min-height: 420px; }
  #map { min-height: 64vh; }
  .all-locations-section { max-height: 280px; overflow: auto; }
}

@media (max-width: 420px) {
  .sidebar { padding-inline: 15px; }
  .button-row { align-items: flex-start; flex-direction: column; }
  .map-hint { max-width: calc(100% - 36px); }
}
