:root {
  --bg: #121212;
  --panel: #161616;
  --box: #0d0d0d;
  --ink: #ffffff;
  --muted: #a3a3a3;
  --line: #333333;
  --line-soft: #2a2a2a;
  --accent: #e8e8e8;
  --accent-ink: #111111;
  --danger: #ff7a6a;
  --ok: #7dffa3;
  --radius: 14px;
  --font: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
}

.brand {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line-soft);
}
.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  border: 1px solid var(--line);
  color: var(--muted);
}
.pill-on { color: var(--ok); border-color: rgba(125, 255, 163, 0.35); }
.pill-off { color: #ffb3a8; border-color: rgba(255, 122, 106, 0.35); }

input, textarea, button {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #1a1a1a;
  color: var(--ink);
}
input, textarea { padding: 0.75rem 0.85rem; width: 100%; }
textarea { resize: vertical; min-height: 84px; }
button {
  cursor: pointer;
  padding: 0.65rem 0.95rem;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  font-weight: 600;
}
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.dual-stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1rem 1.25rem;
}

.feed-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 0.85rem;
  min-width: 0;
}

.feed-label {
  margin: 0 0 0.7rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
}

.feed-box {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: 12px;
  overflow: hidden;
  background: var(--box);
  border: 1px solid var(--line-soft);
}

#camera,
#output {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

#camera.is-on,
#output.is-on {
  display: block;
}

.feed-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.feed-placeholder.is-hidden {
  display: none;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  padding: 0 1.25rem 1.5rem;
}

.control-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 0.9rem 1rem;
}

.control-card h3 {
  margin: 0 0 0.55rem;
  font-size: 0.92rem;
  font-weight: 600;
}

.file-btn {
  display: inline-flex;
  padding: 0.55rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #1f1f1f;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
}

#photo-preview {
  display: block;
  width: 100%;
  margin-top: 0.7rem;
  border-radius: 10px;
  max-height: 140px;
  object-fit: cover;
}

.obs-row {
  display: flex;
  gap: 0.5rem;
}

.obs-row input { flex: 1; }

.status-text {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

/* Auth */
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--bg);
}
.auth-shell {
  width: min(400px, 100%);
  padding: 1.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.auth-shell h1 {
  margin: 0.35rem 0 0.3rem;
  font-size: 1.55rem;
  letter-spacing: -0.03em;
}
.lede { color: var(--muted); margin: 0; }
.auth-form {
  display: grid;
  gap: 0.6rem;
  margin-top: 1.2rem;
}
.auth-form label { font-size: 0.85rem; color: var(--muted); }
.error { color: var(--danger); margin: 0; }

@media (max-width: 900px) {
  .dual-stage,
  .controls {
    grid-template-columns: 1fr;
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }
}
