:root {
  --bg: #090909;
  --bg-2: #0e0e0e;
  --panel: #121212;
  --panel-2: #181818;
  --border: #262626;
  --border-soft: #1d1d1d;
  --text: #e8e8e8;
  --muted: #9c9c9c;
  --faint: #6d6d6d;
  --accent: #d0d0d0;
  --accent-2: #8f8f8f;
  --accent-soft: rgba(255, 255, 255, 0.07);
  --green: #5fd69b;
  --green-bord: #2c8a63;
  --yellow: #f7c96b;
  --yellow-bord: #9a7114;
  --red: #f4748a;
  --red-bord: #95364e;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
  --font: "Montserrat", "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

html {
  background: #090909;
}

body {
  background:
    url("pattern.svg"),
    radial-gradient(1300px 760px at 50% -10%, rgba(150, 150, 150, 0.12), transparent 62%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 34%, var(--bg) 100%);
  background-attachment: fixed;
  background-size: 32px 32px, auto, auto;
  color: var(--text);
  font-family: var(--font);
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  overscroll-behavior-y: contain;
}

* {
  scrollbar-width: thin;
  scrollbar-color: #3a3a3a #0c0c0c;
}
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: #0c0c0c;
}
::-webkit-scrollbar-thumb {
  background: #3a3a3a;
  border-radius: 6px;
  border: 2px solid #0c0c0c;
}
::-webkit-scrollbar-thumb:hover {
  background: #4d4d4d;
}

::selection {
  background: #4a4a4a;
  color: #ffffff;
}

.shell {
  max-width: 780px;
  margin: 0 auto;
  padding: 28px 18px 56px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: justify-content 0.45s ease;
}

.shell.has-results {
  justify-content: flex-start;
}

.shell.has-results .intro {
  transform: translateY(-10px);
}

.shell .reveal {
  opacity: 0;
  transform: translateY(24px);
  max-height: 0;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.5s ease, transform 0.5s ease, max-height 0.6s ease, visibility 0s 0.5s;
}

.shell.has-results .reveal {
  opacity: 1;
  transform: translateY(0);
  max-height: 100000px;
  overflow: visible;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.5s ease, transform 0.5s ease, max-height 0.7s ease;
}

.inters,
.intro > * {
  opacity: 0;
  animation: fadeUp 0.6s ease forwards;
}
.inters:nth-child(1),
.intro > *:nth-child(1) {
  animation-delay: 0.05s;
}
.inters:nth-child(2),
.intro > *:nth-child(2) {
  animation-delay: 0.15s;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #090909;
  transition: opacity 0.5s ease;
}

.loader.hide {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid #2a2a2a;
  border-top-color: #f0f0f0;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.intro {
  transition: transform 0.45s ease;
}

.top {
  text-align: center;
  margin-bottom: 26px;
}

.top h1 {
  font-size: clamp(1.6rem, 4.5vw, 2.2rem);
  font-weight: 700;
  letter-spacing: 0.2px;
  margin: 0 0 10px;
  background: linear-gradient(90deg, #f0f0f0, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sub {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0 auto;
  max-width: 680px;
}

.sub code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.85em;
}

.panel {
  background: rgba(18, 18, 18, 0.42);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.coords {
  width: 100%;
  min-height: 150px;
  border: 1px solid var(--border);
  background: rgba(18, 18, 18, 0.3);
  color: var(--text);
  border-radius: 12px;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 0.95rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.coords:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.coords::placeholder {
  color: var(--faint);
}

.meta-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin: 12px 0 16px;
}

.counter {
  color: var(--muted);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.errors {
  color: var(--red);
  font-size: 0.9rem;
  text-align: right;
  flex: 1;
  min-width: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 9px 22px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(115deg, #4a4a4a, #2c2c2c);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
  transition: transform 0.08s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.65);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn.loading::after {
  content: "…";
}

.cards {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.summary {
  margin-top: 22px;
  display: none;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 0.92rem;
  color: var(--muted);
}

.summary b {
  color: var(--text);
}
.summary .mk.red {
  color: var(--red);
}
.summary .mk.yellow {
  color: var(--yellow);
}
.summary .mk.green {
  color: var(--green);
}

.card {
  border-radius: var(--radius);
  padding: 16px 18px;
  background: rgba(20, 20, 20, 0.42);
  border: 1px solid var(--border);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  animation: cardPop 0.45s ease both;
}

@keyframes cardPop {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.card-green {
  border-color: var(--green-bord);
  background: linear-gradient(180deg, rgba(95, 214, 155, 0.1), rgba(20, 20, 20, 0.42));
}
.card-yellow {
  border-color: var(--yellow-bord);
  background: linear-gradient(180deg, rgba(223, 201, 107, 0.09), rgba(20, 20, 20, 0.42));
}
.card-red {
  border-color: var(--red-bord);
  background: linear-gradient(180deg, rgba(247, 123, 138, 0.1), rgba(20, 20, 20, 0.42));
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.card-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-open {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(20, 20, 20, 0.5);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.card-open:hover {
  color: var(--text);
  border-color: var(--accent-2);
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 10px currentColor;
}

.card-green .dot {
  background: var(--green);
  color: var(--green);
}
.card-yellow .dot {
  background: var(--yellow);
  color: var(--yellow);
}
.card-red .dot {
  background: var(--red);
  color: var(--red);
}

.card-title {
  font-size: 1.02rem;
  font-weight: 700;
  margin: 0;
}
.card-title {
  color: var(--text);
}
.card-green .card-title {
  color: var(--green);
}
.card-yellow .card-title {
  color: var(--yellow);
}
.card-red .card-title {
  color: var(--red);
}

.card-sub {
  color: var(--muted);
  font-size: 0.85rem;
  font-family: var(--mono);
  margin: 0 0 10px;
}

.card-sub-copy {
  cursor: pointer;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.25);
  width: fit-content;
  transition: color 0.15s;
}

.card-sub-copy:hover {
  color: #fff;
}

.leaflet-pane svg path.leaflet-interactive.pt-hit {
  pointer-events: all !important;
  cursor: pointer;
}

.near-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.near-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid var(--bg-2);
  font-size: 0.9rem;
}

.near-list .dist {
  color: var(--muted);
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 0.85em;
}

.map-wrap h2 {
  margin: 44px 0 14px;
  font-size: clamp(1.1rem, 3vw, 1.35rem);
  font-weight: 600;
  color: var(--accent);
}

.map {
  height: clamp(300px, 55vh, 480px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--panel);
}

.map-open {
  display: none;
  margin-top: 12px;
  padding: 11px 18px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(20, 20, 20, 0.45);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.map-open:hover {
  color: var(--accent);
  border-color: var(--accent-2);
}

@media (max-width: 768px) {
  .map-open {
    display: block;
  }
}

.leaflet-container {
  background: var(--panel);
  font-family: inherit;
}

.leaflet-control-attribution {
  display: none;
}

.leaflet-tooltip,
.leaflet-tooltip.tip {
  background: rgba(16, 16, 16, 0.72);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 0.78rem;
  line-height: 1.5;
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.leaflet-tooltip.tip b {
  color: var(--accent);
  font-weight: 600;
}
.leaflet-tooltip-top::before {
  border-top-color: rgba(16, 16, 16, 0.72);
}

.leaflet-tile-pane {
  filter: grayscale(0.9) invert(0.96) hue-rotate(180deg) brightness(0.88) contrast(0.92);
}
.leaflet-tile-pane::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(9, 9, 9, 0.28);
  pointer-events: none;
}

.foot {
  margin-top: 34px;
  padding: 14px 12px 6px;
  border-top: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  letter-spacing: 0.3px;
}

.foot p {
  margin: 0 auto 6px;
  max-width: 560px;
}

.foot .brand {
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.5px;
}

@media (min-width: 640px) {
  .shell {
    padding: 40px 24px 64px;
  }
  .panel {
    padding: 24px;
  }
  .btn {
    width: 100%;
  }
  .coords {
    min-height: 170px;
  }
}

@media (max-width: 520px) {
  .shell {
    padding: 20px 12px 44px;
  }
  .panel {
    padding: 16px;
  }
  .coords {
    min-height: 200px;
    font-size: 0.9rem;
  }
  .meta-row {
    flex-direction: column;
    align-items: stretch;
  }
  .errors {
    text-align: left;
  }
  .card {
    padding: 14px 14px;
  }
  .near-list li {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .map {
    height: 320px;
  }
}