:root {
  --text: #17201c;
  --muted: #65706a;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-strong: rgba(255, 255, 255, 0.98);
  --line: rgba(23, 32, 28, 0.14);
  --shadow: 0 22px 60px rgba(16, 24, 40, 0.22);
  --green: #16824a;
  --red: #d13b2f;
  --blue: #2f80ed;
  --amber: #b56b12;
  --button: #1f2933;
  --button-hover: #111820;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body,
#app,
#map {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

#app {
  position: relative;
}

#map {
  background: #dce7df;
  z-index: 1;
}

.panel {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 500;
  display: flex;
  width: min(390px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

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

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 1.42rem;
  line-height: 1.1;
}

h2 {
  font-size: 0.92rem;
}

.count-pill {
  display: inline-flex;
  min-width: 56px;
  justify-content: center;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.message {
  display: none;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: rgba(181, 107, 18, 0.12);
  color: #6f420a;
  font-size: 0.9rem;
  line-height: 1.35;
}

.message.visible {
  display: block;
}

.message.error {
  background: rgba(209, 59, 47, 0.12);
  color: #8c241d;
}

.message.success {
  background: rgba(22, 130, 74, 0.12);
  color: #0f6438;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 0.94rem;
  font-weight: 650;
  cursor: pointer;
  user-select: none;
}

.toggle input {
  width: 19px;
  height: 19px;
  accent-color: var(--green);
}

.slider-group {
  display: grid;
  gap: 8px;
}

.slider-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

#corridor-value {
  color: var(--text);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--green);
}

.api-key-group,
.search-group {
  display: grid;
  gap: 7px;
}

.api-key-group label,
.search-group label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.api-key-row,
.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 94px;
  gap: 8px;
}

.api-key-row input,
.search-row input {
  min-width: 0;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  outline: none;
}

.api-key-row input:focus,
.search-row input:focus {
  border-color: rgba(47, 128, 237, 0.55);
  box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.13);
}

.search-results {
  display: none;
  max-height: 190px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.84);
}

.search-results.visible {
  display: grid;
}

.search-result {
  display: grid;
  gap: 2px;
  width: 100%;
  min-height: 0;
  padding: 9px 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  text-align: left;
  transform: none;
}

.search-result:last-child {
  border-bottom: 0;
}

.search-result:hover:not(:disabled) {
  background: rgba(47, 128, 237, 0.09);
  transform: none;
}

.search-result strong {
  color: var(--text);
  font-size: 0.88rem;
}

.search-result span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.25;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

button {
  min-height: 42px;
  padding: 9px 11px;
  border: 0;
  border-radius: var(--radius);
  background: rgba(31, 41, 51, 0.09);
  color: var(--text);
  font-weight: 750;
  line-height: 1.15;
  cursor: pointer;
  transition:
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease,
    opacity 160ms ease;
}

button:hover:not(:disabled) {
  background: rgba(31, 41, 51, 0.16);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button.primary {
  background: var(--button);
  color: #fff;
}

button.primary:hover:not(:disabled) {
  background: var(--button-hover);
}

button.danger {
  color: #8c241d;
}

.loading {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border-radius: var(--radius);
  background: rgba(47, 128, 237, 0.12);
  color: #185aa7;
  font-size: 0.9rem;
  font-weight: 700;
}

.loading.hidden {
  display: none;
}

.spinner {
  width: 17px;
  height: 17px;
  border: 2px solid rgba(24, 90, 167, 0.22);
  border-top-color: #185aa7;
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

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

.panel-section {
  display: grid;
  min-height: 0;
  gap: 8px;
}

.points-list {
  display: grid;
  max-height: 178px;
  margin: 0;
  padding: 0;
  gap: 6px;
  overflow: auto;
  list-style: none;
}

.points-list li {
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.68);
}

.point-badge {
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  background: var(--button);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 850;
}

.point-coordinates {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
  word-break: break-word;
}

.point-name {
  display: block;
  margin-bottom: 2px;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 780;
}

.results {
  display: grid;
  gap: 7px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.68);
  font-size: 0.9rem;
}

.results.empty {
  color: var(--muted);
}

.result-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.result-row span:first-child {
  color: var(--muted);
}

.status {
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: var(--radius);
  font-weight: 800;
}

.status.ok {
  background: rgba(22, 130, 74, 0.12);
  color: var(--green);
}

.status.bad {
  background: rgba(209, 59, 47, 0.12);
  color: var(--red);
}

.waypoint-marker {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--button);
  box-shadow: 0 8px 20px rgba(16, 24, 40, 0.3);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 900;
}

.leaflet-container {
  font: inherit;
}

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

  .panel {
    top: auto;
    bottom: 12px;
    left: 12px;
    width: calc(100vw - 24px);
    max-height: 54vh;
    padding: 14px;
    gap: 11px;
  }

  .button-grid {
    grid-template-columns: 1fr;
  }

  .points-list {
    max-height: 120px;
  }

  h1 {
    font-size: 1.2rem;
  }
}
