:root {
  color-scheme: dark;
  --bg: #101114;
  --panel: rgba(20, 22, 24, 0.82);
  --panel-strong: rgba(20, 22, 24, 0.94);
  --fg: #f7f4ee;
  --muted: rgba(247, 244, 238, 0.68);
  --soft: rgba(247, 244, 238, 0.1);
  --line: rgba(247, 244, 238, 0.15);
  --primary: #19c37d;
  --primary-strong: #0f9f67;
  --accent: #f2c94c;
  --danger: #ff7a7a;
  --shadow: rgba(0, 0, 0, 0.32);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body,
.app-shell {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
}

body {
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

#map {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(rgba(247, 244, 238, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(247, 244, 238, 0.04) 1px, transparent 1px),
    #15171a;
  background-size: 28px 28px;
}

.map-fallback {
  display: grid;
  height: 100%;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.app-shell::before,
.app-shell::after {
  position: fixed;
  right: 0;
  left: 0;
  z-index: 400;
  pointer-events: none;
  content: "";
}

.app-shell::before {
  top: 0;
  height: 154px;
  background: linear-gradient(to bottom, rgba(16, 17, 20, 0.64), rgba(16, 17, 20, 0));
}

.app-shell::after {
  bottom: 0;
  height: 280px;
  background: linear-gradient(to top, rgba(16, 17, 20, 0.7), rgba(16, 17, 20, 0));
}

.glass {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 22px 54px var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.top-panel {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  left: 12px;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 10px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.brand-mark {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

.app-title {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.1;
}

.app-subtitle {
  max-width: 52vw;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

button,
input,
a {
  font: inherit;
}

button {
  border: 0;
  color: var(--fg);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: default;
  opacity: 0.5;
}

.small-button,
.icon-button {
  display: grid;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--soft);
  font-size: 13px;
  font-weight: 800;
}

.small-button {
  min-width: 62px;
  border-radius: 8px;
  padding: 0 10px;
}

.icon-button {
  width: 42px;
  border-radius: 999px;
}

.search-panel {
  position: fixed;
  top: calc(max(12px, env(safe-area-inset-top)) + 70px);
  right: 12px;
  left: 12px;
  z-index: 510;
  display: grid;
  gap: 8px;
  padding: 10px;
}

.bottom-panel {
  position: fixed;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 12px;
  z-index: 500;
  max-height: min(48vh, 470px);
  overflow: auto;
  padding: 12px;
}

.panel-handle {
  width: 40px;
  height: 4px;
  margin: 0 auto 10px;
  border-radius: 999px;
  background: rgba(247, 244, 238, 0.24);
}

.action-copy {
  display: grid;
  gap: 3px;
  margin-bottom: 12px;
}

.action-copy h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1.08;
}

.action-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 620;
  line-height: 1.35;
}

.search-label {
  display: grid;
  gap: 5px;
}

.search-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.search-box input {
  padding-right: 8px;
}

.search-button {
  min-width: 58px;
  height: 44px;
  border-radius: 8px;
  background: rgba(242, 201, 76, 0.18);
  color: #ffe38b;
  font-size: 13px;
  font-weight: 850;
}

.search-results {
  display: grid;
  max-height: 168px;
  overflow: auto;
  border: 1px solid rgba(247, 244, 238, 0.12);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.36);
}

.search-result {
  display: grid;
  gap: 3px;
  padding: 10px;
  border-bottom: 1px solid rgba(247, 244, 238, 0.1);
  background: transparent;
  text-align: left;
}

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

.search-result strong {
  overflow: hidden;
  color: var(--fg);
  font-size: 13px;
  font-weight: 850;
  line-height: 1.22;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result span {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.28;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.coordinate-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

label {
  display: grid;
  min-width: 0;
  gap: 5px;
}

label span,
.selected-line span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

input {
  width: 100%;
  min-width: 0;
  height: 44px;
  border: 1px solid rgba(247, 244, 238, 0.14);
  border-radius: 8px;
  outline: 0;
  background: rgba(0, 0, 0, 0.52);
  color: var(--fg);
  padding: 0 10px;
  font-size: 16px;
}

input:focus {
  border-color: rgba(25, 195, 125, 0.85);
}

.selected-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 10px;
}

.selected-line strong {
  min-width: 0;
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.button-grid {
  display: grid;
  grid-template-columns: 1.35fr 0.9fr;
  gap: 8px;
  margin-top: 12px;
}

.primary-button,
.secondary-button {
  height: 48px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 850;
}

.primary-button {
  background: linear-gradient(180deg, var(--primary), var(--primary-strong));
  box-shadow: 0 10px 24px rgba(25, 195, 125, 0.2);
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--soft);
}

.status-block {
  min-height: 48px;
  margin-top: 10px;
  padding: 10px 0 0;
  border-top: 1px solid rgba(247, 244, 238, 0.11);
}

.status-title {
  font-size: 14px;
  font-weight: 850;
}

.status-title[data-tone="good"] {
  color: var(--primary);
}

.status-title[data-tone="warn"] {
  color: var(--accent);
}

.status-title[data-tone="bad"] {
  color: var(--danger);
}

.status-message {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.38;
}

details {
  margin-top: 8px;
  border-top: 1px solid rgba(247, 244, 238, 0.1);
  padding-top: 8px;
}

summary {
  color: var(--fg);
  font-size: 13px;
  font-weight: 850;
}

.guide-intro,
.diagnostic-copy,
.guide-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 620;
  line-height: 1.4;
}

.guide-steps {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: guide;
}

.guide-steps li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid rgba(247, 244, 238, 0.12);
  border-radius: 8px;
  background: rgba(247, 244, 238, 0.07);
  counter-increment: guide;
}

.guide-steps li::before {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  background: rgba(25, 195, 125, 0.16);
  color: var(--primary);
  content: counter(guide);
  font-size: 12px;
  font-weight: 900;
}

.guide-steps strong,
.guide-steps span,
.guide-steps a {
  grid-column: 2;
}

.guide-steps strong {
  font-size: 13px;
  line-height: 1.2;
}

.guide-steps span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.install-link {
  display: inline-grid;
  width: fit-content;
  min-height: 36px;
  place-items: center;
  margin-top: 2px;
  padding: 0 12px;
  border-radius: 8px;
  background: rgba(242, 201, 76, 0.16);
  color: #ffe38b;
  font-size: 12px;
  font-weight: 850;
  text-decoration: none;
}

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

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

.pin-marker {
  position: relative;
  width: 24px;
  height: 24px;
  border: 3px solid #ffffff;
  border-radius: 999px 999px 999px 0;
  background: var(--primary);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.34);
  transform: rotate(-45deg);
}

.pin-marker::after {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #ffffff;
  content: "";
}

@media (min-width: 720px) {
  .top-panel,
  .bottom-panel,
  .search-panel {
    right: 24px;
    left: auto;
    width: min(430px, calc(100vw - 48px));
  }

  .top-panel,
  .search-panel {
    top: 24px;
  }

  .search-panel {
    top: 96px;
  }

  .bottom-panel {
    bottom: 24px;
  }
}

@media (max-width: 360px) {
  .coordinate-row,
  .button-grid,
  .search-box {
    grid-template-columns: 1fr;
  }

  .app-subtitle {
    max-width: 44vw;
  }

  .small-button {
    min-width: 0;
    padding: 0 8px;
    font-size: 12px;
  }
}
