:root {
  color-scheme: dark;
  --bg: #101410;
  --panel: #181e19;
  --panel-2: #202822;
  --line: #314037;
  --text: #e7f0e8;
  --muted: #8ea396;
  --green: #8de0b0;
  --green-ink: #10281b;
  --amber: #f0c36a;
  --red: #ff8d8d;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

button, input, select { font: inherit; color: inherit; }

button { cursor: pointer; }

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #141a15;
}

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

.mark {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--green);
  position: relative;
  flex: none;
}

.mark::before, .mark::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid var(--green);
  border-radius: 50%;
}

.mark::after {
  inset: 15px;
  background: var(--green);
  border: 0;
}

h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.pills { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.pill {
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  border: 1px solid var(--line);
}

.pill.on { background: var(--green); color: var(--green-ink); border-color: transparent; font-weight: 650; }
.pill.warn { background: #3d3218; color: var(--amber); border-color: #6d5a2b; }
.pill.bad { background: #3d1d1d; color: var(--red); border-color: #6d3030; }

.banner {
  display: none;
  margin: 0;
  padding: 10px 16px;
  background: #3d3218;
  color: #ffe3a8;
  font-size: 13px;
}

.banner.show { display: block; }

.shell {
  flex: 1;
  min-height: 0;
  display: flex;
}

.map-wrap {
  flex: 1;
  min-width: 0;
  position: relative;
  background: #0c110e;
}

#map { height: 100%; width: 100%; background: #0c110e; }

.map-tools, .map-readout, .map-layers, .map-hint {
  position: absolute;
  z-index: 500;
}

.map-tools { top: 12px; left: 12px; width: min(360px, calc(100% - 24px)); }

.map-tools input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(16, 20, 16, 0.92);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}

.map-tools input:focus { border-color: var(--green); }

.results {
  list-style: none;
  margin: 6px 0 0;
  padding: 4px;
  background: rgba(16, 20, 16, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 220px;
  overflow: auto;
}

.results[hidden] { display: none; }

.results li {
  padding: 8px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
}

.results li:hover { background: var(--panel-2); cursor: pointer; }

.map-readout {
  left: 12px;
  bottom: 12px;
  background: rgba(16, 20, 16, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}

.map-layers, .map-hint {
  right: 12px;
}

.map-layers { bottom: 12px; display: flex; gap: 6px; }

.map-hint {
  top: 12px;
  color: var(--muted);
  background: rgba(16, 20, 16, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
}

.map-layers button, .side button, .ghost {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 8px 10px;
}

.map-layers button.active {
  background: var(--green);
  color: var(--green-ink);
  border-color: transparent;
}

.leaflet-div-icon.gps-pin {
  background: transparent;
  border: none;
}

.pin-dot, .pin-pulse {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  position: absolute;
  left: 4px;
  top: 4px;
}

.pin-dot {
  background: var(--green);
  border: 2px solid #10281b;
  z-index: 1;
}

.pin-pulse {
  background: rgba(141, 224, 176, 0.35);
  animation: pulse 1.8s ease-out infinite;
}

.gps-pin.lost .pin-dot { background: var(--red); }
.gps-pin.lost .pin-pulse { background: rgba(255, 141, 141, 0.3); }

@keyframes pulse {
  0% { transform: scale(0.7); opacity: 0.8; }
  100% { transform: scale(2.4); opacity: 0; }
}

.side {
  width: 420px;
  overflow: auto;
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 14px;
}

.actions, .row, .checks {
  display: grid;
  gap: 8px;
}

.actions { grid-template-columns: 1fr 1fr; margin-bottom: 12px; }

.actions .wide { grid-column: 1 / -1; }

button.primary {
  background: var(--green);
  color: var(--green-ink);
  border-color: transparent;
  font-weight: 700;
}

button.danger.active {
  background: var(--red);
  color: #3d1212;
  border-color: transparent;
  font-weight: 700;
}

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

.group {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 12px;
}

.group h2 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid-3 { display: grid; grid-template-columns: 1.4fr 0.8fr 0.8fr; gap: 8px; }

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

label.inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
}

input, select {
  width: 100%;
  background: #101410;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  outline: none;
}

input:focus, select:focus { border-color: #6fbf90; }

.hint { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }

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

.readout {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 4px 8px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
}

.readout span { color: var(--muted); }
.readout b { font-weight: 600; }

.meter {
  height: 6px;
  border-radius: 99px;
  background: #101410;
  border: 1px solid var(--line);
  margin-top: 8px;
  overflow: hidden;
}

.meter i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--green);
}

.meter.warn i { background: var(--amber); }
.meter.bad i { background: var(--red); }

.hex, .log {
  margin: 8px 0 0;
  background: #101410;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-all;
}

.log {
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
}

.log div { padding: 2px 0; border-bottom: 1px solid rgba(49, 64, 55, 0.45); }

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

.ghost { padding: 4px 8px; font-size: 12px; }

details { margin-top: 8px; }
summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.help { color: var(--muted); font-size: 13px; line-height: 1.55; }
.help code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  color: var(--text);
}

.leaflet-container { font-family: inherit; background: #0c110e; }

@media (max-width: 960px) {
  .shell { flex-direction: column; overflow: auto; }
  .map-wrap { height: 52vh; flex: none; }
  .side { width: auto; border-left: 0; border-top: 1px solid var(--line); }
  .top { align-items: flex-start; flex-direction: column; }
}
