:root {
  --bg: #07090c;
  --glass: rgba(10, 13, 18, 0.72);
  --line: rgba(255, 255, 255, 0.14);
  --text: #eef2f6;
  --muted: #94a0ad;
  --amber: #ffb547;
  --amber-dim: rgba(255, 181, 71, 0.35);
  --ok: #7ee787;
  --bad: #ff6b6b;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  --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%; overflow: hidden; overscroll-behavior: none;
  background: var(--bg); color: var(--text); font-family: var(--sans);
  -webkit-user-select: none; user-select: none; touch-action: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

#cam {
  position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover; background:
    radial-gradient(ellipse at 50% 120%, #1b2633 0%, var(--bg) 70%);
}

/* ---------- AR labels ---------- */
#labels { position: fixed; inset: 0; pointer-events: none; }
.ac {
  position: absolute; left: 0; top: 0; pointer-events: auto;
  will-change: transform; transition: opacity 0.2s;
}
.ac .dot {
  position: absolute; left: -7px; top: -7px; width: 14px; height: 14px;
  border: 2px solid var(--amber); border-radius: 50%; background: rgba(0, 0, 0, 0.25);
}
.ac .tag {
  position: absolute; left: 12px; top: -30px; white-space: nowrap;
  padding: 3px 7px; border-radius: 6px; background: var(--glass);
  border: 1px solid var(--amber-dim); font: 600 12px/1.25 var(--mono);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.ac .tag small { display: block; color: var(--muted); font-weight: 500; font-size: 10.5px; }
.ac.far { opacity: 0.6; }
.ac.locked .dot { width: 26px; height: 26px; left: -13px; top: -13px; background: rgba(255, 181, 71, 0.18); box-shadow: 0 0 0 4px rgba(255, 181, 71, 0.18); }
.ac.locked .tag { border-color: var(--amber); color: var(--amber); left: 18px; }

/* ---------- reticle ---------- */
#reticle {
  position: fixed; left: 50%; top: 50%; width: 76px; height: 76px;
  transform: translate(-50%, -50%); pointer-events: none;
}
#reticle i { position: absolute; width: 18px; height: 18px; border: 2px solid rgba(255, 255, 255, 0.85); }
#reticle i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; }
#reticle i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; }
#reticle i:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; }
#reticle i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; }
#reticle::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px;
  margin: -2px 0 0 -2px; border-radius: 50%; background: #fff;
}
body.has-lock #reticle i { border-color: var(--amber); }

/* ---------- HUD ---------- */
#hud {
  position: fixed; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 8px;
  padding: calc(var(--safe-t) + 10px) 12px 10px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), transparent);
}
#readout { display: flex; flex-direction: column; font: 500 11px/1.35 var(--mono); color: var(--muted); min-width: 74px; }
#readout b { color: var(--text); font-weight: 700; }
#status { flex: 1; display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.chip {
  font: 600 9.5px/1 var(--mono); letter-spacing: 0.06em; padding: 4px 6px; border-radius: 99px;
  border: 1px solid var(--line); color: var(--muted); background: rgba(0, 0, 0, 0.35);
}
.chip.ok { color: var(--ok); border-color: rgba(126, 231, 135, 0.4); }
.chip.warn { color: var(--amber); border-color: var(--amber-dim); }
.chip.bad { color: var(--bad); border-color: rgba(255, 107, 107, 0.45); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--glass); font-size: 18px; display: grid; place-items: center; flex: none;
}

#hint {
  position: fixed; left: 50%; top: calc(50% + 58px); transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 6px 10px; border-radius: 8px; background: var(--glass);
  font: 600 12px/1.3 var(--mono); color: var(--text); text-align: center; pointer-events: none;
}

/* ---------- info card ---------- */
#card {
  position: fixed; left: 10px; right: 10px; bottom: calc(var(--safe-b) + 10px);
  padding: 14px 16px 12px; border-radius: 18px; background: var(--glass);
  border: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); animation: rise 0.18s ease-out;
}
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
.card-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.flight { font: 800 28px/1.05 var(--mono); color: var(--amber); letter-spacing: 0.02em; }
.airline { font-size: 15px; font-weight: 600; margin-top: 3px; }
#c-photo { width: 92px; height: 62px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); flex: none; }
.route {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  margin: 12px 0 4px; padding: 10px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.route b { display: block; font: 800 22px/1 var(--mono); }
.route small { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route > div:last-child { text-align: right; }
.route .arrow { color: var(--amber); font-size: 18px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 10px; margin: 10px 0 0; }
.stats div { min-width: 0; }
.stats dt { font: 600 9.5px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.stats dd { margin: 3px 0 0; font: 600 13px/1.2 var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note { margin: 8px 0 0; font-size: 11px; color: var(--muted); }
.note:empty { display: none; }

/* ---------- intro ---------- */
#intro {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(ellipse at 50% 0%, #142030 0%, var(--bg) 65%);
}
.intro-inner { max-width: 360px; text-align: center; }
.logo { font-size: 54px; color: var(--amber); transform: rotate(-45deg); display: inline-block; }
h1 { font: 800 30px/1.1 var(--mono); margin: 10px 0 12px; letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 0; }
p { line-height: 1.45; }
.small { font-size: 13px; color: var(--muted); }
.err { color: var(--bad); font-size: 14px; }
.primary, .secondary {
  width: 100%; padding: 15px; border-radius: 14px; font-weight: 700; font-size: 17px; border: 0; margin-top: 12px;
}
.primary { background: var(--amber); color: #1a1205; }
.secondary { background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line); font-size: 15px; }

/* ---------- sheets ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; max-height: 78vh; overflow-y: auto; touch-action: pan-y;
  padding: 16px 16px calc(var(--safe-b) + 18px); border-radius: 20px 20px 0 0;
  background: rgba(12, 15, 20, 0.94); border-top: 1px solid var(--line);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); z-index: 10;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet label { display: block; margin: 16px 0 0; font-size: 14px; }
.sheet label.row { display: flex; gap: 10px; align-items: center; }
.sheet output { float: right; font-family: var(--mono); color: var(--amber); }
.sheet input[type="range"] { width: 100%; margin-top: 8px; accent-color: var(--amber); }
.sheet input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--amber); }
#calib-list { list-style: none; margin: 8px 0 0; padding: 0; }
#calib-list li { padding: 12px 4px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; font-family: var(--mono); font-size: 13px; cursor: pointer; }
#calib-list li b { color: var(--amber); }
#calib-list li span { color: var(--muted); }
#calib-list li:active { background: rgba(255, 255, 255, 0.06); }
#calib-list .empty { color: var(--muted); cursor: default; }
