/* SilentStream — minimal, respects prefers-color-scheme */

:root {
  --bg: #f4f4f5;
  --surface: #ffffff;
  --text: #18181b;
  --muted: #71717a;
  --border: #e4e4e7;
  --primary: #18181b;
  --primary-text: #fafafa;
  --danger: #dc2626;
  --danger-text: #fff;
  --success: #16a34a;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --surface: #18181b;
    --text: #fafafa;
    --muted: #a1a1aa;
    --border: #27272a;
    --primary: #fafafa;
    --primary-text: #18181b;
    --danger: #ef4444;
    --danger-text: #fff;
    --success: #22c55e;
  }
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 1.5rem;
}
.header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.tagline {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

/* Mode switcher */
.mode-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.3rem;
  margin-bottom: 1.25rem;
}
.mode-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.55rem 0.75rem;
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.mode-btn.active {
  background: var(--primary);
  color: var(--primary-text);
}

/* Panels */
.panel { display: none; }
.panel.active { display: block; }
.panel-inner { display: flex; flex-direction: column; gap: 1rem; }
.hidden { display: none !important; }

/* File drop */
.file-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 140px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s;
}
.file-drop:hover,
.file-drop.dragover {
  border-color: var(--text);
}
.drop-label { font-weight: 600; font-size: 1rem; }
.drop-hint { font-size: 0.8rem; color: var(--muted); }

.file-info {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
}
.file-info .name { font-weight: 600; word-break: break-all; }
.file-info .meta { color: var(--muted); font-size: 0.8rem; margin-top: 0.25rem; }

/* Buttons */
.btn {
  appearance: none;
  border: none;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  transition: opacity 0.15s;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary {
  background: var(--primary);
  color: var(--primary-text);
}
.btn.danger {
  background: var(--danger);
  color: var(--danger-text);
}
.btn.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

/* QR + camera */
.qr-container {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #fff;
  border-radius: var(--radius);
  padding: 0.75rem;
  min-height: 280px;
}
.qr-container canvas {
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.video-wrap {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 3/4;
}
.video-wrap video,
.video-wrap .overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.overlay { pointer-events: none; }

/* Stats */
.stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.stats span { color: var(--text); font-weight: 600; }

/* Success */
.success {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}
.success h2 {
  font-size: 1.25rem;
  color: var(--success);
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  word-break: break-all;
}
.mono.small { font-size: 0.75rem; color: var(--muted); }

.hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Footer */
.footer {
  margin-top: auto;
  padding-top: 2rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}
.footer .sep { margin: 0 0.35rem; }

/* Fullscreen QR helper (when streaming) */
body.streaming .header,
body.streaming .mode-switcher,
body.streaming .footer {
  display: none;
}
body.streaming #app {
  max-width: none;
  padding: 0.5rem;
}
body.streaming .qr-container {
  min-height: min(80vh, 90vw);
  padding: 0.5rem;
}


/* Decoder engine indicator */
.decoder-indicator {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.decoder-indicator.wasm {
  color: var(--success);
}
.decoder-indicator.js {
  color: var(--muted);
}
