/* ============================================================
   Aster Messenger — design system
   Custom "aurora orbit" visual language: deep space, soft glass,
   violet-to-mint spectra. Built from scratch.
   ============================================================ */

@font-face {
  font-family: "Golos Text";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("assets/fonts/golos-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Golos Text";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("assets/fonts/golos-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+2215;
}
@font-face {
  font-family: "Unbounded";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("assets/fonts/unbounded-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Unbounded";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("assets/fonts/unbounded-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+2215;
}

:root {
  color-scheme: dark;
  --font-ui: "Golos Text", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --font-display: "Unbounded", "Segoe UI", system-ui, sans-serif;
  --bg: #090b14;
  --bg-soft: #0d101d;
  --surface: #131728;
  --surface-2: #191e32;
  --surface-3: #222943;
  --surface-4: #2b3453;
  --text: #f5f6fc;
  --text-strong: #ffffff;
  --muted: #9ba3ba;
  --faint: #6c748d;
  --line: rgba(255, 255, 255, 0.075);
  --line-strong: rgba(255, 255, 255, 0.14);
  --accent: #8d6bff;
  --accent-2: #33dfc2;
  --accent-3: #ff91c8;
  --accent-soft: rgba(141, 107, 255, 0.16);
  --accent-contrast: #ffffff;
  --success: #40e0b4;
  --danger: #ff6f91;
  --danger-soft: rgba(255, 111, 145, 0.12);
  --warning: #ffd166;
  --gradient: linear-gradient(135deg, #8d6bff 0%, #6a6cff 46%, #33dfc2 120%);
  --gradient-soft: linear-gradient(135deg, rgba(141, 107, 255, 0.22), rgba(51, 223, 194, 0.12));
  --glass: rgba(19, 23, 40, 0.72);
  --glass-strong: rgba(19, 23, 40, 0.92);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.22);
  --shadow-md: 0 18px 48px rgba(0, 0, 0, 0.34);
  --shadow-lg: 0 32px 90px rgba(0, 0, 0, 0.5);
  --bubble-other: #191e32;
  --bubble-own: linear-gradient(135deg, #7757f5 0%, #8662ff 55%, #9a70ff 100%);
  --bubble-own-text: #ffffff;
  --wallpaper:
    radial-gradient(60% 50% at 85% 0%, rgba(141, 107, 255, 0.1), transparent 70%),
    radial-gradient(45% 40% at 0% 100%, rgba(51, 223, 194, 0.055), transparent 70%);
  --radius-xl: 30px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f3fb;
  --bg-soft: #efecf8;
  --surface: #ffffff;
  --surface-2: #f7f5fd;
  --surface-3: #efebf9;
  --surface-4: #e5dff5;
  --text: #1a162b;
  --text-strong: #0d0a19;
  --muted: #6e6882;
  --faint: #9892aa;
  --line: rgba(26, 22, 43, 0.075);
  --line-strong: rgba(26, 22, 43, 0.14);
  --accent: #6547e8;
  --accent-2: #08b39b;
  --accent-3: #e14c94;
  --accent-soft: rgba(101, 71, 232, 0.1);
  --success: #0aaa83;
  --danger: #e44468;
  --danger-soft: rgba(228, 68, 104, 0.09);
  --warning: #d19200;
  --gradient: linear-gradient(135deg, #6a4ce8 0%, #6e62f5 48%, #12bda5 120%);
  --gradient-soft: linear-gradient(135deg, rgba(106, 76, 232, 0.1), rgba(18, 189, 165, 0.08));
  --glass: rgba(255, 255, 255, 0.74);
  --glass-strong: rgba(255, 255, 255, 0.94);
  --shadow-sm: 0 4px 16px rgba(52, 39, 100, 0.08);
  --shadow-md: 0 20px 50px rgba(52, 39, 100, 0.12);
  --shadow-lg: 0 32px 90px rgba(52, 39, 100, 0.18);
  --bubble-other: #ffffff;
  --bubble-own: linear-gradient(135deg, #6a4ce8 0%, #7b5cf3 55%, #9174ff 100%);
  --bubble-own-text: #ffffff;
  --wallpaper:
    radial-gradient(55% 45% at 90% 0%, rgba(101, 71, 232, 0.07), transparent 70%),
    radial-gradient(50% 40% at 0% 100%, rgba(8, 179, 155, 0.06), transparent 70%);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--accent-2); text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
img { max-width: 100%; display: block; }
textarea { resize: none; }
::selection { background: rgba(141, 107, 255, 0.4); color: #fff; }

.hidden { display: none !important; }
.file-input { position: fixed; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.svg-sprite { position: fixed; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 20px; height: 20px; flex: 0 0 auto;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}
.icon.lg { width: 26px; height: 26px; }
.icon.sm { width: 16px; height: 16px; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--surface-4) transparent; }
*::-webkit-scrollbar { width: 7px; height: 7px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--surface-4); border-radius: 99px; }
*::-webkit-scrollbar-thumb:hover { background: var(--faint); }

/* ---------- shared primitives ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  border-radius: 14px; padding: 12px 18px; font-weight: 650; font-size: 14.5px;
  border: 1px solid transparent; letter-spacing: -0.01em;
  transition: transform .18s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease, opacity .2s ease;
  white-space: nowrap; user-select: none;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary {
  background: var(--gradient); color: #fff;
  box-shadow: 0 10px 28px rgba(115, 86, 246, 0.32), inset 0 1px 0 rgba(255,255,255,.2);
}
.btn-primary:hover { box-shadow: 0 14px 34px rgba(115, 86, 246, 0.42), inset 0 1px 0 rgba(255,255,255,.25); transform: translateY(-1px); }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line-strong); }
.btn-glass { background: var(--surface-2); border-color: var(--line); color: var(--text); box-shadow: var(--shadow-sm); }
.btn-glass:hover { background: var(--surface-3); }
.btn-danger-ghost { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.btn-danger-ghost:hover { border-color: rgba(255,111,145,.3); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 9px 13px; font-size: 13px; border-radius: 11px; }
.btn-block { width: 100%; }
.text-btn { color: var(--accent-2); font-weight: 650; font-size: 13px; padding: 4px 2px; }
.text-btn:hover { color: var(--accent); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 13px; color: var(--muted);
  transition: background .18s ease, color .18s ease, transform .15s ease;
  position: relative; flex: 0 0 auto;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.soft { background: var(--surface-2); border: 1px solid var(--line); color: var(--text); }
.icon-btn.soft:hover { background: var(--surface-3); }
.icon-btn.tiny { width: 30px; height: 30px; border-radius: 9px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px;
  border-radius: 99px; background: var(--surface-2); color: var(--muted);
  font-size: 11.5px; font-weight: 600; white-space: nowrap; border: 1px solid var(--line);
}
.pill-glass { background: rgba(255,255,255,.08); color: rgba(255,255,255,.82); border-color: rgba(255,255,255,.14); backdrop-filter: blur(16px); }
.pill-success { color: var(--success); background: rgba(64, 224, 180, .1); border-color: rgba(64,224,180,.16); }
.eyebrow { font-size: 10.5px; letter-spacing: .13em; text-transform: uppercase; color: var(--accent-2); font-weight: 750; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); display: inline-block; flex: 0 0 auto; }
.status-dot.online { background: var(--success); box-shadow: 0 0 0 3px rgba(64,224,180,.12); }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(64,224,180,.15); animation: livePulse 2.4s ease-in-out infinite; }
.separator { width: 1px; height: 24px; background: var(--line); }
kbd {
  font-family: var(--font-ui); font-size: 10.5px; font-weight: 650; color: var(--faint);
  background: var(--surface-2); border: 1px solid var(--line); border-bottom-color: var(--line-strong);
  border-radius: 5px; padding: 1px 5px; margin: 0 1px;
}
.avatar {
  --av1: #7c5cff; --av2: #31d7bd;
  width: 44px; height: 44px; border-radius: 15px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--av1), var(--av2));
  color: #fff; font-weight: 750; font-size: 16px; letter-spacing: -0.03em;
  position: relative; overflow: visible; user-select: none;
  aspect-ratio: 1 / 1; line-height: 1;
}
.avatar-initials { display: grid; place-items: center; width: 100%; height: 100%; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.avatar::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); pointer-events: none; }
.avatar.sm { width: 34px; height: 34px; border-radius: 11px; font-size: 13px; }
.avatar.md { width: 44px; height: 44px; border-radius: 14px; font-size: 16px; }
.avatar.lg { width: 64px; height: 64px; border-radius: 21px; font-size: 23px; }
.avatar.xl { width: 92px; height: 92px; border-radius: 30px; font-size: 32px; }
.avatar .presence-dot {
  position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--success); border: 3px solid var(--bg-soft);
}
.avatar .group-badge {
  position: absolute; right: -3px; bottom: -3px; width: 19px; height: 19px; border-radius: 7px;
  background: var(--surface-3); border: 2px solid var(--bg-soft); display: flex; align-items: center; justify-content: center;
}
.avatar .group-badge .icon { width: 11px; height: 11px; color: var(--muted); }
.avatar-stack { display: flex; align-items: center; }
.avatar-stack .avatar { margin-left: -10px; border: 2px solid var(--bg-soft); border-radius: 12px; width: 30px; height: 30px; font-size: 11px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ---------- boot ---------- */
.boot-screen {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
  background: #080a12; color: #fff; overflow: hidden;
}
.boot-aurora {
  position: absolute; inset: -30%;
  background:
    radial-gradient(40% 45% at 60% 40%, rgba(124, 92, 255, .34), transparent 70%),
    radial-gradient(35% 40% at 30% 75%, rgba(39, 209, 182, .18), transparent 70%);
  filter: blur(30px); animation: auroraDrift 14s ease-in-out infinite alternate;
}
.boot-inner { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 30px; }
.brand-lockup { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 14px; overflow: hidden; flex: 0 0 auto;
  box-shadow: 0 12px 30px rgba(115, 86, 246, .38), inset 0 0 0 1px rgba(255,255,255,.18);
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-mark.small { width: 34px; height: 34px; border-radius: 11px; }
.brand-word { font-family: var(--font-display); font-size: 23px; font-weight: 600; letter-spacing: -0.055em; line-height: 1; color: #fff; }
.brand-tag { font-size: 9.5px; letter-spacing: .22em; text-transform: uppercase; color: rgba(255,255,255,.5); margin-top: 4px; }
.boot-brand { margin-bottom: 34px; }
.boot-orbit { position: relative; width: 138px; height: 138px; margin-bottom: 28px; }
.boot-orbit span {
  position: absolute; inset: 0; border-radius: 50%; border: 1px solid rgba(255,255,255,.12);
  animation: orbitSpin 5s linear infinite;
}
.boot-orbit span:nth-child(2) { inset: 22px; border-color: rgba(51,223,194,.3); animation-duration: 7s; animation-direction: reverse; }
.boot-orbit span:nth-child(3) { inset: 44px; border-color: rgba(141,107,255,.4); animation-duration: 3.5s; }
.boot-orbit span::after {
  content: ""; position: absolute; top: -4px; left: 50%; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-2); box-shadow: 0 0 14px var(--accent-2);
}
.boot-orbit span:nth-child(2)::after { background: var(--accent); box-shadow: 0 0 14px var(--accent); }
.boot-orbit span:nth-child(3)::after { background: #fff; }
.boot-status { font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.boot-detail { font-size: 12.5px; color: rgba(255,255,255,.46); max-width: 320px; }
.boot-actions { display: flex; gap: 10px; margin-top: 20px; }
.boot-admin-link { margin-top: 28px; color: rgba(255,255,255,.4); font-size: 12px; text-decoration: underline; text-underline-offset: 4px; }
.boot-admin-link:hover { color: rgba(255,255,255,.7); }
.boot-footer { position: absolute; bottom: 24px; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: rgba(255,255,255,.25); }

/* ---------- auth ---------- */
.auth-screen { position: fixed; inset: 0; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(440px, .9fr); background: var(--bg); z-index: 50; }
.auth-visual {
  position: relative; overflow: hidden; padding: 36px 48px 28px;
  background: #0a0c15; color: #fff; display: flex; flex-direction: column; min-height: 0;
}
.auth-aurora {
  position: absolute; inset: -20%;
  background:
    radial-gradient(42% 40% at 68% 28%, rgba(124, 92, 255, .5), transparent 72%),
    radial-gradient(38% 38% at 22% 66%, rgba(35, 205, 177, .22), transparent 74%),
    radial-gradient(32% 30% at 90% 88%, rgba(255, 129, 191, .12), transparent 70%);
  filter: blur(34px); animation: auroraDrift 18s ease-in-out infinite alternate;
}
.auth-visual::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .25;
  background-image: radial-gradient(rgba(255,255,255,.3) .6px, transparent .6px);
  background-size: 32px 32px;
  mask-image: radial-gradient(80% 70% at 60% 40%, #000, transparent 75%);
}
.auth-visual-top { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; }
.auth-hero { position: relative; z-index: 2; margin-top: clamp(48px, 12vh, 120px); max-width: 580px; }
.hero-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: rgba(255,255,255,.5); margin-bottom: 22px; display: flex; align-items: center; gap: 10px; }
.hero-eyebrow::before { content: ""; width: 26px; height: 1px; background: linear-gradient(90deg, var(--accent-2), transparent); }
.auth-hero h1 {
  font-family: var(--font-display); font-weight: 500; font-size: clamp(32px, 4.2vw, 58px);
  line-height: 1.06; letter-spacing: -.045em; margin-bottom: 26px; color: #fff;
}
.auth-hero h1 em { font-style: normal; background: linear-gradient(110deg, #ab95ff 10%, #6fe7d2 80%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-hero p { max-width: 440px; color: rgba(255,255,255,.55); font-size: 15px; line-height: 1.65; }
.orbit-scene { position: absolute; z-index: 1; right: 2%; bottom: 12%; width: min(36vw, 440px); aspect-ratio: 1; opacity: .9; }
.orbit { position: absolute; inset: 8%; border-radius: 50%; border: 1px solid rgba(255,255,255,.11); animation: orbitSpin 28s linear infinite; }
.orbit-b { inset: 23%; border-color: rgba(51,223,194,.16); animation-duration: 20s; animation-direction: reverse; }
.orbit-c { inset: 37%; border-color: rgba(141,107,255,.22); animation-duration: 14s; }
.orbit-avatar { position: absolute; top: -23px; left: 50%; width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; font-weight: 750; font-size: 15px; color: #fff; border: 2px solid rgba(10,12,21,.65); box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.orbit-avatar.a1 { background: linear-gradient(135deg, #ff9bc7, #b65cff); }
.orbit-avatar.a2 { background: linear-gradient(135deg, #3bd7c1, #2575e8); }
.orbit-avatar.a3 { background: linear-gradient(135deg, #ffb661, #ff6f91); }
.orbit-b .orbit-avatar { top: auto; bottom: -18px; left: 14%; width: 36px; height: 36px; border-radius: 12px; font-size: 12px; }
.orbit-c .orbit-avatar { top: 18%; left: -18px; width: 30px; height: 30px; border-radius: 10px; font-size: 10px; }
.orbit-core {
  position: absolute; inset: 44%; border-radius: 17px; overflow: hidden;
  box-shadow: 0 0 0 10px rgba(255,255,255,.03), 0 20px 60px rgba(0,0,0,.4);
  animation: floatSoft 6s ease-in-out infinite;
}
.orbit-core img { width: 100%; height: 100%; }
.auth-features { position: relative; z-index: 2; display: flex; flex-wrap: wrap; gap: 9px; margin-top: auto; padding-top: 30px; }
.feature-chip {
  display: flex; align-items: center; gap: 8px; padding: 9px 13px;
  border: 1px solid rgba(255,255,255,.1); border-radius: 12px;
  background: rgba(255,255,255,.045); backdrop-filter: blur(14px);
  color: rgba(255,255,255,.66); font-size: 12px; font-weight: 550;
}
.feature-chip .icon { width: 15px; height: 15px; color: var(--accent-2); }
.auth-visual-footer { position: relative; z-index: 2; display: flex; justify-content: space-between; gap: 20px; margin-top: 22px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.08); color: rgba(255,255,255,.32); font-size: 11px; }
.auth-visual-footer strong { color: rgba(255,255,255,.6); font-weight: 600; }
.auth-panel { background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 36px clamp(24px, 4vw, 64px); overflow-y: auto; position: relative; }
.auth-panel::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(50% 40% at 100% 0%, var(--accent-soft), transparent 70%);
  opacity: .5;
}
.auth-card { width: min(100%, 400px); position: relative; animation: fadeUp .7s cubic-bezier(.2,.7,.2,1) both; }
.auth-mobile-brand { display: none; align-items: center; gap: 10px; margin-bottom: 30px; }
.auth-mobile-brand .brand-word { color: var(--text); }
.auth-heading { margin-bottom: 26px; }
.auth-tabs { display: flex; position: relative; gap: 4px; padding: 4px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 30px; }
.auth-tab { flex: 1; position: relative; z-index: 2; padding: 9px; border-radius: 9px; font-size: 13px; font-weight: 650; color: var(--muted); transition: color .25s ease; }
.auth-tab.active { color: var(--text-strong); }
.auth-tab-ink { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 9px; background: var(--surface); box-shadow: var(--shadow-sm); border: 1px solid var(--line); transition: transform .32s cubic-bezier(.2,.8,.2,1); }
.auth-tab-ink.right { transform: translateX(calc(100% + 4px)); }
.auth-heading h2 { font-family: var(--font-display); font-size: 30px; font-weight: 520; letter-spacing: -.04em; margin-bottom: 8px; color: var(--text-strong); }
.auth-heading p { color: var(--muted); font-size: 13.5px; }
.auth-alert { padding: 11px 14px; border-radius: 12px; background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(255,111,145,.18); font-size: 12.5px; margin-bottom: 16px; animation: shake .35s ease; }
.auth-form { display: flex; flex-direction: column; gap: 15px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field-label { font-size: 11.5px; font-weight: 650; color: var(--muted); letter-spacing: .02em; padding-left: 2px; }
.field-shell {
  display: flex; align-items: center; gap: 10px; min-height: 49px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 0 14px; transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.field-shell:focus-within { border-color: rgba(141,107,255,.48); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface); }
.field-shell .icon { color: var(--faint); width: 18px; height: 18px; }
.field-shell input, .field-shell textarea { flex: 1; min-width: 0; background: none; border: 0; outline: 0; padding: 13px 0; font-size: 14px; color: var(--text); }
.field-shell input::placeholder, .field-shell textarea::placeholder { color: var(--faint); }
.field-prefix { color: var(--faint); font-weight: 600; }
.field-suffix { font-size: 10.5px; color: var(--faint); white-space: nowrap; }
.field-eye { font-size: 10.5px; font-weight: 650; color: var(--muted); padding: 6px 0 6px 6px; }
.field-eye:hover { color: var(--text); }
.btn-auth { width: 100%; height: 50px; margin-top: 6px; border-radius: 14px; font-size: 14.5px; }
.btn-auth .icon { width: 17px; height: 17px; }
.auth-meta { margin-top: 26px; }
.auth-server { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; }
.server-state { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 11.5px; color: var(--muted); }
.server-state span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-privacy { display: flex; gap: 8px; margin-top: 16px; color: var(--faint); font-size: 10.5px; line-height: 1.55; }
.auth-privacy .icon { width: 14px; height: 14px; margin-top: 1px; color: var(--success); }
.auth-side-note { position: absolute; bottom: 20px; font-size: 10px; letter-spacing: .08em; color: var(--faint); text-transform: uppercase; }

/* ---------- main shell ---------- */
.main-screen { position: fixed; inset: 0; display: grid; grid-template-columns: 76px 348px minmax(0, 1fr); background: var(--bg); overflow: hidden; }
.rail {
  background: var(--bg-soft); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; padding: calc(18px + var(--safe-top)) 0 18px;
  z-index: 5;
}
.rail-logo { width: 42px; height: 42px; border-radius: 13px; overflow: hidden; box-shadow: 0 10px 26px rgba(115,86,246,.28); transition: transform .2s ease; }
.rail-logo:hover { transform: translateY(-2px) rotate(-3deg); }
.rail-logo img { width: 100%; height: 100%; }
.rail-nav { display: flex; flex-direction: column; gap: 7px; margin-top: 36px; }
.rail-btn {
  position: relative; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  color: var(--faint); transition: color .2s, background .2s, transform .2s;
}
.rail-btn .icon { width: 21px; height: 21px; }
.rail-btn:hover { color: var(--text); background: var(--surface-2); }
.rail-btn.active { color: #fff; background: var(--gradient); box-shadow: 0 8px 22px rgba(115,86,246,.28); }
.rail-btn.active::before { content: ""; position: absolute; left: -15px; width: 3px; height: 22px; border-radius: 4px; background: var(--accent-2); box-shadow: 0 0 10px var(--accent-2); }
.rail-btn[data-tooltip]::after, .icon-btn[data-tooltip]::after {
  content: attr(data-tooltip); position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%) translateX(-4px);
  background: var(--glass-strong); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 9px; font-size: 11px; white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity .15s ease, transform .15s ease; z-index: 30; box-shadow: var(--shadow-sm);
}
.rail-btn[data-tooltip]:hover::after, .icon-btn[data-tooltip]:hover::after { opacity: 1; transform: translateY(-50%) translateX(0); }
.chat-head .icon-btn[data-tooltip]::after { left: 50%; top: calc(100% + 8px); transform: translateX(-50%) translateY(-4px); }
.chat-head .icon-btn[data-tooltip]:hover::after { transform: translateX(-50%) translateY(0); }
.rail-badge { position: absolute; top: 7px; right: 7px; min-width: 15px; height: 15px; border-radius: 99px; background: var(--danger); border: 2px solid var(--bg-soft); color: #fff; font-size: 8px; font-weight: 750; display: grid; place-items: center; padding: 0 3px; }
.rail-bottom { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.rail-avatar { position: relative; width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(135deg, #7c5cff, #33dfc2); color: #fff; font-weight: 750; font-size: 14px; box-shadow: 0 0 0 2px var(--bg-soft), 0 0 0 3px var(--line-strong); }
.rail-avatar .presence-dot { position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border-radius: 50%; background: var(--success); border: 2px solid var(--bg-soft); }

.sidebar { background: var(--bg-soft); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.sidebar-head { padding: calc(24px + var(--safe-top)) 20px 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.sidebar-head h1 { font-family: var(--font-display); font-size: 21px; font-weight: 560; letter-spacing: -.04em; color: var(--text-strong); }
.sidebar-sub { display: flex; align-items: center; gap: 7px; margin-top: 6px; font-size: 11px; color: var(--faint); }
.head-actions { display: flex; gap: 6px; }
.sidebar-search {
  margin: 4px 16px 10px; display: flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 0 11px;
  transition: border-color .2s, box-shadow .2s;
}
.sidebar-search:focus-within { border-color: rgba(141,107,255,.4); box-shadow: 0 0 0 3px var(--accent-soft); }
.sidebar-search .icon { width: 16px; height: 16px; color: var(--faint); }
.sidebar-search input { flex: 1; min-width: 0; border: 0; background: none; outline: 0; padding: 10px 0; font-size: 12.5px; }
.sidebar-search input::placeholder { color: var(--faint); }
.sidebar-search kbd { margin-right: 2px; }
.sidebar-search.wide { margin: 0; flex: 1; max-width: 420px; }
.chat-list { flex: 1; overflow-y: auto; padding: 4px 10px 10px; min-height: 0; }
.chat-item {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 10px;
  border-radius: 16px; cursor: pointer; transition: background .18s ease, transform .18s ease; border: 1px solid transparent;
  animation: chatIn .3s ease both;
}
.chat-item:hover { background: var(--surface-2); }
.chat-item.active { background: var(--surface-2); border-color: var(--line); box-shadow: 0 6px 22px rgba(0,0,0,.08); }
.chat-item.active::before { content: ""; position: absolute; left: -10px; top: 50%; transform: translateY(-50%); width: 3px; height: 26px; border-radius: 4px; background: var(--gradient); }
.chat-item .avatar { width: 47px; height: 47px; border-radius: 15px; font-size: 16px; }
.chat-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.chat-item-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chat-item-name { font-size: 13.5px; font-weight: 650; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-time { font-size: 10px; color: var(--faint); flex: 0 0 auto; }
.chat-item-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chat-item-preview { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-preview .typing-preview { color: var(--accent-2); }
.chat-item-preview .prefix { color: var(--faint); }
.chat-unread { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--gradient); color: #fff; font-size: 9.5px; font-weight: 750; display: grid; place-items: center; box-shadow: 0 4px 12px rgba(115,86,246,.35); }
.chat-unread.muted { background: var(--surface-4); box-shadow: none; color: var(--muted); }
.chat-item .online-marker { position: absolute; left: 47px; top: 44px; width: 11px; height: 11px; border-radius: 50%; background: var(--success); border: 2.5px solid var(--bg-soft); }
.sidebar-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px calc(14px + var(--safe-bottom)); border-top: 1px solid var(--line); }
.sync-state { display: flex; align-items: center; gap: 7px; font-size: 10.5px; color: var(--faint); min-width: 0; }
.sync-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--warning); transition: background .2s; }
.sync-state.ok .sync-dot { background: var(--success); box-shadow: 0 0 0 3px rgba(64,224,180,.1); }
.sync-state.off .sync-dot { background: var(--danger); }
.mini-avatar-btn { width: 30px; height: 30px; border-radius: 10px; background: linear-gradient(135deg, #7c5cff, #33dfc2); color: #fff; font-size: 11px; font-weight: 750; display: grid; place-items: center; overflow: hidden; }
.mini-avatar-btn img { width: 100%; height: 100%; object-fit: cover; }

/* chat list empty */
.list-empty { padding: 36px 22px; text-align: center; color: var(--faint); }
.list-empty .icon { width: 28px; height: 28px; margin: 0 auto 12px; color: var(--faint); }
.list-empty strong { display: block; color: var(--muted); font-size: 13px; margin-bottom: 5px; }
.list-empty p { font-size: 11.5px; line-height: 1.5; }

/* ---------- main area / welcome ---------- */
.main-area { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg); overflow: hidden; }
.welcome-pane { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px; background: var(--wallpaper); position: relative; overflow: hidden; }
.welcome-pane::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.12) .5px, transparent .5px); background-size: 28px 28px; opacity: .08; mask-image: radial-gradient(50% 50% at 50% 40%, black, transparent 76%); }
.welcome-art { position: relative; width: 210px; height: 210px; display: grid; place-items: center; margin-bottom: 32px; }
.welcome-art img { width: 82px; height: 82px; border-radius: 26px; box-shadow: 0 24px 60px rgba(115,86,246,.42); animation: floatSoft 6s ease-in-out infinite; position: relative; z-index: 2; }
.welcome-ring { position: absolute; border-radius: 50%; border: 1px solid var(--line-strong); }
.welcome-ring.r1 { inset: 0; border-style: dashed; animation: orbitSpin 40s linear infinite; }
.welcome-ring.r2 { inset: 26px; border-color: rgba(141,107,255,.22); animation: orbitSpin 26s linear infinite reverse; }
.welcome-ring.r3 { inset: 54px; border-color: rgba(51,223,194,.2); animation: orbitSpin 18s linear infinite; }
.welcome-spark { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 12px var(--accent-2); }
.welcome-spark.s1 { top: 18px; right: 40px; }
.welcome-spark.s2 { bottom: 28px; left: 24px; background: var(--accent); box-shadow: 0 0 12px var(--accent); width: 4px; height: 4px; }
.welcome-spark.s3 { top: 52%; right: 4px; width: 3px; height: 3px; opacity: .6; }
.welcome-pane h2 { font-family: var(--font-display); font-size: clamp(22px, 2.5vw, 34px); letter-spacing: -.045em; font-weight: 520; margin-bottom: 12px; color: var(--text-strong); position: relative; }
.welcome-pane > p { max-width: 440px; color: var(--muted); font-size: 13px; line-height: 1.65; position: relative; }
.welcome-actions { display: flex; gap: 10px; margin-top: 26px; position: relative; }
.welcome-hints { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; margin-top: 40px; color: var(--faint); font-size: 10.5px; position: relative; }
.welcome-hints kbd { margin-right: 3px; }
.welcome-hints .icon { vertical-align: -2px; }

/* ---------- chat pane ---------- */
.chat-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--wallpaper); position: relative; animation: none; }
.chat-head { height: calc(64px + var(--safe-top)); padding: calc(var(--safe-top)) 10px 0; display: flex; align-items: center; gap: 6px; background: var(--glass); backdrop-filter: blur(24px) saturate(1.2); border-bottom: 1px solid var(--line); z-index: 8; flex: 0 0 auto; }
.back-btn { display: none; }
.chat-person { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; text-align: left; padding: 6px; margin-left: 0; border-radius: 14px; transition: background .2s; }
.chat-person:hover { background: var(--surface-2); }
.chat-person .avatar { width: 38px; height: 38px; border-radius: 12px; }
.chat-person-meta { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.chat-title { font-size: 14.5px; font-weight: 700; color: var(--text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.chat-sub { font-size: 10.5px; color: var(--faint); display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub .status-dot { width: 6px; height: 6px; }
.chat-head-actions { display: flex; gap: 3px; flex: 0 0 auto; }
.chat-head-actions .icon-btn { width: 38px; height: 38px; }
.chat-search { flex: 0 0 auto; display: flex; align-items: center; gap: 9px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--surface); animation: slideDown .22s ease; }
.chat-search .icon { width: 17px; height: 17px; color: var(--faint); }
.chat-search input { flex: 1; background: transparent; border: 0; outline: 0; padding: 5px 0; font-size: 13px; }
.messages-wrap { flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; position: relative; scroll-behavior: auto; }
.messages { display: flex; flex-direction: column; gap: 3px; padding: 22px clamp(16px, 4vw, 54px) 16px; max-width: 980px; margin: 0 auto; min-height: 100%; justify-content: flex-end; }
.date-divider { display: flex; align-items: center; justify-content: center; margin: 18px 0 14px; }
.date-divider span { font-size: 10px; font-weight: 600; color: var(--faint); background: var(--glass); border: 1px solid var(--line); border-radius: 99px; padding: 4px 11px; backdrop-filter: blur(10px); }
.msg-row { display: flex; align-items: flex-end; gap: 8px; padding: 1px 0; position: relative; animation: messageIn .26s cubic-bezier(.2,.7,.2,1) both; }
.msg-row.own { justify-content: flex-end; }
.msg-row.first-in-group { margin-top: 10px; }
.msg-avatar { width: 30px; height: 30px; flex: 0 0 30px; margin-bottom: 2px; }
.msg-avatar .avatar { width: 30px; height: 30px; border-radius: 10px; font-size: 11px; }
.msg-avatar.placeholder { visibility: hidden; }
.msg-stack { display: flex; flex-direction: column; max-width: min(72%, 620px); min-width: 0; }
.msg-row.own .msg-stack { align-items: flex-end; }
.msg-sender { font-size: 10.5px; font-weight: 650; padding: 0 8px 3px; color: var(--accent-2); }
.msg-bubble {
  position: relative; background: var(--bubble-other); border-radius: 18px 18px 18px 7px;
  padding: 9px 12px; box-shadow: var(--shadow-sm); min-width: 74px;
  border: 1px solid var(--line); overflow-wrap: anywhere;
}
.msg-row.own .msg-bubble { background: var(--bubble-own); color: var(--bubble-own-text); border: 0; border-radius: 18px 18px 7px 18px; box-shadow: 0 8px 24px rgba(103, 74, 230, .22); }
.msg-row.same-author .msg-bubble { border-radius: 14px 18px 18px 7px; }
.msg-row.own.same-author .msg-bubble { border-radius: 14px 18px 7px 18px; }
.msg-text { font-size: 13.5px; line-height: 1.46; white-space: pre-wrap; word-break: break-word; }
.msg-text a { color: var(--accent-2); text-decoration: underline; text-underline-offset: 2px; }
.msg-row.own .msg-text a { color: #c9fff7; }
.msg-text .emoji-only { font-size: 30px; line-height: 1.2; }
.msg-meta { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 3px; font-size: 9px; color: var(--faint); white-space: nowrap; user-select: none; }
.msg-row.own .msg-meta { color: rgba(255,255,255,.66); }
.msg-meta .edited { font-style: italic; font-size: 8.5px; opacity: .8; }
.msg-meta .icon { width: 13px; height: 13px; stroke-width: 2.2; }
.msg-meta .read { color: var(--accent-2); }
.msg-row.own .msg-meta .read { color: #b9fff3; }
.msg-meta .status-pending { opacity: .6; }
.msg-deleted { font-style: italic; opacity: .6; font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.msg-deleted .icon { width: 13px; height: 13px; }
.bubble-menu-btn {
  position: absolute; top: 50%; transform: translateY(-50%) scale(.85); right: -34px;
  width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
  opacity: 0; transition: opacity .15s ease, transform .15s ease; z-index: 3;
}
.msg-row.own .bubble-menu-btn { right: auto; left: -34px; }
.msg-row:hover .bubble-menu-btn { opacity: 1; transform: translateY(-50%) scale(1); }
.bubble-menu-btn:hover { color: var(--text); background: var(--surface-3); }
.msg-row.flash .msg-bubble { animation: bubbleFlash 1s ease; }
.msg-row.highlight .msg-bubble { box-shadow: 0 0 0 2px var(--accent-2), var(--shadow-sm); }
.msg-bubble.image-only { background: transparent; border: 0; box-shadow: none; padding: 0; min-width: 0; }
.msg-bubble.image-only .msg-image { margin: 0; }
.msg-bubble.image-only .msg-meta { position: absolute; right: 8px; bottom: 8px; margin: 0; padding: 3px 7px; border-radius: 8px; background: rgba(8,10,18,.52); color: rgba(255,255,255,.92); backdrop-filter: blur(6px); }
.msg-row.own .msg-bubble.image-only .msg-meta { color: rgba(255,255,255,.92); }
.msg-bubble.image-only .msg-meta .read { color: #b9fff3; }
.msg-bubble.image-only .bubble-menu-btn { right: -34px; left: auto; }

/* attachments */
.msg-image { max-width: 340px; max-height: 360px; border-radius: 13px; overflow: hidden; cursor: zoom-in; margin: -3px -4px 4px; background: var(--surface-3); position: relative; }
.msg-image img { width: 100%; height: auto; max-height: 360px; object-fit: cover; transition: transform .35s ease; }
.msg-image:hover img { transform: scale(1.025); }
.msg-image .img-hint { position: absolute; inset: auto 8px 8px auto; background: rgba(8,10,18,.6); color: #fff; border-radius: 7px; padding: 4px 7px; font-size: 8.5px; opacity: 0; transition: opacity .2s; backdrop-filter: blur(8px); }
.msg-image:hover .img-hint { opacity: 1; }
.msg-file { display: flex; align-items: center; gap: 11px; padding: 4px 2px; min-width: 240px; }
.file-icon { width: 42px; height: 42px; border-radius: 12px; background: var(--gradient-soft); border: 1px solid var(--line); display: grid; place-items: center; color: var(--accent-2); flex: 0 0 auto; }
.msg-row.own .file-icon { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.14); color: #fff; }
.msg-file-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.msg-file-name { font-size: 12px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-file-size { font-size: 9.5px; opacity: .6; }
.file-dl { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: inherit; opacity: .65; flex: 0 0 auto; }
.file-dl:hover { background: rgba(255,255,255,.12); opacity: 1; }
.msg-row:not(.own) .file-dl:hover { background: var(--surface-3); }
.voice-msg { display: flex; align-items: center; gap: 10px; min-width: 218px; padding: 3px; }
.voice-play { width: 37px; height: 37px; border-radius: 50%; background: var(--gradient); color: #fff; display: grid; place-items: center; flex: 0 0 auto; box-shadow: 0 6px 18px rgba(115,86,246,.3); }
.msg-row.own .voice-play { background: rgba(255,255,255,.22); box-shadow: none; }
.voice-play .icon { width: 15px; height: 15px; }
.voice-body { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.voice-wave { display: flex; align-items: center; gap: 2.5px; height: 22px; }
.voice-wave i { width: 2.5px; border-radius: 2px; background: var(--faint); opacity: .55; transition: opacity .2s, background .2s; }
.msg-row.own .voice-wave i { background: rgba(255,255,255,.7); }
.voice-wave i.played { background: var(--accent-2); opacity: 1; }
.msg-row.own .voice-wave i.played { background: #fff; }
.voice-meta { display: flex; justify-content: space-between; font-size: 9px; color: var(--faint); }
.msg-row.own .voice-meta { color: rgba(255,255,255,.65); }

.typing-bar { height: 26px; padding: 0 26px; font-size: 10.5px; color: var(--accent-2); display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--accent-2); animation: typing 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }

/* composer */
.composer { margin: 0 clamp(12px, 2.5vw, 28px) calc(14px + var(--safe-bottom)); padding: 8px; background: var(--glass); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-md); backdrop-filter: blur(24px); flex: 0 0 auto; position: relative; transition: border-color .2s, box-shadow .2s; }
.composer:focus-within { border-color: rgba(141,107,255,.3); box-shadow: 0 18px 50px rgba(0,0,0,.28), 0 0 0 3px var(--accent-soft); }
.composer-row { display: flex; align-items: flex-end; gap: 3px; }
.composer .icon-btn { width: 38px; height: 38px; border-radius: 11px; margin-bottom: 1px; }
.input-wrap { flex: 1; min-width: 0; display: flex; }
#messageInput { width: 100%; background: none; border: 0; outline: 0; padding: 9px 6px; max-height: 148px; font-size: 13.5px; line-height: 1.45; color: var(--text); }
#messageInput::placeholder { color: var(--faint); }
.send-btn { width: 40px; height: 40px; border-radius: 13px; background: var(--gradient); color: #fff; display: grid; place-items: center; flex: 0 0 auto; box-shadow: 0 8px 20px rgba(115,86,246,.32); transition: transform .18s ease, opacity .18s ease; margin-bottom: 1px; }
.send-btn:hover { transform: translateY(-1px) scale(1.02); }
.send-btn:active { transform: scale(.95); }
.send-btn .icon { width: 18px; height: 18px; }
.send-btn.mic-mode { background: var(--surface-3); color: var(--muted); box-shadow: none; }
.composer-meta { display: flex; align-items: center; justify-content: space-between; padding: 2px 8px 1px; min-height: 15px; gap: 12px; }
.composer-meta > span:first-child { font-size: 8.5px; color: var(--faint); opacity: .75; }
.upload-progress { display: flex; align-items: center; gap: 8px; font-size: 9.5px; color: var(--accent-2); }
.progress-track { width: 70px; height: 3px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.progress-track i { display: block; height: 100%; width: 0; background: var(--gradient); border-radius: 4px; transition: width .2s; }
.recording-bar { display: flex; align-items: center; gap: 10px; padding: 7px 8px; font-size: 12px; color: var(--text); animation: fadeIn .2s ease; }
.recording-bar strong { color: var(--danger); font-variant-numeric: tabular-nums; margin-right: auto; }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: livePulse 1s infinite; }
.rec-stop { width: 38px; height: 38px; border-radius: 12px; background: var(--danger); display: grid; place-items: center; }
.rec-stop span { width: 12px; height: 12px; background: #fff; border-radius: 3px; }
.composer.recording .composer-row, .composer.recording .composer-meta { display: none; }
.drop-overlay { position: absolute; inset: -8px; z-index: 20; border-radius: 22px; background: var(--glass-strong); border: 2px dashed var(--accent); display: grid; place-items: center; animation: fadeIn .15s; }
.drop-overlay div { display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--accent-2); font-size: 13px; }
.drop-overlay .icon { width: 32px; height: 32px; }
.edit-banner { display: flex; align-items: center; gap: 11px; margin: 0 clamp(12px, 2.5vw, 28px) 8px; padding: 9px 12px; background: var(--glass); border: 1px solid var(--line); border-left: 3px solid var(--accent-2); border-radius: 12px; backdrop-filter: blur(18px); animation: slideUp .2s ease; flex: 0 0 auto; }
.edit-banner > .icon { color: var(--accent-2); width: 17px; height: 17px; }
.edit-banner div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.edit-banner strong { font-size: 10.5px; color: var(--text); }
.edit-banner span { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.edit-banner .icon-btn { color: var(--muted); }
.scroll-bottom { position: absolute; right: 26px; bottom: 22px; width: 40px; height: 40px; border-radius: 13px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-md); display: grid; place-items: center; color: var(--muted); z-index: 5; transition: opacity .2s, transform .2s; }
.scroll-bottom:hover { color: var(--text); transform: translateY(-2px); }
.scroll-bottom #scrollUnread { position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; border-radius: 99px; background: var(--accent); color: #fff; font-size: 8px; display: grid; place-items: center; padding: 0 4px; }

/* ---------- page panes ---------- */
.pane { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--bg); overflow: hidden; animation: fadeIn .2s ease; }
.page-head { min-height: calc(84px + var(--safe-top)); padding: calc(18px + var(--safe-top)) clamp(18px, 3vw, 34px) 16px; display: flex; align-items: center; gap: 15px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.page-head .back-btn { display: none; }
.page-head h2 { font-family: var(--font-display); font-size: 23px; font-weight: 560; letter-spacing: -.04em; color: var(--text-strong); }
.page-head p { font-size: 11.5px; color: var(--faint); margin-top: 4px; }
.page-head .btn { margin-left: auto; }
.page-head-spacer { margin-left: auto; }
.page-toolbar { display: flex; align-items: center; gap: 12px; padding: 14px clamp(18px, 3vw, 34px); border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.contacts-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; padding: 20px clamp(18px, 3vw, 34px) 24px; overflow-y: auto; }
.contacts-list { display: flex; flex-direction: column; gap: 4px; align-content: start; }
.contact-row { display: flex; align-items: center; gap: 13px; padding: 12px; border-radius: 16px; border: 1px solid transparent; transition: background .18s, border-color .18s, transform .18s; cursor: pointer; animation: fadeUp .3s ease both; }
.contact-row:hover { background: var(--surface-2); border-color: var(--line); transform: translateX(2px); }
.contact-row .avatar { width: 45px; height: 45px; border-radius: 14px; }
.contact-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.contact-name { font-size: 13.5px; font-weight: 650; color: var(--text); }
.contact-sub { font-size: 11px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-sub .status-dot { margin-right: 4px; }
.contact-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.contact-row:hover .contact-actions { opacity: 1; }
.contact-row .icon-btn { width: 34px; height: 34px; }
.contacts-side-card { position: sticky; top: 0; align-self: start; overflow: hidden; border-radius: 24px; padding: 28px 22px; background: var(--surface-2); border: 1px solid var(--line); text-align: center; }
.side-card-orb { position: absolute; width: 200px; height: 200px; border-radius: 50%; background: var(--gradient); filter: blur(70px); opacity: .14; top: -100px; right: -50px; pointer-events: none; }
.contacts-side-card > .icon { width: 38px; height: 38px; color: var(--accent-2); margin: 0 auto 16px; position: relative; }
.contacts-side-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.contacts-side-card p { font-size: 11.5px; color: var(--muted); line-height: 1.55; margin-bottom: 18px; }
.contacts-layout .list-empty { grid-column: 1 / -1; }
.contacts-helper { padding: 10px 4px; font-size: 10.5px; color: var(--faint); }

/* settings */
.settings-pane { overflow: hidden; }
.settings-scroll { flex: 1; overflow-y: auto; padding: 22px clamp(18px, 3vw, 34px) 40px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; max-width: 1060px; margin: 0 auto; align-content: start; }
.settings-card { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 20px; box-shadow: var(--shadow-sm); animation: fadeUp .35s ease both; }
.settings-card.profile-card { grid-column: 1 / -1; }
.settings-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.settings-card-head h3 { font-size: 15px; font-weight: 700; margin-top: 3px; letter-spacing: -.01em; }
.profile-editor { display: flex; gap: 20px; align-items: center; margin-bottom: 17px; }
.avatar-edit { position: relative; flex: 0 0 auto; }
.avatar-edit .avatar { box-shadow: 0 12px 30px rgba(0,0,0,.16); }
.avatar-edit-badge { position: absolute; right: -5px; bottom: -5px; width: 30px; height: 30px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line-strong); display: grid; place-items: center; color: var(--text); box-shadow: var(--shadow-sm); }
.avatar-edit-badge .icon { width: 14px; height: 14px; }
.profile-fields { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; min-width: 0; }
.field.compact .field-label { font-size: 10.5px; }
.field.compact .field-shell { min-height: 42px; border-radius: 11px; }
.field.compact .field-shell input { padding: 9px 0; font-size: 13px; }
.textarea-shell { align-items: flex-start; position: relative; }
.field-shell textarea { padding: 11px 0; line-height: 1.45; }
.field-count { position: absolute; right: 11px; bottom: 7px; font-size: 8.5px; color: var(--faint); }
.settings-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.settings-actions.between { justify-content: space-between; }
.saved-hint { color: var(--success); font-size: 11px; animation: fadeIn .2s; }
.theme-options { display: flex; flex-direction: column; gap: 7px; margin-bottom: 17px; }
.theme-option { display: flex; align-items: center; gap: 11px; padding: 8px; border-radius: 13px; border: 1px solid var(--line); text-align: left; transition: border-color .18s, background .18s; }
.theme-option:hover { background: var(--surface-2); }
.theme-option.active { border-color: rgba(141,107,255,.4); background: var(--accent-soft); }
.theme-preview { width: 42px; height: 32px; border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; gap: 3px; padding: 5px 4px; flex: 0 0 auto; border: 1px solid var(--line); }
.theme-preview i { display: block; height: 5px; border-radius: 2px; }
.theme-preview i:last-child { width: 66%; }
.theme-preview.light { background: #f4f1fb; }
.theme-preview.light i { background: #c9c1dd; }
.theme-preview.light i:first-child { background: #6547e8; }
.theme-preview.dark { background: #131728; }
.theme-preview.dark i { background: #2c3452; }
.theme-preview.dark i:first-child { background: #8d6bff; }
.theme-preview.system { background: linear-gradient(110deg, #f4f1fb 50%, #131728 50%); }
.theme-preview.system i { background: linear-gradient(110deg, #c9c1dd 50%, #2c3452 50%); }
.theme-option > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.theme-option strong { font-size: 12px; font-weight: 650; }
.theme-option small { font-size: 9.5px; color: var(--faint); }
.theme-option .tick { width: 16px; height: 16px; color: var(--accent-2); opacity: 0; }
.theme-option.active .tick { opacity: 1; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 0; border-top: 1px solid var(--line); }
.setting-row > div { display: flex; flex-direction: column; gap: 2px; }
.setting-row strong { font-size: 12px; font-weight: 600; }
.setting-row small { font-size: 9.5px; color: var(--faint); }
.switch { width: 40px; height: 23px; border-radius: 99px; background: var(--surface-4); position: relative; transition: background .2s; flex: 0 0 auto; }
.switch span { position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: transform .24s cubic-bezier(.2,.8,.2,1); box-shadow: 0 2px 5px rgba(0,0,0,.25); }
.switch.on { background: var(--gradient); }
.switch.on span { transform: translateX(17px); }
.server-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 9.5px; font-weight: 650; color: var(--success); background: rgba(64,224,180,.09); padding: 5px 9px; border-radius: 99px; }
.server-pill.off { color: var(--danger); background: var(--danger-soft); }
.server-pill.off .status-dot { background: var(--danger); }
.server-address-row { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; flex-wrap: wrap; }
.server-icon { width: 38px; height: 38px; border-radius: 11px; background: var(--gradient-soft); display: grid; place-items: center; color: var(--accent-2); flex: 0 0 auto; }
.server-icon .icon { width: 18px; height: 18px; }
.server-info { flex: 1; min-width: 120px; display: flex; flex-direction: column; gap: 1px; }
.server-info strong { font-size: 12px; font-weight: 600; word-break: break-all; }
.server-info small { font-size: 9.5px; color: var(--faint); }
.server-address-row .btn { padding: 7px 10px; font-size: 10.5px; }
.server-public { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 9px 12px; border-radius: 11px; background: rgba(51,223,194,.06); border: 1px solid rgba(51,223,194,.12); }
.server-public > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.server-public span { font-size: 9px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.server-public strong { font-size: 10.5px; font-weight: 550; color: var(--accent-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-note { display: flex; gap: 7px; align-items: flex-start; margin-top: 12px; color: var(--faint); font-size: 9.5px; line-height: 1.5; }
.settings-note.inline { margin: 0; align-items: center; }
.settings-note .icon { width: 13px; height: 13px; color: var(--success); margin-top: 1px; }
.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 13px; overflow: hidden; margin-bottom: 16px; }
.about-cell { background: var(--surface); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.about-cell span { font-size: 8.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.about-cell strong { font-size: 11px; font-weight: 600; }
.mobile-nav { display: none; }

/* ---------- modal system ---------- */
.modal-root { position: fixed; inset: 0; z-index: 70; pointer-events: none; }
.modal-overlay {
  position: fixed; inset: 0; background: rgba(5, 6, 12, 0.58); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; padding: 22px;
  pointer-events: auto; animation: fadeIn .18s ease; z-index: 71; overflow-y: auto;
}
html[data-theme="light"] .modal-overlay { background: rgba(30, 22, 60, .3); }
.modal {
  width: min(100%, 500px); max-height: min(90dvh, 820px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 26px;
  box-shadow: var(--shadow-lg); animation: modalIn .3s cubic-bezier(.2,.8,.2,1) both; overflow: hidden;
}
.modal.wide { width: min(100%, 640px); }
.modal.narrow { width: min(100%, 420px); }
.modal-head { display: flex; align-items: flex-start; gap: 14px; padding: 22px 22px 0; flex: 0 0 auto; }
.modal-head > div:first-child { flex: 1; min-width: 0; }
.modal-head h3 { font-family: var(--font-display); font-size: 19px; font-weight: 550; letter-spacing: -.03em; color: var(--text-strong); }
.modal-head p { font-size: 11.5px; color: var(--faint); margin-top: 5px; line-height: 1.5; }
.modal-head .icon-btn { margin-top: -4px; }
.modal-body { padding: 18px 22px; overflow-y: auto; min-height: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 9px; padding: 0 22px 22px; flex: 0 0 auto; }
.modal-foot .btn { min-width: 96px; }
.modal-section { margin-bottom: 17px; }
.modal-section:last-child { margin-bottom: 0; }
.modal-label { font-size: 10.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.modal-label .text-btn { text-transform: none; letter-spacing: 0; }
.tabs { display: flex; background: var(--surface-2); padding: 4px; border-radius: 11px; border: 1px solid var(--line); gap: 3px; margin-bottom: 16px; }
.tabs .tab { flex: 1; padding: 8px; border-radius: 8px; font-size: 11.5px; font-weight: 650; color: var(--muted); transition: background .18s, color .18s; }
.tabs .tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.user-search-box { display: flex; align-items: center; gap: 9px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; margin-bottom: 10px; }
.user-search-box:focus-within { border-color: rgba(141,107,255,.4); box-shadow: 0 0 0 3px var(--accent-soft); }
.user-search-box .icon { width: 16px; height: 16px; color: var(--faint); }
.user-search-box input { flex: 1; background: none; border: 0; outline: 0; padding: 11px 0; font-size: 12.5px; }
.user-list { display: flex; flex-direction: column; gap: 2px; max-height: 330px; overflow-y: auto; }
.user-row { display: flex; align-items: center; gap: 11px; padding: 8px; border-radius: 12px; transition: background .15s; }
.user-row:hover { background: var(--surface-2); }
.user-row .avatar { width: 38px; height: 38px; border-radius: 12px; font-size: 13px; }
.user-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.user-row-name { font-size: 12.5px; font-weight: 650; display: flex; align-items: center; gap: 6px; }
.user-row-sub { font-size: 10px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row .btn { padding: 6px 10px; font-size: 10px; border-radius: 8px; }
.user-row .icon-btn { width: 30px; height: 30px; }
.check-user { width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--line-strong); display: grid; place-items: center; color: transparent; flex: 0 0 auto; transition: all .15s; }
.user-row.selected .check-user { background: var(--gradient); border-color: transparent; color: #fff; }
.user-row.selected { background: var(--accent-soft); }
.check-user .icon { width: 12px; height: 12px; stroke-width: 2.5; }
.selected-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.selected-chip { display: inline-flex; align-items: center; gap: 5px; background: var(--accent-soft); border: 1px solid rgba(141,107,255,.2); border-radius: 99px; padding: 3px 8px 3px 4px; font-size: 10px; }
.selected-chip .avatar { width: 20px; height: 20px; border-radius: 50%; font-size: 8px; }
.selected-chip button { display: grid; place-items: center; width: 13px; height: 13px; color: var(--muted); }
.selected-chip button .icon { width: 10px; height: 10px; }
.input-plain { width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; outline: 0; font-size: 12.5px; }
.input-plain:focus { border-color: rgba(141,107,255,.4); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-hint { text-align: center; padding: 24px 12px; color: var(--faint); font-size: 11.5px; line-height: 1.5; }
.search-hint .icon { width: 25px; height: 25px; margin: 0 auto 8px; opacity: .7; }
.searching-spinner { width: 18px; height: 18px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin: 26px auto; }
.profile-hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 4px 0 18px; }
.profile-hero .avatar { width: 88px; height: 88px; border-radius: 28px; font-size: 30px; margin-bottom: 13px; }
.profile-hero h3 { font-family: var(--font-display); font-size: 20px; font-weight: 550; letter-spacing: -.03em; }
.profile-hero .username { color: var(--faint); font-size: 11px; margin-top: 3px; display: inline-flex; align-items: center; gap: 5px; }
.developer-badge { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; border-radius: 50%; color: var(--accent); background: var(--accent-soft); vertical-align: middle; }
.developer-badge .icon { width: 11px; height: 11px; }
.profile-hero .status-line { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--muted); margin-top: 8px; }
.profile-bio { padding: 12px 14px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; color: var(--muted); text-align: center; margin-bottom: 14px; }
.profile-actions { display: flex; gap: 8px; }
.profile-actions .btn { flex: 1; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-radius: 10px; }
.member-row:hover { background: var(--surface-2); }
.member-row[role="button"] { cursor: pointer; }
.member-row[role="button"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.member-row .avatar { width: 34px; height: 34px; border-radius: 10px; font-size: 12px; }
.member-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.member-name { font-size: 12px; font-weight: 600; }
.member-role { font-size: 9px; color: var(--faint); }
.member-row .icon-btn { width: 28px; height: 28px; color: var(--faint); }
.member-row .icon-btn:hover { color: var(--danger); background: var(--danger-soft); }
.group-avatar-edit { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.group-avatar-edit .avatar { width: 62px; height: 62px; border-radius: 19px; font-size: 23px; }
.group-avatar-edit .btn { padding: 7px 10px; font-size: 10px; }
.admin-note { padding: 10px 12px; background: var(--accent-soft); border: 1px solid rgba(141,107,255,.16); border-radius: 11px; font-size: 10px; color: var(--muted); line-height: 1.5; margin-top: 12px; }
.server-input-row { display: flex; gap: 8px; }
.server-input-row .input-plain { flex: 1; font-family: ui-monospace, "Cascadia Code", monospace; font-size: 11.5px; }
.test-result { margin-top: 10px; font-size: 11px; border-radius: 10px; padding: 9px 11px; display: flex; align-items: center; gap: 7px; }
.test-result.ok { color: var(--success); background: rgba(64,224,180,.08); }
.test-result.err { color: var(--danger); background: var(--danger-soft); }
.pin-hint { font-size: 9.5px; color: var(--faint); margin-top: 7px; }
.confirm-text { font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.confirm-text strong { color: var(--text); }
.danger-zone { border-color: rgba(255,111,145,.18); background: var(--danger-soft); }
.danger-zone .modal-head p { color: var(--danger); }

/* toasts */
.toast-root { position: fixed; top: calc(18px + var(--safe-top)); right: 22px; z-index: 100; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; width: min(92vw, 390px); }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 11px 15px; border-radius: 13px;
  background: var(--glass-strong); border: 1px solid var(--line-strong); color: var(--text);
  font-size: 12px; box-shadow: var(--shadow-md); backdrop-filter: blur(22px);
  animation: toastIn .3s cubic-bezier(.2,.8,.2,1) both; pointer-events: auto; width: 100%;
}
.toast.leaving { animation: toastOut .2s ease both; }
.toast .icon { width: 16px; height: 16px; color: var(--accent-2); flex: 0 0 auto; }
.toast.error .icon { color: var(--danger); }
.toast.success .icon { color: var(--success); }
.toast-body { flex: 1; min-width: 0; }
.toast strong { display: block; font-size: 11.5px; font-weight: 650; margin-bottom: 1px; }
.toast span { display: block; font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* context menu / emoji */
.context-menu { position: fixed; z-index: 80; min-width: 186px; padding: 5px; background: var(--glass-strong); border: 1px solid var(--line-strong); border-radius: 13px; box-shadow: var(--shadow-lg); backdrop-filter: blur(24px); animation: menuIn .15s ease both; }
.context-item { width: 100%; display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px; font-size: 11.5px; color: var(--text); text-align: left; transition: background .13s; }
.context-item:hover { background: var(--surface-2); }
.context-item .icon { width: 15px; height: 15px; color: var(--muted); }
.context-item.danger { color: var(--danger); }
.context-item.danger .icon { color: var(--danger); }
.context-sep { height: 1px; background: var(--line); margin: 4px 6px; }
.emoji-panel { position: fixed; z-index: 75; width: 310px; max-height: 300px; overflow-y: auto; padding: 12px; background: var(--glass-strong); border: 1px solid var(--line-strong); border-radius: 18px; box-shadow: var(--shadow-lg); backdrop-filter: blur(24px); animation: menuIn .18s ease both; }
.emoji-cats { display: flex; gap: 3px; margin-bottom: 8px; }
.emoji-cat { padding: 4px 8px; border-radius: 7px; font-size: 13px; opacity: .55; }
.emoji-cat.active { background: var(--accent-soft); opacity: 1; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 1px; }
.emoji-grid button { font-size: 19px; padding: 5px; border-radius: 7px; line-height: 1; transition: background .12s, transform .12s; }
.emoji-grid button:hover { background: var(--surface-3); transform: scale(1.15); }
.emoji-title { font-size: 9px; color: var(--faint); text-transform: uppercase; letter-spacing: .1em; margin: 6px 2px; }

/* lightbox */
.lightbox { position: fixed; inset: 0; z-index: 95; background: rgba(4, 5, 10, .94); backdrop-filter: blur(10px); display: flex; flex-direction: column; animation: fadeIn .2s; }
.lightbox-close { position: absolute; top: calc(18px + var(--safe-top)); right: 18px; z-index: 3; width: 42px; height: 42px; border-radius: 13px; background: rgba(255,255,255,.09); color: #fff; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.12); }
.lightbox-close:hover { background: rgba(255,255,255,.16); }
.lightbox-stage { flex: 1; display: grid; place-items: center; padding: 50px 24px 20px; min-height: 0; }
.lightbox-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 10px; box-shadow: 0 30px 90px rgba(0,0,0,.5); animation: lightboxIn .3s ease; }
.lightbox-bar { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 14px 20px calc(20px + var(--safe-bottom)); color: rgba(255,255,255,.6); font-size: 11px; }
.lightbox-bar .btn { color: #fff; }

/* misc */
.empty-block { padding: 50px 20px; text-align: center; color: var(--faint); }
.empty-block .icon { width: 36px; height: 36px; margin: 0 auto 14px; color: var(--faint); }
.empty-block h4 { color: var(--text); font-size: 14px; margin-bottom: 5px; }
.empty-block p { font-size: 11.5px; line-height: 1.5; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 8px; }
.linkified { color: var(--accent-2); text-decoration: underline; text-underline-offset: 2px; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }

/* ---------- animations ---------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes chatIn { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }
@keyframes messageIn { from { opacity: 0; transform: translateY(7px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes menuIn { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes orbitSpin { to { transform: rotate(360deg); } }
@keyframes floatSoft { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes auroraDrift { 0% { transform: translate3d(-2%, -1%, 0) scale(1); } 100% { transform: translate3d(3%, 2%, 0) scale(1.06); } }
@keyframes livePulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .5; transform: scale(.82); } }
@keyframes typing { 0%,60%,100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes bubbleFlash { 0%,100% { box-shadow: var(--shadow-sm); } 35% { box-shadow: 0 0 0 3px var(--accent-2); } }
@keyframes lightboxIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }

/* ---------- channels ---------- */
.channel-banner {
  margin: 0 12px 10px; padding: 8px 8px 8px 10px; display: flex; align-items: center; gap: 6px;
  border: 1px solid rgba(141,107,255,.28); border-radius: 15px;
  background: linear-gradient(135deg, rgba(141,107,255,.18), rgba(51,223,194,.08));
  box-shadow: 0 10px 28px rgba(0,0,0,.12); animation: fadeUp .3s ease both;
}
.channel-banner-main { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; text-align: left; }
.channel-banner-avatar { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex: 0 0 auto; color: #fff; background: var(--gradient); box-shadow: 0 6px 16px rgba(115,86,246,.28); }
.channel-banner-avatar .icon { width: 17px; height: 17px; }
.channel-banner-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.channel-banner-text strong { font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-banner-text small { font-size: 9.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-banner .icon-btn { width: 28px; height: 28px; border-radius: 9px; color: var(--faint); }
.channels-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 18px clamp(14px, 3vw, 32px) 28px; }
.channels-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; max-width: 1080px; margin: 0 auto; align-items: start; }
.channels-list { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.channel-card { display: flex; align-items: center; gap: 13px; padding: 13px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; transition: background .18s, border-color .18s, transform .18s; }
.channel-card:hover { background: var(--surface-2); border-color: var(--line-strong); transform: translateY(-1px); }
.channel-card .avatar { width: 48px; height: 48px; border-radius: 15px; font-size: 16px; }
.channel-card-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.channel-card-top { display: flex; align-items: center; gap: 7px; min-width: 0; }
.channel-card-top strong { font-size: 13.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-card-desc { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-card-meta { font-size: 9.5px; color: var(--faint); display: flex; align-items: center; gap: 7px; }
.channel-card-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.channel-side-card { position: sticky; top: 12px; }
.pill.channel-pill { background: var(--accent-soft); color: var(--accent-2); border-color: transparent; }
.privacy-row { align-items: center; gap: 14px; padding-top: 14px; border-top: 1px solid var(--line); margin-top: 12px; }
.privacy-row > div { flex: 1; min-width: 0; }
.select-plain { width: 160px; flex: 0 0 auto; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; color: var(--text); padding: 9px 10px; outline: 0; font-size: 12px; }
.select-plain:focus { border-color: rgba(141,107,255,.45); box-shadow: 0 0 0 3px var(--accent-soft); }
.channel-readonly { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 12px; color: var(--faint); font-size: 12px; text-align: center; }
.channel-readonly .icon { width: 16px; height: 16px; color: var(--accent-2); }
.composer.read-only .composer-row, .composer.read-only .composer-meta { display: none; }
.retry-send { display: inline-flex; align-items: center; gap: 3px; color: var(--danger); font-size: 9.5px; font-weight: 650; }
.retry-send .icon { width: 12px; height: 12px; }

/* ---------- calls ---------- */
.call-overlay { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 18px; background: rgba(5,7,14,.72); backdrop-filter: blur(18px); animation: fadeIn .2s ease; }
.call-card { width: min(440px, 100%); max-height: 92dvh; overflow: hidden; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 28px; box-shadow: var(--shadow-lg); position: relative; }
.call-top { padding: 24px 22px 14px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.call-avatar { width: 86px; height: 86px; border-radius: 28px; display: grid; place-items: center; background: var(--gradient); color: #fff; font-size: 28px; font-weight: 750; margin-bottom: 6px; box-shadow: 0 16px 40px rgba(115,86,246,.32); }
.call-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.call-name { font-family: var(--font-display); font-size: 19px; letter-spacing: -.03em; color: var(--text-strong); }
.call-status { font-size: 11.5px; color: var(--muted); min-height: 16px; }
.call-status .status-dot { margin-right: 5px; }
.call-videos { position: relative; padding: 0 16px; }
.call-remote { width: 100%; aspect-ratio: 4/3; border-radius: 18px; background: #05070d; object-fit: cover; display: block; }
.call-local { position: absolute; width: 30%; aspect-ratio: 3/4; right: 24px; bottom: 10px; border-radius: 12px; background: #0b0e18; border: 1px solid var(--line-strong); object-fit: cover; display: block; transform: scaleX(-1); }
.call-videos.audio-only .call-local { display: none; }
.call-videos.audio-only .call-remote { display: none; }
.call-actions { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 22px 20px 26px; }
.call-btn { width: 52px; height: 52px; border-radius: 18px; display: grid; place-items: center; background: var(--surface-3); color: var(--text); border: 1px solid var(--line); transition: transform .15s, background .18s; }
.call-btn .icon { width: 21px; height: 21px; }
.call-btn:hover { transform: translateY(-2px); background: var(--surface-4); }
.call-btn:active { transform: scale(.95); }
.call-btn.danger { background: var(--danger); color: #fff; border-color: transparent; box-shadow: 0 10px 26px rgba(255,111,145,.3); }
.call-btn.accept { background: var(--success); color: #05221b; border-color: transparent; box-shadow: 0 10px 26px rgba(64,224,180,.28); }
.call-btn.muted { background: var(--danger-soft); color: var(--danger); border-color: rgba(255,111,145,.25); }
.call-timer { position: absolute; top: 18px; right: 18px; font-size: 10px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; padding: 4px 9px; font-variant-numeric: tabular-nums; }
.voice-room-bar { position: absolute; left: 50%; top: calc(76px + var(--safe-top)); transform: translateX(-50%); z-index: 9; display: flex; align-items: center; gap: 9px; padding: 7px 8px 7px 12px; border-radius: 99px; background: var(--glass-strong); border: 1px solid rgba(64,224,180,.28); box-shadow: var(--shadow-md); backdrop-filter: blur(20px); font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.voice-room-bar .icon { width: 14px; height: 14px; color: var(--success); }
.voice-room-bar .voice-people { color: var(--text); font-weight: 650; }
.voice-room-bar .icon-btn { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-3); }
@media (max-width: 1180px) {
  .channels-layout { grid-template-columns: minmax(0, 1fr) 260px; }
}
@media (max-width: 1020px) {
  .channels-layout { grid-template-columns: 1fr; }
  .channel-side-card { display: none; }
}
@media (max-width: 900px) {
  .main-screen.view-channels .sidebar,
  .main-screen.view-channels .rail { display: none; }
  .main-screen.view-channels .main-area { display: flex; padding-bottom: calc(61px + var(--safe-bottom)); }
  .main-screen.view-channels .mobile-nav { display: flex; }
  .main-screen.view-channels .welcome-pane,
  .main-screen.view-channels .chat-pane { display: none; }
  .channels-scroll { padding: 12px 12px 24px; }
  .channel-banner { margin-bottom: 12px; }
  .privacy-row { align-items: flex-start; flex-direction: column; gap: 9px; }
  .select-plain { width: 100%; }
  .call-card { border-radius: 24px; }
  .voice-room-bar { top: calc(68px + var(--safe-top)); font-size: 10px; }
}

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .main-screen { grid-template-columns: 70px 318px minmax(0, 1fr); }
  .rail-btn { width: 42px; height: 42px; }
  .rail-logo { width: 38px; height: 38px; }
  .auth-visual { padding: 30px 36px 24px; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-card.profile-card { grid-column: auto; }
  .contacts-layout { grid-template-columns: minmax(0, 1fr) 260px; }
}
@media (max-width: 1020px) {
  .main-screen { grid-template-columns: 64px 300px minmax(0, 1fr); }
  .rail-nav { margin-top: 26px; gap: 4px; }
  .rail { padding-top: 14px; }
  .sidebar-head { padding-left: 16px; padding-right: 16px; }
  .chat-item .avatar { width: 43px; height: 43px; }
  .chat-item .online-marker { left: 43px; top: 41px; }
  .contacts-layout { grid-template-columns: 1fr; }
  .contacts-side-card { display: none; }
  .auth-screen { grid-template-columns: minmax(0, 1fr) minmax(390px, .95fr); }
  .orbit-scene { opacity: .55; }
}
@media (max-width: 900px) {
  .main-screen { display: flex; padding-bottom: 0; }
  .rail { display: none; }
  .sidebar { width: 100%; flex: 1; border-right: 0; }
  .main-area { display: none; width: 100%; }
  .mobile-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--glass-strong); backdrop-filter: blur(26px) saturate(1.3);
    border-top: 1px solid var(--line); padding: 7px 6px calc(7px + var(--safe-bottom));
    justify-content: space-around;
  }
  .mnav-btn { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 5px 2px; border-radius: 12px; color: var(--faint); font-size: 9px; font-weight: 550; transition: color .18s; }
  .mnav-btn .icon { width: 21px; height: 21px; }
  .mnav-btn.active { color: var(--accent-2); }
  .mnav-btn.active::before { content: ""; position: absolute; top: -8px; width: 22px; height: 2px; border-radius: 2px; background: var(--accent-2); box-shadow: 0 0 8px var(--accent-2); }
  .mnav-badge { position: absolute; top: 1px; right: calc(50% - 18px); min-width: 15px; height: 15px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 8px; display: grid; place-items: center; padding: 0 3px; border: 2px solid var(--bg-soft); }
  .sidebar-head { padding-top: calc(18px + var(--safe-top)); }
  .sidebar-head h1 { font-size: 24px; }
  .chat-list { padding-bottom: 14px; }
  .sidebar-foot { display: none; }
  .main-screen.view-chats .sidebar { display: flex; }
  .main-screen.view-chats .main-area { display: none; }
  .main-screen.view-chats.chat-open .sidebar { display: none; }
  .main-screen.view-chats.chat-open .main-area { display: flex; }
  .main-screen.view-chats.chat-open .mobile-nav { display: none; }
  .main-screen.view-contacts .sidebar, .main-screen.view-settings .sidebar { display: none; }
  .main-screen.view-contacts .main-area, .main-screen.view-settings .main-area { display: flex; padding-bottom: calc(61px + var(--safe-bottom)); }
  .main-screen.view-contacts .mobile-nav, .main-screen.view-settings .mobile-nav { display: flex; }
  .main-screen.view-contacts .welcome-pane, .main-screen.view-contacts .chat-pane,
  .main-screen.view-settings .welcome-pane, .main-screen.view-settings .chat-pane { display: none; }
  .main-screen.view-settings .mobile-nav .mnav-btn.active, .main-screen.view-contacts .mobile-nav .mnav-btn.active { color: var(--accent-2); }
  .page-head { min-height: 70px; padding: calc(13px + var(--safe-top)) 16px 12px; }
  .page-head .back-btn { display: inline-flex; }
  .page-head h2 { font-size: 20px; }
  .page-head .btn span { display: none; }
  .page-head .btn { padding: 9px; }
  .page-head .btn .icon { margin: 0; }
  .page-toolbar { padding: 12px 16px; }
  .contacts-layout { padding: 14px 12px 20px; }
  .contact-actions { opacity: 1; }
  .settings-scroll { padding: 14px 12px 28px; }
  .settings-grid { gap: 12px; }
  .settings-card { padding: 16px; border-radius: 19px; }
  .profile-editor { flex-direction: column; align-items: flex-start; gap: 14px; }
  .profile-fields { width: 100%; grid-template-columns: 1fr; }
  .settings-order { display: flex; flex-direction: column; }
  .chat-pane { height: 100%; }
  .chat-head { height: calc(64px + var(--safe-top)); padding: calc(var(--safe-top)) 10px 0; gap: 6px; }
  .back-btn { display: inline-flex !important; }
  .chat-person { margin-left: 0; gap: 9px; }
  .chat-head-actions { gap: 3px; flex: 0 0 auto; }
  .chat-head-actions .icon-btn { width: 36px; height: 36px; }
  .chat-head-actions #chatSearchBtn,
  .chat-head-actions #chatInfoBtn { display: none !important; }
  .chat-person .avatar { width: 38px; height: 38px; border-radius: 12px; }
  .channel-banner {
    position: fixed; left: 12px; right: 12px; bottom: calc(72px + var(--safe-bottom));
    margin: 0; z-index: 35;
  }
  .messages { padding: 16px 12px 8px; }
  .msg-stack { max-width: 84%; }
  .msg-bubble { padding: 8px 11px; }
  .msg-text { font-size: 13.5px; }
  .bubble-menu-btn { display: none; }
  .composer { margin: 0 8px calc(8px + var(--safe-bottom)); border-radius: 18px; padding: 6px; }
  .composer-meta { padding-left: 6px; }
  .composer-meta > span:first-child { display: none; }
  .typing-bar { padding: 0 16px; }
  .edit-banner { margin: 0 8px 6px; }
  .msg-image { max-width: min(300px, 68vw); }
  .chat-search { padding: 8px 12px; }
  .toast-root { top: auto; right: 50%; bottom: calc(86px + var(--safe-bottom)); transform: translateX(50%); align-items: center; width: min(92vw, 390px); }
  .lightbox-bar { padding-bottom: calc(16px + var(--safe-bottom)); }
  .welcome-pane { padding: 24px; }
  .welcome-art { width: 160px; height: 160px; margin-bottom: 24px; }
  .welcome-art img { width: 66px; height: 66px; border-radius: 21px; }
  .welcome-actions .btn { padding: 10px 14px; font-size: 12.5px; }
  .welcome-hints { display: none; }
  .context-menu { min-width: 210px; }
  .emoji-panel { width: min(94vw, 330px); }
}
@media (max-width: 760px) {
  .auth-screen { display: block; height: 100dvh; overflow-y: auto; }
  .auth-visual { display: none; }
  .auth-panel { min-height: 100dvh; padding: 26px 20px 46px; justify-content: flex-start; overflow: visible; }
  .auth-card { margin-top: max(4vh, 22px); }
  .auth-mobile-brand { display: flex; }
  .auth-heading h2 { font-size: 25px; }
  .auth-meta { margin-bottom: 32px; }
  .auth-side-note { display: none; }
  .modal-overlay { padding: 10px; align-items: flex-end; }
  .modal { border-radius: 22px; max-height: 92dvh; width: 100%; animation: modalMobileIn .3s cubic-bezier(.2,.8,.2,1) both; }
  .modal-head { padding: 18px 18px 0; }
  .modal-head h3 { font-size: 17px; }
  .modal-body { padding: 15px 18px; }
  .modal-foot { padding: 0 18px 18px; }
  .modal-foot .btn { flex: 1; }
  .modal-foot .btn-danger, .modal-foot .btn-ghost { flex: 0 0 auto; }
  .user-list { max-height: 45dvh; }
  .lightbox-stage { padding: 58px 10px 12px; }
}
@media (max-width: 420px) {
  .auth-panel { padding: 22px 16px 40px; }
  .auth-tabs { margin-bottom: 22px; }
  .field-shell { min-height: 46px; }
  .welcome-actions { flex-direction: column; width: 100%; max-width: 280px; }
  .welcome-actions .btn { width: 100%; justify-content: center; }
  .sidebar-head { padding-left: 14px; padding-right: 14px; }
  .sidebar-search { margin-left: 12px; margin-right: 12px; }
  .chat-list { padding-left: 7px; padding-right: 7px; }
  .chat-item { padding: 10px 8px; gap: 10px; }
  .chat-title { font-size: 13.5px; }
  .about-grid { grid-template-columns: 1fr; }
  .server-address-row .btn { flex: 1; }
  .profile-fields { gap: 9px; }
  .composer .icon-btn { width: 34px; height: 34px; }
  .send-btn { width: 38px; height: 38px; }
}
@media (max-height: 700px) {
  .auth-hero { margin-top: 40px; }
  .auth-hero h1 { font-size: clamp(28px, 3.6vw, 44px); margin-bottom: 18px; }
  .orbit-scene { width: min(30vw, 330px); bottom: 9%; }
  .auth-features { padding-top: 16px; }
}
@media (hover: none) {
  .rail-btn[data-tooltip]::after, .icon-btn[data-tooltip]::after { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}


.server-latency { color: var(--muted); font: 600 11px ui-monospace, monospace; white-space: nowrap; padding: 7px 10px; border-radius: 9px; background: var(--surface-2); }

.profile-banner { position: relative; height: 190px; margin: 0 0 -12px; display: flex; align-items: flex-start; justify-content: flex-end; padding: 14px 18px; background: linear-gradient(135deg, rgba(124,92,255,.16), rgba(51,223,194,.08)); background-size: cover; background-position: center; border-bottom: 1px solid var(--line); }
.profile-banner.has-banner { background-color: var(--surface-2); }
.profile-banner-edit { backdrop-filter: blur(12px); }
.profile-hero h3 { display: flex; align-items: center; gap: 7px; }
.profile-joined { margin-top: 6px; font-size: 10px; color: var(--faint); }
.profile-bio { min-height: 44px; }
.modal.wide:has(.profile-banner) { width: min(620px, calc(100vw - 32px)); }

.profile-account-id { margin-top: 8px; color: var(--muted); font: 600 11px ui-monospace, monospace; }

.reply-banner { display:flex; align-items:center; justify-content:space-between; gap:12px; margin:0 12px 7px; padding:9px 12px; border-left:3px solid var(--accent); border-radius:9px; background:var(--surface-2); }
.reply-banner span { min-width:0; display:flex; flex-direction:column; gap:2px; }
.reply-banner strong { font-size:11px; color:var(--accent-2); }
.reply-banner small,.reply-quote span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--muted); font-size:10px; }
.reply-quote { display:flex; flex-direction:column; width:100%; text-align:left; border-left:2px solid var(--accent); padding:4px 8px; margin-bottom:5px; background:var(--surface-2); border-radius:5px; }
.reply-quote strong { color:var(--accent-2); font-size:10px; }
.reply-target { outline:2px solid var(--accent); outline-offset:3px; border-radius:12px; }

.msg-row { transition: transform .12s ease-out; touch-action: pan-y; }
