:root {
  color-scheme: dark;
  --bg: #111827;
  --card: #1f2937;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --radius: 12px;
}

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

html,
body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

header {
  padding: 1rem;
  text-align: center;
  border-bottom: 1px solid #374151;
}

header h1 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.status-bar {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  background: #0f172a;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
}

/* === Semáforo === */
.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  position: relative;
  flex-shrink: 0;
}

.dot--gray {
  background: #6b7280;
}

.dot--green {
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
  animation: pulse-green 2s infinite;
}

.dot--red {
  background: var(--danger);
  animation: pulse-red 1.5s infinite;
}

.dot--yellow {
  background: var(--warning);
}

@keyframes pulse-green {
  0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  70%  { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

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

main {
  flex: 1;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card h2 {
  font-size: 1rem;
  color: var(--muted);
  font-weight: 500;
}

video,
img#preview {
  width: 100%;
  height: auto;
  background: #000;
  border-radius: var(--radius);
  max-height: 70vh;
  object-fit: contain;
}

.info {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

.controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

button,
label {
  flex: 1;
  min-width: 120px;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, transform 0.05s, opacity 0.15s;
}

button:active,
label:active {
  transform: scale(0.98);
}

button:disabled,
label:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.primary,
label {
  background: var(--primary);
  color: white;
}

button.primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

button.secondary {
  background: #374151;
  color: var(--text);
}

button.secondary:hover:not(:disabled) {
  background: #4b5563;
}

button[hidden],
section[hidden] {
  display: none !important;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #1f2937;
  color: var(--text);
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  font-size: 0.9rem;
  z-index: 100;
  max-width: 90%;
  text-align: center;
}

#toast.error {
  background: var(--danger);
}

#toast.success {
  background: var(--success);
}

#toast.warning {
  background: var(--warning);
  color: #111827;
}
