:root {
  --bg: #0b1020;
  --panel: #111734;
  --card: #141c3d;
  --fg: #e6ecff;
  --muted: #a7b6ff;
  --accent: #7aa2ff;
  --accent2: #ffd56b;
  --good: #6bff95;
  --bad: #ff6b6b;
  --line: #91a6ff;
}
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  margin: 0;
}
body {
  font-family:
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Arial,
    sans-serif;
  background: var(--bg);
  color: var(--fg);
}

.app {
  display: flex;
  height: 100%;
}
#map {
  flex: 1 1 64%;
  min-width: 50vw;
}
.panel {
  flex: 0 0 36%;
  max-width: 36%;
  min-width: 360px;
  background: var(--panel);
  padding: 14px;
  overflow-y: auto;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
h1 {
  font-size: 18px;
  margin: 0;
}
.badge {
  background: #0c1230;
  border: 1px solid #253065;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid #1e2753;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
.row {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
input[type="text"],
input[type="number"],
input[type="file"],
select {
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #2a3359;
  background: #0f1530;
  color: var(--fg);
}
button {
  margin-top: auto;
  padding: 10px 14px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #0a0a0a;
  font-weight: 700;
  cursor: pointer;
}
.hidden {
  display: none;
}
.muted {
  color: var(--muted);
  font-size: 12px;
}

.nrow {
  display: flex;
  gap: 10px;
  align-items: center;
}
input[type="range"] {
  width: 100%;
}

.results {
  padding: 0;
  overflow: hidden;
}
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid #1f2750;
}
.result-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.result-item {
  border-bottom: 1px solid #1f2750;
}
.result-item button.item-head {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  background: transparent;
  border: none;
  color: var(--fg);
  cursor: pointer;
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 10px;
  align-items: center;
}
.rank {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f1530;
  border: 1px solid #2a3359;
  color: var(--muted);
  font-weight: 700;
}
.item-title {
  font-size: 14px;
}
.item-metrics {
  font-size: 12px;
  color: var(--muted);
}
.item-body {
  display: none;
  padding: 8px 12px 12px 50px;
  font-size: 13px;
  color: var(--muted);
}
.result-item.active .item-body {
  display: block;
}
.result-item.active button.item-head {
  background: #101943;
}

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 10px;
  margin-top: 6px;
}
.kv span.key {
  color: #8fa1ff;
}
.kv code {
  color: #dbe3ff;
  background: #0f1530;
  border: 1px solid #2a3359;
  border-radius: 6px;
  padding: 2px 6px;
}

.tag {
  font-size: 11px;
  color: #0a0a0a;
  background: var(--accent2);
  padding: 2px 6px;
  border-radius: 6px;
  margin-left: 8px;
}

.autofit {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.autofit input {
  transform: translateY(1px);
}

/* distance pills */
.dist-pill {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  margin-right: 4px;
  color: #0a0a0a;
}
.dist-km {
  background: var(--accent2);
} /* amber */
.dist-mi {
  background: var(--accent);
} /* blue */

.copy {
  cursor: pointer;
  position: relative;
}
.copy.copied::after {
  content: "Copied!";
  position: absolute;
  top: -18px;
  right: -4px;
  font-size: 10px;
  background: #00d1ff;
  color: #0a0a0a;
  padding: 2px 6px;
  border-radius: 6px;
}

.hint { color: var(--muted); font-size: 12px; margin-top: 4px; display:block; }
.hint.ok { color: #9cffc4; }
.hint.warn { color: #ffd56b; }
.hint.err { color: #ff9f9f; }
.progress-row { display:flex; align-items:center; gap:10px; }
.progress-bar { flex:1; height:10px; background:#0f1530; border:1px solid #2a3359; border-radius:999px; overflow:hidden; }
#progressFill { height:100%; width:0%; background: linear-gradient(90deg, var(--accent), var(--accent2)); }

.panel-toggle {
  display: none;
}

/* Mobile responsiveness */
@media (max-width: 900px) {
  .app {
    flex-direction: column;
    height: auto;
    min-height: 100dvh;
  }

  #map {
    order: 1;
    width: 100%;
    min-width: 0;
    min-height: 48dvh;
    height: 48dvh;
  }

  .panel {
    order: 2;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 14px clamp(12px, 3vw, 18px);
    max-height: none;
  }

  .panel-toggle {
    display: block;
    width: 100%;
    margin-bottom: 10px;
    margin-top: 0;
  }

  .panel.collapsed > :not(.panel-toggle) {
    display: none;
  }

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

  .result-item button.item-head {
    grid-template-columns: 28px 1fr;
  }

  .item-metrics {
    display: none;
  }
}

@media (max-width: 420px) {
  h1 { font-size: 16px; }
  .badge { font-size: 11px; padding: 4px 8px; }
  #map { min-height: 52dvh; height: 52dvh; }
}

@media (max-height: 480px) and (orientation: landscape) {
  #map { min-height: 60dvh; height: 60dvh; }
}
