:root {
  --bg: #0f1420;
  --bg-elevated: #161d2e;
  --bg-card: #1c2438;
  --bg-hover: #232c44;
  --border: #2a3350;
  --text: #eef1f8;
  --text-muted: #8b93ab;
  --primary: #5b8def;
  --primary-hover: #4a7bdc;
  --success: #29c76f;
  --danger: #ef4b5b;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0,0,0,0.35);
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none; /* verhindert "Gummiband"-Ziehen der ganzen Seite auf Mobilgeräten */
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 800px at 20% -10%, #1b2440 0%, var(--bg) 55%);
  color: var(--text);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent; /* kein grauer Blitz beim Antippen auf Mobilgeräten */
}

.hidden { display: none !important; }

button {
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation; /* entfernt die 300ms-Tap-Verzögerung & Doppeltipp-Zoom */
  -webkit-tap-highlight-color: transparent;
}
input { font-family: inherit; }
a, li, .friend-item, .search-result-item { touch-action: manipulation; }

/* ===================== AUTH SCREEN ===================== */
.screen {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

#auth-screen {
  display: flex;
  overflow-y: auto;
}

/* Große Branding-Spalte - standardmäßig ausgeblendet, erst ab einer gewissen
   Breite eingeblendet (siehe Media-Query weiter unten). Auf dem Handy bleibt
   es beim einfachen, mittig zentrierten Formular wie bisher. */
.auth-branding { display: none; }

.auth-form-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  min-height: 100%;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px 24px;
}

@media (min-width: 860px) {
  .auth-branding {
    display: flex;
    flex: 1.1;
    align-items: center;
    justify-content: center;
    padding: 60px;
    position: relative;
    overflow: hidden;
    background:
      radial-gradient(900px 700px at 15% 10%, rgba(91,141,239,0.35) 0%, transparent 60%),
      radial-gradient(700px 600px at 85% 90%, rgba(41,199,111,0.18) 0%, transparent 55%),
      linear-gradient(160deg, #17203a 0%, #0c111f 100%);
  }
  .auth-branding-content { max-width: 420px; color: #fff; }
  .auth-branding .brand-logo.lg svg { display: block; filter: drop-shadow(0 8px 24px rgba(0,0,0,0.35)); }
  .auth-branding h1 { font-size: 38px; margin: 20px 0 14px; letter-spacing: -0.02em; }
  .auth-branding-tagline {
    font-size: 16px;
    line-height: 1.65;
    color: rgba(255,255,255,0.78);
    margin: 0 0 34px;
  }
  .auth-feature-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  .auth-feature-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14.5px;
    color: rgba(255,255,255,0.88);
  }
  .auth-feature-list svg { flex-shrink: 0; color: var(--success); }

  .auth-form-panel { flex: 1; background: var(--bg); padding: 40px; }
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
}
.brand h1 { font-size: 26px; margin: 0; }
.brand.small { justify-content: flex-start; }
.brand.small span { font-weight: 700; font-size: 16px; }

.tagline {
  text-align: center;
  color: var(--text-muted);
  margin: 8px 0 24px;
  font-size: 14px;
}

.tabs {
  display: flex;
  background: var(--bg-elevated);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 20px;
}
.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 9px 0;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  transition: all .15s ease;
}
.tab-btn.active {
  background: var(--primary);
  color: white;
}

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}
.auth-form input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
  outline: none;
  transition: border-color .15s ease;
}
.auth-form input:focus { border-color: var(--primary); }

.form-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 16px;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  transition: background .15s ease, transform .05s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: .5; cursor: default; }

.auth-footer {
  text-align: center;
  margin-top: 22px;
  font-size: 12px;
  color: var(--text-muted);
}
.auth-footer a { color: inherit; text-decoration: none; }
.auth-footer strong { color: var(--primary); }
.auth-footer a:hover strong { text-decoration: underline; }

/* ===================== APP SHELL ===================== */
#app-screen { display: flex; flex-direction: column; }
.app-shell {
  flex: 1;
  display: flex;
  min-height: 0;
}

.sidebar {
  width: 300px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.me-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
}
.me-info { flex: 1; min-width: 0; }
.me-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-username { font-size: 12px; color: var(--text-muted); }

.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 15px; flex-shrink: 0;
  background: var(--primary);
  position: relative;
  overflow: hidden;
}
.avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}
.avatar.small { width: 34px; height: 34px; font-size: 13px; }
.avatar.large { width: 88px; height: 88px; font-size: 32px; margin: 0 auto 12px; flex-shrink: 0; }
.avatar.xlarge { width: 128px; height: 128px; font-size: 44px; margin: 0 auto 18px; }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  width: 34px; height: 34px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn:disabled:hover { background: transparent; }

.icon-btn svg, .round-btn svg { display: block; }
/* Hörer-Symbol für "Ablehnen"/"Auflegen" um 135° gedreht -> klassisches Auflegen-Icon */
.icon-rot { transform: rotate(135deg); }

.sidebar-toolbar { display: flex; gap: 8px; }
.toolbar-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 10px;
  padding: 9px 8px;
  font-size: 12.5px;
  font-weight: 600;
  transition: background .15s ease, color .15s ease;
}
.toolbar-btn:hover { background: var(--bg-hover); color: var(--text); }

.add-friend { position: relative; }
.add-friend input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}
.add-friend input:focus { border-color: var(--primary); }

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 20;
  max-height: 260px;
  overflow-y: auto;
}
.search-result-item, .request-item, .friend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
}
.search-result-item { cursor: default; }
.search-result-item .name-block, .request-item .name-block, .friend-item .name-block {
  flex: 1; min-width: 0;
}
.name-block .dn { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.name-block .un { font-size: 12px; color: var(--text-muted); }

.mini-btn {
  border: none;
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  background: var(--primary);
  color: white;
  white-space: nowrap;
}
.mini-btn.secondary { background: var(--bg-hover); color: var(--text); }
.mini-btn.danger { background: transparent; color: var(--danger); }
.mini-btn:disabled { opacity: .5; }

.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  font-weight: 700;
  margin-top: 4px;
}

.request-list, .friends-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.request-item { background: var(--bg-card); border-radius: 10px; margin-bottom: 6px; }
.request-item .actions { display: flex; gap: 6px; }

.friend-item {
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  transition: background .12s ease;
}
.friend-item:hover { background: var(--bg-hover); }
.friend-item.active { background: var(--bg-card); border: 1px solid var(--border); }
.friend-item .avatar { position: relative; }
.presence-dot {
  position: absolute;
  bottom: -1px; right: -1px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: #555;
  border: 2px solid var(--bg-elevated);
}
.presence-dot.online { background: var(--success); }
.empty-hint { color: var(--text-muted); font-size: 13px; padding: 10px; }
.unread-badge {
  background: var(--primary);
  color: white;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}

/* ===================== MAIN CHAT AREA ===================== */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-header {
  min-height: 62px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
}
.chat-header-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.chat-name { font-weight: 600; font-size: 15px; }
.chat-status { font-size: 12px; color: var(--text-muted); }
.chat-header-actions { display: flex; gap: 6px; margin-left: auto; }
.mobile-only { display: none; }

.chat-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 10px;
  text-align: center;
  padding: 20px;
}
.chat-empty-icon { opacity: .5; display: flex; justify-content: center; }

.messages-list {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.msg-row { display: flex; }
.msg-row.mine { justify-content: flex-end; }
.msg-bubble {
  max-width: 70%;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.msg-row.mine .msg-bubble {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}
.msg-row:not(.mine) .msg-bubble { border-bottom-left-radius: 4px; }
.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 3px;
}
.msg-time { font-size: 10.5px; opacity: .65; }
.msg-receipt { display: flex; align-items: center; opacity: .8; }
.msg-receipt.read { color: #bfe0ff; opacity: 1; }

.chat-status.typing { color: var(--primary) !important; font-style: italic; }

/* ===================== ANRUF-EINTRAG IM CHATVERLAUF ===================== */
.msg-row.call-row { justify-content: center; }
.call-log-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.call-log-pill svg { flex-shrink: 0; }
.call-log-pill.missed { color: var(--danger); border-color: rgba(239,75,91,0.4); }
.call-log-pill .call-log-time { opacity: .7; margin-left: 2px; }

.chat-input-bar {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}
.chat-input-bar input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14.5px;
  outline: none;
}
.chat-input-bar input:focus { border-color: var(--primary); }
.send-btn { padding: 11px 20px; }

.app-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.app-footer a { color: inherit; text-decoration: none; }
.app-footer strong { color: var(--primary); }
.app-footer a:hover strong { text-decoration: underline; }

/* ===================== INCOMING CALL TOAST (kompakt) ===================== */
.incoming-call {
  position: fixed;
  top: 20px; left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  width: min(92vw, 380px);
}
.incoming-call-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 16px;
  padding: 12px 16px;
  animation: slideDown .25s ease;
}
.incoming-call-row { display: flex; align-items: center; gap: 14px; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-16px);} to { opacity: 1; transform: translateY(0);} }
.incoming-text { flex: 1; min-width: 0; }
.incoming-text #incoming-name { font-weight: 700; font-size: 15px; }
.incoming-type { font-size: 12px; color: var(--text-muted); }
.incoming-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ===================== SCHNELLANTWORTEN (Anruf ablehnen) ===================== */
.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.quick-reply-chip {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 12.5px;
  padding: 7px 12px;
  border-radius: 999px;
  white-space: nowrap;
  transition: background .12s ease, border-color .12s ease;
}
.quick-reply-chip:hover { background: var(--bg-hover); border-color: var(--primary); }
.quick-replies-fs { justify-content: center; padding: 0 20px; }
.quick-replies-fs .quick-reply-chip {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.18);
  color: white;
  font-size: 13.5px;
  padding: 9px 14px;
}
.quick-replies-fs .quick-reply-chip:hover { background: rgba(255,255,255,0.16); }

/* ===================== INCOMING CALL VOLLBILD (FaceTime-artig) ===================== */
.incoming-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  background: radial-gradient(1200px 900px at 50% -10%, #23345c 0%, #0a0e18 60%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 48px 20px 20px;
  z-index: 250;
  color: white;
  text-align: center;
}
.incoming-fs-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.incoming-fs-name { font-size: 26px; font-weight: 700; margin-bottom: 6px; }
.incoming-fs-type { font-size: 15px; color: var(--text-muted); animation: pulseText 1.8s ease-in-out infinite; }
@keyframes pulseText { 0%, 100% { opacity: .6; } 50% { opacity: 1; } }

.incoming-fs-actions {
  display: flex;
  justify-content: center;
  gap: 56px;
  padding: 28px 0 8px;
}
.incoming-fs-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}
.round-btn.xl { width: 68px; height: 68px; }

.round-btn {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: none;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s ease, filter .1s ease;
}
.round-btn:hover { filter: brightness(1.1); }
.round-btn:active { transform: scale(0.95); }
.round-btn.accept { background: var(--success); color: white; }
.round-btn.decline { background: var(--danger); color: white; }
.round-btn.control { background: var(--bg-hover); color: var(--text); }
.round-btn.control.active-off { background: var(--danger); color: white; }

/* ===================== CALL SCREEN ===================== */
.call-screen {
  position: fixed;
  top: 0;
  left: 0;
  background: #0a0e18;
  display: flex;
  flex-direction: column;
  z-index: 200;
}
.call-videos {
  flex: 1;
  position: relative;
  overflow: hidden;
}
#remote-video {
  width: 100%; height: 100%;
  object-fit: cover;
  background: #0a0e18;
}
.remote-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  text-align: center;
  gap: 4px;
}
#remote-placeholder.hidden-flag { display: none; }
#call-peer-name { font-size: 20px; font-weight: 700; }
#call-status-text { color: var(--text-muted); font-size: 14px; }

#local-video {
  position: absolute;
  width: 160px;
  height: 210px;
  object-fit: cover;
  bottom: 18px; right: 18px;
  border-radius: 14px;
  border: 2px solid rgba(255,255,255,0.15);
  box-shadow: var(--shadow);
  background: #111;
}

.call-controls {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  gap: 18px;
  padding: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}
.call-controls .round-btn { width: 58px; height: 58px; font-size: 22px; }

.call-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding-bottom: 10px;
}
.call-footer a { color: inherit; text-decoration: none; }
.call-footer strong { color: var(--primary); }
.call-footer a:hover strong { text-decoration: underline; }

/* ===================== ANRUFE / EINSTELLUNGEN (Unterseiten) ===================== */
.secondary-screen {
  position: fixed;
  top: 0;
  left: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  z-index: 220;
}
.secondary-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
}
.secondary-header h2 { margin: 0; font-size: 18px; }

.calls-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  -webkit-overflow-scrolling: touch;
}
.call-history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 10px;
  border-radius: 12px;
  cursor: pointer;
}
.call-history-item:hover { background: var(--bg-hover); }
.call-history-item .name-block { flex: 1; min-width: 0; }
.call-history-item .dn { font-size: 14.5px; font-weight: 600; }
.call-history-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}
.call-history-meta.missed { color: var(--danger); }
.call-history-time { font-size: 11.5px; color: var(--text-muted); flex-shrink: 0; }
.call-history-icon { flex-shrink: 0; color: var(--text-muted); display: flex; }
.call-history-icon.outgoing { color: var(--success); }
.call-history-icon.missed { color: var(--danger); }

.settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.settings-section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 10px;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 0;
}
.settings-row-title { font-size: 14.5px; font-weight: 600; }
.settings-row-hint { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.settings-note { margin-top: 6px; line-height: 1.5; }
.settings-upload-label { display: inline-flex; cursor: pointer; }

.settings-row .avatar.large { margin: 0; }
.settings-avatar-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.theme-color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 4px 0 14px;
}
.theme-swatch {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid transparent;
  padding: 0;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease;
}
.theme-swatch:hover { transform: scale(1.08); }
.theme-swatch.active { border-color: var(--text); }
.theme-swatch-custom {
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.theme-swatch-custom input[type="color"] {
  width: 46px; height: 46px;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
  opacity: 0; /* eigenes rundes Swatch-Aussehen kommt vom umgebenden Label; der native Farbwähler öffnet sich trotzdem beim Klick */
}

.messages-list.has-chat-bg {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
}
.messages-list.has-chat-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(15, 20, 32, 0.55);
  pointer-events: none;
}
.messages-list.has-chat-bg .msg-row,
.messages-list.has-chat-bg .empty-hint {
  position: relative;
  z-index: 1;
}

/* ===================== GRUPPEN ===================== */
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}
.section-title-row .section-title { margin-top: 0; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  width: min(420px, 100%);
  max-height: 86vh;
  overflow-y: auto;
}
.modal-card h3 { margin: 0 0 16px; font-size: 17px; }
.modal-label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.modal-label input {
  display: block;
  width: 100%;
  margin-top: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}
.modal-label input:focus { border-color: var(--primary); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.group-member-picker {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 8px;
}
.group-member-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 6px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.group-member-option:hover { background: var(--bg-hover); }
.group-member-option input { accent-color: var(--primary); }

.msg-sender {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 2px;
}

/* ===================== VERBINDUNGSSTATUS ===================== */
.connection-banner {
  background: var(--danger);
  color: white;
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  padding: 7px 12px;
  padding-top: max(7px, env(safe-area-inset-top));
  flex-shrink: 0;
}

/* ===================== UPLOAD-FORTSCHRITT ===================== */
.upload-progress-wrap {
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: var(--bg-hover);
  overflow: hidden;
  margin-top: 8px;
}
.upload-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width .15s ease;
}

/* ===================== TOAST ===================== */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 13.5px;
  z-index: 300;
}

/* ===================== RESPONSIVE (MOBILE) ===================== */
@media (max-width: 760px) {
  .mobile-only { display: flex; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 82vw;
    max-width: 320px;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform .22s cubic-bezier(.32,.72,0,1);
    box-shadow: var(--shadow);
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .sidebar.open { transform: translateX(0); }

  .chat-header { padding: 0 8px; }
  .messages-list { padding: 12px; }
  .msg-bubble { max-width: 85%; }

  /* Größere Touch-Ziele auf Mobilgeräten (mind. ~44px empfohlen) */
  .icon-btn { width: 42px; height: 42px; }
  .friend-item, .request-item, .search-result-item { padding: 11px 10px; }
  .mini-btn { padding: 8px 12px; }
  .add-friend input { padding: 12px 14px; }
  .chat-input-bar input { padding: 13px 14px; }
  .send-btn { padding: 13px 18px; }

  /* Schriftgröße >= 16px verhindert, dass iOS Safari beim Fokussieren automatisch hineinzoomt */
  .auth-form input, .add-friend input, .chat-input-bar input { font-size: 16px; }

  #local-video {
    width: 96px;
    height: 128px;
    bottom: 12px; right: 12px;
    transition: opacity .15s ease;
  }
  .call-controls { gap: 14px; padding: 16px; }
  .call-controls .round-btn { width: 54px; height: 54px; }

  .auth-card { padding: 26px 20px 18px; }
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 50;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
