:root {
  --bg: #04060d;
  --glass: rgba(10, 14, 28, 0.62);
  --glass-strong: rgba(10, 14, 28, 0.9);
  --line: rgba(255, 255, 255, 0.1);
  --text: #eef2ff;
  --muted: #95a1bd;
  --accent: #6d8dff;
  --accent-2: #7ef0cf;
  --good: #44e3a0;
  --warn: #ffb547;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Space Grotesk", var(--font);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font: 15px/1.4 var(--font); overscroll-behavior: none; -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* App-like touch behaviour (no text selection, long-press callouts or double-tap zoom). */
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
input, .wiki p { -webkit-user-select: text; user-select: text; }
img { -webkit-user-drag: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; color: var(--text); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.row { display: flex; align-items: center; justify-content: space-between; }
.gap { gap: 8px; justify-content: flex-start; flex-wrap: wrap; }

#cam, #camfx, #sky { position: fixed; inset: 0; width: 100vw; height: 100dvh; }
#cam { object-fit: cover; background: #000; transform-origin: 50% 50%; }
#camfx { display: none; transform-origin: 50% 50%; background: #000; }
#sky { touch-action: none; }

/* ---------- HUD ---------- */
#hud { position: fixed; top: 0; left: 0; right: 0;
  padding: calc(env(safe-area-inset-top) + 10px) calc(env(safe-area-inset-right) + 16px) 26px calc(env(safe-area-inset-left) + 16px);
  pointer-events: none; background: linear-gradient(rgba(2,4,10,.72), rgba(2,4,10,.28) 70%, rgba(2,4,10,0));
  display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
#hud button { pointer-events: auto; }
.hud-row { display: flex; justify-content: space-between; align-items: flex-start; }
.mono-big { font: 700 26px/1 var(--display); letter-spacing: .3px; font-variant-numeric: tabular-nums; text-shadow: 0 1px 8px rgba(0,0,0,.6); }
.hud-sub { margin-top: 4px; white-space: nowrap; font-size: 12.5px; color: #c9d2ea; text-shadow: 0 1px 3px #000; }
.hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.hud-clock { font: 600 15px var(--display); font-variant-numeric: tabular-nums; text-shadow: 0 1px 3px #000; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--glass);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); padding: 4px 10px; border-radius: 99px;
  font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; max-width: 52vw; overflow: hidden; text-overflow: ellipsis; }
.dot-status { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); flex: none; }
.dot-status.ok { background: var(--good); box-shadow: 0 0 8px var(--good); }
#tape { display: block; width: min(560px, 100%); height: 34px; margin: 2px auto 0; }
.live-chip { align-self: center; color: #d7fff2; max-width: calc(100vw - 32px); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 0 0 rgba(126,240,207,.7); animation: pulse 1.8s infinite; flex: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(126,240,207,0); } 100% { box-shadow: 0 0 0 0 rgba(126,240,207,0); } }

#crosshair { position: fixed; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; pointer-events: none; }
#crosshair i { position: absolute; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.85); filter: drop-shadow(0 0 2px #000); }
#crosshair i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; border-radius: 4px 0 0 0; }
#crosshair i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; border-radius: 0 4px 0 0; }
#crosshair i:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 4px; }
#crosshair i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; border-radius: 0 0 4px 0; }
#reticle { position: fixed; left: 50%; top: calc(50% + 36px); transform: translateX(-50%); pointer-events: none;
  padding: 4px 10px; border-radius: 10px; background: var(--glass); border: 1px solid var(--line); font-size: 12.5px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); white-space: nowrap; text-align: center; }
#reticle b { font-weight: 650; }

#zoomCtl { position: fixed; right: calc(env(safe-area-inset-right) + 12px); top: 50%; transform: translateY(-50%); display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--glass);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
#zoomCtl button { width: 46px; height: 46px; border: 0; background: transparent; font: 600 22px var(--display); }
#zoomCtl #zoomVal { height: 34px; font-size: 13px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
#zoomCtl button:active { background: rgba(255,255,255,.1); }

.pill-btn { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 150px); transform: translateX(-50%);
  border: 0; background: var(--accent); color: #fff; font-weight: 600; padding: 10px 18px; border-radius: 99px; box-shadow: 0 6px 24px rgba(0,0,0,.4); }
#camBanner { position: fixed; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top) + 150px);
  width: min(420px, calc(100vw - 32px)); display: flex; gap: 10px; align-items: center; padding: 10px 12px;
  border-radius: 14px; background: var(--glass-strong); border: 1px solid rgba(255,181,71,.35); font-size: 13px; }
#camBanner span { flex: 1; }
#camBanner button { flex: none; border: 0; background: var(--warn); color: #1b1203; font-weight: 600; padding: 7px 12px; border-radius: 10px; }

/* ---------- Toolbar ---------- */
#toolbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 12px);
  display: flex; gap: 4px; padding: 6px; background: var(--glass); border: 1px solid var(--line);
  border-radius: 22px; backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3);
  box-shadow: 0 10px 30px rgba(0,0,0,.35); }
#toolbar button { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 70px;
  padding: 8px 8px 6px; border: 0; background: transparent; border-radius: 16px; font-size: 11.5px; font-weight: 500; color: #dfe6fb; }
#toolbar button:active, #toolbar button.on { background: rgba(109,141,255,.22); }
#toolbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Target card ---------- */
.card { position: fixed; left: 50%; transform: translateX(-50%); width: min(460px, calc(100vw - 24px));
  bottom: calc(env(safe-area-inset-bottom) + 88px); padding: 12px 14px; background: var(--glass-strong);
  border: 1px solid var(--line); border-radius: 20px; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.t-head { display: flex; align-items: center; gap: 10px; }
.t-icon { width: 14px; height: 14px; border-radius: 50%; flex: none; margin: 0 4px; }
.t-title { flex: 1; min-width: 0; }
#tName { font: 650 18px/1.15 var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tType { font-size: 12.5px; color: var(--muted); }
button.icon { border: 0; background: rgba(255,255,255,.08); width: 32px; height: 32px; border-radius: 50%; flex: none; font-size: 14px; }
.guide { margin: 10px 0 2px; font: 650 17px var(--display); color: var(--warn); }
.guide.locked { color: var(--good); }
.quick { font-size: 13px; color: #c9d2ea; font-variant-numeric: tabular-nums; }
#tDetails { overflow: hidden; transition: max-height .25s ease; max-height: 480px; }
#tDetails.collapsed { max-height: 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 10px; font-variant-numeric: tabular-nums; margin: 10px 0 6px; font-size: 14px; }
.stats div > span:first-child { display: block; color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; margin-bottom: 1px; }
.extra { font-size: 12.5px; color: var(--muted); }
button.ghost { border: 1px solid var(--line); background: rgba(255,255,255,.05); padding: 7px 12px; border-radius: 10px; margin-top: 8px; font-size: 13px; }
.up { color: var(--good); } .down { color: #ff8a8a; }
.live { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px; font-size: 10px; font-weight: 700;
  letter-spacing: .6px; color: #05140e; background: var(--accent-2); vertical-align: 1px; animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .5; } }

/* ---------- Sheets ---------- */
.sheet { position: fixed; z-index: 4; left: 0; right: 0; bottom: 0; max-height: 80dvh; overscroll-behavior: contain; display: flex; flex-direction: column;
  background: rgba(8, 11, 22, .97); border-top: 1px solid var(--line); border-radius: 24px 24px 0 0;
  padding: 6px 16px calc(env(safe-area-inset-bottom) + 12px); max-width: 640px; margin: 0 auto;
  box-shadow: 0 -10px 40px rgba(0,0,0,.5); animation: rise .22s ease-out; }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }
.grab { width: 40px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.2); margin: 4px auto 10px; flex: none; }
.sheet-head { display: flex; gap: 8px; align-items: center; flex: none; }
.sheet-head h2 { margin: 0; font: 650 18px var(--display); flex: 1; }
.sheet input[type=search], .sheet input[inputmode] { flex: 1; min-width: 0; padding: 11px 14px; border-radius: 14px;
  border: 1px solid var(--line); background: rgba(255,255,255,.06); outline: none; }
.sheet input:focus { border-color: var(--accent); }
.chips { flex: none; display: flex; gap: 6px; overflow-x: auto; padding: 12px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; border: 1px solid var(--line); background: transparent; padding: 6px 12px; border-radius: 99px; font-size: 13px; }
.chips button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
#list { flex: 1; min-height: 0; list-style: none; margin: 0; padding: 0; overflow-y: auto; }
#list li { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid rgba(255,255,255,.05); cursor: pointer; }
#list li:active { background: rgba(255,255,255,.05); }
#list .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
#list .nm { flex: 1; min-width: 0; }
#list .nm b { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#list .pos { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }
.set-body { overflow-y: auto; padding-bottom: 8px; }
.set-body h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 18px 0 4px; font-weight: 600; }
.set-body label { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.set-body label.tog { justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,.04); }
.set-body label em { font-style: normal; color: var(--muted); font-size: 12px; margin-left: 6px; }
.set-body label.range input { flex: 1; accent-color: var(--accent); }
.set-body label.range b { min-width: 44px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.tog input { appearance: none; -webkit-appearance: none; width: 42px; height: 24px; border-radius: 99px; background: rgba(255,255,255,.15);
  position: relative; transition: background .2s; flex: none; margin: 0; cursor: pointer; }
.tog input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.tog input:checked { background: var(--accent); }
.tog input:checked::after { transform: translateX(18px); }
.about { margin-top: 18px; line-height: 1.5; }

/* ---------- Splash ---------- */
#splash { position: fixed; inset: 0; display: flex; overflow-y: auto; -webkit-overflow-scrolling: touch; z-index: 5;
  padding: calc(env(safe-area-inset-top) + 20px) calc(env(safe-area-inset-right) + 24px) calc(env(safe-area-inset-bottom) + 20px) calc(env(safe-area-inset-left) + 24px);
  background: radial-gradient(ellipse at 50% 18%, #1a2a66 0%, #0a1030 38%, #04060d 75%); }
#stars { position: absolute; inset: 0; width: 100%; height: 100%; }
.splash-inner { position: relative; margin: auto; max-width: 380px; text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.splash-inner h1 { margin: 0; font: 700 36px/1 var(--display); letter-spacing: -.5px; }
.splash-inner h1 span { font-size: 15px; margin-left: 8px; padding: 3px 8px; border-radius: 8px; background: var(--accent-2); color: #04211a; vertical-align: 8px; letter-spacing: .5px; }
.lead { margin: 0; color: #c8d2ee; font-size: 16px; }
.feats { list-style: none; padding: 0; margin: 4px 0 8px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.feats li { font-size: 12.5px; color: #c8d2ee; padding: 6px 10px; border-radius: 99px; border: 1px solid var(--line); background: rgba(255,255,255,.04); }
.feats b { color: #fff; }
.logo { width: 92px; height: 92px; filter: drop-shadow(0 0 24px rgba(255,190,110,.35)); animation: float 5s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px); } }
button.primary { border: 0; background: linear-gradient(135deg, #7c9bff, #5a6dff); color: #fff; padding: 15px 22px; border-radius: 16px;
  font: 650 17px var(--display); width: 100%; box-shadow: 0 10px 30px rgba(90,109,255,.4); }
button.primary:active { transform: scale(.98); }
button.link { border: 0; background: none; color: #b8c4ea; text-decoration: underline; text-underline-offset: 3px; font-size: 14px; padding: 4px; }

#toast { position: fixed; top: calc(env(safe-area-inset-top) + 118px); left: 50%; transform: translateX(-50%);
  background: var(--glass-strong); border: 1px solid var(--line); padding: 10px 14px; border-radius: 14px; font-size: 14px;
  max-width: calc(100vw - 32px); text-align: center; z-index: 10; box-shadow: 0 8px 24px rgba(0,0,0,.4); }

/* ---------- Details sheet ---------- */
.info-btn { border: 0; background: var(--accent); color: #fff; font-weight: 600; font-size: 13px; padding: 7px 12px; border-radius: 99px; flex: none; }
#details { max-height: 88dvh; z-index: 4; }
.d-head { display: flex; align-items: center; gap: 10px; flex: none; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
#dName { font: 650 21px/1.15 var(--display); }
#dType { font-size: 12.5px; color: var(--muted); }
.d-body { overflow-y: auto; flex: 1; min-height: 0; padding: 4px 0 8px; -webkit-overflow-scrolling: touch; }
.d-foot { flex: none; padding-top: 10px; }
.d-foot .primary { padding: 12px; font-size: 15px; }
#dLive { margin-top: 10px; padding: 10px 12px; border-radius: 14px; background: rgba(126,240,207,.06); border: 1px solid rgba(126,240,207,.18); }
.d-live-h { display: flex; align-items: center; gap: 8px; font-size: 11px; letter-spacing: .8px; text-transform: uppercase; color: var(--accent-2); font-weight: 650; margin-bottom: 6px; }
.d-sec { margin-top: 16px; }
.d-sec:empty { display: none; }
.d-sec h3 { margin: 0 0 8px; font-size: 11.5px; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); font-weight: 650; }
.d-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.d-grid div { min-width: 0; }
.d-grid div > span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 1px; }
.d-grid b { font-weight: 550; font-size: 14px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.d-lead { margin: 0 0 10px; font-size: 15px; color: #dfe6fb; }
.d-src { margin: 8px 0 0; font-size: 11.5px; color: var(--muted); }
.d-loading { color: var(--muted); font-size: 13px; }
.wiki { display: flex; gap: 12px; align-items: flex-start; }
.wiki img { width: 96px; height: 96px; object-fit: cover; border-radius: 12px; flex: none; background: #111; }
.wiki p { margin: 0; font-size: 14px; line-height: 1.5; color: #d4dbef; }
.wiki-link { display: inline-block; margin-top: 8px; color: #9fb4ff; font-size: 13.5px; text-decoration: none; font-weight: 550; }
.passes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.passes li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 9px 12px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid var(--line); }
.passes li.vis { border-color: rgba(68,227,160,.45); background: rgba(68,227,160,.07); }
.passes li div span { display: block; font-size: 12px; color: var(--muted); }
.passes li .pk { text-align: right; }
.passes li em { grid-column: 1 / -1; font-style: normal; font-size: 11.5px; font-weight: 650; letter-spacing: .4px; color: var(--muted); }
.passes li.vis em { color: var(--good); }
@media (min-width: 520px) { .d-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---------- Night camera ---------- */
#camBtn { position: fixed; right: calc(env(safe-area-inset-right) + 12px); top: calc(50% - 128px); width: 48px; height: 58px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; border: 1px solid var(--line); border-radius: 16px; background: var(--glass);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); font-size: 10.5px; font-weight: 600; }
#camBtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
#camBtn.on { background: rgba(255,181,71,.25); border-color: rgba(255,181,71,.6); color: #ffd391; }
#camSheet { z-index: 4; }
.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.presets button { border: 1px solid var(--line); background: rgba(255,255,255,.04); border-radius: 14px; padding: 10px 8px; text-align: left; }
.presets button b { display: block; font: 650 14px var(--display); }
.presets button span { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.presets button.on { border-color: var(--accent); background: rgba(109,141,255,.2); }
.cam-now { margin-top: 10px; font-size: 12.5px; color: var(--accent-2); font-variant-numeric: tabular-nums; }
#camHw label.range span, #camSwBox label.range span { min-width: 108px; }

/* ---------- iPhone extras ---------- */
#iosHint { position: fixed; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top) + 156px); z-index: 3;
  width: min(420px, calc(100vw - 24px)); display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px;
  border-radius: 18px; background: var(--glass-strong); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0,0,0,.45); font-size: 13.5px; }
#iosHint img { width: 40px; height: 40px; border-radius: 10px; flex: none; }
#iosHint svg { width: 16px; height: 16px; vertical-align: -3px; fill: none; stroke: #9fb4ff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.d-foot { display: flex; gap: 10px; }
.share-btn { flex: none; width: 52px; border: 1px solid var(--line); background: rgba(255,255,255,.06); border-radius: 16px; display: grid; place-items: center; }
.share-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.passes li .cal { grid-column: 1 / -1; justify-self: start; margin-top: 4px; border: 1px solid var(--line); background: rgba(255,255,255,.06);
  border-radius: 9px; padding: 5px 10px; font-size: 12px; font-weight: 600; }
.passes li.vis .cal { border-color: rgba(68,227,160,.5); color: #b6f5d9; }
/* Red night vision: multiply everything by pure red so only red light reaches your eyes. */
#redMode { display: none; position: fixed; inset: 0; background: #ff0000; mix-blend-mode: multiply; pointer-events: none; z-index: 100; }
body.red #redMode { display: block; }
body.red { --accent: #b3261e; --accent-2: #ff5a4d; --good: #ff6b5e; }

/* Phones in landscape: compact start screen. */
@media (max-height: 520px) {
  .logo { width: 56px; height: 56px; }
  .splash-inner { gap: 8px; max-width: 520px; }
  .splash-inner h1 { font-size: 28px; }
  .feats { display: none; }
  #stars { position: fixed; }
}

#camBtn.stalled { border-color: #ff6b6b; color: #ff9b9b; }
#darkHint { position: fixed; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top) + 222px); z-index: 3;
  width: min(440px, calc(100vw - 24px)); display: flex; gap: 10px; align-items: center; padding: 10px 10px 10px 14px;
  border-radius: 16px; background: var(--glass-strong); border: 1px solid rgba(126,240,207,.35); font-size: 13px; line-height: 1.35; }
#darkHint span { flex: 1; }
#darkHint #darkBoost { flex: none; border: 0; background: var(--accent-2); color: #04211a; font-weight: 700; padding: 8px 12px; border-radius: 10px; }
.diag { margin: 0; padding: 10px 12px; border-radius: 12px; background: rgba(0,0,0,.35); border: 1px solid var(--line);
  font: 11.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: #cfe3ff; white-space: pre-wrap; word-break: break-word; -webkit-user-select: text; user-select: text; }

.d-stamp { margin-left: auto; font: 500 11px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); letter-spacing: 0; text-transform: none; }
#dLive .d-grid b { font-variant-numeric: tabular-nums; }
