* { box-sizing: border-box; font-family: "gg sans", "Segoe UI", system-ui, sans-serif; }
:root {
  --bg-app: #1e1f22;
  --bg-sidebar: #2b2d31;
  --bg-chat: #313338;
  --bg-panel: #2b2d31;
  --bg-input: #1e1f22;
  --bg-hover: #35373c;
  --bg-active: #404249;
  --text: #dbdee1;
  --text-muted: #949ba4;
  --text-bright: #f2f3f5;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --danger: #ed4245;
  --green: #23a55a;
}
html, body { height: 100%; margin: 0; background: var(--bg-app); color: var(--text); }
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

body.center { display: flex; align-items: center; justify-content: center; }
.card { background: var(--bg-sidebar); padding: 32px; border-radius: 10px; width: 360px; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.card h1 { margin: 0 0 20px; color: var(--text-bright); font-size: 24px; text-align: center; }

#app { display: flex; height: 100vh; overflow: hidden; }

#guilds {
  width: 72px; background: var(--bg-app); padding: 12px 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  flex-shrink: 0; overflow-y: auto;
}
#guilds::-webkit-scrollbar { width: 0; }
.guild-icon { width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; cursor: pointer; position: relative; flex-shrink: 0; }
.guild-inner {
  width: 48px; height: 48px; background: var(--bg-sidebar); border-radius: 16px;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
  transition: all .15s; color: var(--text); font-weight: 700;
}
.guild-icon:hover .guild-inner, .guild-icon.active .guild-inner { border-radius: 14px; background: var(--accent); color: #fff; }
.guild-icon.active::before {
  content: ''; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 32px; background: #fff; border-radius: 0 4px 4px 0;
}
.guild-inner.create { font-size: 24px; color: var(--green); }
.guild-sep { width: 32px; height: 2px; background: var(--bg-sidebar); border-radius: 1px; margin: 4px 0; }

#sidebar { width: 260px; background: var(--bg-sidebar); display: flex; flex-direction: column; flex-shrink: 0; }
#top-menu { padding: 8px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: 6px; color: var(--text-muted); font-size: 15px; font-weight: 500;
  cursor: pointer; margin-bottom: 2px; position: relative; transition: background .1s;
}
.menu-item:hover { background: var(--bg-hover); color: var(--text-bright); }
.menu-item.active { background: var(--bg-active); color: var(--text-bright); }
.menu-icon { font-size: 18px; width: 22px; text-align: center; }
.menu-badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px; }
.menu-sep { height: 1px; background: var(--bg-app); margin: 4px 8px 8px; }

.dm-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 14px 6px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; color: var(--text-muted);
}
.dm-header .plus { cursor: pointer; font-size: 16px; }
.dm-header .plus:hover { color: var(--text-bright); }

#sidebar-content { flex: 1; overflow-y: auto; }
.tab-panel { padding: 4px 8px 8px; }
.section { margin-bottom: 16px; }
.section-title {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 6px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; color: var(--text-muted);
}
.section-title .plus { cursor: pointer; font-size: 16px; }
.section-title .plus:hover { color: var(--text-bright); }

#sidebar ul { list-style: none; padding: 0; margin: 0; }
#sidebar li {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px;
  border-radius: 6px; color: var(--text-muted); cursor: pointer; font-size: 15px;
  margin-bottom: 2px; transition: background .1s;
}
#sidebar li:hover { background: var(--bg-hover); color: var(--text); }
#sidebar li.active { background: var(--bg-active); color: var(--text-bright); }

.avatar-wrap { position: relative; flex-shrink: 0; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px; flex-shrink: 0; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.gray { background: var(--bg-input); color: var(--text); }
.online-dot {
  position: absolute; right: -2px; bottom: -2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--green); border: 3px solid var(--bg-sidebar);
}
.item-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.item-info strong { font-size: 14px; color: inherit; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-info small { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-info small.online { color: var(--green); }

.add-friend { display: flex; gap: 6px; padding: 0 4px; }
.add-friend input { flex: 1; padding: 8px; background: var(--bg-input); border: none; border-radius: 4px; color: var(--text); font-size: 14px; }
.add-friend button { padding: 8px 12px; background: var(--accent); color: #fff; border: none; border-radius: 4px; font-weight: 600; }
.hint { font-size: 12px; color: var(--text-muted); padding: 4px 8px; }

#profile-bar {
  height: 56px; padding: 0 10px; background: var(--bg-app);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  box-shadow: 0 -1px 0 rgba(0,0,0,.2);
}
.profile-avatar-wrap { position: relative; flex-shrink: 0; }
.profile-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--accent);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; overflow: hidden;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-avatar-wrap .online-dot { right: -1px; bottom: -1px; width: 13px; height: 13px; border: 3px solid var(--bg-app); }
.profile-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.profile-info strong { color: var(--text-bright); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-info small { color: var(--text-muted); font-size: 12px; }

#main { flex: 1; display: flex; flex-direction: column; background: var(--bg-chat); min-width: 0; position: relative; }
#chat-header { height: 48px; padding: 0 16px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 1px 0 rgba(0,0,0,.2); flex-shrink: 0; }
.header-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chat-icon { color: var(--text-muted); font-size: 20px; }
#chat-title { color: var(--text-bright); font-size: 15px; }
.chat-sub { color: var(--text-muted); font-size: 13px; margin-left: 8px; }
.header-actions { display: flex; align-items: center; gap: 4px; position: relative; }
.icon-btn { background: transparent; border: none; color: var(--text-muted); font-size: 18px; padding: 6px 8px; border-radius: 4px; position: relative; }
.icon-btn:hover { color: var(--text-bright); background: var(--bg-hover); }

#notif-wrap { position: relative; }
#notif-badge {
  position: absolute; top: -2px; right: -2px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; border-radius: 10px; min-width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center; padding: 0 5px;
  border: 2px solid var(--bg-chat);
}
#notif-panel {
  position: absolute; right: 0; top: 40px; width: 340px; max-height: 480px;
  background: var(--bg-sidebar); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.6); z-index: 100; padding: 8px; overflow-y: auto;
}
.notif-header { display: flex; justify-content: space-between; align-items: center; padding: 8px; border-bottom: 1px solid var(--bg-app); margin-bottom: 6px; color: var(--text-bright); font-weight: 600; }
#notif-list li { padding: 10px; border-radius: 6px; cursor: pointer; color: var(--text); font-size: 14px; margin-bottom: 4px; }
#notif-list li:hover { background: var(--bg-hover); }
#notif-list li.unread { background: rgba(88,101,242,.12); border-left: 3px solid var(--accent); }
#notif-list li .time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

#main-body { flex: 1; display: flex; overflow: hidden; }
#messages-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#messages { flex: 1; overflow-y: auto; padding: 16px; }
.msg { display: flex; gap: 12px; padding: 4px 0; margin-bottom: 4px; }
.msg .avatar { width: 40px; height: 40px; font-size: 16px; }
.msg .body { flex: 1; min-width: 0; }
.msg .author-line { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.msg .author { color: var(--text-bright); font-weight: 600; font-size: 15px; }
.msg .time { color: var(--text-muted); font-size: 11px; }
.msg .text { color: var(--text); font-size: 15px; line-height: 1.4; word-wrap: break-word; white-space: pre-wrap; }

#composer { padding: 0 16px 12px; }
#composer input { width: 100%; padding: 11px 16px; background: var(--bg-input); border: none; border-radius: 8px; color: var(--text); font-size: 15px; }
#composer input::placeholder { color: var(--text-muted); }
#composer button { display: none; }

#right-panel { width: 300px; background: var(--bg-panel); border-left: 1px solid var(--bg-app); overflow-y: auto; padding: 14px; flex-shrink: 0; }
#right-panel.hidden { display: none; }
#right-panel h3 { margin: 4px 0 10px; font-size: 12px; color: var(--text-muted); text-transform: uppercase; font-weight: 700; }
#right-panel h4 { margin: 14px 0 6px; font-size: 12px; color: var(--text-muted); text-transform: uppercase; font-weight: 700; }
#right-panel input, #right-panel select { width: 100%; padding: 8px; background: var(--bg-input); border: none; border-radius: 4px; color: var(--text); margin: 4px 0; font-size: 14px; }
#right-panel button.primary { margin-top: 6px; padding: 8px 12px; background: var(--accent); color: #fff; border: none; border-radius: 4px; font-weight: 600; width: 100%; }
#right-panel button.primary:hover { background: var(--accent-hover); }
#right-panel ul { list-style: none; padding: 0; margin: 0; }
#right-panel li { padding: 8px; border-radius: 6px; margin-bottom: 4px; color: var(--text); font-size: 14px; }
#right-panel li:hover { background: var(--bg-hover); }
.member-row { display: flex; flex-direction: column; gap: 6px; }
.member-row .head { display: flex; align-items: center; gap: 8px; }
.member-row .name { font-size: 14px; color: var(--text-bright); font-weight: 600; }
.member-row .role { font-size: 11px; color: var(--text-muted); }
.member-row .flags { display: flex; flex-wrap: wrap; gap: 8px; font-size: 11px; color: var(--text-muted); }
.member-row .flags label { display: flex; align-items: center; gap: 3px; cursor: pointer; }
.invite-block { background: var(--bg-app); border-radius: 6px; padding: 8px; margin: 6px 0; }
.invite-block .url { font-size: 12px; color: var(--text-muted); word-break: break-all; margin-bottom: 6px; }
.invite-row { display: flex; gap: 6px; }
.invite-row input { flex: 1; margin: 0; }

.channel-banner { display: flex; align-items: center; gap: 8px; padding: 10px; margin-bottom: 8px; border-bottom: 1px solid var(--bg-app); color: var(--text-bright); font-weight: 600; font-size: 14px; }
.channel-banner .ico { font-size: 18px; }
#panel-channel-rooms ul li { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 4px; color: var(--text-muted); cursor: pointer; font-size: 14px; margin-bottom: 2px; }
#panel-channel-rooms ul li:hover { background: var(--bg-hover); color: var(--text); }
#panel-channel-rooms ul li.active { background: var(--bg-active); color: var(--text-bright); }
.room-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.room-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-badge { font-size: 11px; background: var(--bg-active); color: var(--text); padding: 1px 6px; border-radius: 8px; min-width: 20px; text-align: center; }
.room-badge.active { background: var(--green); color: #fff; }

.voice-controls { display: flex; gap: 6px; padding: 8px 0; }
.vctl { flex: 1; padding: 8px; background: var(--bg-active); border: none; border-radius: 6px; color: var(--text); font-size: 16px; cursor: pointer; }
.vctl:hover { background: var(--bg-hover); }
.vctl.off { background: var(--danger); color: #fff; }

#voice-participants { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.voice-user { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; background: var(--bg-active); font-size: 14px; color: var(--text); }
.voice-user .avatar { width: 26px; height: 26px; font-size: 12px; }
.voice-user .name { flex: 1; }

#voice-grid { flex: 1; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; padding: 16px; overflow-y: auto; align-content: start; }
#voice-grid.hidden { display: none; }
#voice-grid .tile { background: #111214; border-radius: 10px; aspect-ratio: 16 / 10; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
#voice-grid .tile video { width: 100%; height: 100%; object-fit: cover; background: #000; }
#voice-grid .tile .placeholder { font-size: 48px; font-weight: 700; color: var(--accent); width: 88px; height: 88px; border-radius: 50%; background: var(--bg-active); display: flex; align-items: center; justify-content: center; }
#voice-grid .tile .tile-name { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.65); padding: 3px 8px; border-radius: 4px; font-size: 12px; color: #fff; max-width: 80%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#voice-grid .tile .tile-mic { position: absolute; right: 8px; top: 8px; background: rgba(0,0,0,.65); padding: 2px 6px; border-radius: 4px; font-size: 12px; color: #fff; }
#voice-grid .tile .tile-mic.off { background: var(--danger); }

#voice-controls-bar { background: #1e1f22; border-top: 1px solid #000; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; flex-shrink: 0; }
#voice-controls-bar.hidden { display: none; }
.vc-top { display: flex; justify-content: space-between; align-items: center; background: #111214; border-radius: 8px; padding: 10px 12px; }
.vc-top-left { display: flex; align-items: center; gap: 10px; }
.vc-channel-icon { width: 36px; height: 36px; border-radius: 8px; background: #1a1b1e; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.vc-channel-name { color: #f2f3f5; font-size: 15px; font-weight: 600; max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vc-top-right { display: flex; gap: 6px; }
.vc-icon-btn { width: 36px; height: 36px; border: none; border-radius: 8px; background: #2b2d31; color: #dbdee1; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.vc-icon-btn:hover { background: #35373c; }
.vc-icon-btn.small { width: 32px; height: 32px; font-size: 15px; }
.vc-icon-btn.danger { background: #da373c; color: #fff; }
.vc-icon-btn.danger:hover { background: #c53030; }
.vc-icon-btn.off { background: #da373c; color: #fff; }

.vc-status { display: flex; justify-content: space-between; align-items: center; background: #111214; border-radius: 8px; padding: 10px 12px; }
.vc-status-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.vc-signal { font-size: 20px; color: #23a55a; }
.vc-status-text { display: flex; flex-direction: column; min-width: 0; }
.vc-status-text strong { color: #23a55a; font-size: 14px; font-weight: 600; }
.vc-status-text small { color: #949ba4; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.vc-status-right { display: flex; gap: 6px; }

.vc-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.vc-big-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 10px 6px; background: #2b2d31; border: none; border-radius: 8px; color: #dbdee1; cursor: pointer; min-height: 62px; }
.vc-big-btn:hover { background: #35373c; }
.vc-big-btn .vc-big-icon { font-size: 22px; line-height: 1; }
.vc-big-btn .vc-big-label { font-size: 11px; font-weight: 600; text-transform: uppercase; color: #949ba4; }
.vc-big-btn.active { background: #1f3a2a; color: #23a55a; }
.vc-big-btn.active .vc-big-label { color: #23a55a; }
.vc-big-btn.off { background: #3a1f22; color: #da373c; }
.vc-big-btn.off .vc-big-label { color: #da373c; }

.voice-room-members { flex-basis: 100%; margin-left: 28px; margin-top: 4px; display: flex; flex-direction: column; gap: 2px; }
.voice-room-member { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.voice-room-member .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.voice-room-member .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; z-index: 200; }
.modal-card { background: var(--bg-sidebar); border-radius: 8px; padding: 24px; width: 440px; max-width: 92vw; }
.modal-card h2 { margin: 0 0 16px; color: var(--text-bright); text-align: center; font-size: 22px; }
.modal-card input, .modal-card select { width: 100%; padding: 10px; margin: 6px 0; background: var(--bg-input); color: var(--text); border: none; border-radius: 6px; font-size: 15px; }
.icon-picker { margin-top: 8px; }
.icon-picker label { display: block; font-size: 12px; color: var(--text-muted); text-transform: uppercase; margin-bottom: 4px; }
.icon-picker input { text-align: center; font-size: 22px; letter-spacing: 2px; }
.icon-hint { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-muted); margin: 8px 0; }
.check input { width: auto; margin: 0; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.modal-actions button { padding: 10px 20px; border: none; border-radius: 4px; font-weight: 600; font-size: 14px; background: var(--accent); color: #fff; cursor: pointer; }
.modal-actions button.secondary { background: transparent; color: var(--text); }
.modal-actions button.secondary:hover { text-decoration: underline; }

.mini { background: var(--bg-active); color: var(--text); border: none; padding: 4px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; cursor: pointer; }
.mini:hover { background: var(--bg-hover); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-app); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #111214; }