:root {
  --bg: #0b0b0c;
  --card: #151518;
  --line: #26262b;
  --fg: #f2f2f3;
  --muted: #9a9aa2;
  --panel: rgba(20, 20, 22, 0.82);
  --accent: #2f7cf6;
  --go: #1fa855;
  --stop: #e0443a;
  --warn: #f0b429;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }
a { color: #7fb0ff; }
code { background: #222; padding: 1px 6px; border-radius: 4px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); margin-right: 6px; flex: none; }
.dot.ok { background: var(--go); } .dot.warn { background: var(--warn); } .dot.err { background: var(--stop); }

/* ------------------------------------------------ Dashboard (PC) */
.dash { height: auto; min-height: 100%; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 24px; border-bottom: 1px solid var(--line); }
.top h1 { font-size: 20px; margin: 0; }
.chip { display: inline-flex; align-items: center; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; }
.grid { display: grid; gap: 16px; padding: 16px 24px 32px; max-width: 1280px; margin: 0 auto;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.grid { align-items: start; }
.side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; min-width: 0; }
.card h2 { font-size: 17px; margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.card p { margin: 8px 0; }
.card ul { padding-left: 18px; margin: 8px 0; }
.card li { margin: 4px 0; font-size: 14px; }
.step { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); font-size: 14px; }
.preview { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 10px; overflow: hidden; }
.preview video { width: 100%; height: 100%; object-fit: contain; display: block; }
.preview-hint { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; margin-top: 10px; flex-wrap: wrap; }
.toggle { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; cursor: pointer; }
.qr { background: #fff; width: 220px; max-width: 100%; padding: 6px; border-radius: 10px; line-height: 0; }
.qr svg { width: 100%; height: auto; }
.copy { display: flex; gap: 8px; }
.copy input { flex: 1; min-width: 0; background: #0f0f11; color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; font: 13px ui-monospace, Consolas, monospace; }
.button { display: inline-block; border: 1px solid var(--line); background: #24242a; color: var(--fg); border-radius: 8px; padding: 9px 14px;
  font: inherit; font-size: 15px; cursor: pointer; text-decoration: none; text-align: center; }
.button:hover { background: #2d2d34; }
.button.primary { background: var(--accent); border-color: var(--accent); }
.button.danger { color: #ffb4ad; }
details summary { cursor: pointer; margin-top: 8px; font-size: 14px; }
.mobile { padding: 16px; max-width: 520px; margin: 0 auto; }
.mobile .button { width: 100%; padding: 16px; margin-top: 8px; }
@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; padding: 16px; }
  .top { padding: 14px 16px; }
}

/* ------------------------------------------------ Sender (iPhone) */
.send { overflow: hidden; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.send video { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.send video.mirror { transform: scaleX(-1); }
.controls { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0,0,0,.85) 25%); display: flex; flex-direction: column; gap: 8px; }
.seg { display: flex; background: var(--panel); border-radius: 12px; padding: 3px; }
.seg button { flex: 1; border: 0; background: transparent; color: var(--fg); font: inherit; font-size: 15px;
  padding: 10px 4px; border-radius: 9px; }
.seg button[aria-pressed="true"] { background: #3a3a40; font-weight: 600; }
#startStop { width: 100%; border: 0; border-radius: 16px; padding: 20px; font: inherit; font-size: 24px; font-weight: 700;
  color: #fff; background: var(--go); }
#startStop.running { background: var(--stop); }
#startStop:disabled { opacity: .6; }
.status { position: fixed; top: 0; left: 0; right: 0; padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: linear-gradient(rgba(0,0,0,.8), transparent); font-size: 13px; display: flex; flex-wrap: wrap; gap: 2px 12px; }
.banner { position: fixed; left: 12px; right: 12px; top: calc(60px + env(safe-area-inset-top)); background: #3b2a06;
  border: 1px solid var(--warn); color: #ffe7a6; padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.banner.err { background: #3b0b08; border-color: var(--stop); color: #ffc9c4; }
.noroom { position: fixed; inset: 0; display: grid; place-content: center; padding: 24px; text-align: center; }

/* iPhone quer (typisch als Webcam): Bedienung rechts, Vorschau links frei */
@media (orientation: landscape) and (max-height: 600px) {
  .send video { right: 270px; width: auto; }
  .controls { left: auto; top: 0; width: 270px; justify-content: center; background: #000;
    padding: calc(8px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 12px 12px; }
  .seg button { font-size: 14px; padding: 9px 2px; }
  #startStop { padding: 16px; font-size: 21px; }
  .status { right: 270px; }
  .banner { right: 282px; }
}

/* ------------------------------------------------ Empfänger (OBS): randlos, keine UI */
.view { overflow: hidden; cursor: none; background: #000; }
.view video { position: fixed; inset: 0; width: 100vw; height: 100vh; object-fit: contain; background: #000; }
.view.cover video { object-fit: cover; }
#stats.view-stats, .view #stats { position: fixed; left: 8px; top: 8px; font: 12px/1.35 ui-monospace, Consolas, monospace; color: #0f0;
  background: rgba(0,0,0,.6); padding: 6px 8px; white-space: pre; }
