/* ============================================================================
   Watch Together - Prototyp
   tk.weslie.WatchTogether

   Token-System: native CSS custom properties, ein Akzent (Ember).
   Radien-Regel: Flaechen 14px, Bedienelemente 10px, Chips/Pills voll rund.
   Hell ist Standard, Dunkel per data-theme="dark" am <html>.
   Dazwischen "dim": gedaempft, aber kein Schwarz. ========================= */

*, *::before, *::after { box-sizing: border-box; }

/* Klassen wie .btn setzen display und wuerden das hidden-Attribut sonst
   ueberstimmen. Verstecktes bleibt versteckt. */
[hidden] { display: none !important; }

:root {
  color-scheme: light;

  --bg:            #f3f3f4;
  --bg-grad:       radial-gradient(1200px 600px at 15% -10%, #ffffff 0%, transparent 60%);
  --surface:       #ffffff;
  --surface-2:     #fafafa;
  --surface-3:     #f1f1f2;
  --line:          #e5e5e7;
  --line-strong:   #d6d6da;
  --text:          #17171a;
  --text-2:        #55555d;
  --text-3:        #86868f;

  --accent:        #c9431a;
  --accent-hi:     #b03a15;
  --accent-on:     #ffffff;
  --accent-soft:   #fdeee8;
  --accent-line:   #f3cdbe;

  --ok:            #1c7a52;
  --ok-soft:       #e6f3ec;
  --warn:          #9a6212;
  --bad:           #b3261e;
  --bad-soft:      #fdeceb;

  --stage-bg:      #101013;

  --r-surface: 14px;
  --r-control: 10px;
  --r-pill:    999px;

  --shadow-1: 0 1px 2px rgb(23 23 26 / .05), 0 1px 1px rgb(23 23 26 / .04);
  --shadow-2: 0 12px 32px -12px rgb(23 23 26 / .18), 0 2px 8px -4px rgb(23 23 26 / .10);
  --shadow-3: 0 32px 80px -24px rgb(23 23 26 / .32), 0 4px 16px -8px rgb(23 23 26 / .14);

  --ease: cubic-bezier(.16, 1, .3, 1);
  --sans: "Segoe UI Variable Display", "Segoe UI", ui-sans-serif, system-ui,
          -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;

  --topbar-h: 60px;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg:            #0c0c0e;
  --bg-grad:       radial-gradient(1200px 600px at 15% -10%, #1a1a1f 0%, transparent 60%);
  --surface:       #141417;
  --surface-2:     #1a1a1e;
  --surface-3:     #202026;
  --line:          #26262c;
  --line-strong:   #343440;
  --text:          #f2f2f3;
  --text-2:        #a6a6b0;
  --text-3:        #75757f;

  --accent:        #ff7a45;
  --accent-hi:     #ff9166;
  --accent-on:     #241007;
  --accent-soft:   #2a1509;
  --accent-line:   #4a2412;

  --ok:            #4cc38a;
  --ok-soft:       #10261c;
  --warn:          #e0a33a;
  --bad:           #f2705f;
  --bad-soft:      #2b1210;

  --stage-bg:      #08080a;

  --shadow-1: 0 1px 2px rgb(0 0 0 / .40);
  --shadow-2: 0 12px 32px -12px rgb(0 0 0 / .60), 0 2px 8px -4px rgb(0 0 0 / .40);
  --shadow-3: 0 32px 80px -24px rgb(0 0 0 / .80), 0 4px 16px -8px rgb(0 0 0 / .50);
}

:root[data-theme="dim"] {
  color-scheme: dark;

  --bg:            #2b2b30;
  --bg-grad:       radial-gradient(1200px 600px at 15% -10%, #3a3a41 0%, transparent 60%);
  --surface:       #34343b;
  --surface-2:     #3b3b43;
  --surface-3:     #45454e;
  --line:          #505059;
  --line-strong:   #5f5f6a;
  --text:          #f0f0f1;
  --text-2:        #c2c2c9;
  --text-3:        #97979f;

  --accent:        #ff8a5c;
  --accent-hi:     #ff9f78;
  --accent-on:     #2a1006;
  --accent-soft:   #3a2013;
  --accent-line:   #5a3018;

  --ok:            #3bb87c;
  --ok-soft:       #1c3428;
  --warn:          #d1a13c;
  --bad:           #e8674f;
  --bad-soft:      #3a1f1a;

  --stage-bg:      #0d0d10;

  --shadow-1: 0 1px 2px rgb(0 0 0 / .30);
  --shadow-2: 0 12px 32px -12px rgb(0 0 0 / .45), 0 2px 8px -4px rgb(0 0 0 / .30);
  --shadow-3: 0 32px 80px -24px rgb(0 0 0 / .60), 0 4px 16px -8px rgb(0 0 0 / .35);
}

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor;
      stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.ta-r { text-align: right; }

:where(button, a, input, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-control);
}

/* ---------------------------------------------------------------- Buttons -- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; white-space: nowrap;
  border: 1px solid transparent; border-radius: var(--r-control);
  font-size: 14px; font-weight: 550; letter-spacing: -.005em;
  cursor: pointer; background: none;
  transition: background-color .18s var(--ease), border-color .18s var(--ease),
              transform .12s var(--ease), color .18s var(--ease);
}
.btn svg { width: 17px; height: 17px; }
.btn:active { transform: scale(.985); }

.btn-accent { background: var(--accent); color: var(--accent-on); }
.btn-accent:hover { background: var(--accent-hi); }

.btn-soft { background: var(--surface-3); color: var(--text); border-color: var(--line); }
.btn-soft:hover { background: var(--line); }

.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }

/* Laeuft die Uebertragung schon, wird aus dem Startknopf ein Beenden-Knopf. */
#btnLive.is-live { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
#btnLive.is-live:hover { background: var(--bad-soft); filter: brightness(0.96); }

.btn-sm { height: 34px; padding: 0 12px; font-size: 13.5px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; flex: none;
  border: 0; border-radius: var(--r-control);
  color: var(--text-2); background: none; cursor: pointer;
  transition: background-color .18s var(--ease), color .18s var(--ease), transform .12s var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn-lg { width: 42px; height: 42px; }
.icon-btn-lg svg { width: 22px; height: 22px; }
.icon-btn-xs { width: 26px; height: 26px; }
.icon-btn-xs svg { width: 15px; height: 15px; }

/* Theme-Toggle und Play/Pause zeigen je nach Zustand nur ein Glyph */
.ico-light, .ico-dim, .ico-dark { display: none; }
:root[data-theme="light"] .ico-light { display: block; }
:root[data-theme="dim"]   .ico-dim   { display: block; }
:root[data-theme="dark"]  .ico-dark  { display: block; }
.ico-pause, .is-playing .ico-play { display: none; }
.is-playing .ico-pause { display: block; }
.ico-off, .is-muted .ico-on { display: none; }
.is-muted .ico-off { display: block; }
.ico-unfull, .is-full .ico-full { display: none; }
.is-full .ico-unfull { display: block; }
.ico-narrow, .is-wide .ico-wide { display: none; }
.is-wide .ico-narrow { display: block; }

/* ---------------------------------------------------------------- Overlay -- */

.veil {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center; padding: 20px;
  /* Ein hoher Bogen soll sich rollen lassen und nicht oben abgeschnitten sein. */
  overflow-y: auto;
  background: rgb(12 12 14 / .52);
  backdrop-filter: blur(6px) saturate(120%);
  -webkit-backdrop-filter: blur(6px) saturate(120%);
  animation: veil-in .22s var(--ease) both;
}
.veil[hidden] { display: none; }

.sheet {
  width: min(560px, 100%);
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-surface);
  box-shadow: var(--shadow-3);
  animation: sheet-in .28s var(--ease) both;
}
.sheet-narrow { width: min(420px, 100%); }
.sheet-notice { border-color: var(--accent-line); }

.sheet-mark { margin-bottom: 18px; }
.sheet-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.sheet-head .sheet-title { flex: 1; }
.sheet-head-actions { display: flex; gap: 2px; margin: -6px -6px 0 0; }

.sheet-title { font-size: 21px; font-weight: 650; letter-spacing: -.022em; line-height: 1.25; }
.sheet-lead { margin-top: 8px; color: var(--text-2); font-size: 14.5px; max-width: 52ch; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }

.logomark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent); color: var(--accent-on);
}
.logomark svg { width: 18px; height: 18px; }

@keyframes veil-in  { from { opacity: 0 } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(10px) scale(.985) } }

/* ---------------------------------------------------------------- Felder --- */

.field-form { margin-top: 22px; display: grid; gap: 18px; }
.field { display: grid; gap: 7px; }
.field-label { font-size: 13px; font-weight: 550; color: var(--text-2); }

.input {
  width: 100%; height: 44px; padding: 0 14px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  color: var(--text);
  transition: border-color .18s var(--ease), background-color .18s var(--ease);
}
.input::placeholder { color: var(--text-3); }
.input:hover { border-color: var(--text-3); }
.input:focus { outline: none; border-color: var(--accent); background: var(--surface); }

.field-hint  { font-size: 12.5px; color: var(--text-3); }
.field-error { font-size: 12.5px; color: var(--accent); font-weight: 550; }
.field-error[hidden] { display: none; }

/* Gruppe von Feldern, die zusammengehoeren. Eine Haarlinie trennt sie vom
   Block darueber, sonst schwimmt alles im gleichen Abstand. */
.group { display: grid; gap: 14px; padding-top: 18px; border-top: 1px solid var(--line); }
.group-head { display: grid; gap: 3px; }
.group-title { font-size: 14px; font-weight: 600; letter-spacing: -.012em; }
.group-lead { font-size: 12.5px; color: var(--text-2); max-width: 62ch; }
.group-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }

/* Schalter. Ein gewoehnliches Kaestchen, nur anders gezeichnet. Die ganze
   Zeile ist die Beschriftung, also schaltet auch ein Klick daneben. */
.switch-row {
  display: flex; align-items: center; gap: 18px;
  padding: 14px; cursor: pointer;
  background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-control);
  transition: border-color .18s var(--ease), background-color .18s var(--ease);
}
.switch-row:hover { border-color: var(--line-strong); }
.switch-main { display: grid; gap: 3px; min-width: 0; }
.switch-label { font-size: 14px; font-weight: 550; }
.switch-hint { font-size: 12.5px; color: var(--text-2); }

.switch {
  appearance: none; -webkit-appearance: none;
  position: relative; flex: none;
  width: 42px; height: 24px; margin: 0; border-radius: var(--r-pill);
  background: var(--line-strong); cursor: pointer;
  transition: background-color .18s var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgb(23 23 26 / .35);
  transition: transform .18s var(--ease);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }

.suggest { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.suggest-flat { margin-top: 0; padding-top: 0; border-top: 0; }
.suggest-head { display: flex; align-items: center; gap: 4px; }
.suggest-label { font-size: 12.5px; color: var(--text-3); }
.suggest-more {
  display: grid; place-items: center;
  width: 24px; height: 24px; border: 0; border-radius: 7px;
  background: none; color: var(--text-3); cursor: pointer;
  transition: background-color .18s var(--ease), color .18s var(--ease), transform .3s var(--ease);
}
.suggest-more svg { width: 14px; height: 14px; }
.suggest-more:hover { background: var(--surface-3); color: var(--text); }
.suggest-more:active { transform: rotate(-90deg); }
.suggest-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.suggest-pill {
  height: 30px; padding: 0 12px; border-radius: var(--r-pill);
  border: 1px solid var(--line-strong); background: var(--surface-2);
  color: var(--text-2); font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  transition: border-color .18s var(--ease), color .18s var(--ease), background-color .18s var(--ease);
}
.suggest-pill:hover { border-color: var(--accent); color: var(--text); background: var(--surface); }
.suggest-pill b { font-weight: 550; color: var(--text-3); font-size: 12px; }

/* Fusszeile des Raumdialogs: der Verweis auf das Projekt. Mittig, leise. */
.sheet-foot { margin-top: 20px; text-align: center; }
.foot-link {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--text-3); font-size: 12.5px; text-decoration: none;
  padding: 5px 10px; border-radius: var(--r-pill);
  transition: color .18s var(--ease), background-color .18s var(--ease);
}
.foot-link svg { width: 15px; height: 15px; flex: none; }
.foot-link:hover { color: var(--text); background: var(--surface-3); }
.foot-link:focus-visible { color: var(--text); background: var(--surface-3); }

/* ---------------------------------------------------------------- Topbar --- */

.app[hidden] { display: none; }
.app { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  height: var(--topbar-h); padding: 0 18px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand-name { font-weight: 620; letter-spacing: -.02em; font-size: 15.5px; }

.room-chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 12px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--line-strong);
  cursor: pointer; color: var(--text-2);
  transition: border-color .18s var(--ease), color .18s var(--ease);
}
.room-chip:hover { border-color: var(--accent); color: var(--text); }
.room-name { font-family: var(--mono); font-size: 13px; color: var(--text); }
.room-copy { width: 15px; height: 15px; }
.room-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.me-chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 10px 0 4px; border-radius: var(--r-pill);
  border: 1px solid transparent; background: none; cursor: pointer;
  transition: background-color .18s var(--ease), border-color .18s var(--ease);
}
.me-chip:hover { background: var(--surface); border-color: var(--line); }
.me-name { font-size: 14px; font-weight: 550; max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-edit { width: 14px; height: 14px; color: var(--text-3); }

.avatar {
  display: grid; place-items: center; flex: none;
  width: 26px; height: 26px; border-radius: 50%;
  font-size: 11.5px; font-weight: 650; letter-spacing: .01em;
  color: #fff; background: var(--text-3);
}

/* ---------------------------------------------------------------- Layout --- */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  width: 100%; max-width: 1500px; margin: 0 auto;
  padding: 20px 18px 24px;
  align-items: stretch;
}
.stage-col { display: grid; gap: 12px; min-width: 0; align-content: start; }
.side {
  display: grid; gap: 16px; min-height: 0;
  grid-template-rows: auto minmax(220px, 1fr);
  position: sticky; top: calc(var(--topbar-h) + 20px);
}
/* Die Warteschlange fuellt den Rest der Spalte. */
.panel-grow { display: flex; flex-direction: column; min-height: 0; }
.panel-grow .queue { flex: 1; overflow-y: auto; }

/* Grosses Bild: die Spalte rechts raeumt das Feld und legt sich unter das
   Video. Zuschauer und Warteschlange stehen dort nebeneinander, damit die
   Seite nicht ins Endlose waechst. */
.app.is-wide .layout { grid-template-columns: minmax(0, 1fr); }
.app.is-wide .side {
  position: static;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  grid-template-rows: auto;
  align-items: start;
}
.app.is-wide .panel-grow .queue { max-height: 360px; }

/* ---------------------------------------------------------------- Buehne --- */

/* Buehne und Bedienleiste sind kein Text. Sonst zieht der Doppelklick, der
   auf Vollbild schaltet, jedes Mal eine blaue Markierung hinter sich her. */
.stage, .controls { user-select: none; -webkit-user-select: none; }

.stage {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--stage-bg);
  border: 1px solid var(--line);
  border-radius: var(--r-surface);
  overflow: hidden;
  box-shadow: var(--shadow-2);
}
.stage-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block; object-fit: contain; background: var(--stage-bg);
}
.stage-video[hidden] { display: none; }

.stage-tap { position: absolute; inset: 0; cursor: pointer; }
.stage-tap[hidden] { display: none; }

.stage-empty {
  position: absolute; inset: 0; z-index: 3;
  display: grid; place-content: center; justify-items: center; gap: 6px;
  padding: 24px; text-align: center; color: #d7d7dc;
  background: var(--stage-bg);
}
.stage-empty[hidden] { display: none; }
.empty-icon { display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: 8px;
  border-radius: var(--r-control); background: rgb(255 255 255 / .07); color: #fff; }
.empty-title { font-size: 16px; font-weight: 600; color: #fff; }
.empty-sub { font-size: 13.5px; color: #9a9aa4; max-width: 34ch; margin-bottom: 14px; }

/* Der Schleier bleibt durchlaessig: nur der Knopf selbst startet. Daneben
   zaehlt der Klick als Klick auf das Bild. */
.stage-start { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center;
  background: rgb(8 8 10 / .35); pointer-events: none; }
.stage-start[hidden] { display: none; }
.big-play {
  pointer-events: auto;
  width: 74px; height: 74px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center;
  background: rgb(255 255 255 / .94); color: #17171a;
  box-shadow: 0 12px 40px -8px rgb(0 0 0 / .5);
  transition: transform .18s var(--ease), background-color .18s var(--ease);
}
.big-play svg { width: 32px; height: 32px; margin-left: 4px; }
.big-play:hover { transform: scale(1.05); background: #fff; }
.big-play:active { transform: scale(.97); }

/* Bereit-Modus. Solange der Raum auf die Runde wartet, liegt ein Muster ueber
   dem Bild und in seiner Mitte der Knopf dafuer. Rot heisst: noch nicht
   bereit. Wie beim grossen Startknopf bleibt der Schleier durchlaessig -
   daneben zaehlt ein Klick als Klick auf das Bild. */
.stage-go {
  position: absolute; inset: 0; z-index: 4;
  display: grid; place-items: center;
  pointer-events: none;
  background:
    repeating-linear-gradient(-45deg,
      rgb(179 38 30 / .34) 0 10px, transparent 10px 20px),
    rgb(8 8 10 / .45);
}
.stage-go[hidden] { display: none; }
.stage-go.is-go {
  background:
    repeating-linear-gradient(-45deg,
      rgb(28 122 82 / .34) 0 10px, transparent 10px 20px),
    rgb(8 8 10 / .45);
}

.big-go {
  pointer-events: auto;
  display: inline-flex; align-items: center; gap: 10px;
  height: 54px; padding: 0 26px; border: 0; border-radius: var(--r-pill);
  cursor: pointer; white-space: nowrap;
  font-size: 16px; font-weight: 650; letter-spacing: -.015em;
  color: #fff; background: #b3261e;
  box-shadow: 0 12px 40px -8px rgb(0 0 0 / .5);
  transition: transform .18s var(--ease), background-color .18s var(--ease);
}
.big-go svg { width: 22px; height: 22px; }
.big-go:hover { transform: scale(1.04); }
.big-go:active { transform: scale(.97); }
.stage-go.is-go .big-go { background: #1c7a52; }

/* Solange das Zeichen fehlt, blinkt der Knopf und schiebt einen Ring vor sich
   her: er wartet ja auf einen Druck. Steht das Zeichen, wird er still. Wer
   mit dem Zeiger darauf steht, hat ihn ohnehin gefunden - dann hoert es auf. */
@media (prefers-reduced-motion: no-preference) {
  .stage-go:not(.is-go) .big-go { animation: go-blink 1.2s var(--ease) infinite; }
  .stage-go:not(.is-go) .big-go:hover { animation: none; }
}
@keyframes go-blink {
  50% {
    background: #e6493b;
    box-shadow: 0 12px 40px -8px rgb(0 0 0 / .5), 0 0 0 13px rgb(230 73 59 / 0);
  }
  0%, 100% {
    background: #b3261e;
    box-shadow: 0 12px 40px -8px rgb(0 0 0 / .5), 0 0 0 0 rgb(230 73 59 / .5);
  }
}

.stage.is-full .stage-go { transition: opacity .2s var(--ease); }
.stage.is-full.is-idle .stage-go { opacity: 0; }
.stage.is-full.is-idle .big-go { pointer-events: none; }

.stage-badge {
  position: absolute; top: 12px; left: 12px; z-index: 5;
  display: inline-flex; align-items: center; gap: 8px;
  height: 28px; padding: 0 12px; border-radius: var(--r-pill);
  background: rgb(12 12 14 / .72); color: #fff; font-size: 12.5px; font-weight: 550;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: badge-in .24s var(--ease) both;
}
.stage-badge[hidden] { display: none; }
/* Zweite Marke, wenn die Verbindung haengt. Steht neben der ersten. */
.stage-badge-warn { left: auto; right: 12px; }
.stage-badge-warn .pulse { background: var(--accent); }
/* Live-Marke: eigene Farbe, damit sie sich von Sync/Warten unterscheidet. */
.stage-badge-live .pulse { background: var(--bad); }
@keyframes badge-in { from { opacity: 0; transform: translateY(-6px) } }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-hi); flex: none; }
@media (prefers-reduced-motion: no-preference) {
  .pulse { animation: pulse 1.6s ease-in-out infinite; }
}
@keyframes pulse { 50% { opacity: .3; transform: scale(.7) } }

/* ------------------------------------------------------------- Steuerung --- */

.controls {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-surface); box-shadow: var(--shadow-1);
}
.controls[data-idle="1"] { opacity: .5; pointer-events: none; }

/* Gesperrt: nur der Taktgeber bedient das Video. Die Knoepfe bleiben stehen
   und blass - sie nehmen den Druck noch an, sagen dann aber nur, was fehlt. */
.is-locked { opacity: .38; }
.icon-btn.is-locked:hover { background: none; color: var(--text-2); }
.icon-btn.is-locked:active { transform: none; }
.scrub.is-locked { cursor: default; }
.scrub.is-locked:hover .scrub-knob { transform: none; }

/* Zehn Sekunden vor und zurueck. Etwas groesser gezeichnet, sonst
   verschwindet die Zahl im Ring. */
.ctl-skip svg { width: 22px; height: 22px; }

.time { font-size: 13px; color: var(--text-2); flex: none; }
.time-total { color: var(--text-3); }

.scrub { position: relative; flex: 1; min-width: 0; height: 34px; cursor: pointer;
  display: flex; align-items: center; touch-action: none; }
.scrub-track { position: relative; width: 100%; height: 5px; border-radius: var(--r-pill);
  background: var(--surface-3); border: 1px solid var(--line); }
.scrub-fill { position: absolute; inset: 0 auto 0 0; width: 0;
  background: var(--accent); border-radius: var(--r-pill); }
.scrub-knob {
  position: absolute; top: 50%; left: 0;
  width: 13px; height: 13px; margin: -6.5px 0 0 -6.5px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px var(--surface);
  transition: transform .16s var(--ease);
}
.scrub:hover .scrub-knob, .scrub:focus-visible .scrub-knob { transform: scale(1.25); }

/* Zeit unter dem Zeiger. Sitzt ueber der Leiste und ragt bewusst aus der
   Steuerung heraus, damit sie den Regler nicht verdeckt. */
.scrub-hint {
  position: absolute; left: 0; bottom: calc(100% - 3px);
  transform: translateX(-50%);
  padding: 3px 8px; border-radius: 7px;
  background: var(--text); color: var(--bg);
  font-size: 11.5px; line-height: 1.45; white-space: nowrap;
  pointer-events: none; opacity: 0;
  transition: opacity .14s var(--ease);
}
.scrub-hint.is-on { opacity: 1; }

.scrub-peers { position: absolute; inset: 0; pointer-events: none; }
.peer-tick {
  position: absolute; top: 50%; width: 2px; height: 13px; margin-top: -6.5px;
  border-radius: 1px; opacity: .8;
  transition: left .4s linear;
}

.vol { display: flex; align-items: center; gap: 4px; flex: none; }
.vol-range { width: 80px; accent-color: var(--accent); }

@media (max-width: 640px) {
  .vol-range { display: none; }
}

/* ------------------------------------------------------------- Vollbild ---- */
/* Im Vollbild ziehen Titelzeile und Steuerung auf die Buehne. Es sind
   dieselben Knoten wie darunter, nur anders gebettet: dunkler Verlauf statt
   Flaeche, und die Marken der Farben zeigen fuer diesen Grund nach hell.
   Nach fuenf Sekunden ohne Mausbewegung verschwindet alles samt Zeiger. */

.stage.is-full {
  aspect-ratio: auto; width: 100%; height: 100%;
  border: 0; border-radius: 0; box-shadow: none;
}

.stage.is-full .now,
.stage.is-full .controls {
  position: absolute; left: 0; right: 0; z-index: 6;
  border: 0; border-radius: 0; box-shadow: none;
  color: #fff;
  transition: opacity .2s var(--ease), transform .2s var(--ease);

  --bg:          #101013;
  --text:        #ffffff;
  --text-2:      #dcdce2;
  --text-3:      #adadb7;
  --surface-3:   rgb(255 255 255 / .16);
  --line:        rgb(255 255 255 / .22);
  --line-strong: rgb(255 255 255 / .32);
  /* Auf dem dunklen Verlauf braucht der Bereit-Knopf hellere Farben. */
  --ok:          #4cc38a;
  --ok-soft:     rgb(76 195 138 / .22);
  --bad:         #ff7a6b;
  --bad-soft:    rgb(255 122 107 / .22);
}

.stage.is-full .now {
  top: 0; align-items: flex-start;
  padding: 16px 22px 44px;
  background: linear-gradient(to bottom, rgb(6 6 8 / .82), transparent);
}
.stage.is-full .now-title { font-size: 18px; }

.stage.is-full .controls {
  bottom: 0;
  padding: 46px 22px 18px;
  background: linear-gradient(to top, rgb(6 6 8 / .9), rgb(6 6 8 / .5) 55%, transparent);
}
.stage.is-full .scrub-hint { background: #fff; color: #101013; }

.stage.is-full.is-idle,
.stage.is-full.is-idle .stage-tap { cursor: none; }
.stage.is-full.is-idle .now     { opacity: 0; transform: translateY(-10px); pointer-events: none; }
.stage.is-full.is-idle .controls { opacity: 0; transform: translateY(10px); pointer-events: none; }

/* Der grosse Knopf gehoert dazu. Bliebe er allein stehen, schwebte er ohne
   alles mitten im Bild. */
.stage.is-full .stage-start { transition: opacity .2s var(--ease); }
.stage.is-full.is-idle .stage-start { opacity: 0; }
.stage.is-full.is-idle .big-play { pointer-events: none; }

/* --------------------------------------------------------------- Laeuft ---- */

.now { display: flex; align-items: center; gap: 14px; padding: 2px 4px; min-height: 40px; }
.now-main { min-width: 0; }
.now-title { font-size: 16.5px; font-weight: 600; letter-spacing: -.018em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now-by { font-size: 13px; color: var(--text-3); }
.now-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; }
.now-actions .btn { flex: none; }
.now .btn[hidden] { display: none; }

/* Der Knopf fuer das eigene Zeichen. Er traegt seinen Zustand als Farbe:
   rot heisst nicht bereit, gruen heisst bereit. */
.btn-go { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn-go:hover { background: var(--bad-soft); }
.btn-go.is-go { border-color: var(--ok); color: var(--ok); }
.btn-go.is-go:hover { background: var(--ok-soft); }

/* --------------------------------------------------------------- Panels ---- */

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-surface); box-shadow: var(--shadow-1);
  overflow: hidden;
}
.panel-head { display: flex; align-items: center; gap: 9px; padding: 13px 14px;
  border-bottom: 1px solid var(--line); }
.panel-ico { width: 17px; height: 17px; color: var(--text-3); }
.panel-title { font-size: 14px; font-weight: 600; letter-spacing: -.012em; }
.count {
  margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px;
  display: inline-grid; place-items: center; border-radius: var(--r-pill);
  background: var(--surface-3); color: var(--text-2);
  font-family: var(--mono); font-size: 12px;
}

/* Zuschauer-Tabelle */
.table-wrap { max-height: 260px; overflow-y: auto; }
.viewers { width: 100%; border-collapse: collapse; }
.viewers th {
  position: sticky; top: 0; z-index: 1;
  padding: 8px 14px; text-align: left; font-size: 11.5px; font-weight: 550;
  color: var(--text-3); background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.viewers th.ta-r { text-align: right; }
.viewers td { padding: 9px 14px; font-size: 13.5px; vertical-align: middle; }
.viewers tbody tr { transition: background-color .2s var(--ease); }
.viewers tbody tr + tr td { border-top: 1px solid var(--line); }

.v-who { display: flex; align-items: center; gap: 9px; min-width: 0; }
.v-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.v-you { font-size: 11.5px; color: var(--text-3); flex: none; }
.v-pos { font-family: var(--mono); font-size: 13px; color: var(--text-2); text-align: right; white-space: nowrap; }

/* Waehrend eines Livestreams steht hier statt der Position ein Punkt: gruen
   heisst verbunden, rot heisst nicht (mehr). */
.v-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.v-dot-on  { background: var(--ok); }
.v-dot-off { background: var(--bad); }

.viewers tr.is-master { background: var(--accent-soft); }
.viewers tr.is-master .v-name { color: var(--accent); font-weight: 600; }
.viewers tr.is-master .v-crown { display: grid; }
.v-crown { display: none; place-items: center; width: 17px; height: 17px; color: var(--accent); flex: none; }
.v-crown svg { width: 15px; height: 15px; }

.viewers tr.is-drifting .v-pos { color: var(--warn); }

/* Bereit-Modus: gruen heisst bereit, rot heisst, der Raum wartet beim
   naechsten Wechsel auf ihn. Steht hier unten, damit es die Marke des
   Taktgebers ueberdeckt - die bleibt an Krone und Namen zu erkennen. */
.viewers tr.is-go   { background: var(--ok-soft); }
.viewers tr.is-nogo { background: var(--bad-soft); }

/* Protokoll. Dieselbe Tabelle wie bei den Zuschauern, drei Spalten, und so
   breit wie das Video darueber. */
/* Eigene Hoehe, nicht die der Zuschauer: das Protokoll bleibt auch auf
   schmalen Geraeten ein Fenster und waechst nicht ins Endlose. */
.log-wrap { max-height: 236px; overflow-y: auto; }
/* Feste Spalten, sonst zieht ein langer Titel die Zeile auseinander, statt
   sich abschneiden zu lassen. */
.log { table-layout: fixed; }
.log-col-at  { width: 96px; }
.log-col-who { width: 30%; }
.log-at { color: var(--text-2); font-size: 13px; white-space: nowrap; }
.log-what { color: var(--text); overflow: hidden; }

/* Der Titel steht farbig im Satz und weicht als Einziger zurueck, wenn der
   Platz nicht reicht. Der Satz drumherum bleibt immer ganz zu lesen. */
.log-line { display: flex; align-items: baseline; min-width: 0; white-space: pre; }
.log-line > span { flex: none; }
.log-line > .log-title {
  flex: 0 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis;
  color: var(--accent); font-weight: 550;
}
.log-nobody { color: var(--text-3); }
.log-none td { padding: 24px 14px; text-align: center; color: var(--text-3); }

@media (max-width: 720px) {
  .log-col-at { width: 74px; }
  .log .log-at { font-size: 12px; }
  .log td { padding: 9px 10px; }
}

/* Warteschlange */
.q-item {
  display: grid; grid-template-columns: 92px minmax(0, 1fr) auto;
  gap: 11px; align-items: center;
  padding: 10px 12px 10px 10px;
  transition: background-color .2s var(--ease);
}
.q-item + .q-item { border-top: 1px solid var(--line); }
.q-item:hover { background: var(--surface-2); }
.q-item.is-current { background: var(--accent-soft); }

.q-thumb {
  display: block;
  position: relative; width: 92px; aspect-ratio: 16 / 9;
  border-radius: 8px; overflow: hidden; background: var(--surface-3);
  border: 1px solid var(--line);
}
.q-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.q-dur {
  position: absolute; right: 4px; bottom: 4px;
  padding: 1px 5px; border-radius: 5px;
  background: rgb(10 10 12 / .78); color: #fff;
  font-family: var(--mono); font-size: 10.5px; line-height: 1.45;
}
.q-body { display: block; min-width: 0; }
.q-title { display: block; font-size: 13.5px; font-weight: 550; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-by { display: block; font-size: 12px; color: var(--text-3); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-item.is-current .q-title { color: var(--accent); }
.q-now { font-size: 11.5px; font-weight: 600; color: var(--accent); }
.q-del { opacity: 0; transition: opacity .18s var(--ease); }
.q-item:hover .q-del, .q-del:focus-visible { opacity: 1; }
@media (hover: none) { .q-del { opacity: 1; } }

/* Eintrag, der gerade hochgeladen wird */
.q-item.is-coming { cursor: default; }
.q-item.is-coming .q-title { color: var(--text-2); }
.q-coming { color: var(--accent); font-weight: 600; }
.q-bar {
  display: block; height: 3px; margin-top: 6px; border-radius: var(--r-pill);
  background: var(--surface-3); border: 1px solid var(--line); overflow: hidden;
}
.q-bar i { display: block; height: 100%; width: 0;
  background: var(--accent); transition: width .3s linear; }
.q-pct { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.q-item.is-coming .q-thumb::before {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(-45deg,
    transparent 0 6px, rgb(128 128 140 / .12) 6px 12px);
}

.panel-grow .queue:empty { flex: 0 0 auto; }
.queue-empty { margin: auto 0; padding: 26px 18px 24px; text-align: center;
  color: var(--text-3); font-size: 13.5px; }
.queue-empty[hidden] { display: none; }
.queue-empty .btn { margin-top: 12px; }

/* Skelett waehrend das Vorschaubild entsteht */
.q-thumb.is-loading::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / .35), transparent);
  transform: translateX(-100%);
}
@media (prefers-reduced-motion: no-preference) {
  .q-thumb.is-loading::after { animation: shimmer 1.3s var(--ease) infinite; }
}
@keyframes shimmer { to { transform: translateX(100%) } }

/* ---------------------------------------------------------------- Upload --- */

.drop {
  display: grid; place-items: center; gap: 4px;
  padding: 40px 20px; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--line-strong); border-radius: var(--r-control);
  background: var(--surface-2); color: var(--text-2);
  transition: border-color .18s var(--ease), background-color .18s var(--ease);
}
.drop:hover, .drop.is-over { border-color: var(--accent); background: var(--accent-soft); }
.drop-icon { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 8px;
  border-radius: var(--r-control); background: var(--surface-3); color: var(--text-2); }
.drop.is-over .drop-icon { background: var(--surface); color: var(--accent); }
.drop-title { font-size: 15px; font-weight: 600; color: var(--text); }
.drop-sub { font-size: 13px; color: var(--text-3); }

/* Liste der Dateien im Upload-Fenster */
.up-list {
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line);
  display: grid; gap: 13px; max-height: 230px; overflow-y: auto;
}
.up-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto 26px;
  align-items: center; gap: 4px 9px;
}
.up-row-name { font-size: 13.5px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-row-size { font-size: 12px; color: var(--text-3); }
.up-row-state { font-size: 12px; color: var(--text-2); min-width: 42px; text-align: right; }
.up-row-state.is-done { color: var(--ok); }
.up-row-state.is-converting { color: var(--accent); }
.up-row-state svg { width: 15px; height: 15px; vertical-align: -3px; }
.up-row-gap { width: 26px; }
.up-row-bar {
  grid-column: 1 / -1; height: 4px; border-radius: var(--r-pill);
  background: var(--surface-3); border: 1px solid var(--line); overflow: hidden;
}
.up-row-bar i { display: block; height: 100%; width: 0;
  background: var(--accent); transition: width .25s linear; }

.bar { height: 8px; border-radius: var(--r-pill); background: var(--surface-3);
  border: 1px solid var(--line); overflow: hidden; }
.bar-thin { height: 5px; }
.bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: var(--r-pill);
  transition: width .3s linear; }

.up-meta { display: flex; gap: 14px; margin-top: 9px; font-size: 12.5px; color: var(--text-2); }
.up-meta span:last-child { margin-left: auto; }

.done { display: flex; align-items: center; gap: 12px; padding: 8px 0 2px; }
.done-icon { display: grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.done-text { font-size: 14.5px; }

/* Mini-Fortschritt */
.mini {
  position: fixed; right: 18px; bottom: 18px; z-index: 60;
  width: 250px; padding: 11px 13px 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-control); box-shadow: var(--shadow-2);
  animation: mini-in .28s var(--ease) both;
}
.mini[hidden] { display: none; }
.mini.is-leaving { animation: mini-out .3s var(--ease) both; }
@keyframes mini-in  { from { opacity: 0; transform: translateY(14px) scale(.96) } }
@keyframes mini-out { to   { opacity: 0; transform: translateY(14px) scale(.96) } }
.mini-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.mini-name { font-size: 13px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-top .icon-btn { margin-left: auto; }
.mini-meta { display: flex; justify-content: space-between; margin-top: 7px;
  font-size: 11.5px; color: var(--text-3); }

/* ---------------------------------------------------------------- Toasts --- */

.toasts { position: fixed; left: 50%; top: calc(var(--topbar-h) + 14px); z-index: 70;
  transform: translateX(-50%); display: grid; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 15px; border-radius: 18px;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-2); font-size: 13.5px;
  max-width: min(420px, calc(100vw - 32px));
  animation: toast-in .26s var(--ease) both;
}
.toast.is-leaving { animation: toast-out .26s var(--ease) both; }
.toast svg { width: 16px; height: 16px; color: var(--accent); flex: none; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(-10px) } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(-10px) } }

/* ---------------------------------------------------------------- Mobil ---- */

@media (max-width: 1080px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 16px; align-content: start; }
  .side { position: static; grid-template-rows: auto auto; }
  .table-wrap { max-height: none; }
  .panel-grow .queue { overflow-y: visible; }
  .app.is-wide .panel-grow .queue { max-height: none; }
  /* Hier steht ohnehin schon alles untereinander. */
  #btnWide { display: none; }
}

@media (max-width: 720px) {
  body { font-size: 14.5px; }
  .layout { padding: 14px 12px 20px; }
  .topbar { padding: 0 12px; gap: 10px; }
  .brand-name { display: none; }
  .btn-accent#btnAdd span, .btn-soft#btnLive span { display: none; }
  .btn-accent#btnAdd, .btn-soft#btnLive { width: 34px; padding: 0; }
  .me-name { display: none; }
  .me-chip { padding: 0 4px; }
  .stage { border-radius: var(--r-control); }
  .controls { gap: 8px; padding: 6px 8px; }
  .sheet { padding: 22px; }
}

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