:root {
  --bg-0: #18181d;
  --bg-1: #1f1f25;
  --bg-2: #26262e;
  --bg-3: #2e2e38;
  --bg-hover: #34343f;
  --bg-active: #3c3c49;
  --text: #e6e6ec;
  --text-2: #b4b4c0;
  --muted: #8a8a98;
  --accent: #7c5cff;
  --accent-2: #6847f0;
  --green: #3ba55d;
  --red: #ed4245;
  --yellow: #f0b232;
  --radius: 8px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
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, input, select, textarea { font: inherit; color: inherit; }
a { color: #8fb4ff; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error-text { color: var(--red); font-size: 13.5px; min-height: 1em; }
.spacer { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; }
.row > input:not([type]), .row > input[type=range] { flex: 1; }
.mobile-only, .icon-btn.mobile-only { display: none; }
code { background: var(--bg-0); padding: 1px 5px; border-radius: 4px; font-size: 13.5px; font-family: Consolas, "Cascadia Mono", monospace; }
svg { width: 20px; height: 20px; fill: currentColor; display: block; }

/* ---------- Buttons & Inputs ---------- */
.btn { border: 0; border-radius: 6px; padding: 8px 16px; background: var(--bg-active); cursor: pointer; transition: background .15s, filter .15s; }
.btn:hover { filter: brightness(1.15); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.danger { background: var(--red); color: #fff; }
.btn.danger-outline { background: transparent; color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.big { padding: 11px; font-size: 15.5px; font-weight: 600; width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }
.icon-btn { border: 0; background: transparent; color: var(--text-2); width: 32px; height: 32px; border-radius: 6px; display: grid; place-items: center; cursor: pointer; flex-shrink: 0; font-size: 17px; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.off { color: var(--red); }
.icon-btn.danger { color: var(--text); background: var(--red); }
label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--text-2); }
label.check { flex-direction: row; align-items: center; text-transform: none; font-size: 14.5px; font-weight: 500; letter-spacing: 0; color: var(--text); }
input:not([type=checkbox]):not([type=range]):not([type=color]), select, textarea.edit-box {
  background: var(--bg-0); border: 1px solid transparent; border-radius: 6px; padding: 9px 11px; outline: none; font-size: 15px; text-transform: none; font-weight: 400; letter-spacing: 0; color: var(--text);
}
input:focus, select:focus, textarea.edit-box:focus { border-color: var(--accent); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
input[type=range] { accent-color: var(--accent); }
input[type=color] { width: 48px; height: 38px; border: 0; background: none; padding: 0; cursor: pointer; }

/* ---------- Auth ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 20% 20%, #3b2b80 0, transparent 45%), radial-gradient(circle at 80% 80%, #1f4f6f 0, transparent 40%), var(--bg-0); }
.auth-card { width: 100%; max-width: 420px; background: var(--bg-2); padding: 32px; border-radius: 12px; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 20px 60px #0008; }
.auth-card h1 { margin: 0; text-align: center; font-size: 24px; }
.auth-card > p { margin: -8px 0 4px; text-align: center; }
.auth-logo { width: 64px; height: 64px; margin: 0 auto; border-radius: 20px; background: var(--accent); display: grid; place-items: center; font-size: 36px; font-weight: 800; color: #fff; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 72px 248px 1fr auto; height: 100vh; height: 100dvh; overflow: hidden; }
.server-bar { background: var(--bg-0); padding: 12px 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.server-icon { width: 48px; height: 48px; border-radius: 16px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 20px; position: relative; }
.server-icon.active::before { content: ""; position: absolute; left: -12px; width: 4px; height: 40px; border-radius: 0 4px 4px 0; background: #fff; }

.sidebar { background: var(--bg-1); display: flex; flex-direction: column; min-width: 0; }
.server-header { height: 48px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; font-weight: 700; box-shadow: 0 1px 0 #0005; cursor: pointer; flex-shrink: 0; }
.server-header:hover { background: var(--bg-hover); }
.server-header span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-list { flex: 1; overflow-y: auto; padding: 8px; }
.cat { display: flex; justify-content: space-between; align-items: center; padding: 16px 8px 4px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.cat-add { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1; padding: 0 2px; }
.cat-add:hover { color: var(--text); }
.channel { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 6px; color: var(--muted); cursor: pointer; margin: 1px 0; }
.channel:hover { background: var(--bg-hover); color: var(--text-2); }
.channel.active { background: var(--bg-active); color: var(--text); }
.channel.unread { color: var(--text); font-weight: 600; }
.channel.unread::before { content: ""; width: 8px; height: 8px; background: var(--text); border-radius: 50%; margin-left: -12px; margin-right: -2px; }
.ch-icon { width: 20px; display: grid; place-items: center; font-size: 20px; color: var(--muted); }
.ch-icon svg { width: 18px; height: 18px; }
.ch-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-edit { background: none; border: 0; color: var(--muted); cursor: pointer; opacity: 0; padding: 0; }
.ch-edit svg { width: 16px; height: 16px; }
.channel:hover .ch-edit { opacity: 1; }
.ch-edit:hover { color: var(--text); }
.voice-users { padding: 0 0 4px 30px; }
.voice-user { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; color: var(--text-2); font-size: 14px; cursor: pointer; }
.voice-user:hover { background: var(--bg-hover); }
.voice-user .avatar { transition: box-shadow .1s; }
.voice-user.speaking .avatar { box-shadow: 0 0 0 2px var(--bg-1), 0 0 0 4px var(--green); }
.vu-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vu-icon { color: var(--red); }
.vu-icon svg { width: 15px; height: 15px; }

.voice-panel { display: flex; flex-direction: column; padding: 8px 10px; border-top: 1px solid #0004; background: var(--bg-1); gap: 8px; }
.voice-panel-row { display: flex; align-items: center; gap: 8px; }
.btn.wide { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; }
.btn.active { background: var(--green); color: #fff; }
.btn-ic svg { width: 16px; height: 16px; }
.ptt-badge { font-size: 11px; font-weight: 700; padding: 4px 6px; border-radius: 5px; background: var(--bg-active); color: var(--muted); white-space: nowrap; }
.ptt-badge.on { background: var(--green); color: #fff; }
.ch-lock svg { width: 13px; height: 13px; color: var(--muted); }
.badge { background: var(--red); color: #fff; font-size: 11px; font-weight: 700; border-radius: 9px; padding: 1px 6px; min-width: 18px; text-align: center; }
.live { background: var(--red); color: #fff; font-size: 10px; font-weight: 800; border-radius: 4px; padding: 1px 5px; letter-spacing: .04em; cursor: pointer; }
.sub-setting { padding: 4px 0 4px 26px; display: flex; flex-direction: column; gap: 8px; }
.sub-setting.row { flex-direction: row; align-items: center; flex-wrap: wrap; }
.voice-panel-info { flex: 1; min-width: 0; }
.voice-panel-info > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-status { color: var(--green); font-weight: 700; font-size: 14px; cursor: pointer; }
.voice-status:hover { text-decoration: underline; }
.diag { width: 100%; border-collapse: collapse; font-size: 14px; }
.diag th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; padding: 4px 6px; }
.diag td { padding: 6px; border-top: 1px solid var(--bg-active); }
.st-connected { color: var(--green); }
.st-failed, .st-disconnected { color: var(--red); }
.st-connecting, .st-new { color: var(--yellow); }
.voice-status.warn { color: var(--yellow); }
.voice-status.bad { color: var(--red); }
.user-panel { display: flex; align-items: center; gap: 6px; padding: 8px; background: #1b1b21; flex-shrink: 0; }
.user-panel-name { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; }
.user-panel-name > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Avatare ---------- */
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; flex-shrink: 0; user-select: none; }
.avatar.sm { width: 32px; height: 32px; font-size: 14px; }
.avatar.xs { width: 22px; height: 22px; font-size: 11px; }
.avatar.lg { width: 72px; height: 72px; font-size: 30px; border: 5px solid var(--bg-0); }
.avatar-wrap { position: relative; }
.status { position: absolute; right: -2px; bottom: -2px; width: 13px; height: 13px; border-radius: 50%; background: var(--muted); border: 3px solid var(--bg-1); }
.status.on { background: var(--green); }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; background: var(--bg-2); min-width: 0; }
.chat-header { height: 48px; display: flex; align-items: center; gap: 6px; padding: 0 12px 0 16px; box-shadow: 0 1px 0 #0005; font-weight: 700; flex-shrink: 0; }
.chat-header .hash { color: var(--muted); font-size: 22px; font-weight: 400; }
.messages { flex: 1; overflow-y: auto; padding: 16px 0 8px; overflow-wrap: anywhere; }
.loading { padding: 32px; color: var(--muted); text-align: center; }
.channel-intro { padding: 16px 16px 8px; }
.channel-intro h2 { margin: 8px 0 4px; font-size: 28px; }
.channel-intro p { margin: 0; }
.intro-icon { width: 68px; height: 68px; border-radius: 50%; background: var(--bg-active); display: grid; place-items: center; font-size: 40px; }
.day-sep { display: flex; align-items: center; margin: 16px 16px 8px; color: var(--muted); font-size: 12px; font-weight: 600; }
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: var(--bg-active); }
.day-sep span { padding: 0 8px; }

.msg { display: flex; gap: 16px; padding: 2px 48px 2px 16px; margin-top: 16px; position: relative; }
.msg.grouped { margin-top: 0; padding-left: 72px; }
.msg:hover { background: #00000014; }
.msg-avatar { cursor: pointer; padding-top: 2px; }
.msg-main { flex: 1; min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-author { font-weight: 600; cursor: pointer; }
.msg-author:hover { text-decoration: underline; }
.msg-time { color: var(--muted); font-size: 12px; }
.msg-time-hover { position: absolute; left: 0; width: 64px; text-align: center; font-size: 11px; color: var(--muted); opacity: 0; top: 5px; }
.msg.grouped:hover .msg-time-hover { opacity: 1; }
.msg-body { min-width: 0; flex: 1; }
.msg-content { white-space: normal; color: var(--text); }
.msg-content pre { background: var(--bg-0); padding: 10px; border-radius: 6px; overflow-x: auto; margin: 4px 0; white-space: pre; }
.msg-content pre code { background: none; padding: 0; }
.msg-content .quote { display: inline-block; border-left: 4px solid var(--bg-active); padding-left: 10px; }
.mention { background: #7c5cff33; color: #c9bcff; border-radius: 4px; padding: 0 3px; font-weight: 500; }
.mention.me { background: #f0b23233; color: #ffd27a; }
.msg.mentioned { background: #f0b2320f; box-shadow: inset 3px 0 0 var(--yellow); }
.msg.mentioned:hover { background: #f0b2321a; }
.mention-box { background: var(--bg-1); border-radius: 8px; margin-bottom: 6px; padding: 6px; box-shadow: 0 4px 16px #0006; }
.mb-title { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); padding: 2px 6px 6px; }
.mb-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 5px; cursor: pointer; }
.mb-item.active, .mb-item:hover { background: var(--bg-active); }
.mb-at { width: 22px; text-align: center; color: var(--muted); font-weight: 700; }

.stage { flex: 0 0 auto; height: 46%; min-height: 200px; background: #000; display: grid; gap: 4px; padding: 4px; }
.stage.multi { grid-template-columns: 1fr 1fr; }
.stage-tile { position: relative; background: #0b0b0e; border-radius: 6px; overflow: hidden; display: grid; place-items: center; min-height: 0; }
.stage-tile video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.stage-wait { color: var(--muted); }
.stage-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: linear-gradient(transparent, #000c); opacity: 0; transition: opacity .2s; }
.stage-tile:hover .stage-bar { opacity: 1; }
.stage-name { font-weight: 600; font-size: 14px; }
.spoiler {background: #111; color: transparent; border-radius: 3px; cursor: pointer; }
.spoiler.shown { background: #ffffff1a; color: inherit; }
.edited { color: var(--muted); font-size: 11px; }
.msg-actions { position: absolute; right: 16px; top: -14px; display: none; background: var(--bg-1); border-radius: 6px; box-shadow: 0 2px 8px #0006; overflow: hidden; }
.msg:hover .msg-actions:not(:empty) { display: flex; }
.msg-actions button { border: 0; background: none; padding: 5px 9px; cursor: pointer; color: var(--text-2); }
.msg-actions button:hover { background: var(--bg-hover); color: var(--text); }
.msg-actions button.danger:hover { color: var(--red); }
.edit-box { width: 100%; resize: none; margin: 4px 0; }

.attachment { margin-top: 6px; display: inline-flex; max-width: 100%; }
.attachment.image img, .attachment.image video { max-width: min(420px, 100%); max-height: 340px; border-radius: 8px; cursor: zoom-in; display: block; }
.attachment.file { gap: 10px; align-items: center; background: var(--bg-1); border: 1px solid #0004; padding: 10px 14px; border-radius: 8px; text-decoration: none; color: var(--text); flex-direction: row; flex-wrap: wrap; }
.file-icon { font-size: 28px; }
.file-name { color: #8fb4ff; }
.lightbox { position: fixed; inset: 0; background: #000c; display: grid; place-items: center; z-index: 100; cursor: zoom-out; }
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 6px; }

.composer-wrap { padding: 0 16px; flex-shrink: 0; }
.composer { display: flex; align-items: flex-end; gap: 4px; background: var(--bg-3); border-radius: 10px; padding: 6px 8px; }
.composer textarea { flex: 1; min-width: 0;resize: none; border: 0; outline: 0; background: transparent; padding: 6px 4px; max-height: 220px; font-size: 15px; }
.composer .icon-btn { font-size: 20px; }
.typing { height: 22px; font-size: 12.5px; color: var(--text-2); padding: 2px 4px; }

/* ---------- Mitgliederliste ---------- */
.members { width: 240px; background: var(--bg-1); overflow-y: auto; padding: 8px; }
.members.hidden-pane { display: none; }
.member { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.member:hover { background: var(--bg-hover); }
.member.offline { opacity: .45; }
.member-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.crown { font-size: 13px; }

/* ---------- Popover / Member-Card ---------- */
.popover { position: fixed; width: 300px; z-index: 60; background: var(--bg-0); border-radius: 10px; box-shadow: 0 8px 30px #000a; overflow: hidden; }
.member-card { background: var(--bg-0); border-radius: 10px; overflow: hidden; }
.mc-banner { height: 56px; opacity: .8; }
.mc-head { display: flex; align-items: flex-end; gap: 12px; padding: 0 14px; margin-top: -36px; }
.mc-name { font-weight: 700; font-size: 18px; }
.mc-section { padding: 10px 14px; border-top: 1px solid var(--bg-2); }
.mc-section:first-of-type { margin-top: 10px; }
.mc-section .label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; color: var(--text-2); margin-bottom: 6px; }
.mc-roles { display: flex; flex-wrap: wrap; gap: 6px; }
.role-chip { flex-direction: row; align-items: center; gap: 6px; background: var(--bg-2); border-radius: 5px; padding: 3px 8px; font-size: 13px; text-transform: none; font-weight: 500; letter-spacing: 0; color: var(--text); opacity: .55; }
.role-chip.on { opacity: 1; }
.role-chip.clickable { cursor: pointer; }
.role-chip input { width: 14px; height: 14px; }
.role-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.mc-actions { display: flex; gap: 8px; }

/* ---------- Modals ---------- */
.modal-bg { position: fixed; inset: 0; background: #000b; display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s; }
.modal { background: var(--bg-2); border-radius: 12px; width: 100%; max-width: 460px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px #000a; animation: pop .15s; }
.modal.wide { max-width: 880px; height: min(680px, 90vh); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 0 20px; }
.modal-head h2 { margin: 0; font-size: 20px; }
.modal-body { padding: 16px 20px 20px; overflow-y: auto; flex: 1; min-height: 0; }
.modal-body form, .settings { display: flex; flex-direction: column; gap: 14px; }
.settings h3 { margin: 8px 0 -4px; font-size: 13px; text-transform: uppercase; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.hint { background: var(--bg-1); padding: 10px 12px; border-radius: 6px; font-size: 14px; }
.row-form { display: grid !important; grid-template-columns: 1fr 1fr auto; align-items: end; }
.meter { height: 8px; background: var(--bg-0); border-radius: 4px; overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--yellow); transition: width .08s; }
.meter-fill.loud { background: var(--green); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }

.server-settings { display: flex; flex-direction: column; height: 100%; gap: 14px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--bg-active); }
.tab { background: none; border: 0; padding: 8px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--text); border-color: var(--accent); }
.tab-content { flex: 1; min-height: 0; }
.roles-layout { display: grid; grid-template-columns: 200px 1fr; gap: 16px; height: 100%; }
.role-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.role-list .btn { margin-bottom: 8px; }
.role-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 6px; cursor: pointer; color: var(--text-2); }
.role-item:hover { background: var(--bg-hover); }
.role-item.active { background: var(--bg-active); color: var(--text); }
.role-editor { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; padding-right: 4px; }
.perm-list { display: flex; flex-direction: column; }
.perm { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--bg-active); text-transform: none; font-size: 15px; font-weight: 500; letter-spacing: 0; color: var(--text); cursor: pointer; }
.perm input { order: 2; }
.perm.disabled { opacity: .45; cursor: not-allowed; }
.member-admin { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.ma-row .member-card { height: 100%; }
.ban-row { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 6px; }
.ban-row:hover { background: var(--bg-hover); }

/* ---------- Toasts / Drop ---------- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; align-items: center; pointer-events: none; }
.toast { background: var(--bg-0); padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 20px #0008; border-left: 4px solid var(--accent); transition: opacity .4s, transform .4s; max-width: 90vw; }
.toast.error { border-color: var(--red); }
.toast.warn { border-color: var(--yellow); }
.toast.ok { border-color: var(--green); }
.toast.out { opacity: 0; transform: translateY(8px); }
.drop-overlay { position: fixed; inset: 0; background: #7c5cffcc; color: #fff; display: grid; place-items: center; font-size: 26px; font-weight: 700; z-index: 150; pointer-events: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #0007; border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .members { position: fixed; right: 0; top: 48px; bottom: 0; z-index: 30; box-shadow: -8px 0 20px #0006; }
}
@media (max-width: 700px) {
  .app { grid-template-columns: 1fr; }
  .server-bar { display: none; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: 8px 0 20px #0006; }
  .sidebar.open { transform: none; }
  .mobile-only, .icon-btn.mobile-only { display: grid; }
  .msg { padding-right: 16px; }
  .roles-layout { grid-template-columns: 1fr; }
  .row-form { grid-template-columns: 1fr !important; }
}
