:root {
  /* Discord dark theme palette */
  --bg: #313338;          /* основной фон чата (как у Discord) */
  --bg2: #2b2d31;         /* фон сайдбара каналов */
  --rail: #1e1f22;        /* левый рейл серверов */
  --side: #2b2d31;        /* сайдбар */
  --main: #313338;        /* область сообщений */
  --panel: #2b2d31;
  --panel2: #383a40;      /* hover/active */
  --accent: #5865f2;      /* Discord blurple */
  --accent-2: #7984f5;
  --accent-hover: #4752c4;
  --border: #1e1f22;
  --border-soft: #26282c;
  --text: #f2f3f5;
  --text-dim: #b5bac1;
  --text-muted: #949ba4;
  --green: #23a55a;
  --idle: #f0b232;
  --dnd: #f23f43;
  --nitro: linear-gradient(135deg,#5865f2,#a78bfa,#ff73fa);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: var(--bg); color: var(--text);
  font-family: 'Inter', 'gg sans', system-ui, sans-serif; overflow: hidden; overscroll-behavior: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; }
.hidden { display: none !important; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #1a1b1e; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== AUTH ===== */
#auth { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 30% 20%, rgba(88,101,242,0.20), transparent 55%),
              radial-gradient(ellipse at 80% 80%, rgba(121,132,245,0.12), transparent 60%), var(--bg); padding: 20px; }
.auth-card { width: 100%; max-width: 410px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 20px; padding: 34px 28px; box-shadow: 0 20px 60px rgba(0,0,0,0.55); }
.auth-logo { font-size: 42px; font-weight: 900; text-align: center; letter-spacing: -2px; }
.auth-logo span { color: var(--accent); text-shadow: 0 0 24px rgba(88,101,242,0.6); }
.auth-sub { text-align: center; color: var(--text-dim); font-size: 13px; margin: 6px 0 26px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; letter-spacing: .5px; }
.field input { width: 100%; padding: 13px 14px; background: #1e1f22; border: 1px solid var(--border); border-radius: 11px; color: var(--text); font-size: 15px; outline: none; transition: border-color .2s; }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(88,101,242,0.15); }
.auth-btn { width: 100%; padding: 14px; margin-top: 8px; border-radius: 11px; background: linear-gradient(135deg, var(--accent), var(--accent-hover)); color: #fff; font-weight: 800; font-size: 15px; box-shadow: 0 6px 24px rgba(88,101,242,0.3); }
.auth-btn:active { transform: scale(.98); }
.auth-err { color: #ff8a8a; font-size: 13px; text-align: center; margin-top: 12px; min-height: 18px; }
.auth-hint { font-size: 12px; color: var(--text-muted); text-align: center; margin-top: 10px; line-height: 1.5; }

/* ===== APP LAYOUT ===== */
#app { display: none; height: 100%; }
#app.show { display: flex; }

/* Server rail */
.rail { width: 72px; background: var(--rail); flex-shrink: 0; display: flex; flex-direction: column; align-items: center;
  padding: 12px 0; gap: 8px; overflow-y: auto; padding-top: calc(12px + env(safe-area-inset-top)); }
.rail::-webkit-scrollbar { display: none; }
.rail-item { width: 48px; height: 48px; border-radius: 50%; background: var(--panel); display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800; color: var(--text); cursor: pointer; transition: border-radius .18s, background .18s; position: relative; flex-shrink: 0; overflow: hidden; }
.rail-item img { width: 100%; height: 100%; object-fit: cover; }
.rail-item:hover, .rail-item.active { border-radius: 16px; }
.rail-item.active::before { content: ''; position: absolute; left: -12px; top: 50%; transform: translateY(-50%); width: 4px; height: 30px; background: var(--accent); border-radius: 0 4px 4px 0; }
.rail-item.home.active { background: var(--accent); }
.rail-item.add { color: var(--green); font-size: 26px; background: var(--panel); }
.rail-item.add:hover { background: var(--green); color: #fff; border-radius: 16px; }
.rail-sep { width: 32px; height: 2px; background: #35373c; border-radius: 1px; flex-shrink: 0; }

/* Sidebar */
.sidebar { width: 250px; background: var(--side); flex-shrink: 0; display: flex; flex-direction: column; border-right: 1px solid var(--border-soft); }
.side-head { padding: 16px; padding-top: calc(16px + env(safe-area-inset-top)); font-weight: 800; font-size: 16px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; gap: 8px; min-height: 52px; }
.side-scroll { flex: 1; overflow-y: auto; padding: 8px; }
.side-section { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); padding: 12px 8px 6px; letter-spacing: .5px; display:flex; justify-content:space-between; align-items:center; }
.side-section button { color: var(--text-muted); font-size: 18px; line-height: 1; }
.side-section button:hover { color: var(--text); }

.tabs { display: flex; padding: 8px; gap: 6px; }
.tab { flex: 1; padding: 9px; color: var(--text-dim); font-size: 13px; font-weight: 700; border-radius: 9px; position: relative; }
.tab.active { background: var(--panel2); color: var(--text); }
.tab .badge { position: absolute; top: 2px; right: 6px; background: var(--accent); color: #fff; font-size: 10px; min-width: 16px; height: 16px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; padding: 0 4px; font-weight: 800; }

.search-row { padding: 8px; }
.search-row input { width: 100%; padding: 9px 12px; background: #1e1f22; border: 1px solid var(--border); border-radius: 9px; color: var(--text); font-size: 13px; outline: none; }

.chan { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 4px; cursor: pointer; color: var(--text-muted); font-size: 15px; font-weight: 500; margin: 1px 0; }
.chan:hover { background: #35373c; color: var(--text-dim); }
.chan.active { background: #404249; color: #fff; }
.chan .hash { color: var(--text-muted); font-weight: 700; }
.chan.voice { flex-wrap: wrap; }
.voice-users { width: 100%; padding-left: 26px; display: flex; flex-direction: column; gap: 3px; margin-top: 2px; }
.voice-user { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-dim); }

.friend { display: flex; align-items: center; gap: 11px; padding: 9px; border-radius: 10px; cursor: pointer; }
.friend:hover, .friend.active { background: var(--panel2); }
.friend .meta { flex: 1; min-width: 0; }
.friend .name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.friend .status { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.req-actions { display: flex; gap: 6px; }
.mini-btn { border-radius: 8px; padding: 7px 10px; font-size: 12px; font-weight: 700; color: #fff; }
.mini-btn.ok { background: var(--green); }
.mini-btn.no { background: #4e5058; }
.mini-btn.add { background: var(--accent); }
.list-empty { text-align: center; color: var(--text-muted); font-size: 13px; padding: 28px 16px; line-height: 1.6; }
.friend .badge { background: var(--dnd); color:#fff; font-size:11px; min-width:18px; height:18px; border-radius:9px; display:inline-flex; align-items:center; justify-content:center; padding:0 5px; font-weight:800; flex-shrink:0; }

/* avatar */
.av { border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; flex-shrink: 0; position: relative; overflow: visible; width: 40px; height: 40px; font-size: 16px; }
.av img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.av.sm { width: 32px; height: 32px; font-size: 13px; }
.av.lg { width: 80px; height: 80px; font-size: 32px; }
.av .dot { position: absolute; bottom: -2px; right: -2px; width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--side); background: var(--text-muted); }
.av .dot.online { background: var(--green); }
.av .dot.idle { background: var(--idle); }
.av .dot.dnd { background: var(--dnd); }
.av.anim { animation: avGlow 3s ease-in-out infinite; }
@keyframes avGlow { 0%,100%{ box-shadow: 0 0 0 0 rgba(88,101,242,0); } 50%{ box-shadow: 0 0 14px 2px rgba(88,101,242,0.45);} }

/* User panel (bottom of sidebar) */
.userpanel { display: flex; align-items: center; gap: 9px; padding: 9px; background: var(--bg2); border-top: 1px solid var(--border-soft); padding-bottom: calc(9px + env(safe-area-inset-bottom)); }
.userpanel .meta { flex: 1; min-width: 0; cursor: pointer; }
.userpanel .name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.userpanel .sub { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.userpanel .ctrls { display: flex; gap: 2px; }
.icon-btn { width: 34px; height: 34px; border-radius: 8px; color: var(--text-dim); font-size: 17px; display: flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--panel2); color: #fff; }
.icon-btn.on { color: var(--green); }
.icon-btn.danger { color: var(--accent-2); }

/* Main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--main); }
.main-header { min-height: 52px; padding: 0 16px; padding-top: env(safe-area-inset-top); display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border-soft); font-weight: 700; }
.main-header .back { display: none; font-size: 24px; }
.main-header .title { flex: 1; display: flex; align-items: center; gap: 9px; min-width: 0; }
.main-header .title .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main-header .actions { display: flex; gap: 4px; }
.main-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.welcome-screen { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:14px; color: var(--text-muted); text-align:center; padding:30px; }
.welcome-screen .big { font-size: 60px; opacity:.5; }

/* Messages */
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 2px; }
.msg-row { display: flex; gap: 12px; padding: 4px 4px; border-radius: 8px; position: relative; }
.msg-row:hover { background: rgba(255,255,255,0.02); }
.msg-row.cont { padding-top: 1px; }
.msg-row.cont .msg-av { visibility: hidden; height: 0; }
.msg-av { flex-shrink: 0; }
.msg-content { flex: 1; min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-author { font-weight: 600; font-size: 15px; }
.msg-badge { font-size: 11px; }
.msg-time { font-size: 12px; color: var(--text-muted); }
.msg-text { font-size: 15px; line-height: 1.375; word-break: break-word; white-space: pre-wrap; color: #dbdee1; }
.msg-reacts { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
.react { background: var(--panel2); border: 1px solid var(--border-soft); border-radius: 9px; padding: 2px 8px; font-size: 13px; display: inline-flex; gap: 4px; align-items: center; cursor: pointer; }
.react.mine { border-color: var(--accent); background: rgba(88,101,242,0.15); }
.react-add { opacity: 0; position: absolute; right: 8px; top: 2px; background: var(--panel2); border: 1px solid var(--border-soft); border-radius: 8px; padding: 3px 7px; font-size: 14px; }
.msg-row:hover .react-add { opacity: 1; }

/* DM bubbles */
.dm-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 78%; padding: 9px 13px; border-radius: 16px; font-size: 15px; line-height: 1.4; word-break: break-word; position: relative; }
.bubble .t { display: block; font-size: 10px; color: rgba(255,255,255,.45); margin-top: 3px; text-align: right; }
.bubble.them { align-self: flex-start; background: var(--panel2); border-bottom-left-radius: 5px; }
.bubble.me { align-self: flex-end; background: linear-gradient(135deg,var(--accent),var(--accent-hover)); border-bottom-right-radius: 5px; }

.typing { color: var(--text-muted); font-size: 12px; padding: 2px 16px; height: 18px; }

.composer { display: flex; gap: 8px; padding: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); align-items: flex-end; }
.composer .inwrap { flex: 1; display: flex; align-items: flex-end; background: var(--panel2); border: 1px solid var(--border-soft); border-radius: 14px; padding: 4px 6px 4px 12px; }
.composer textarea { flex: 1; resize: none; max-height: 120px; padding: 9px 0; background: none; border: none; color: var(--text); font-size: 15px; outline: none; }
.composer .emoji-btn { font-size: 20px; padding: 6px; align-self: flex-end; }
.send-btn { width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg,var(--accent),var(--accent-hover)); color: #fff; font-size: 19px; flex-shrink: 0; }
.send-btn:active { transform: scale(.92); }

/* Member list */
.members { width: 220px; background: var(--side); flex-shrink: 0; border-left: 1px solid var(--border-soft); overflow-y: auto; padding: 12px 8px; display: none; }
.members.show { display: block; }
.members .mtitle { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); padding: 8px; }

/* Voice bar */
.voice-bar { background: var(--bg2); border-top: 1px solid var(--border-soft); padding: 10px 12px; display: flex; align-items: center; gap: 10px; }
.voice-bar .vinfo { flex: 1; min-width: 0; }
.voice-bar .vstate { color: var(--green); font-weight: 700; font-size: 13px; }
.voice-bar .vchan { font-size: 12px; color: var(--text-muted); }
.voice-bar .vbtn { width: 40px; height: 40px; border-radius: 10px; background: var(--panel2); font-size: 18px; display: flex; align-items: center; justify-content: center; }
.voice-bar .vbtn.active { background: var(--accent); }
.voice-bar .vbtn.leave { background: var(--accent); color: #fff; }

/* Call overlay — Discord-style */
#call { position: fixed; inset: 0; z-index: 200; background: #000; display: none; flex-direction: column; }
#call.show { display: flex; }
.call-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; position: relative; padding: 20px; }
.call-stage video { width: 100%; height: 100%; object-fit: contain; border-radius: 16px; background: #000; }
.call-stage .call-pip { position: absolute; right: 20px; bottom: 20px; width: 220px; height: 140px; object-fit: cover; border-radius: 12px; border: 2px solid var(--border); box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.call-bigav { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.call-bigav .av { width: 130px; height: 130px; font-size: 52px; animation: callPulse 1.8s ease-out infinite; }
.call-bigname { font-size: 26px; font-weight: 800; }
@keyframes callPulse { 0%{box-shadow:0 0 0 0 rgba(88,101,242,.5);} 100%{box-shadow:0 0 0 28px rgba(88,101,242,0);} }
.call-meta { text-align: center; padding-bottom: 6px; }
#call .cstatus { color: var(--text-dim); font-size: 15px; }
#call .ctimer { font-size: 16px; color: var(--green); font-variant-numeric: tabular-nums; margin-top: 2px; }
.call-controls { display: flex; gap: 16px; justify-content: center; padding: 24px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
.call-btn { width: 60px; height: 60px; border-radius: 50%; font-size: 24px; color: #fff; display: flex; align-items: center; justify-content: center; background: #4e5058; transition: .15s; }
.call-btn:hover { background: #6d6f78; }
.call-btn.on { background: #fff; color: #111; }
.call-btn.off { background: var(--accent); }
.call-btn.end { background: var(--dnd); }
.call-btn.end:hover { background: #d83c40; }
.call-btn.accept { background: var(--green); }
.call-btn:active { transform: scale(.92); }

/* Call top bar (свернуть) */
.call-topbar { display:flex; align-items:center; gap:12px; padding:14px 18px; padding-top:calc(14px + env(safe-area-inset-top)); color:var(--text); font-weight:700; font-size:15px; }
.call-min { width:36px; height:36px; border-radius:50%; background:rgba(255,255,255,.08); color:#fff; font-size:20px; display:flex; align-items:center; justify-content:center; }
.call-min:hover { background:rgba(255,255,255,.16); }

/* Mini-call bar — звонок свёрнут, приложение доступно */
#miniCall { position:fixed; left:50%; transform:translateX(-50%); bottom:calc(16px + env(safe-area-inset-bottom)); z-index:190;
  display:none; align-items:center; gap:10px; background:var(--bg2); border:1px solid var(--border-soft); border-radius:14px;
  padding:8px 10px; box-shadow:0 10px 40px rgba(0,0,0,.55); max-width:calc(100vw - 24px); }
#miniCall.show { display:flex; }
#miniCall .mini-av .av { width:38px; height:38px; }
#miniCall .mini-info { min-width:0; }
#miniCall .mini-name { font-weight:700; font-size:14px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:140px; }
#miniCall .mini-timer { font-size:12px; color:var(--green); font-variant-numeric:tabular-nums; }
#miniCall .mini-btn { width:38px; height:38px; border-radius:50%; background:var(--panel2); color:#fff; font-size:17px; display:flex; align-items:center; justify-content:center; }
#miniCall .mini-btn.off { background:var(--accent); }
#miniCall .mini-btn.end { background:var(--dnd); }
#miniCall .mini-expand { width:32px; height:32px; border-radius:8px; background:transparent; color:var(--text-dim); font-size:16px; }
#miniCall .mini-expand:hover { background:var(--panel2); color:#fff; }

/* Modal */
.modal-bg { position: fixed; inset: 0; z-index: 150; background: rgba(0,0,0,.65); display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-bg.show { display: flex; }
.modal { width: 100%; max-width: 460px; background: var(--panel); border: 1px solid var(--border); border-radius: 18px; padding: 24px; max-height: 88vh; overflow-y: auto; }
.modal h3 { font-size: 19px; margin-bottom: 16px; }
.modal .field input, .modal .field textarea { width: 100%; padding: 12px; background: #1e1f22; border: 1px solid var(--border); border-radius: 10px; color: var(--text); font-size: 15px; outline: none; }
.modal .field textarea { resize: vertical; min-height: 60px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions button { flex: 1; padding: 13px; border-radius: 11px; font-weight: 700; font-size: 14px; }
.btn-primary { background: linear-gradient(135deg,var(--accent),var(--accent-hover)); color: #fff; }
.btn-ghost { background: var(--panel2); color: var(--text-dim); }
.color-dots { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.color-dot { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; }
.color-dot.sel { border-color: #fff; }
.seg { display: flex; gap: 6px; margin-top: 8px; }
.seg button { flex: 1; padding: 9px; border-radius: 9px; background: var(--panel2); color: var(--text-dim); font-size: 13px; font-weight: 600; }
.seg button.sel { background: var(--accent); color: #fff; }
.nitro-badge { display: inline-block; background: var(--nitro); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 900; }

/* Profile card popup */
.profile-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--border); border-radius: 18px; overflow: hidden; }
.profile-banner { height: 90px; }
.profile-body { padding: 0 18px 18px; margin-top: -34px; }
.profile-body .av { border: 5px solid var(--panel); }
.profile-name { font-size: 20px; font-weight: 800; margin-top: 8px; }
.profile-tag { color: var(--text-muted); font-size: 13px; }
.profile-bio { margin-top: 12px; font-size: 14px; color: var(--text-dim); line-height: 1.5; background: var(--bg2); border-radius: 10px; padding: 12px; }
.profile-badges { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.pbadge { font-size: 12px; padding: 3px 9px; border-radius: 8px; background: var(--panel2); display: inline-flex; gap: 4px; align-items: center; }
.pbadge.nitro { background: var(--nitro); color: #fff; font-weight: 700; }

/* Emoji picker */
.emoji-pop { position: fixed; z-index: 160; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 10px; display: none; grid-template-columns: repeat(7, 1fr); gap: 4px; box-shadow: 0 12px 40px rgba(0,0,0,.5); max-width: 300px; }
.emoji-pop.show { display: grid; }
.emoji-pop span { font-size: 22px; padding: 5px; border-radius: 8px; cursor: pointer; text-align: center; }
.emoji-pop span:hover { background: var(--panel2); }

/* Toast */
#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); background: var(--panel2); border: 1px solid var(--border); color: var(--text); padding: 12px 20px; border-radius: 12px; font-size: 14px; z-index: 300; opacity: 0; transition: all .3s; pointer-events: none; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Mobile ===== */
@media (max-width: 820px) {
  .members { display: none !important; }
  .sidebar { width: 100%; }
  /* На телефоне: показываем либо sidebar, либо main */
  #app[data-view="main"] .sidebar { display: none; }
  #app[data-view="main"] .rail { display: none; }
  #app[data-view="sidebar"] .main { display: none; }
  .main-header .back { display: block; }
}

/* ===== Voice Stage ===== */
#voiceStage { position: fixed; inset: 0; z-index: 180; background: #000; display: none; flex-direction: column; }
#voiceStage.show { display: flex; }
.stage-head { padding: 16px; padding-top: calc(16px + env(safe-area-inset-top)); text-align: center; font-weight: 800; font-size: 16px; color: var(--text); }
.stage-grid { flex: 1; min-height: 0; display: grid; gap: 10px; padding: 12px; align-content: center; justify-content: center;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); overflow-y: auto; }
.vtile { position: relative; background: #2b2d31; border: 1px solid var(--border-soft); border-radius: 16px; aspect-ratio: 16/10; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.vtile video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.vtile-av { display: flex; align-items: center; justify-content: center; }
.vtile-name { position: absolute; left: 10px; bottom: 8px; background: rgba(0,0,0,.6); padding: 3px 10px; border-radius: 8px; font-size: 13px; font-weight: 600; }
.stage-controls { display: flex; gap: 12px; justify-content: center; padding: 18px; padding-bottom: calc(18px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
.stage-btn { width: 56px; height: 56px; border-radius: 50%; background: #4e5058; color: #fff; font-size: 22px; display: flex; align-items: center; justify-content: center; }
.stage-btn.on { background: #fff; color: #111; }
.stage-btn.off { background: var(--accent); }
.stage-btn.end { background: var(--dnd); }
.stage-btn:active { transform: scale(.92); }

/* ===== Markdown ===== */
.md-pre { background:#1e1f22; border:1px solid var(--border-soft); border-radius:8px; padding:10px 12px; margin:4px 0; font-family:'Cascadia Mono',Consolas,monospace; font-size:13px; white-space:pre-wrap; overflow-x:auto; }
.md-code { background:#1e1f22; border:1px solid var(--border-soft); border-radius:5px; padding:1px 5px; font-family:'Cascadia Mono',Consolas,monospace; font-size:13px; }
.md-quote { display:block; border-left:3px solid var(--text-muted); padding-left:10px; color:var(--text-dim); margin:2px 0; }
.md-link { color:#5ab2ff; text-decoration:underline; }
.md-spoiler { background:#202225; color:transparent; border-radius:5px; padding:0 4px; cursor:pointer; }
.md-spoiler.open { background:#2f3136; color:inherit; }
.edited { font-size:10px; color:var(--text-muted); margin-left:6px; }
.msg-text .missed, .missed-call { color: var(--dnd); font-weight:600; }

/* ===== Day separator ===== */
.day-sep { align-self:center; text-align:center; color:var(--text-muted); font-size:11px; font-weight:700; margin:14px 0 8px; position:relative; width:100%; }
.day-sep::before,.day-sep::after { content:''; position:absolute; top:50%; width:38%; height:1px; background:var(--border-soft); }
.day-sep::before{ left:0; } .day-sep::after{ right:0; }

/* ===== Message actions ===== */
.msg-row { position:relative; }
.msg-actions { position:absolute; right:10px; top:-8px; display:none; gap:2px; background:var(--panel2); border:1px solid var(--border-soft); border-radius:8px; padding:2px; }
.msg-row:hover .msg-actions { display:flex; }
.msg-actions button { width:30px; height:28px; border-radius:6px; font-size:14px; color:var(--text-dim); }
.msg-actions button:hover { background:var(--panel); color:#fff; }
.msg-row.flash { background:rgba(88,101,242,.15); border-radius:8px; transition:background .4s; }
.reply-ref { font-size:12px; color:var(--text-muted); margin-bottom:2px; cursor:pointer; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:90%; }
.reply-ref b { color:var(--text-dim); }
.reply-ref:hover { color:var(--text-dim); }

/* DM bubble actions */
.bubble { position:relative; }
.bubble-actions { position:absolute; top:-10px; right:6px; display:none; gap:2px; background:var(--panel2); border:1px solid var(--border-soft); border-radius:7px; padding:2px; }
.bubble:hover .bubble-actions { display:flex; }
.bubble-actions button { width:26px; height:24px; border-radius:5px; font-size:12px; color:var(--text-dim); }
.bubble-actions button:hover { color:#fff; }

/* ===== Composer reply/edit bar ===== */
.composer-bar { display:flex; align-items:center; justify-content:space-between; padding:8px 14px; background:var(--panel2); border-top:1px solid var(--border-soft); font-size:13px; color:var(--text-dim); }
.composer-bar b { color:#fff; }
.composer-bar button { color:var(--text-muted); font-size:16px; }
.composer-bar.hidden { display:none; }

/* ===== Speaking indicator ===== */
.vtile.talking { outline:3px solid var(--green); outline-offset:-3px; }
.voice-user.talking .av, .av.talking { box-shadow:0 0 0 2px var(--green); border-radius:50%; }
