:root {
  --glass: rgba(22, 26, 34, 0.86);
  --glass-hover: rgba(36, 42, 54, 0.92);
  --line: rgba(255, 255, 255, 0.08);
  --text: #f3f4f6;
  --muted: #a3aab8;
  --accent: #f7c948;
  --accent-ink: #2a2105;
  --fog-a: #e3e8e6;
  --fog-b: #c7d0cf;
  --radius: 999px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.28), 0 1px 3px rgba(0, 0, 0, 0.2);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--fog-b); font-family: var(--font); color: var(--text); }

#map {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at 50% 45%, var(--fog-a) 0%, var(--fog-b) 75%);
  cursor: grab;
}
#map.leaflet-dragging { cursor: grabbing; }
.leaflet-container { font-family: var(--font); background: transparent; outline: none; }
#map.overzoom .leaflet-tile { image-rendering: pixelated; }
.leaflet-control-container { display: none; }

/* Glass pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 15px; border-radius: var(--radius);
  background: var(--glass); color: var(--text); border: 1px solid var(--line);
  font: 600 13.5px/1 var(--font); letter-spacing: 0.01em; white-space: nowrap;
  box-shadow: var(--shadow); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  text-decoration: none;
}
button.pill { cursor: pointer; }
button.pill:hover { background: var(--glass-hover); }
.pill .arrow { color: var(--accent); }
.brand { color: var(--accent); }

/* Loading */
#loading {
  position: fixed; inset: 0; z-index: 2000; display: grid; place-content: center; gap: 18px; justify-items: center;
  background: radial-gradient(ellipse at 50% 45%, #2b3240 0%, #151920 80%);
  transition: opacity 0.6s ease, visibility 0.6s;
}
#loading.done { opacity: 0; visibility: hidden; }
.ld-title { font: 700 15px/1 var(--font); letter-spacing: 0.32em; color: var(--text); }
.ld-bar { width: 180px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.ld-bar i { display: block; height: 100%; width: 35%; background: var(--accent); border-radius: 3px; animation: ld 1.1s ease-in-out infinite; }
@keyframes ld { 0% { transform: translateX(-110%); } 100% { transform: translateX(320%); } }

/* Search */
.search {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 1000;
  width: min(520px, calc(100vw - 32px)); height: 48px;
  display: flex; align-items: center; gap: 10px; padding: 0 6px 0 16px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.search-icon { width: 19px; height: 19px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent;
  color: var(--text); font: 500 15.5px var(--font);
}
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { display: none; }
.search kbd {
  flex: none; font: 600 11.5px var(--font); color: var(--muted); padding: 2px 7px;
  border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 6px;
}
.icon-btn {
  flex: none; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer;
  border: 0; border-radius: 10px; background: rgba(255, 255, 255, 0.07); color: var(--text);
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.14); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.icon-btn svg .dot { fill: currentColor; stroke: none; }
.icon-btn.spin svg { animation: spin 0.5s ease; }
@keyframes spin { to { transform: rotate(360deg); } }

#results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; margin: 0; padding: 6px; list-style: none;
  background: var(--glass); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); max-height: 50vh; overflow-y: auto;
}
#results li {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 10px 12px; border-radius: 9px; cursor: pointer; font-size: 14.5px;
}
#results li .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#results li .nm b { color: var(--accent); font-weight: 700; margin-right: 6px; }
#results li .kd { flex: none; color: var(--muted); font-size: 12.5px; }
#results li.sel, #results li:hover { background: rgba(255, 255, 255, 0.09); }
#results li.empty { color: var(--muted); cursor: default; }

/* Layer toggle */
.layer-toggle {
  position: fixed; top: 16px; right: 16px; z-index: 1000; display: flex; padding: 3px; gap: 2px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.layer-toggle[hidden] { display: none; }
.layer-toggle button {
  border: 0; background: transparent; color: var(--muted); font: 600 13px var(--font);
  padding: 8px 12px; border-radius: 9px; cursor: pointer;
}
.layer-toggle button.on { background: var(--accent); color: var(--accent-ink); }

/* Corners */
.corner-left { position: fixed; left: 16px; bottom: 34px; z-index: 1000; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.corner-right { position: fixed; right: 16px; bottom: 34px; z-index: 1000; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.zoom { display: flex; flex-direction: column; background: var(--glass); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.zoom button { width: 44px; height: 42px; border: 0; background: transparent; color: var(--text); font: 500 22px/1 var(--font); cursor: pointer; }
.zoom button + button { border-top: 1px solid var(--line); }
.zoom button:hover { background: var(--glass-hover); }
.share-row { display: flex; align-items: center; gap: 10px; }
.share-btn {
  width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow); transition: transform 0.15s ease;
}
.share-btn:hover { transform: scale(1.06); }
.share-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }

.hint {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%); z-index: 999;
  transition: opacity 0.5s ease, transform 0.5s ease; pointer-events: none;
}
.hint.gone { opacity: 0; transform: translate(-50%, 8px); }

.attrib {
  position: fixed; right: 12px; bottom: 8px; z-index: 1000; font-size: 11px; color: #3c4450;
  background: rgba(255, 255, 255, 0.55); padding: 2px 8px; border-radius: 6px;
}
.attrib button { border: 0; background: none; padding: 0; color: inherit; cursor: pointer; font-size: 12px; }

/* Place label shown after search */
.place-label {
  position: absolute; left: 0; top: 0; width: max-content;
  transform: translate(-50%, calc(-100% - 10px)); white-space: nowrap;
  background: var(--glass); color: var(--text); border: 1px solid var(--line);
  padding: 7px 12px; border-radius: 10px; font: 600 13.5px var(--font); box-shadow: var(--shadow);
  animation: pop 0.35s cubic-bezier(.2, 1.4, .4, 1);
}
.place-label small { display: block; color: var(--muted); font-weight: 500; font-size: 11.5px; margin-top: 2px; }
.place-label::after {
  content: ""; position: absolute; left: 50%; bottom: -7px; margin-left: -7px;
  border: 7px solid transparent; border-bottom: 0; border-top-color: var(--glass);
}
.place-dot { width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--accent); border: 2px solid #1b1f27; box-shadow: 0 0 0 0 rgba(247, 201, 72, 0.7); animation: pulse 1.6s infinite; }
.leaflet-div-icon { background: none; border: 0; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, calc(-100% + 4px)); } }
.place-label { z-index: 1; }
@keyframes pulse { 70% { box-shadow: 0 0 0 14px rgba(247, 201, 72, 0); } 100% { box-shadow: 0 0 0 0 rgba(247, 201, 72, 0); } }

/* Toast */
#toast {
  position: fixed; left: 50%; top: 76px; transform: translate(-50%, -8px); z-index: 1500; opacity: 0; pointer-events: none;
  background: var(--accent); color: var(--accent-ink); font: 700 13.5px var(--font); padding: 9px 16px; border-radius: 999px;
  box-shadow: var(--shadow); transition: opacity 0.25s ease, transform 0.25s ease;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Dialogs */
dialog {
  width: min(520px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 18px; padding: 26px 28px 22px;
  background: #171b23; color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); font-size: 14.5px; line-height: 1.55;
}
dialog::backdrop { background: rgba(10, 12, 16, 0.45); backdrop-filter: blur(2px); }
dialog h2 { margin: 0 0 12px; font-size: 19px; }
dialog ol, dialog ul { padding-left: 20px; margin: 0 0 12px; }
dialog li { margin-bottom: 8px; }
dialog a { color: var(--accent); }
dialog .muted { color: var(--muted); font-size: 13px; margin: 0; }
dialog .close {
  position: absolute; top: 12px; right: 14px; width: 32px; height: 32px; border: 0; border-radius: 8px;
  background: rgba(255, 255, 255, 0.07); color: var(--text); font-size: 20px; cursor: pointer;
}

@media (max-width: 640px) {
  .search { top: 12px; height: 46px; }
  .search kbd { display: none; }
  .layer-toggle { top: 68px; right: 50%; transform: translateX(50%); }
  .share-label, .hint { display: none; }
  .corner-left { bottom: 30px; left: 12px; }
  .corner-right { bottom: 30px; right: 12px; }
  .brand { display: none; }
}
