:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #1a1a2e;
  --bg-card: #16213e;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0a0;
  --accent: #0f3460;
  --success: #00c853;
  --warning: #ffc107;
  --error: #ff1744;
  --border: #2a2a4a;
}

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

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

/* ==================== Camera Page ==================== */
.camera-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  gap: 20px;
}

.header {
  text-align: center;
}

.header h1 {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--text-primary);
}

.header p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.preview-container {
  position: relative;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 9 / 16;
  background: var(--bg-secondary);
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 14px;
}

.preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.preview-placeholder svg {
  width: 64px;
  height: 64px;
  opacity: 0.4;
}

/* Status badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
}

.status-dot.connected { background: var(--success); }
.status-dot.connecting { background: var(--warning); animation: pulse 1.2s infinite; }
.status-dot.waiting { background: var(--text-secondary); opacity: 0.6; }
.status-dot.error { background: var(--error); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Button */
.btn-start {
  padding: 14px 48px;
  font-size: 1.05rem;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-start:hover {
  background: #1a4a7a;
}

.btn-start:active {
  transform: scale(0.97);
}

.btn-start:disabled {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: not-allowed;
}

/* ==================== Viewer Page ==================== */
.viewer-page {
  width: 100vw;
  height: 100vh;
  background: #000;
  position: relative;
  overflow: hidden;
}

.viewer-page video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.viewer-controls {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
  z-index: 10;
}

.viewer-controls button {
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  backdrop-filter: blur(8px);
  transition: background 0.2s;
}

.viewer-controls button:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ==================== Debug Panel ==================== */
.debug-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 100;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
}

.debug-panel {
  position: fixed;
  bottom: 12px;
  left: 12px;
  z-index: 100;
  background: rgba(22, 33, 62, 0.92);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  min-width: 240px;
  font-size: 0.78rem;
  line-height: 1.6;
  backdrop-filter: blur(10px);
  display: none;
}

.debug-panel.visible {
  display: block;
}

.debug-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.debug-row .label {
  color: var(--text-secondary);
}

.debug-row .value {
  color: var(--text-primary);
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.75rem;
}

/* ==================== Viewer waiting overlay ==================== */
.waiting-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 1rem;
  z-index: 5;
}

.waiting-overlay svg {
  width: 80px;
  height: 80px;
  opacity: 0.3;
}

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

/* ==================== Toast ==================== */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-60px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--text-primary);
  z-index: 200;
  transition: transform 0.3s ease;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  border-color: var(--error);
}

.toast.success {
  border-color: var(--success);
}
