* { box-sizing: border-box; margin: 0; padding: 0; }

.lucide-icon { flex-shrink: 0; display: block; }

:root {
  --accent: #8b5cf6;
  --accent2: #06b6d4;
  --gradient: linear-gradient(135deg, #8b5cf6, #6366f1 45%, #06b6d4);
  --accent-hover: #9d70ff;
  --bg-darkest: #0a0b12;
  --bg-dark: #12141f;
  --bg-mid: #171928;
  --bg-light: #1f2333;
  --bg-lighter: #2a2f45;
  --text-normal: #c7cce3;
  --text-muted: #7d84a8;
  --text-bright: #f5f6fc;
  --online: #22c55e;
  --idle: #f0b232;
  --dnd: #f43f5e;
  --danger: #f43f5e;
  --border: rgba(255,255,255,.07);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --glow: 0 0 0 1px rgba(139,92,246,.25), 0 8px 24px rgba(139,92,246,.18);
}

html[data-theme="light"] {
  --bg-darkest: #f3f4f9;
  --bg-dark: #ffffff;
  --bg-mid: #eef0f7;
  --bg-light: #e3e6f0;
  --bg-lighter: #d5d9e8;
  --text-normal: #33364a;
  --text-muted: #6b7089;
  --text-bright: #14151f;
  --border: rgba(20,21,31,.10);
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: "Vazirmatn", "Segoe UI", "Tahoma", -apple-system, sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(139,92,246,.10), transparent 40%),
    radial-gradient(circle at 90% 85%, rgba(6,182,212,.08), transparent 45%),
    var(--bg-darkest);
  color: var(--text-normal);
  user-select: none;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; color: inherit; }

/* Titlebar */
#titlebar {
  height: 32px;
  background: var(--bg-darkest);
  display: flex;
  align-items: center;
  justify-content: space-between;
  -webkit-app-region: drag;
  border-bottom: 1px solid var(--border);
}
#titlebar-drag { display: flex; align-items: center; gap: 8px; padding-inline-start: 12px; }
.tb-logo {
  width: 18px; height: 18px; border-radius: 6px; background: var(--gradient);
  color: #fff; font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center;
}
.tb-title { font-size: 12px; color: var(--text-muted); letter-spacing: .02em; }
#titlebar-controls { display: flex; -webkit-app-region: no-drag; }
#titlebar-controls button {
  width: 44px; height: 32px; color: var(--text-muted); font-size: 13px;
  display: flex; align-items: center; justify-content: center; transition: background .1s, color .1s;
}
#titlebar-controls button:hover { background: var(--bg-light); color: var(--text-bright); }
#tb-close:hover { background: var(--danger); color: #fff; }

#app { height: calc(100% - 32px); display: flex; }

/* Server rail */
#server-rail {
  width: 76px; background: rgba(10,11,18,.7); backdrop-filter: blur(16px); display: flex; flex-direction: column;
  align-items: center; padding: 14px 0; gap: 10px; overflow-y: auto; flex-shrink: 0; border-inline-end: 1px solid var(--border);
}
.rail-item {
  width: 48px; height: 48px; border-radius: var(--r-md); background: var(--bg-light);
  display: flex; align-items: center; justify-content: center; font-weight: 700;
  color: var(--text-bright); font-size: 15px; position: relative; overflow: hidden;
  transition: border-radius .18s, background .18s, box-shadow .18s, transform .15s;
  flex-shrink: 0;
}
.rail-item-icon { width: 100%; height: 100%; object-fit: cover; display: block; }
.rail-item:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.35); }
.rail-item.active { background: var(--gradient) !important; box-shadow: var(--glow); }
.rail-item.dragging { opacity: .4; }
.rail-item .pill {
  position: absolute; inset-inline-start: -13px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 0; border-radius: 4px; background: var(--text-bright); transition: height .18s;
}
.rail-item.active .pill, .rail-item:hover .pill { height: 22px; }
.rail-item.active .pill { height: 38px; background: var(--accent2); }
.rail-sep { width: 32px; height: 2px; background: var(--border); border-radius: 1px; margin: 4px 0; }
.rail-item.add { background: var(--bg-light); color: var(--online); font-size: 22px; border: 1px dashed rgba(34,197,94,.4); }
.rail-item.add:hover { background: var(--online); color: #fff; border-style: solid; }
.rail-item.home { color: var(--text-bright); background: var(--bg-lighter); }
.rail-item.unread:not(.active) .pill { height: 10px; background: var(--text-bright); }
.rail-item.unread::after {
  content: ''; position: absolute; top: -2px; inset-inline-end: -2px; width: 11px; height: 11px;
  border-radius: 50%; background: var(--danger); border: 3px solid var(--bg-darkest); box-shadow: 0 0 8px rgba(244,63,94,.6);
}
.folder-item { border: 1px solid var(--border); }
.folder-item.expanded { border-radius: var(--r-sm); }
.folder-grid {
  width: 32px; height: 32px; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 2px;
}
.folder-mini-icon {
  width: 100%; height: 100%; border-radius: 4px; object-fit: cover; display: flex; align-items: center; justify-content: center;
  font-size: 8px; font-weight: 700; color: #fff;
}

/* Channel sidebar */
#channel-sidebar { width: 246px; background: rgba(18,20,31,.85); backdrop-filter: blur(16px); display: flex; flex-direction: column; flex-shrink: 0; border-inline-end: 1px solid var(--border); }
#server-header {
  height: 52px; display: flex; align-items: center; padding: 0 16px; font-weight: 700;
  color: var(--text-bright); border-bottom: 1px solid var(--border);
  font-size: 15px; transition: background .12s;
}
#server-header:hover { background: var(--bg-light); }
#channel-list { flex: 1; overflow-y: auto; padding: 12px 10px; }
.channel-group { color: var(--text-muted); font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 14px 8px 6px; letter-spacing: .04em; }
.category-header {
  display: flex; align-items: center; gap: 4px; padding: 10px 6px 4px; cursor: pointer; user-select: none;
  color: var(--text-muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}
.category-header:hover { color: var(--text-normal); }
.cat-chevron { font-size: 9px; width: 10px; display: inline-block; color: var(--accent2); }
.cat-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-add { opacity: 0; font-size: 14px; }
.category-header:hover .cat-add { opacity: .8; }
.cat-add:hover { opacity: 1 !important; color: var(--text-bright); }
.channel-item {
  display: flex; align-items: center; gap: 7px; padding: 7px 9px; border-radius: var(--r-sm); margin-bottom: 2px;
  color: var(--text-muted); font-size: 14px; transition: background .1s, color .1s;
}
.channel-item .hash { display: inline-flex; align-items: center; justify-content: center; opacity: .65; font-size: 15px; width: 18px; flex-shrink: 0; }
.channel-item:hover { background: var(--bg-light); color: var(--text-normal); }
.channel-item.active { background: var(--bg-lighter); color: var(--text-bright); box-shadow: inset 2px 0 0 var(--accent); }
.channel-item.voice-active { color: var(--online); }
.channel-item.unread { color: var(--text-bright); font-weight: 600; }
.channel-item.drag-over-channel { box-shadow: inset 0 -2px 0 var(--accent); }
.category-header.drag-over-channel { box-shadow: inset 0 -2px 0 var(--accent); }
.drag-handle { opacity: 0; cursor: grab; font-size: 13px; width: 12px; text-align: center; flex-shrink: 0; color: var(--text-muted); }
.channel-item:hover .drag-handle, .category-header:hover .drag-handle { opacity: .6; }
.drag-handle:hover { opacity: 1 !important; color: var(--text-bright); }
.drag-handle:active { cursor: grabbing; }
.unread-dot { margin-inline-start: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); flex-shrink: 0; box-shadow: 0 0 6px rgba(244,63,94,.7); }

/* Persistent voice status bar (stays visible while browsing, audio keeps playing) */
#voice-status-bar { background: linear-gradient(180deg, rgba(139,92,246,.12), transparent); padding: 10px 12px; border-top: 1px solid var(--border); }
.vsb-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.vsb-status { font-size: 13px; font-weight: 700; color: var(--online); }
.vsb-channel { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.vsb-controls { display: flex; gap: 6px; }
.vsb-controls button { flex: 1; height: 32px; border-radius: var(--r-sm); background: var(--bg-light); color: var(--text-normal); display: flex; align-items: center; justify-content: center; font-size: 14px; transition: background .1s, transform .1s; }
.vsb-controls button:hover { background: var(--bg-lighter); transform: translateY(-1px); }
.vsb-controls button.danger:hover { background: var(--danger); color: #fff; }

.screen-tile {
  width: min(640px, 90%); aspect-ratio: 16/9; background: #000; border-radius: var(--r-lg); position: relative;
  overflow: hidden; margin: 0 auto 16px; box-shadow: 0 16px 40px rgba(0,0,0,.55), 0 0 0 1px var(--border);
}
.screen-tile video { width: 100%; height: 100%; object-fit: contain; }
.screen-tile .tile-name { position: absolute; bottom: 8px; inset-inline-start: 10px; font-size: 13px; color: #fff; background: rgba(0,0,0,.55); padding: 3px 9px; border-radius: 20px; backdrop-filter: blur(6px); }
.screen-tile-controls { position: absolute; top: 8px; inset-inline-end: 10px; display: flex; gap: 6px; }
.screen-tile-controls button { width: 34px; height: 34px; border-radius: 50%; background: rgba(0,0,0,.55); backdrop-filter: blur(6px); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 15px; transition: background .1s; }
.screen-tile-controls button:hover { background: rgba(0,0,0,.75); }

.share-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; max-height: 50vh; overflow-y: auto; }
.share-card { cursor: pointer; border-radius: var(--r-md); overflow: hidden; background: var(--bg-darkest); border: 2px solid transparent; transition: border-color .12s, transform .12s; }
.share-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.share-card img { width: 100%; height: 110px; object-fit: cover; background: #000; }
.share-card-name { padding: 6px 8px 2px; font-size: 12px; color: var(--text-normal); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.share-card-audio-hint { padding: 0 8px 6px; font-size: 10.5px; color: var(--accent2); }

.mic-test-meter { height: 8px; background: var(--bg-darkest); border-radius: 4px; margin-top: 8px; overflow: hidden; position: relative; }
.mic-test-meter::after { content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: var(--level, 0%); background: var(--gradient); transition: width .05s; }

#user-panel {
  height: 56px; background: rgba(10,11,18,.5); display: flex; align-items: center; padding: 0 10px; gap: 8px;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 13px; flex-shrink: 0; position: relative; overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar .status-dot {
  position: absolute; bottom: -1px; inset-inline-end: -1px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--online); border: 3px solid var(--bg-darkest);
}
#user-panel .who { flex: 1; min-width: 0; }
#user-panel .uname { font-size: 13px; font-weight: 700; color: var(--text-bright); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#user-panel .utag { font-size: 11px; color: var(--text-muted); }
#user-panel .icon-btn { width: 30px; height: 30px; border-radius: var(--r-sm); color: var(--text-muted); display: flex; align-items: center; justify-content: center; font-size: 15px; transition: background .1s, color .1s, transform .15s; }
#user-panel .icon-btn:hover { background: var(--bg-light); color: var(--text-bright); transform: rotate(45deg); }

/* Main area */
#main { flex: 1; display: flex; flex-direction: column; background: var(--bg-mid); min-width: 0; }
#chat-header {
  height: 52px; display: flex; align-items: center; padding: 0 18px; gap: 8px; border-bottom: 1px solid var(--border);
  flex-shrink: 0; background: rgba(23,25,40,.6); backdrop-filter: blur(10px);
}
#chat-header .hash { display: inline-flex; align-items: center; color: var(--text-muted); font-size: 19px; }
#chat-header .cname { font-weight: 700; color: var(--text-bright); font-size: 15px; }
#chat-header .spacer { flex: 1; }
#chat-header .icon-btn { width: 34px; height: 34px; border-radius: var(--r-sm); color: var(--text-muted); display:flex; align-items:center; justify-content:center; transition: background .1s, color .1s; }
#chat-header .icon-btn:hover { background: var(--bg-light); color: var(--text-bright); }
#chat-header .icon-btn.active { background: var(--bg-lighter); color: var(--accent2); }

#message-list { flex: 1; overflow-y: auto; padding: 16px 0; display: flex; flex-direction: column; }
.msg-row { display: flex; gap: 16px; padding: 3px 18px 3px 22px; margin: 0 8px; border-radius: var(--r-md); transition: background .1s; position: relative; }
.msg-row:hover { background: rgba(255,255,255,.03); }
.msg-row.head { margin-top: 14px; }
.msg-row.grouped { margin-top: 0; }
.msg-row .avatar { margin-top: 2px; }
.avatar-slot { width: 40px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.hover-time { display: none; font-size: 10px; color: var(--text-muted); }
.msg-row:hover .hover-time { display: block; }
.msg-body { flex: 1; min-width: 0; }
.msg-meta { display: flex; align-items: baseline; gap: 8px; }
.msg-author { font-weight: 700; font-size: 15px; color: var(--text-bright); }
.msg-time { font-size: 11px; color: var(--text-muted); }
.msg-content { font-size: 14px; line-height: 1.45; color: var(--text-normal); white-space: pre-wrap; word-break: break-word; }

.compact-mode .msg-row { padding: 1px 18px 1px 22px; gap: 10px; }
.compact-mode .msg-row.head { margin-top: 6px; }
.compact-mode .avatar-slot { width: 24px; }
.compact-mode .msg-row .avatar { width: 20px !important; height: 20px !important; margin-top: 1px; }
.compact-mode .msg-content { font-size: 13px; line-height: 1.3; }
.compact-mode .msg-author { font-size: 13px; }
.compact-mode .msg-reactions { margin-top: 1px; }
.msg-content strong { font-weight: 700; color: var(--text-bright); }
.msg-content em { font-style: italic; }
.msg-content .inline-code { background: var(--bg-darkest); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 1px 6px; font-family: "Cascadia Code", Consolas, monospace; font-size: 12.5px; color: var(--accent2); }
.msg-content .code-block-lang { font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 6px; }
.msg-content .code-block {
  background: var(--bg-darkest); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 12px; margin-top: 2px;
  overflow-x: auto; direction: ltr; text-align: left;
}
.msg-content .code-block code { font-family: "Cascadia Code", Consolas, monospace; font-size: 12.5px; color: var(--text-normal); white-space: pre; line-height: 1.5; }
.tok-keyword { color: #c586c0; }
.tok-string { color: #ce9178; }
.tok-comment { color: var(--text-muted); font-style: italic; }
.tok-number { color: #b5cea8; }

.image-lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 300; display: flex; align-items: center; justify-content: center;
  animation: fadeIn .12s ease-out;
}
.lightbox-img { max-width: 90vw; max-height: 90vh; object-fit: contain; border-radius: var(--r-md); box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.lightbox-close { position: absolute; top: 20px; inset-inline-end: 24px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.1); color: #fff; font-size: 18px; }
.lightbox-close:hover { background: rgba(255,255,255,.2); }
.lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; background: rgba(255,255,255,.1); color: #fff; font-size: 26px; }
.lightbox-nav:hover { background: rgba(255,255,255,.2); }
.lightbox-prev { left: 20px; }
.lightbox-next { right: 20px; }
.msg-content .msg-link { color: var(--accent2); text-decoration: none; cursor: pointer; }
.msg-content .msg-link:hover { text-decoration: underline; }

.msg-toolbar {
  display: none; position: absolute; top: -16px; inset-inline-end: 16px; background: var(--bg-dark);
  border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: 0 6px 18px rgba(0,0,0,.4); overflow: hidden;
}
.msg-row:hover .msg-toolbar { display: flex; }
.msg-toolbar button { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; font-size: 14px; color: var(--text-normal); transition: background .1s; }
.msg-toolbar button:hover { background: var(--bg-light); }
.msg-toolbar button.danger:hover { background: var(--danger); color: #fff; }

.channel-welcome { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; padding: 24px 24px 32px; }
.channel-welcome-icon {
  width: 72px; height: 72px; border-radius: var(--r-lg); background: var(--gradient); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 34px; font-weight: 700; margin-bottom: 18px;
  box-shadow: var(--glow);
}
.channel-welcome-title { font-size: 28px; font-weight: 800; color: var(--text-bright); margin-bottom: 8px; }
.channel-welcome-sub { font-size: 14px; color: var(--text-muted); }

.day-divider { display: flex; align-items: center; gap: 12px; margin: 12px 16px; color: var(--text-muted); font-size: 12px; }
.day-divider::before, .day-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

#composer-wrap { padding: 0 18px 20px; flex-shrink: 0; position: relative; }
#attachment-chip-host:empty { display: none; }
.attachment-chip {
  display: inline-flex; align-items: center; gap: 8px; background: var(--bg-light); border: 1px solid var(--border);
  border-radius: var(--r-md) var(--r-md) 0 0; padding: 8px 12px; font-size: 12.5px; color: var(--text-normal); margin-inline-start: 4px;
}
.attachment-chip button { color: var(--text-muted); font-size: 13px; }
.attachment-chip button:hover { color: var(--danger); }

.msg-attachment-img { max-width: 340px; max-height: 300px; border-radius: var(--r-md); margin-top: 6px; cursor: pointer; display: block; box-shadow: 0 6px 18px rgba(0,0,0,.3); }
.msg-attachment-file {
  display: flex; align-items: center; gap: 12px; background: var(--bg-light); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 10px 14px; margin-top: 6px; max-width: 320px; cursor: pointer; transition: background .1s;
}
.msg-attachment-file:hover { background: var(--bg-lighter); }
.att-icon { font-size: 22px; }
.att-info { flex: 1; min-width: 0; }
.att-name { font-size: 13px; color: var(--text-bright); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-size { font-size: 11px; color: var(--text-muted); }
.att-download { color: var(--accent2); font-size: 16px; }
#composer { background: var(--bg-light); border-radius: var(--r-lg); display: flex; align-items: center; padding: 0 8px; min-height: 46px; border: 1px solid var(--border); transition: border-color .15s, box-shadow .15s; }
#composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139,92,246,.15); }
#composer input { flex: 1; background: transparent; border: none; outline: none; padding: 12px 6px; font-size: 14px; color: var(--text-normal); }
#composer input::placeholder { color: var(--text-muted); }
.composer-icon-btn { width: 34px; height: 34px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 17px; border-radius: 50%; color: var(--text-muted); transition: background .1s, color .1s; }
.composer-icon-btn:hover:not(:disabled) { background: var(--bg-lighter); color: var(--text-bright); }
.composer-icon-btn:disabled { opacity: .35; cursor: default; }
.emoji-picker {
  position: absolute; bottom: 58px; inset-inline-end: 16px; width: 280px; max-height: 280px; overflow-y: auto;
  background: var(--bg-dark); border: 1px solid var(--border); border-radius: var(--r-md); padding: 8px;
  box-shadow: 0 16px 40px rgba(0,0,0,.5); animation: ctxIn .12s ease-out;
}
.emoji-picker .emoji-search {
  width: 100%; background: var(--bg-darkest); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 7px 10px; font-size: 12.5px; color: var(--text-normal); outline: none; margin-bottom: 6px;
}
.emoji-picker .emoji-search:focus { border-color: var(--accent); }
.emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; }
.emoji-picker button { font-size: 20px; padding: 6px 0; border-radius: var(--r-sm); }
.emoji-picker button:hover { background: var(--bg-light); }
.emoji-picker-floating { position: fixed; bottom: auto; inset-inline-end: auto; }
.quick-reactions {
  position: fixed; z-index: 210; display: flex; align-items: center; gap: 2px; padding: 5px;
  background: var(--bg-dark); border: 1px solid var(--border); border-radius: 20px;
  box-shadow: 0 12px 30px rgba(0,0,0,.5); animation: ctxIn .1s ease-out;
}
.quick-reaction-btn { font-size: 19px; padding: 4px 7px; border-radius: 50%; transition: background .1s, transform .1s; }
.quick-reaction-btn:hover { background: var(--bg-light); transform: scale(1.15); }
.quick-reaction-more { font-size: 15px; font-weight: 700; color: var(--text-muted); }
.mention-dropdown {
  position: absolute; bottom: 58px; inset-inline-start: 16px; width: 260px; max-height: 220px; overflow-y: auto;
  background: var(--bg-dark); border: 1px solid var(--border); border-radius: var(--r-md); padding: 6px;
  box-shadow: 0 16px 40px rgba(0,0,0,.5); animation: ctxIn .12s ease-out; z-index: 60;
}
.mention-dropdown-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r-sm); font-size: 13.5px; color: var(--text-normal); cursor: pointer; }
.mention-dropdown-item.active, .mention-dropdown-item:hover { background: var(--gradient); color: #fff; }
.mdi-icon { font-size: 13px; opacity: .8; width: 16px; text-align: center; }

.quick-switcher { padding: 14px; width: 480px; }
.quick-switcher input { width: 100%; background: var(--bg-darkest); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 12px; font-size: 15px; outline: none; }
.quick-switcher input:focus { border-color: var(--accent); }
.quick-switcher-list { max-height: 360px; overflow-y: auto; margin-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.quick-switcher-item { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border-radius: var(--r-sm); font-size: 14px; color: var(--text-normal); cursor: pointer; }
.quick-switcher-item.active, .quick-switcher-item:hover { background: var(--gradient); color: #fff; }
.qs-sub { font-size: 11px; color: var(--text-muted); }
.quick-switcher-item.active .qs-sub, .quick-switcher-item:hover .qs-sub { color: rgba(255,255,255,.75); }
.emoji-picker-sep { grid-column: 1 / -1; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); padding: 6px 2px 2px; }
.custom-emoji-btn { display: flex; align-items: center; justify-content: center; }
.custom-emoji-btn .custom-emoji { width: 22px; height: 22px; vertical-align: middle; }

.msg-translation { margin-top: 4px; padding: 6px 10px; background: var(--bg-darkest); border-inline-start: 3px solid var(--accent); border-radius: var(--r-sm); font-size: 13px; color: var(--text-muted); }
.msg-content .mention { background: rgba(139,92,246,.18); color: var(--accent-hover); border-radius: 4px; padding: 0 3px; font-weight: 600; }
.msg-content .role-mention { background: rgba(139,92,246,.14); }
.msg-content .custom-emoji { width: 22px; height: 22px; vertical-align: -6px; object-fit: contain; }
.msg-content .spoiler { background: var(--bg-lighter); color: transparent; border-radius: 4px; padding: 0 4px; cursor: pointer; transition: color .1s; user-select: none; }
.msg-content .spoiler::selection { color: transparent; }
.msg-content .spoiler.revealed { color: var(--text-normal); cursor: text; user-select: text; background: rgba(255,255,255,.06); }

.msg-reply-preview {
  display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-muted);
  margin-bottom: 3px; padding-inline-start: 2px; max-width: 480px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.msg-reply-preview b { color: var(--text-normal); font-weight: 600; }

.msg-reactions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.reaction-pill {
  display: inline-flex; align-items: center; gap: 5px; background: var(--bg-light); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 9px; font-size: 12.5px; color: var(--text-normal); transition: background .1s, border-color .1s;
}
.reaction-pill:hover { background: var(--bg-lighter); }
.reaction-pill.mine { background: rgba(139,92,246,.18); border-color: rgba(139,92,246,.5); color: var(--text-bright); }
.reaction-pill .reaction-count { font-size: 11.5px; color: var(--text-muted); }
.reaction-pill.mine .reaction-count { color: var(--accent-hover); }

.pin-badge { color: var(--accent2); font-size: 12px; margin-inline-start: 4px; }

.reply-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--bg-light); border: 1px solid var(--border); border-bottom: none;
  border-radius: var(--r-md) var(--r-md) 0 0; padding: 8px 14px; font-size: 12.5px; color: var(--text-normal);
}
.reply-bar button { color: var(--text-muted); font-size: 14px; }
.reply-bar button:hover { color: var(--danger); }

.typing-indicator { padding: 0 18px 4px; font-size: 12px; color: var(--text-muted); font-style: italic; }

.pinned-row { border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 14px; margin-bottom: 10px; background: var(--bg-mid); }
.pinned-row-meta { font-size: 12.5px; margin-bottom: 4px; }
.pinned-row-content { font-size: 13.5px; color: var(--text-normal); word-break: break-word; }

.search-results { max-height: 360px; overflow-y: auto; margin-top: 4px; }

.msg-edited-tag { font-size: 10.5px; color: var(--text-muted); }

.msg-edit-box { margin-top: 2px; }
.msg-edit-box input {
  width: 100%; background: var(--bg-light); border: 1px solid var(--accent); border-radius: var(--r-sm);
  padding: 8px 10px; font-size: 14px; color: var(--text-normal); outline: none;
}
.msg-edit-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.msg-attachments { display: flex; flex-direction: column; gap: 6px; }

.poll-block { background: var(--bg-darkest); border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 14px; margin-top: 6px; max-width: 340px; }
.poll-question { font-weight: 700; color: var(--text-bright); margin-bottom: 10px; }
.poll-option {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--bg-dark);
  margin-bottom: 6px; cursor: pointer; overflow: hidden; transition: border-color .1s;
}
.poll-option:hover { border-color: var(--accent); }
.poll-option.voted { border-color: var(--accent); }
.poll-option-fill { position: absolute; inset-inline-start: 0; top: 0; bottom: 0; background: rgba(139,92,246,.18); transition: width .2s; z-index: 0; }
.poll-option-text { position: relative; z-index: 1; font-size: 13.5px; color: var(--text-normal); }
.poll-option-pct { position: relative; z-index: 1; font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.poll-total { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.thread-pill {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; padding: 6px 12px;
  background: var(--bg-darkest); border: 1px solid var(--border); border-radius: 999px; font-size: 12.5px; color: var(--accent-hover);
  cursor: pointer; transition: border-color .1s;
}
.thread-pill:hover { border-color: var(--accent); }

.mute-icon { display: inline-flex; align-items: center; opacity: .6; margin-inline-start: 4px; }
.timeout-badge { display: inline-flex; align-items: center; color: var(--danger); margin-inline-start: 4px; }
.inline-status-icon { display: inline-flex; align-items: center; margin-inline-start: 4px; opacity: .8; vertical-align: middle; }
.voice-limit-badge { font-size: 10.5px; color: var(--text-muted); margin-inline-start: 4px; }

#composer-wrap.drag-over #composer { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139,92,246,.2); }

.link-preview-card {
  display: flex; flex-direction: column; margin-top: 8px; max-width: 380px; border: 1px solid var(--border);
  border-radius: var(--r-md); overflow: hidden; cursor: pointer; background: var(--bg-mid); transition: background .1s;
}
.link-preview-card:hover { background: var(--bg-light); }
.link-preview-img { width: 100%; max-height: 180px; object-fit: cover; display: block; }
.link-preview-body { padding: 10px 12px; }
.link-preview-title { font-size: 13.5px; font-weight: 700; color: var(--text-bright); margin-bottom: 3px; }
.link-preview-desc { font-size: 12.5px; color: var(--text-normal); margin-bottom: 4px; line-height: 1.4; }
.link-preview-url { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.invite-card {
  display: flex; align-items: center; gap: 12px; margin-top: 8px; max-width: 380px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--bg-mid);
}
.invite-card-body { flex: 1; min-width: 0; }
.invite-card-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.invite-card-name { font-size: 15px; font-weight: 700; color: var(--text-bright); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.invite-card-count { font-size: 12px; color: var(--text-muted); }

/* Members list */
#member-list { width: 246px; background: rgba(18,20,31,.85); backdrop-filter: blur(16px); flex-shrink: 0; padding: 16px 10px; overflow-y: auto; border-inline-start: 1px solid var(--border); }
.member-group { color: var(--text-muted); font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 8px; letter-spacing: .04em; }
.member-search { margin-bottom: 8px; padding: 0 4px; }
.member-search input { width: 100%; background: var(--bg-darkest); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 8px 10px; font-size: 12.5px; color: var(--text-normal); outline: none; }
.member-search input:focus { border-color: var(--accent); }
.member-item { display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: var(--r-sm); transition: background .1s; cursor: pointer; }
.member-item:hover { background: var(--bg-lighter); }
.member-item:hover { background: var(--bg-light); }
.member-info { min-width: 0; }
.member-item .mname { font-size: 14px; color: var(--text-normal); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-custom-status { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Empty / voice / video views */
.center-view { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; color: var(--text-muted); }
.voice-hero { width: 92px; height: 92px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 34px; background: var(--gradient); box-shadow: var(--glow); }
.voice-title { color: var(--text-bright); font-size: 20px; font-weight: 800; }
.voice-sub { font-size: 14px; }

.voice-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.voice-scroll { flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center; padding-top: 32px; gap: 16px; min-height: 0; }
.call-tiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; padding: 0 24px;
  align-content: center; max-width: 1100px; margin: 0 auto;
}
.call-tile {
  width: 100%; aspect-ratio: 4 / 3; max-height: 260px; background: linear-gradient(160deg, var(--bg-light), var(--bg-lighter)); border-radius: var(--r-lg); position: relative;
  display: flex; align-items: center; justify-content: center; overflow: hidden; box-shadow: 0 10px 28px rgba(0,0,0,.4), 0 0 0 1px var(--border);
}
.call-tile video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.call-tile .tile-name { position: absolute; bottom: 8px; inset-inline-start: 10px; font-size: 13px; color: #fff; background: rgba(0,0,0,.55); padding: 3px 10px; border-radius: 20px; backdrop-filter: blur(6px); }
.call-tile .tile-avatar-big { width: 76px; height: 76px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 26px; color: #fff; font-weight: 700; background: var(--gradient); box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.stage-badge { position: absolute; top: 8px; inset-inline-start: 8px; font-size: 11px; color: #fff; background: rgba(0,0,0,.55); padding: 2px 8px; border-radius: 20px; backdrop-filter: blur(6px); }
.stage-badge.stage-hand { display: inline-flex; align-items: center; justify-content: center; top: 8px; inset-inline-end: 8px; inset-inline-start: auto; background: var(--gradient); animation: ctxIn .3s ease-out; }
.tile-mod-row { position: absolute; top: 8px; inset-inline-end: 8px; display: flex; gap: 4px; }
.tile-mod-btn { width: 24px; height: 24px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 12px; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(6px); }
.tile-mod-btn:hover { background: var(--gradient); }
.mic-ring {
  position: absolute; inset: 0; border-radius: var(--r-lg); border: 3px solid transparent; pointer-events: none;
  transition: border-color .1s, box-shadow .1s;
}
.mic-ring.speaking { border-color: var(--online); box-shadow: 0 0 20px rgba(34,197,94,.5) inset; }

.soundboard { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; padding: 4px 24px 0; }
.soundboard-btn {
  width: 44px; height: 44px; border-radius: 50%; background: var(--bg-light); font-size: 18px;
  display: flex; align-items: center; justify-content: center; transition: background .1s, transform .08s;
}
.soundboard-btn:hover { background: var(--bg-lighter); transform: scale(1.08); }
.soundboard-btn:active { transform: scale(.95); }
.soundboard-mute-btn.active { background: var(--danger); color: #fff; }

.tile-status-badge {
  position: absolute; bottom: 8px; inset-inline-end: 10px; font-size: 14px; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0,0,0,.6); color: #fff; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(6px);
}
.tile-status-badge.deaf { background: rgba(244,63,94,.8); }
.tile-status-badge.relay-badge {
  bottom: auto; top: 8px; inset-inline-end: 8px; width: 24px; height: 24px; background: rgba(234,179,8,.75);
}
.tile-soundboard-badge {
  position: absolute; top: 8px; inset-inline-start: 8px; font-size: 18px; width: 32px; height: 32px; border-radius: 50%;
  background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; backdrop-filter: blur(6px);
  box-shadow: 0 0 0 2px var(--accent); animation: soundboardPop .3s ease-out, soundboardPulse 1s ease-in-out infinite;
}
@keyframes soundboardPop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes soundboardPulse { 0%, 100% { box-shadow: 0 0 0 2px var(--accent); } 50% { box-shadow: 0 0 0 5px rgba(139,92,246,.3); } }

.voice-chat-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; border-top: 1px solid var(--border); margin-top: 12px; }
.voice-chat-panel #message-list { max-height: 220px; }

.call-controls { display: flex; gap: 14px; padding: 18px; justify-content: center; flex-shrink: 0; border-top: 1px solid var(--border); }
.call-btn {
  width: 54px; height: 54px; border-radius: 50%; background: var(--bg-light); color: var(--text-bright);
  display: flex; align-items: center; justify-content: center; font-size: 19px; transition: background .12s, transform .1s, box-shadow .12s;
}
.call-btn:hover { background: var(--bg-lighter); transform: translateY(-3px); box-shadow: 0 6px 16px rgba(0,0,0,.35); }
.call-btn.danger { background: var(--danger); }
.call-btn.danger:hover { background: #d3324f; }
.call-btn.active { background: var(--gradient); box-shadow: var(--glow); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(6,7,12,.72); backdrop-filter: blur(4px); display: flex;
  align-items: center; justify-content: center; z-index: 50; animation: fadeIn .12s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal { background: var(--bg-dark); border: 1px solid var(--border); border-radius: var(--r-lg); width: 440px; max-width: 90vw; padding: 26px; animation: modalIn .18s cubic-bezier(.2,.9,.3,1); box-shadow: 0 30px 70px rgba(0,0,0,.55); }
.modal.modal-wide { width: 560px; }
.modal.modal-settings { width: 760px; max-width: 92vw; padding: 0; display: flex; height: 74vh; max-height: 640px; overflow: hidden; }
.settings-sidebar { width: 200px; flex-shrink: 0; background: var(--bg-darkest); border-inline-end: 1px solid var(--border); padding: 18px 10px; overflow-y: auto; }
.settings-sidebar h2 { padding: 0 10px; margin-bottom: 14px; }
.settings-tab { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-sm); font-size: 14px; font-weight: 600; color: var(--text-muted); cursor: pointer; margin-bottom: 2px; transition: background .1s, color .1s; }
.settings-tab:hover { background: var(--bg-lighter); color: var(--text-normal); }
.settings-tab.active { background: var(--accent); color: #fff; }
.settings-tab.danger { color: var(--danger); margin-top: 12px; border-top: 1px solid var(--border); padding-top: 14px; }
.settings-tab.danger:hover { background: rgba(244,63,94,.12); }
.settings-content { flex: 1; overflow-y: auto; padding: 24px 28px; }
.settings-content h3 { color: var(--text-bright); font-size: 17px; font-weight: 800; margin-bottom: 16px; }
.role-row { display: flex; align-items: center; gap: 10px; padding: 10px 8px; border-top: 1px solid var(--border); }
.role-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.role-row .rname { font-weight: 700; color: var(--text-bright); font-size: 14px; }
.role-row .rperms { font-size: 11px; color: var(--text-muted); }
.perm-check-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13px; color: var(--text-normal); }
.perm-check-row input { width: 16px; height: 16px; accent-color: var(--accent); }
.role-color-row { display: flex; gap: 6px; margin: 6px 0 12px; flex-wrap: wrap; }
.member-role-row { display: flex; align-items: center; gap: 10px; padding: 10px 8px; border-top: 1px solid var(--border); }
.modal h2 { display: flex; align-items: center; gap: 9px; color: var(--text-bright); font-size: 19px; font-weight: 800; margin-bottom: 18px; }
.modal-title-icon { flex-shrink: 0; opacity: .9; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.field input, .field select {
  width: 100%; background: var(--bg-darkest); color: var(--text-normal); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 11px;
  font-size: 14px; outline: none; transition: border-color .12s, box-shadow .12s;
}
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139,92,246,.15); }
select, .field select option, select option { background: var(--bg-dark); color: var(--text-normal); }
.color-row { display: flex; gap: 8px; margin-top: 4px; }
.color-dot { width: 28px; height: 28px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: transform .1s; }
.color-dot:hover { transform: scale(1.15); }
.color-dot.selected { border-color: #fff; transform: scale(1.1); box-shadow: 0 0 0 2px rgba(255,255,255,.2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.confirm-modal { width: 400px; }
.confirm-message { color: var(--text-normal); font-size: 14.5px; line-height: 1.7; }

/* Profile modal */
.profile-modal { padding: 0; overflow: hidden; width: 380px; }
.profile-banner { height: 80px; }
.profile-head { padding: 0 22px; margin-top: -42px; }
.profile-head .avatar { border: 5px solid var(--bg-dark); }
.profile-body { padding: 14px 22px 22px; }
.profile-name { font-size: 19px; font-weight: 800; color: var(--text-bright); }
.profile-username-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.profile-custom-status { font-size: 13px; color: var(--text-normal); margin-top: 8px; }
.profile-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.profile-sep { height: 1px; background: var(--border); margin: 16px 0; }
.profile-info { display: flex; flex-direction: column; gap: 8px; }
.profile-info-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-normal); }
.profile-actions { display: flex; gap: 8px; margin-top: 18px; }
.profile-actions .btn { flex: 1; }
.btn { padding: 10px 20px; border-radius: var(--r-sm); font-size: 14px; font-weight: 700; transition: background .12s, transform .06s, box-shadow .12s; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--gradient); color: #fff; box-shadow: 0 4px 14px rgba(139,92,246,.35); }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost { color: var(--text-normal); }
.btn-ghost:hover { text-decoration: underline; }
.btn-toggle-option.btn-ghost { background: var(--bg-darkest); border: 1px solid var(--border); }
.btn-toggle-option.btn-ghost:hover { background: var(--bg-lighter); text-decoration: none; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--bg-lighter); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* Auth screen */
#app.auth-app {
  display: flex; align-items: center; justify-content: center; width: 100%;
  background:
    radial-gradient(circle at 20% 15%, rgba(139,92,246,.22), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(6,182,212,.16), transparent 40%),
    var(--bg-darkest);
}
.auth-card { position: relative; width: 400px; max-width: 90vw; background: rgba(18,20,31,.9); backdrop-filter: blur(20px); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 34px; box-shadow: 0 30px 80px rgba(0,0,0,.55); animation: modalIn .22s cubic-bezier(.2,.9,.3,1); }
.auth-lang-row-top { position: absolute; top: 14px; inset-inline-end: 14px; margin-top: 0; }
.auth-logo-row { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 20px; }
.auth-logo-big { width: 42px; height: 42px; border-radius: var(--r-md); background: var(--gradient); color: #fff; font-weight: 800; font-size: 18px; display: flex; align-items: center; justify-content: center; box-shadow: var(--glow); }
.auth-brand { font-size: 21px; font-weight: 800; color: var(--text-bright); }
.auth-title { color: var(--text-bright); font-size: 21px; font-weight: 800; text-align: center; margin-bottom: 4px; }
.auth-sub { color: var(--text-muted); font-size: 14px; text-align: center; margin-bottom: 22px; }
.auth-error { background: rgba(244,63,94,.15); border: 1px solid var(--danger); color: #ffb3c0; font-size: 13px; padding: 10px 12px; border-radius: var(--r-sm); margin-bottom: 14px; }
.auth-submit { width: 100%; padding: 13px; margin-top: 6px; }
.auth-switch { text-align: center; margin-top: 18px; font-size: 13px; color: var(--text-muted); }
.auth-switch a { color: var(--accent2); cursor: pointer; }
.auth-hint { text-align: center; font-size: 11px; color: var(--text-muted); margin-top: 20px; }
.auth-lang-row { display: flex; justify-content: center; gap: 8px; margin-top: 14px; }
.lang-btn { font-size: 11px; padding: 5px 12px; border-radius: 999px; color: var(--text-muted); background: var(--bg-darkest); border: 1px solid var(--border); }
.lang-btn.active { color: #fff; background: var(--gradient); border-color: transparent; }

/* Friends panel */
#friends-view { flex: 1; display: flex; flex-direction: column; }
.friends-toolbar { display: flex; align-items: center; gap: 18px; padding: 0 18px; height: 52px; border-bottom: 1px solid var(--border); flex-shrink: 0; background: rgba(23,25,40,.6); backdrop-filter: blur(10px); }
.friends-tab { color: var(--text-muted); font-size: 14px; font-weight: 700; padding: 4px 2px; transition: color .1s; }
.friends-tab.active { color: var(--text-bright); }
.friends-body { flex: 1; overflow-y: auto; padding: 18px 22px; }
.add-friend-box { display: flex; gap: 10px; align-items: center; background: var(--bg-light); padding: 14px 16px; border-radius: var(--r-md); margin-bottom: 20px; border: 1px solid var(--border); }
.add-friend-box input { flex: 1; background: var(--bg-darkest); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px; color: var(--text-normal); outline: none; }
.add-friend-box input:focus { border-color: var(--accent); }
.section-label { color: var(--text-muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin: 10px 0 6px; }
.friend-row { display: flex; align-items: center; gap: 12px; padding: 11px 9px; border-top: 1px solid var(--border); border-radius: var(--r-sm); transition: background .1s; }
.friend-row:hover { background: var(--bg-light); }
.friend-row .fname { font-weight: 700; color: var(--text-bright); font-size: 15px; }
.friend-row .fstatus { font-size: 12px; color: var(--text-muted); }
.friend-row .spacer { flex: 1; }
.row-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--bg-light); display: flex; align-items: center; justify-content: center; color: var(--text-normal); transition: background .1s, transform .1s; }
.row-btn:hover { background: var(--bg-lighter); transform: translateY(-1px); }
.row-btn.accept:hover { background: var(--online); color: #fff; }
.row-btn.decline:hover, .row-btn.danger:hover { background: var(--danger); color: #fff; }
.empty-hint { color: var(--text-muted); font-size: 14px; text-align: center; padding: 40px 0; }

.role-badge { font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 20px; background: var(--bg-lighter); color: var(--text-muted); text-transform: uppercase; letter-spacing: .02em; }
.role-badge.owner { background: rgba(240,178,50,.18); color: var(--idle); }
.role-badge.admin { background: rgba(34,197,94,.18); color: var(--online); }

.member-item { position: relative; }
.member-actions { display: none; position: absolute; inset-inline-end: 8px; top: 50%; transform: translateY(-50%); gap: 4px; }
.member-item:hover .member-actions { display: flex; }
.member-actions button { width: 26px; height: 26px; border-radius: var(--r-sm); background: var(--bg-lighter); font-size: 11px; transition: background .1s; }
.member-actions button:hover { background: var(--accent); color: #fff; }

#toast-host {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 500;
  display: flex; flex-direction: column-reverse; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  background: var(--bg-lighter); color: var(--text-bright); padding: 11px 20px; border-radius: 999px; font-size: 13px;
  box-shadow: 0 10px 28px rgba(0,0,0,.45); border: 1px solid var(--border); max-width: min(80vw, 420px);
  text-align: center; animation: toastIn .18s ease-out; pointer-events: auto;
}
.toast.toast-out { animation: toastOut .2s ease-in forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-6px); } }

#update-banner {
  position: fixed; top: 32px; inset-inline: 0; z-index: 150; background: var(--gradient);
  color: #fff; display: flex; align-items: center; justify-content: center; gap: 16px; padding: 9px 16px; font-size: 13px; font-weight: 700;
  animation: fadeIn .2s ease-out; box-shadow: 0 4px 16px rgba(0,0,0,.35);
}
#update-banner .btn-primary { background: rgba(255,255,255,.22); box-shadow: none; }
#update-banner .btn-primary:hover { background: rgba(255,255,255,.34); }

#dmcall-overlay {
  position: fixed; top: 44px; left: 50%; transform: translateX(-50%); z-index: 160;
  background: rgba(18,20,31,.92); backdrop-filter: blur(16px); border: 1px solid var(--border); border-radius: 999px; padding: 12px 18px;
  display: flex; align-items: center; gap: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.55); animation: modalIn .2s cubic-bezier(.2,.9,.3,1);
}
#dmcall-overlay span { color: var(--text-bright); font-weight: 700; font-size: 14px; white-space: nowrap; }
#dmcall-overlay .btn { border-radius: 999px; }

.spinner-wrap { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-muted); }

/* Context menu */
.ctx-menu {
  position: fixed; z-index: 200; min-width: 205px; background: rgba(18,20,31,.96); backdrop-filter: blur(14px); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 6px; box-shadow: 0 16px 40px rgba(0,0,0,.55); animation: ctxIn .1s ease-out;
}
@keyframes ctxIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
.ctx-item {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 11px; border-radius: var(--r-sm); font-size: 13.5px; color: var(--text-normal); cursor: pointer; transition: background .08s;
}
.ctx-item:hover { background: var(--gradient); color: #fff; }
.ctx-item.danger { color: var(--danger); }
.ctx-item.danger:hover { background: var(--danger); color: #fff; }
.ctx-item.disabled { color: var(--text-muted); cursor: default; opacity: .5; }
.ctx-item.disabled:hover { background: none; color: var(--text-muted); }
.ctx-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.ctx-arrow { font-size: 11px; opacity: .7; }
.ctx-check { font-size: 12px; }
.ctx-item-main { display: flex; align-items: center; gap: 9px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-icon { flex-shrink: 0; opacity: .85; }
.ctx-submenu {
  /* Rendered as a sibling appended straight to <body> (see buildMenuItems), with left/top set by JS
     (positionSubmenu) so it's always clamped inside the window — the old absolute/inset-inline-end:100%
     flyout, nested inside .ctx-menu, had no viewport bounds check and could render partly or fully outside
     the app frame near an edge; nesting it under .ctx-menu also broke position:fixed math, since
     .ctx-menu's own backdrop-filter makes it a containing block for fixed descendants. */
  display: none; position: fixed; z-index: 201; min-width: 190px;
  background: rgba(18,20,31,.96); backdrop-filter: blur(14px); border: 1px solid var(--border); border-radius: var(--r-md); padding: 6px;
  box-shadow: 0 16px 40px rgba(0,0,0,.55);
}

/* optimistic (not yet confirmed) messages */
.msg-row.pending { opacity: 0.6; }
.msg-row.pending .msg-toolbar { display: none; }

/* badges, voice messages, web mode */
.user-badge { display: inline-flex; align-items: center; margin-inline-start: 4px; cursor: default; }
.user-badge-chip { display: inline-flex; align-items: center; gap: 5px; }
.user-badge-chip { background: var(--bg-light); color: var(--text-normal); }
.msg-attachment-audio { display: block; max-width: 300px; width: 100%; height: 40px; margin-top: 4px; }
.voice-rec-bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; }
.voice-rec-bar .rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #ef4444; animation: rec-pulse 1s infinite; }
.voice-rec-bar .rec-timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text-bright); }
.voice-rec-bar .rec-label { color: var(--text-muted); font-size: 13px; }
.voice-rec-bar .rec-send { background: var(--accent); color: #fff; border-radius: 50%; }
@keyframes rec-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
body.web #titlebar { display: none; }
body.web #app { height: 100%; }

/* composer textarea + markdown blocks */
#composer textarea { flex: 1; background: transparent; border: none; outline: none; padding: 12px 6px; font-size: 14px; line-height: 1.5; color: var(--text-normal); resize: none; max-height: 160px; font-family: inherit; }
#composer textarea::placeholder { color: var(--text-muted); }
.msg-content del { opacity: .7; }
.msg-content .md-h { font-weight: 800; color: var(--text-bright); margin: 4px 0 2px; }
.msg-content .md-h1 { font-size: 1.5em; }
.msg-content .md-h2 { font-size: 1.25em; }
.msg-content .md-h3 { font-size: 1.1em; }
.msg-content .md-quote { border-inline-start: 3px solid var(--accent); padding: 2px 10px; margin: 2px 0; color: var(--text-muted); background: rgba(255,255,255,.03); border-radius: 4px; }
.msg-content .md-li { position: relative; padding-inline-start: 18px; margin: 1px 0; }
.msg-content .md-li:not(.md-ol)::before { content: '•'; position: absolute; inset-inline-start: 4px; color: var(--accent); }
.msg-content .md-num { position: absolute; inset-inline-start: 0; color: var(--accent); font-variant-numeric: tabular-nums; }
.msg-content .md-ol { padding-inline-start: 24px; }

/* stickers */
.msg-sticker { width: 160px; height: 160px; object-fit: contain; display: block; margin-top: 4px; }
.sticker-picker { width: 340px; }
.sticker-tabs { display: flex; gap: 6px; padding: 8px 8px 0; flex-wrap: wrap; }
.sticker-tab { padding: 4px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 700; color: var(--text-muted); background: transparent; }
.sticker-tab.active { background: var(--bg-lighter, rgba(255,255,255,.08)); color: var(--text-bright); }
.sticker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 10px; max-height: 280px; overflow-y: auto; }
.sticker-grid img { width: 100%; aspect-ratio: 1; object-fit: contain; cursor: pointer; border-radius: 10px; transition: transform .12s; }
.sticker-grid img:hover { transform: scale(1.08); }
.sticker-picker { max-height: none; overflow: visible; padding: 0; }

/* forum channels + rules gate */
.forum-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.forum-bar { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.forum-bar-title { font-weight: 800; font-size: 16px; color: var(--text-bright); }
.forum-list { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.forum-card { background: var(--bg-mid, var(--bg-dark)); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; cursor: pointer; transition: border-color .15s, transform .15s; }
.forum-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.forum-card-title { font-size: 16px; font-weight: 800; color: var(--text-bright); margin-bottom: 4px; }
.forum-card-body { font-size: 13.5px; color: var(--text-normal); line-height: 1.6; margin-bottom: 8px; word-break: break-word; }
.forum-card-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.forum-replies { margin-inline-start: auto; }
.rules-card { width: min(520px, 92%); background: var(--bg-dark); border: 1px solid var(--border); border-radius: 18px; padding: 28px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.rules-card h2 { margin: 0; color: var(--text-bright); }
.rules-text { white-space: pre-wrap; text-align: start; align-self: stretch; background: var(--bg-darkest); border: 1px solid var(--border); border-radius: 12px; padding: 14px; max-height: 40vh; overflow-y: auto; line-height: 1.7; color: var(--text-normal); font-size: 14px; }
.rules-hint { font-size: 12.5px; color: var(--text-muted); }

/* ===================== Responsive / phone layout ===================== */
#nav-fab { display: none; }

@media (max-width: 900px) {
  html { --tb: 32px; --nav-w: 64px; --dir: -1; }
  html[dir="rtl"] { --dir: 1; }
  body.web { --tb: 0px; height: 100dvh; }
  @supports (height: 100dvh) { html, body { height: 100dvh; } }

  #app { position: relative; }
  #main { width: 100%; min-width: 0; }

  /* drawer: server rail + channel list slide in from the reading-start edge */
  #server-rail, #channel-sidebar {
    position: fixed; top: var(--tb); bottom: 0; z-index: 40;
    transition: transform .22s ease; box-shadow: 0 0 40px rgba(0,0,0,.5);
    transform: translateX(calc(var(--dir) * (100% + 80px)));
  }
  #server-rail { inset-inline-start: 0; width: var(--nav-w); background: rgba(10,11,18,.97); backdrop-filter: none; }
  #channel-sidebar { inset-inline-start: var(--nav-w); width: min(260px, calc(100vw - var(--nav-w) - 44px)); background: rgba(18,20,31,.98); backdrop-filter: none; }
  #app.nav-open #server-rail, #app.nav-open #channel-sidebar { transform: translateX(0); }

  #app.nav-open::after, #app.members-open::after {
    content: ''; position: fixed; inset: var(--tb) 0 0 0; background: rgba(0,0,0,.55); z-index: 30;
  }

  #member-list {
    position: fixed; top: var(--tb); bottom: 0; inset-inline-end: 0; width: min(290px, 86vw); z-index: 40;
    background: rgba(18,20,31,.98); backdrop-filter: none; box-shadow: 0 0 40px rgba(0,0,0,.5);
  }

  #nav-fab {
    display: flex; align-items: center; justify-content: center; position: fixed; z-index: 20;
    top: calc(var(--tb) + 9px); inset-inline-start: 8px; width: 34px; height: 34px; border-radius: 10px;
    background: var(--bg-light); color: var(--text-bright); font-size: 17px; border: 1px solid var(--border);
  }
  #nav-fab.unread::after { content: ''; position: absolute; top: -3px; inset-inline-end: -3px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger, #f43f5e); }
  #app.nav-open #nav-fab { display: none; }

  /* headers leave room for the menu button */
  #chat-header, .friends-toolbar, .forum-bar { padding-inline-start: 52px; }
  #chat-header .cname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .friends-toolbar { overflow-x: auto; gap: 14px; }
  .friends-tab { white-space: nowrap; }
  .friends-body { padding: 14px; }

  /* composer + messages */
  #composer-wrap { padding: 0 8px calc(8px + env(safe-area-inset-bottom)); }
  .composer-icon-btn { width: 32px; height: 32px; font-size: 16px; flex-shrink: 0; }
  #composer { padding: 0 4px; }
  input, textarea, select, #composer textarea { font-size: 16px; }
  .msg-row { padding-inline: 10px; }
  .msg-attachment-img { max-width: 100%; height: auto; }
  .msg-sticker { width: 120px; height: 120px; }
  .emoji-picker { inset-inline-end: 8px; inset-inline-start: 8px; width: auto; }
  .sticker-picker { width: auto; }
  .forum-list, .forum-bar { padding-inline-end: 12px; }

  /* modals become near full-screen sheets */
  .modal-backdrop { align-items: flex-end; }
  .modal, .modal.modal-wide { width: 100%; max-width: 100vw; max-height: 92dvh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
  .modal.confirm-modal { align-self: center; width: 92vw; border-radius: 18px; }
  .modal.modal-settings { flex-direction: column; height: 92dvh; max-height: 92dvh; width: 100%; padding: 0; overflow: hidden; }
  .settings-sidebar { width: auto; display: flex; flex-direction: row; align-items: center; overflow-x: auto; overflow-y: hidden; padding: 8px; border-inline-end: none; border-bottom: 1px solid var(--border); flex-shrink: 0; gap: 4px; }
  .settings-sidebar h2 { display: none; }
  .settings-tab { white-space: nowrap; margin: 0; flex-shrink: 0; padding: 8px 12px; }
  .settings-tab.danger { margin: 0; border-top: none; padding-top: 8px; }
  .settings-content { padding: 16px; }
  .modal-actions { flex-wrap: wrap; }
  .discover-card { flex-wrap: wrap; }
  .rules-card { padding: 20px; }
  .auth-card { padding: 24px 20px; }
  .profile-modal { padding: 0; }
}

@media (max-width: 420px) {
  #composer-wrap .composer-icon-btn[title] { width: 28px; }
}

/* profile notes, volume button */
.profile-note-label { font-size: 11.5px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin: 4px 0 6px; }
.profile-note { width: 100%; background: var(--bg-darkest); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 13px; color: var(--text-normal); resize: none; outline: none; font-family: inherit; user-select: text; }
.profile-note:focus { border-color: var(--accent); }
.call-tile { position: relative; }
.tile-vol-btn { position: absolute; top: 8px; inset-inline-end: 8px; width: 30px; height: 30px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .15s; }
.call-tile:hover .tile-vol-btn { opacity: 1; }
@media (hover: none) { .tile-vol-btn { opacity: .85; } }

/* call spotlight */
.call-tile { cursor: pointer; }
.call-tiles.has-spotlight { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); max-width: 1300px; }
.call-tiles.has-spotlight .call-tile { max-height: 110px; aspect-ratio: 16 / 9; }
.call-tiles.has-spotlight .call-tile.spotlighted { grid-column: 1 / -1; order: -1; max-height: 58vh; aspect-ratio: 16 / 9; box-shadow: 0 0 0 2px var(--accent), 0 16px 40px rgba(0,0,0,.5); }
.screen-tile.spotlight { width: min(1200px, 96%); }
.msg-edited-tag:hover { text-decoration: underline; }

/* giveaways + watch together */
.giveaway-card { margin-top: 8px; max-width: 420px; background: linear-gradient(135deg, rgba(139,92,246,.16), rgba(6,182,212,.10)); border: 1px solid var(--accent); border-radius: 14px; padding: 12px 14px; }
.giveaway-card.ended { opacity: .8; border-color: var(--border); }
.giveaway-prize { font-weight: 800; font-size: 15px; color: var(--text-bright); }
.giveaway-meta { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }
.giveaway-winners { margin-top: 6px; font-weight: 700; color: var(--text-bright); }
#watch-panel { position: fixed; z-index: 45; bottom: 96px; inset-inline-end: 18px; width: min(400px, calc(100vw - 36px)); background: var(--bg-dark); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 18px 50px rgba(0,0,0,.6); overflow: hidden; }
#watch-panel .watch-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; background: var(--bg-darkest); }
#watch-panel .watch-title { font-size: 12.5px; font-weight: 700; color: var(--text-bright); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#watch-panel iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; background: #000; }
@media (max-width: 900px) { #watch-panel { bottom: 84px; inset-inline-end: 8px; width: calc(100vw - 16px); } }
.auth-hint a { color: var(--accent2); text-decoration: none; cursor: pointer; } .auth-hint a:hover { text-decoration: underline; }

.notification-bell-btn { position: relative; }
.notification-bell-btn.has-unread::after {
  content: ''; position: absolute; top: 3px; inset-inline-end: 3px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--danger); border: 2px solid var(--bg-mid); box-shadow: 0 0 6px rgba(244,63,94,.6);
}

/* ---------- Nitro ---------- */
.nitro-name { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 800; }
.custom-emoji-picker-section { max-height: 140px; overflow-y: auto; }
.emoji-picker-server-label { font-size: 10px; color: var(--text-muted); padding: 4px 2px 1px; opacity: .8; }
.nitro-page { width: 720px; max-width: 92vw; }
.nitro-hero {
  position: relative; border-radius: 16px; padding: 34px 26px; margin-bottom: 20px; overflow: hidden; text-align: center;
  background: radial-gradient(circle at 30% 20%, rgba(139,92,246,.5), transparent 55%), radial-gradient(circle at 80% 70%, rgba(6,182,212,.4), transparent 55%), var(--bg-mid);
  border: 1px solid rgba(139,92,246,.4);
}
.nitro-hero h2 { font-size: 26px; font-weight: 900; color: #fff; text-transform: uppercase; letter-spacing: .01em; margin-bottom: 8px; }
.nitro-hero p { color: var(--text-normal); font-size: 14px; max-width: 480px; margin: 0 auto; }
.nitro-hero .nitro-hero-badge {
  display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.1); border-radius: 999px; padding: 6px 14px;
  font-size: 12.5px; color: #fff; margin-top: 14px;
}
.nitro-plans { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
@media (max-width: 600px) { .nitro-plans { grid-template-columns: 1fr; } }
.nitro-plan {
  background: var(--bg-mid); border: 1px solid var(--border); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 12px;
}
.nitro-plan.full { border-color: rgba(139,92,246,.6); background: linear-gradient(160deg, rgba(139,92,246,.14), rgba(6,182,212,.08)), var(--bg-mid); }
.nitro-plan-title { font-size: 17px; font-weight: 800; color: var(--text-bright); text-transform: uppercase; }
.nitro-plan ul { list-style: none; display: flex; flex-direction: column; gap: 9px; }
.nitro-plan li { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--text-normal); }
.nitro-plan li svg { flex-shrink: 0; color: var(--accent2); }
.nitro-plan-status { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); font-size: 12.5px; font-weight: 700; text-align: center; border-radius: 8px; padding: 8px; }
.nitro-plan-status.active { background: rgba(34,197,94,.15); color: var(--online); }
.nitro-plan-status.inactive { background: rgba(255,255,255,.05); color: var(--text-muted); }
.nitro-note { margin-top: 18px; font-size: 12.5px; color: var(--text-muted); text-align: center; line-height: 1.8; }
