/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-card-hover: #222636;
  --text: #e4e6f0;
  --text-dim: #8b8fa3;
  --accent: #7c5cfc;
  --accent-hover: #9575fd;
  --accent-glow: rgba(124, 92, 252, 0.25);
  --green: #4ade80;
  --green-glow: rgba(74, 222, 128, 0.25);
  --red: #f87171;
  --yellow: #fbbf24;
  --border: #2a2d3a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --transition: 0.2s ease;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

/* === Header === */
.header {
  background: linear-gradient(135deg, #1a1025 0%, #1a1d27 50%, #0f1624 100%);
  border-bottom: 1px solid var(--border);
  padding: 28px 0 20px;
  text-align: center;
}
.logo {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #fff;
}
.logo .dot { color: var(--accent); }
.logo span { font-weight: 400; color: var(--text-dim); }
.tagline {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-top: 6px;
}

/* === Cards === */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  margin: 24px 0;
  box-shadow: var(--shadow);
}
.card-icon { font-size: 3rem; text-align: center; margin-bottom: 12px; }
.card h2 { font-size: 1.35rem; margin-bottom: 12px; color: #fff; }
.card h3 { font-size: 1.05rem; margin-bottom: 8px; color: var(--text); }

/* === Buttons === */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; transition: all var(--transition);
  font-family: inherit;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  background: var(--bg-card-hover); color: var(--text); border-color: var(--border);
}
.btn-secondary:hover { background: #2e3246; }
.btn-outline {
  background: transparent; color: var(--accent); border-color: var(--accent);
}
.btn-outline:hover { background: rgba(124,92,252,0.1); }
.btn-sm { padding: 6px 14px; font-size: 0.85rem; }
.btn-lg { padding: 14px 32px; font-size: 1.1rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* === Permission Gate === */
.permission-gate { text-align: center; }
.permission-gate p { margin-bottom: 16px; color: var(--text-dim); }
.hint { font-size: 0.82rem; color: var(--text-dim); margin-top: 10px; }

/* === Ad Banners === */
.ad-banner {
  text-align: center;
  padding: 12px 0;
  min-height: 90px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.ad-banner:last-of-type { border-bottom: none; border-top: 1px solid var(--border); }

/* === Device Selector === */
.device-selector {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.device-selector label { font-weight: 600; white-space: nowrap; }
.select {
  flex: 1; min-width: 180px; padding: 8px 12px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.9rem; font-family: inherit;
}

/* === Video Container === */
.video-container {
  position: relative; width: 100%; max-width: 720px;
  margin: 0 auto 16px; border-radius: var(--radius);
  overflow: hidden; background: #000;
  aspect-ratio: 16 / 10;
}
.video-container video,
.video-container canvas {
  width: 100%; height: 100%; object-fit: contain;
}
.video-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.7); color: var(--text-dim);
  font-size: 1rem;
}
.video-overlay.hidden, .hidden { display: none !important; }

/* === Camera Controls === */
.camera-controls, .mic-controls {
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
  margin-bottom: 12px;
}

/* === Snapshot Status === */
.snapshot-status {
  text-align: center; font-size: 0.88rem; color: var(--text-dim);
  padding: 8px 0;
}
.pulse {
  display: inline-block; width: 10px; height: 10px;
  border-radius: 50%; background: var(--green);
  animation: pulse 1.5s ease-in-out infinite;
  box-shadow: 0 0 8px var(--green-glow);
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

/* === Snapshot Gallery === */
.snapshot-gallery { margin-top: 16px; }
.gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px; margin-top: 8px;
}
.gallery-item {
  position: relative;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.gallery-item img {
  width: 100%; aspect-ratio: 16/10; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  cursor: pointer; transition: transform var(--transition);
}
.gallery-item img:hover { transform: scale(1.05); }
.btn-delete-snapshot {
  position: absolute; top: 4px; right: 4px;
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(0,0,0,0.7); border: 1px solid var(--red);
  color: var(--red); font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity var(--transition);
}
.gallery-item:hover .btn-delete-snapshot { opacity: 1; }
.btn-delete-snapshot:hover { background: var(--red); color: #fff; }

/* === VU Meter === */
.vu-meter-container {
  max-width: 400px; margin: 0 auto;
}
.vu-meter {
  height: 24px; background: var(--bg);
  border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border); margin-bottom: 6px;
}
.vu-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--green), var(--yellow), var(--red));
  border-radius: 12px; transition: width 0.05s linear;
}
.vu-labels {
  display: flex; justify-content: space-between;
  font-size: 0.7rem; color: var(--text-dim); margin-bottom: 4px;
}
.vu-value { text-align: center; font-size: 0.85rem; color: var(--text-dim); }

/* === Diagnostics === */
.diag-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}
.diag-block {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px;
}
.diag-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.diag-table td { padding: 4px 8px; border-bottom: 1px solid var(--border); }
.diag-table td:first-child {
  color: var(--text-dim); white-space: nowrap; width: 45%;
}
.diag-table td:last-child { word-break: break-all; }
.diag-table tr:last-child td { border-bottom: none; }

/* === Codec Tags === */
.codec-tag {
  display: inline-block; padding: 3px 8px; margin: 2px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 4px; font-size: 0.75rem; font-family: monospace;
}
.codec-tag.supported { border-color: var(--green); color: var(--green); }
.codec-tag.unsupported { border-color: var(--red); color: var(--red); opacity: 0.6; }

/* === Affiliate === */
.affiliate-section { text-align: center; }
.affiliate-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-top: 16px;
}
.affiliate-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 20px;
  text-decoration: none; color: inherit;
  transition: all var(--transition); text-align: center;
}
.affiliate-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--accent-glow);
}
.affiliate-img { font-size: 2.5rem; margin-bottom: 8px; }
.affiliate-card h4 { margin-bottom: 6px; }
.affiliate-card p { font-size: 0.85rem; color: var(--text-dim); }
.price {
  display: inline-block; margin-top: 8px; padding: 4px 12px;
  background: var(--accent); color: #fff; border-radius: 20px;
  font-size: 0.85rem; font-weight: 600;
}

/* === Footer === */
.footer {
  text-align: center; padding: 24px 0;
  border-top: 1px solid var(--border);
  color: var(--text-dim); font-size: 0.82rem;
}
.footer-links { margin-top: 8px; }
.footer-links a { color: var(--text-dim); margin: 0 6px; }
.footer-links a:hover { color: var(--accent); }

/* === Status Messages === */
.status-msg {
  text-align: center; padding: 12px; border-radius: var(--radius-sm);
  margin: 12px 0; font-size: 0.9rem;
}
.status-msg.error { background: rgba(248,113,113,0.15); color: var(--red); border: 1px solid rgba(248,113,113,0.3); }
.status-msg.success { background: rgba(74,222,128,0.15); color: var(--green); border: 1px solid rgba(74,222,128,0.3); }
.status-msg.info { background: rgba(124,92,252,0.12); color: var(--accent-hover); border: 1px solid rgba(124,92,252,0.3); }

/* === Responsive === */
@media (max-width: 768px) {
  .logo { font-size: 1.3rem; }
  .card { padding: 20px 14px; }
  h2 { font-size: 1.15rem; }
  .diag-grid { grid-template-columns: 1fr; }
  .affiliate-grid { grid-template-columns: 1fr; }
  .device-selector { flex-direction: column; align-items: stretch; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .btn-lg { padding: 12px 20px; font-size: 1rem; }
}

@media (max-width: 480px) {
  .logo { font-size: 1.1rem; }
  .btn { padding: 8px 14px; font-size: 0.85rem; }
}
