/* ==========================================================================
   АЛДИ · Связь — макет корпоративного мессенджера
   Палитра: фирменный тёмно-синий ALDI (#00005A), светло-синий (#6498CA),
   оранжевый акцент (#F58220). Две темы — светлая и тёмная.
   ========================================================================== */

:root {
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --bg: #eef2f9;
  --surface: #ffffff;
  --surface-2: #f6f9fd;
  --surface-3: #edf2fa;
  --surface-hover: #f2f6fc;
  --ink: #101a33;
  --ink-soft: #2b3a55;
  --muted: #6a7a92;
  --muted-2: #93a1b5;
  --line: #e3e9f2;
  --line-strong: #d4deec;

  --brand: #00005a;
  --brand-2: #1d4f9c;
  --brand-3: #6498ca;
  --brand-soft: #e9f1fb;
  --brand-softer: #f3f8fe;
  --accent: #f58220;
  --accent-soft: #fff1e3;
  --danger: #d84b4b;
  --danger-soft: #fdecec;
  --green: #2f9e6a;
  --green-soft: #e7f6ee;

  --rail-w: 68px;
  --sb-w: 300px;
  --panel-w: 372px;
  --radius: 14px;

  --shadow-sm: 0 1px 2px rgba(16, 26, 51, .06);
  --shadow-md: 0 10px 30px rgba(13, 29, 58, .1);
  --shadow-lg: 0 24px 70px rgba(9, 20, 45, .22);

  --rail-grad: linear-gradient(180deg, #07173f 0%, #000039 100%);
  --active-grad: linear-gradient(100deg, #0a2472 0%, #1d4f9c 58%, #3a72c4 100%);
  --msg-hover: #f4f8fd;
  --scroll-thumb: #c9d5e5;

  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #050c19;
  --surface: #0b1526;
  --surface-2: #101c30;
  --surface-3: #152339;
  --surface-hover: #12203a;
  --ink: #e9effb;
  --ink-soft: #cbd7ea;
  --muted: #8fa1bb;
  --muted-2: #6d809b;
  --line: #1d2c44;
  --line-strong: #293b58;

  --brand: #a8c8ee;
  --brand-2: #6498ca;
  --brand-3: #446f9f;
  --brand-soft: #14263f;
  --brand-softer: #0f1e33;
  --accent: #ff9a3d;
  --accent-soft: #33220f;
  --danger: #ff7676;
  --danger-soft: #3a1a1e;
  --green: #57c894;
  --green-soft: #122c22;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 12px 34px rgba(0, 0, 0, .38);
  --shadow-lg: 0 26px 80px rgba(0, 0, 0, .55);

  --rail-grad: linear-gradient(180deg, #08152f 0%, #030a17 100%);
  --active-grad: linear-gradient(100deg, #12305f 0%, #1d4f9c 60%, #2a5c9e 100%);
  --msg-hover: #0f1b2f;
  --scroll-thumb: #2b3d59;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font: 15px/1.5 var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: .55; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, p { margin: 0; }
img { max-width: 100%; }
::selection { background: #6498ca55; }

:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }

.icon { width: 20px; height: 20px; display: block; flex: none; }
.icon--sm { width: 16px; height: 16px; }
.icon--lg { width: 24px; height: 24px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Скроллбары ------------------------------------------------------------- */
.chat__scroll, .sb__list, .panel__body, .palette__results, .notifs__list, .modal__body {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}
.chat__scroll::-webkit-scrollbar, .sb__list::-webkit-scrollbar,
.panel__body::-webkit-scrollbar, .palette__results::-webkit-scrollbar,
.notifs__list::-webkit-scrollbar, .modal__body::-webkit-scrollbar { width: 8px; height: 8px; }
.chat__scroll::-webkit-scrollbar-thumb, .sb__list::-webkit-scrollbar-thumb,
.panel__body::-webkit-scrollbar-thumb, .palette__results::-webkit-scrollbar-thumb,
.notifs__list::-webkit-scrollbar-thumb, .modal__body::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb); border-radius: 8px; border: 2px solid transparent; background-clip: content-box;
}

/* ==========================================================================
   Каркас
   ========================================================================== */
.app {
  display: grid;
  grid-template-columns: var(--rail-w) var(--sb-w) minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
  position: relative;
}
.app.has-panel { grid-template-columns: var(--rail-w) var(--sb-w) minmax(0, 1fr) var(--panel-w); }

/* ==========================================================================
   Рейл (рабочие пространства)
   ========================================================================== */
.rail {
  background: var(--rail-grad);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px 0 14px;
  position: relative;
  z-index: 30;
  user-select: none;
}
.rail__logo {
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center;
  background: #ffffff10;
  box-shadow: inset 0 0 0 1px #ffffff1c;
  margin-bottom: 6px;
  transition: transform .18s ease;
}
.rail__logo:hover { transform: translateY(-1px) scale(1.03); }
.rail__logo img { width: 32px; height: 32px; border-radius: 9px; display: block; }
.rail__divider { width: 28px; height: 1px; background: #ffffff1f; margin: 4px 0; border-radius: 1px; }
.rail__spacer { flex: 1; }
.rail__btn {
  position: relative;
  width: 44px; height: 44px; border-radius: 14px;
  display: grid; place-items: center;
  color: #a9c0dc;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}
.rail__btn:hover { background: #ffffff12; color: #fff; }
.rail__btn:active { transform: scale(.96); }
.rail__btn.is-active { background: #ffffff1c; color: #fff; box-shadow: inset 0 0 0 1px #ffffff2b; }
.rail__btn.is-active::before {
  content: ""; position: absolute; left: -12px; top: 12px; bottom: 12px; width: 3px;
  border-radius: 0 3px 3px 0; background: #6498ca;
}
.rail__badge {
  position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--accent); color: #231000;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px #000039;
}
.rail__avatar {
  width: 40px; height: 40px; border-radius: 50%; position: relative;
  display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700;
  letter-spacing: .2px; box-shadow: 0 0 0 2px #ffffff26;
  background: linear-gradient(135deg, #3f7ac2, #123b7b);
}
.rail__avatar .presence { position: absolute; right: -1px; bottom: -1px; }
.rail [data-tip] { position: relative; }
.rail [data-tip]::after {
  content: attr(data-tip);
  position: absolute; left: calc(100% + 12px); top: 50%; translate: 0 -50%;
  background: #0b1730; color: #eaf1fb; border: 1px solid #ffffff1f;
  padding: 6px 10px; border-radius: 8px; font-size: 12px; font-weight: 500; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .12s ease; z-index: 80;
  box-shadow: var(--shadow-md);
}
.rail [data-tip]:hover::after { opacity: 1; }

.presence {
  width: 11px; height: 11px; border-radius: 50%; background: var(--muted-2);
  border: 2.5px solid var(--surface); box-sizing: content-box; display: inline-block;
}
.presence--online { background: var(--green); }
.presence--away { background: #e5a63c; }
.presence--dnd { background: var(--danger); }
.rail .presence { border-color: #07173f; }

/* ==========================================================================
   Сайдбар
   ========================================================================== */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  z-index: 20;
}
.sb__top {
  display: flex; align-items: center; gap: 10px;
  height: 66px; padding: 0 14px 0 18px; flex: none;
}
.sb__ws { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; text-align: left; border-radius: 10px; padding: 4px; margin-left: -4px; }
.sb__ws:hover { background: var(--surface-hover); }
.sb__ws-mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--surface-3);
  display: grid; place-items: center; flex: none; box-shadow: inset 0 0 0 1px var(--line);
}
.sb__ws-mark img { width: 25px; height: 25px; border-radius: 7px; }
.sb__ws-text { min-width: 0; }
.sb__ws-name { font-size: 15px; font-weight: 700; letter-spacing: -.2px; display: flex; align-items: center; gap: 5px; }
.sb__ws-name .icon { width: 15px; height: 15px; color: var(--muted-2); }
.sb__ws-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb__iconbtn {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  color: var(--muted); flex: none; position: relative;
  transition: background .15s ease, color .15s ease;
}
.sb__iconbtn:hover { background: var(--surface-hover); color: var(--ink); }
.sb__iconbtn .dot { position: absolute; top: 8px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--surface); }

.sb__search { padding: 0 14px 8px; flex: none; }
.sb__search .field {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid transparent; border-radius: 10px;
  padding: 0 10px; height: 36px; transition: border-color .15s, background .15s;
}
.sb__search .field:focus-within { background: var(--surface); border-color: var(--brand-3); box-shadow: 0 0 0 3px var(--brand-soft); }
.sb__search .icon { width: 17px; height: 17px; color: var(--muted-2); }
.sb__search input {
  border: 0; outline: 0; background: none; width: 100%; font-size: 13.5px; color: var(--ink);
  padding: 0; height: 100%;
}
.sb__search input::placeholder { color: var(--muted-2); }
.sb__search kbd {
  font: 11px var(--mono); color: var(--muted-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 5px; background: var(--surface);
}
.sb__nav { padding: 2px 10px 8px; display: flex; flex-direction: column; gap: 1px; flex: none; }
.sb__navitem {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: 9px; color: var(--ink-soft);
  font-size: 14px; font-weight: 550; text-align: left; width: 100%;
  transition: background .14s ease, color .14s ease;
}
.sb__navitem:hover { background: var(--surface-hover); }
.sb__navitem.is-active { background: var(--brand-soft); color: var(--brand-2); font-weight: 650; }
html[data-theme="dark"] .sb__navitem.is-active { color: var(--brand); }
.sb__navitem .icon { color: var(--muted); }
.sb__navitem.is-active .icon { color: var(--brand-2); }
html[data-theme="dark"] .sb__navitem.is-active .icon { color: var(--brand); }
.sb__navitem .count {
  margin-left: auto; font-size: 11.5px; font-weight: 650; color: var(--muted);
  background: var(--surface-2); border-radius: 7px; padding: 1px 7px; min-width: 22px; text-align: center;
}
.sb__navitem.is-active .count { background: #ffffff00; color: var(--brand-2); }
.sb__navitem .toggle {
  margin-left: auto; width: 34px; height: 18px; border-radius: 9px; background: var(--line);
  position: relative; transition: background .16s ease;
}
.sb__navitem .toggle::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px #0002; transition: transform .16s ease;
}
.sb__navitem .toggle.is-on { background: var(--brand-2); }
.sb__navitem .toggle.is-on::after { transform: translateX(16px); }

.sb__section {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px 6px; font-size: 11px; font-weight: 700; letter-spacing: .9px;
  text-transform: uppercase; color: var(--muted-2); flex: none;
}
.sb__section .actions { margin-left: auto; display: flex; gap: 2px; }
.sb__section .sb__iconbtn { width: 26px; height: 26px; border-radius: 7px; }
.sb__section .sb__iconbtn .icon { width: 16px; height: 16px; }
.sb__list { flex: 1; overflow-y: auto; padding: 0 10px 12px; min-height: 0; }
.sb__empty { padding: 26px 16px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.6; }
.sb__empty .icon { margin: 0 auto 8px; width: 26px; height: 26px; color: var(--muted-2); }

.chat-row {
  position: relative; display: flex; gap: 11px; align-items: center; width: 100%;
  padding: 9px 10px; border-radius: 11px; text-align: left; color: var(--ink);
  transition: background .14s ease;
}
.chat-row:hover { background: var(--surface-hover); }
.chat-row.is-active { background: var(--active-grad); color: #fff; box-shadow: 0 6px 18px #00005a2e; }
.chat-row.is-active .chat-row__preview,
.chat-row.is-active .chat-row__time,
.chat-row.is-active .chat-row__role { color: #ffffffb3; }
.chat-row.is-active .chat-row__role { background: #ffffff24; }
.chat-row.is-active .chat-row__badge { background: #fff; color: var(--brand); }
.chat-row.is-active .chat-row__pin { color: #ffffffc9; }
.chat-row.is-active .chat-ava { box-shadow: 0 0 0 2px #ffffff3d; }

.chat-ava {
  width: 40px; height: 40px; border-radius: 13px; flex: none; position: relative;
  display: grid; place-items: center; font-size: 19px; overflow: visible;
  box-shadow: inset 0 0 0 1px #0000000d;
}
.chat-ava--person { border-radius: 50%; font-size: 13px; font-weight: 700; color: #fff; letter-spacing: .2px; }
.chat-ava--person .presence { position: absolute; right: -1px; bottom: -1px; }
.chat-row .chat-ava .presence { border-color: var(--surface); }
.chat-row.is-active .chat-ava .presence { border-color: #1d4f9c; }

.chat-row__main { min-width: 0; flex: 1; }
.chat-row__line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.chat-row__title { font-size: 14px; font-weight: 600; letter-spacing: -.1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row__pin { color: var(--muted-2); display: inline-flex; }
.chat-row__pin .icon { width: 13px; height: 13px; }
.chat-row__role {
  font-size: 9.5px; font-weight: 700; letter-spacing: .3px; padding: 1.5px 5px; border-radius: 5px;
  background: var(--brand-soft); color: var(--brand-2); text-transform: uppercase; flex: none;
}
html[data-theme="dark"] .chat-row__role { color: var(--brand); }
.chat-row__meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex: none; }
.chat-row__time { font-size: 11px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.chat-row__badge {
  min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: var(--accent);
  color: #2a1400; font-size: 11px; font-weight: 700; line-height: 19px; text-align: center;
}
.chat-row__badge.is-muted { background: var(--surface-3); color: var(--muted); }
.chat-row__preview {
  font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px; display: flex; align-items: center; gap: 4px; min-width: 0;
}
.chat-row__preview b { font-weight: 600; color: var(--ink-soft); }
.chat-row.is-active .chat-row__preview b { color: #fff; }
.chat-row__preview .icon { width: 12px; height: 12px; flex: none; opacity: .7; }
.chat-row__typing { color: var(--brand-2); font-style: italic; }

.sb__footer {
  flex: none; border-top: 1px solid var(--line); padding: 10px 14px;
  display: flex; align-items: center; gap: 9px;
}
.sb__me { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; text-align: left; border-radius: 10px; padding: 3px; }
.sb__me:hover { background: var(--surface-hover); }
.sb__me-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb__me-role { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ava-initials {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-size: 12px; font-weight: 700; flex: none; position: relative;
}
.ava-initials .presence { position: absolute; right: -2px; bottom: -2px; }

.sidebar-veil { display: none; }

/* ==========================================================================
   Чат
   ========================================================================== */
.chat { display: flex; flex-direction: column; min-width: 0; background: var(--surface); position: relative; }

.chat__header {
  flex: none; display: flex; align-items: center; gap: 12px;
  min-height: 66px; padding: 8px 18px; border-bottom: 1px solid var(--line);
  background: var(--surface); position: relative; z-index: 10;
}
.chat__back { display: none; width: 36px; height: 36px; border-radius: 10px; place-items: center; color: var(--muted); }
.chat__back:hover { background: var(--surface-hover); }
.chat__titlewrap { min-width: 0; flex: 1; }
.chat__title { display: flex; align-items: center; gap: 8px; font-size: 15.5px; font-weight: 700; letter-spacing: -.2px; }
.chat__title .icon { color: var(--muted-2); width: 15px; height: 15px; }
.chat__sub { font-size: 12px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat__sub .is-typing { color: var(--brand-2); }
.chat__actions { display: flex; align-items: center; gap: 2px; flex: none; }
.chat__action {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  color: var(--muted); transition: background .14s, color .14s; position: relative;
}
.chat__action:hover { background: var(--surface-hover); color: var(--ink); }
.chat__action.is-on { color: var(--accent); }
.chat__action--split { margin-left: 10px; padding-left: 0; }
.chat__action--split::before { content: ""; position: absolute; left: -6px; top: 9px; bottom: 9px; width: 1px; background: var(--line); }
.chat__action .ind { position: absolute; top: 7px; right: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

.chat__pinned {
  flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 20px;
  background: var(--brand-softer); border-bottom: 1px solid var(--line);
  font-size: 12.5px; color: var(--ink-soft); min-height: 38px;
}
.chat__pinned .icon { color: var(--brand-2); width: 16px; height: 16px; }
.chat__pinned .label { font-weight: 650; color: var(--brand-2); flex: none; }
.chat__pinned .text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.chat__pinned .chat__action { width: 26px; height: 26px; border-radius: 7px; }

.chat__body { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.chat__scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.chat__inner { max-width: 920px; margin: 0 auto; padding: 18px 26px 10px; }

.chat__hero { padding: 26px 0 10px; }
.chat__hero-ava { width: 66px; height: 66px; border-radius: 20px; display: grid; place-items: center; font-size: 30px; margin-bottom: 14px; }
.chat__hero-ava--person { border-radius: 50%; font-size: 22px; font-weight: 700; color: #fff; }
.chat__hero-title { font-size: 21px; font-weight: 750; letter-spacing: -.5px; }
.chat__hero-desc { color: var(--muted); font-size: 13.5px; margin-top: 4px; max-width: 560px; }
.chat__hero-meta { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; color: var(--muted-2); font-size: 12px; }
.chat__hero-meta span { display: inline-flex; align-items: center; gap: 5px; }
.chat__hero-meta .icon { width: 14px; height: 14px; }

.day {
  display: flex; align-items: center; gap: 14px; margin: 22px 0 12px;
  color: var(--muted-2); font-size: 11.5px; font-weight: 650; letter-spacing: .4px; text-transform: uppercase;
}
.day::before, .day::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.chat__unread {
  display: flex; align-items: center; gap: 12px; margin: 18px 0 10px;
  color: var(--accent); font-size: 11.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
}
.chat__unread::before, .chat__unread::after { content: ""; height: 1px; background: color-mix(in srgb, var(--accent) 45%, transparent); flex: 1; }

.msg {
  position: relative; display: grid; grid-template-columns: 38px minmax(0, 1fr);
  gap: 11px; padding: 6px 12px 6px 10px; margin: 0 -12px; border-radius: 12px;
  transition: background .12s ease;
}
.msg:hover { background: var(--msg-hover); }
.msg.is-target { animation: flash 1.6s ease; }
@keyframes flash {
  0%, 30% { background: color-mix(in srgb, var(--brand-3) 22%, transparent); }
  100% { background: transparent; }
}
.msg__avatar { padding-top: 2px; }
.msg__avatar .ava-initials, .msg__avatar .chat-ava { width: 36px; height: 36px; border-radius: 11px; font-size: 12px; }
.msg__avatar .chat-ava--person { border-radius: 50%; }
.msg__body { min-width: 0; }
.msg__head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.msg__author { font-size: 13.5px; font-weight: 650; color: var(--ink); }
.msg__author:hover { color: var(--brand-2); }
.msg__time { font-size: 11px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.msg__edited { font-size: 10.5px; color: var(--muted-2); }
.msg__badge { font-size: 9.5px; font-weight: 700; padding: 1px 5px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); letter-spacing: .3px; }
.msg__text { font-size: 14.5px; line-height: 1.58; color: var(--ink-soft); margin-top: 1px; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg__text strong { font-weight: 700; color: var(--ink); }
.msg__text code { font: 12.5px var(--mono); background: var(--surface-3); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }
.msg__text .mention {
  color: var(--brand-2); background: var(--brand-soft); border-radius: 5px; padding: 1px 4px; font-weight: 600;
  white-space: nowrap;
}
html[data-theme="dark"] .msg__text .mention { color: #a8c8ee; }
.msg__text .mention--me { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }
.msg__text a.link { color: var(--brand-2); border-bottom: 1px solid color-mix(in srgb, var(--brand-2) 35%, transparent); }
.msg--grouped { padding-top: 1px; padding-bottom: 1px; }
.msg--grouped .msg__head { display: none; }
.msg__quote {
  display: flex; gap: 8px; border-left: 3px solid var(--brand-3); background: var(--surface-2);
  border-radius: 8px; padding: 6px 10px; margin: 4px 0 5px; font-size: 12.5px; color: var(--muted);
  max-width: 520px;
}
.msg__quote b { color: var(--brand-2); font-weight: 600; display: block; font-size: 12px; }
.msg__quote .txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.msg__actions {
  position: absolute; right: 8px; top: -16px; display: none; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px;
  box-shadow: var(--shadow-sm); padding: 2px; z-index: 4;
}
.msg:hover .msg__actions, .msg:focus-within .msg__actions { display: flex; }
.msg__action { width: 28px; height: 28px; border-radius: 6px; display: grid; place-items: center; color: var(--muted); }
.msg__action:hover { background: var(--surface-hover); color: var(--ink); }
.msg__action .icon { width: 16px; height: 16px; }
.msg__react-add { width: 28px; height: 28px; border-radius: 6px; display: grid; place-items: center; font-size: 15px; }
.msg__react-add:hover { background: var(--surface-hover); }

.msg__attachments { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; align-items: flex-start; }

.att-image { margin: 2px 0; border-radius: 13px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); max-width: 470px; display: block; padding: 0; text-align: left; }
.att-image img { display: block; width: 100%; height: auto; }
.att-image figcaption { font-size: 12px; color: var(--muted); padding: 6px 11px 8px; border-top: 1px solid var(--line); background: var(--surface); }

.att-file {
  display: flex; align-items: center; gap: 11px; min-width: 250px; max-width: 360px;
  border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px 9px 9px;
  background: var(--surface); transition: border-color .15s, box-shadow .15s, transform .15s;
  text-align: left;
}
.att-file:hover { border-color: var(--brand-3); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.att-file__icon {
  width: 38px; height: 44px; border-radius: 8px; display: grid; place-items: center;
  color: #fff; font-size: 9.5px; font-weight: 800; letter-spacing: .4px; flex: none;
}
.att-file__meta { min-width: 0; flex: 1; }
.att-file__name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-file__size { font-size: 11px; color: var(--muted); margin-top: 1px; }
.att-file__dl { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); flex: none; }
.att-file__dl:hover { background: var(--surface-hover); color: var(--brand-2); }

.att-voice {
  display: flex; align-items: center; gap: 11px; border: 1px solid var(--line); border-radius: 20px;
  padding: 7px 16px 7px 8px; background: var(--surface); max-width: 430px; width: 100%;
}
.att-voice__play {
  width: 34px; height: 34px; border-radius: 50%; background: var(--brand-2); color: #fff;
  display: grid; place-items: center; flex: none;
}
.att-voice__play .icon { width: 16px; height: 16px; }
.att-voice .wave { display: flex; align-items: center; gap: 2px; height: 26px; flex: 1; overflow: hidden; }
.att-voice .wave i { flex: 1; min-width: 2px; max-width: 3px; border-radius: 2px; background: var(--brand-3); opacity: .55; }
.att-voice .wave i.is-played { opacity: 1; background: var(--brand-2); }
.att-voice__time { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.att-voice.is-playing .att-voice__play { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--brand-3) 20%, transparent); } }

.att-poll { border: 1px solid var(--line); border-radius: 13px; padding: 13px 14px; min-width: min(100%, 380px); max-width: 420px; background: var(--surface); }
.att-poll__head { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .5px; }
.att-poll__q { font-size: 14px; font-weight: 650; margin: 4px 0 10px; }
.poll-option {
  display: block; width: 100%; text-align: left; border: 1px solid var(--line); border-radius: 9px;
  padding: 8px 10px; margin-top: 6px; font-size: 13px; position: relative; overflow: hidden;
  transition: border-color .15s, background .15s;
}
.poll-option:hover { border-color: var(--brand-3); }
.poll-option .bar { position: absolute; inset: 0 auto 0 0; background: var(--brand-soft); transition: width .5s ease; z-index: 0; }
html[data-theme="dark"] .poll-option .bar { background: #1b3355; }
.poll-option .row { position: relative; z-index: 1; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.poll-option .pct { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.poll-option.is-mine { border-color: var(--brand-2); }
.poll-option.is-mine .row b { color: var(--brand-2); }
.poll-option .row b { font-weight: 550; display: flex; align-items: center; gap: 6px; }
.poll-option .check { color: var(--brand-2); }
.att-poll__foot { font-size: 11.5px; color: var(--muted-2); margin-top: 9px; display: flex; align-items: center; gap: 5px; }

.msg__foot { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.msg__reacts { display: flex; gap: 5px; flex-wrap: wrap; }
.react {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px;
  border-radius: 12px; background: var(--surface-2); border: 1px solid transparent;
  font-size: 12px; color: var(--muted); font-weight: 550;
  transition: background .14s, border-color .14s, transform .14s;
}
.react:hover { background: var(--surface-3); transform: translateY(-1px); }
.react.is-mine { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand-3) 45%, transparent); color: var(--brand-2); }
html[data-theme="dark"] .react.is-mine { color: #a8c8ee; }
.react .count { font-variant-numeric: tabular-nums; }
.thread-link {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 8px 0 5px;
  border-radius: 13px; font-size: 12px; color: var(--brand-2); font-weight: 550;
  transition: background .14s;
}
.thread-link:hover { background: var(--brand-soft); }
.thread-link .icon { width: 15px; height: 15px; }
.thread-link__avatars { display: flex; }
.thread-link__avatars .ava-initials { width: 19px; height: 19px; font-size: 8.5px; margin-left: -5px; box-shadow: 0 0 0 2px var(--surface); border-radius: 50%; }
.thread-link__avatars .ava-initials:first-child { margin-left: 0; }
.msg--own .msg__author::after { content: "вы"; margin-left: 6px; font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--brand-3); vertical-align: 1px; }

/* Композер --------------------------------------------------------------- */
.composer { flex: none; padding: 8px 24px 16px; background: var(--surface); position: relative; }
.composer__reply {
  max-width: 920px; margin: 0 auto 8px; display: flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--brand-3);
  border-radius: 9px; padding: 6px 10px; font-size: 12.5px; color: var(--muted);
}
.composer__reply b { color: var(--brand-2); font-weight: 600; }
.composer__reply .txt { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer__reply .chat__action { width: 24px; height: 24px; }
.composer__box {
  max-width: 920px; margin: 0 auto;
  display: flex; align-items: flex-end; gap: 6px; padding: 7px 8px 7px 8px;
  border: 1px solid var(--line-strong); border-radius: 16px; background: var(--surface);
  box-shadow: 0 2px 10px rgba(16, 26, 51, .04);
  transition: border-color .15s, box-shadow .15s;
}
.composer__box:focus-within { border-color: var(--brand-3); box-shadow: 0 0 0 3px var(--brand-soft); }
.composer__btn { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); flex: none; }
.composer__btn:hover { background: var(--surface-hover); color: var(--ink); }
.composer__btn--plus { background: var(--brand-soft); color: var(--brand-2); border-radius: 50%; }
.composer__btn--plus:hover { background: color-mix(in srgb, var(--brand-3) 22%, transparent); }
.composer__input {
  flex: 1; min-height: 34px; max-height: 190px; resize: none; border: 0; outline: 0;
  background: none; padding: 7px 4px 6px; font-size: 14.5px; line-height: 1.45; color: var(--ink);
  align-self: center;
}
.composer__input::placeholder { color: var(--muted-2); }
.composer__divider { width: 1px; height: 22px; background: var(--line); margin: 0 2px 6px; flex: none; }
.composer__send {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  background: var(--brand); color: #fff; flex: none; transition: transform .15s, background .15s, opacity .15s;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 30%, transparent);
}
html[data-theme="dark"] .composer__send { background: var(--brand-2); color: #04101f; }
.composer__send:hover:not(:disabled) { transform: translateY(-1px); background: var(--brand-2); }
.composer__send:disabled { opacity: .4; box-shadow: none; }
.composer__send .icon { width: 18px; height: 18px; }
.composer__chips { max-width: 920px; margin: 0 auto 7px; display: flex; flex-wrap: wrap; gap: 6px; }
.composer__chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; font-size: 12px; }
.composer__chip .x { color: var(--muted); }
.composer__hint { max-width: 920px; margin: 7px auto 0; display: flex; align-items: center; gap: 12px; font-size: 11px; color: var(--muted-2); padding: 0 4px; }
.composer__hint b { font-weight: 600; color: var(--muted); }
.composer__hint .spacer { flex: 1; }
.composer__typing { display: inline-flex; align-items: center; gap: 5px; color: var(--brand-2); }

/* ==========================================================================
   Панель справа (ветка / информация / участники / поиск)
   ========================================================================== */
.panel {
  background: var(--surface); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; min-width: 0; z-index: 25;
}
.panel[hidden] { display: none; }
.panel__head {
  height: 66px; flex: none; display: flex; align-items: center; gap: 10px;
  padding: 0 12px 0 18px; border-bottom: 1px solid var(--line);
}
.panel__title { font-size: 14.5px; font-weight: 700; flex: 1; display: flex; align-items: center; gap: 8px; }
.panel__title .icon { color: var(--muted); width: 17px; height: 17px; }
.panel__body { flex: 1; overflow-y: auto; min-height: 0; padding: 16px 18px; }

.thread-root { border-bottom: 1px solid var(--line); padding: 0 0 14px; margin: 0 0 4px; }
.thread-root .msg, .thread-list .msg { margin: 0; padding: 6px 8px; }
.thread-root .msg__avatar, .thread-list .msg__avatar { display: none; }
.thread-root .msg, .thread-list .msg { display: block; }
.thread-root .msg__actions { display: none; }
.thread-list .msg:hover .msg__actions { display: flex; }
.thread-list .msg__text, .thread-root .msg__text { font-size: 14px; }
.thread-composer { flex: none; padding: 10px 14px 14px; border-top: 1px solid var(--line); }
.thread-composer .composer__box { max-width: none; }
.thread-composer .composer__hint { display: none; }
.panel__day { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted-2); font-weight: 650; margin: 16px 0 8px; }
.panel__empty { text-align: center; color: var(--muted); font-size: 13px; padding: 44px 12px; line-height: 1.65; }
.panel__empty .icon { width: 30px; height: 30px; margin: 0 auto 10px; color: var(--muted-2); }

.info-card { text-align: center; padding: 6px 0 18px; border-bottom: 1px solid var(--line); }
.info-card .chat-ava { width: 74px; height: 74px; border-radius: 22px; margin: 0 auto 12px; font-size: 32px; }
.info-card .chat-ava--person { border-radius: 50%; font-size: 24px; }
.info-card h3 { font-size: 18px; font-weight: 700; letter-spacing: -.3px; }
.info-card p { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.info-card .role-line { margin-top: 8px; }
.panel__section { padding: 16px 0 0; }
.panel__section-head { display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--muted-2); margin-bottom: 10px; }
.panel__section-head .count { background: var(--surface-2); border-radius: 6px; padding: 0 6px; font-size: 10.5px; line-height: 17px; color: var(--muted); }
.panel__section-head .spacer { flex: 1; }
.panel__section-head button { font-size: 11px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--brand-2); }
.info-topic { font-size: 13px; color: var(--ink-soft); line-height: 1.55; background: var(--surface-2); border-radius: 9px; padding: 10px 12px; }
.member { display: flex; align-items: center; gap: 10px; padding: 7px 0; width: 100%; text-align: left; border-radius: 8px; }
.member:hover { background: var(--surface-hover); }
.member__main { min-width: 0; flex: 1; }
.member__name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member__pos { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member__badge { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; color: var(--brand-2); background: var(--brand-soft); border-radius: 5px; padding: 2px 6px; }
.info-files { display: flex; flex-direction: column; gap: 6px; }
.info-file { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 8px; text-align: left; width: 100%; }
.info-file:hover { background: var(--surface-hover); }
.info-file .att-file__icon { width: 30px; height: 34px; font-size: 8px; }
.info-file__name { font-size: 12.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.info-file__meta { font-size: 11px; color: var(--muted); }
.panel__actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 14px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 13px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 600;
  transition: background .14s, border-color .14s;
}
.btn:hover { background: var(--surface-hover); }
.btn .icon { width: 16px; height: 16px; }
.btn--primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn--primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
html[data-theme="dark"] .btn--primary { background: var(--brand-2); color: #04101f; border-color: var(--brand-2); }
.btn--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }
.btn--danger:hover { background: var(--danger-soft); }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--surface-hover); }
.btn--block { width: 100%; }

/* ==========================================================================
   Поповеры, меню, палитра команд, модалки
   ========================================================================== */
.layer-root { position: relative; z-index: 100; }
.overlay {
  position: fixed; inset: 0; background: rgba(4, 10, 24, .5);
  backdrop-filter: blur(2px); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 12vh 20px 20px;
  animation: fade .14s ease;
}
.overlay--center { align-items: center; padding: 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(-8px) scale(.985); } }

.palette {
  width: min(660px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .16s ease;
  max-height: 70vh; display: flex; flex-direction: column;
}
.palette__top { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.palette__top .icon { color: var(--muted-2); }
.palette__input { flex: 1; border: 0; outline: 0; background: none; font-size: 15px; }
.palette__esc { font: 11px var(--mono); color: var(--muted-2); border: 1px solid var(--line); padding: 2px 6px; border-radius: 5px; }
.palette__results { overflow-y: auto; padding: 8px; }
.palette__section { font-size: 10.5px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--muted-2); padding: 10px 10px 6px; }
.palette__row {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 10px;
  border-radius: 9px; text-align: left;
}
.palette__row:hover, .palette__row.is-cursor { background: var(--surface-hover); }
.palette__row .chat-ava { width: 32px; height: 32px; border-radius: 9px; font-size: 15px; }
.palette__row .chat-ava--person { border-radius: 50%; font-size: 11px; }
.palette__row-main { flex: 1; min-width: 0; }
.palette__row-title { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette__row-title mark { background: color-mix(in srgb, var(--accent) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.palette__row-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette__row-hint { font-size: 11px; color: var(--muted-2); flex: none; }
.palette__empty { padding: 30px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.palette__foot { border-top: 1px solid var(--line); padding: 8px 14px; display: flex; gap: 14px; font-size: 11px; color: var(--muted-2); }
.palette__foot b { color: var(--muted); font-weight: 600; }

.menu {
  position: fixed; z-index: 120; background: var(--surface); border: 1px solid var(--line);
  border-radius: 11px; box-shadow: var(--shadow-md); padding: 5px; min-width: 196px;
  animation: pop .12s ease;
}
.menu__item {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--ink);
}
.menu__item:hover { background: var(--surface-hover); }
.menu__item .icon { width: 16px; height: 16px; color: var(--muted); }
.menu__item--danger { color: var(--danger); }
.menu__item--danger .icon { color: var(--danger); }
.menu__sep { height: 1px; background: var(--line); margin: 5px 6px; }
.menu__label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted-2); padding: 7px 10px 4px; }
.menu__emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; padding: 6px; }
.menu__emoji { width: 34px; height: 34px; border-radius: 8px; font-size: 19px; display: grid; place-items: center; }
.menu__emoji:hover { background: var(--surface-hover); }

.emoji-pop { width: 324px; }
.emoji-pop .emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px; max-height: 250px; overflow-y: auto; }
.emoji-pop .emoji-grid button { height: 36px; border-radius: 8px; font-size: 20px; display: grid; place-items: center; }
.emoji-pop .emoji-grid button:hover { background: var(--surface-hover); }
.emoji-pop__head { padding: 9px 12px 2px; font-size: 11px; font-weight: 700; letter-spacing: .7px; text-transform: uppercase; color: var(--muted-2); }

.modal {
  width: min(560px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .16s ease;
  display: flex; flex-direction: column; max-height: 82vh;
}
.modal--wide { width: min(720px, 100%); }
.modal__head { display: flex; align-items: center; gap: 10px; padding: 16px 20px 12px; }
.modal__head h3 { font-size: 17px; font-weight: 700; letter-spacing: -.3px; flex: 1; }
.modal__body { padding: 4px 20px 18px; overflow-y: auto; }
.modal__foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line); justify-content: flex-end; }
.modal__hint { font-size: 12px; color: var(--muted); margin: 4px 0 14px; }
.input {
  width: 100%; height: 40px; border: 1px solid var(--line-strong); border-radius: 9px;
  background: var(--surface); padding: 0 12px; outline: 0; font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--brand-3); box-shadow: 0 0 0 3px var(--brand-soft); }
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 12px 0 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 20px;
  background: var(--brand-soft); color: var(--brand-2); font-size: 12px; font-weight: 600;
  padding: 3px 9px 3px 4px;
}
html[data-theme="dark"] .chip { color: #a8c8ee; }
.chip .ava-initials { width: 20px; height: 20px; font-size: 8px; border-radius: 50%; }
.chip button { color: currentColor; opacity: .7; display: grid; place-items: center; }
.people-pick { max-height: 280px; overflow-y: auto; margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; }
.people-pick .member { padding: 8px 11px; border-radius: 0; border-bottom: 1px solid var(--line); }
.people-pick .member:last-child { border-bottom: 0; }
.people-pick .member.is-picked { background: var(--brand-softer); }
.member .check { width: 18px; height: 18px; border-radius: 6px; border: 1.5px solid var(--line-strong); display: grid; place-items: center; color: #fff; flex: none; }
.member.is-picked .check { background: var(--brand-2); border-color: var(--brand-2); }
.member.is-picked .check .icon { width: 12px; height: 12px; }

/* Уведомления ------------------------------------------------------------ */
.notifs {
  position: fixed; top: 64px; left: calc(var(--rail-w) + 10px); width: 360px; max-width: calc(100vw - 90px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-lg); z-index: 110; overflow: hidden; animation: pop .14s ease;
}
.notifs__head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.notifs__head h4 { font-size: 14px; font-weight: 700; flex: 1; }
.notifs__head button { font-size: 11.5px; font-weight: 600; color: var(--brand-2); }
.notifs__list { max-height: 380px; overflow-y: auto; padding: 6px; }
.notif { display: flex; gap: 10px; width: 100%; text-align: left; padding: 9px; border-radius: 9px; position: relative; }
.notif:hover { background: var(--surface-hover); }
.notif.is-new::after { content: ""; position: absolute; right: 10px; top: 50%; translate: 0 -50%; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.notif__text { font-size: 12.5px; line-height: 1.45; color: var(--ink-soft); padding-right: 14px; }
.notif__text b { font-weight: 650; color: var(--ink); }
.notif__time { font-size: 11px; color: var(--muted-2); margin-top: 3px; }
.notifs__empty { padding: 30px 16px; text-align: center; color: var(--muted); font-size: 13px; }

/* Звонок ----------------------------------------------------------------- */
.call {
  position: fixed; inset: 0; z-index: 200; color: #fff;
  background: radial-gradient(1200px 700px at 50% -10%, #16376b 0%, #071328 55%, #030a18 100%);
  display: flex; flex-direction: column; animation: fade .2s ease;
}
.call__head { display: flex; align-items: center; gap: 14px; padding: 18px 26px; flex: none; }
.call__info { min-width: 0; flex: 1; }
.call__info h3 { font-size: 16px; font-weight: 700; }
.call__sub { font-size: 12.5px; color: #9fb6d6; margin-top: 2px; display: flex; align-items: center; gap: 8px; }
.call__rec { display: inline-flex; align-items: center; gap: 5px; color: #ff9b9b; font-weight: 600; }
.call__rec i { width: 7px; height: 7px; border-radius: 50%; background: #ff5b5b; animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.call__timer { font: 13px var(--mono); color: #cfe0f5; background: #ffffff12; border-radius: 7px; padding: 4px 9px; }
.call__grid {
  flex: 1; min-height: 0; display: grid; gap: 12px; padding: 0 26px 12px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); align-content: center;
}
.call__tile {
  position: relative; border-radius: 16px; overflow: hidden; min-height: 160px;
  background: linear-gradient(140deg, #183a6e, #0b1f3f);
  display: grid; place-items: center; border: 1px solid #ffffff14;
  transition: box-shadow .2s;
}
.call__tile.is-speaking { box-shadow: 0 0 0 2px #6498ca, 0 0 40px #6498ca44; }
.call__tile .ava-initials { width: 84px; height: 84px; font-size: 28px; box-shadow: 0 0 0 4px #ffffff18; }
.call__tile .ava-initials .presence { display: none; }
.call__tile-name {
  position: absolute; left: 12px; bottom: 10px; font-size: 12.5px; font-weight: 600;
  background: #00000066; padding: 3px 9px; border-radius: 7px; display: flex; align-items: center; gap: 6px;
}
.call__tile-name .icon { width: 13px; height: 13px; color: #ffb1b1; }
.call__tile--me { border-color: #6498ca55; }
.call__tile-badge { position: absolute; top: 10px; right: 10px; font-size: 10.5px; background: #ffffff1a; border-radius: 6px; padding: 2px 7px; color: #d7e6f9; }
.call__controls { flex: none; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px 20px 26px; flex-wrap: wrap; }
.call__btn {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center;
  background: #ffffff14; color: #e6effb; border: 1px solid #ffffff1f; position: relative;
  transition: background .15s, transform .15s;
}
.call__btn:hover { background: #ffffff24; }
.call__btn:active { transform: scale(.96); }
.call__btn.is-off { background: #ffffff2e; color: #fff; }
.call__btn.is-off::after { content: ""; position: absolute; width: 26px; height: 2px; background: #ff8a8a; rotate: -45deg; border-radius: 2px; }
.call__btn--end { background: #e5484d; border-color: #e5484d; width: 64px; }
.call__btn--end:hover { background: #f25b60; }
.call__btn--end .icon { width: 24px; height: 24px; }
.call__caption { font-size: 11px; color: #9fb6d6; position: absolute; bottom: -18px; left: 50%; translate: -50%; white-space: nowrap; }
.call__caption-wrap { position: relative; padding-bottom: 18px; }
.call__note { position: absolute; left: 50%; bottom: 96px; translate: -50%; background: #0b1f3fcc; border: 1px solid #ffffff1f; color: #dce9fa; font-size: 12px; padding: 7px 14px; border-radius: 9px; }

/* Тосты ------------------------------------------------------------------ */
.toasts { position: fixed; right: 22px; bottom: 22px; z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  background: #0b1730; color: #eef4fd; border: 1px solid #ffffff1f; border-radius: 11px;
  padding: 10px 14px; font-size: 13px; box-shadow: var(--shadow-lg); max-width: 360px;
  animation: toastIn .2s ease;
  display: flex; align-items: center; gap: 8px;
}
.toast .icon { color: #6fc39a; width: 17px; height: 17px; }
.toast--error { background: #481b1f; }
.toast--error .icon { color: #ff9d9d; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* Ссылка «прокрутить вниз» ------------------------------------------------- */
.chat__jump {
  position: absolute; right: 26px; bottom: 108px; width: 38px; height: 38px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow-md);
  display: none; place-items: center; color: var(--muted); z-index: 6;
}
.chat__jump.is-show { display: grid; }
.chat__jump:hover { color: var(--brand-2); }
.chat__jump .badge { position: absolute; top: -5px; right: -4px; background: var(--accent); color: #2a1400; font-size: 10px; font-weight: 700; border-radius: 8px; padding: 1px 5px; }

/* Пустое состояние -------------------------------------------------------- */
.chat--empty { display: grid; place-items: center; text-align: center; padding: 30px; }
.chat--empty .empty-card { max-width: 380px; }
.chat--empty .empty-mark { width: 76px; height: 76px; border-radius: 22px; background: var(--brand-soft); display: grid; place-items: center; margin: 0 auto 18px; }
.chat--empty .empty-mark img { width: 46px; height: 46px; border-radius: 13px; }
.chat--empty h2 { font-size: 22px; letter-spacing: -.5px; }
.chat--empty p { color: var(--muted); font-size: 13.5px; margin: 8px 0 18px; line-height: 1.6; }

/* ==========================================================================
   Адаптивность
   ========================================================================== */
@media (max-width: 1320px) {
  :root { --sb-w: 280px; --panel-w: 340px; }
  .chat__inner { padding-inline: 20px; }
}

@media (max-width: 1120px) {
  .app.has-panel { grid-template-columns: var(--rail-w) var(--sb-w) minmax(0, 1fr); }
  .panel {
    position: fixed; right: 0; top: 0; bottom: 0; width: min(400px, 92vw);
    box-shadow: var(--shadow-lg); animation: slideIn .18s ease;
  }
  @keyframes slideIn { from { transform: translateX(20px); opacity: 0; } }
}

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

/* ==========================================================================
   Дополнения: поповеры, настройки, детали
   ========================================================================== */
.overlay--plain {
  background: transparent;
  backdrop-filter: none;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 0;
}
.overlay--plain .menu { position: fixed; }

.menu__emoji-grid { grid-template-columns: repeat(6, 1fr); }
.emoji-pop .emoji-grid { grid-template-columns: repeat(8, 1fr); }
.composer__chip button { display: grid; place-items: center; color: var(--muted); border-radius: 4px; }
.composer__chip button:hover { color: var(--ink); background: var(--surface-3); }

/* Аватары в разных контекстах */
.chat-ava--person { width: 40px; height: 40px; }
.chat__header .chat-ava { width: 38px; height: 38px; border-radius: 12px; font-size: 18px; }
.chat__header .chat-ava--person { width: 38px; height: 38px; }
.chat__hero-ava--person { width: 66px; height: 66px; font-size: 22px; }
.chat__hero-ava.chat-ava { width: 66px; height: 66px; border-radius: 20px; font-size: 30px; }
.info-card .chat-ava--person { width: 74px; height: 74px; font-size: 24px; }
.palette__row .ava-initials { width: 32px; height: 32px; font-size: 11px; }
.notif .ava-initials { width: 34px; height: 34px; font-size: 11px; }
.notif__text { flex: 1; min-width: 0; }
.notif__time { flex: none; align-self: flex-start; padding-top: 2px; }
.thread-root .ava-initials { width: 24px; height: 24px; font-size: 9px; }
.thread-root .msg__head .ava-initials { display: none; }

/* Уведомления */
.notifs { position: fixed; }
.notif { align-items: flex-start; }

/* Настройки */
.settings-row {
  display: flex; align-items: center; gap: 18px; justify-content: space-between;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.settings-row b { font-size: 13.5px; font-weight: 650; }
.settings-row .muted { font-size: 12px; color: var(--muted); margin-top: 3px; max-width: 320px; }
.settings-row .segmented { display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 9px; border: 1px solid var(--line); flex: none; }
.seg { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.seg .icon { width: 15px; height: 15px; }
.seg.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
html[data-theme="dark"] .seg.is-active { background: var(--surface-3); }
.switch { position: relative; width: 40px; height: 22px; flex: none; display: block; }
.switch input { position: absolute; opacity: 0; }
.switch span { position: absolute; inset: 0; background: var(--line-strong); border-radius: 11px; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px #0003; transition: transform .15s; }
.switch input:checked + span { background: var(--brand-2); }
.switch input:checked + span::after { transform: translateX(18px); }
.about { display: flex; gap: 12px; align-items: center; margin-top: 18px; padding: 14px; background: var(--surface-2); border-radius: 11px; }
.about img { width: 40px; height: 40px; border-radius: 11px; }
.about b { font-size: 13.5px; display: block; }
.about span { font-size: 12px; color: var(--muted); display: block; margin-top: 2px; }

/* Профиль */
.profile-head { display: flex; align-items: center; gap: 10px; padding: 8px 9px 10px; }
.profile-head .ava-initials { width: 38px; height: 38px; font-size: 13px; }
.profile-head b { display: block; font-size: 13.5px; font-weight: 650; }
.profile-head > div span { display: block; font-size: 11.5px; color: var(--muted); }

/* Служебные бейджи */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px;
  border-radius: 6px; background: var(--brand-soft); color: var(--brand-2);
  font-size: 11px; font-weight: 650;
}
.role-badge {
  display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 6px;
  background: var(--surface-3); color: var(--muted); font-size: 11px; font-weight: 600;
}

/* Лайтбокс */
.lightbox { padding: 32px 20px; }
.lightbox figure { margin: 0; max-width: min(1100px, 94vw); max-height: 88vh; display: flex; flex-direction: column; background: #0b1526; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-lg); }
.lightbox img { max-height: 78vh; width: auto; margin: auto; display: block; }
.lightbox figcaption { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: #dbe7f7; font-size: 13px; border-top: 1px solid #ffffff1a; }
.lightbox figcaption .btn { height: 30px; font-size: 12px; }

/* Разное */
.sb__section .count {
  background: var(--surface-2); border-radius: 6px; padding: 0 6px;
  font-size: 10.5px; line-height: 17px; color: var(--muted); font-weight: 700;
}
.sb__navitem .count:empty { display: none; }
.thread-list .msg:last-child { padding-bottom: 12px; }
.thread-composer .composer__box { border-color: var(--line-strong); }
.chat--empty .empty-card p a { color: var(--brand-2); }

/* Мобильная шапка: кнопка закрытия панели не уезжает */
@media (max-width: 1120px) {
  .panel { z-index: 90; }
}

@media (max-width: 620px) {
  .sb__navitem { padding: 10px 12px; }
  .settings-row { flex-direction: column; align-items: flex-start; gap: 10px; }
  .profile-head { padding-bottom: 8px; }
  .lightbox { padding: 12px; }
}

/* Все ветки */
.threads-list { display: flex; flex-direction: column; gap: 2px; }
.thread-row {
  display: flex; align-items: flex-start; gap: 11px; width: 100%; text-align: left;
  padding: 11px 10px; border-radius: 10px; transition: background .14s;
}
.thread-row:hover { background: var(--surface-hover); }
.thread-row__main { flex: 1; min-width: 0; }
.thread-row__head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.thread-row__head b { font-weight: 650; }
.thread-row__head span { color: var(--muted); font-size: 11.5px; }
.thread-row__time { margin-left: auto; color: var(--muted-2) !important; font-variant-numeric: tabular-nums; }
.thread-row__text { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-row__count { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--brand-2); font-weight: 600; flex: none; background: var(--brand-soft); border-radius: 8px; padding: 3px 8px; }

/* Контейнеры не должны растягиваться под контент */
.app { min-height: 0; }
.sidebar, .chat, .panel { min-height: 0; overflow: hidden; }
.chat__body { min-height: 0; }
.chat__scroll { min-height: 0; }
html, body { overflow: hidden; overscroll-behavior: none; }

/* ==========================================================================
   Верхняя панель рабочих пространств (вместо левого рейла)
   ========================================================================== */
:root { --topbar-h: 58px; }

.app { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
.app.has-panel .app__body { grid-template-columns: var(--sb-w) minmax(0, 1fr) var(--panel-w); }
.app__body {
  flex: 1; min-height: 0; display: grid;
  grid-template-columns: var(--sb-w) minmax(0, 1fr);
  overflow: hidden; position: relative;
}

.topbar {
  flex: none; display: flex; align-items: center; gap: 4px;
  height: var(--topbar-h); padding: 0 12px 0 14px;
  background: var(--rail-grad); color: #eaf1fb; position: relative; z-index: 50;
  box-shadow: 0 1px 0 #ffffff10, 0 6px 24px #0000001f;
}
.topbar__brand { display: flex; align-items: center; gap: 9px; margin-right: 4px; flex: none; }
.topbar__brand img { width: 32px; height: 32px; border-radius: 9px; box-shadow: 0 0 0 1px #ffffff26; }
.topbar__brandtext { display: flex; align-items: baseline; gap: 7px; white-space: nowrap; }
.topbar__brandtext b { font-size: 15.5px; font-weight: 750; letter-spacing: -.2px; color: #fff; }
.topbar__brandtext span { font-size: 9.5px; font-weight: 800; letter-spacing: 1.4px; color: #90b2d8; text-transform: uppercase; }
.topbar__divider { width: 1px; height: 22px; background: #ffffff26; margin: 0 8px; flex: none; }
.topbar__ws { display: flex; align-items: center; gap: 6px; flex: none; }
.ws {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  font-size: 10.5px; font-weight: 800; letter-spacing: .3px; color: #c3d6ec;
  background: #ffffff10; box-shadow: inset 0 0 0 1px #ffffff18;
  transition: background .15s, color .15s, box-shadow .15s;
}
.ws img { width: 22px; height: 22px; border-radius: 6px; }
.ws:hover { background: #ffffff1e; color: #fff; }
.ws.is-active { background: #ffffff1f; color: #fff; box-shadow: inset 0 0 0 1px #ffffff3d, 0 0 0 3px #6498ca26; }
.ws--add { background: transparent; color: #9fb6d6; box-shadow: inset 0 0 0 1px #ffffff26; }
.ws--add:hover { background: #ffffff14; color: #fff; }
.topbar__spacer { flex: 1; }
.topbar__search {
  display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px 0 11px;
  border-radius: 9px; background: #ffffff0f; color: #b9cde6; font-size: 12.5px;
  border: 1px solid #ffffff14; min-width: 200px; margin-right: 6px;
  transition: background .15s, border-color .15s;
}
.topbar__search:hover { background: #ffffff1c; color: #fff; border-color: #ffffff26; }
.topbar__search .icon { width: 15px; height: 15px; }
.topbar__search span { flex: 1; text-align: left; }
.topbar__search kbd { font: 10px var(--mono); border: 1px solid #ffffff2b; border-radius: 4px; padding: 1px 4px; color: #9fb6d6; }
.topbar__btn { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; color: #c3d6ec; position: relative; flex: none; transition: background .15s, color .15s; }
.topbar__btn:hover { background: #ffffff16; color: #fff; }
.topbar__btn .icon { width: 19px; height: 19px; }
.topbar__badge {
  position: absolute; top: 1px; right: 0; min-width: 17px; height: 17px; line-height: 17px;
  border-radius: 9px; background: var(--accent); color: #241100; font-size: 10px;
  font-weight: 800; text-align: center; padding: 0 4px; box-shadow: 0 0 0 2px #07173f;
}
.topbar__avatar {
  width: 36px; height: 36px; border-radius: 50%; margin-left: 6px; flex: none;
  background: linear-gradient(135deg, #3f7ac2, #123b7b); color: #fff;
  font-size: 12px; font-weight: 700; display: grid; place-items: center;
  position: relative; box-shadow: 0 0 0 2px #ffffff2e;
}
.topbar__avatar .presence { position: absolute; right: -1px; bottom: -1px; border-color: #07173f; }
.topbar__menu { display: none; width: 36px; height: 36px; border-radius: 9px; place-items: center; color: #c3d6ec; flex: none; }
.topbar__menu:hover { background: #ffffff16; }

.sidebar { height: 100%; }
.sb__search { padding-top: 14px; }

/* Уведомления теперь под верхней панелью */
.notifs { top: calc(var(--topbar-h) + 8px); left: 12px; }

@media (max-width: 1320px) and (min-width: 1121px) {
  .app.has-panel .app__body { grid-template-columns: var(--sb-w) minmax(0, 1fr) var(--panel-w); }
}

@media (max-width: 1120px) {
  .app.has-panel .app__body { grid-template-columns: var(--sb-w) minmax(0, 1fr); }
  .panel { top: var(--topbar-h); }
}

/* Планшеты и развёрнутые складные: полноценный десктопный каркас */
@media (max-width: 900px) {
  .topbar__divider { display: none; }
  .topbar__brand { margin-right: 0; }
  .topbar__search { min-width: 0; width: 36px; padding: 0; justify-content: center; background: transparent; border-color: transparent; margin-right: 2px; }
  .topbar__search span, .topbar__search kbd { display: none; }
  .topbar__btn--desktop { display: none; }
  .topbar__ws .ws { width: 32px; height: 32px; }
  .chat__action--desktop { display: none; }
  .chat__header { padding-inline: 10px; }
  .chat__inner { padding: 12px 14px 8px; }
  .composer { padding: 8px 12px 12px; }
  .composer__hint { display: none; }
  .msg { margin: 0 -6px; padding: 6px 8px; }
  .chat__jump { right: 14px; bottom: 96px; }
  .notifs { left: 10px; top: calc(var(--topbar-h) + 6px); }
}

/* Телефоны: список чатов — выдвижной */
@media (max-width: 600px) {
  .app__body { grid-template-columns: minmax(0, 1fr); }
  .app.has-panel .app__body { grid-template-columns: minmax(0, 1fr); }
  .topbar__menu { display: grid; }
  .topbar__ws { display: none; }
  .sidebar {
    position: fixed; left: 0; top: var(--topbar-h); bottom: 0; width: min(320px, 86vw); z-index: 70;
    transform: translateX(-104%); transition: transform .22s ease; box-shadow: var(--shadow-lg);
  }
  body.sb-open .sidebar { transform: none; }
  .sidebar-veil { display: block; position: fixed; top: var(--topbar-h); right: 0; bottom: 0; left: 0; z-index: 60; background: rgba(4, 10, 24, .45); border: 0; opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.sb-open .sidebar-veil { opacity: 1; pointer-events: auto; }
}

@media (max-width: 620px) {
  :root { --topbar-h: 54px; }
  .topbar { padding: 0 8px 0 10px; }
  .topbar__brandtext span { display: none; }
  .topbar__brand img { width: 30px; height: 30px; }
  .topbar__search { display: none; }
  .topbar__avatar { width: 32px; height: 32px; margin-left: 2px; }
  .topbar__btn { width: 34px; height: 34px; }
  .chat__title { font-size: 15px; }
  .chat__hero { padding-top: 12px; }
  .chat__hero-ava { width: 54px; height: 54px; border-radius: 16px; font-size: 24px; }
  .msg__text { font-size: 14px; }
  .msg__actions { display: none !important; }
  .att-image { max-width: 100%; }
  .att-file { min-width: 0; width: 100%; max-width: none; }
  .att-voice { max-width: none; }
  .att-poll { min-width: 0; width: 100%; }
  .call__grid { padding-inline: 12px; grid-template-columns: 1fr 1fr; }
  .call__head { padding: 14px 16px; }
  .toasts { right: 12px; left: 12px; bottom: 12px; align-items: stretch; }
  .toast { max-width: none; }
  .overlay { padding: 8vh 12px 12px; }
}

/* Мобильная шапка: убираем дублирующую кнопку меню */
@media (max-width: 900px) {
  .chat__back { display: none; }
  .chat__title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .chat__title .chat-row__role { flex: none; }
}
.chat__titlewrap { min-width: 0; }
.chat__title { min-width: 0; }

/* Типографика списков */
.palette__row-title, .palette__row-sub,
.member__name, .member__pos,
.att-file__name, .att-file__size,
.info-file__name, .info-file__meta { display: block; }
.palette__row-main { display: block; }
.member__main { display: block; }
.info-file > span { min-width: 0; }
.chip .presence { display: none; }
.chip .ava-initials { width: 20px; height: 20px; font-size: 8px; }
.thread-row__count .icon { width: 13px; height: 13px; }
.call__controls-divider { width: 1px; height: 30px; background: #ffffff1f; margin: 0 6px; }
.call__controls { padding-bottom: 34px; }

/* ==========================================================================
   Айдентика Luna (предоставленные логотипы, белые плашки)
   ========================================================================== */
.topbar__brand img {
  width: 40px; height: 40px; padding: 2px;
  background: #fff; border-radius: 12px; object-fit: contain;
  box-shadow: 0 1px 0 #ffffff33, 0 3px 10px #00000033;
}
.topbar__brandtext b { font-size: 16px; }
.ws.is-active img {
  width: 28px; height: 28px; padding: 1px;
  background: #fff; border-radius: 8px; object-fit: contain;
}
.chat--empty .empty-mark {
  width: 92px; height: 92px; border-radius: 24px;
  background: #fff; border: 1px solid var(--line);
  box-shadow: 0 10px 26px #0b17301a;
}
.chat--empty .empty-mark img { width: 62px; height: auto; border-radius: 0; }
.about img { width: 46px; height: 46px; padding: 5px; background: #fff; border-radius: 12px; object-fit: contain; border: 1px solid var(--line); }
.panel .info-card img.about-lockup { width: 100%; max-width: 260px; height: auto; }
@media (max-width: 620px) {
  .topbar__brand img { width: 32px; height: 32px; }
}

/* ==========================================================================
   Список чатов: нормальные переносы и изменяемая ширина панели
   ========================================================================== */
.chat-row { align-items: flex-start; }
.chat-row__line { align-items: flex-start; }
.chat-row__title {
  flex: 1; min-width: 0;
  white-space: normal; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; line-height: 1.32;
}
.chat-row__preview {
  white-space: normal; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; line-height: 1.36; margin-top: 3px;
}
.chat-row__meta { padding-top: 1px; }
.chat-row__role, .chat-row__pin { flex: none; }
.chat-row .chat-ava, .chat-row .ava-initials { margin-top: 1px; }

.sb-resizer {
  position: absolute; top: 0; bottom: 0; left: calc(var(--sb-w) - 5px);
  width: 10px; z-index: 36; cursor: col-resize; touch-action: none;
}
.sb-resizer::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px;
  transform: translateX(-50%); background: transparent; border-radius: 2px;
  transition: background .15s ease;
}
.sb-resizer:hover::after, .is-resizing .sb-resizer::after { background: var(--brand-3); }
.sb-resizer:focus-visible { outline: none; }
.sb-resizer:focus-visible::after { background: var(--brand-2); }
body.is-resizing, body.is-resizing * { cursor: col-resize !important; user-select: none !important; }

@media (max-width: 600px) {
  .sb-resizer { display: none; }
}

/* ==========================================================================
   Мобильный композер: 16px (без авто-зума iOS), компактнее и не «раздувается»
   ========================================================================== */
@media (max-width: 900px) {
  .sb__search input,
  .palette__input,
  .input,
  #threadInput,
  #chatFilter,
  #newChatSearch,
  #newChatTitle { font-size: 16px; }
}

@media (max-width: 620px) {
  .composer {
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .composer__box {
    padding: 6px 6px 6px 8px;
    gap: 3px;
    border-radius: 15px;
    align-items: flex-end;
  }
  .composer__input {
    font-size: 16px;
    line-height: 1.4;
    min-height: 40px;
    max-height: 92px;
    padding: 9px 2px 8px;
  }
  .composer__btn { width: 32px; height: 32px; border-radius: 9px; }
  .composer__btn--plus { width: 34px; height: 34px; }
  .composer__send { width: 36px; height: 36px; border-radius: 11px; }
  .composer__divider { display: none; }
  .composer__btn[data-action="attach-menu"]:not(.composer__btn--plus) { display: none; }
  .composer__box:focus-within { box-shadow: 0 0 0 2px var(--brand-soft); }
  .composer__reply { margin-bottom: 6px; }
  .thread-composer { padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px)); }
  .thread-composer .composer__input { min-height: 38px; max-height: 84px; }
}

/* Планшет / внутренний экран складного: список уже, чат шире */
@media (min-width: 601px) and (max-width: 900px) {
  :root { --sb-w: 280px; }
  .topbar__brandtext span { display: none; }
  .topbar__brand img { width: 34px; height: 34px; }
  .chat__inner { padding-inline: 16px; }
  .chat__title { max-width: 100%; }
}

/* На узком десктопном каркасе (планшет/складной) не даём бейджу роли ломать шапку */
@media (max-width: 900px) {
  .chat__title .chat-row__role { display: none; }
  .topbar__ws { gap: 5px; }
}

/* ==========================================================================
   Аватары: «НМ» всегда строго по центру (в т.ч. кнопки с точкой статуса)
   ========================================================================== */
.ava-initials,
.chat-ava,
.topbar__avatar,
.rail__avatar,
.profile-head .ava-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
}
.ava-initials > .presence,
.chat-ava > .presence,
.topbar__avatar > .presence,
.rail__avatar > .presence {
  position: absolute;
  right: -1px;
  bottom: -1px;
}
.profile-head .ava-initials {
  width: 38px;
  height: 38px;
  font-size: 13px;
  color: #fff;
  flex: none;
  line-height: 1;
}

/* ==========================================================================
   Мобильная клавиатура: приложение сжимается по visual viewport,
   композер остаётся над клавиатурой
   ========================================================================== */
.app { height: 100dvh; }
@media (max-width: 600px) {
  .chat__scroll { scroll-padding-bottom: 12px; }
  .chat { padding-bottom: var(--kb-inset, 0px); transition: padding-bottom .12s ease; }
  .panel { padding-bottom: var(--kb-inset, 0px); }
  html[data-kb="1"] .chat__jump { display: none !important; }
}

/* ==========================================================================
   Рабочие пространства — под поиском по чатам
   ========================================================================== */
.sb__spaces {
  flex: none;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 14px 10px;
}
.space-chip {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; flex: none;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--muted); font-size: 10.5px; font-weight: 800; letter-spacing: .3px;
  transition: background .15s, border-color .15s, color .15s, transform .12s;
}
.space-chip img { width: 21px; height: 21px; border-radius: 6px; display: block; }
.space-chip:hover { background: var(--surface-2); border-color: var(--line-strong); color: var(--ink); }
.space-chip:active { transform: scale(.96); }
.space-chip.is-active {
  background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand-3) 55%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-3) 14%, transparent);
}
.space-chip--add {
  border-style: dashed; background: transparent; color: var(--muted-2);
}
.space-chip--add:hover { background: var(--surface-2); color: var(--brand-2); }
@media (max-width: 600px) {
  .sb__spaces { padding-top: 0; }
}

/* ==========================================================================
   Уведомления на телефоне — на весь экран
   ========================================================================== */
.notifs--full {
  left: 0 !important;
  top: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  animation: notifSlide .2s ease;
}
@keyframes notifSlide { from { transform: translateY(12px); opacity: 0; } }
.notifs--full .notifs__head {
  flex: none;
  min-height: 64px;
  padding: 0 16px;
  gap: 12px;
  position: sticky;
  top: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 2;
}
.notifs--full .notifs__head h4 { font-size: 18px; }
.notifs--full .notifs__head button[data-action="mark-all-read"] {
  font-size: 12.5px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
}
.notifs--full .notifs__head .chat__action { width: 40px; height: 40px; }
.notifs--full .notifs__list {
  flex: 1;
  max-height: none;
  overflow-y: auto;
  padding: 8px 10px 20px;
  overscroll-behavior: contain;
}
.notifs--full .notif { padding: 12px 10px; gap: 12px; border-radius: 12px; }
.notifs--full .notif + .notif { border-top: 1px solid var(--line); border-radius: 0; }
.notifs--full .notif__text { font-size: 13.5px; line-height: 1.5; }
.notifs--full .notif__time { font-size: 11.5px; }
.notifs--full .notif .ava-initials { width: 40px; height: 40px; font-size: 13px; }
.notifs--full .notifs__empty { padding: 60px 20px; font-size: 14px; }

/* ==========================================================================
   Тач-устройства (в т.ч. развёрнутый Fold): без авто-фокуса и раздувания поля
   ========================================================================== */
html.is-touch .composer__input {
  font-size: 16px;
  line-height: 1.4;
  min-height: 40px;
  max-height: 88px;
  padding: 9px 2px 8px;
}
html.is-touch .composer__hint { display: none; }
html.is-touch .composer__divider { display: none; }
html.is-touch .composer__btn[data-action="attach-menu"]:not(.composer__btn--plus) { display: none; }
html.is-touch .composer { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
html.is-touch .composer__btn { width: 32px; height: 32px; }
html.is-touch .composer__btn--plus { width: 34px; height: 34px; }
html.is-touch .composer__send { width: 36px; height: 36px; }
html.is-touch .thread-composer .composer__input { max-height: 84px; }

/* ==========================================================================
   Тач-композер: текст и иконки по одной оси (по центру), многострочный — вниз
   ========================================================================== */
html.is-touch .composer__box {
  align-items: center;
  padding: 5px 6px 5px 8px;
}
html.is-touch .composer__box.is-multiline { align-items: flex-end; }
html.is-touch .composer__input {
  min-height: 36px;
  padding: 7px 2px;
  align-self: center;
}
html.is-touch .composer__btn,
html.is-touch .composer__btn--plus,
html.is-touch .composer__send {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}
html.is-touch .composer__send { border-radius: 11px; }
html.is-touch .composer__btn--plus { border-radius: 50%; }

/* Пользователи (каталог сотрудников) */
.users-search { position: relative; display: flex; align-items: center; margin: 4px 0 10px; }
.users-search .icon { position: absolute; left: 12px; color: var(--muted-2); }
.users-search .input { padding-left: 36px; }
.users-list { display: flex; flex-direction: column; gap: 2px; max-height: min(56vh, 520px); overflow-y: auto; padding-right: 2px; }
.user-row { padding: 9px 10px; border-radius: 9px; }
.user-row[hidden] { display: none; }
.user-row__status { font-size: 11.5px; color: var(--muted); flex: none; margin-right: 6px; }
.users-empty { padding: 22px 10px; text-align: center; color: var(--muted); font-size: 13px; }
@media (max-width: 600px) {
  .users-list { max-height: 62vh; }
  .user-row__status { display: none; }
}

/* ==========================================================================
   Мобильные полноэкранные разделы: ветки, инфа о чате, профиль, модалки,
   поиск, меню/эмодзи как нижние шторки
   ========================================================================== */
@media (max-width: 600px) {
  /* модальные окна — на весь экран */
  .overlay--center { padding: 0; align-items: stretch; }
  .overlay--center .modal {
    width: 100%; max-width: 100%;
    height: 100dvh; max-height: 100dvh;
    border: 0; border-radius: 0;
    padding-top: env(safe-area-inset-top, 0px);
  }
  .modal__head { padding: 16px 16px 10px; }
  .modal__head h3 { font-size: 19px; }
  .modal__body { flex: 1; padding: 0 16px 16px; }
  .modal__foot { padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px)); }
  .lightbox { padding: 12px; }

  /* ветка / информация о чате — на весь экран */
  .panel {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100dvh !important;
    border: 0 !important;
    border-left: 0 !important;
    z-index: 120;
    box-shadow: none !important;
  }
  .panel__head {
    height: auto;
    min-height: 60px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px;
    border-bottom: 1px solid var(--line);
  }
  .panel__body { padding: 14px 16px 18px; }
  .thread-composer { padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0px)); }

  /* глобальный поиск/палитра — весь экран */
  .overlay:not(.overlay--plain) { padding: 0; align-items: stretch; }
  .palette {
    width: 100%; max-width: 100%;
    height: 100dvh; max-height: 100dvh;
    border-radius: 0; border: 0;
    padding-top: env(safe-area-inset-top, 0px);
  }
  .palette__top { padding: 16px; }
  .palette__results { flex: 1; }

  /* любые меню/эмодзи/вложения — нижняя шторка */
  .overlay--sheet { align-items: flex-end; background: rgba(4, 10, 24, .38); backdrop-filter: blur(2px); }
  .menu.menu--sheet {
    position: fixed !important;
    left: 0 !important; right: 0 !important; bottom: 0 !important; top: auto !important;
    width: 100% !important; max-width: 100% !important;
    max-height: 74vh; overflow-y: auto;
    border-radius: 18px 18px 0 0;
    border-left: 0; border-right: 0; border-bottom: 0;
    padding: 8px 10px calc(12px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -18px 50px rgba(4, 10, 24, .28);
    animation: sheetUp .18s ease;
  }
  @keyframes sheetUp { from { transform: translateY(16px); opacity: 0; } }
  .menu--sheet::before {
    content: ""; display: block; width: 38px; height: 4px; border-radius: 2px;
    background: var(--line-strong); margin: 2px auto 8px;
  }
  .menu--sheet .menu__item { padding: 12px 12px; font-size: 14.5px; border-radius: 10px; }
  .menu--sheet .menu__emoji-grid { grid-template-columns: repeat(6, 1fr); }
  .menu--sheet .emoji-pop { width: 100%; }
  .menu--sheet .menu__emoji { width: 40px; height: 40px; }
  .menu--sheet .emoji-pop .emoji-grid { max-height: 46vh; }

  /* полноэкранный профиль */
  .sheet--full {
    position: fixed; inset: 0; z-index: 140;
    background: var(--surface);
    display: flex; flex-direction: column;
    height: 100dvh;
    padding-top: env(safe-area-inset-top, 0px);
    animation: sheetUp .18s ease;
  }
  .sheet__head {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px; border-bottom: 1px solid var(--line); flex: none;
  }
  .sheet__head h3 { font-size: 19px; font-weight: 700; flex: 1; }
  .sheet__body { flex: 1; overflow-y: auto; padding: 18px 16px calc(20px + env(safe-area-inset-bottom, 0px)); }
  .profile-sheet__top { display: flex; align-items: center; gap: 14px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
  .profile-sheet__top .ava-initials { width: 62px; height: 62px; font-size: 20px; }
  .profile-sheet__top b { display: block; font-size: 18px; font-weight: 700; }
  .profile-sheet__top span { display: block; font-size: 12.5px; color: var(--muted); margin-top: 3px; }
  .profile-sheet__status { margin-top: 8px !important; font-weight: 650; color: var(--brand-2) !important; font-size: 12px !important; }
  .sheet__list { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
  .sheet__item {
    display: flex; align-items: center; gap: 11px; width: 100%;
    padding: 13px 10px; border-radius: 10px; text-align: left;
    font-size: 15px; font-weight: 550; color: var(--ink);
  }
  .sheet__item:hover { background: var(--surface-hover); }
  .sheet__item .icon { width: 19px; height: 19px; color: var(--muted); }
  .sheet__item--danger { color: var(--danger); }
  .sheet__item--danger .icon { color: var(--danger); }
  .sheet__body .menu__label { margin-top: 14px; }
}

/* Установка PWA */
.install-steps { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 14px; }
.install-step { display: flex; gap: 12px; align-items: flex-start; font-size: 13.5px; line-height: 1.5; color: var(--ink-soft); }
.install-step > b {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-2);
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.install-step .icon { width: 15px; height: 15px; vertical-align: -2px; }
.install-note {
  display: flex; gap: 9px; align-items: flex-start;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 12px; font-size: 12.5px; line-height: 1.5; color: var(--muted);
}
.install-note .icon { width: 16px; height: 16px; flex: none; margin-top: 1px; color: var(--brand-2); }
.install-note + .install-note { margin-top: 8px; }

/* ==========================================================================
   Папки чатов (Все / Личные / Каналы / Группы)
   ========================================================================== */
.sb__folders {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.sb__folders::-webkit-scrollbar { display: none; }
.folder-chip {
  height: 28px;
  padding: 0 10px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  transition: background .15s, color .15s, border-color .15s;
}
.folder-chip:hover { background: var(--surface-3); color: var(--ink); }
.folder-chip.is-active {
  background: var(--brand-soft);
  border-color: color-mix(in srgb, var(--brand-3) 45%, transparent);
  color: var(--brand-2);
}
.folder-chip .n {
  min-width: 16px;
  padding: 0 4px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
.folder-chip.is-active .n { background: color-mix(in srgb, var(--brand-3) 20%, transparent); color: var(--brand-2); }

/* Папки: компактнее, чтобы помещались в узком сайдбаре */
.sb__folders { padding-inline: 12px; gap: 5px; }
.folder-chip { padding: 0 8px; font-size: 11.5px; }

/* ==========================================================================
   Мобильный низ: таббар, скрытие разделов из сайдбара, свайп
   ========================================================================== */
.tabbar { display: none; }

@media (max-width: 600px) {
  .sb__nav { display: none; }

  .tabbar {
    display: flex;
    flex: none;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: 45;
  }
  .tabbar__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 2px 7px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .1px;
    position: relative;
    transition: color .15s;
  }
  .tabbar__item:active { background: var(--surface-2); }
  .tabbar__item .icon { width: 22px; height: 22px; }
  .tabbar__ico { position: relative; display: grid; place-items: center; }
  .tabbar__badge {
    position: absolute; top: -4px; right: -10px;
    min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 8px; background: var(--accent); color: #2a1400;
    font-size: 10px; font-weight: 800; line-height: 16px; text-align: center;
    box-shadow: 0 0 0 2px var(--surface);
  }
  .tabbar__count {
    position: absolute; top: -5px; right: -12px;
    background: var(--brand-soft); color: var(--brand-2);
    font-size: 9.5px; font-weight: 700;
    border-radius: 7px; padding: 1px 5px;
    box-shadow: 0 0 0 2px var(--surface);
  }
}

/* ==========================================================================
   Шапка чата: клик по названию — информация о чате
   ========================================================================== */
.chat__titlewrap {
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.chat__titlewrap:hover .chat__title { color: var(--brand-2); }

/* Композер: не показываем скролл, пока текст не переполнил поле */
.composer__input { scrollbar-width: none; }
.composer__input::-webkit-scrollbar { display: none; }
html.is-touch .composer__input { overflow-y: hidden; }
html.is-touch .composer__box.is-multiline .composer__input { overflow-y: auto; }

/* ==========================================================================
   Телефон: чаты и люди — полноценные страницы, а не выдвижные меню
   ========================================================================== */
@media (max-width: 600px) {
  :root { --tabbar-h: calc(56px + env(safe-area-inset-bottom, 0px)); }

  .tabbar { height: var(--tabbar-h); }
  .tabbar__item.is-active { color: var(--brand-2); }
  .tabbar__item.is-active .icon { color: var(--brand-2); }

  .sidebar-veil { display: none !important; }

  body[data-view="chat"] .sidebar { transform: translateX(-104%); }

  body[data-view="chats"] .sidebar,
  body[data-view="people"] .sidebar {
    position: fixed;
    left: 0; right: 0; top: var(--topbar-h); bottom: var(--tabbar-h);
    width: auto; height: auto;
    transform: none;
    border-right: 0;
    box-shadow: none;
    z-index: 80;
  }

  body[data-view="chats"] .chat,
  body[data-view="people"] .chat { visibility: hidden; }

  .m-page {
    position: fixed;
    left: 0; right: 0; top: var(--topbar-h); bottom: var(--tabbar-h);
    background: var(--surface);
    z-index: 85;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }
  .m-page[hidden] { display: none; }
  .m-page__head {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 2;
    background: var(--surface);
  }
  .m-page__head h2 { font-size: 19px; font-weight: 700; flex: 1; }
  .m-page__body { padding: 12px 14px 20px; }
  .m-page .users-list { max-height: none; }
}

/* ==========================================================================
   Мобильная шапка приложения: верхний бар убираем, вместо него — шапки страниц
   ========================================================================== */
.sb__mobilehead { display: none; }
.chat__action--mobile { display: none; }

@media (max-width: 900px) {
  :root {
    --topbar-h: 0px;
    --tabbar-h: calc(56px + env(safe-area-inset-bottom, 0px));
  }
  .topbar { display: none !important; }

  .sb__mobilehead {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: none;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 2px;
  }
  .sb__mobilebrand { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
  .sb__mobilebrand img { width: 32px; height: 32px; border-radius: 9px; background: #fff; padding: 2px; }
  .sb__mobilebrand b { display: block; font-size: 16px; font-weight: 750; letter-spacing: -.2px; }
  .sb__mobilebrand span { display: block; font-size: 9px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted-2); }
  .sb__mobilehead .sb__iconbtn { position: relative; }
  .sb__mobilehead .sb__iconbtn .dot { position: absolute; top: 8px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--surface); }

  .tabbar {
    display: flex;
    flex: none;
    height: var(--tabbar-h);
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: 45;
  }
  .tabbar__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 2px 7px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .1px;
    position: relative;
    transition: color .15s;
  }
  .tabbar__item:active { background: var(--surface-2); }
  .tabbar__item .icon { width: 22px; height: 22px; }
  .tabbar__item.is-active, .tabbar__item.is-active .icon { color: var(--brand-2); }
  .tabbar__ico { position: relative; display: grid; place-items: center; }
  .tabbar__badge {
    position: absolute; top: -4px; right: -10px;
    min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 8px; background: var(--accent); color: #2a1400;
    font-size: 10px; font-weight: 800; line-height: 16px; text-align: center;
    box-shadow: 0 0 0 2px var(--surface);
  }
  .tabbar__count {
    position: absolute; top: -5px; right: -12px;
    background: var(--brand-soft); color: var(--brand-2);
    font-size: 9.5px; font-weight: 700;
    border-radius: 7px; padding: 1px 5px;
    box-shadow: 0 0 0 2px var(--surface);
  }

  .chat__action--mobile { display: grid; }
  .chat__header { padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
  .panel__head { padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
  .m-page { top: 0 !important; }
  body[data-view="chats"] .sidebar,
  body[data-view="people"] .sidebar { top: 0 !important; }
}

@media (max-width: 600px) {
  .chat__back { display: grid; }
  .sb__search { padding-top: 8px; }
}

/* Свайп по сообщению → ответ */
@media (max-width: 600px) {
  .msg { transition: transform .16s ease, background .16s ease; will-change: transform; }
  .msg.is-swiping {
    background: color-mix(in srgb, var(--brand-soft) 75%, transparent);
    border-radius: 12px;
  }
  .msg.is-swiping::after {
    content: "↩";
    position: absolute; left: 2px; top: 50%;
    transform: translateY(-50%);
    font-size: 18px; color: var(--brand-2);
    opacity: .9;
    pointer-events: none;
  }
}

/* Цитата ответа: текст не выходит за рамки */
.msg__quote > div { min-width: 0; flex: 1; overflow: hidden; }
.msg__quote .txt {
  display: block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.composer__reply > div { min-width: 0; flex: 1; overflow: hidden; }
.composer__reply .txt {
  display: block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Мобильные вкладки: без «корявых» анимаций и лишнего профиля внизу списка */
@media (max-width: 900px) {
  .sb__footer { display: none !important; }
  .sidebar { transition: none !important; }
  .tabbar__item { transition: none !important; }
  .m-page { animation: none !important; }
  .msg { transition: none; }
}

/* ==========================================================================
   Красивый экран профиля
   ========================================================================== */
.profile-head-bar { gap: 6px; }
.profile-head-bar h2 { font-size: 18px; }
.profile-page { display: flex; flex-direction: column; gap: 16px; }

.profile-hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 10px 28px #0b17300f;
}
.profile-hero__cover {
  height: 96px;
  background:
    radial-gradient(120px 120px at 82% -20%, #6498ca55, transparent 70%),
    radial-gradient(180px 180px at 12% 120%, #1d4f9c33, transparent 70%),
    linear-gradient(120deg, #07173f 0%, #12315f 55%, #2a5c9e 100%);
  position: relative;
}
.profile-hero__cover::after {
  content: ""; position: absolute; right: -30px; top: -60px;
  width: 180px; height: 180px; border-radius: 50%;
  border: 1px solid #ffffff1f;
  box-shadow: 0 0 0 30px #ffffff08, 0 0 0 60px #ffffff05;
}
.profile-hero__body { padding: 0 18px 16px; text-align: center; }
.profile-hero__ava {
  width: 84px; height: 84px; margin: -42px auto 10px;
  border-radius: 50%;
}
.profile-hero__ava .ava-initials {
  width: 84px; height: 84px; font-size: 26px;
  border: 4px solid var(--surface);
  box-shadow: 0 10px 22px #0b173026;
}
.profile-hero__body h3 { font-size: 20px; font-weight: 750; letter-spacing: -.3px; }
.profile-hero__body p { font-size: 13px; color: var(--muted); margin-top: 3px; }
.profile-hero__status {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 10px; padding: 4px 11px; border-radius: 20px;
  background: var(--green-soft); color: var(--green);
  font-size: 11.5px; font-weight: 650;
}
.profile-hero__status .presence { border: 0; width: 8px; height: 8px; }

.profile-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.profile-stats > div { padding: 12px 8px; text-align: center; }
.profile-stats > div + div { border-left: 1px solid var(--line); }
.profile-stats b { display: block; font-size: 18px; font-weight: 750; letter-spacing: -.4px; }
.profile-stats span { font-size: 11px; color: var(--muted); }

.profile-section { display: flex; flex-direction: column; gap: 8px; }
.profile-section__title {
  font-size: 11px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
  color: var(--muted-2); padding-left: 4px;
}
.status-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.status-chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 13px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 12.5px; font-weight: 600; color: var(--muted);
}
.status-chip .presence { border: 0; width: 8px; height: 8px; }
.status-chip.is-active {
  border-color: color-mix(in srgb, var(--brand-3) 50%, transparent);
  background: var(--brand-soft); color: var(--brand-2);
}

.profile-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}
.profile-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 13px 14px; text-align: left; background: none;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.profile-row:last-child { border-bottom: 0; }
.profile-row:active { background: var(--surface-2); }
.profile-row--static { cursor: default; }
.profile-row__icon {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-2);
}
.profile-row__icon .icon { width: 18px; height: 18px; }
.profile-row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.profile-row__main b { font-size: 13.5px; font-weight: 650; }
.profile-row__main span { font-size: 11.5px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-row__chev { color: var(--muted-2); width: 16px; height: 16px; flex: none; }
.profile-row--danger .profile-row__icon { background: var(--danger-soft); color: var(--danger); }
.profile-row--danger .profile-row__main b { color: var(--danger); }
.profile-footer { text-align: center; font-size: 11px; color: var(--muted-2); padding: 4px 0 12px; }

@media (max-width: 600px) {
  .profile-page { padding: 12px 12px 20px; }
  .profile-hero__cover { height: 88px; }
  .profile-hero__ava .ava-initials { width: 78px; height: 78px; font-size: 24px; }
  .profile-hero__ava { width: 78px; height: 78px; margin-top: -39px; }
}

/* ==========================================================================
   Аккуратные анимации переходов (только opacity/transform, без лагов)
   ========================================================================== */
@keyframes lunaPageIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes lunaSideIn {
  from { opacity: 0; transform: translateX(-14px); }
  to { opacity: 1; transform: none; }
}
@keyframes lunaChatIn {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: none; }
}
@media (max-width: 900px) {
  .anim-page { animation: lunaPageIn .22s cubic-bezier(.2,.7,.3,1); }
  .anim-side { animation: lunaSideIn .22s cubic-bezier(.2,.7,.3,1); }
  .anim-chat { animation: lunaChatIn .2s cubic-bezier(.2,.7,.3,1); }
  .tabbar__item { transition: color .15s ease; }
}
@media (prefers-reduced-motion: reduce) {
  .anim-page, .anim-side, .anim-chat { animation: none !important; }
}


/* ==========================================================================
   Ответ на сообщение: аккуратный свайп-индикатор и цитата
   ========================================================================== */
@media (max-width: 600px) {
  .msg.is-swiping {
    background: transparent !important;
    border-radius: 18px;
  }
  .msg.is-swiping::before {
    content: "";
    position: absolute; left: 8px; top: 50%;
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--brand-soft);
    border: 1px solid color-mix(in srgb, var(--brand-3) 40%, transparent);
    transform: translateY(-50%) scale(calc(.45 + var(--swipe, 0) * .55));
    opacity: calc(var(--swipe, 0) * .95);
    pointer-events: none;
    z-index: 1;
  }
  .msg.is-swiping::after {
    content: "";
    position: absolute; left: 17px; top: 50%;
    width: 18px; height: 18px;
    background: var(--brand-2);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 17 4 12l5-5'/%3E%3Cpath d='M20 18v-2a4 4 0 0 0-4-4H4'/%3E%3C/svg%3E") center / 18px no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 17 4 12l5-5'/%3E%3Cpath d='M20 18v-2a4 4 0 0 0-4-4H4'/%3E%3C/svg%3E") center / 18px no-repeat;
    transform: translateY(-50%) scale(calc(.6 + var(--swipe, 0) * .4));
    opacity: calc(var(--swipe, 0) * .95);
    pointer-events: none;
    z-index: 2;
  }
}

.composer__reply {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 14px;
}
.composer__reply-icon {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
  background: var(--brand-soft); color: var(--brand-2);
}
.composer__reply-icon .icon { width: 16px; height: 16px; }
.composer__reply-body { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.composer__reply-body b { font-size: 12px; font-weight: 650; color: var(--brand-2); }
.composer__reply-body .txt {
  display: block; min-width: 0; max-width: 100%;
  font-size: 12.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.composer__reply-close {
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center; color: var(--muted);
  flex: none;
}
.composer__reply-close:hover { background: var(--surface-hover); color: var(--ink); }

.msg__quote-icon {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
  background: var(--brand-soft); color: var(--brand-2);
}
.msg__quote-icon .icon { width: 14px; height: 14px; }
.msg__quote { align-items: center; padding: 7px 10px; gap: 9px; }
.msg__quote > div { display: flex; flex-direction: column; }

/* На десктопе — воздух между сообщениями и панелью отправки */
@media (min-width: 901px) {
  .chat__inner { padding-bottom: 26px; }
  .composer { padding-top: 14px; }
}

@media (max-width: 600px) {
  .msg { transition: transform .18s ease; }
  .msg.is-swiping { transition: none; }
}
