/* Videocall — dunkles, cleanes Design nach Joran-Vorlage */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0e1015;
  --bar: #12141a;
  --tile: #14161d;
  --tile-border: #262a33;
  --accent: #4c7dff;
  --text: #e8eaf0;
  --text-dim: #9aa0ab;
  --chip: rgba(10, 11, 15, 0.72);
  --red: #e5484d;
  --ctrl: #232733;
}

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  overflow: hidden;
}
.hidden { display: none !important; }
svg { width: 26px; height: 26px; fill: currentColor; stroke: currentColor; }
svg [fill="none"] { fill: none; }

/* ---------- Pre-Join ---------- */
.prejoin {
  height: 100%; height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.prejoin-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; }
.prejoin-card h1 { font-size: 22px; text-align: center; margin-bottom: 6px; font-weight: 650; }
.preview-wrap {
  position: relative; aspect-ratio: 16 / 10; border-radius: 14px;
  background: var(--tile); border: 1px solid var(--tile-border); overflow: hidden;
}
.preview-wrap video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview-off {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: 15px;
}
.prejoin-card input {
  background: var(--tile); border: 1px solid var(--tile-border); border-radius: 12px;
  padding: 14px 16px; font-size: 16px; color: var(--text); outline: none; width: 100%;
}
.prejoin-card input:focus { border-color: var(--accent); }
.join-btn {
  background: var(--accent); color: #fff; border: none; border-radius: 12px;
  padding: 15px; font-size: 16px; font-weight: 600; cursor: pointer;
}
.join-btn:disabled { opacity: 0.55; cursor: default; }
.prejoin-error { color: #ff8589; font-size: 14px; text-align: center; }

/* ---------- Topbar ---------- */
.call { height: 100%; height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  height: 64px; flex: 0 0 auto;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 28px; background: var(--bar); border-bottom: 1px solid #1c1f27;
}
.topbar-left {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-dim); font-size: 14px; letter-spacing: 0.22em; font-weight: 500;
}
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); flex: 0 0 auto; }
.topbar-title { font-size: 18px; font-weight: 700; text-align: center; }
.topbar-right { text-align: right; font-size: 17px; font-variant-numeric: tabular-nums; color: var(--text); }

/* ---------- Stage ---------- */
.stage { flex: 1; display: flex; gap: 20px; padding: 24px 28px; min-height: 0; }
.main-slot { flex: 1; min-width: 0; display: flex; }
.side-slot { width: 26%; max-width: 380px; min-width: 220px; display: flex; flex-direction: column; gap: 18px; overflow-y: auto; }
.side-slot:empty { display: none; }

.tile {
  position: relative; border-radius: 14px; overflow: hidden;
  background: var(--tile); border: 2px solid var(--tile-border);
  width: 100%;
}
.main-slot .tile { height: 100%; }
.side-slot .tile { aspect-ratio: 16 / 10; flex: 0 0 auto; cursor: pointer; }
.tile.speaking { border-color: var(--accent); }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile.mirror video { transform: scaleX(-1); }
.tile .avatar {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
}
.tile .avatar span {
  width: 72px; height: 72px; border-radius: 50%; background: #232733;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 600; color: var(--text-dim);
}
.side-slot .tile .avatar span { width: 52px; height: 52px; font-size: 20px; }
.name-chip {
  position: absolute; left: 14px; bottom: 12px; z-index: 2;
  background: var(--chip); border-radius: 9px; padding: 5px 13px;
  font-size: 14.5px; font-weight: 500; display: flex; align-items: center; gap: 8px;
}
.name-chip .mute-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); display: none; }
.tile.muted .name-chip .mute-dot { display: block; }

/* ---------- Controls ---------- */
.controls {
  flex: 0 0 auto; display: flex; justify-content: center; align-items: center; gap: 14px;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  background: var(--bar); border-top: 1px solid #1c1f27;
}
.ctrl {
  position: relative; width: 56px; height: 56px; border-radius: 50%;
  background: var(--ctrl); color: #dfe2ea; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.ctrl.off { background: #3a2026; color: #f26b6b; }
.ctrl.off::after {
  content: ""; position: absolute; width: 34px; height: 2.5px; background: #f26b6b;
  transform: rotate(-45deg); border-radius: 2px;
}
.ctrl.active { background: #2a3550; color: #9db6ff; }
.ctrl.leave { width: 96px; border-radius: 30px; background: var(--red); color: #fff; }
.badge {
  position: absolute; top: 2px; right: 2px; min-width: 19px; height: 19px; border-radius: 10px;
  background: var(--red); color: #fff; font-size: 11.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; padding: 0 5px;
}

/* ---------- Chat / Teilnehmer ---------- */
.chat-panel, .people-panel {
  position: absolute; top: 64px; right: 0; bottom: 93px; width: 320px; z-index: 10;
  background: var(--bar); border-left: 1px solid #1c1f27;
  display: flex; flex-direction: column;
}
.chat-head {
  padding: 16px 18px; font-weight: 650; border-bottom: 1px solid #1c1f27;
  display: flex; justify-content: space-between; align-items: center;
}
.panel-close { background: none; border: none; color: var(--text-dim); font-size: 22px; cursor: pointer; line-height: 1; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { font-size: 14.5px; line-height: 1.45; overflow-wrap: break-word; }
.chat-msg .who { color: var(--accent); font-weight: 600; margin-right: 6px; }
.chat-form { display: flex; gap: 8px; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid #1c1f27; }
.chat-form input {
  flex: 1; background: var(--tile); border: 1px solid var(--tile-border); border-radius: 10px;
  padding: 10px 12px; color: var(--text); font-size: 15px; outline: none; min-width: 0;
}
.chat-form button {
  background: var(--accent); border: none; border-radius: 10px; color: #fff;
  padding: 0 16px; font-size: 14.5px; font-weight: 600; cursor: pointer;
}
.people-list { list-style: none; padding: 10px 18px; display: flex; flex-direction: column; gap: 12px; }
.people-list li { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.people-list .mic-state { color: var(--text-dim); font-size: 13px; margin-left: auto; }

/* ---------- Film-Modus (Handy quer): Video vollflaechig, Leisten als Overlay ---------- */
body.film .call { position: relative; }
body.film .topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  background: linear-gradient(rgba(8, 9, 12, 0.78), rgba(8, 9, 12, 0)); border-bottom: none;
}
body.film .stage { position: absolute; inset: 0; padding: 0; gap: 0; }
body.film .main-slot .tile { border: none; border-radius: 0; }
body.film .main-slot .tile video { object-fit: contain; }
body.film .side-slot {
  position: absolute; top: 52px; right: 10px; width: 118px; min-width: 0;
  gap: 8px; z-index: 15; max-height: calc(100% - 120px);
}
body.film .side-slot .tile { border-width: 1.5px; border-radius: 10px; }
body.film .controls {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 20;
  background: linear-gradient(rgba(8, 9, 12, 0), rgba(8, 9, 12, 0.78)); border-top: none;
}
body.film .chat-panel, body.film .people-panel { top: 44px; bottom: 0; z-index: 25; }
body.film.ui-hidden .topbar, body.film.ui-hidden .controls { opacity: 0; pointer-events: none; }

/* ---------- iPhone quer (wenig Hoehe): kompakt, Bild fuellt den Platz ---------- */
@media (max-height: 520px) {
  .topbar { height: 44px; padding: 0 14px; }
  .topbar-left { font-size: 11px; letter-spacing: 0.16em; gap: 8px; }
  .live-dot { width: 8px; height: 8px; }
  .topbar-title { font-size: 14px; }
  .topbar-right { font-size: 13px; }
  .stage { padding: 10px 14px; gap: 10px; }
  .side-slot { min-width: 150px; width: 22%; gap: 10px; }
  .controls { padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); gap: 10px; }
  .ctrl { width: 44px; height: 44px; }
  .ctrl svg { width: 22px; height: 22px; }
  .ctrl.off::after { width: 27px; }
  .ctrl.leave { width: 74px; }
  .name-chip { left: 10px; bottom: 8px; padding: 3px 9px; font-size: 12px; }
  .tile .avatar span { width: 48px; height: 48px; font-size: 18px; }
  .chat-panel, .people-panel { top: 44px; bottom: 61px; width: 280px; }
}

/* ---------- iPhone / schmale Screens ---------- */
@media (max-width: 760px) {
  .topbar { padding: 0 16px; height: 54px; }
  .topbar-left { font-size: 12px; letter-spacing: 0.18em; gap: 8px; }
  .topbar-title { font-size: 16px; }
  .topbar-right { font-size: 15px; }
  .stage { flex-direction: column; padding: 12px; gap: 10px; }
  .side-slot {
    width: 100%; max-width: none; min-width: 0;
    flex-direction: row; gap: 10px; overflow-x: auto; overflow-y: hidden;
    flex: 0 0 auto; height: 96px;
  }
  .side-slot .tile { width: 130px; height: 96px; aspect-ratio: auto; }
  .side-slot .tile .avatar span { width: 40px; height: 40px; font-size: 16px; }
  .name-chip { left: 8px; bottom: 7px; padding: 3px 9px; font-size: 12px; }
  .controls { gap: 10px; }
  .ctrl { width: 50px; height: 50px; }
  .ctrl.leave { width: 78px; }
  .chat-panel, .people-panel { width: 100%; top: 54px; bottom: 87px; }
}
