@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=Inter:wght@400;500;600&display=swap');

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

:root {
  --bg:        #080b10;
  --bg-card:   #0d1117;
  --bg-muted:  #161b22;
  --border:    #21262d;
  --fg:        #e6edf3;
  --fg-muted:  #8b949e;
  --primary:   #00f5ff;
  --secondary: #00ff88;
  --danger:    #f85149;
  --radius:    8px;
  --font-mono: 'Space Mono', monospace;
  --font-sans: 'Inter', sans-serif;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- LAYOUT ---- */
.layout { display: flex; flex: 1; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo .icon {
  width: 34px; height: 34px;
  border-radius: 6px;
  background: rgba(0,245,255,0.08);
  border: 1px solid rgba(0,245,255,0.25);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 12px rgba(0,245,255,0.12);
}

.sidebar-logo .icon svg { width: 18px; height: 18px; color: var(--primary); }

nav { flex: 1; padding: 16px 12px; }

nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg-muted);
  text-decoration: none;
  transition: all 0.15s ease;
  margin-bottom: 4px;
}

nav a:hover { color: var(--fg); background: rgba(255,255,255,0.04); }

nav a.active {
  color: var(--primary);
  background: rgba(0,245,255,0.08);
  border: 1px solid rgba(0,245,255,0.2);
  box-shadow: 0 0 8px rgba(0,245,255,0.04);
}

nav a svg { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 20px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(139,148,158,0.4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
  border-top: 1px solid var(--border);
  line-height: 1.8;
}

.main { flex: 1; overflow-y: auto; padding: 48px; }

.page-header { margin-bottom: 36px; }
.page-header h1 {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 12px;
}
.page-header h1 svg { color: var(--secondary); }
.page-header p {
  margin-top: 8px;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 13px;
}

/* ---- CAMERA ---- */
.camera-grid { display: grid; grid-template-columns: 1fr 320px; gap: 28px; }

.camera-wrap {
  position: relative;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: radial-gradient(ellipse at center, #0a1520 0%, #050810 100%);
}

.camera-wrap video,
.camera-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.camera-wrap canvas { z-index: 2; pointer-events: none; }

.cam-status {
  position: absolute;
  top: 14px; left: 14px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-muted);
}

.cam-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--fg-muted);
}

.cam-dot.active {
  background: var(--secondary);
  box-shadow: 0 0 8px rgba(0,255,136,0.8);
  animation: pulse 2s infinite;
}

.cam-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.8);
}

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

.cam-overlay .spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(0,245,255,0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

.cam-overlay p {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gesture-badge {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.2s;
}

.gesture-badge.visible { opacity: 1; }

.gesture-badge .name-tag {
  background: rgba(8,11,16,0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0,245,255,0.4);
  color: var(--primary);
  padding: 8px 20px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 0 20px rgba(0,245,255,0.2);
}

.gesture-badge .cmd-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--secondary);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(0,255,136,0.8);
}

/* ---- COMMAND LOG ---- */
.cmd-log {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.cmd-log h3 {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(0,245,255,0.15);
  margin-bottom: 16px;
}

.cmd-log .entries { flex: 1; overflow-y: auto; }

.cmd-log .empty {
  color: rgba(139,148,158,0.4);
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: center;
  margin-top: 40px;
  letter-spacing: 0.06em;
}

.cmd-entry {
  display: flex;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  margin-bottom: 12px;
  color: var(--fg-muted);
}

.cmd-entry.fresh { color: var(--fg); }
.cmd-entry .ts { color: rgba(0,245,255,0.5); flex-shrink: 0; }
.cmd-entry .gesture-name { color: var(--secondary); }

/* ---- GESTURE GRID ---- */
.gesture-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.gesture-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.gesture-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(0,245,255,0.04), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}

.gesture-card:hover { border-color: rgba(0,245,255,0.4); }
.gesture-card:hover::before { opacity: 1; }

.gesture-card .icon {
  width: 36px; height: 36px;
  margin-bottom: 16px;
  color: var(--primary);
}

.gesture-card h3 {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}

.gesture-card .badge {
  display: inline-block;
  padding: 3px 10px;
  background: rgba(0,255,136,0.1);
  border: 1px solid rgba(0,255,136,0.2);
  color: var(--secondary);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.gesture-card p {
  font-size: 13px;
  color: var(--fg-muted);
}

/* ---- INTEGRATE ---- */
.code-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  max-width: 720px;
  margin-bottom: 32px;
}

.code-block-header {
  background: var(--bg-muted);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-muted);
}

.code-block-header .file { display: flex; align-items: center; gap: 8px; }

.copy-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 4px;
  transition: background 0.15s;
  letter-spacing: 0.08em;
}

.copy-btn:hover { background: rgba(0,245,255,0.08); }

.code-block pre {
  padding: 20px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  overflow-x: auto;
  color: var(--primary);
  background: #0d0d12;
}

.feature-list {
  list-style: none;
  space: 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg-muted);
}

.feature-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.feature-list li::before {
  content: '>';
  color: var(--secondary);
  flex-shrink: 0;
  margin-top: 1px;
}

.section-title {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
}

/* ---- UTILS ---- */
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes spin  { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .camera-grid { grid-template-columns: 1fr; }
  .main { padding: 24px; }
  .sidebar { width: 200px; }
}

@media (max-width: 640px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  nav { display: flex; flex-direction: row; overflow-x: auto; padding: 8px; }
  nav a { white-space: nowrap; margin-bottom: 0; margin-right: 4px; }
}
