/* app.css – Feldmeyer Office (SPEC.md §3.9, §3.10). Keine externen Fonts/Assets. */

/* [hidden] muss jedes eigene display: … schlagen (z. B. #panel{display:flex}). */
[hidden] { display: none !important; }

/* ============ Variablen & Reset ============ */
:root {
  --bg: #0f1117;
  --panel: #1b1f2e;
  --panel-alpha: rgba(27, 31, 46, 0.95);
  --panel-blur: blur(8px);
  --text: #e7e9ee;
  --muted: #8b93a7;
  --accent: #4f8cff;
  --accent-dim: rgba(79, 140, 255, 0.18);
  --green: #00c245;
  --red: #e5484d;
  --yellow: #f5b90a;
  --away: #7a8194;
  --border: rgba(255, 255, 255, 0.08);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

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

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body { overflow: hidden; }
body.legal-page { overflow: auto; }

h1, h2, h3, p, dl, dt, dd { margin: 0; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
ul { margin: 0; }

button {
  background: none;
  border: none;
  cursor: pointer;
}
button:disabled { cursor: not-allowed; opacity: 0.6; }

img, canvas, video { display: block; }

/* Sichtbare Fokus-Styles */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

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

/* ============ Bildschirm-Umschaltung ============ */
#unsupported, #join, #app { display: none; }
body[data-screen="unsupported"] #unsupported { display: flex; }
body[data-screen="join"] #join { display: flex; }
body[data-screen="app"] #app { display: block; }

/* ============ Unsupported-Screen ============ */
#unsupported {
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}
.unsupported-card {
  max-width: 480px;
  background: var(--panel-alpha);
  backdrop-filter: var(--panel-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
}
.unsupported-card h1 { font-size: 18px; margin-bottom: 12px; }
.unsupported-card p { color: var(--muted); line-height: 1.5; margin-bottom: 10px; }
.unsupported-card .unsupported-hint { font-size: 12px; color: var(--muted); }

/* ============ Join-Screen ============ */
#join {
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 24px max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  padding-top: max(24px, env(safe-area-inset-top));
  background:
    radial-gradient(1200px 800px at 20% -10%, rgba(79, 140, 255, 0.10), transparent 60%),
    radial-gradient(900px 700px at 100% 110%, rgba(0, 194, 69, 0.08), transparent 60%),
    var(--bg);
}
.join-card {
  width: 100%;
  max-width: 620px;
  background: var(--panel-alpha);
  backdrop-filter: var(--panel-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
}
.join-title { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 4px; }
.join-subtitle { color: var(--muted); text-align: center; margin-bottom: 20px; font-size: 13px; }

.join-body {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 20px;
  margin-bottom: 18px;
}
@media (max-width: 520px) {
  .join-body { grid-template-columns: 1fr; }
}

.field-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.join-col-avatar { display: flex; flex-direction: column; align-items: center; }
.avatar-preview {
  width: 96px;
  height: 144px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#avatar-canvas { image-rendering: pixelated; image-rendering: crisp-edges; width: 96px; height: 144px; }

.avatar-parts { width: 100%; margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.avatar-part-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.avatar-part-name { flex: 1; text-align: center; font-size: 12px; color: var(--muted); }
.avatar-arrow {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}
.avatar-arrow:hover { background: rgba(255, 255, 255, 0.12); }

.join-col-media { min-width: 0; }
.media-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius-md);
  background: #05070c;
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
#preview-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}
.media-off-msg { color: var(--muted); font-size: 13px; }
.mic-level {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  height: 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.mic-level-bar {
  height: 100%;
  width: 0%;
  background: var(--green);
  transition: width 80ms linear;
}

.media-toggles { display: flex; gap: 12px; justify-content: center; margin-top: 12px; }
.round-toggle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
}
.round-toggle .icon svg { width: 20px; height: 20px; }
.round-toggle.off { background: var(--red); color: #fff; }
.round-toggle.on { background: var(--green); color: #fff; }

.device-selects { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.device-select-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}
.device-select-row select {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  color: var(--text);
}

.btn-secondary, .btn-primary {
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  margin-top: 10px;
  width: 100%;
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.12); }
.btn-primary {
  background: var(--green);
  color: #06210f;
  border-color: transparent;
}
.btn-primary:hover { filter: brightness(1.08); }

.join-field { margin-bottom: 14px; }
.join-field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.join-field input {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
}
.join-field input:focus-visible { border-color: var(--accent); }

.join-error {
  background: rgba(229, 72, 77, 0.14);
  border: 1px solid rgba(229, 72, 77, 0.4);
  color: #ffb3b5;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}
.join-hint { color: var(--muted); font-size: 12px; margin-bottom: 14px; }

.btn-large { width: 100%; padding: 13px 16px; font-size: 15px; }

.join-privacy { color: var(--muted); font-size: 11.5px; line-height: 1.5; margin-top: 16px; }
.join-privacy-link { display: inline-block; margin-top: 4px; font-size: 12px; }

/* ============ App-Shell ============ */
#app { position: fixed; inset: 0; }
#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #05070c;
}

.hud {
  position: fixed;
  inset: 0;
  height: 100dvh;
  pointer-events: none;
  z-index: 10;
}
.hud-el { pointer-events: none; }

/* ============ Topbar ============ */
#topbar {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-alpha);
  backdrop-filter: var(--panel-blur);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12.5px;
  max-width: calc(100vw - 24px);
  pointer-events: auto;
}
.topbar-room { font-weight: 700; white-space: nowrap; }
.topbar-online, .topbar-zone { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-sep { color: var(--muted); }
.topbar-net { display: flex; align-items: center; gap: 6px; margin-left: 4px; }
.net-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.net-dot.net-online { background: var(--green); }
.net-dot.net-reconnecting { background: var(--yellow); }
.net-dot.net-offline { background: var(--red); }
.net-label { display: none; }
@media (min-width: 560px) { .net-label { display: inline; color: var(--muted); } }

/* ============ Video-Leiste ============ */
#videos {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  max-width: calc(100vw - 24px);
  flex-wrap: wrap;
  justify-content: center;
}
.video-tile {
  position: relative;
  width: 180px;
  height: 101px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #05070c;
  border: 2px solid transparent;
  pointer-events: auto;
  cursor: pointer;
  flex-shrink: 0;
}
.video-tile.speaking { border-color: var(--green); }
.tile-media { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: #12141c; }
.tile-media video { width: 100%; height: 100%; object-fit: cover; }
.tile-placeholder { display: flex; align-items: center; justify-content: center; }
.tile-bottom {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 6px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.65), transparent);
}
.tile-name {
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.tile-icons { display: flex; align-items: center; gap: 3px; flex-shrink: 0; }
.tile-icons .icon svg { width: 14px; height: 14px; }
.tile-icons .icon { color: #fff; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6)); }
.tile-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(245, 185, 10, 0.92);
  color: #241900;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
}
.tile-mute-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 120ms ease;
}
.tile-mute-btn .icon svg { width: 14px; height: 14px; }
.video-tile:hover .tile-mute-btn, .tile-mute-btn.active { opacity: 1; }
.tile-mute-btn.active { background: var(--red); }

.video-overflow {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
}
.overflow-count { font-size: 16px; font-weight: 700; color: var(--text); }

/* ============ Bühne (Pin / Screen-Share groß) ============ */
#stage {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60vw;
  max-width: 960px;
  min-width: 280px;
}
.stage-card {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #05070c;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  pointer-events: auto;
  box-shadow: var(--shadow);
}
.stage-video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.stage-cam .stage-video { object-fit: cover; }
.stage-label {
  position: absolute;
  left: 12px;
  bottom: 10px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
}
.stage-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stage-close .icon svg { width: 16px; height: 16px; }

/* ============ Minimap ============ */
#minimap {
  position: absolute;
  top: max(64px, calc(env(safe-area-inset-top) + 56px));
  right: max(12px, env(safe-area-inset-right));
  width: 160px;
  height: 160px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(5, 7, 12, 0.7);
  box-shadow: var(--shadow);
}

/* ============ Self-View ============ */
#selfview {
  position: absolute;
  left: max(12px, env(safe-area-inset-left));
  bottom: max(96px, calc(env(safe-area-inset-bottom) + 88px));
}
.selfview-card {
  position: relative;
  width: 160px;
  height: 90px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #12141c;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.selfview-video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.selfview-placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.selfview-name {
  position: absolute;
  left: 6px;
  bottom: 4px;
  color: #fff;
  font-size: 11px;
  background: rgba(0, 0, 0, 0.5);
  padding: 1px 6px;
  border-radius: 999px;
}

/* ============ Toolbar ============ */
#toolbar {
  position: absolute;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100vw - 16px);
}
.toolbar-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--panel-alpha);
  backdrop-filter: var(--panel-blur);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px;
  box-shadow: var(--shadow);
  pointer-events: auto;
}
.toolbar-sep { width: 1px; align-self: stretch; background: var(--border); margin: 4px 2px; flex-shrink: 0; }

.personal-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
}
.personal-chip:hover { background: rgba(255, 255, 255, 0.08); }
.chip-avatar { width: 28px; height: 28px; border-radius: 50%; overflow: hidden; display: flex; }
.chip-name { font-size: 13px; font-weight: 600; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-chevron svg { width: 14px; height: 14px; color: var(--muted); }

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.status-dot-available { background: var(--green); }
.status-dot-busy { background: var(--yellow); }
.status-dot-dnd { background: var(--red); }
.status-dot-away { background: var(--away); }

.tb-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  color: var(--text);
}
.tb-btn:hover { background: rgba(255, 255, 255, 0.08); }
.tb-btn .icon svg { width: 20px; height: 20px; }
.tb-btn.on, .tb-mic.on, .tb-cam.on { background: var(--green); color: #06210f; }
.tb-btn.off, .tb-mic.off, .tb-cam.off { color: var(--text); }
.tb-mic:not(.on), .tb-cam:not(.on) { }
.tb-mic.on, .tb-cam.on, .tb-screen.on { background: var(--green); color: #06210f; }
.tb-mic:not(.on) { color: var(--red); }
.tb-cam:not(.on) { color: var(--red); }
.tb-emote.on { color: var(--yellow); }
.tb-label { font-size: 12px; margin-left: 2px; }
.tb-participants { width: auto; padding: 0 12px 0 6px; border-radius: 999px; gap: 4px; }

.badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.top-right-controls {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  gap: 6px;
  pointer-events: auto;
  z-index: 11;
}
.top-right-controls .tb-btn {
  background: var(--panel-alpha);
  backdrop-filter: var(--panel-blur);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.top-right-controls .tb-btn.active { color: var(--accent); }

/* ---- Popovers (Personal-Menü, Emote-Picker) ---- */
.popover {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-alpha);
  backdrop-filter: var(--panel-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  padding: 8px;
  min-width: 220px;
  pointer-events: auto;
  z-index: 20;
}
.personal-menu { left: 90px; transform: none; }
@media (max-width: 700px) { .personal-menu { left: 8px; } }

.menu-section { padding: 4px 6px; }
.menu-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  text-align: left;
}
.menu-item:hover { background: rgba(255, 255, 255, 0.08); }
.menu-item .icon svg { width: 16px; height: 16px; color: var(--muted); }
.menu-item.active { color: var(--accent); }
.status-item.active { background: var(--accent-dim); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }

.emote-picker { min-width: 260px; }
.emote-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.emote-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 10px 4px;
  border-radius: 10px;
}
.emote-btn:hover { background: rgba(255, 255, 255, 0.08); }
.emote-glyph { font-size: 22px; line-height: 1; }
.emote-key { font-size: 9px; color: var(--muted); }
.emote-clear-row { margin-top: 4px; }
.emote-clear { flex-direction: row; width: 100%; gap: 8px; }

/* ============ Panel ============ */
#panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  max-width: 100vw;
  display: flex;
  flex-direction: column;
  background: var(--panel-alpha);
  backdrop-filter: var(--panel-blur);
  border-left: 1px solid var(--border);
  pointer-events: auto;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.35);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-right: env(safe-area-inset-right);
}
.panel-header {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 6px 6px 6px 12px;
  flex-shrink: 0;
}
.panel-tabs { display: flex; gap: 2px; flex: 1; }
.panel-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--muted);
}
.panel-tab .icon svg { width: 16px; height: 16px; }
.panel-tab:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.panel-tab.active { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.panel-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex-shrink: 0;
}
.panel-close:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.panel-close .icon svg { width: 16px; height: 16px; }
.panel-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.panel-body > * { flex: 1; min-height: 0; }

@media (max-width: 700px) {
  #panel { width: 100vw; }
  .panel-tab-label { display: none; }
}

/* ---- Chat-Tab ---- */
.chat-tab { display: flex; flex-direction: column; height: 100%; }
.chat-scope-switch {
  display: flex;
  gap: 4px;
  padding: 10px 12px 0;
  flex-shrink: 0;
}
.chat-scope-btn {
  flex: 1;
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 12.5px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}
.chat-scope-btn.active { background: var(--accent-dim); color: var(--accent); }
.chat-hint { padding: 6px 12px 0; font-size: 11.5px; color: var(--muted); flex-shrink: 0; }
.chat-messages { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.chat-empty { color: var(--muted); font-size: 12.5px; text-align: center; margin-top: 20px; }
.chat-msg { max-width: 100%; }
.chat-msg.scope-nearby { background: rgba(0, 194, 69, 0.08); border-radius: 8px; padding: 6px 8px; margin: -6px -8px; }
.chat-msg-head { display: flex; align-items: baseline; gap: 6px; margin-bottom: 2px; }
.chat-msg-name { font-size: 12.5px; font-weight: 700; }
.chat-msg-scope-tag {
  font-size: 9.5px;
  color: var(--green);
  background: rgba(0, 194, 69, 0.15);
  padding: 1px 6px;
  border-radius: 999px;
}
.chat-msg-time { font-size: 11px; color: var(--muted); margin-left: auto; }
.chat-msg-text { font-size: 13px; line-height: 1.45; word-break: break-word; white-space: pre-wrap; }
.chat-msg-text a { word-break: break-all; }
.chat-system { text-align: center; font-size: 11.5px; color: var(--muted); font-style: italic; }
.chat-compose {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  resize: none;
  max-height: 120px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
}
.chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-send-btn .icon svg { width: 16px; height: 16px; }
.chat-send-btn:hover { filter: brightness(1.1); }

/* ---- Teilnehmer-Tab ---- */
.participants-tab { padding: 10px 8px; overflow-y: auto; height: 100%; }
.participant-group { margin-bottom: 14px; }
.participant-group-title {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 8px 6px;
}
.participant-list { display: flex; flex-direction: column; gap: 2px; }
.participant-empty { color: var(--muted); font-size: 12.5px; padding: 6px 8px; }
.participant-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 10px;
}
.participant-row:hover { background: rgba(255, 255, 255, 0.05); }
.participant-info { flex: 1; min-width: 0; }
.participant-name-line { display: flex; align-items: center; gap: 6px; }
.participant-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.participant-hand { font-size: 12px; }
.participant-sub { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.participant-sub .sub-icon svg { width: 13px; height: 13px; color: var(--muted); }
.participant-tag {
  font-size: 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 6px;
  border-radius: 999px;
}
.participant-samenetwork { color: var(--yellow); background: rgba(245, 185, 10, 0.12); }
.participant-actions { display: flex; gap: 2px; flex-shrink: 0; }
.participant-actions .icon-btn { width: 30px; height: 30px; }
.participant-actions .icon svg { width: 15px; height: 15px; }
.participant-mute-btn.active { color: var(--red); }

/* ---- Einstellungen-Tab ---- */
.settings-tab { padding: 6px 14px 16px; overflow-y: auto; height: 100%; }
.settings-section { padding: 14px 0; border-bottom: 1px solid var(--border); }
.settings-section:last-child { border-bottom: none; }
.settings-section-title { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 10px; }
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  font-size: 13px;
}
.settings-row-label { flex: 1; }
.settings-select-row select {
  min-width: 0;
  max-width: 170px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  color: var(--text);
}
.settings-range-row input[type="range"] { width: 150px; accent-color: var(--accent); }
.settings-hint { font-size: 11px; color: var(--muted); margin: -2px 0 6px; }

.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch-track {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  transition: background 120ms ease;
}
.switch-track::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 120ms ease;
}
.switch input:checked + .switch-track { background: var(--green); }
.switch input:checked + .switch-track::before { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============ Toasts & Banner ============ */
#toasts {
  position: absolute;
  left: 50%;
  bottom: max(84px, calc(env(safe-area-inset-bottom) + 76px));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 24px);
}
.toast {
  background: rgba(10, 12, 18, 0.92);
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 200ms ease, transform 200ms ease;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.hide { opacity: 0; }
.toast-error { background: rgba(229, 72, 77, 0.92); }
.toast-success { background: rgba(0, 194, 69, 0.92); }

#banners {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  z-index: 15;
}
.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(245, 185, 10, 0.95);
  color: #241900;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  pointer-events: auto;
  box-shadow: var(--shadow);
}
.banner[data-id="reconnecting"], .banner[data-id="offline"] { background: rgba(229, 72, 77, 0.95); color: #2a0506; }
.banner-action {
  background: rgba(0, 0, 0, 0.16);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.banner-action:hover { background: rgba(0, 0, 0, 0.26); }

/* ============ Overlays (Hilfe, Tutorial, Bestätigung) ============ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  pointer-events: auto;
  padding: 20px;
}

#help, #tutorial { z-index: 30; }
#help { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); display: flex; align-items: center; justify-content: center; padding: 20px; pointer-events: auto; }
#help[hidden] { display: none; }

.help-card {
  width: 100%;
  max-width: 480px;
  max-height: 82vh;
  overflow-y: auto;
  background: var(--panel-alpha);
  backdrop-filter: var(--panel-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.overlay-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.overlay-header h2 { font-size: 16px; }
.overlay-close { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.overlay-close:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.overlay-close .icon svg { width: 16px; height: 16px; }
.help-intro { color: var(--muted); font-size: 12.5px; margin-bottom: 14px; }
.help-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin-bottom: 14px; }
.help-list dt {
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 3px 8px;
  white-space: nowrap;
  align-self: start;
}
.help-list dd { font-size: 12.5px; color: var(--text); align-self: center; }
.help-note { font-size: 11.5px; color: var(--muted); line-height: 1.5; margin-top: 8px; }

#tutorial {
  position: fixed;
  left: 50%;
  bottom: max(94px, calc(env(safe-area-inset-bottom) + 86px));
  transform: translateX(-50%);
  pointer-events: none;
}
.tutorial-card {
  background: rgba(10, 12, 18, 0.92);
  color: #fff;
  border-radius: 999px;
  padding: 10px 18px;
  text-align: center;
  box-shadow: var(--shadow);
  max-width: 90vw;
}
.tutorial-text { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tutorial-skip { font-size: 11px; color: rgba(255, 255, 255, 0.6); margin-top: 2px; }

.confirm-overlay { z-index: 200; }
.confirm-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel-alpha);
  backdrop-filter: var(--panel-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.confirm-text { font-size: 14px; line-height: 1.5; margin-bottom: 18px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }
.confirm-actions .btn-secondary, .confirm-actions .btn-primary { width: auto; margin-top: 0; }

/* ============ Icon-Buttons (generisch) ============ */
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.08); }
.icon-btn .icon svg { width: 18px; height: 18px; }
.icon { display: inline-flex; }
.icon svg { display: block; }

/* ============ Responsive: < 700px – nur Icons in der Toolbar ============ */
@media (max-width: 700px) {
  .chip-name { display: none; }
  .tb-label { display: none; }
  .tb-participants { width: 40px; padding: 0; }
  #videos { max-width: calc(100vw - 16px); }
  .video-tile { width: 128px; height: 72px; }
  #stage { width: 92vw; }
  #minimap { width: 110px; height: 110px; top: max(56px, calc(env(safe-area-inset-top) + 48px)); }
}

@media (max-width: 480px) {
  .video-tile { width: 100px; height: 56px; }
  #selfview { display: none; }
}

/* ============ Datenschutz / Impressum ============ */
body.legal-page {
  min-height: 100%;
  background:
    radial-gradient(1000px 700px at 15% -10%, rgba(79, 140, 255, 0.08), transparent 60%),
    var(--bg);
}
.legal {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px 80px;
  padding-top: max(40px, env(safe-area-inset-top));
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.legal-back { color: var(--accent); font-size: 13px; text-decoration: none; }
.legal-back:hover { text-decoration: underline; }
.legal h1 { font-size: 24px; margin-top: 4px; }
.legal-updated { color: var(--muted); font-size: 12px; margin-top: -14px; }
.legal section { display: flex; flex-direction: column; gap: 8px; }
.legal h2 { font-size: 15px; color: var(--text); }
.legal p, .legal li { color: #c7cbd6; line-height: 1.6; font-size: 13.5px; }
.legal ul { padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.legal code {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
}
.legal-placeholder {
  background: rgba(245, 185, 10, 0.1);
  border: 1px dashed rgba(245, 185, 10, 0.5);
  border-radius: 10px;
  padding: 10px 12px;
  color: #f5d998 !important;
  font-style: italic;
}

/* ============ Virtueller Joystick (nur Touch) ============ */
.joystick {
  position: fixed;
  width: 108px;
  height: 108px;
  margin: -54px 0 0 -54px;      /* left/top = Berührpunkt */
  border-radius: 50%;
  background: rgba(15, 17, 23, 0.45);
  border: 2px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(3px);
  pointer-events: none;
  z-index: 30;
}
.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(79, 140, 255, 0.75);
  border: 2px solid rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
}
@media (prefers-reduced-motion: no-preference) {
  .joystick-knob { transition: transform 60ms linear; }
}

/* ============ Handy-Layout ============ */
@media (max-width: 560px) {
  /* Beitritt: Name, Passwort und Button zuerst – ohne Scrollen erreichbar */
  #join { align-items: flex-start; padding-top: max(16px, env(safe-area-inset-top)); }
  .join-card { display: flex; flex-direction: column; padding: 18px 16px 22px; }
  .join-title { order: 0; }
  .join-subtitle { order: 1; margin-bottom: 12px; }
  #join .join-field { order: 2; }
  #join #password-field { order: 3; }
  #join .join-error { order: 4; }
  #join #enter-btn { order: 5; margin-top: 6px; }
  #join .join-hint { order: 6; margin-top: 10px; }
  #join .join-body { order: 7; margin-top: 14px; }
  #join .join-privacy { order: 8; }
  #join .join-privacy-link { order: 9; }
  .avatar-preview { width: 64px; height: 96px; }
  #avatar-canvas { width: 64px; height: 96px; }
  .avatar-arrow { width: 34px; height: 34px; }
  .media-box { max-height: 150px; }

  /* HUD: Video-Kacheln unter die Kopfzeile, Minimap kleiner */
  #videos { top: calc(max(12px, env(safe-area-inset-top)) + 44px); }
  #minimap { width: 92px; height: 92px; top: calc(max(12px, env(safe-area-inset-top)) + 110px); }
  #topbar { font-size: 12px; padding: 6px 10px; }

  /* Toolbar: Bildschirmfreigabe und Einstellungen raus (beides über das Personen-Menü bzw. am Handy nicht verfügbar) */
  .tb-screen, .tb-settings { display: none; }
  .toolbar-pill { gap: 2px; padding: 5px; }
  .tb-btn { width: 38px; height: 38px; }
  .personal-chip { padding: 3px 6px 3px 3px; }
  #toolbar { bottom: max(10px, env(safe-area-inset-bottom)); max-width: calc(100vw - 8px); }

  /* Toasts über der Toolbar halten */
  #toasts { bottom: calc(max(10px, env(safe-area-inset-bottom)) + 62px); }
}
