:root {
  --bg-0: #15161b;
  --bg-1: #1c1d23;
  --bg-2: #24262d;
  --bg-3: #2d3038;
  --bg-hover: #32353e;
  --text: #e6e7eb;
  --muted: #9a9ca6;
  --accent: #6c5ce7;
  --accent-2: #8174f0;
  --ok: #2ecc71;
  --danger: #e5484d;
  --warn: #f5a623;
  --radius: 8px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg-0);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}
input,
textarea,
select {
  font: inherit;
  color: var(--text);
  background: var(--bg-0);
  border: 1px solid var(--bg-3);
  border-radius: 6px;
  padding: 9px 11px;
  width: 100%;
}
input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
a {
  color: #7fb2ff;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 12px;
}
.bold {
  font-weight: 600;
}
.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.pad {
  padding: 8px;
}
.spacer {
  flex: 1;
}
.icon {
  display: inline-flex;
  flex-shrink: 0;
}
.loading {
  display: grid;
  place-items: center;
  height: 100vh;
  color: var(--muted);
}

/* ---------- Buttons ---------- */
.btn {
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  padding: 9px 16px;
  font-weight: 600;
  color: #fff;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
}
.btn:hover {
  background: var(--accent-2);
}
.btn.ghost {
  background: transparent;
  color: var(--text);
}
.btn.ghost:hover {
  background: var(--bg-hover);
}
.btn.danger {
  background: var(--danger);
}
.btn.wide {
  width: 100%;
}
.icon-btn {
  background: transparent;
  border: 0;
  border-radius: 6px;
  padding: 6px;
  color: var(--muted);
  display: inline-grid;
  place-items: center;
}
.icon-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
}
.icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.icon-btn.danger {
  color: var(--danger);
}
.icon-btn.ok {
  color: var(--ok);
}

/* ---------- Anmeldung ---------- */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(circle at 20% 10%, #2a2457 0, transparent 50%), radial-gradient(circle at 80% 90%, #1d3a4a 0, transparent 50%), var(--bg-0);
}
.auth-card {
  width: min(420px, 100%);
  background: var(--bg-2);
  border-radius: 12px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 60px #0008;
}
.auth-card h1 {
  margin: 0;
  text-align: center;
  font-size: 24px;
}
.auth-card > .muted {
  text-align: center;
  margin: -8px 0 4px;
}
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
label > span {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.form-error {
  color: var(--danger);
  min-height: 1em;
  font-size: 13px;
}
.switch {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 72px 240px 1fr 240px;
  height: 100vh;
  height: 100dvh; /* Handy: sichtbare Höhe ohne Adressleiste/Tastatur */
  overflow: hidden;
  /* Notch / Statusleiste / Home-Balken als installierte Web-App */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.layout.no-members {
  grid-template-columns: 72px 240px 1fr;
}
.layout.no-members .members {
  display: none;
}

.rail {
  background: var(--bg-0);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  overflow-y: auto;
}
.rail-btn {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 0;
  background: var(--bg-2);
  font-weight: 700;
  font-size: 15px;
  transition: border-radius 0.15s, background 0.15s;
  position: relative;
  display: grid;
  place-items: center;
}
.rail-btn:hover,
.rail-btn.active {
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
}
.rail-btn.add {
  color: var(--ok);
}
.rail-btn.add:hover {
  background: var(--ok);
  color: #fff;
}
.rail-btn::before {
  content: '';
  position: absolute;
  left: -12px;
  width: 4px;
  height: 0;
  border-radius: 0 4px 4px 0;
  background: #fff;
  transition: height 0.15s;
}
.rail-btn.unread::before {
  height: 8px;
}
.rail-btn.active::before {
  height: 36px;
}
.rail-sep {
  width: 32px;
  height: 2px;
  background: var(--bg-3);
  border-radius: 1px;
}

.sidebar {
  background: var(--bg-1);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.sidebar-header {
  width: 100%;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border: 0;
  background: transparent;
  font-weight: 700;
  border-bottom: 1px solid var(--bg-0);
  gap: 8px;
}
button.sidebar-header:hover {
  background: var(--bg-hover);
}
.channel-list {
  padding: 8px;
}
.cat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  padding: 14px 8px 4px;
}
.cat .icon-btn {
  padding: 2px;
}
.channel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  margin: 1px 0;
}
.channel:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.channel.active {
  background: var(--bg-3);
  color: var(--text);
}
.channel.unread {
  color: var(--text);
  font-weight: 600;
}
.channel .ellipsis {
  flex: 1;
}
.channel.dm {
  padding: 4px 8px;
}
.hover-only {
  visibility: hidden;
  padding: 2px;
}
.channel:hover .hover-only,
.member:hover .hover-only {
  visibility: visible;
}
.badge {
  background: var(--danger);
  color: #fff;
  border-radius: 10px;
  padding: 0 6px;
  font-size: 12px;
  font-weight: 700;
}
.p2p-tag {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  color: var(--ok);
}
.voice-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px 3px 34px;
  color: var(--muted);
  font-size: 14px;
}
.voice-user .ellipsis {
  flex: 1;
}
.ring {
  border-radius: 50%;
  box-shadow: 0 0 0 2px transparent;
  transition: box-shadow 0.1s;
}
.ring.speaking {
  box-shadow: 0 0 0 2px var(--ok);
}

.avatar {
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
  user-select: none;
}
.pavatar {
  position: relative;
  flex-shrink: 0;
  width: fit-content;
}
.pavatar .dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #747f8d;
  border: 3px solid var(--bg-1);
}
.pavatar .dot.on {
  background: var(--ok);
}

.voice-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-top: 1px solid var(--bg-0);
  gap: 8px;
}
.voice-bar.show {
  display: flex;
}
.voice-bar .ok {
  color: var(--ok);
  font-weight: 600;
  font-size: 13px;
}
.voice-bar > div {
  min-width: 0;
}
.user-panel {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  background: #18191e;
}
.user-panel .who {
  flex: 1;
  min-width: 0;
  line-height: 1.2;
}
.user-panel .icon-btn {
  padding: 5px;
}
.user-panel .icon-btn.danger {
  color: var(--danger);
}

/* ---------- Hauptbereich ---------- */
.main {
  background: var(--bg-2);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.main-header {
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--bg-0);
  color: var(--muted);
}
.main-header h3 {
  margin: 0;
  font-size: 16px;
  color: var(--text);
}
.conn-state {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-3);
}
.conn-state.connected {
  color: var(--ok);
}
.conn-state.connecting {
  color: var(--warn);
}
.call-controls {
  display: flex;
  gap: 4px;
  align-items: center;
  background: var(--bg-1);
  border-radius: 8px;
  padding: 2px 4px 2px 10px;
  color: var(--ok);
}
.tabs {
  display: flex;
  gap: 4px;
  margin-left: 12px;
  flex-wrap: wrap;
}
.tab {
  background: transparent;
  border: 0;
  border-radius: 4px;
  padding: 3px 10px;
  color: var(--muted);
}
.tab:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.tab.active {
  background: var(--bg-3);
  color: var(--text);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0 8px;
  min-height: 0;
}
.channel-start {
  padding: 16px 16px 24px;
}
.channel-start h2 {
  margin: 8px 0 4px;
}
.channel-start p {
  margin: 4px 0;
  max-width: 640px;
}
.big-icon {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--bg-3);
  display: grid;
  place-items: center;
}
.msg {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 0 14px;
  padding: 2px 16px;
  margin-top: 14px;
  position: relative;
}
.msg.grouped {
  margin-top: 0;
}
.msg:hover {
  background: #0000001a;
}
.msg.mention {
  background: #f5a62312;
  box-shadow: inset 2px 0 var(--warn);
}
.msg-time-side {
  font-size: 11px;
  color: var(--muted);
  visibility: hidden;
  text-align: right;
  padding-top: 3px;
}
.msg:hover .msg-time-side {
  visibility: visible;
}
.msg-body {
  min-width: 0;
}
.msg-head {
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.author {
  font-weight: 600;
}
.time {
  font-size: 12px;
  color: var(--muted);
}
.msg-text {
  word-wrap: break-word;
  white-space: normal;
}
.md code {
  background: var(--bg-0);
  border-radius: 4px;
  padding: 1px 4px;
  font-size: 0.9em;
}
.md pre {
  background: var(--bg-0);
  border-radius: 6px;
  padding: 8px 10px;
  overflow-x: auto;
  margin: 4px 0;
}
.md pre code {
  padding: 0;
}
.spoiler {
  background: #000;
  color: transparent;
  border-radius: 3px;
  cursor: pointer;
}
.spoiler:focus,
.spoiler:hover {
  color: inherit;
  background: var(--bg-3);
}
.msg-actions {
  position: absolute;
  right: 16px;
  top: -14px;
  display: none;
  background: var(--bg-1);
  border: 1px solid var(--bg-0);
  border-radius: 6px;
}
.msg:hover .msg-actions {
  display: flex;
}
.dm-status {
  font-size: 11px;
  margin-left: 6px;
  color: var(--muted);
}
.dm-status.delivered {
  color: var(--ok);
}
.attachment-img img {
  max-width: min(400px, 100%);
  max-height: 320px;
  border-radius: 6px;
  margin-top: 4px;
  display: block;
}
.attachment-media {
  max-width: min(480px, 100%);
  border-radius: 6px;
  margin-top: 4px;
}
.attachment-file {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  background: var(--bg-1);
  border: 1px solid var(--bg-0);
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 4px;
  max-width: min(400px, 100%);
  text-decoration: none;
  color: var(--text);
}
.attachment-file > div {
  min-width: 0;
}
.progress-bar {
  height: 4px;
  background: var(--bg-3);
  border-radius: 2px;
  margin-top: 4px;
  max-width: 400px;
}
.progress {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 2px;
}

.typing {
  height: 20px;
  font-size: 12px;
  color: var(--muted);
  padding: 0 16px;
}
.composer-wrap {
  margin: 0 16px 20px;
}
.dm-messages + .composer-wrap {
  margin-top: 12px;
}
.composer {
  background: var(--bg-3);
  border-radius: var(--radius);
  display: flex;
  align-items: flex-end;
  padding: 4px;
  gap: 2px;
}
.composer.drag {
  outline: 2px dashed var(--accent);
}
.composer.disabled {
  padding: 12px 16px;
  color: var(--muted);
}
.composer textarea {
  background: transparent;
  border: 0;
  resize: none;
  max-height: 240px;
  padding: 8px 6px;
}
.composer textarea:focus {
  outline: none;
}
.dm-messages + .composer {
  margin-top: 12px;
}
.empty-main {
  flex: 1;
  display: grid;
  place-items: center;
}

/* ---------- Freunde ---------- */
.friends {
  padding: 16px 24px;
  overflow-y: auto;
}
.friends h4 {
  margin: 4px 0 12px;
}
.friend-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-top: 1px solid var(--bg-3);
  border-radius: 6px;
}
.friend-row:hover {
  background: var(--bg-hover);
}
.friend-row .who {
  flex: 1;
  min-width: 0;
}
.add-friend {
  display: flex;
  gap: 8px;
  max-width: 640px;
}
.add-friend .btn {
  white-space: nowrap;
}
.empty {
  text-align: center;
  padding: 40px 0;
}

/* ---------- Mitglieder ---------- */
.members {
  background: var(--bg-1);
  overflow-y: auto;
  padding: 8px;
}
.member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
  border-radius: 6px;
}
.member:hover {
  background: var(--bg-hover);
}
.member.offline {
  opacity: 0.45;
}
.member .who {
  flex: 1;
  min-width: 0;
}
.member .pavatar .dot {
  border-color: var(--bg-1);
}
.role-badge {
  font-size: 11px;
  color: var(--muted);
}

/* ---------- Overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: #000a;
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 16px;
}
.modal {
  background: var(--bg-2);
  border-radius: 12px;
  padding: 24px;
  width: min(460px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 60px #000a;
}
.modal h2 {
  margin: 0;
  font-size: 20px;
}
.modal p {
  margin: 0;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}
.menu {
  position: fixed;
  z-index: 40;
  background: #111216;
  border-radius: 8px;
  padding: 6px;
  min-width: 220px;
  box-shadow: 0 8px 24px #000a;
  display: flex;
  flex-direction: column;
}
.menu-item {
  background: transparent;
  border: 0;
  text-align: left;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 14px;
}
.menu-item:hover {
  background: var(--accent);
  color: #fff;
}
.menu-item.danger {
  color: var(--danger);
}
.menu-item.danger:hover {
  background: var(--danger);
  color: #fff;
}
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 20px);
  background: #111216;
  padding: 10px 18px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
  z-index: 60;
  box-shadow: 0 8px 24px #000a;
  max-width: calc(100vw - 32px);
}
#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
#toast.error {
  border-left: 3px solid var(--danger);
}
#toast.clickable {
  pointer-events: auto;
  cursor: pointer;
  border-left: 3px solid var(--accent);
}
.update-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 8px;
}
.update-box .inst-row {
  width: 100%;
}
.update-box p {
  margin: 0;
}
.conn-lost {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--danger);
  color: #fff;
  text-align: center;
  padding: 4px;
  font-size: 13px;
  transform: translateY(-100%);
  transition: 0.2s;
  z-index: 70;
}
.conn-lost.show {
  transform: none;
}
.call-popup {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #111216;
  border-radius: 14px;
  padding: 20px 28px;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 55;
  box-shadow: 0 12px 40px #000c;
  animation: pulse 1.5s infinite;
}
.call-popup.show {
  display: flex;
}
.call-popup .row {
  display: flex;
  gap: 16px;
  margin-top: 10px;
}
.round {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  color: #fff;
}
.round.ok {
  background: var(--ok);
}
.round.danger {
  background: var(--danger);
}
@keyframes pulse {
  50% {
    box-shadow: 0 12px 40px #000c, 0 0 0 6px #2ecc7133;
  }
}

/* ---------- P2P / Einstellungen ---------- */
.modal {
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
label.check {
  flex-direction: row-reverse;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}
label.check input {
  width: auto;
}
label.check span {
  text-transform: none;
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
}
.code-row {
  display: flex;
  gap: 8px;
  align-items: center;
  max-width: 720px;
}
.code-box {
  flex: 1;
  min-width: 0;
  background: var(--bg-0);
  border-radius: 6px;
  padding: 9px 11px;
  font-size: 13px;
  overflow-wrap: anywhere;
  user-select: all;
}
.code-input {
  max-width: 720px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  margin-bottom: 8px;
  resize: vertical;
}
.mono {
  font-family: ui-monospace, Consolas, monospace;
}
h4.space {
  margin-top: 28px !important;
}
.settings-extra {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.settings-extra .cat {
  padding: 8px 0 0;
}
.row-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.inst-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.inst-row .ellipsis {
  flex: 1;
}
.rail-btn.inst-off {
  opacity: 0.45;
  outline: 2px dashed var(--danger);
  outline-offset: -2px;
}
.sidebar-header.static .p2p-tag {
  font-size: 11px;
  font-weight: 600;
}
.sidebar-header .ellipsis .muted {
  font-weight: 400;
}

/* ---------- Einstellungen (Vollbild) ---------- */
.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: var(--bg-2);
  display: flex;
  justify-content: center;
}
.settings-window {
  display: grid;
  grid-template-columns: 240px minmax(0, 720px);
  width: 100%;
  max-width: 1000px;
  position: relative;
}
.settings-nav {
  background: var(--bg-1);
  padding: 40px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.settings-tab {
  display: flex;
  gap: 10px;
  align-items: center;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--muted);
}
.settings-tab:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.settings-tab.active {
  background: var(--bg-3);
  color: var(--text);
}
.settings-body {
  padding: 40px 40px 80px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.settings-body h2 {
  margin: 0 0 6px;
}
.settings-body h3 {
  margin: 18px 0 0;
  font-size: 13px;
  text-transform: uppercase;
  color: var(--muted);
}
.settings-body p {
  margin: 0;
}
.settings-body .btn.ghost {
  background: var(--bg-3);
}
.settings-body .btn.ghost:hover {
  background: var(--bg-hover);
}
.settings-close {
  position: absolute;
  top: 16px;
  right: 16px;
  border: 1px solid var(--bg-3);
  border-radius: 50%;
}
.set-field {
  gap: 6px;
}
.set-field small {
  font-size: 12px;
}
.set-check {
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}
.set-check input {
  width: auto;
  margin-top: 3px;
}
.set-check.inline {
  align-items: center;
}
.set-check.inline input {
  margin: 0;
}
.range-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.range-row input {
  flex: 1;
  padding: 0;
  accent-color: var(--accent);
}
.range-val {
  width: 52px;
  text-align: right;
  color: var(--muted);
  font-size: 13px;
}
.meter {
  height: 8px;
  background: var(--bg-0);
  border-radius: 4px;
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--ok), var(--warn));
  transition: width 0.06s;
}
.cam-preview {
  width: 100%;
  max-width: 480px;
  border-radius: 8px;
  background: #000;
}
.cam-preview:not([src]):not(.active) {
  min-height: 0;
}
video.mirror {
  transform: scaleX(-1);
}
.sound-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}
.sound-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.sound-row .sound-btn {
  flex: 1;
}
.sound-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-3);
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 0;
  text-align: left;
}
.sound-btn:hover {
  background: var(--accent);
  color: #fff;
}
.sound-btn .emoji {
  font-size: 18px;
}
.sound-add {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.sound-add input[type='file'] {
  flex: 1 1 220px;
}
.sound-add input:not([type='file']) {
  flex: 0 1 180px;
}
.sound-menu {
  min-width: 280px;
  max-width: 320px;
}
.sound-menu .cat {
  padding: 4px 6px 8px;
}
.sound-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 6px;
}

/* ---------- GIFs ---------- */
.gif-btn {
  font-weight: 800;
  font-size: 12px;
  border: 2px solid currentColor;
  padding: 1px 5px;
  margin: 8px 4px;
  border-radius: 5px;
}
.gif-modal {
  width: min(640px, 100%);
}
.gif-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
  max-height: 55vh;
  overflow-y: auto;
}
.gif {
  border: 0;
  padding: 0;
  background: var(--bg-0);
  border-radius: 6px;
  overflow: hidden;
  height: 110px;
}
.gif img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.gif:hover {
  outline: 2px solid var(--accent);
}
.gif-msg img {
  display: block;
  max-width: min(320px, 100%);
  max-height: 260px;
  border-radius: 6px;
  margin-top: 4px;
}

/* ---------- Sprachkanal & Anruf (Kacheln) ---------- */
.voice-stage {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  align-content: center;
  background: #0e0f13;
}
.voice-stage[data-count='1'] {
  grid-template-columns: minmax(260px, 900px);
  justify-content: center;
}
.tile {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--bg-1);
  border-radius: 10px;
  overflow: hidden;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 2px transparent;
  transition: box-shadow 0.1s;
}
.tile.speaking {
  box-shadow: 0 0 0 3px var(--ok);
}
.tile video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
.tile-label {
  position: absolute;
  left: 8px;
  bottom: 8px;
  background: #000a;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 13px;
  display: flex;
  gap: 4px;
  align-items: center;
}
.voice-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  background: #0e0f13;
}
.round-ctl {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 0;
  background: var(--bg-3);
  display: grid;
  place-items: center;
}
.round-ctl:hover {
  background: var(--bg-hover);
}
.round-ctl.off {
  background: #fff;
  color: var(--danger);
}
.round-ctl.on {
  background: var(--ok);
  color: #fff;
}
.round-ctl.leave {
  background: var(--danger);
  color: #fff;
}
.call-panel {
  background: #0e0f13;
  border-bottom: 1px solid var(--bg-0);
}
.call-stage {
  position: relative;
  padding: 12px 12px 0;
  display: flex;
  justify-content: center;
}
.call-stage .tile.remote {
  width: min(720px, 100%);
}
.call-stage .tile.self {
  position: absolute;
  right: 20px;
  bottom: 8px;
  width: 180px;
  border: 2px solid var(--bg-3);
}
.call-badge,
.live-badge {
  background: var(--ok);
  color: #fff;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 700;
}
.live-badge {
  background: var(--danger);
  padding: 0 5px;
  font-size: 9px;
}
.voice-bar {
  flex-direction: column;
  align-items: stretch;
}
.voice-bar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.voice-bar-info {
  background: transparent;
  border: 0;
  text-align: left;
  padding: 0;
  min-width: 0;
}
.voice-bar-btns {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.small-btn {
  flex: 1;
  padding: 5px 8px;
  font-size: 12px;
  background: var(--bg-3);
}
.small-btn.on {
  background: var(--ok);
  color: #fff;
}

/* ---------- 0.3: Antworten, Reaktionen, Sprachnachrichten, Bildschirm, QR ---------- */
.reply-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-1);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 6px 8px 6px 12px;
  font-size: 13px;
  color: var(--muted);
}
.reply-bar + .composer {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}
.reply-bar .ellipsis {
  flex: 1;
}
.reply-bar .icon-btn {
  padding: 2px;
}
.reply-quote {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  max-width: 100%;
  margin-bottom: 2px;
}
.reply-quote .author {
  font-weight: 600;
  flex-shrink: 0;
}
.reply-quote:hover {
  color: var(--text);
}
.msg.flash {
  animation: flash 1.5s;
}
@keyframes flash {
  0%,
  40% {
    background: #6c5ce744;
  }
}
.reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.reaction {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  background: var(--bg-1);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 1px 7px;
  font-size: 14px;
}
.reaction span {
  font-size: 12px;
  color: var(--muted);
}
.reaction.mine {
  border-color: var(--accent);
  background: #6c5ce726;
}
.reaction:hover {
  border-color: var(--bg-hover);
}
.react-menu {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  min-width: 0;
  width: 260px;
  gap: 2px;
}
.react-pick {
  border: 0;
  background: transparent;
  font-size: 20px;
  padding: 4px;
  border-radius: 6px;
}
.react-pick:hover {
  background: var(--bg-hover);
}
.rec-btn {
  margin-left: 2px;
}
.composer.recording .rec-btn {
  color: #fff;
  background: var(--danger);
  border-radius: 50%;
}
.rec-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  font-size: 14px;
}
.rec-info .btn {
  margin-left: auto;
  flex: 0;
}
.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  animation: blink 1s infinite;
}
@keyframes blink {
  50% {
    opacity: 0.2;
  }
}
.attachment-audio {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
}
.attachment-audio audio {
  max-width: min(360px, 100%);
  height: 40px;
}
.tile.screen {
  grid-column: 1 / -1;
  aspect-ratio: 16 / 9;
  max-height: 70vh;
  justify-self: center;
  width: 100%;
}
.tile.screen video {
  object-fit: contain;
}
.tile[title] {
  cursor: pointer;
}
.call-stage.has-screen {
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.call-stage .remote-screen {
  width: min(960px, 100%);
}
.call-stage.has-screen .tile.remote {
  width: 240px;
}
.verify-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: 1px solid var(--bg-3);
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 11px;
}
.verify-badge.ok {
  color: var(--ok);
  border-color: #2ecc7155;
}
.verified-mark {
  color: var(--ok);
  display: inline-flex;
}
.safety-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px 10px;
  background: var(--bg-0);
  border-radius: 8px;
  padding: 14px;
  font-size: 17px;
  text-align: center;
  letter-spacing: 1px;
}
.qr-row {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 10px;
  flex-wrap: wrap;
}
.qr {
  width: 168px;
  height: 168px;
  background: #fff;
  border-radius: 8px;
  padding: 4px;
  flex-shrink: 0;
}
.qr svg {
  width: 100%;
  height: 100%;
  display: block;
}
.space-top {
  margin-top: 10px;
}
.scan-video {
  width: 100%;
  border-radius: 8px;
  background: #000;
}
.vol-menu {
  width: 260px;
  min-width: 0;
}
.vol-menu .range-row {
  padding: 4px 6px 8px;
}
.key-btn {
  font-family: ui-monospace, Consolas, monospace;
}

/* ---------- 0.4: Vollbild, Medien laden/fehlen, Speicherort ---------- */
.tile-fs {
  position: absolute;
  top: 8px;
  right: 8px;
  border: 0;
  border-radius: 6px;
  background: #000a;
  color: #fff;
  padding: 5px;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.15s;
}
.tile:hover .tile-fs,
.tile:fullscreen .tile-fs {
  opacity: 1;
}
@media (hover: none) {
  .tile-fs {
    opacity: 1;
  }
}
.tile:fullscreen {
  border-radius: 0;
  aspect-ratio: auto;
  width: 100vw;
  height: 100vh;
  max-height: none;
  background: #000;
  box-shadow: none;
}
.tile:fullscreen video {
  object-fit: contain;
}
.main:fullscreen,
.call-panel:fullscreen {
  background: #0e0f13;
  display: flex;
  flex-direction: column;
}
.main:fullscreen .voice-stage {
  flex: 1;
}
.call-panel:fullscreen .call-stage {
  flex: 1;
  align-items: center;
}
.call-panel:fullscreen .call-stage .tile.remote,
.call-panel:fullscreen .call-stage .remote-screen {
  width: min(100%, calc((100vh - 120px) * 16 / 9));
}
.attachment-loading,
.attachment-missing {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-1);
  border: 1px solid var(--bg-0);
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 4px;
  max-width: min(400px, 100%);
  color: var(--muted);
}
.attachment-missing {
  border-color: #e5484d55;
  color: var(--text);
}
.attachment-missing .icon {
  color: var(--danger);
}
.attachment-missing .small {
  color: var(--danger);
}
.attachment-missing > div {
  min-width: 0;
}
.storage-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-1);
  border-radius: 8px;
  padding: 12px;
}
.storage-row .path {
  display: block;
  margin: 4px 0;
  font-size: 12px;
}
.warn-box {
  background: #f5a6231a;
  border-left: 3px solid var(--warn);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
}

/* ---------- Mobil ---------- */
.mobile-only {
  display: none;
}
@media (max-width: 900px) {
  .layout,
  .layout.no-members {
    grid-template-columns: 1fr;
  }
  .rail,
  .sidebar,
  .members {
    display: none;
  }
  .layout.show-sidebar {
    grid-template-columns: 72px 1fr;
  }
  .layout.show-sidebar .rail,
  .layout.show-sidebar .sidebar {
    display: flex;
  }
  .layout.show-sidebar .main {
    display: none;
  }
  .mobile-only {
    display: inline-grid;
  }
  .tabs {
    margin-left: 0;
  }
  .add-friend {
    flex-direction: column;
  }
  .settings-window {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .settings-nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 12px;
  }
  .settings-nav .cat {
    display: none;
  }
  .settings-body {
    padding: 20px 16px 60px;
  }
  .call-stage .tile.self {
    width: 110px;
  }
  /* iOS zoomt bei Eingabefeldern unter 16px */
  input,
  textarea,
  select {
    font-size: 16px;
  }
  .composer-wrap {
    margin: 0 8px 8px;
  }
  .tile.screen {
    grid-column: auto;
  }
  .msg {
    padding: 2px 10px;
    gap: 0 10px;
  }
  .main-header {
    padding: 0 8px;
  }
  .main-header .tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
  }
  .voice-controls {
    gap: 8px;
  }
  .round-ctl {
    width: 48px;
    height: 48px;
  }
  .settings-overlay {
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  }
  .call-popup {
    left: 16px;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
  }
}

/* Touch-Geräte: kein Hover -> Bedienelemente sichtbar bzw. per Tippen */
@media (hover: none) {
  .hover-only {
    visibility: visible;
  }
  .msg:hover {
    background: none;
  }
  .msg.sel {
    background: #0000002a;
  }
  .msg:hover .msg-actions {
    display: none;
  }
  .msg.sel .msg-actions {
    display: flex;
  }
  .msg-time-side {
    visibility: hidden !important;
  }
  .icon-btn {
    padding: 8px;
  }
}

.settings-version {
  margin-top: auto;
  padding: 16px 10px 0;
}

/* ---------- 0.0.7: Sprachkanal wie bei Discord (groß anzeigen, Leiste, Vollbild) ---------- */
.voice-stage.focus {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  justify-content: center;
  gap: 8px;
}
.voice-stage.focus .tile {
  flex: 0 0 176px;
  height: 99px;
  aspect-ratio: auto;
  max-height: none;
}
.voice-stage.focus .tile.focused {
  order: -1;
  flex: 1 1 100%;
  height: calc(100% - 115px);
  min-height: 200px;
}
.voice-stage.focus .tile .tile-avatar .avatar {
  transform: scale(0.6);
}
.voice-stage.focus .tile.focused .tile-avatar .avatar {
  transform: none;
}
.voice-stage .tile.focused video,
.voice-stage.focus .tile.screen video {
  object-fit: contain;
}
.voice-stage .tile.screen:not(.focused) {
  grid-column: auto;
}
.tile-label .live {
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  padding: 0 5px;
  margin-right: 2px;
}
.tile-avatar img.avatar {
  object-fit: cover;
}
/* Vollbild: Bild maximal, Kopfzeile weg, Knöpfe erscheinen beim Bewegen der Maus */
.main:fullscreen .main-header {
  display: none;
}
.main:fullscreen .voice-stage {
  padding: 8px;
  background: #000;
}
.main:fullscreen .voice-stage.focus .tile.focused {
  height: calc(100% - 107px);
  border-radius: 6px;
}
.main:fullscreen .voice-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(transparent, #000c);
  transition: opacity 0.3s;
}
.main:fullscreen.idle .voice-controls {
  opacity: 0;
}
.main:fullscreen.idle {
  cursor: none;
}
.main:fullscreen {
  position: relative;
}

/* ---------- 0.0.7: Status, Profilbild, Profil-Karte, Rollen, Töne, Spiele ---------- */
img.avatar {
  object-fit: cover;
  display: block;
  background: var(--bg-3);
}
.dot.idle,
.pavatar .dot.idle {
  background: var(--warn);
}
.dot.dnd,
.pavatar .dot.dnd {
  background: var(--danger);
}
.menu .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #747f8d;
  flex-shrink: 0;
}
.menu .dot.on {
  background: var(--ok);
}
.menu .dot.on.idle {
  background: var(--warn);
}
.menu .dot.on.dnd {
  background: var(--danger);
}
.clickable {
  cursor: pointer;
}
.author.clickable:hover {
  text-decoration: underline;
}
.activity {
  color: var(--ok);
  display: flex;
  align-items: center;
  gap: 4px;
}
.member {
  cursor: pointer;
}
.member .who .role-badge {
  margin-left: 6px;
}
.me-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  border-radius: 6px;
  padding: 2px 4px;
  text-align: left;
  color: inherit;
}
.me-btn:hover {
  background: var(--bg-hover);
}
.me-menu {
  min-width: 260px;
}
.me-head {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 8px 10px;
  border-bottom: 1px solid var(--bg-3);
  margin-bottom: 4px;
}
.status-item {
  display: flex;
  gap: 10px;
  align-items: center;
}
.status-item.active {
  background: var(--bg-3);
}
.menu-sep {
  height: 1px;
  background: var(--bg-3);
  margin: 4px 6px;
}
.profile-card {
  width: 300px;
  padding: 0;
  overflow: hidden;
}
.pc-banner {
  height: 60px;
}
.pc-avatar {
  margin: -40px 0 0 16px;
}
.pc-avatar .pavatar .dot {
  width: 18px;
  height: 18px;
  border: 4px solid #111216;
  right: 0;
  bottom: 0;
}
.pc-avatar .avatar {
  border: 5px solid #111216;
  box-sizing: content-box;
}
.pc-body {
  padding: 8px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pc-body h3 {
  margin: 0;
  font-size: 18px;
}
.pc-section {
  border-top: 1px solid var(--bg-3);
  margin-top: 6px;
  padding-top: 6px;
  min-width: 0;
}
.pc-section .cat {
  padding: 0 0 4px;
}
.pc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.role-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.role-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  background: var(--bg-2);
  border-radius: 4px;
  padding: 2px 8px;
}
.role-chip .role-dot {
  width: 10px;
  height: 10px;
}
.roles-modal {
  width: min(520px, 100%);
}
.role-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 50vh;
  overflow-y: auto;
  margin: 8px 0;
}
.role-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--bg-2);
}
.role-row .who {
  flex: 1;
  min-width: 0;
}
.role-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}
.modal input[type='color'] {
  padding: 2px;
  height: 36px;
}
.avatar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.sound-events {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0;
}
.sound-event {
  display: grid;
  grid-template-columns: 1fr minmax(160px, 220px) auto;
  gap: 8px;
  align-items: center;
}
.game-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 8px 0;
}
.game-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-2);
  border-radius: 6px;
}
.row-actions {
  display: flex;
  gap: 8px;
  margin: 8px 0;
}
@media (max-width: 600px) {
  .sound-event {
    grid-template-columns: 1fr auto;
  }
  .sound-event span {
    grid-column: 1 / -1;
  }
}

/* Verbindungsinfo und „Warte auf Bild“ auf Kacheln */
.tile-info {
  position: absolute;
  top: 8px;
  right: 40px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: #000a;
  color: #fff;
  font: 700 13px/1 Georgia, serif;
  opacity: 0;
  transition: opacity 0.15s;
}
.tile:hover .tile-info,
.voice-stage.show-stats .tile-info {
  opacity: 1;
}
.tile-stats {
  display: none;
  position: absolute;
  top: 8px;
  left: 8px;
  right: 76px;
  background: #000b;
  color: #fff;
  font: 11px/1.4 ui-monospace, Consolas, monospace;
  padding: 3px 6px;
  border-radius: 4px;
}
.voice-stage.show-stats .tile-stats {
  display: block;
}
.tile-wait {
  display: none;
  position: absolute;
  inset: 0;
  place-items: center;
  color: var(--muted);
  background: #000c;
}
.tile.waiting .tile-wait {
  display: grid;
}
