:root {
  --bg: #101014;
  --panel: #1a1a20;
  --border: #2c2c36;
  --text: #e8e8ee;
  --muted: #9a9aa8;
  --accent: #6ea8fe;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
}

main {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

header h1 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: 0.01em;
}

header p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.sources {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* The drop target keeps the row's full width; the camera buttons sit beside it
   and wrap beneath on narrow (phone) screens rather than cramping. */
.sources .dropzone {
  flex: 1 1 240px;
}

.dropzone {
  flex: 1;
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover,
.dropzone.dragging {
  border-color: var(--accent);
  background: #14161d;
  color: var(--text);
}

.dropzone.has-image {
  padding: 1rem;
}

/* While the live feed is on, the drop target steps back — the camera owns the
   canvas, but a drop still swaps back to a still image. */
.dropzone.camera-active {
  opacity: 0.5;
}

.camera-btn {
  flex: 0 0 auto;
  align-self: stretch;
  padding-inline: 1.25rem;
  white-space: nowrap;
}

/* Camera on: invert to read as an engaged toggle rather than a call to action. */
.camera-btn.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--accent);
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  background: var(--panel);
}

.swatches {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  min-height: 20px;
}

/* Each swatch is a toggle button: click/tap to freeze or rotate that color. */
.swatch {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  appearance: none;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  transition: transform 0.1s, opacity 0.1s;
}

.swatch:hover {
  transform: scale(1.12);
}

.swatch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Frozen (deselected): dimmed and ringed so it reads as "not rotating". */
.swatch.off {
  opacity: 0.3;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.15rem;
}

.controls label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
  min-width: 220px;
  color: var(--muted);
}

.controls input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

/* A checkbox toggle sits inline with its label — not a full-width slider row. */
.controls label.toggle {
  flex: 0 0 auto;
  min-width: 0;
  gap: 0.4rem;
  cursor: pointer;
  color: var(--text);
}

.controls label.toggle input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
}

.controls .value {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  min-width: 3.5em;
  text-align: right;
}

button {
  background: var(--accent);
  color: #0b0b0f;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.status {
  color: var(--muted);
  min-height: 1.2em;
  font-variant-numeric: tabular-nums;
}

footer {
  color: var(--muted);
  font-size: 0.85rem;
}

footer a { color: var(--accent); }
