:root {
  --bg-dark: #07090e;
  --glass-bg: rgba(18, 24, 38, 0.75);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-glow: rgba(0, 240, 255, 0.15);
  --neon-cyan: #00f0ff;
  --neon-magenta: #ff007f;
  --neon-purple: #9d00ff;
  --neon-green: #00ff88;
  --neon-yellow: #ffcc00;
  --text-main: #f0f6fc;
  --text-muted: #8b949e;
  --radius-full: 9999px;
  --radius-card: 20px;
  --radius-sm: 10px;
  --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: var(--font-sans);
  color: var(--text-main);
}

/* App Viewports */
#app-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

.viewport-wrap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#webcam {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  transition: transform 0.25s ease;
  z-index: 1;
}

#webcam.no-mirror {
  transform: scaleX(1);
}

#canvas-2d {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  z-index: 2;
  transform: scaleX(-1);
  transition: transform 0.25s ease;
}

#canvas-2d.no-mirror {
  transform: scaleX(1);
}

#canvas-3d {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

/* Vignette */
.cyber-vignette {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 60%, rgba(4, 7, 13, 0.6) 100%);
  z-index: 4;
}

/* --- Apple / SF Style Compact Top Bar --- */
.top-bar {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  z-index: 10;
}

.brand-pill {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-title {
  font-weight: 800;
  font-size: 0.92rem;
  letter-spacing: 0.8px;
  color: #fff;
}

.brand-title span {
  color: var(--neon-cyan);
}

.fps-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--neon-green);
}

.fps-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--neon-green);
  box-shadow: 0 0 6px var(--neon-green);
}

/* SF Action Buttons in Top Bar */
.actions-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.sf-btn svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
}

.sf-btn:active {
  transform: scale(0.9);
}

.sf-btn.active {
  background: rgba(0, 240, 255, 0.2);
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
}

/* --- Floating Smart HUD Pills (Compact & Clean) --- */
.smart-hud-row {
  position: absolute;
  top: 64px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
  z-index: 10;
  flex-wrap: wrap;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: rgba(14, 18, 28, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.hud-pill.visible {
  opacity: 1;
  transform: translateY(0);
}

.hud-pill.hand {
  border-color: rgba(0, 240, 255, 0.35);
}

.hud-pill.face {
  border-color: rgba(157, 0, 255, 0.35);
}

.hud-pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--neon-cyan);
}

/* --- Bottom Floating Dock --- */
.bottom-dock {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.5);
  z-index: 10;
}

.dock-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.dock-btn svg {
  width: 17px;
  height: 17px;
}

.dock-btn:active {
  transform: scale(0.95);
}

.dock-btn.active {
  background: rgba(0, 240, 255, 0.18);
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
}

.dock-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  transition: all 0.2s ease;
}

.dock-btn.active .dock-indicator {
  background: var(--neon-green);
  box-shadow: 0 0 6px var(--neon-green);
}

/* --- Slide-Up Bottom Sheet Drawer (Menu) --- */
.sheet-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sheet-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 75vh;
  background: #0f1420;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6);
  z-index: 51;
  transform: translateY(105%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.bottom-sheet.open {
  transform: translateY(0);
}

.sheet-handle-wrap {
  width: 100%;
  padding: 10px 0 6px;
  display: flex;
  justify-content: center;
  cursor: pointer;
}

.sheet-handle {
  width: 38px;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.25);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 18px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sheet-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.sheet-close-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sheet-close-btn svg {
  width: 14px;
  height: 14px;
}

.sheet-content {
  padding: 16px 18px 30px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Detail Cards inside Sheet */
.info-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.info-card-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--neon-cyan);
  text-transform: uppercase;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-box {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  margin-top: 2px;
}

.telemetry-pre {
  background: #06080d;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--neon-green);
  max-height: 140px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.sheet-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px;
  background: rgba(0, 240, 255, 0.15);
  border: 1px solid var(--neon-cyan);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

/* --- Camera Permission Modal --- */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(4, 7, 13, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  max-width: 420px;
  width: 100%;
  background: #0f1523;
  border: 1px solid rgba(0, 240, 255, 0.4);
  border-radius: var(--radius-card);
  box-shadow: 0 10px 40px rgba(0, 240, 255, 0.25);
  padding: 24px;
  text-align: center;
}

.modal-icon-wrap {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 240, 255, 0.15);
  border-radius: 50%;
  color: var(--neon-cyan);
}

.modal-icon-wrap svg {
  width: 28px;
  height: 28px;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.modal-desc {
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 20px;
  background: linear-gradient(135deg, #00f0ff, #9d00ff);
  border: none;
  border-radius: var(--radius-full);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 240, 255, 0.4);
}

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