:root {
  --bg: #050814;
  --bg-2: #070d1d;
  --panel: rgba(13, 23, 39, .72);
  --panel-strong: rgba(14, 25, 44, .92);
  --panel-soft: rgba(19, 33, 55, .55);
  --line: rgba(120, 170, 255, .13);
  --line-strong: rgba(120, 170, 255, .24);
  --text: #eaf2ff;
  --muted: #8a9ab2;
  --dim: #5c6d86;
  --blue: #55a9ff;
  --purple: #7c5cff;
  --cyan: #3ee6d0;
  --danger: #ff5d6c;
  --ok: #46e3a4;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 28px 80px rgba(0, 0, 0, .5);
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 700px at 78% -10%, rgba(85, 169, 255, .13), transparent 60%),
    radial-gradient(900px 700px at 5% 110%, rgba(124, 92, 255, .12), transparent 60%),
    linear-gradient(160deg, var(--bg), var(--bg-2) 55%, #04070f);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(85, 169, 255, .35); }

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

.icon { width: 20px; height: 20px; display: block; flex: 0 0 auto; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

#stars {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.aurora { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; filter: blur(10px); }
.aurora span { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55; animation: drift 22s ease-in-out infinite alternate; }
.aurora-a { width: 520px; height: 520px; left: -140px; top: -120px; background: rgba(85, 169, 255, .28); }
.aurora-b { width: 620px; height: 620px; right: -200px; top: 18%; background: rgba(124, 92, 255, .22); animation-delay: -7s; }
.aurora-c { width: 480px; height: 480px; left: 38%; bottom: -220px; background: rgba(62, 230, 208, .14); animation-delay: -13s; }

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(40px, 50px, 0) scale(1.12); }
}

/* ============ AUTH ============ */

.auth-view {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(380px, .85fr);
  gap: 40px;
  padding: 34px clamp(24px, 4vw, 70px);
}

.hero { display: flex; flex-direction: column; justify-content: space-between; padding: 14px 0 4px; min-height: 0; }

.brand { display: inline-flex; align-items: center; gap: 13px; width: fit-content; }
.brand-logo { height: 32px; width: auto; display: block; filter: drop-shadow(0 8px 24px rgba(85, 169, 255, .35)); }
.brand-mark { width: 46px; height: 46px; filter: drop-shadow(0 8px 24px rgba(85, 169, 255, .4)); }
.brand-mark .icon { width: 100%; height: 100%; }
.brand-name { font-weight: 700; letter-spacing: .38em; font-size: 14px; }

.hero-copy { margin-top: auto; padding: 44px 0 26px; max-width: 650px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .28em; text-transform: uppercase;
  color: var(--blue);
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 0 4px rgba(70, 227, 164, .12);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

.hero h1 {
  margin: 18px 0 18px;
  font-size: clamp(46px, 5.4vw, 82px);
  line-height: .98;
  letter-spacing: -.045em;
  font-weight: 650;
}
.hero h1 em {
  font-style: normal;
  background: linear-gradient(100deg, var(--blue), var(--purple) 52%, var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub { margin: 0; max-width: 520px; color: var(--muted); font-size: 16px; line-height: 1.6; }

.hero-points { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 26px; }
.hero-points span {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 13px; border-radius: 999px;
  background: rgba(17, 30, 50, .62);
  border: 1px solid var(--line);
  color: #b9c9df; font-size: 12.5px;
}
.hero-points .icon { width: 15px; height: 15px; color: var(--blue); }

.hero-demo { position: relative; width: min(400px, 100%); margin: 6px 0 22px; animation: float 7s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0) rotate(-.4deg); } 50% { transform: translateY(-10px) rotate(.4deg); } }

.mock-chat {
  position: relative; z-index: 2;
  border-radius: 24px; border: 1px solid rgba(120, 170, 255, .2);
  background: linear-gradient(160deg, rgba(16, 29, 51, .9), rgba(8, 15, 28, .92));
  box-shadow: 0 30px 70px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255,255,255,.05);
  overflow: hidden;
  backdrop-filter: blur(18px);
}
.mock-head { display: flex; align-items: center; gap: 11px; padding: 15px 17px; border-bottom: 1px solid var(--line); }
.mock-avatar {
  width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, #274b77, #4c3f9c); font-weight: 700; font-size: 14px;
  overflow: hidden;
}
.mock-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mock-head b { display: block; font-size: 13.5px; }
.mock-head small { color: var(--ok); font-size: 10.5px; }
.mock-online { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 12px var(--ok); }
.mock-body { padding: 15px 15px 8px; display: flex; flex-direction: column; gap: 8px; }
.mock-msg { max-width: 78%; padding: 9px 12px; border-radius: 14px; font-size: 12.5px; }
.mock-msg.theirs { align-self: flex-start; background: rgba(255,255,255,.07); border-bottom-left-radius: 5px; }
.mock-msg.mine { align-self: flex-end; background: linear-gradient(135deg, #1769aa, #2c5cc4); border-bottom-right-radius: 5px; }
.mock-typing { align-self: flex-start; display: flex; gap: 4px; padding: 11px 13px; border-radius: 14px; background: rgba(255,255,255,.05); }
.mock-typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: blink 1.3s infinite; }
.mock-typing i:nth-child(2) { animation-delay: .16s; }
.mock-typing i:nth-child(3) { animation-delay: .32s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }
.mock-input { display: flex; align-items: center; justify-content: space-between; margin: 8px 13px 14px; padding: 11px 14px; border-radius: 14px; background: rgba(255,255,255,.05); color: var(--dim); font-size: 12px; }
.mock-input b { color: var(--blue); font-size: 16px; }
.mock-glow { position: absolute; inset: 18% 8% -14% 8%; background: radial-gradient(closest-side, rgba(85,169,255,.28), transparent); filter: blur(30px); z-index: 1; }

.hero-foot { color: var(--dim); font-size: 11px; letter-spacing: .08em; }

.auth-panel { display: grid; place-items: center; padding: 20px 0; }
.auth-card {
  width: 100%; max-width: 410px;
  padding: 30px 32px 26px;
  border-radius: var(--radius);
  background: linear-gradient(165deg, rgba(18, 31, 53, .82), rgba(8, 14, 26, .86));
  border: 1px solid rgba(120, 170, 255, .18);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.06);
  backdrop-filter: blur(24px);
}
.auth-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.status-pill, .version-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 10px; border-radius: 999px; font-size: 10px; letter-spacing: .06em;
  border: 1px solid var(--line); background: rgba(255,255,255,.03); color: var(--muted);
}
.status-pill { color: #a7e8cb; border-color: rgba(70, 227, 164, .2); }
.status-pill.offline { color: #ffb3ba; border-color: rgba(255, 93, 108, .35); }
.status-pill.offline .live-dot { background: #ff5d6c; box-shadow: 0 0 0 4px rgba(255, 93, 108, .12); }
.version-pill { color: var(--dim); font-family: var(--mono); }
.auth-card h2 { margin: 0; font-size: 30px; letter-spacing: -.03em; }
.auth-logo { height: 34px; width: auto; display: block; margin: 2px 0 14px; }
.auth-sub { margin: 6px 0 24px; color: var(--muted); font-size: 13.5px; }

.field { display: block; margin-bottom: 15px; }
.field > span { display: block; margin: 0 0 7px 3px; font-size: 11px; font-weight: 600; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }
.field-row {
  display: flex; align-items: center; gap: 10px;
  padding: 0 13px; border-radius: var(--radius-sm);
  background: rgba(5, 11, 22, .62);
  border: 1px solid var(--line);
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.field-row:focus-within { border-color: rgba(85, 169, 255, .55); box-shadow: 0 0 0 4px rgba(85, 169, 255, .1); background: rgba(8, 16, 30, .85); }
.field-row .icon { color: var(--dim); width: 18px; height: 18px; }
.field-row input {
  flex: 1; min-width: 0; height: 48px; border: 0; outline: 0; background: transparent;
  color: var(--text); font-size: 14.5px;
}
.field-row input::placeholder { color: #44536a; }
.ghost-icon { display: grid; place-items: center; border: 0; background: transparent; color: var(--dim); padding: 6px; border-radius: 9px; }
.ghost-icon:hover { color: var(--blue); background: rgba(85, 169, 255, .1); }

.form-error {
  margin: 4px 0 14px; padding: 11px 13px; border-radius: 12px;
  background: rgba(255, 93, 108, .1); border: 1px solid rgba(255, 93, 108, .34);
  color: #ff9aa3; font-size: 12.5px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  border: 0; border-radius: var(--radius-sm); height: 50px; padding: 0 18px;
  font-weight: 650; font-size: 13.5px; letter-spacing: .02em;
  transition: transform .15s, box-shadow .2s, background .2s, opacity .2s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #2f7fd4, #4f74e8 58%, #7c5cff);
  color: #fff;
  box-shadow: 0 14px 34px rgba(65, 116, 226, .32);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 18px 42px rgba(65, 116, 226, .45); }
.btn-primary .icon { width: 17px; height: 17px; }
.btn-primary.compact { width: auto; height: 42px; padding: 0 18px; }
.btn-ghost {
  width: 100%; margin-top: 10px; height: 48px;
  background: rgba(255,255,255,.045); border: 1px solid var(--line); color: #cdddf3;
}
.btn-ghost:hover { background: rgba(255,255,255,.08); border-color: var(--line-strong); }
.btn-ghost .icon { width: 16px; height: 16px; color: var(--cyan); }
.btn-danger-ghost { background: rgba(255, 93, 108, .08); border: 1px solid rgba(255, 93, 108, .3); color: #ff9aa3; }
.btn-danger-ghost:hover { background: rgba(255, 93, 108, .16); }

.auth-links { display: flex; align-items: center; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.link { border: 0; background: none; padding: 0; color: var(--blue); font-size: 12.5px; }
.link:hover { text-decoration: underline; }
.dot-sep { color: var(--dim); }
.muted { color: var(--muted); }
.small { font-size: 11px; }
.auth-note { margin: 16px 0 0; color: var(--dim); font-size: 11px; text-align: center; }
.auth-note .link { font-size: inherit; color: #7fbfe8; }

/* ============ APP ============ */

.app-view {
  position: relative; z-index: 1;
  height: 100vh; height: 100dvh;
  display: grid;
  grid-template-columns: 74px 330px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  max-width: 1680px;
  margin: 0 auto;
}

.rail, .conversations, .chat {
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 20px 50px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.04);
  backdrop-filter: blur(22px);
  min-height: 0;
}

.rail { display: flex; flex-direction: column; align-items: center; padding: 15px 10px; }
.rail-logo { width: 42px; height: 42px; margin-bottom: 22px; filter: drop-shadow(0 8px 20px rgba(85,169,255,.35)); }
.rail-logo img { width: 100%; height: 100%; display: block; border-radius: 13px; object-fit: cover; }
.rail-logo .icon { width: 100%; height: 100%; }
.rail-nav { display: flex; flex-direction: column; gap: 8px; }
.rail-bottom { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.rail-btn {
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 1px solid transparent; border-radius: 13px; background: transparent; color: var(--dim);
  transition: color .16s, background .16s, border-color .16s;
}
.rail-btn:hover { color: #cfe3ff; background: rgba(255,255,255,.05); }
.rail-btn.active { color: var(--blue); background: rgba(85, 169, 255, .12); border-color: rgba(85, 169, 255, .22); }
.rail-avatar {
  width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: linear-gradient(135deg, #274b77, #4c3f9c); color: #fff; font-weight: 700; font-size: 14px;
  display: grid; place-items: center; overflow: hidden;
}
.rail-avatar img { width: 100%; height: 100%; object-fit: cover; }

.conversations { display: flex; flex-direction: column; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 20px 12px; }
.panel-head h2 { margin: 3px 0 0; font-size: 25px; letter-spacing: -.03em; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(255,255,255,.03); color: var(--muted);
  transition: .16s;
}
.icon-btn:hover { color: var(--blue); border-color: var(--line-strong); background: rgba(85,169,255,.08); }
.icon-btn.filled { background: linear-gradient(135deg, #2f7fd4, #6a61ee); color: #fff; border-color: transparent; box-shadow: 0 10px 24px rgba(65,116,226,.3); }
.icon-btn.filled .icon { width: 19px; height: 19px; }
.icon-btn .icon { width: 19px; height: 19px; }

.search-box {
  display: flex; align-items: center; gap: 9px; margin: 0 16px 12px; padding: 0 13px;
  border-radius: 13px; border: 1px solid var(--line); background: rgba(5,11,22,.55);
  color: var(--dim);
}
.search-box:focus-within { border-color: rgba(85,169,255,.45); }
.search-box .icon { width: 17px; height: 17px; }
.search-box input { flex: 1; height: 42px; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13.5px; }
.search-box input::placeholder { color: #44536a; }

.demo-badge {
  margin: 0 16px 10px; padding: 8px 11px; border-radius: 10px; font-size: 11px;
  color: #ffd08a; background: rgba(255, 183, 77, .1); border: 1px solid rgba(255, 183, 77, .28);
}

.conv-list { flex: 1; overflow-y: auto; padding: 2px 10px 14px; }
.conv-item {
  position: relative;
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 11px 10px; border-radius: 15px; border: 1px solid transparent;
  background: transparent; transition: background .16s, border-color .16s;
}
.conv-item:hover { background: rgba(255,255,255,.04); }
.conv-item.active { background: linear-gradient(120deg, rgba(85,169,255,.14), rgba(124,92,255,.08)); border-color: rgba(85,169,255,.22); }
.conv-main { flex: 1; min-width: 0; }
.conv-top { display: flex; align-items: baseline; gap: 8px; }
.conv-name { font-weight: 600; font-size: 13.8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.online-dot {
  display: inline-block; width: 6px; height: 6px; margin-left: 6px;
  border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok);
  vertical-align: middle;
}
.conv-time { margin-left: auto; color: var(--dim); font-size: 10.5px; flex: 0 0 auto; }
.conv-preview { margin-top: 2px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item.unread .conv-name { color: #fff; }
.conv-item.unread .conv-preview { color: #b9c9df; }
.unread-badge {
  position: absolute; right: 10px; bottom: 10px;
  min-width: 18px; height: 18px; padding: 0 5px;
  display: grid; place-items: center;
  border-radius: 9px; background: linear-gradient(135deg, #55a9ff, #7c5cff);
  color: #fff; font-size: 10.5px; font-weight: 700; line-height: 1;
  box-shadow: 0 0 10px rgba(85, 169, 255, .55);
}
.conv-menu-btn {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 9px; border: 0; background: transparent;
  color: var(--dim); display: grid; place-items: center; opacity: 0; transition: .15s;
}
.conv-item:hover .conv-menu-btn { opacity: 1; }
.conv-menu-btn:hover { background: rgba(255,255,255,.08); color: var(--text); }

.avatar {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 14px;
  display: grid; place-items: center; overflow: hidden;
  background: linear-gradient(135deg, #274b77, #4c3f9c);
  color: #fff; font-weight: 700; font-size: 15px; letter-spacing: .02em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
}
.avatar.md { width: 46px; height: 46px; border-radius: 15px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.chat { position: relative; display: flex; flex-direction: column; overflow: hidden; }
/* Чат — прозрачное стекло: сквозь него виден фон с авророй */
.chat {
  background: transparent;
  border-color: rgba(120, 170, 255, .16);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .16);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.chat-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 30px;
}
.empty-orb {
  width: 88px; height: 88px; border-radius: 26px; display: grid; place-items: center; margin-bottom: 20px;
  background: linear-gradient(150deg, rgba(85,169,255,.16), rgba(124,92,255,.12));
  border: 1px solid rgba(85,169,255,.25); color: var(--blue);
  box-shadow: 0 20px 50px rgba(85,169,255,.12);
}
.empty-orb .icon { width: 38px; height: 38px; }
.chat-empty h2 { margin: 0 0 8px; font-size: 26px; letter-spacing: -.03em; }
.chat-empty p { margin: 0 0 22px; max-width: 330px; color: var(--muted); font-size: 13.5px; }
.empty-hint { margin-top: 30px; color: #3c4a5e; font-size: 11px; font-family: var(--mono); letter-spacing: .1em; }

.chat-active { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 15, 28, .22);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.chat-title { min-width: 0; }
.chat-title b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title span { color: var(--muted); font-size: 11.5px; }
.chat-actions { margin-left: auto; display: flex; gap: 6px; }
.back-btn { display: none; }
.chat.drop-active { outline: 2px dashed rgba(85,169,255,.55); outline-offset: -8px; }
.chat.drop-active::after {
  content: 'Отпусти файл — он отправится в этот чат';
  position: absolute; inset: 20px; z-index: 6; display: grid; place-items: center;
  border-radius: 18px; background: rgba(5, 11, 22, .72); color: #bcd6ff;
  font-size: 14px; pointer-events: none; backdrop-filter: blur(4px);
}

.messages { flex: 1; overflow-y: auto; padding: 22px 22px 12px; display: flex; flex-direction: column; gap: 3px; }
.date-sep { align-self: center; margin: 12px 0 10px; padding: 5px 12px; border-radius: 999px; background: rgba(255,255,255,.04); border: 1px solid var(--line); color: var(--dim); font-size: 10.5px; letter-spacing: .06em; }
.msg-row { display: flex; margin: 2px 0; }
.msg-row.mine { justify-content: flex-end; }
.msg-row.theirs { justify-content: flex-start; }
.msg-row.grouped { margin-top: 1px; }
.msg-tools {
  position: absolute; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; gap: 2px;
  padding: 2px; border-radius: 9px;
  background: rgba(5, 11, 22, .35);
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.msg-row.mine .msg-tools { right: calc(100% + 6px); }
.msg-row.theirs .msg-tools { left: calc(100% + 6px); }
.msg-row:hover .msg-tools { opacity: 1; pointer-events: auto; }
.bubble {
  position: relative;
  display: flow-root;
  max-width: min(620px, 78%);
  padding: 8px 12px 6px;
  border-radius: 16px;
  background: rgba(20, 34, 57, .82);
  border: 1px solid rgba(120,170,255,.09);
  border-bottom-left-radius: 6px;
  color: #e8f1ff;
  font-size: 14px;
  line-height: 1.42;
  word-break: break-word;
  animation: bubbleIn .18s ease-out;
}
@keyframes bubbleIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.msg-row.mine .bubble {
  background: linear-gradient(135deg, #1769aa, #355ed0);
  border-color: rgba(120, 170, 255, .18);
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 6px;
}
.bubble .msg-text { display: inline; white-space: pre-wrap; }
.bubble .msg-meta {
  float: right;
  display: inline-flex;
  align-items: center;
  margin: 5px 0 -2px 8px;
  color: rgba(255,255,255,.55);
  font-size: 10px;
}
.bubble .msg-meta .icon { width: 12px; height: 12px; }
.msg-delete {
  opacity: 0; width: 18px; height: 18px; display: grid; place-items: center;
  border: 0; border-radius: 6px; background: rgba(0,0,0,.18); color: rgba(255,255,255,.7);
  transition: .15s;
}
.msg-row:hover .msg-delete { opacity: 1; }
.msg-delete:hover { background: rgba(255, 93, 108, .8); color: #fff; }
.msg-delete .icon { width: 12px; height: 12px; }
.msg-reply {
  opacity: 0; width: 18px; height: 18px; display: grid; place-items: center;
  border: 0; border-radius: 6px; background: rgba(0,0,0,.18); color: rgba(255,255,255,.7);
  transition: .15s;
}
.msg-row:hover .msg-reply { opacity: 1; }
.msg-reply:hover { background: rgba(85, 169, 255, .85); color: #fff; }
.msg-reply .icon { width: 12px; height: 12px; }
.reply-banner {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 8px; padding: 8px 10px;
  border-radius: 12px; background: rgba(85, 169, 255, .12);
  border-left: 3px solid var(--blue);
}
.reply-banner-body { min-width: 0; display: flex; flex-direction: column; }
.reply-banner-body b { font-size: 11px; color: var(--blue); }
.reply-banner-body span {
  font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.reply-banner .icon-btn { margin-left: auto; }

.twofa-remember {
  display: flex; align-items: center; gap: 8px;
  margin: 2px 0 14px; font-size: 12.5px; color: var(--muted);
}
.twofa-remember input { accent-color: var(--blue); }
.twofa-qr {
  width: 200px; height: 200px; margin: 8px auto 16px;
  padding: 10px; background: #fff; border-radius: 14px;
}
.twofa-qr svg { width: 100%; height: 100%; display: block; }
.twofa-secret { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.twofa-secret code {
  font-family: var(--mono); font-size: 12px; padding: 6px 8px;
  border-radius: 8px; background: rgba(255,255,255,.06); word-break: break-all;
}
.backup-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 16px; }
.backup-codes code {
  font-family: var(--mono); font-size: 13px; padding: 8px; text-align: center;
  border-radius: 8px; color: #dbe9ff;
  background: rgba(85,169,255,.12); border: 1px solid rgba(120,170,255,.22);
}
.reply-quote {
  margin: 0 0 6px; padding: 7px 9px; border-radius: 9px;
  background: rgba(0,0,0,.16); border-left: 3px solid rgba(255,255,255,.5);
  font-size: 11.5px; color: rgba(255,255,255,.74);
  max-height: 46px; overflow: hidden;
}
.reply-quote b { display: block; color: rgba(255,255,255,.9); font-size: 10.5px; margin-bottom: 1px; }
.msg-sender { font-size: 10.5px; color: var(--blue); margin-bottom: 3px; font-weight: 600; }

.attachment { margin: 2px 0 6px; }
.attachment img, .attachment video { display: block; max-width: 100%; border-radius: 12px; max-height: 320px; cursor: zoom-in; }
.attachment audio { display: block; width: 260px; max-width: 100%; }
.att-loading { display: grid; place-items: center; width: 200px; height: 110px; border-radius: 12px; background: rgba(255,255,255,.06); color: var(--dim); font-size: 11px; }
.file-chip {
  display: flex; align-items: center; gap: 9px; max-width: 280px; padding: 10px 12px;
  border-radius: 12px; border: 1px solid rgba(255,255,255,.14); background: rgba(0,0,0,.16);
  color: #eaf2ff; text-align: left;
}
.file-chip:hover { background: rgba(0,0,0,.26); }
.file-chip .icon { width: 22px; height: 22px; color: #bcd6ff; flex: 0 0 auto; }
.file-chip span { display: block; min-width: 0; }
.file-chip b { display: block; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-chip small { color: rgba(255,255,255,.55); font-size: 10px; }

.composer-wrap {
  padding: 10px 16px 14px; border-top: 1px solid var(--line);
  background: rgba(8, 15, 28, .22);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.composer { display: flex; align-items: flex-end; gap: 9px; padding: 7px 7px 7px 14px; border-radius: 17px; border: 1px solid var(--line); background: rgba(5, 11, 22, .6); }
.composer:focus-within { border-color: rgba(85,169,255,.45); box-shadow: 0 0 0 4px rgba(85,169,255,.08); }
.composer textarea {
  flex: 1; min-height: 38px; max-height: 150px; padding: 9px 0; resize: none;
  border: 0; outline: 0; background: transparent; color: var(--text);
  font-size: 14px; line-height: 1.4;
}
.composer textarea::placeholder { color: #44536a; }
.send-btn {
  width: 40px; height: 40px; flex: 0 0 auto; display: grid; place-items: center; border: 0; border-radius: 13px;
  background: linear-gradient(135deg, #2f7fd4, #6a61ee); color: #fff;
  box-shadow: 0 10px 22px rgba(65,116,226,.3); transition: .15s;
}
.send-btn:hover { filter: brightness(1.08); }
.send-btn:disabled { opacity: .45; }
.send-btn .icon { width: 18px; height: 18px; }
.composer-hint { display: flex; justify-content: space-between; gap: 10px; padding: 7px 6px 0; color: #3c4a5e; font-size: 10px; }
.composer-tool {
  width: 36px; height: 40px; flex: 0 0 auto; display: grid; place-items: center;
  border: 0; border-radius: 12px; background: transparent; color: var(--muted);
  transition: background .15s, color .15s;
}
.composer-tool:hover { background: rgba(255,255,255,.06); color: #bcd6ff; }
.composer-tool:disabled { opacity: .4; }
.composer-tool .icon { width: 19px; height: 19px; }
.composer-tool.recording { color: #ff7b87; background: rgba(255,93,108,.12); }
.composer-tool.recording .icon { animation: voicePulse 1.1s ease-in-out infinite; }
@keyframes voicePulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.86); opacity: .65; } }
.upload-status {
  margin: 0 0 8px; padding: 8px 12px; border-radius: 11px;
  border: 1px solid var(--line); background: rgba(5,11,22,.55);
  color: var(--muted); font-size: 11.5px;
}
.upload-status.error { color: #ffb3ba; border-color: rgba(255,93,108,.35); }
.upload-status .bar { height: 3px; margin-top: 6px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; }
.upload-status .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #2f7fd4, #6a61ee); transition: width .15s; }
.status-form textarea {
  width: 100%; min-height: 64px; resize: vertical; padding: 12px 13px;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: rgba(5, 11, 22, .62); color: var(--text); font-size: 14px; outline: 0;
}
.status-form textarea:focus { border-color: rgba(85, 169, 255, .55); box-shadow: 0 0 0 4px rgba(85, 169, 255, .1); }
.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.profile-actions .btn { margin-top: 0; height: 40px; width: auto; padding: 0 14px; font-size: 12px; }
.reg-note { margin: -2px 0 14px; padding: 10px 12px; border-radius: 11px; background: rgba(85,169,255,.07); border: 1px solid rgba(85,169,255,.16); color: #9fc4ea; font-size: 11.5px; line-height: 1.45; }
.code-input { letter-spacing: .35em; text-align: center; font-size: 20px !important; font-weight: 700; }


/* ============ MODALS / TOAST ============ */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px;
  background: rgba(2, 6, 14, .68); backdrop-filter: blur(8px);
  animation: fadeIn .15s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 440px; max-height: min(86vh, 760px); overflow-y: auto;
  padding: 24px;
  border-radius: 22px;
  background: linear-gradient(165deg, rgba(20, 34, 58, .97), rgba(9, 16, 30, .98));
  border: 1px solid rgba(120, 170, 255, .2);
  box-shadow: var(--shadow);
  animation: modalIn .18s ease-out;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.modal-head h3 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.modal-close { margin-left: auto; }
.modal p { color: var(--muted); font-size: 13px; }
.modal .field { margin-bottom: 14px; }
.modal .field-row input { height: 44px; }
.modal-actions { display: flex; gap: 9px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }
.modal-actions .btn-ghost { margin-top: 0; }
.modal-actions.stacked { flex-direction: column; }
.modal-actions.stacked .btn { width: 100%; flex: none; }

.profile-card { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 16px; background: rgba(255,255,255,.04); border: 1px solid var(--line); }
.profile-card .avatar { width: 54px; height: 54px; border-radius: 17px; font-size: 19px; }
.profile-card b { display: block; font-size: 16px; }
.profile-card span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; word-break: break-word; }
.section-label { margin: 22px 0 10px; color: var(--dim); font-size: 10.5px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }

.search-result {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px; border-radius: 14px; border: 1px solid transparent; background: transparent;
}
.search-result:hover { background: rgba(255,255,255,.05); border-color: var(--line); }
.search-result b { display: block; font-size: 13.5px; }
.search-result span { color: var(--muted); font-size: 11.5px; }
.search-result span.is-online { color: var(--ok); }
.search-empty { padding: 18px 8px; text-align: center; color: var(--dim); font-size: 12.5px; }

.toast {
  position: fixed; z-index: 80; left: 50%; bottom: 26px; transform: translateX(-50%);
  max-width: min(92vw, 520px); padding: 12px 18px; border-radius: 13px;
  background: rgba(16, 30, 50, .96); border: 1px solid var(--line-strong);
  color: var(--text); font-size: 13px; box-shadow: var(--shadow);
  animation: toastIn .18s ease-out;
}
.toast.error { border-color: rgba(255,93,108,.5); color: #ffb3ba; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============ SCROLLBARS ============ */

* { scrollbar-width: thin; scrollbar-color: rgba(120,170,255,.22) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: rgba(120,170,255,.22); border-radius: 999px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ============ RESPONSIVE ============ */

@media (max-width: 1180px) {
  .app-view { grid-template-columns: 70px 300px minmax(0, 1fr); }
}

@media (max-width: 980px) {
  .auth-view { grid-template-columns: 1fr; gap: 22px; padding: 26px 24px 40px; }
  .hero { padding: 0; }
  .hero-copy { margin-top: 30px; margin-inline: auto; padding: 10px 0 20px; text-align: center; }
  .eyebrow { justify-content: center; }
  .hero h1 { font-size: clamp(42px, 10vw, 64px); text-wrap: balance; }
  .hero-sub { margin-inline: auto; }
  .hero-points { justify-content: center; }
  .hero-demo { display: none; }
  .hero-foot { margin-top: 22px; text-align: center; }
  .auth-panel { padding: 0 0 10px; }
  .auth-card { max-width: 460px; }

  .app-view { grid-template-columns: 68px minmax(0, 1fr); }
  .conversations { grid-column: 2; }
  .chat { grid-column: 2; display: none; }
  body.chat-open .conversations { display: none; }
  body.chat-open .chat { display: flex; }
  .back-btn { display: grid; }
}

@media (max-width: 620px) {
  .auth-view { padding: 20px 16px 34px; }
  .brand-logo { height: 26px; }
  .auth-card { padding: 24px 20px 22px; }
  .auth-logo { height: 28px; }
  .hero h1 { font-size: 42px; }
  .hero-sub { font-size: 14px; }
  .hero-points span { font-size: 11.5px; padding: 8px 11px; }

  .app-view { grid-template-columns: 58px minmax(0, 1fr); gap: 9px; padding: 9px; }
  .rail { padding: 12px 7px; border-radius: 18px; }
  .rail-logo { width: 36px; height: 36px; margin-bottom: 16px; }
  .rail-btn { width: 40px; height: 40px; }
  .conversations, .chat { border-radius: 18px; }
  .panel-head { padding: 16px 15px 10px; }
  .panel-head h2 { font-size: 22px; }
  .search-box { margin: 0 11px 10px; }
  .conv-list { padding: 2px 7px 12px; }
  .messages { padding: 16px 13px 8px; }
  .bubble { max-width: 88%; }
  .composer-wrap { padding: 9px 11px 12px; }
  .composer-hint span:first-child { display: none; }
  .chat-head { padding: 11px 12px; }
  .chat-head .avatar { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
