@import url('https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --bg-tertiary: #1e1f22;
  --bg-secondary: #2b2d31;
  --bg-secondary-alt: #232428;
  --bg-primary: #313338;
  --bg-modifier-hover: #35373c;
  --bg-modifier-active: #404249;
  --bg-message-hover: #2e3035;
  --bg-input: #383a40;
  --bg-floating: #111214;
  --text-normal: #dbdee1;
  --text-muted: #949ba4;
  --header-primary: #f2f3f5;
  --header-secondary: #b5bac1;
  --interactive-normal: #b5bac1;
  --interactive-hover: #dbdee1;
  --brand: #5865f2;
  --brand-hover: #4752c4;
  --green: #23a55a;
  --red: #f23f43;
  --link: #00a8fc;
  --shadow-low: 0 1px 0 rgba(4,4,5,.2), 0 1.5px 0 rgba(6,6,7,.05), 0 2px 0 rgba(4,4,5,.05);
  --shadow-high: 0 8px 16px rgba(0,0,0,.24);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "gg sans", "Noto Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-normal);
  font-size: 16px;
  line-height: 1.375;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--header-secondary); }
button { font: inherit; cursor: pointer; color: inherit; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: rgba(88,101,242,.4); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--bg-tertiary) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar { width: 16px; }
.messages::-webkit-scrollbar-thumb { background: #1a1b1e; border: 4px solid var(--bg-primary); border-radius: 8px; }
.messages::-webkit-scrollbar-track { background: var(--bg-secondary); border: 4px solid var(--bg-primary); border-radius: 8px; }
.servers { scrollbar-width: none; }
.servers::-webkit-scrollbar { display: none; }

/* ---------- Auth ---------- */
.auth {
  height: 100%; display: grid; place-items: center;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(88,101,242,.55), transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(235,69,158,.35), transparent 55%),
    #1e1f22;
}
.auth-box {
  background: var(--bg-primary); padding: 32px; border-radius: 5px;
  width: min(480px, 92vw); display: flex; flex-direction: column; gap: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,.2);
}
.auth-box h1 { color: var(--header-primary); text-align: center; font-size: 24px; font-weight: 600; line-height: 30px; }
.auth-box p { text-align: center; font-size: 16px; margin-top: -12px; }
.auth-box label {
  display: flex; flex-direction: column; gap: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: var(--header-secondary);
}
.auth-box input {
  background: var(--bg-tertiary); border: none; border-radius: 3px; height: 40px; padding: 10px;
  color: var(--text-normal); font-size: 16px; font-family: inherit; outline: none;
}
.auth-box input:focus { box-shadow: 0 0 0 2px var(--link); }
.auth-box button {
  background: var(--brand); color: #fff; border: none; border-radius: 3px; height: 44px;
  font-size: 16px; font-weight: 500; transition: background .17s;
}
.auth-box button:hover { background: var(--brand-hover); }
.switch { text-align: left !important; margin-top: -12px !important; }
.switch a { font-size: 14px; }
.error { color: #fa777c; font-size: 14px; min-height: 0; }
.error:empty { display: none; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 72px 240px 1fr 240px; height: 100%; }

/* ---------- Serverleiste ---------- */
.servers {
  background: var(--bg-tertiary); display: flex; flex-direction: column; align-items: center;
  gap: 8px; padding: 12px 0; overflow-y: auto;
}
.server-icon {
  position: relative; width: 48px; height: 48px; border-radius: 50%;
  background: var(--bg-primary); color: var(--text-normal);
  display: grid; place-items: center; font-weight: 500; font-size: 16px;
  cursor: pointer; user-select: none; flex-shrink: 0;
  transition: border-radius .15s ease-out, background-color .15s ease-out, color .15s ease-out;
}
.server-icon:hover, .server-icon.active { border-radius: 16px; background: var(--brand); color: #fff; }
.server-icon::before {
  content: ""; position: absolute; left: -16px; top: 50%;
  width: 8px; height: 0; background: #fff; border-radius: 0 4px 4px 0;
  transform: translateY(-50%); transition: height .15s ease-out;
}
.server-icon.unread::before { height: 8px; }
.server-icon:hover::before { height: 20px; }
.server-icon.active::before { height: 40px; }
.server-icon.add { color: var(--green); font-size: 24px; font-weight: 400; }
.server-icon.add:hover { background: var(--green); color: #fff; }
.server-icon.add::before { display: none; }
.sep { width: 32px; height: 2px; background: var(--bg-modifier-hover); border-radius: 1px; flex-shrink: 0; }

/* ---------- Kanalliste ---------- */
.sidebar { background: var(--bg-secondary); display: flex; flex-direction: column; min-width: 0; }
.sidebar-head {
  height: 48px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between;
  font-size: 16px; font-weight: 600; color: var(--header-primary);
  box-shadow: var(--shadow-low); position: relative; z-index: 2; flex-shrink: 0;
}
.sidebar-head span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channels { flex: 1; overflow-y: auto; padding: 8px 8px 8px 8px; }
.group {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 8px 4px 2px; height: 40px;
  font-size: 12px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase;
  color: var(--text-muted);
}
.group:first-child { padding-top: 10px; height: 32px; }
.group:hover { color: var(--interactive-hover); }
.channel {
  display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 8px;
  border-radius: 4px; color: var(--text-muted); cursor: pointer; margin: 2px 0;
  font-size: 16px; font-weight: 500; position: relative;
}
.channel span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel:hover { background: var(--bg-modifier-hover); color: var(--interactive-hover); }
.channel.active { background: var(--bg-modifier-active); color: #fff; }
.channel.unread { color: #fff; font-weight: 600; }
.channel.unread::before {
  content: ""; position: absolute; left: -8px; width: 4px; height: 8px;
  background: #fff; border-radius: 0 4px 4px 0;
}
.channel.voice { cursor: not-allowed; opacity: .55; }
.channel .hash { font-size: 22px; width: 22px; text-align: center; color: #80848e; font-weight: 400; flex-shrink: 0; }
.channel.voice .hash { font-size: 16px; }
.icon-btn {
  background: none; border: none; color: var(--interactive-normal);
  font-size: 16px; padding: 4px 6px; border-radius: 4px; line-height: 1;
  display: inline-grid; place-items: center;
}
.icon-btn:hover { color: var(--interactive-hover); background: var(--bg-modifier-hover); }
.group .icon-btn { font-size: 18px; padding: 0 2px; color: var(--text-muted); }
.group .icon-btn:hover { background: none; color: var(--interactive-hover); }

.userbar {
  height: 52px; background: var(--bg-secondary-alt); display: flex; align-items: center;
  gap: 8px; padding: 0 8px; flex-shrink: 0;
}
.who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; padding: 4px; border-radius: 4px; }
.who b { font-size: 14px; font-weight: 600; color: var(--header-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who small { color: var(--header-secondary); font-size: 12px; }
#logout { width: 32px; height: 32px; font-size: 18px; }

/* ---------- Avatare ---------- */
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-weight: 600; font-size: 16px; flex-shrink: 0; position: relative; user-select: none;
}
.userbar .avatar, .members .avatar { width: 32px; height: 32px; font-size: 13px; }
.mini-avatar {
  width: 16px; height: 16px; border-radius: 50%; display: inline-grid; place-items: center;
  color: #fff; font-size: 8px; font-weight: 700; flex-shrink: 0;
}
.status {
  position: absolute; right: -3px; bottom: -3px; width: 16px; height: 16px; border-radius: 50%;
  border: 3px solid var(--bg-secondary); background: #80848e;
}
.status::after { content: ""; position: absolute; inset: 2px; border-radius: 50%; background: var(--bg-secondary); }
.status.on { background: var(--green); }
.status.on::after { display: none; }
.member:hover .status { border-color: var(--bg-modifier-hover); }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; min-width: 0; background: var(--bg-primary); position: relative; }
.chat.dragging::after {
  content: "Dateien hochladen"; position: absolute; inset: 16px; border-radius: 12px;
  display: grid; place-items: center; background: rgba(88,101,242,.9); color: #fff;
  font-size: 22px; font-weight: 700; z-index: 20; pointer-events: none;
  outline: 2px dashed rgba(255,255,255,.6); outline-offset: -16px;
}
.chat-head {
  height: 48px; padding: 0 16px; display: flex; align-items: center; gap: 8px;
  font-size: 16px; font-weight: 600; color: var(--header-primary);
  box-shadow: var(--shadow-low); position: relative; z-index: 2; flex-shrink: 0;
}
.chat-head .hash { font-size: 24px; color: #80848e; font-weight: 400; }
.messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 16px 0 20px; }
.empty { padding: 16px; margin: 0 0 16px; color: var(--header-secondary); }
.empty h2 { color: var(--header-primary); font-size: 32px; font-weight: 700; line-height: 40px; margin-bottom: 8px; }
.empty p { font-size: 16px; }

/* ---------- Nachrichten ---------- */
.msg {
  display: flex; flex-wrap: wrap; column-gap: 16px;
  padding: 2px 48px 2px 16px; position: relative; margin-top: 17px; min-height: 44px;
}
.msg.grouped { margin-top: 0; min-height: 0; padding-top: 2px; padding-bottom: 2px; }
.msg:hover { background: var(--bg-message-hover); }
.msg.replying { background: rgba(88,101,242,.08); }
.msg.replying::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--brand); }
.msg.flash { animation: flash 2s ease; }
@keyframes flash { 0%, 50% { background: rgba(250,168,26,.1); } 100% { background: transparent; } }
.msg > .avatar { margin-top: 2px; cursor: pointer; }
.msg .spacer {
  width: 40px; flex-shrink: 0; font-size: 11px; line-height: 22px; color: var(--text-muted);
  text-align: right; visibility: hidden; user-select: none;
}
.msg.grouped:hover .spacer { visibility: visible; }
.msg-body { min-width: 0; flex: 1; }
.msg-head { display: flex; align-items: baseline; gap: 8px; line-height: 22px; }
.msg-head b { color: var(--header-primary); font-weight: 500; font-size: 16px; cursor: pointer; }
.msg-head b:hover { text-decoration: underline; }
.msg-head time { color: var(--text-muted); font-size: 12px; font-weight: 500; }
.msg-text { white-space: pre-wrap; word-wrap: break-word; line-height: 22px; font-size: 16px; color: var(--text-normal); }
.edited { color: var(--text-muted); font-size: 10px; margin-left: 2px; user-select: none; }

.reply-preview {
  flex-basis: 100%; display: flex; align-items: center; gap: 4px;
  padding-left: 56px; margin-bottom: 2px; height: 18px;
  font-size: 14px; color: var(--header-secondary); cursor: pointer; position: relative;
  overflow: hidden; white-space: nowrap; line-height: 18px;
}
.reply-preview::before {
  content: ""; position: absolute; left: 36px; top: 8px; width: 33px; height: 12px;
  border-left: 2px solid #4e5058; border-top: 2px solid #4e5058; border-top-left-radius: 6px;
  margin-right: 4px;
}
.reply-preview .mini-avatar { margin-left: 18px; }
.reply-preview b { color: var(--header-primary); font-weight: 500; flex-shrink: 0; opacity: .85; margin-right: 2px; }
.reply-preview span:last-child { overflow: hidden; text-overflow: ellipsis; color: var(--header-secondary); }
.reply-preview:hover span:last-child { color: var(--header-primary); }

/* ---------- Markdown ---------- */
.msg-text strong { font-weight: 700; }
.msg-text code {
  background: var(--bg-secondary-alt); padding: 0 .2em; margin: -.2em 0; border-radius: 3px;
  font-family: Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", monospace; font-size: 85%; line-height: 1.125rem;
}
.msg-text pre {
  background: var(--bg-secondary); border: 1px solid var(--bg-tertiary); border-radius: 4px;
  padding: .5em; margin: 6px 0 2px; max-width: 90%; overflow-x: auto; white-space: pre;
}
.msg-text pre code { background: none; padding: 0; margin: 0; font-size: .875rem; line-height: 1.125rem; color: #b5bac1; }
.msg-text blockquote { position: relative; padding: 0 8px 0 12px; margin: 2px 0; }
.msg-text blockquote::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; border-radius: 4px; background: #4e5058; }
.spoiler { background: #1e1f22; color: transparent; border-radius: 3px; cursor: pointer; padding: 0 2px; transition: background .1s; }
.spoiler:hover { background: #18191c; }
.spoiler.shown { background: rgba(255,255,255,.1); color: inherit; cursor: auto; }
.spoiler a { color: transparent; }
.spoiler.shown a { color: var(--link); }

/* ---------- Anhänge ---------- */
.attachments { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 2px 0; }
.att-image { display: block; border-radius: 8px; overflow: hidden; }
.att-image img { max-width: min(550px, 100%); max-height: 350px; display: block; cursor: pointer; }
.att-video { max-width: min(550px, 100%); max-height: 350px; border-radius: 8px; background: #000; }
.att-file {
  display: flex; align-items: center; gap: 8px; width: min(432px, 100%);
  background: var(--bg-secondary); border: 1px solid var(--bg-secondary-alt); border-radius: 8px; padding: 16px;
}
.att-icon { font-size: 30px; line-height: 1; }
.att-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.att-info a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.att-info small { color: var(--text-muted); font-size: 12px; }

/* ---------- Reaktionen ---------- */
.reactions { display: flex; flex-wrap: wrap; gap: 4px; padding: 2px 0; }
.reaction {
  display: flex; align-items: center; gap: 6px; height: 24px; padding: 0 6px;
  background: var(--bg-secondary); border: 1px solid transparent; border-radius: 8px;
  color: var(--interactive-normal); font-size: 15px; transition: background .1s, border-color .1s;
}
.reaction:hover { background: var(--bg-modifier-hover); border-color: #4e5058; }
.reaction.me { background: rgba(88,101,242,.15); border-color: var(--brand); }
.reaction.me b { color: #c9cdfb; }
.reaction b { font-size: 14px; font-weight: 600; min-width: 9px; text-align: center; }

/* ---------- Aktionsleiste ---------- */
.msg-actions {
  position: absolute; right: 14px; top: -16px; display: none; height: 32px;
  background: var(--bg-primary); border-radius: 4px; padding: 0 2px; z-index: 5;
  box-shadow: 0 0 0 1px rgba(4,4,5,.15);
}
.msg:hover .msg-actions { display: flex; align-items: center; }
.msg-actions .icon-btn { width: 32px; height: 32px; font-size: 16px; border-radius: 4px; padding: 0; }
.msg-actions .icon-btn:last-child:hover { color: var(--red); }

/* ---------- Bearbeiten ---------- */
.edit-box {
  width: 100%; background: var(--bg-input); border: none; border-radius: 8px; padding: 11px 16px;
  color: var(--text-normal); font: inherit; font-size: 16px; line-height: 22px;
  resize: none; outline: none; margin: 4px 0 2px; display: block;
}
.edit-hint { font-size: 12px; color: var(--text-normal); padding: 2px 0 6px; }

/* ---------- Eingabe ---------- */
.composer-wrap { padding: 0 16px; flex-shrink: 0; }
.composer-box { background: var(--bg-input); border-radius: 8px; }
.reply-bar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-secondary); border-radius: 8px 8px 0 0; padding: 0 8px 0 16px; height: 34px;
  font-size: 14px; color: var(--header-secondary);
}
.reply-bar b { color: var(--header-primary); font-weight: 600; }
.reply-bar .icon-btn { width: 24px; height: 24px; border-radius: 50%; font-size: 12px; background: var(--interactive-normal); color: var(--bg-secondary); }
.reply-bar .icon-btn:hover { background: var(--interactive-hover); color: var(--bg-secondary); }
.file-preview { display: flex; gap: 24px; padding: 20px 10px 10px; overflow-x: auto; border-bottom: 1px solid rgba(78,80,88,.48); }
.file-card {
  position: relative; width: 216px; min-width: 216px; height: 216px;
  background: var(--bg-secondary); border-radius: 4px; padding: 8px;
  display: flex; flex-direction: column; gap: 8px;
}
.file-card img { width: 100%; flex: 1; min-height: 0; object-fit: contain; border-radius: 3px; }
.file-icon { flex: 1; display: grid; place-items: center; font-size: 56px; }
.file-name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-shrink: 0; }
.file-remove {
  position: absolute; top: -8px; right: -8px; width: 28px; height: 28px; border-radius: 4px;
  border: none; background: var(--bg-primary); color: var(--red); font-size: 14px;
  box-shadow: 0 0 0 1px rgba(4,4,5,.15);
}
.file-remove:hover { background: var(--bg-modifier-hover); }
.composer { display: flex; align-items: flex-start; padding: 0 12px 0 0; min-height: 44px; }
.composer textarea {
  flex: 1; background: none; border: none; color: var(--text-normal);
  font: inherit; font-size: 16px; line-height: 22px; padding: 11px 10px 11px 0;
  resize: none; outline: none; max-height: 50vh; min-height: 44px;
}
.composer textarea::placeholder { color: #6d6f78; }
.composer-btn {
  background: none; border: none; color: var(--interactive-normal);
  width: 40px; height: 44px; flex-shrink: 0; font-size: 22px;
  display: grid; place-items: center; transition: transform .1s, filter .1s;
}
#emojiBtn { filter: grayscale(1) brightness(.8); }
#emojiBtn:hover { filter: none; transform: scale(1.15); }
.composer-btn.attach {
  width: 24px; height: 24px; margin: 10px 16px; border-radius: 50%;
  background: var(--interactive-normal); color: var(--bg-input);
  font-size: 18px; font-weight: 800; line-height: 24px;
}
.composer-btn.attach:hover { background: var(--interactive-hover); }
.typing { height: 24px; font-size: 14px; font-weight: 500; color: var(--text-normal); line-height: 24px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ---------- Emoji-Auswahl ---------- */
.emoji-picker {
  position: fixed; z-index: 100; display: grid; grid-template-columns: repeat(8, 40px); gap: 4px;
  background: var(--bg-secondary); border-radius: 8px; padding: 12px;
  box-shadow: 0 0 0 1px rgba(4,4,5,.15), var(--shadow-high);
}
.emoji-picker button { background: none; border: none; font-size: 26px; width: 40px; height: 40px; border-radius: 4px; transition: background .05s; }
.emoji-picker button:hover { background: var(--bg-modifier-active); }

/* ---------- Mitglieder ---------- */
.members { background: var(--bg-secondary); overflow-y: auto; padding: 0 8px 20px; }
.members .group { padding: 24px 8px 4px; height: auto; }
.member { display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 8px; border-radius: 4px; cursor: pointer; margin: 1px 0; }
.member:hover { background: var(--bg-modifier-hover); }
.member span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; font-weight: 500; color: var(--text-muted); }
.member:hover span { color: var(--interactive-hover); }
.member:not(.off) span { color: var(--text-normal); }
.member.off { opacity: .3; }
.member.off:hover { opacity: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) { .app { grid-template-columns: 72px 240px 1fr; } .members { display: none; } }
@media (max-width: 700px) { .app { grid-template-columns: 72px 1fr; } .sidebar { display: none; } }
