:root {
  --bg: #0e1116;
  --panel: rgba(18, 22, 29, 0.92);
  --text: #e6e9ee;
  --muted: #8a93a3;
  --line: #262c36;
  --alt-low: #4cd964;
  --alt-mid: #4aa8ff;
  --alt-high: #c38bff;
  --ground: #8a93a3;
  --highlight: #ffb020;
  --home: #ff5a5f;
  --gps: #2f80ff;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
#map { position: absolute; inset: 0; background: var(--bg); }

#panel { position: absolute; top: 12px; right: 12px; bottom: 12px; width: 300px; z-index: 1000;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  display: flex; flex-direction: column; overflow: hidden; }
#panel header { padding: 12px 14px; border-bottom: 1px solid var(--line); }
#panel .row { display: flex; gap: 6px; }
#panel .row button, .dialog-head button, #use-gps { font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 0 10px; cursor: pointer; min-width: 36px; }
#panel.collapsed { bottom: auto; }
#panel.collapsed #list { display: none; }
#place { flex: 1; min-width: 0; font: inherit; font-size: 16px; font-weight: 600; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
#status { color: var(--muted); font-size: 12px; margin-top: 2px; }
#status.error { color: var(--home); }
#list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
#list li { padding: 8px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
#list li:hover, #list li.active { background: rgba(255, 255, 255, 0.06); }
#list .top { display: flex; justify-content: space-between; font-weight: 600; }
#list .sub { color: var(--muted); font-size: 12px; }
#list .route { font-size: 12px; }

#legend { position: absolute; left: 12px; bottom: 24px; z-index: 1000; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12px;
  display: flex; gap: 10px; }
#legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; }

.plane-icon { background: none; border: none; }
.plane-icon svg { display: block; filter: drop-shadow(0 0 2px #000); }
.plane-label { background: rgba(14, 17, 22, 0.8); color: var(--text); border: none; box-shadow: none;
  font-size: 11px; line-height: 1.2; padding: 2px 4px; border-radius: 3px; }
.plane-label::before { display: none; }

.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--text); }
.leaflet-popup-content { margin: 10px 12px; min-width: 200px; }
.pop h2 { margin: 0 0 2px; font-size: 15px; }
.pop .muted { color: var(--muted); }
.pop table { border-collapse: collapse; margin-top: 6px; width: 100%; }
.pop td { padding: 1px 0; }
.pop td:first-child { color: var(--muted); padding-right: 10px; }
.pop .route { margin-top: 6px; font-weight: 600; }
.pop .warn { color: var(--highlight); font-size: 12px; font-weight: normal; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }

.recenter { width: 34px; height: 34px; font-size: 20px; line-height: 1; background: #fff; color: #222;
  border: 2px solid rgba(0, 0, 0, 0.2); cursor: pointer; }

dialog { background: #12161d; color: var(--text); border: 1px solid var(--line); border-radius: 12px;
  width: min(420px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 16px; }
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h2 { margin: 0; font-size: 18px; }
.dialog-head button { height: 32px; }
dialog h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 6px; }
dialog .muted { color: var(--muted); }
dialog p { margin: 6px 0; font-size: 13px; }
.place-list { list-style: none; margin: 0; padding: 0; }
.place-list li { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.place-list li span:first-child { flex: 1; font-weight: 600; }
.place-list button { background: none; border: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px 8px; }
dialog label { display: block; margin: 8px 0; font-size: 13px; color: var(--muted); }
dialog input { display: block; width: 100%; margin-top: 3px; font: inherit; font-size: 16px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; }
dialog .inline { display: flex; gap: 6px; margin-top: 3px; }
dialog .inline input { margin-top: 0; }
dialog .error { color: var(--home); font-size: 13px; min-height: 1em; }
dialog .primary { font: inherit; font-weight: 600; width: 100%; padding: 9px; margin-top: 4px; border: none;
  border-radius: 6px; background: var(--alt-mid); color: #06121f; cursor: pointer; }

@media (max-width: 700px) {
  #panel { top: auto; left: 12px; right: 12px; bottom: calc(12px + var(--safe-b)); width: auto; height: 34vh; }
  #panel.collapsed { height: auto; bottom: calc(12px + var(--safe-b)); }
  #legend { left: auto; right: 12px; bottom: auto; top: calc(12px + var(--safe-t)); gap: 6px; padding: 4px 8px; }
  .leaflet-top { top: var(--safe-t); }
}
