:root {
  --bg: #030712;
  --panel: rgba(8, 16, 36, 0.82);
  --border: rgba(0, 212, 255, 0.28);
  --text: #e8f1ff;
  --muted: #8ba3c7;
  --cyan: #00d4ff;
  --mint: #00ff9d;
  --amber: #fbbf24;
  --rose: #fb7185;
  --font: "Outfit", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #000;
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

#ar-app {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

/* Camera */
#cam {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  z-index: 0;
  transform: scaleX(1);
}

#hud {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

#hud canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Gate / permissions */
#gate {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  padding-top: calc(1.25rem + var(--safe-t));
  padding-bottom: calc(1.25rem + var(--safe-b));
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(0, 212, 255, 0.14), transparent 55%),
    #030712;
}

#gate[hidden] {
  display: none !important;
}

.gate-card {
  width: min(420px, 100%);
  padding: 1.5rem 1.25rem 1.25rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(14px);
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.gate-card .badge {
  display: inline-block;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mint);
  border: 1px solid rgba(0, 255, 157, 0.35);
  background: rgba(0, 255, 157, 0.1);
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  margin-bottom: 0.75rem;
}

.gate-card h1 {
  margin: 0.2rem 0 0.6rem;
  font-size: 1.45rem;
  letter-spacing: 0.02em;
}

.gate-card p {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.gate-card ul {
  text-align: left;
  margin: 0.75rem 0 1.1rem;
  padding-left: 1.15rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.gate-card li {
  margin-bottom: 0.3rem;
}

.gate-actions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  border-radius: 12px;
  padding: 0.85rem 1.1rem;
  font: 600 0.95rem/1 var(--font);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  color: #031018;
  background: linear-gradient(135deg, var(--cyan), var(--mint));
  box-shadow: 0 8px 28px rgba(0, 212, 255, 0.28);
}

.btn-ghost {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.gate-err {
  margin-top: 0.85rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: rgba(251, 113, 133, 0.12);
  border: 1px solid rgba(251, 113, 133, 0.35);
  color: #fecdd3;
  font-size: 0.85rem;
  line-height: 1.4;
  text-align: left;
}

.gate-err[hidden] {
  display: none !important;
}

.gate-fine {
  margin-top: 0.9rem;
  font-size: 0.72rem;
  color: rgba(139, 163, 199, 0.75);
  line-height: 1.4;
}

/* Live chrome */
#chrome {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  display: flex;
  flex-direction: column;
}

#chrome > * {
  pointer-events: auto;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: calc(0.55rem + var(--safe-t)) 0.75rem 0.45rem;
  background: linear-gradient(180deg, rgba(3, 7, 18, 0.75), transparent);
}

.brand {
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
}

.brand span {
  color: var(--cyan);
  font-weight: 500;
}

.top-actions {
  display: flex;
  gap: 0.35rem;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(8, 16, 36, 0.72);
  color: var(--text);
  font-size: 1.05rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.center-reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  pointer-events: none;
  border: 2px solid rgba(0, 212, 255, 0.55);
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.25);
}

.center-reticle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: var(--cyan);
}

.bottom-panel {
  margin-top: auto;
  padding: 0.5rem 0.65rem calc(0.75rem + var(--safe-b));
  background: linear-gradient(0deg, rgba(3, 7, 18, 0.92) 40%, transparent);
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.chip {
  font-size: 0.72rem;
  font-family: var(--mono);
  padding: 0.28rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 212, 255, 0.2);
  background: rgba(8, 16, 36, 0.75);
  color: var(--muted);
}

.chip strong {
  color: var(--text);
  font-weight: 600;
}

.chip.ok {
  border-color: rgba(0, 255, 157, 0.35);
  color: var(--mint);
}

.chip.warn {
  border-color: rgba(251, 191, 36, 0.4);
  color: var(--amber);
}

/* Selected target guidance card */
.target-card {
  margin-bottom: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-radius: 14px;
  border: 1px solid rgba(0, 212, 255, 0.28);
  background: rgba(8, 16, 36, 0.92);
}

.target-empty {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  padding: 0.35rem 0;
}

.target-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.4rem;
}

.target-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--c, var(--cyan));
  box-shadow: 0 0 10px color-mix(in srgb, var(--c, #00d4ff) 60%, transparent);
  flex-shrink: 0;
}

.target-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.target-meta {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--mono);
}

.target-guide {
  font-size: 0.84rem;
  line-height: 1.4;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.target-guide .lock-ok {
  color: var(--mint);
  font-weight: 700;
}

.target-nums {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
  font-size: 0.72rem;
  font-family: var(--mono);
  color: var(--muted);
}

.target-nums em {
  font-style: normal;
  color: var(--cyan);
  font-weight: 600;
  margin-right: 0.2rem;
}

.badge-sky {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  white-space: nowrap;
}

.badge-sky.up {
  color: #031018;
  background: var(--mint);
}

.badge-sky.down {
  color: #031018;
  background: var(--amber);
}

/* Filters */
.list-filters {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
}

.filter-btn {
  flex: 1;
  border: 1px solid rgba(0, 212, 255, 0.2);
  background: rgba(8, 16, 36, 0.7);
  color: var(--muted);
  border-radius: 10px;
  padding: 0.4rem 0.35rem;
  font: 600 0.72rem/1.2 var(--font);
  cursor: pointer;
}

.filter-btn .fcount {
  display: inline-block;
  margin-left: 0.15rem;
  opacity: 0.85;
  font-family: var(--mono);
}

.filter-btn.is-active {
  color: #031018;
  background: linear-gradient(135deg, var(--cyan), var(--mint));
  border-color: transparent;
}

.sat-list {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding: 0.1rem 0 0.25rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  max-height: none;
}

.sat-list::-webkit-scrollbar {
  display: none;
}

.list-empty {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 0.5rem;
  width: 100%;
  text-align: center;
}

.sat-pill {
  flex: 0 0 auto;
  border: 1px solid rgba(0, 212, 255, 0.22);
  background: rgba(8, 16, 36, 0.9);
  color: var(--text);
  border-radius: 14px;
  padding: 0.55rem 0.7rem;
  min-width: 9.2rem;
  max-width: 11rem;
  text-align: left;
  cursor: pointer;
  font-family: var(--font);
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.sat-pill.is-below {
  opacity: 0.78;
}

.sat-pill.is-active {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px rgba(0, 212, 255, 0.4), 0 0 18px rgba(0, 212, 255, 0.15);
  background: rgba(0, 50, 70, 0.95);
}

.sat-pill .pill-top {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.2rem;
}

.sat-pill .n {
  font-weight: 700;
  font-size: 0.9rem;
}

.sat-pill .m {
  font-size: 0.7rem;
  color: var(--muted);
  font-family: var(--mono);
  margin-top: 0.1rem;
}

.sat-pill .sub {
  font-size: 0.68rem;
  color: rgba(139, 163, 199, 0.75);
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sat-pill .el-hi {
  color: var(--mint);
}

.sat-pill .el-lo {
  color: var(--amber);
}

.sat-pill .el-down {
  color: var(--rose);
}

.hint {
  margin: 0.45rem 0 0;
  font-size: 0.75rem;
  color: rgba(139, 163, 199, 0.85);
  line-height: 1.35;
  min-height: 2.2em;
}

/* Desktop notice */
.desktop-note {
  display: none;
}

@media (min-width: 900px) and (pointer: fine) {
  .desktop-note {
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 15;
    max-width: 360px;
    padding: 1rem 1.15rem;
    border-radius: 14px;
    background: rgba(8, 16, 36, 0.9);
    border: 1px solid var(--border);
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.45;
    pointer-events: none;
  }
}
