:root { color-scheme: dark; }
* { box-sizing: border-box; }
html, body {
  /* Verhindert Pull-to-refresh (versehentliches Neuladen per Wisch von oben)
     auf Handy-Browsern; normales Scrollen bleibt erhalten. */
  overscroll-behavior-y: contain;
}
body {
  margin: 0;
  font-family: system-ui, "Segoe UI", sans-serif;
  background: #0d1117;
  color: #e6edf3;
}
header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
  flex-wrap: wrap;
}
header h1 { font-size: 16px; margin: 0; }
header .logo { height: 28px; width: 28px; margin-left: -4px; }   /* weiße Kachel aus logo.png */
header .mode { font-size: 12px; color: #7d8590; }
.bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid #30363d;
}
input[type="text"] {
  background: #0d1117;
  border: 1px solid #30363d;
  color: #e6edf3;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
}
input#signalingUrl { width: 230px; }
button {
  background: #238636;
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
}
button:hover { filter: brightness(1.1); }
button.secondary { background: #30363d; }
label { font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
/* Menü-Gruppen: vertiefte Boxen statt "|"-Trennern. Brechen am Handy als
   Ganzes um (flex-wrap der .bar), nicht mitten in einer Gruppe. */
.group {
  display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 5px; border-radius: 10px;
  background: #010409; border: 1px solid #21262d;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .6);
}
input[readonly] { color: #7ee787; min-width: 130px; }
/* Eigener Session-Code: fest 7 Zeichen ("K7M-4QX") -> schmal. Schrift wie das
   Partner-Feld; beide Codes grün. */
input#myCode {
  min-width: 0; box-sizing: content-box; width: 10.5ch;   /* passt auch "WMW-MWM"; Padding kommt dazu */
  text-align: center;
}
input#room { color: #7ee787; }
button:disabled { opacity: .5; cursor: default; }
button.active { background: #8957e5; }
.share-wrap { display: inline-flex; align-items: center; gap: 6px; }
.info {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: #30363d; color: #58a6ff; font-size: 12px; font-weight: 700;
  cursor: help; user-select: none;
}
.info:hover { background: #3d444d; }
#status { padding: 6px 16px; font-size: 13px; color: #58a6ff; }

/* Dateiaustausch: Liste laufender/fertiger Übertragungen */
#transfers { display: flex; flex-direction: column; gap: 8px; padding: 4px 16px; }
.transfer {
  background: #161b22; border: 1px solid #30363d; border-radius: 8px;
  padding: 8px 10px; font-size: 12px;
}
.tr-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.tr-name { color: #e6edf3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-size { color: #7d8590; flex: none; }
.tr-bar { height: 6px; background: #0d1117; border-radius: 4px; overflow: hidden; }
.tr-fill { height: 100%; width: 0; background: #238636; transition: width .15s ease; }
.tr-status { display: inline-block; margin-top: 5px; color: #58a6ff; }
.tr-dl { color: #7ee787; text-decoration: underline; cursor: pointer; }
.tr-dl:hover { filter: brightness(1.15); }
/* Ganzflächiger Hinweis beim Drag & Drop */
body.dragging::after {
  content: "Dateien hier ablegen zum Senden";
  position: fixed; inset: 0; z-index: 3000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(13, 17, 23, .85); color: #e6edf3; font-size: 20px;
  border: 3px dashed #238636; pointer-events: none;
}
/* Seite als Spalte über die volle Höhe: Kopf, Leiste, Status oben, die Bühne
   füllt den Rest -> am Handy kein Hin- und Herscrollen zwischen den Videos. */
body { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
#transfers { max-height: 30vh; overflow-y: auto; }
video { width: 100%; background: #000; border-radius: 8px; border: 1px solid #30363d; }

/* Menüleiste einklappbar (am Handy nach dem Verbinden automatisch). Eingeklappt
   bleiben nur die Medien-/Datei-Gruppen sichtbar; Session-Gruppen + Modus-Text weg. */
.menu-btn { margin-left: auto; padding: 5px 10px; font-size: 12px; }
body.menu-collapsed .bar .sess,
body.menu-collapsed header .mode { display: none; }

/* Bühne: der wichtigste Partner-Stream füllt die freie Fläche (Bild-im-Bild wie
   bei Teams/FaceTime). Klick/Tipp darauf öffnet den Zoom-Viewer. */
#stage {
  position: relative; flex: 1 1 auto; min-height: 260px;
  margin: 8px 16px 16px; border-radius: 10px; overflow: hidden;
  background: #010409; border: 1px solid #21262d;
}
.placeholder {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 16px; text-align: center; color: #7d8590; font-size: 14px;
}
.placeholder[hidden] { display: none; }
#remotes { position: absolute; inset: 0; }
.tile-wrap.main { position: absolute; inset: 0; }
.tile-wrap.main video {
  height: 100%; object-fit: contain; border: 0; border-radius: 0; cursor: zoom-in;
}

/* Dock: eigenes Bild + weitere Partner-Streams als kleine Fenster in einer Ecke.
   Verschiebbar, rastet in der nächsten Ecke ein (Klassen .top / .left). */
.dock {
  position: absolute; right: 8px; bottom: 8px; z-index: 5;
  width: clamp(96px, 28vw, 240px);
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
  touch-action: none; user-select: none; cursor: grab;
}
.dock.top { top: 8px; bottom: auto; flex-direction: column-reverse; }
.dock.left { left: 8px; right: auto; align-items: flex-start; }
.dock.dragging { cursor: grabbing; opacity: .85; }
.dock > * { width: 100%; }
.dock video {
  max-height: 38vh; object-fit: cover; display: block;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .6);
}
.dock .tile-wrap video { cursor: pointer; }   /* Tipp = auf die Bühne holen */
/* Eigene Vorschauen (Kamera, Bildschirm). Verkleinert (Tipp darauf): nur noch eine kleine Marke. */
.self[hidden] { display: none; }
.self.mini { width: 64px; }
.self.mini .overlay-btn:not(.muted) { display: none; }

/* Mute-/Kamera-Wechsel-Buttons als Overlay im eigenen Bild (nur bei geteilter Kamera).
   Mute dient zugleich als Anzeige: stumm -> rot + Beschriftung, dauerhaft sichtbar. */
.local-wrap { position: relative; }
.overlay-bar { position: absolute; top: 4px; right: 4px; display: flex; gap: 4px; }
.overlay-btn {
  font-size: 12px; padding: 3px 6px; border-radius: 6px;
  background: rgba(22, 27, 34, .7); color: #e6edf3; border: 1px solid #30363d;
  cursor: pointer;
}
.overlay-btn:hover { background: rgba(48, 54, 61, .9); }
.overlay-btn.muted { background: #da3633; border-color: #f85149; font-weight: 600; }
.overlay-btn[hidden] { display: none; }

/* Partner-Kachel: Wrapper für den Stumm-Hinweis */
.tile-wrap { position: relative; }
.mute-badge {
  position: absolute; top: 8px; right: 8px; pointer-events: none;
  font-size: 13px; font-weight: 600; padding: 4px 8px; border-radius: 6px;
  background: #da3633; color: #fff; border: 1px solid #f85149;
}
.mute-badge[hidden] { display: none; }
/* Im Vollbild oben links (Mitte = Toolbar, Ecken rechts oft das Dock) */
.viewer-badge { position: fixed; top: 12px; left: 12px; right: auto; z-index: 2001; }
/* "Tippen zum Starten" / "Tippen für Ton" mittig auf dem Video (Autoplay-Sperre) */
.play-hint {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2;
  pointer-events: none; white-space: nowrap;
  font-size: 14px; padding: 8px 14px; border-radius: 8px;
  background: rgba(22, 27, 34, .85); color: #e6edf3; border: 1px solid #58a6ff;
}
.play-hint[hidden] { display: none; }
.dock .play-hint { font-size: 11px; padding: 3px 6px; }
.resume-link {
  background: none; border: 0; padding: 0; font: inherit;
  color: #7ee787; text-decoration: underline; cursor: pointer;
}
.dock .mute-badge { top: 4px; right: 4px; font-size: 11px; padding: 2px 5px; }
.dock .mute-badge .mb-text { display: none; }   /* im kleinen Fenster nur 🔇 */

/* Eigener Vollbild-Viewer mit Zoom */
.zoom-viewer {
  position: fixed; inset: 0; z-index: 2000;
  background: #000; overflow: hidden;
  touch-action: none;                 /* eigene Pinch-/Pan-Gesten statt Browser-Zoom */
}
.zoom-viewer video {
  width: 100%; height: 100%;
  object-fit: contain;
  transform-origin: 0 0;
  border: 0; border-radius: 0;
  will-change: transform;
}
.zoom-viewer.zoomed { cursor: grab; }
.zoom-viewer.controlling { cursor: crosshair; }
.zoom-viewer.controlling.zoomed { cursor: crosshair; }

/* Hover-Toolbar: Zoom zurücksetzen, Steuern übernehmen/beenden, Modus, Schließen */
.zoom-bar {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 2001; display: flex; gap: 8px; padding: 6px;
  background: rgba(22, 27, 34, .82); border: 1px solid #30363d; border-radius: 10px;
  transition: opacity .25s;
}
.zoom-bar.hidden { opacity: 0; pointer-events: none; }
.zoom-bar button {
  font-size: 13px; padding: 6px 10px; border-radius: 6px;
  background: #21262d; color: #e6edf3; border: 1px solid #30363d;
  white-space: nowrap;
}
.zoom-bar button:hover:not(:disabled) { background: #30363d; }
.zoom-bar button:disabled { opacity: .55; }
.zoom-bar .zoom-bar-close { background: transparent; }
.zoom-bar .zoom-bar-close:hover { background: #30363d; }
.zoom-hint {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  z-index: 2001; padding: 6px 12px; border-radius: 6px;
  background: rgba(22, 27, 34, .8); color: #e6edf3; font-size: 12px;
  pointer-events: none; transition: opacity .6s; max-width: 92vw; text-align: center;
}
.zoom-hint.fade { opacity: 0; }

/* Links im Kopf: Desktop-App anfragen, Datenschutz (eingeklappt ausgeblendet) */
.site-links { font-size: 12px; color: #7d8590; }
.site-links a { color: #58a6ff; text-decoration: none; }
.site-links a:hover { text-decoration: underline; }
.site-links a[hidden] { display: none; }
body.menu-collapsed header .site-links { display: none; }

/* Unterseiten der Website (download.html, anfrage.html, datenschutz.html, Admin-Seiten) */
.site-page { max-width: 680px; margin: 0 auto; padding: 20px 16px 40px; line-height: 1.5; font-size: 14px; }
.site-page h1 { font-size: 20px; margin: 8px 0 12px; }
.site-page h2 { font-size: 15px; margin: 22px 0 6px; }
.site-page a { color: #58a6ff; }
.site-box {
  background: #161b22; border: 1px solid #30363d; border-radius: 10px; padding: 12px 16px; margin: 12px 0;
}
.site-form { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.site-form label { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
.site-form input, .site-form textarea {
  background: #0d1117; border: 1px solid #30363d; color: #e6edf3;
  border-radius: 6px; padding: 8px 10px; font: inherit;
}
.site-form button { align-self: flex-start; }
.site-form .hp { position: absolute; left: -9999px; }   /* Köderfeld gegen Bots */
.site-msg { color: #58a6ff; }
.site-small { font-size: 12px; color: #7d8590; }
.site-dl {
  display: inline-block; margin: 6px 8px 6px 0; padding: 9px 14px; border-radius: 6px;
  background: #238636; color: #fff !important; text-decoration: none; font-weight: 600;
}
.site-dl:hover { filter: brightness(1.1); }

/* Screen-/Fenster-Picker (Desktop) */
.modal {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0, 0, 0, .7);
  display: flex; align-items: center; justify-content: center;
}
.modal-box {
  background: #161b22; border: 1px solid #30363d; border-radius: 10px;
  padding: 20px; max-width: 80vw; max-height: 82vh; overflow: auto;
}
.modal-box h3 { margin: 0 0 14px; font-size: 15px; }
.src-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  margin-bottom: 14px;
}
.src-card {
  background: #0d1117; border: 1px solid #30363d; border-radius: 8px;
  padding: 8px; display: flex; flex-direction: column; gap: 6px;
  cursor: pointer; text-align: left;
}
.src-card:hover { border-color: #58a6ff; }
.src-card img { width: 100%; border-radius: 4px; background: #000; }
.src-card span { font-size: 12px; color: #e6edf3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
