* { box-sizing: border-box; }
:root {
  color-scheme: dark;
  --bg:#0b1220; --glow:#243a63; --panel:#131e30; --panel-a:#131e30dd; --panel-solid:#0f1a2c;
  --line:#26364d; --hair:#ffffff12; --muted:#9aabc2; --text:#f3f6fb; --text-2:#dce5f4; --btn-text:#eaf0fb; --status:#b8c8e2;
  --surface:#1a2940; --surface-hover:#263a59; --surface-line:#344761;
  --input-bg:#0b1423; --input-line:#34465f; --inset:#0b142366;
  --blue:#6c8cff; --accent-hover:#829aff; --accent-text:#91a7ff; --on-accent:#fff;
  --talk:#3659d9; --talk-line:#6d89ff; --talk-hover:#2442b4; --talk-text:#fff;
  --err:#ff9c9c; --warn:#ffcf8a; --danger:#ffb1b1; --shadow:#0008;
}
:root[data-theme="hell"] {
  color-scheme: light;
  --bg:#eef2f9; --glow:#c9d8f5; --panel:#ffffff; --panel-a:#ffffffee; --panel-solid:#ffffff;
  --line:#ccd5e6; --hair:#00000018; --muted:#5b6b86; --text:#0f1a2e; --text-2:#22314d; --btn-text:#16253f; --status:#3a4d6e;
  --surface:#ffffff; --surface-hover:#e6edfb; --surface-line:#c2cce0;
  --input-bg:#ffffff; --input-line:#b6c2d8; --inset:#eef2f9aa;
  --blue:#3b5bdb; --accent-hover:#2f4ac0; --accent-text:#3b5bdb; --on-accent:#fff;
  --talk:#3b5bdb; --talk-line:#5c7cfa; --talk-hover:#2f4ac0; --talk-text:#fff;
  --err:#c92a2a; --warn:#b45309; --danger:#c92a2a; --shadow:#1b2a4a33;
}
:root[data-theme="graphit"] {
  --bg:#111214; --glow:#2b2e35; --panel:#1b1d21; --panel-a:#1b1d21dd; --panel-solid:#191b1f;
  --line:#34373e; --hair:#ffffff14; --muted:#a0a5b1; --text:#f2f3f5; --text-2:#dcdee3; --btn-text:#eceef2; --status:#bfc3cc;
  --surface:#25272c; --surface-hover:#34373e; --surface-line:#42454d;
  --input-bg:#0c0d0f; --input-line:#42454d; --inset:#0c0d0f66;
  --blue:#8fb0ff; --accent-hover:#a8c1ff; --accent-text:#a8c1ff; --on-accent:#0b1020;
  --talk:#3d57c4; --talk-line:#8fb0ff; --talk-hover:#2f45a0; --talk-text:#fff; --shadow:#0009;
}
:root[data-theme="wald"] {
  --bg:#0a1511; --glow:#1d4a3a; --panel:#112019; --panel-a:#112019dd; --panel-solid:#0f1c16;
  --line:#24433a; --hair:#ffffff12; --muted:#98b3a8; --text:#eefaf4; --text-2:#d4eadf; --btn-text:#e6f6ee; --status:#b5cfc3;
  --surface:#163026; --surface-hover:#1f4234; --surface-line:#2c5646;
  --input-bg:#08110d; --input-line:#2c5646; --inset:#08110d66;
  --blue:#3ecf8e; --accent-hover:#5ddba3; --accent-text:#6ee7b0; --on-accent:#04140d;
  --talk:#1f9d68; --talk-line:#3ecf8e; --talk-hover:#167a50; --talk-text:#fff;
}
:root[data-theme="sonne"] {
  --bg:#160d14; --glow:#5a2540; --panel:#231420; --panel-a:#231420dd; --panel-solid:#1f1119;
  --line:#4a2a3c; --hair:#ffffff12; --muted:#bfa3b3; --text:#fff3ee; --text-2:#f2d9d2; --btn-text:#ffeae2; --status:#dcbfc5;
  --surface:#321b2b; --surface-hover:#452638; --surface-line:#5c3548;
  --input-bg:#120a10; --input-line:#5c3548; --inset:#120a1066;
  --blue:#ff7a59; --accent-hover:#ff927a; --accent-text:#ff9a7c; --on-accent:#1a0b08;
  --talk:#d9482b; --talk-line:#ff7a59; --talk-hover:#b53a22; --talk-text:#fff;
}
:root[data-theme="kontrast"] {
  --bg:#000; --glow:#000; --panel:#000; --panel-a:#000; --panel-solid:#000;
  --line:#fff; --hair:#ffffff55; --muted:#e0e0e0; --text:#fff; --text-2:#fff; --btn-text:#fff; --status:#fff;
  --surface:#000; --surface-hover:#2a2a2a; --surface-line:#fff;
  --input-bg:#000; --input-line:#fff; --inset:#000;
  --blue:#ffd400; --accent-hover:#ffe34d; --accent-text:#ffd400; --on-accent:#000;
  --talk:#ffd400; --talk-line:#fff; --talk-hover:#ffe34d; --talk-text:#000;
  --err:#ff8a8a; --warn:#ffd400; --danger:#ff8a8a; --shadow:#000;
}
:root[data-theme="kontrast"] .video-card { border-width:2px; }
:root[data-theme="kontrast"] :focus-visible { outline:3px solid #ffd400; outline-offset:2px; }
body { margin:0; min-height:100vh; min-height:100dvh; -webkit-text-size-adjust:100%; padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); background:radial-gradient(ellipse at 50% -20%,var(--glow) 0%,transparent 55%),var(--bg); color:var(--text); font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; }
.shell { width:min(1080px,calc(100% - 36px)); margin:0 auto; }
.topbar { height:76px; display:flex; align-items:center; justify-content:space-between; border-bottom:1px solid var(--hair); }
.brand { display:flex; gap:10px; align-items:center; font-weight:750; letter-spacing:.2px; font-size:19px; }
.brand-icon { display:grid; place-items:center; width:34px;height:34px;border-radius:11px;background:var(--blue);color:var(--on-accent);font-size:23px; }
.secure-note,.hint,footer,.talk-help { color:var(--muted); font-size:12px; }
.intro { text-align:center; padding:48px 0 28px; }
.eyebrow { color:#9db2ff; font-size:11px; letter-spacing:2px; font-weight:750; }
h1 { font-size:clamp(38px,6vw,62px); line-height:1.02; letter-spacing:-2px; margin:14px 0; }
h1 span { color:var(--accent-text); }
.sub { color:var(--muted); max-width:510px; margin:0 auto; line-height:1.6; }
.join-panel { max-width:650px; margin:0 auto 28px; padding:20px; background:var(--panel-a); border:1px solid var(--line); border-radius:18px; box-shadow:0 18px 55px #0003; }
label { display:block; font-size:12px; font-weight:700; margin-bottom:9px; color:var(--text-2); }
.join-row { display:flex; gap:10px; }
input { min-width:0; flex:1; background:var(--input-bg); border:1px solid var(--input-line); border-radius:10px; color:var(--text); padding:13px 14px; font:inherit; outline:none; }
input:focus { border-color:var(--blue); }
button { border:0; border-radius:10px; cursor:pointer; font:inherit; font-weight:700; transition:transform .15s,background .15s,opacity .15s; }
button:active:not(:disabled) { transform:scale(.97); }
button:disabled { opacity:.38; cursor:not-allowed; }
.primary { padding:0 20px; background:var(--blue); color:var(--on-accent); }
.primary:hover { background:var(--accent-hover); }
.hint { margin-top:9px; }
.invite-row { display:flex; gap:10px; margin-top:14px; }
.ghost { flex:1; padding:12px 14px; background:var(--surface); border:1px solid var(--surface-line); color:var(--btn-text); }
.ghost:hover { background:var(--surface-hover); }
.invite-panel { margin-top:14px; padding:14px; border:1px dashed var(--input-line); border-radius:12px; background:var(--inset); }
.invite-panel[hidden] { display:none; }
.invite-id { font-size:13px; color:var(--text-2); margin-bottom:10px; }
.invite-id strong { color:var(--accent-text); letter-spacing:.5px; }
.invite-panel input { width:100%; font-size:13px; margin-bottom:12px; }
.share-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; }
.share { padding:11px 6px; background:var(--surface); border:1px solid var(--surface-line); color:var(--btn-text); font-size:13px; }
.share:hover { background:var(--surface-hover); }
.share.wa { background:#128c4a; border-color:#25d366; }
.share.ig { background:linear-gradient(45deg,#f09433,#dc2743,#bc1888); border-color:#dc2743; }
.share.fb { background:#1877f2; border-color:#4a95ff; }
.share.xx { background:#000; border-color:#555; }
@media(max-width:620px){ .share-grid { grid-template-columns:repeat(2,1fr); } }
.status { margin-top:13px; font-size:12px; color:var(--status); min-height:16px; }
.status.error { color:var(--err); }
.videos { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.video-card { height:clamp(210px,32vw,340px); position:relative; overflow:hidden; background:#050a12; border:1px solid var(--line); border-radius:18px; }
video { width:100%; height:100%; display:block; object-fit:cover; }
#localVideo { transform:scaleX(-1); }
.video-label { position:absolute; z-index:2; top:13px; left:14px; display:flex; gap:8px; align-items:center; padding:7px 10px; border-radius:8px; background:#07101dcc; font-size:10px; letter-spacing:1px; font-weight:800; }
.live-dot { width:7px;height:7px;border-radius:50%;background:#54df9a; }
.video-placeholder { position:absolute; inset:0; display:grid; place-items:center; color:#71839d; font-size:13px; pointer-events:none; }
.controls { display:flex; justify-content:center; flex-wrap:wrap; gap:10px; margin:22px 0 10px; }
.control,.talk { display:flex; align-items:center; justify-content:center; gap:9px; min-width:145px; padding:13px 17px; background:var(--surface); border:1px solid var(--surface-line); color:var(--btn-text); }
.control:hover { background:var(--surface-hover); }
.control-icon { font-size:18px; }
.talk { background:var(--talk); border:1px solid var(--talk-line); color:var(--talk-text); min-width:190px; user-select:none; -webkit-user-select:none; -webkit-touch-callout:none; -webkit-tap-highlight-color:transparent; touch-action:none; }
.talk:hover,.talk.active { background:var(--talk-hover); box-shadow:0 0 0 4px #6c8cff25; }
.danger { color:var(--danger); }
.talk-help { text-align:center; margin:0 0 40px; }
footer { display:flex; justify-content:space-between; gap:12px; padding:18px 0 25px; border-top:1px solid var(--hair); }
@media(max-width:620px) {
 .shell { width:min(100% - 22px,540px); }
 .topbar { height:62px; }
 .intro { padding:35px 0 23px; }
 .join-panel { padding:15px; }
 .join-row { flex-direction:column; }
 .primary { min-height:46px; }
 .videos { gap:9px; }
 .video-card { height:210px; border-radius:13px; }
 .video-label { top:8px;left:8px;font-size:8px;padding:6px 7px; }
 .controls { gap:8px; }
 .control,.talk { flex:1 1 calc(50% - 8px); min-width:0; padding:12px 8px; font-size:12px; }
 footer { flex-direction:column; }
}

.peer-info { position:absolute; z-index:1; inset:44px 8px 8px; overflow:auto; padding:10px 12px; border-radius:12px; background:#07101de6; border:1px solid #26364d; font-size:11px; line-height:1.45; color:#cfe0ff; -webkit-overflow-scrolling:touch; }
.peer-info[hidden] { display:none; }
.peer-title { font-weight:800; font-size:12px; color:#fff; margin-bottom:4px; }
.peer-sec { margin-top:9px; font-size:10px; letter-spacing:1px; text-transform:uppercase; color:#91a7ff; font-weight:800; }
.peer-info dl { display:grid; grid-template-columns:minmax(80px,38%) 1fr; gap:1px 10px; margin:3px 0 0; }
.peer-info dt { color:#8a9db8; }
.peer-info dd { margin:0; word-break:break-all; color:#eaf0fb; }
.privacy-note { color:var(--muted); font-size:11px; text-align:center; margin:0 0 22px; }

/* Gruppengespräch: dynamisches Raster */
.videos[data-count="3"] .video-card, .videos[data-count="4"] .video-card { height:clamp(170px,24vw,270px); }
.videos[data-count="5"], .videos[data-count="6"] { grid-template-columns:repeat(3,1fr); }
.videos[data-count="5"] .video-card, .videos[data-count="6"] .video-card { height:clamp(140px,19vw,220px); }
@media(max-width:620px) {
  .videos[data-count="5"], .videos[data-count="6"] { grid-template-columns:1fr 1fr; }
  .videos[data-count="3"] .video-card, .videos[data-count="4"] .video-card,
  .videos[data-count="5"] .video-card, .videos[data-count="6"] .video-card { height:170px; }
}

/* Klickbarer Name oben links + Infofenster */
.video-label.clickable { cursor:pointer; z-index:3; -webkit-tap-highlight-color:transparent; user-select:none; -webkit-user-select:none; }
.video-label.clickable:hover { background:#142544; }
.peer-info { background:#07101d; z-index:2; }
.peer-title { display:flex; justify-content:space-between; align-items:center; }
.peer-close { background:#1a2940; border:1px solid #344761; color:#fff; border-radius:6px; padding:0 9px; font-size:15px; line-height:20px; min-height:22px; }

/* Kompakter Kopfbereich: Überschrift und Raum-Code in einer Zeile */
.sr-only { position:absolute; width:1px; height:1px; margin:-1px; padding:0; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0; }
.topbar { height:44px; }
.brand { font-size:16px; gap:8px; }
.brand-icon { width:26px; height:26px; border-radius:8px; font-size:17px; }
.hero { display:flex; align-items:center; gap:18px; margin:10px 0 12px; }
.hero h1 { flex:0 0 auto; margin:0; font-size:22px; line-height:1.1; letter-spacing:-.5px; white-space:nowrap; }
.join-panel { position:relative; flex:1; min-width:0; max-width:none; margin:0; padding:8px 10px; border-radius:12px; box-shadow:none; }
.join-row { display:flex; flex-direction:row; flex-wrap:wrap; gap:8px; align-items:stretch; }
.join-row input { flex:1 1 150px; padding:8px 12px; border-radius:9px; font-size:16px; }
.join-row .primary { flex:0 0 auto; padding:0 16px; min-height:38px; }
.join-row .ghost { flex:0 0 auto; padding:0 13px; min-height:38px; white-space:nowrap; font-size:13px; }
.status { margin-top:5px; min-height:0; font-size:11.5px; line-height:1.3; }
.invite-panel { position:absolute; top:calc(100% + 6px); right:0; margin:0; width:min(440px,100%); z-index:30; background:var(--panel-solid); box-shadow:0 14px 40px var(--shadow); }
@media(max-width:620px) {
  .hero { flex-direction:column; align-items:stretch; gap:6px; margin:6px 0 10px; }
  .hero h1 { font-size:19px; }
  .join-panel { padding:8px; }
  .join-row input { flex:1 1 100%; }
  .join-row .primary { flex:1 1 40%; min-height:40px; padding:0 8px; white-space:nowrap; font-size:15px; }
  .join-row .ghost { flex:1 1 25%; min-height:40px; padding:0 8px; }
  .topbar { height:38px; }
  .secure-note { display:none; }
}

/* Push-Benachrichtigungen */
.push-row { display:grid; grid-template-columns:1fr auto; gap:8px; margin-top:10px; }
.push-row .share { font-size:12.5px; }
.push-row .share.on { background:#128c4a; border-color:#25d366; }
.push-row .share:disabled { opacity:.45; cursor:not-allowed; }
.push-note { margin-top:8px; font-size:11.5px; line-height:1.4; color:var(--muted); min-height:0; }
.push-note:empty { display:none; }
.push-note.warn { color:var(--warn); }

.share.wa, .share.ig, .share.fb, .share.xx, .push-row .share.on { color:#fff; }

/* ---------- Bühne: Anordnungen der Videofenster ---------- */
.stage { position:relative; --self-w:112px; }
.stage[data-selfsize="s"] { --self-w:112px; }
.stage[data-selfsize="m"] { --self-w:176px; }
.stage[data-selfsize="l"] { --self-w:260px; }
.video-card[hidden] { display:none !important; }
.videos[data-count="1"] { grid-template-columns:1fr; }
.videos[data-count="1"] .video-card { height:clamp(260px,calc(100dvh - 300px),620px); }

/* Sprecher: ein großes Bild, die anderen darunter */
.stage[data-layout="speaker"] .videos { grid-template-columns:repeat(var(--thumbs,1),minmax(0,1fr)); }
.stage[data-layout="speaker"] .videos > .video-card.is-main { grid-column:1 / -1; order:-1; height:clamp(260px,calc(100dvh - 390px),580px); }
.stage[data-layout="speaker"] .videos > .video-card:not(.is-main) { height:clamp(100px,14vw,150px); }

/* Seitenleiste: großes Bild links, die anderen rechts untereinander */
.stage[data-layout="side"] .videos { grid-template-columns:minmax(0,1fr) clamp(150px,22vw,230px); align-items:start; }
.stage[data-layout="side"] .videos > .video-card.is-main { grid-column:1; grid-row:1 / span var(--thumbs,1); order:-1; height:clamp(280px,calc(100dvh - 330px),620px); }
.stage[data-layout="side"] .videos > .video-card:not(.is-main) { grid-column:2; height:clamp(96px,13vw,140px); }

/* Vollbild: Hauptbild füllt die Fläche, die anderen schweben unten rechts */
.stage[data-layout="full"] .videos { display:flex; flex-direction:row; flex-wrap:wrap; align-items:flex-end; justify-content:flex-end; align-content:flex-end; gap:8px; padding:10px; position:relative; height:clamp(320px,calc(100dvh - 210px),760px); }
.stage[data-layout="full"] .videos > .video-card.is-main { position:absolute; inset:0; width:auto; height:auto; z-index:0; }
.stage[data-layout="full"] .videos > .video-card:not(.is-main) { position:relative; z-index:5; width:clamp(110px,16vw,170px); height:clamp(80px,12vw,125px); border-width:2px; box-shadow:0 8px 24px #000a; }

@media(max-width:620px) {
  .videos[data-count="1"] .video-card { height:clamp(240px,calc(100dvh - 330px),520px); }
  .stage[data-layout="speaker"] .videos > .video-card.is-main,
  .stage[data-layout="side"] .videos > .video-card.is-main { height:clamp(240px,calc(100dvh - 420px),460px); }
  .stage[data-layout="speaker"] .videos > .video-card:not(.is-main),
  .stage[data-layout="side"] .videos > .video-card:not(.is-main) { height:96px; }
  .stage[data-layout="side"] .videos { grid-template-columns:repeat(var(--thumbs,1),minmax(0,1fr)); }
  .stage[data-layout="side"] .videos > .video-card.is-main { grid-column:1 / -1; grid-row:auto; }
  .stage[data-layout="side"] .videos > .video-card:not(.is-main) { grid-column:auto; }
  .stage[data-layout="full"] .videos { height:clamp(300px,calc(100dvh - 250px),640px); }
  .stage[data-layout="full"] .videos > .video-card:not(.is-main) { width:92px; height:68px; }
  .stage[data-selfsize="s"] { --self-w:84px; }
  .stage[data-selfsize="m"] { --self-w:120px; }
  .stage[data-selfsize="l"] { --self-w:170px; }
}

/* Kachel-Knöpfe (Vergrößern / Größe ändern) */
.tile-btn { position:absolute; z-index:4; top:9px; right:10px; width:28px; height:28px; padding:0; border-radius:8px; background:#07101dcc; color:#fff; font-size:14px; line-height:1; opacity:0; transition:opacity .15s; }
.video-card:hover .tile-btn, .tile-btn:focus-visible, .video-card.pinned .tile-btn { opacity:1; }
@media(hover:none) { .tile-btn { opacity:.85; } }
.video-card.pinned .tile-btn.tile-pin { background:var(--blue); color:var(--on-accent); }
.self-size { display:none; }

/* Eigenes Fenster */
.stage[data-self="float"] > .self-card { position:fixed; right:12px; bottom:12px; z-index:40; width:var(--self-w); height:auto; aspect-ratio:4/3; min-height:0; border-radius:12px; border:2px solid #ffffff40; box-shadow:0 10px 30px #000a; cursor:grab; touch-action:none; }
.stage[data-self="float"] > .self-card:active { cursor:grabbing; }
.stage[data-self="float"] > .self-card video { position:absolute; inset:0; }
.stage[data-self="float"] > .self-card .video-label { top:5px; left:5px; padding:4px 6px; font-size:8px; }
.stage[data-self="float"] > .self-card .video-placeholder { font-size:10px; padding:6px; text-align:center; }
.stage[data-self="float"] > .self-card .tile-pin { display:none; }
.stage[data-self="float"] > .self-card .self-size { display:block; top:4px; right:4px; width:22px; height:22px; font-size:11px; opacity:.85; }
.stage[data-self="float"] > .self-card.info-open { width:min(340px,calc(100vw - 24px)); height:300px; aspect-ratio:auto; cursor:default; }
.stage[data-self="float"] > .self-card .peer-info { inset:32px 6px 6px; }
.self-restore { position:fixed; right:12px; bottom:12px; z-index:15; padding:8px 12px; font-size:12px; background:var(--surface); border:1px solid var(--surface-line); color:var(--btn-text); box-shadow:0 8px 24px #0007; }
.self-restore[hidden] { display:none; }

/* Ansicht-Menü */
.topbar { position:relative; }
.top-actions { display:flex; align-items:center; gap:12px; }
.view-btn { padding:0 11px; min-height:28px; font-size:12px; background:var(--surface); border:1px solid var(--surface-line); color:var(--btn-text); }
.view-btn:hover, .view-btn[aria-expanded="true"] { background:var(--surface-hover); }
.view-panel { position:absolute; top:calc(100% + 6px); right:0; z-index:50; width:min(360px,calc(100vw - 22px)); padding:12px 14px 14px; border-radius:14px; background:var(--panel-solid); border:1px solid var(--line); box-shadow:0 16px 44px var(--shadow); color:var(--text); }
.view-panel[hidden] { display:none; }
.vp-title { margin:10px 0 6px; font-size:10px; letter-spacing:1.2px; text-transform:uppercase; font-weight:800; color:var(--muted); }
.vp-title:first-child { margin-top:0; }
.seg { display:grid; grid-auto-flow:column; grid-auto-columns:1fr; gap:6px; }
.seg button { padding:8px 4px; font-size:11.5px; display:flex; flex-direction:column; align-items:center; gap:4px; background:var(--surface); border:1px solid var(--surface-line); color:var(--btn-text); }
.seg button:hover:not(:disabled) { background:var(--surface-hover); }
.seg button.active { background:var(--blue); border-color:var(--blue); color:var(--on-accent); }
.seg svg { width:30px; height:20px; fill:currentColor; }
.swatches { display:grid; grid-template-columns:repeat(2,1fr); gap:6px; }
.swatch { display:flex; align-items:center; gap:7px; padding:6px 8px; font-size:12px; background:var(--surface); border:1px solid var(--surface-line); color:var(--btn-text); }
.swatch:hover { background:var(--surface-hover); }
.swatch.active { outline:2px solid var(--blue); outline-offset:1px; }
.swatch i { flex:0 0 auto; width:18px; height:18px; border-radius:50%; border:1px solid #8884; background:linear-gradient(135deg,var(--sw-bg) 50%,var(--sw-ac) 50%); }
.vp-reset { margin-top:12px; width:100%; padding:8px; font-size:12px; background:transparent; border:1px solid var(--surface-line); color:var(--muted); }
.vp-reset:hover { color:var(--text); border-color:var(--muted); }
@media(max-width:620px) { .view-btn { min-height:24px; font-size:11px; } .top-actions .secure-note { display:none; } }
