:root {
  --bg: #0e1014;
  --glass: rgb(255 255 255 / 0.06);
  --glass-hover: rgb(255 255 255 / 0.12);
  --line: rgb(255 255 255 / 0.08);
  --text: #f2f3f7;
  --muted: #8b91a1;
  --accent: #8b9dff;
  --accent-2: #b48cff;
  --danger: #ff8a8a;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.standalone { max-width: 760px; margin: 0 auto; border-inline: 1px solid var(--line); }

/* ---------- header ---------- */
header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 16px;
  background: linear-gradient(180deg, rgb(255 255 255 / 0.04), transparent);
  border-bottom: 1px solid var(--line);
  user-select: none;
}
body:not(.standalone) header { cursor: grab; touch-action: none; }
body.grabbing, body.grabbing * { cursor: grabbing !important; }
.logo { width: 22px; height: 22px; border-radius: 6px; display: block; }
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 10px rgb(139 157 255 / 0.7);
}
body[data-mode="live"] .dot { background: #5be49b; box-shadow: 0 0 10px rgb(91 228 155 / 0.8); }
header strong { flex: 1; font-size: 13px; font-weight: 600; letter-spacing: 0.01em; }
.timer { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---------- screen ---------- */
main { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #000; }
body.dragging main { outline: 2px dashed var(--accent); outline-offset: -8px; }

video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}
#local { transform: scaleX(-1); filter: brightness(0.55); }
body[data-mode="starting"] #local { display: block; }
/* stays "on screen" (just see-through) while waiting — Chrome won't start playing a hidden video */
#output { display: block; opacity: 0; transition: opacity 0.3s var(--ease); }
body[data-mode="live"] #output { opacity: 1; }

.idle {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  background: radial-gradient(120% 80% at 50% 0%, rgb(139 157 255 / 0.12), transparent 60%), #07080b;
}
.idle p { margin: 0 0 8px; max-width: 260px; }
.idle b { color: var(--text); font-weight: 600; }
.idle .privacy { margin: 14px 0 0; font-size: 11px; color: #5d6372; max-width: 240px; }
body:not([data-mode="idle"]) .idle { display: none; }
body:not([data-mode="live"]) .live-only { display: none; }
body[data-mode="idle"] .busy-only { display: none; }

.thumb {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 52px;
  height: 70px;
  object-fit: contain;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.5), 0 0 0 1px rgb(255 255 255 / 0.15);
}
body[data-mode="idle"] .thumb { display: none; }

.status {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 76px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgb(14 16 20 / 0.7);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  text-align: left;
  font-size: 12px;
}
.status:empty { display: none; }
.status[data-kind="error"] { color: var(--danger); }

.float { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); }

/* floating controls over the video */
footer {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: rgb(14 16 20 / 0.7);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
}
body[data-mode="idle"] footer:not(:has(#cart:not([hidden]))) { display: none; }

/* ---------- controls ---------- */
select {
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 28px 5px 12px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%238b91a1' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  transition: background-color 0.15s var(--ease);
}
select:hover { background-color: var(--glass-hover); }
select:focus-visible, button:focus-visible, .btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
select option { background: #1a1d24; color: var(--text); }

button, .btn {
  font: inherit;
  font-weight: 500;
  color: var(--text);
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 18px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s var(--ease), transform 0.15s var(--ease), border-color 0.15s var(--ease);
}
button:hover, .btn:hover { background: var(--glass-hover); }
button:active, .btn:active { transform: scale(0.97); }
.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #0b0d12;
  font-weight: 600;
  box-shadow: 0 6px 20px rgb(139 157 255 / 0.3);
}
.primary:hover { background: linear-gradient(135deg, #a0afff, #c4a4ff); }
.icon {
  width: 28px;
  height: 28px;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  font-size: 14px;
}
.icon:hover { color: var(--text); }
footer .icon { width: 34px; height: 34px; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
