:root {
  --bg-0: #05070f;
  --bg-1: #0c1124;
  --ink: #eef1ff;
  --muted: #9aa4c7;
  --muted-2: #6a7396;
  --line: rgba(255, 255, 255, .10);
  --line-soft: rgba(255, 255, 255, .06);
  --glass: rgba(18, 24, 48, .55);
  --glass-hi: rgba(255, 255, 255, .08);
  --violet: #7c5cff;
  --cyan: #22d3ee;
  --pink: #ff5f9e;
  --grad: linear-gradient(135deg, #7c5cff 0%, #3f83ff 45%, #22d3ee 100%);
  --grad-hot: linear-gradient(135deg, #ff5f9e 0%, #7c5cff 55%, #22d3ee 100%);
  --radius: 20px;
  --shadow: 0 20px 60px rgba(3, 6, 18, .55), inset 0 1px 0 rgba(255, 255, 255, .06);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
}

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

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg-0);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(124, 92, 255, .4); }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.16) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 8px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.24); }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------- background */
.bg {
  position: fixed; inset: 0; z-index: 0; overflow: hidden;
  background:
    radial-gradient(1200px 800px at 80% -10%, #1b2350 0%, transparent 55%),
    radial-gradient(900px 700px at -10% 110%, #2a1345 0%, transparent 55%),
    linear-gradient(160deg, var(--bg-1) 0%, var(--bg-0) 60%);
}
.orb {
  position: absolute; border-radius: 50%;
  filter: blur(90px); opacity: .5; will-change: transform;
  animation: float 18s ease-in-out infinite;
}
.orb-1 { width: 480px; height: 480px; top: -120px; right: -80px;
  background: radial-gradient(circle, #6d3bff 0%, transparent 65%); }
.orb-2 { width: 420px; height: 420px; bottom: -140px; left: -60px;
  background: radial-gradient(circle, #0ea5d0 0%, transparent 65%);
  animation-delay: -6s; }
.orb-3 { width: 320px; height: 320px; top: 40%; left: 55%;
  background: radial-gradient(circle, #ff5f9e 0%, transparent 65%);
  opacity: .28; animation-delay: -12s; }
@keyframes float {
  0%,100% { transform: translate(0,0) scale(1); }
  33%      { transform: translate(40px,-30px) scale(1.06); }
  66%      { transform: translate(-30px,26px) scale(.96); }
}
.grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 30%, #000 0%, transparent 75%);
}
.noise {
  position: absolute; inset: 0; opacity: .05; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.6'/%3E%3C/svg%3E");
}

/* ---------------------------------------------------------------- glass base */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  backdrop-filter: blur(26px) saturate(150%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------------------------------------------------------------- login */
.login-wrap {
  position: fixed; inset: 0; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  width: min(430px, 100%);
  padding: 44px 40px 38px;
  text-align: center;
  animation: pop .5s cubic-bezier(.22,1,.36,1);
}
.login-logo { display: inline-block; margin-bottom: 18px; filter: drop-shadow(0 8px 24px rgba(124,92,255,.5)); }
.login-logo svg { display: block; border-radius: 18px; animation: logo-breathe 3.5s ease-in-out infinite; }
@keyframes logo-breathe {
  0%,100% { transform: scale(1) rotate(0deg); }
  50%     { transform: scale(1.05) rotate(-3deg); }
}
.login-title {
  font-weight: 800; font-size: 30px; letter-spacing: .18em;
  font-family: var(--mono); margin-bottom: 10px;
}
.login-sub { color: var(--muted); font-size: 14px; line-height: 1.6; margin-bottom: 28px; }
.login-sub b { color: var(--ink); }
.btn-sso {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 15px 20px; border: 0; cursor: pointer;
  border-radius: 14px; font-family: var(--font); font-weight: 700; font-size: 15px;
  color: #fff; text-decoration: none;
  background: var(--grad);
  box-shadow: 0 12px 34px rgba(96,84,255,.42), inset 0 1px 0 rgba(255,255,255,.28);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
  position: relative; overflow: hidden;
}
.btn-sso::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,.35) 50%, transparent 70%);
  transform: translateX(-120%);
  transition: transform .6s ease;
}
.btn-sso:hover { transform: translateY(-2px); filter: brightness(1.08); box-shadow: 0 16px 40px rgba(96,84,255,.55), inset 0 1px 0 rgba(255,255,255,.3); }
.btn-sso:hover::after { transform: translateX(120%); }
.btn-sso:active { transform: translateY(0) scale(.98); }
.login-hint { margin-top: 20px; font-size: 12.5px; color: var(--muted-2); min-height: 18px; }

/* ---------------------------------------------------------------- app layout */
.app-wrap {
  position: fixed; inset: 0; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  padding: clamp(8px, 2vw, 26px);
}
.app {
  display: flex; width: min(1180px, 100%); height: 100%;
  overflow: hidden; animation: pop .45s cubic-bezier(.22,1,.36,1);
}
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }

.sidebar {
  width: 350px; flex: 0 0 350px; min-width: 0;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line-soft);
  padding: 16px 14px 12px;
}
.chat-area { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }

/* sidebar head */
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 14px; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; color: #fff; font-size: 15px;
  background: var(--grad); box-shadow: 0 6px 18px rgba(96,84,255,.45);
}
.brand-name { font-family: var(--mono); font-weight: 700; letter-spacing: .16em; font-size: 14px; display: flex; gap: 8px; align-items: center;}
.brand-name::after { content:"beta"; font-size: 9px; letter-spacing:.08em; padding: 2px 6px; border:1px solid var(--line); border-radius: 999px; color: var(--muted); }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 14px; cursor: default;
  border: 1px solid transparent; transition: background .18s ease;
}
.user-chip:hover { background: rgba(255,255,255,.05); }
.uc-ava { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff; flex: 0 0 auto; }
.uc-meta { min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.uc-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.uc-role { font-size: 11px; color: var(--muted-2); text-transform: lowercase; }

.icon-btn {
  width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center;
  border-radius: 12px; border: 1px solid transparent; cursor: pointer;
  color: var(--muted); background: rgba(255,255,255,.03);
  transition: .18s ease;
}
.icon-btn:hover { color: var(--ink); background: rgba(255,255,255,.08); border-color: var(--line-soft); }
.icon-btn:active { transform: scale(.93); }
.icon-btn.accent {
  background: var(--grad); color: #fff;
  box-shadow: 0 8px 22px rgba(96,84,255,.4);
}
.icon-btn.accent:hover { filter: brightness(1.1); color: #fff; background: var(--grad); }
.icon-btn svg { width: 19px; height: 19px; }

/* search */
.search-row { display: flex; gap: 8px; padding: 4px 2px 12px; }
.search-box {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.055);
  border: 1px solid var(--line-soft); border-radius: 13px;
  padding: 0 12px; height: 40px;
  transition: .18s ease;
}
.search-box:focus-within { border-color: rgba(124,92,255,.6); background: rgba(255,255,255,.08); box-shadow: 0 0 0 3px rgba(124,92,255,.14); }
.s-icon { width: 16px; height: 16px; color: var(--muted-2); flex: 0 0 auto; }
.search-box input {
  flex: 1; min-width: 0; background: transparent; border: 0; outline: none;
  color: var(--ink); font-size: 13.5px; font-family: var(--font);
}
.search-box input::placeholder { color: var(--muted-2); }

/* chat list */
.chat-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding: 2px 0 8px; }
.chat-list-empty { color: var(--muted-2); font-size: 13px; text-align: center; padding: 32px 16px; line-height: 1.6; }
.chat-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 10px; border-radius: 16px; border: 1px solid transparent;
  cursor: pointer; transition: .18s ease; position: relative;
}
.chat-item:hover { background: rgba(255,255,255,.05); }
.chat-item.active { background: rgba(124,92,255,.16); border-color: rgba(124,92,255,.35); }
.chat-item.active::before {
  content: ""; position: absolute; left: -14px; top: 24%; bottom: 24%; width: 3px; border-radius: 3px;
  background: var(--grad);
}
.ci-ava { position: relative; flex: 0 0 auto; }
.ci-ava .ava {
  width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center;
  font-weight: 700; font-size: 17px; color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25);
}
.ci-online {
  position: absolute; right: -2px; bottom: -2px; width: 13px; height: 13px; border-radius: 50%;
  background: #2fd66b; border: 2.5px solid var(--bg-1);
}
.ci-online.off { background: var(--muted-2); }
.ci-body { flex: 1; min-width: 0; }
.ci-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ci-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-time { font-size: 11px; color: var(--muted-2); flex: 0 0 auto; }
.ci-row2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 3px; }
.ci-preview { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; flex: 0 0 auto;
  background: var(--grad-hot); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; box-shadow: 0 4px 12px rgba(255,95,158,.35);
}
.ci-badge.hidden { display: none; }

.sb-foot { display: flex; align-items: center; gap: 8px; padding: 8px 8px 0; font-size: 11.5px; color: var(--muted-2); border-top: 1px solid var(--line-soft); }
.foot-dot { width: 8px; height: 8px; border-radius: 50%; background: #2fd66b; box-shadow: 0 0 10px rgba(47,214,107,.8); }
.foot-dot.warn { background: #f5b301; box-shadow: 0 0 10px rgba(245,179,1,.8); }
.foot-dot.bad { background: #ff5f6d; box-shadow: 0 0 10px rgba(255,95,109,.8); }

/* ---------------------------------------------------------------- empty / chat pane */
.empty-state {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 20px; gap: 6px;
}
.empty-orb {
  width: 110px; height: 110px; border-radius: 36px; display: grid; place-items: center;
  color: #b9c2ff; margin-bottom: 16px;
  background: linear-gradient(150deg, rgba(124,92,255,.18), rgba(34,211,238,.10));
  border: 1px solid var(--line); 
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 18px 50px rgba(96,84,255,.18);
}
.empty-state h2 { font-size: 20px; font-weight: 700; }
.empty-state p { color: var(--muted); font-size: 13.5px; line-height: 1.7; margin-top: 4px; }

.chat-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.ch-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid var(--line-soft);
  background: rgba(10, 14, 32, .35); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  z-index: 3;
}
.ch-ava { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-weight: 700; font-size: 16px; color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,.25); }
.ch-meta { flex: 1; min-width: 0; line-height: 1.25; }
.ch-name { font-weight: 700; font-size: 15px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-status { font-size: 12px; color: var(--muted); display: block; }
.ch-status.online { color: #2fd66b; }
.mobile-back { display: none; }

.messages {
  flex: 1; overflow-y: auto; padding: 18px 22px 12px;
  display: flex; flex-direction: column; gap: 2px;
}
.load-older {
  position: absolute; top: 58px; left: 50%; transform: translateX(-50%);
  z-index: 4; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: rgba(20,26,54,.72); color: var(--muted);
  font-size: 12px; font-weight: 600; font-family: var(--font); cursor: pointer;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: 0 8px 22px rgba(3,6,18,.35);
  transition: .18s ease;
}
.load-older:hover { color: var(--ink); background: rgba(124,92,255,.25); border-color: rgba(124,92,255,.5); }
.load-older:disabled { opacity: .6; cursor: default; }
.chat-pane { position: relative; }
.date-sep { align-self: center; margin: 14px 0 10px; }
.date-sep span {
  font-size: 11px; letter-spacing: .04em; color: var(--muted); text-transform: uppercase;
  background: rgba(255,255,255,.05); border: 1px solid var(--line-soft);
  padding: 4px 14px; border-radius: 999px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.msg { display: flex; align-items: flex-end; gap: 8px; margin: 3px 0; animation: msg-in .22s cubic-bezier(.22,1,.36,1); }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.msg.mine { justify-content: flex-end; }
.msg-ava {
  width: 28px; height: 28px; border-radius: 10px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff;
}
.bubble {
  max-width: min(62%, 560px);
  padding: 8px 13px 7px; border-radius: 18px;
  font-size: 14px; line-height: 1.45; word-wrap: break-word; overflow-wrap: anywhere;
  position: relative; white-space: pre-wrap;
}
.msg.mine .bubble {
  color: #fff;
  background: linear-gradient(135deg, rgba(124,92,255,.92), rgba(47,131,255,.90));
  border-bottom-right-radius: 6px;
  box-shadow: 0 8px 24px rgba(96,84,255,.30), inset 0 1px 0 rgba(255,255,255,.18);
}
.msg.other .bubble {
  background: rgba(255,255,255,.07);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}
.msg.grouped .bubble { border-radius: 18px; }
.msg.grouped.other .bubble { border-bottom-left-radius: 18px; }
.msg.grouped.mine .bubble { border-bottom-right-radius: 18px; }
.msg.grouped.other .msg-ava.spacer { visibility: hidden; }
.msg.grouped { margin-top: 1px; }
.msg .meta { display: inline-flex; align-items: center; gap: 4px; float: right; margin: 8px -4px -3px 10px; font-size: 10.5px; color: rgba(255,255,255,.85); }
.msg.other .meta { color: var(--muted-2); }
.msg .ticks { display: inline-flex; } 
.msg .ticks svg { width: 13px; height: 13px; }
.tick-read { color: #7ef0ff; }
.msg.other .tick-read { color: var(--cyan); }
.typing-ind { display: inline-flex; align-items: center; gap: 4px; padding: 12px 14px; }
.typing-ind .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing-ind .dot:nth-child(2) { animation-delay: .15s; }
.typing-ind .dot:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%,60%,100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* ---------------------------------------------------------------- composer */
.composer {
  position: relative;
  display: flex; align-items: flex-end; gap: 8px;
  margin: 8px 14px 14px; padding: 8px;
  background: rgba(255,255,255,.055);
  border: 1px solid var(--line); border-radius: 20px;
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  transition: .2s ease;
}
.composer:focus-within { border-color: rgba(124,92,255,.55); box-shadow: 0 0 0 3px rgba(124,92,255,.12); }
.composer textarea {
  flex: 1; min-width: 0; resize: none; max-height: 130px;
  background: transparent; border: 0; outline: none; color: var(--ink);
  font-size: 14.5px; font-family: var(--font); line-height: 1.45;
  padding: 9px 4px 8px;
}
.composer textarea::placeholder { color: var(--muted-2); }
.send-btn {
  width: 44px; height: 44px; flex: 0 0 auto; border: 0; border-radius: 15px; cursor: pointer;
  display: grid; place-items: center; color: #fff;
  background: var(--grad); box-shadow: 0 8px 20px rgba(96,84,255,.42);
  transition: .18s ease;
}
.send-btn:hover { transform: translateY(-1px) scale(1.04); filter: brightness(1.1); }
.send-btn:active { transform: scale(.92); }
.emoji-bar {
  position: absolute; bottom: calc(100% + 10px); right: 10px; z-index: 5;
  width: 300px; max-height: 220px; overflow-y: auto; padding: 10px;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
  background: rgba(15,20,44,.8);
}
.emoji-bar button {
  background: transparent; border: 0; border-radius: 10px; cursor: pointer;
  font-size: 20px; padding: 6px; transition: .12s ease;
}
.emoji-bar button:hover { background: rgba(255,255,255,.1); transform: scale(1.15); }

/* ---------------------------------------------------------------- modals */
.modal { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-mask { position: absolute; inset: 0; background: rgba(3,5,12,.6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  position: relative; width: min(440px, 100%); padding: 20px;
  animation: pop .28s cubic-bezier(.22,1,.36,1);
  background: rgba(16,21,45,.82);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { font-size: 17px; font-weight: 700; }
.modal-search { margin-bottom: 12px; }
.user-results { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.user-results-empty { color: var(--muted-2); font-size: 13px; text-align: center; padding: 26px 10px; }
.user-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 10px; border-radius: 14px; border: 1px solid transparent;
  cursor: pointer; transition: .15s ease;
}
.user-item:hover { background: rgba(255,255,255,.06); border-color: var(--line-soft); }
.user-item .ava { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 15px; }
.ur-meta { min-width: 0; }
.ur-name { font-weight: 600; font-size: 14px; }
.ur-sub { font-size: 12px; color: var(--muted-2); }
.ur-sub.new { color: var(--cyan); }

.modal-info { text-align: center; padding: 26px; }
.info-ava { width: 86px; height: 86px; border-radius: 28px; margin: 0 auto 14px; display: grid; place-items: center; font-size: 30px; font-weight: 700; color: #fff; }
.info-name { font-size: 19px; font-weight: 700; margin-bottom: 4px; }
.info-status { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.info-status.online { color: #2fd66b; }
.info-meta { display: flex; align-items: center; justify-content: space-between; padding: 11px 6px; border-top: 1px solid var(--line-soft); font-size: 13px; }
.info-meta span { color: var(--muted); }
.info-meta b { font-weight: 600; color: var(--ink); }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  z-index: 20; padding: 12px 20px; border-radius: 14px;
  background: rgba(124,92,255,.9); color: #fff; font-size: 13.5px; font-weight: 600;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: 0 14px 40px rgba(3,6,18,.5);
  animation: pop .3s cubic-bezier(.22,1,.36,1);
}
.toast.err { background: rgba(255,95,109,.92); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 860px) {
  .app-wrap { padding: 0; }
  .app { border-radius: 0; border: 0; height: 100%; width: 100%; }
  .sidebar { position: absolute; inset: 0; z-index: 5; width: 100%; flex-basis: 100%; background: rgba(10,14,30,.9); }
  .sidebar.hidden-m { transform: translateX(-100%); }
  .sidebar { transition: transform .28s cubic-bezier(.22,1,.36,1); }
  .chat-area { width: 100%; }
  .empty-state { display: flex; padding-top: 30vh; }
  .chat-pane { display: flex; }
  .mobile-back { display: grid; }
  .bubble { max-width: 82%; }
  .login-card { padding: 34px 28px 30px; }
}
@media (min-width: 861px) {
  .sidebar.hidden-m { display: flex; }
}

/* ================================================================ v3 layout */

.sb-nav {
  display: flex; gap: 4px; align-items: center;
  padding: 2px 2px 12px; border-bottom: 1px solid var(--line-soft);
  margin-bottom: 10px;
}
.nav-btn {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 9px 4px 7px; border-radius: 14px; border: 1px solid transparent;
  background: transparent; cursor: pointer; color: var(--muted);
  font-family: var(--font); font-size: 10.5px; font-weight: 600; letter-spacing: .02em;
  transition: .18s ease; position: relative;
}
.nav-btn svg { width: 20px; height: 20px; }
.nav-btn:hover { color: var(--ink); background: rgba(255,255,255,.05); }
.nav-btn.active {
  color: #fff; background: linear-gradient(135deg, rgba(124,92,255,.28), rgba(34,211,238,.16));
  border-color: rgba(124,92,255,.35);
}
.nav-btn.active svg { filter: drop-shadow(0 2px 8px rgba(124,92,255,.6)); }
.nav-badge {
  position: absolute; top: 3px; right: 14%;
  min-width: 17px; height: 17px; padding: 0 5px; border-radius: 999px;
  background: var(--grad-hot); color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center; box-shadow: 0 4px 12px rgba(255,95,158,.4);
}
.nav-badge.hidden { display: none; }

.sb-content { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.sb-panel { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
.sb-panel[hidden] { display: none; }

/* mini buttons */
.btn-mini, .btn-primary {
  font-family: var(--font); font-size: 13px; font-weight: 600;
  border-radius: 12px; cursor: pointer; transition: .16s ease;
}
.btn-mini {
  padding: 8px 12px; color: var(--ink);
  background: rgba(255,255,255,.06); border: 1px solid var(--line);
}
.btn-mini:hover { background: rgba(124,92,255,.22); border-color: rgba(124,92,255,.5); }
.btn-mini:active { transform: scale(.97); }
.btn-mini.subtle { background: transparent; color: var(--muted); }
.btn-mini.subtle:hover { color: var(--ink); background: rgba(255,255,255,.05); border-color: var(--line); }
.btn-mini.danger { color: #ff8b98; border-color: rgba(255,95,109,.35); }
.btn-mini.danger:hover { background: rgba(255,95,109,.15); border-color: rgba(255,95,109,.6); }
.btn-primary {
  width: 100%; padding: 12px 16px; border: 0; color: #fff;
  background: var(--grad); box-shadow: 0 10px 26px rgba(96,84,255,.4);
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0) scale(.99); }

/* channel panels */
.chan-actions { display: flex; gap: 8px; padding: 2px 2px 12px; }
.chan-actions .btn-mini { flex: 1; }
.chan-section {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted-2);
  font-weight: 700; padding: 10px 6px 6px;
}
.chan-mine, .chan-public { display: flex; flex-direction: column; gap: 4px; }
.chan-row {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px;
  border-radius: 16px; border: 1px solid transparent; cursor: pointer; transition: .16s ease;
}
.chan-row:hover { background: rgba(255,255,255,.05); }
.chan-row .ava {
  width: 46px; height: 46px; border-radius: 16px; display: grid; place-items: center;
  font-weight: 700; font-size: 15px; color: #fff; flex: 0 0 auto;
}
.chan-row .cr-body { flex: 1; min-width: 0; }
.chan-row .cr-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chan-row .cr-sub { font-size: 12px; color: var(--muted-2); display: flex; gap: 6px; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chan-row .cr-sub .lock { font-size: 11px; }
.chan-row .cr-right { display: flex; flex-direction: column; gap: 5px; align-items: flex-end; flex: 0 0 auto; }
.chan-row .cr-role { font-size: 10.5px; color: var(--cyan); font-weight: 600; }
.chan-row .cr-role.owner { color: #f5b301; }
.chan-row .cr-join {
  padding: 5px 14px; border-radius: 999px; border: 1px solid rgba(124,92,255,.55);
  color: #fff; background: rgba(124,92,255,.28); font-size: 12px; font-weight: 700; cursor: pointer;
  font-family: var(--font); transition: .16s ease;
}
.chan-row .cr-join:hover { background: rgba(124,92,255,.5); }
.chan-row .cr-open {
  padding: 5px 14px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); background: rgba(255,255,255,.04); font-size: 12px; font-weight: 600; cursor: pointer;
  font-family: var(--font); transition: .16s ease;
}
.chan-row .cr-open:hover { color: var(--ink); border-color: rgba(255,255,255,.25); }
.chan-empty { color: var(--muted-2); font-size: 13px; text-align: center; padding: 18px 14px; line-height: 1.6; }

/* contacts */
.contacts { display: flex; flex-direction: column; gap: 4px; padding: 2px 0 8px; }

/* settings */
.settings { display: flex; flex-direction: column; gap: 10px; padding: 6px 2px 16px; }
.set-profile { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; background: rgba(255,255,255,.04); border: 1px solid var(--line-soft); }
.set-ava { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; font-size: 20px; font-weight: 700; color: #fff; }
.set-meta { min-width: 0; }
.set-name { font-weight: 700; font-size: 16px; }
.set-sub { font-size: 12.5px; color: var(--muted-2); }
.set-row { display: flex; align-items: center; justify-content: space-between; padding: 12px; border-radius: 14px; background: rgba(255,255,255,.03); border: 1px solid var(--line-soft); font-size: 13.5px; }
.set-row .set-val { color: var(--muted); font-size: 12.5px; }
.set-note { font-size: 12px; color: var(--muted-2); line-height: 1.6; padding: 2px 4px; }

/* switch */
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: 0 0 auto; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; border-radius: 999px; transition: .2s ease;
  background: rgba(255,255,255,.14); border: 1px solid var(--line);
}
.switch .slider::before {
  content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  left: 2px; top: 2px; background: #fff; transition: .2s ease;
}
.switch input:checked + .slider { background: var(--grad); border-color: transparent; }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 2px; font-size: 13.5px; color: var(--muted); }

/* forms in modals */
.modal-form { display: flex; flex-direction: column; gap: 10px; }
.inp {
  width: 100%; padding: 11px 13px; border-radius: 12px;
  background: rgba(255,255,255,.055); border: 1px solid var(--line-soft);
  color: var(--ink); font-family: var(--font); font-size: 14px; outline: none; transition: .16s ease;
  resize: none;
}
.inp:focus { border-color: rgba(124,92,255,.6); box-shadow: 0 0 0 3px rgba(124,92,255,.14); }
.inp::placeholder { color: var(--muted-2); }
.form-hint { font-size: 12px; color: var(--muted-2); line-height: 1.5; }

/* channel info modal */
.chan-info-card { width: min(520px, 100%); }
.chan-info-text { text-align: center; }
.chan-info { text-align: left; }
.chan-info .ci-top { text-align: center; }
.chan-desc { font-size: 13px; color: var(--muted); line-height: 1.6; margin: 0 auto 16px; max-width: 90%; }
.chan-actions-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 0 4px; }
.chan-actions-row .btn-mini { flex: 1; min-width: 110px; }
.chan-invite { padding-top: 6px; }
.invite-line { display: flex; gap: 8px; align-items: center; }
.invite-line code {
  flex: 1; min-width: 0; font-family: var(--mono); font-size: 12.5px; color: var(--cyan);
  background: rgba(34,211,238,.08); border: 1px solid rgba(34,211,238,.25);
  padding: 8px 10px; border-radius: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chan-members-list { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow-y: auto; }
.chm-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; }
.chm-row:hover { background: rgba(255,255,255,.04); }
.chm-row .ava { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; }
.chm-name { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chm-role {
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px;
}
.chm-role.owner { color: #f5b301; border-color: rgba(245,179,1,.4); }
.chm-role.admin { color: var(--cyan); border-color: rgba(34,211,238,.4); }
.chm-actions { display: flex; gap: 4px; align-items: center; }
.chm-actions .icon-btn { width: 30px; height: 30px; border-radius: 9px; }
.chm-actions .icon-btn svg { width: 15px; height: 15px; }
.chm-actions .icon-btn.danger-btn:hover { color: #ff8b98; background: rgba(255,95,109,.15); }
.chm-you { color: var(--muted-2); font-size: 10.5px; margin-left: 4px; }

/* chat header avatar button */
.ch-info-btn { width: 42px; height: 42px; border-radius: 14px; background: transparent; border: 1px solid transparent; padding: 0; cursor: pointer; }
.ch-info-btn:hover { border-color: rgba(255,255,255,.18); filter: brightness(1.15); }
.ch-ava { pointer-events: none; }

/* sender names in channel messages */
.msg .sender {
  display: block; font-size: 12.5px; font-weight: 700; margin: 0 0 2px 2px;
  color: var(--ink);
}
.msg-typing .sender { margin-bottom: 6px; }
.sender[data-sender="other"] { color: #9aa4c7; }

/* channel icon rows in chat list */
.chat-item .ci-ava .h { font-size: 11px; position: absolute; right: -4px; top: -4px; background: var(--grad); color: #fff; border-radius: 8px; padding: 1px 5px; font-weight: 800; border: 2px solid var(--bg-1); }

/* bottom nav (mobile) */
@media (max-width: 860px) {
  .sidebar { padding-bottom: 0; }
  .sb-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 8;
    margin: 0; padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
    background: rgba(12,16,34,.88);
    -webkit-backdrop-filter: blur(22px) saturate(150%); backdrop-filter: blur(22px) saturate(150%);
    border-top: 1px solid var(--line); border-bottom: 0;
  }
  .sb-content { padding-bottom: 74px; }
  .nav-btn { flex-direction: column; padding: 6px 4px 4px; gap: 3px; }
  .sb-foot { padding-bottom: 66px; }
}
@media (min-width: 861px) {
  .sb-nav { display: flex; }
}