:root {
  --bg: #0f1626;
  --panel: #16203a;
  --panel-2: #1d2b4d;
  --accent: #2979ff;
  --text: #e6edf7;
  --muted: #9fb0c8;
  --danger: #ff5252;
  --ok: #69f0ae;
  --me: #1f3a5f;
  --them: #24304d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  height: 100dvh;   /* Handy: Adressleiste beruecksichtigen */
  overflow: hidden;
}

.hidden { display: none !important; }

/* ── Beitreten ─────────────────────────────────────────── */
.join {
  height: 100vh; height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.join-card {
  background: var(--panel);
  padding: 30px;
  border-radius: 14px;
  width: 380px;
  max-width: 94vw;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}
.join-card h1 { margin: 0 0 4px; color: var(--accent); }
.join-card .sub { margin: 0 0 20px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.join-card label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.join-card input {
  width: 100%; margin-top: 5px; padding: 11px 12px;
  border-radius: 8px; border: 1px solid var(--panel-2);
  background: var(--bg); color: var(--text); font-size: 16px;
}
.join-card button {
  width: 100%; padding: 13px; border: none; border-radius: 8px;
  background: var(--accent); color: #fff; font-size: 16px; font-weight: 600;
  cursor: pointer; margin-top: 6px;
}
.join-card button:hover { filter: brightness(1.1); }
.hint { color: var(--danger); font-size: 13px; min-height: 18px; margin: 10px 0 0; }

/* ── Chat ──────────────────────────────────────────────── */
.chat { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--panel-2);
}
.room-label { font-size: 14px; }
.peer-status { color: var(--muted); font-size: 12px; }
.peer-status.online { color: var(--ok); }
.spacer { flex: 1; }
.ghost {
  background: transparent; border: 1px solid var(--panel-2); color: var(--text);
  padding: 7px 11px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.ghost:hover { background: var(--panel-2); }
.ghost.leave { border-color: #5a2a2a; color: var(--danger); }

.safety {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px;
  padding: 8px 14px;
  background: #14251c;
  border-bottom: 1px solid #1e3a2a;
  font-size: 13px;
}
.safety b { color: var(--ok); letter-spacing: 1px; }
.safety-hint { color: var(--muted); font-size: 11px; }

.log {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;      /* nie horizontal ausbrechen */
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.bubble {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.bubble .who { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.bubble.me   { align-self: flex-end; background: var(--me); border-bottom-right-radius: 4px; }
.bubble.them { align-self: flex-start; background: var(--them); border-bottom-left-radius: 4px; }
.bubble.sys  {
  align-self: center; background: transparent; color: var(--muted);
  font-size: 12px; padding: 2px 6px;
}

.composer {
  display: flex; gap: 8px;
  padding: 10px 12px;
  background: var(--panel);
  border-top: 1px solid var(--panel-2);
}
.composer input {
  flex: 1; padding: 12px 14px;
  border-radius: 10px; border: 1px solid var(--panel-2);
  background: var(--bg); color: var(--text); font-size: 16px;
}
.composer input:disabled { opacity: 0.5; }
.composer button {
  padding: 12px 20px; border: none; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 600;
  cursor: pointer;
}
.composer button:disabled { opacity: 0.4; cursor: default; }

/* Aufnahme-Knopf (Push-to-Talk) */
.composer button.rec {
  padding: 12px 16px; background: var(--panel-2); font-size: 18px;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.composer button.rec.recording {
  background: #e5484d; color: #fff;
  animation: recpulse 1s ease-in-out infinite;
}
@keyframes recpulse { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.35); } }

/* Sprachnachricht-Bubble: Blase passt sich dem nativen Player an (kein Ausbrechen,
   kein Abschneiden). Der Player hat eine Mindestbreite (~200px) — die Blase gibt sie ihm. */
.bubble { min-width: 0; }
.bubble.vb { width: 256px; max-width: 86vw; }
.bubble.vb audio.voice {
  display: block; margin-top: 2px; height: 40px; width: 100%;
}

/* ── Kontakte ──────────────────────────────────────────── */
.contacts { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.me-name { font-size: 13px; color: var(--muted); cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.me-name:hover { background: var(--panel-2); color: var(--text); }
.contacts-body { flex: 1; overflow-y: auto; padding: 14px; }
.contacts-actions { margin-bottom: 12px; }
button.primary {
  padding: 12px 16px; border: none; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
}
button.primary:hover { filter: brightness(1.1); }
.paste-row { display: flex; gap: 8px; margin-bottom: 16px; }
.paste-row input { flex: 1; padding: 11px 12px; border-radius: 8px; border: 1px solid var(--panel-2); background: var(--bg); color: var(--text); font-size: 14px; }
.paste-row button { padding: 11px 16px; border: none; border-radius: 8px; background: var(--panel-2); color: var(--text); font-weight: 600; cursor: pointer; }
.paste-row button:hover { background: var(--accent); color: #fff; }

.contact-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.contact {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--panel-2);
  border-radius: 10px; padding: 10px 12px;
}
.contact .dot { width: 10px; height: 10px; border-radius: 50%; background: #47506a; flex: none; }
.contact.online .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.contact .cname { font-size: 15px; font-weight: 600; }
.contact .cstate { font-size: 11px; color: var(--muted); }
.contact .spacer { flex: 1; }
.contact button { flex: none; }
.contact .cstate { margin-right: auto; }
.contact .del { border-color: #5a2a2a; }
.empty-hint { color: var(--muted); font-size: 13px; line-height: 1.6; padding: 10px 4px; }

.quick { margin-top: 22px; color: var(--muted); }
.quick summary { cursor: pointer; font-size: 13px; padding: 6px 0; }
.quick-body { display: flex; gap: 8px; margin-top: 8px; }
.quick-body input { flex: 1; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--panel-2); background: var(--bg); color: var(--text); font-size: 15px; }
.quick-body button { padding: 10px 16px; border: none; border-radius: 8px; background: var(--panel-2); color: var(--text); cursor: pointer; }

/* ── Modals ────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.55); padding: 12px;
}
.modal-card { background: var(--panel); border-radius: 14px; padding: 24px; width: 400px; max-width: 94vw; box-shadow: 0 10px 40px rgba(0,0,0,0.5); }
.modal-card h2 { margin: 0 0 6px; color: var(--accent); font-size: 18px; }
.modal-card .sub { margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.modal-card label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.modal-card label input { width: 100%; margin-top: 5px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--panel-2); background: var(--bg); color: var(--text); font-size: 15px; }
.link-row { display: flex; gap: 8px; margin-bottom: 16px; }
.link-row input { flex: 1; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--panel-2); background: var(--bg); color: var(--muted); font-size: 12px; }
.link-row button { padding: 10px 14px; border: none; border-radius: 8px; background: var(--panel-2); color: var(--text); cursor: pointer; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .primary { flex: 1; }
.modal-actions .ghost { flex: none; }

/* ── Video-Bühne ───────────────────────────────────────── */
.video-stage {
  position: fixed; inset: 0; z-index: 35;
  background: #000;
  display: flex; align-items: center; justify-content: center;
}
.video-stage #remoteVideo {
  width: 100%; height: 100%; object-fit: contain; background: #000;
}
.video-stage .local-pip {
  position: absolute; right: 14px; bottom: 92px;
  width: 120px; height: 160px; object-fit: cover;
  border-radius: 12px; border: 2px solid rgba(255,255,255,0.25);
  background: #111; box-shadow: 0 6px 20px rgba(0,0,0,0.5);
  transform: scaleX(-1);   /* Spiegel wie ein Selfie */
}
.video-stage .local-pip.sharing {
  transform: none;          /* Bildschirm NICHT spiegeln (Text lesbar) */
  object-fit: contain; background: #000;
}
.video-stage .video-name {
  position: absolute; top: 14px; left: 16px;
  padding: 6px 12px; border-radius: 20px;
  background: rgba(0,0,0,0.5); color: #fff; font-size: 14px;
}
.video-controls {
  position: absolute; bottom: 20px; left: 0; right: 0;
  display: flex; gap: 16px; justify-content: center;
}
.video-controls button {
  width: 56px; height: 56px; border-radius: 50%;
  border: none; cursor: pointer; font-size: 22px;
  background: rgba(255,255,255,0.15); color: #fff;
  backdrop-filter: blur(6px);
}
.video-controls button:hover { background: rgba(255,255,255,0.28); }
.video-controls button.off { background: rgba(255,80,80,0.35); }
.video-controls button.hang { background: var(--danger); }
.video-controls button.hang:hover { filter: brightness(1.15); }
@media (max-width: 520px) {
  .video-stage .local-pip { width: 90px; height: 120px; bottom: 88px; }
}

/* ── Eingehender Anruf ─────────────────────────────────── */
.incoming { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.6); }
.incoming-card { background: var(--panel); border-radius: 18px; padding: 32px 28px; text-align: center; width: 320px; max-width: 92vw; box-shadow: 0 12px 48px rgba(0,0,0,0.6); }
.incoming-emoji { font-size: 46px; animation: ringshake 0.8s ease-in-out infinite; }
@keyframes ringshake { 0%,100% { transform: rotate(-12deg); } 50% { transform: rotate(12deg); } }
.incoming-name { font-size: 18px; margin: 12px 0 4px; }
.incoming-kind { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.incoming-actions { display: flex; gap: 14px; justify-content: center; }
.incoming-actions button { padding: 13px 22px; border: none; border-radius: 30px; font-size: 15px; font-weight: 600; cursor: pointer; color: #fff; }
.incoming-actions .accept { background: #22c55e; }
.incoming-actions .decline { background: var(--danger); }
