:root {
  --bg: #111114;
  --card: #1a1a20;
  --card2: #22222a;
  --line: rgba(255, 255, 255, .09);
  --line2: rgba(255, 255, 255, .16);
  --text: #ececf2;
  --muted: #9b9ba8;
  --accent: #b48cff;
  --accent2: #8a5cff;
  --ok: #7cf0b4;
  --ok2: #3fd99a;
  --warn: #ffb86b;
  --live: #ff5d6c;
  --radius: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
main { padding: 12px; display: flex; flex-direction: column; gap: 10px; max-width: 520px; margin: 0 auto; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.center { text-align: center; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.info { min-height: 1.3em; color: var(--ok); }
.info.warn { color: var(--warn); }
.info:empty { display: none; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand { display: flex; align-items: center; gap: 7px; }
.brand h1 { margin: 0; font-size: 19px; letter-spacing: .01em; font-weight: 750; }
.brand img { display: block; transition: transform .5s cubic-bezier(.3, 1.6, .5, 1); }
.brand:hover img { transform: rotate(-12deg) scale(1.08); }
.pill { display: flex; align-items: center; gap: 7px; background: #0b0b0d; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 12px; max-width: 62%; }
.pill span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #6b6b76; }
.dot.armed { background: var(--ok); box-shadow: 0 0 0 3px rgba(124, 240, 180, .15); }
.dot.gone { background: var(--accent); box-shadow: 0 0 0 3px rgba(180, 140, 255, .2); }
.dot.warn { background: var(--warn); }
.dot.busy { background: var(--accent); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }

/* ---------- stage: what others see ---------- */
.stage { position: relative; margin: 0; border-radius: var(--radius); overflow: hidden; background: #000; aspect-ratio: 16 / 9; border: 1px solid var(--line); }
.stage canvas { display: block; width: 100%; height: 100%; object-fit: cover; }
.stage.portrait { aspect-ratio: 3 / 4; max-height: 300px; align-self: center; width: auto; }
.badge { position: absolute; left: 8px; top: 8px; display: flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 999px; background: rgba(0, 0, 0, .55); backdrop-filter: blur(6px); font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.bdot { width: 7px; height: 7px; border-radius: 50%; background: var(--live); }
.stage[data-mode="gone"] .bdot { background: var(--accent); }
.stage[data-mode="away"] .bdot { background: var(--ok); animation: blink 1.6s infinite; }
.stageEmpty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 2px; color: var(--muted);
  background: radial-gradient(120% 90% at 50% 110%, rgba(138, 92, 255, .28), transparent 60%), repeating-linear-gradient(45deg, #15151a 0 10px, #17171d 10px 20px); }
.stageEmpty span { font-weight: 650; color: var(--text); font-size: 14px; }

/* ---------- the two big buttons ---------- */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.act {
  position: relative; display: grid; justify-items: start; gap: 1px; text-align: left;
  padding: 12px 12px 11px; border-radius: 14px; border: 0; cursor: pointer; font: inherit; color: #140b26;
  transition: transform .12s ease, filter .15s ease, box-shadow .2s ease, opacity .2s;
}
.act:active:not(:disabled) { transform: scale(.97); }
.act:hover:not(:disabled) { filter: brightness(1.07); }
.act:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.act.vanish { background: linear-gradient(140deg, #8a5cff, #c3a2ff); box-shadow: 0 6px 22px -10px rgba(138, 92, 255, .9); }
.act.away { background: linear-gradient(140deg, #4a8cff, #8fd0ff); box-shadow: 0 6px 22px -10px rgba(74, 140, 255, .9); color: #06162b; }
.act.back { background: linear-gradient(140deg, var(--ok2), var(--ok)); color: #062417; box-shadow: 0 6px 22px -10px rgba(63, 217, 154, .9); }
.act.needs { background: var(--card2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line2); }
.act.needs .actSub { color: var(--warn); }
.act:disabled { opacity: .45; cursor: default; }
.act.busy .actIco svg { animation: spin 1.2s linear infinite; }
.actIco svg { width: 20px; height: 20px; fill: currentColor; stroke: currentColor; display: block; margin-bottom: 4px; }
.actLbl { font-size: 15px; font-weight: 750; letter-spacing: .01em; }
.actSub { font-size: 11px; opacity: .8; }
.act kbd { position: absolute; right: 9px; top: 9px; font: 600 10px/1 ui-monospace, monospace; opacity: .55; }
.hint { min-height: 1.3em; text-align: center; color: var(--muted); font-size: 12px; }
.hint b { color: var(--text); }
.note { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: rgba(255, 184, 107, .08); border: 1px solid rgba(255, 184, 107, .35); font-size: 12px; color: var(--muted); }
.note p { flex: 1; }
.note b { color: var(--warn); }
.note button { flex: none; }

/* ---------- setup checklist ---------- */
.setup { display: flex; flex-direction: column; gap: 6px; }
.setupHead { display: flex; align-items: center; gap: 8px; padding: 4px 2px 0; }
.setupHead h2 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.meter { flex: 1; height: 4px; border-radius: 4px; background: var(--card2); overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent2), var(--ok)); transition: width .5s ease; }
.step { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: border-color .3s; }
.step.flash { animation: flash 1.2s ease; }
@keyframes flash { 0%, 60% { border-color: var(--warn); box-shadow: 0 0 0 3px rgba(255, 184, 107, .18); } }
.stepHead { all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px; cursor: pointer; }
.stepHead:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius); }
.num { flex: none; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--card2); border: 1px solid var(--line2); color: var(--text); font-size: 11px; font-weight: 700; transition: background .3s; }
.step.done .num { background: var(--ok); border-color: transparent; color: #062417; font-size: 0; }
.step.done .num::after { content: ""; width: 9px; height: 5px; border: solid #062417; border-width: 0 0 2px 2px; transform: translate(0, -1px) rotate(-45deg); }
.step.todo .num { background: var(--accent); color: #140b26; border-color: transparent; }
.stepTitle { flex: 1; display: grid; min-width: 0; }
.stepTitle b { font-size: 13px; }
.stepTitle small { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step.done .stepTitle small { color: var(--ok); }
.step.warn .stepTitle small { color: var(--warn); }
.chev { width: 8px; height: 8px; border: solid var(--muted); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); transition: transform .2s; margin-right: 4px; }
.step.open .chev { transform: rotate(-135deg); }
.stepBody { display: none; padding: 0 10px 11px 42px; flex-direction: column; gap: 8px; }
.step.open .stepBody { display: flex; }
.howto { margin: 0; padding-left: 16px; color: var(--muted); }
.howto li + li { margin-top: 2px; }
.howto b { color: var(--text); }
canvas.prev { width: 100%; max-width: 320px; height: auto; aspect-ratio: 16 / 9; background: #000; border-radius: 8px; }

/* ---------- controls ---------- */
button, .file {
  background: #26262e; color: var(--text); border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 8px; padding: 6px 11px; font: inherit; cursor: pointer; transition: background .15s;
}
button:not(.act):enabled:hover, .file:hover { background: #30303a; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: #140b26; border-color: transparent; font-weight: 650; }
button.primary:enabled:hover { background: #c3a2ff; }
button.quiet { background: transparent; }
button.small { padding: 3px 8px; font-size: 11.5px; }
.file input { display: none; }
.chips { display: flex; align-items: center; gap: 5px; }
.chips .muted { margin-right: 3px; font-size: 12px; }
.chip { padding: 3px 9px; border-radius: 999px; font-size: 12px; }
.chip[aria-checked="true"] { background: rgba(180, 140, 255, .18); border-color: var(--accent); color: #e2d4ff; }
.toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; color: var(--muted); }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle span { width: 30px; height: 18px; border-radius: 999px; background: var(--card2); border: 1px solid var(--line2); position: relative; transition: background .2s; flex: none; }
.toggle span::after { content: ""; position: absolute; left: 2px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: #bbb; transition: transform .2s, background .2s; }
.toggle input:checked + span { background: rgba(124, 240, 180, .25); border-color: var(--ok2); }
.toggle input:checked + span::after { transform: translateX(12px); background: var(--ok); }
.toggle input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.waiting { display: flex; gap: 10px; align-items: flex-start; background: rgba(180, 140, 255, .08); border: 1px dashed rgba(180, 140, 255, .4); border-radius: 10px; padding: 9px; }
.waiting > div { display: grid; gap: 4px; min-width: 0; }
.waiting small { color: var(--muted); }
.spinner { flex: none; width: 16px; height: 16px; margin-top: 1px; border-radius: 50%; border: 2px solid rgba(180, 140, 255, .3); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.link { width: 100%; background: #0b0b0d; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; font: 11px ui-monospace, monospace; }
.clipBox { display: flex; gap: 10px; align-items: flex-start; }
.clipPrev { position: relative; flex: none; width: 128px; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #000; }
.clipPrev img, .clipPrev video { width: 100%; height: 100%; object-fit: cover; display: block; }
.loopTag { position: absolute; right: 4px; bottom: 4px; font-size: 9.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; background: rgba(0, 0, 0, .6); padding: 1px 5px; border-radius: 4px; }
.clipMeta { display: grid; gap: 3px; justify-items: start; }

/* ---------- troubleshooting ---------- */
.trouble { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.trouble > * + * { margin-top: 8px; }
.trouble summary { cursor: pointer; color: var(--muted); }
textarea { width: 100%; background: #0b0b0d; color: var(--text); border: 1px solid var(--line); border-radius: 6px; font: 11px/1.4 ui-monospace, monospace; padding: 6px; resize: vertical; }

/* ---------- toasts ---------- */
#toasts { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); display: grid; gap: 6px; width: min(92vw, 380px); z-index: 10; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; background: #2a2a34; border: 1px solid var(--line2); border-radius: 11px; padding: 9px 11px; box-shadow: 0 10px 30px -10px #000; animation: toastIn .35s cubic-bezier(.2, 1.4, .4, 1); }
.toast.out { animation: toastOut .25s ease forwards; }
.toast p { flex: 1; }
.toast.warn { border-color: rgba(255, 184, 107, .5); }
.toast button { padding: 4px 10px; }
@keyframes toastIn { from { transform: translateY(14px) scale(.96); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(8px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* phones: Zoom's mobile app panel */
body.mobile main { padding: 14px; gap: 12px; }
body.mobile .act { padding: 16px 14px; }
body.mobile .act kbd { display: none; }
body.mobile .actLbl { font-size: 16px; }

/* Camera Mode instance: transparent full-frame overlay */
body.camera { background: transparent; overflow: hidden; }
body.camera #cam, body.camera #away { position: fixed; inset: 0; width: 100vw; height: 100vh; }

/* local preview without Zoom (?mock=1) */
body.mocked main { margin: 0; }
#mock { position: fixed; right: 12px; top: 12px; width: 480px; }
#mock iframe { width: 480px; height: 270px; border: 1px solid var(--line); border-radius: 8px; display: block; background: #000; }
#mock canvas.phone { width: 270px; height: 480px; border: 1px solid var(--line); border-radius: 18px; display: block; background: #000; }
#mock p { color: var(--muted); font-size: 11px; }
#mockcam { position: fixed; inset: 0; width: 100vw; height: 100vh; }
@media (max-width: 1000px) { #mock { position: static; width: auto; padding: 12px; } #mock iframe { width: 100%; height: auto; aspect-ratio: 16 / 9; } }
