:root {
  --bg: #0b0f17;
  --panel: rgba(16, 22, 34, 0.92);
  --line: rgba(255, 255, 255, 0.1);
  --text: #e8eef8;
  --muted: #8b97ab;
  --acc: #ffb020;
  --acc2: #38bdf8;
  --good: #34d399;
  --bad: #f87171;
  --r: 10px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden;
  font: 14px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--acc2); }
.i { width: 20px; height: 20px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

.view { position: fixed; inset: 0; display: none; }
.view.active { display: block; }

/* ---------- карта ---------- */
#map { position: absolute; inset: 0; background: #0d1320; }
.leaflet-container { background: #0d1320; font: inherit; }
.leaflet-control-attribution { background: rgba(0,0,0,.5) !important; color: #889 !important; font-size: 10px; }
.leaflet-control-attribution a { color: #9ab !important; }
.leaflet-control-zoom { display: none; }

.topbar { position: absolute; top: calc(10px + var(--safe-t)); left: 10px; right: 10px; z-index: 500;
  display: flex; gap: 8px; align-items: center; }
.brand { display: flex; align-items: center; gap: 6px; padding: 0 12px; height: 42px; border-radius: var(--r);
  background: var(--panel); border: 1px solid var(--line); font-size: 16px; letter-spacing: .3px; }
.brand .i { color: var(--acc); }
.brand b { color: var(--acc); }
.search { position: relative; flex: 1; display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.search .i { color: var(--muted); width: 18px; }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); font: inherit; }
#search-res { position: absolute; top: 46px; left: 0; right: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden; display: none; max-height: 50vh; overflow-y: auto; }
#search-res.on { display: block; }
#search-res div { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
#search-res div:hover { background: rgba(255,255,255,.05); }
.pill { height: 42px; display: flex; align-items: center; padding: 0 12px; border-radius: var(--r);
  background: var(--panel); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
@media (max-width: 520px) { .brand span, .pill { display: none; } .brand { padding: 0 10px; } }

.map-btns { position: absolute; right: 10px; top: calc(64px + var(--safe-t)); z-index: 500; display: flex; flex-direction: column; gap: 8px; }
.round { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel);
  display: grid; place-items: center; }
.round.dark { background: rgba(0,0,0,.45); backdrop-filter: blur(6px); border-color: rgba(255,255,255,.15); }

.ar-fab { position: absolute; z-index: 500; left: 50%; transform: translateX(-50%); bottom: calc(22px + var(--safe-b));
  display: flex; align-items: center; gap: 10px; padding: 14px 26px; border: 0; border-radius: 999px;
  background: linear-gradient(135deg, #ffb020, #ff7a18); color: #1a1100; font-weight: 700; font-size: 16px;
  box-shadow: 0 8px 30px rgba(255, 140, 0, .35); }
.ar-fab .i { width: 22px; height: 22px; }

.status { position: absolute; left: 10px; bottom: calc(86px + var(--safe-b)); z-index: 500; font-size: 12px;
  color: var(--muted); background: rgba(0,0,0,.45); padding: 3px 8px; border-radius: 6px; pointer-events: none; }
.status:empty { display: none; }

/* иконки самолётов на карте */
.pl { width: 30px; height: 30px; margin: -15px 0 0 -15px; position: relative; }
.pl svg { width: 30px; height: 30px; display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,.8)); transition: transform .3s linear; }
.pl.sel svg { filter: drop-shadow(0 0 6px #fff); }
.pl .lb { position: absolute; left: 26px; top: 6px; white-space: nowrap; font-size: 11px; font-weight: 600;
  color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000; pointer-events: none; }
.me-dot { width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; background: var(--acc2);
  border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(56,189,248,.25); }

/* ---------- AR ---------- */
#ar-view { background: #000; touch-action: none; user-select: none; -webkit-user-select: none; }
#cam { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform-origin: 50% 50%; }
#sky-bg { position: absolute; inset: 0; display: none; }
#ar-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#ar-labels { position: absolute; inset: 0; overflow: hidden; z-index: 1; }

.tag { position: absolute; left: 0; top: 0; will-change: transform; pointer-events: auto; cursor: pointer; }
.tag .card { position: absolute; bottom: 0; left: 0; white-space: nowrap;
  background: rgba(8, 12, 20, .72); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  border: 1px solid rgba(255,255,255,.16); border-left: 3px solid var(--c, var(--acc)); border-radius: 8px;
  padding: 5px 8px 6px; color: #fff; font-size: 12px; line-height: 1.3; box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.tag .t1 { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; }
.tag .t1 img { width: 18px; height: 18px; border-radius: 3px; background: #fff; object-fit: contain; }
.tag .t1 .ty { font-weight: 500; font-size: 11px; color: #b9c4d6; }
.tag .t2 { color: #ffd27a; font-weight: 600; }
.tag .t3 { color: #cfd8e6; display: flex; gap: 8px; }
.tag .t3 .i { width: 11px; height: 11px; vertical-align: -1px; }
.tag.far .t2, .tag.far .t3 { display: none; }
.tag.mini .card { padding: 2px 6px; font-size: 11px; }
.tag.mini .t1 { font-size: 11px; }
.tag.mini .t1 img, .tag.mini .t2, .tag.mini .t3, .tag.mini .ty { display: none; }
.tag.sel .card { border-color: #fff; background: rgba(20, 30, 48, .9); }
.tag.emerg .card { border-left-color: var(--bad); background: rgba(80, 10, 10, .8); }

.ar-top { position: absolute; z-index: 5; top: calc(10px + var(--safe-t)); left: 10px; right: 10px; display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; }
.ar-top > * { pointer-events: auto; }
.ar-heading { text-align: center; text-shadow: 0 1px 3px #000; padding-top: 52px; pointer-events: none; }
.ar-heading b { font-size: 18px; display: block; }
.ar-heading span { font-size: 12px; color: #cfd8e6; }

.ar-hint { position: absolute; z-index: 6; left: 50%; bottom: calc(140px + var(--safe-b)); transform: translateX(-50%); max-width: 86%; text-align: center;
  background: rgba(0,0,0,.6); padding: 12px 16px; border-radius: 12px; font-size: 14px; pointer-events: none; }
.ar-hint:empty { display: none; }

.ar-bottom { position: absolute; z-index: 5; left: 10px; right: 10px; bottom: calc(12px + var(--safe-b)); display: flex; align-items: flex-end; gap: 10px; pointer-events: none; }
.ar-bottom > * { pointer-events: auto; }
#ar-radar { width: 110px; height: 110px; border-radius: 50%; background: rgba(0,0,0,.45); backdrop-filter: blur(4px); border: 1px solid rgba(255,255,255,.15); }
.ar-info { flex: 1; text-shadow: 0 1px 3px #000; font-size: 13px; padding-bottom: 4px; }
.ar-info .muted { color: #c2ccdb; font-size: 11px; }
.ar-zoom { display: flex; flex-direction: column; gap: 6px; }
.ar-zoom button { width: 44px; height: 36px; border-radius: 10px; border: 1px solid rgba(255,255,255,.2);
  background: rgba(0,0,0,.45); font-weight: 700; }
.ar-zoom button.on { background: var(--acc); color: #1a1100; border-color: var(--acc); }

/* ---------- панели ---------- */
.panel { position: absolute; z-index: 900; right: 10px; top: calc(62px + var(--safe-t)); width: min(340px, calc(100% - 20px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; backdrop-filter: blur(8px);
  max-height: calc(100% - 140px); overflow-y: auto; }
.panel.center { position: fixed; top: 50%; left: 50%; right: auto; transform: translate(-50%, -50%); }
.panel-h { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 15px; margin-bottom: 8px; }
.x { background: none; border: 0; font-size: 24px; line-height: 1; color: var(--muted); padding: 0 4px; }
.row { display: flex; justify-content: space-between; align-items: center; margin: 10px 0 4px; color: #cfd8e6; }
.row.check { margin: 8px 0; justify-content: flex-start; }
.row.check label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
input[type=range] { width: 100%; accent-color: var(--acc); }
input[type=checkbox], input[type=radio] { accent-color: var(--acc); width: 18px; height: 18px; }
.cal { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.btns { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.btn { border: 0; background: var(--acc); color: #1a1100; font-weight: 600; padding: 8px 12px; border-radius: 8px; }
.btn.ghost { background: rgba(255,255,255,.08); color: var(--text); }

/* ---------- карточка самолёта ---------- */
.sheet { position: fixed; z-index: 1000; left: 0; right: 0; bottom: 0; max-height: 78vh; overflow-y: auto;
  background: #101724; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; padding: 8px 16px calc(16px + var(--safe-b));
  box-shadow: 0 -10px 40px rgba(0,0,0,.5); animation: up .22s ease-out; }
@media (min-width: 760px) { .sheet { left: 12px; right: auto; width: 380px; bottom: 12px; top: auto; border-radius: 18px; border: 1px solid var(--line); } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.grab { width: 40px; height: 4px; border-radius: 2px; background: #2b3647; margin: 2px auto 8px; }
.sheet-x { position: absolute; right: 10px; top: 6px; }
.sh-head { display: flex; align-items: center; gap: 10px; padding-right: 26px; }
.sh-head img.logo { width: 40px; height: 40px; border-radius: 8px; background: #fff; object-fit: contain; padding: 3px; }
.sh-head h2 { margin: 0; font-size: 20px; }
.sh-head .sub { color: var(--muted); font-size: 13px; }
.photo { margin: 10px 0; border-radius: 12px; overflow: hidden; background: #0b111c; aspect-ratio: 16/9; position: relative; }
.photo.empty { aspect-ratio: auto; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .cr { position: absolute; right: 6px; bottom: 4px; font-size: 10px; color: #fff; text-shadow: 0 0 3px #000; }
.photo .cr a { color: #fff; }
.route { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin: 10px 0; }
.route .ap b { font-size: 22px; display: block; }
.route .ap span { color: var(--muted); font-size: 12px; }
.route .ap.r { text-align: right; }
.route .mid { color: var(--acc); }
.prog { height: 4px; background: #222c3b; border-radius: 2px; margin: -2px 0 10px; overflow: hidden; }
.prog div { height: 100%; background: var(--acc); }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.grid > div { background: #172031; border-radius: 10px; padding: 8px; }
.grid small { display: block; color: var(--muted); font-size: 11px; }
.grid b { font-size: 15px; }
.note { margin: 10px 0 0; padding: 8px 10px; border-radius: 10px; background: rgba(56,189,248,.1); color: #bfe6fb; font-size: 13px; }
.note.red { background: rgba(248,113,113,.15); color: #fecaca; }
.sh-actions { display: flex; gap: 8px; margin-top: 12px; }
.sh-actions .btn { flex: 1; }

#toast { position: fixed; left: 50%; bottom: calc(100px + var(--safe-b)); transform: translateX(-50%); z-index: 2000;
  background: rgba(10,14,22,.95); border: 1px solid var(--line); padding: 10px 14px; border-radius: 10px; display: none; max-width: 90%; text-align: center; }
#toast.on { display: block; }
