/* ==========================================================================
   Nimble · application shell — rail, chat list, conversation, composer
   ========================================================================== */

.app {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: 74px minmax(276px, 340px) minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  height: 100vh;
  height: 100dvh;
  animation: fadeIn .4s ease both;
}
.app.has-side { grid-template-columns: 74px minmax(276px, 340px) minmax(0, 1fr) minmax(280px, 330px); }

/* --------------------------------- rail ---------------------------------- */
.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 0;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .025));
  border: 1px solid var(--border);
  backdrop-filter: blur(var(--blur)) saturate(140%);
  box-shadow: var(--shadow-1);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  overscroll-behavior: contain;
}
.rail::-webkit-scrollbar { width: 0; height: 0; display: none; }
[data-theme='light'] .rail { background: linear-gradient(180deg, #fff, rgba(255, 255, 255, .75)); }
.rail__logo { margin-bottom: 10px; flex: none; }
.rail__btn, .rail__me { flex: none; }
.rail__btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 15px;
  color: var(--text-2);
  transition: background .2s, color .2s, transform .18s;
}
.rail__btn:hover { background: var(--surface-2); color: var(--text); transform: translateY(-2px); }
.rail__btn.is-active { color: #fff; background: var(--grad); box-shadow: var(--accent-glow); }
.rail__btn.is-active::before {
  content: '';
  position: absolute;
  left: -14px;
  top: 50%;
  width: 4px;
  height: 22px;
  transform: translateY(-50%);
  border-radius: 0 4px 4px 0;
  background: var(--grad);
}
.rail__btn .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 19px;
  height: 19px;
  font-size: 11px;
  padding: 0 5px;
}
.rail__spacer { flex: 1; }
.rail__me { position: relative; border-radius: 15px; transition: transform .18s; }
.rail__me:hover { transform: translateY(-2px) scale(1.04); }
.rail__me-dot { position: absolute; right: -2px; bottom: -2px; border-color: var(--bg-2); }

/* --------------------------------- panels -------------------------------- */
.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .022));
  border: 1px solid var(--border);
  backdrop-filter: blur(var(--blur)) saturate(140%);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
[data-theme='light'] .panel { background: linear-gradient(180deg, #fff, rgba(255, 255, 255, .78)); }
.panel__head { padding: 16px 16px 12px; border-bottom: 1px solid var(--border); }
.panel__title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.panel__title { display: flex; align-items: center; gap: 9px; font-size: 19px; font-weight: 780; letter-spacing: -.3px; }
.panel__actions { display: flex; align-items: center; gap: 6px; }
.panel__body { flex: 1; min-height: 0; min-width: 0; padding: 8px; overflow: hidden; }
.panel__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 15px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
}
.conn { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.conn__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-3);
  transition: background .3s, box-shadow .3s;
}
.conn.is-online .conn__dot { background: var(--ok); box-shadow: 0 0 10px rgba(53, 211, 154, .9); }
.conn.is-online { color: var(--ok); }
.conn.is-offline .conn__dot { background: var(--danger); box-shadow: 0 0 10px rgba(251, 113, 133, .8); }
.conn.is-offline { color: #ff9fb0; }
.conn.is-connecting .conn__dot { background: var(--warn); animation: pulseRing 1.6s infinite; }
.conn.is-connecting { color: var(--warn); }

/* -------------------------------- search --------------------------------- */
.search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color .2s, box-shadow .2s, background .2s;
  margin-bottom: 11px;
}
.search > .ico { color: var(--text-3); }
.search:focus-within { border-color: rgba(124, 140, 255, .5); box-shadow: 0 0 0 4px rgba(124, 140, 255, .12); background: var(--surface-2); }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 14.2px;
}
.search input::placeholder { color: var(--text-3); }
.search input::-webkit-search-cancel-button { display: none; }
.search__kbd {
  padding: 3px 7px;
  border-radius: 7px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.search:focus-within .search__kbd { display: none; }

.chips { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }

/* ------------------------------ chat items ------------------------------- */
.chat-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  text-align: left;
  transition: background .18s, transform .18s;
  animation: popIn .3s ease both;
  overflow: hidden;
}
.chat-item:hover { background: var(--surface-2); }
.chat-item.is-active { background: var(--grad-soft); box-shadow: inset 0 0 0 1px var(--border-strong); }
.chat-item.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 14%;
  height: 72%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--grad);
}
.chat-item__avatar { position: relative; }
.chat-item__avatar .dot { position: absolute; right: -3px; bottom: -2px; border-color: var(--bg-2); }
.chat-item__body { flex: 1; min-width: 0; }
.chat-item__top { display: flex; align-items: center; gap: 8px; }
.chat-item__name { flex: 1; min-width: 0; overflow: hidden; font-weight: 640; font-size: 14.6px; letter-spacing: -.1px; }
.chat-item__name .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item__time { font-size: 11.6px; color: var(--text-3); white-space: nowrap; }
.chat-item__bottom { display: flex; align-items: center; gap: 7px; margin-top: 3px; min-width: 0; }
.chat-item__preview { flex: 1; min-width: 0; font-size: 13.3px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item__preview b { color: var(--text-2); font-weight: 600; }
.chat-item--unread .chat-item__name { font-weight: 760; }
.chat-item--unread .chat-item__preview { color: var(--text); }
.chat-item__typing { color: var(--accent-3); font-style: normal; }
.chat-item__badge {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 99px;
  font-size: 11.8px;
  font-weight: 750;
  color: #fff;
  background: var(--grad);
  box-shadow: 0 6px 16px -7px rgba(124, 140, 255, .95);
}
.chat-item__badge--muted { background: var(--surface-3); color: var(--text-2); box-shadow: none; }
.chat-item__pin { color: var(--text-3); }
.chat-item__verified { color: var(--accent-3); }
.chat-item__draft { color: var(--danger); font-style: normal; }

/* --------------------------- saved messages row -------------------------- */
.chat-item--saved .avatar--saved { background: linear-gradient(150deg, #7c8cff, #a855f7 55%, #ec4899); }
.chat-item--saved .avatar--saved .ico { width: 21px; height: 21px; color: #fff; }
.chat-item--saved .chat-item__name { flex: none; }
.chat-item--saved .chat-item__badge { background: var(--grad); }

.list-section { padding: 14px 12px 6px; font-size: 11.6px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); min-width: 0; }

.skeleton-row { display: flex; gap: 12px; align-items: center; padding: 12px; }
.skeleton {
  border-radius: 12px;
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-3) 40%, var(--surface) 80%);
  background-size: 500px 100%;
  animation: shimmer 1.5s linear infinite;
}
.skeleton--avatar { width: 46px; height: 46px; border-radius: 16px; flex: none; }
.skeleton--line { height: 11px; flex: 1; }
.skeleton--line.short { width: 40%; flex: none; }

.list-empty { padding: 40px 18px; text-align: center; color: var(--text-3); font-size: 13.6px; }
.list-empty .ico { width: 34px; height: 34px; margin: 0 auto 12px; opacity: .5; }

/* ---------------------------- conversation ------------------------------- */
.chat {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .02));
  border: 1px solid var(--border);
  backdrop-filter: blur(var(--blur)) saturate(140%);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
[data-theme='light'] .chat { background: linear-gradient(180deg, #fff, rgba(255, 255, 255, .8)); }

.chat__head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, .04), transparent);
  min-height: 76px;
}
.chat__back { display: none; }
.chat__identity {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  transition: background .18s;
  text-align: left;
  overflow: hidden;
}
.chat__identity:hover { background: var(--surface); }
.chat__identity-text { min-width: 0; overflow: hidden; }
.chat__name { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; font-size: 16.4px; font-weight: 700; letter-spacing: -.2px; }
.chat__name > span:not(.pill) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat__name .ico { flex: none; color: var(--accent-3); width: 17px; height: 17px; }
.chat__status { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; white-space: nowrap; font-size: 12.8px; color: var(--text-2); margin-top: 1px; }
.chat__status > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat__status--online { color: var(--ok); }
.chat__status--typing { color: var(--accent-3); }
.chat__tools { display: flex; align-items: center; gap: 4px; flex: none; }
.chat__search {
  position: absolute;
  inset: 8px 12px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  backdrop-filter: blur(20px);
  animation: fadeIn .2s ease both;
}
.chat__search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; }
.chat__search-count { font-size: 12.6px; color: var(--text-3); white-space: nowrap; }

.chat__body {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 18px clamp(12px, 3vw, 30px) 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ------------------------------ messages --------------------------------- */
.day {
  display: flex;
  justify-content: center;
  margin: 16px 0 12px;
  animation: fadeIn .3s ease both;
}
.day span {
  padding: 5px 13px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 650;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.unread-line {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.unread-line::before, .unread-line::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(124, 140, 255, .6), transparent);
}
[data-theme='light'] .unread-line { color: var(--accent-2); }

.msg { display: flex; gap: 10px; margin-bottom: 9px; align-items: flex-end; animation: bubbleIn .3s cubic-bezier(.2, .9, .25, 1) both; }
.msg--me { flex-direction: row-reverse; }
.msg--grouped { margin-top: -5px; }
.msg__avatar { align-self: flex-end; margin-bottom: 2px; }
.msg__avatar-spacer { width: 36px; flex: none; }
.msg__col { display: flex; flex-direction: column; min-width: 0; max-width: min(620px, 82%); align-items: flex-start; }
.msg--me .msg__col { align-items: flex-end; }
.msg__author { font-size: 12.6px; font-weight: 700; margin: 0 6px 4px; letter-spacing: .1px; }

.msg__bubble {
  position: relative;
  display: block;
  padding: 9px 13px 8px;
  border-radius: 20px 20px 20px 6px;
  background: var(--bubble-them);
  border: 1px solid var(--bubble-them-border);
  box-shadow: 0 6px 18px -12px rgba(0, 0, 0, .9);
  transition: box-shadow .25s, transform .2s;
  max-width: 100%;
}
.msg__bubble:hover { box-shadow: 0 12px 30px -14px rgba(0, 0, 0, .95); }
.msg--me .msg__bubble {
  border-radius: 20px 20px 6px 20px;
  color: #fff;
  background: var(--bubble-me);
  border-color: transparent;
  box-shadow: var(--accent-glow);
}
.msg__text {
  font-size: 14.6px;
  line-height: 1.42;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg__text a { color: inherit; text-decoration: underline; text-underline-offset: 2px; opacity: .95; }
.msg__meta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  float: right;
  margin: 6px -2px -2px 9px;
  font-size: 11.3px;
  font-weight: 600;
  color: var(--text-3);
  white-space: nowrap;
}
.msg__bubble::after { content: ''; display: table; clear: both; }
.msg__retry {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-left: 2px;
  border-radius: 50%;
  color: #ffb3c0;
  background: rgba(251, 113, 133, .18);
  transition: background .16s, transform .16s;
}
.msg__retry:hover { background: rgba(251, 113, 133, .3); transform: rotate(-24deg); }
.msg__retry .ico { width: 13px; height: 13px; }
.msg--pending .msg__bubble { opacity: .6; }
.msg--pending .msg__meta { color: var(--text-3); }
.msg--failed .msg__bubble { border-color: rgba(251, 113, 133, .55); box-shadow: 0 0 0 3px rgba(251, 113, 133, .12); }
.msg--failed.msg--me .msg__bubble { background: linear-gradient(135deg, #fb7185, #b06cff); box-shadow: 0 0 0 3px rgba(251, 113, 133, .2); }
.msg--me .msg__meta { color: rgba(255, 255, 255, .82); }
.msg__meta .ico { width: 15px; height: 15px; stroke-width: 2.2; }
.msg__ticks--read { color: #b9f5ff; }
.msg--me .msg__ticks--read { color: #eafaff; }
.msg__edited { opacity: .75; font-size: 11px; }
.msg__reply {
  display: block;
  margin: 0 0 6px;
  padding: 6px 10px 6px 10px;
  border-radius: 10px;
  border-left: 3px solid currentColor;
  background: rgba(255, 255, 255, .07);
  font-size: 12.8px;
  cursor: pointer;
  transition: background .18s;
  max-width: 100%;
}
[data-theme='light'] .msg__reply { background: rgba(20, 30, 60, .05); }
.msg__reply:hover { background: rgba(255, 255, 255, .13); }
.msg--me .msg__reply { background: rgba(255, 255, 255, .18); border-left-color: rgba(255, 255, 255, .8); }
.msg__reply b { display: block; font-size: 12.2px; margin-bottom: 1px; }
.msg__reply span { display: block; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.msg__reactions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; clear: both; }
.reaction {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 650;
  background: var(--surface-3);
  border: 1px solid var(--border);
  transition: transform .16s, background .2s, border-color .2s;
}
.reaction:hover { transform: translateY(-2px) scale(1.04); }
.reaction.is-mine { background: var(--grad-soft); border-color: rgba(124, 140, 255, .5); }
.msg--me .reaction { background: rgba(255, 255, 255, .2); border-color: rgba(255, 255, 255, .3); color: #fff; }
.msg--me .reaction.is-mine { background: rgba(255, 255, 255, .34); }

.msg__actions {
  position: absolute;
  top: -42px;
  right: 6px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 99px;
  background: linear-gradient(180deg, rgba(30, 36, 66, .97), rgba(20, 26, 50, .97));
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-2);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px) scale(.94);
  transition: opacity .18s, transform .18s;
  z-index: 4;
}
[data-theme='light'] .msg__actions { background: #fff; }
.msg--me .msg__actions { right: auto; left: 6px; }
.msg:hover .msg__actions { opacity: 1; transform: none; pointer-events: auto; }
.msg__action {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--text-2);
  transition: background .16s, color .16s, transform .16s;
}
.msg__action:hover { background: var(--surface-3); color: var(--text); transform: scale(1.08); }
.msg__action .ico { width: 16px; height: 16px; }

.msg--system { justify-content: center; margin: 10px 0; }
.msg--system .msg__bubble {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-2);
  border-radius: 99px;
  font-size: 12.6px;
  padding: 6px 14px;
  box-shadow: none;
}
.msg--deleted .msg__text { font-style: italic; opacity: .6; }
.msg--emoji .msg__bubble { background: none; border-color: transparent; box-shadow: none; padding: 2px 0; }
.msg--emoji .msg__text { font-size: 42px; line-height: 1.1; }
.msg--emoji.msg--me .msg__bubble { background: none; box-shadow: none; }
.msg--highlight .msg__bubble { animation: flash 1.6s ease; }
@keyframes flash {
  0%, 100% { box-shadow: 0 0 0 0 rgba(124, 140, 255, 0); }
  25%      { box-shadow: 0 0 0 4px rgba(124, 140, 255, .35); }
}
.chat__loader { display: flex; justify-content: center; padding: 14px; color: var(--text-3); font-size: 12.6px; }

/* --------------------------------- jump ---------------------------------- */
.jump {
  position: absolute;
  right: 22px;
  bottom: 118px;
  z-index: 5;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--text);
  background: linear-gradient(180deg, rgba(30, 36, 66, .95), rgba(20, 26, 50, .95));
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(14px);
  animation: popIn .24s ease both;
  transition: transform .18s;
}
[data-theme='light'] .jump { background: #fff; }
.jump:hover { transform: translateY(-3px); }
.jump__count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border-radius: 99px;
  font-size: 11.6px;
  font-weight: 750;
  color: #fff;
  background: var(--grad);
  box-shadow: var(--accent-glow);
}

/* ------------------------------- composer -------------------------------- */
.composer { position: relative; padding: 10px clamp(12px, 3vw, 26px) 16px; }
.composer__box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 7px 8px 7px 10px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.composer__box:focus-within {
  border-color: rgba(124, 140, 255, .5);
  box-shadow: 0 0 0 4px rgba(124, 140, 255, .12);
  background: var(--surface-2);
}
.composer__box textarea {
  flex: 1;
  min-width: 0;
  max-height: 180px;
  min-height: 40px;
  padding: 9px 0;
  border: 0;
  background: transparent;
  outline: none;
  resize: none;
  font-size: 14.8px;
  line-height: 1.4;
}
.composer__box textarea::placeholder { color: var(--text-3); }
.composer__hint { font-size: 11.6px; color: var(--text-3); margin-bottom: 12px; white-space: nowrap; }
@media (max-width: 720px) { .composer__hint { display: none; } }
.send {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 15px;
  color: #fff;
  background: var(--grad);
  box-shadow: var(--accent-glow);
  transition: transform .18s cubic-bezier(.2, .8, .2, 1), filter .2s, opacity .2s;
}
.send:hover { transform: translateY(-2px) scale(1.05); filter: brightness(1.08); }
.send:active { transform: scale(.94); }
.send[disabled] { opacity: .38; box-shadow: none; pointer-events: none; }

.composer__banner {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 8px;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  animation: popIn .2s ease both;
}
.composer__banner .ico { color: var(--accent); }
.composer__banner--edit { border-left-color: var(--warn); }
.composer__banner--edit .ico { color: var(--warn); }
.composer__banner-text { flex: 1; min-width: 0; font-size: 13.2px; }
.composer__banner-text b { display: block; font-size: 12.6px; color: var(--accent); }
.composer__banner--edit .composer__banner-text b { color: var(--warn); }
.composer__banner-text span { display: block; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer__noaccess {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 15px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  color: var(--text-2);
  font-size: 13.6px;
}

/* --------------------------- voice recording ring ------------------------ */
.rec {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 10px);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  pointer-events: none;
  animation: popIn .16s ease both;
}
.rec[hidden] { display: none; }
.rec__circle {
  display: grid;
  place-items: center;
  gap: 1px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  color: #fff;
  background: radial-gradient(circle at 32% 24%, #ff8095, #e11d48 68%);
  animation: recPulse 1.6s ease-in-out infinite;
}
.rec__ico { width: 20px; height: 20px; opacity: .9; }
.rec__time { font-size: 19px; font-weight: 750; letter-spacing: .4px; font-variant-numeric: tabular-nums; }
.rec__hint {
  padding: 5px 12px;
  border-radius: 99px;
  background: rgba(12, 16, 32, .82);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12.2px;
  white-space: nowrap;
  backdrop-filter: blur(12px);
}
.rec.is-cancel .rec__circle { background: #3a3f55; animation: none; }
.rec.is-cancel .rec__hint { color: var(--danger); }
@keyframes recPulse {
  0%, 100% { box-shadow: 0 0 0 7px rgba(225, 29, 72, .16), 0 18px 38px -20px rgba(225, 29, 72, .9); }
  50% { box-shadow: 0 0 0 18px rgba(225, 29, 72, .03), 0 18px 38px -20px rgba(225, 29, 72, .9); }
}

/* --------------------------- saved chats (modal) ------------------------- */
.saved-head {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 2px 2px 14px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.saved-head__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.saved-head__text b { font-size: 16px; }
.saved-head__text span { font-size: 12.6px; color: var(--text-3); }
.saved-list { display: flex; flex-direction: column; gap: 10px; padding-top: 8px; }
.saved-msg {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 4px;
  border-radius: 14px;
  cursor: pointer;
  transition: background .15s;
}
.saved-msg:hover { background: var(--surface); }
.saved-msg__bubble {
  min-width: 0;
  max-width: min(560px, 82%);
  padding: 9px 13px 10px;
  border-radius: 4px 16px 16px 16px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.saved-msg__meta { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; margin-bottom: 3px; font-size: 11.6px; color: var(--text-3); }
.saved-msg__meta b { color: var(--accent-3); font-weight: 650; }
.saved-msg__text { font-size: 13.8px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.saved-msg__remove { flex: none; opacity: .45; transition: opacity .15s, background .15s; }
.saved-msg:hover .saved-msg__remove, .saved-msg__remove:focus-visible { opacity: 1; }

/* ------------------------------ empty state ------------------------------ */
.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  text-align: center;
  padding: 30px;
  animation: fadeIn .4s ease both;
}
.empty__art {
  display: grid;
  place-items: center;
  width: 104px;
  height: 104px;
  border-radius: 34px;
  color: #fff;
  background: var(--grad);
  box-shadow: var(--accent-glow), var(--shadow-in);
  margin-bottom: 6px;
  animation: bob 7s ease-in-out infinite;
}
.empty__art .ico { width: 46px; height: 46px; }
.empty h3 { font-size: 22px; font-weight: 750; letter-spacing: -.4px; }
.empty p { color: var(--text-2); font-size: 14.4px; max-width: 44ch; }

/* ------------------------------- responsive ------------------------------ */
@media (max-width: 1180px) {
  .app.has-side { grid-template-columns: 74px minmax(250px, 300px) minmax(0, 1fr); }
  .side { position: fixed; top: 12px; right: 12px; bottom: 12px; width: min(380px, calc(100vw - 24px)); z-index: 60; box-shadow: var(--shadow-2); animation: slideRight .3s ease both; }
}
@media (max-width: 1080px) {
  .app, .app.has-side { grid-template-columns: 68px minmax(236px, 292px) minmax(0, 1fr); gap: 10px; padding: 10px; }
  .chat__head { gap: 9px; padding: 10px 12px; min-height: 68px; }
  .chat__identity { gap: 10px; padding: 4px 6px; }
  .chat__tools .icon-btn { width: 38px; height: 38px; }
  .composer { padding: 8px 12px 12px; }
  .composer__box { flex-wrap: wrap; align-items: center; gap: 3px; padding: 5px 6px; border-radius: 16px; }
  .composer__box .icon-btn { width: 38px; height: 38px; flex: none; }
  .composer__box textarea {
    order: 2;
    flex: 1 1 100%;
    width: 100%;
    min-height: 42px;
    max-height: 112px;
    padding: 9px 11px;
    border-radius: 12px;
    background: var(--surface-2);
  }
  .composer__box .send { order: 1; width: 42px; height: 42px; margin-left: auto; border-radius: 14px; }
  .composer__hint { display: none; }
}
@media (max-width: 760px) {
  .app, .app.has-side { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 0; padding: 0; }
  .rail {
    grid-row: 2;
    flex-direction: row;
    justify-content: flex-start;
    gap: 2px;
    height: calc(60px + env(safe-area-inset-bottom, 0px));
    padding: 4px 8px calc(4px + env(safe-area-inset-bottom, 0px));
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    overflow-x: auto;
    overflow-y: hidden;
    z-index: 40;
  }
  .rail__logo, .rail__spacer { display: none; }
  .rail__btn { width: 46px; height: 44px; border-radius: 14px; }
  .rail__btn.is-active::before { display: none; }
  .rail__me { margin-left: auto; }
  .rail__me .avatar { width: 40px; height: 40px; border-radius: 14px; }
  .panel { border-radius: 0; border-left: 0; border-right: 0; border-top: 0; }
  .list-panel { grid-row: 1; }
  .chat { grid-row: 1; border-radius: 0; border: 0; }
  .app:not(.chat-open) .chat { display: none; }
  .app.chat-open .list-panel { display: none; }
  .chat__back { display: grid; width: 34px; height: 34px; flex: none; }
  .chat__head { gap: 4px; padding: 7px 8px; min-height: 60px; }
  .chat__identity { gap: 8px; padding: 3px 4px; }
  .chat__head .avatar--md { width: 40px; height: 40px; border-radius: 14px; }
  .chat__identity-text { flex: 1; }
  .chat__name { gap: 4px; font-size: 15.2px; }
  .chat__name .ico { width: 15px; height: 15px; }
  .chat__status { gap: 4px; font-size: 11.8px; }
  .chat__tools { gap: 0; }
  .chat__tools .icon-btn { width: 34px; height: 34px; }
  .chat__tools .icon-btn .ico { width: 17px; height: 17px; }
  .side { position: fixed; inset: 0; width: auto; border-radius: 0; z-index: 60; }
  .toasts { top: 10px; right: 10px; left: 10px; width: auto; }
  .jump { bottom: 132px; right: 12px; }
  .msg__col { max-width: 90%; }
  .composer { padding: 6px 8px 8px; }
  .composer__box { flex-wrap: wrap; align-items: center; gap: 3px; padding: 5px 6px; border-radius: 16px; }
  .composer__box .icon-btn { width: 36px; height: 36px; flex: none; }
  .composer__box .icon-btn .ico { width: 18px; height: 18px; }
  .composer__box textarea {
    order: 2;
    flex: 1 1 100%;
    width: 100%;
    min-height: 42px;
    max-height: 112px;
    padding: 9px 11px;
    border-radius: 12px;
    background: var(--surface-2);
  }
  .composer__box .send { order: 1; width: 40px; height: 40px; margin-left: auto; border-radius: 13px; }
  .composer__banner { margin-bottom: 6px; padding: 7px 10px; }
  .rec { bottom: calc(100% + 6px); }
  .rec__circle { width: 84px; height: 84px; }
  .rec__time { font-size: 17px; }
  .saved-msg__bubble { max-width: 100%; }
}
#btnMic { touch-action: none; -webkit-touch-callout: none; }

/* --------------------------- pinned message bar --------------------------- */
.chat__pinned {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 14px 6px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  animation: slideDown .2s ease both;
}
.chat__pinned[hidden] { display: none; }
.chat__pinned .ico { color: var(--accent); flex: none; }
.chat__pinned-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  text-align: left;
}
.chat__pinned-text b { font-size: 12.6px; font-weight: 700; color: var(--accent); }
.chat__pinned-text span {
  font-size: 12.8px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ----------------------------- forward header ----------------------------- */
.msg__forward {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 5px;
  padding-bottom: 5px;
  border-bottom: 1px dashed var(--border);
  font-size: 12.1px;
  color: var(--text-3);
  min-width: 0;
}
.msg__forward .ico { color: var(--accent); flex: none; }
.msg__forward b { font-weight: 600; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg__forward-from { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-3); }

/* ------------------------------- mentions -------------------------------- */
.mention {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-radius: 5px;
  padding: 0 3px;
  font-weight: 600;
}
.msg--me .mention { color: #fff; background: rgba(255, 255, 255, .22); }

/* --------------------------- mention autocomplete ------------------------- */
.mention-pop {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: calc(100% - 6px);
  max-width: 340px;
  padding: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2, var(--surface));
  box-shadow: var(--shadow-2);
  z-index: 40;
  animation: slideUp .16s ease both;
}
.mention-pop[hidden] { display: none; }
.mention-pop__title {
  padding: 4px 8px 6px;
  font-size: 11.2px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-3);
}
.mention-pop__item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.mention-pop__item:hover,
.mention-pop__item.is-active { background: var(--surface-3, rgba(127, 127, 127, .16)); }
.mention-pop__name { flex: 1; min-width: 0; font-size: 13.2px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mention-pop__nick { font-size: 12.2px; color: var(--text-3); }

/* ---------------------------- forward preview ----------------------------- */
.forward-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-strong);
  background: var(--surface);
  font-size: 12.8px;
  color: var(--text-2);
}
.forward-preview .ico { color: var(--accent); flex: none; }
.forward-preview span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------ attachments ------------------------------- */
.msg__image-wrap { margin: -10px -13px 6px; border-radius: var(--radius-bubble, 14px); overflow: hidden; }
.msg--me .msg__image-wrap { margin-right: -13px; }
.msg__image {
  display: block;
  max-width: min(340px, 62vw);
  max-height: 380px;
  object-fit: cover;
  cursor: zoom-in;
  background: var(--surface-3);
}
.msg--grouped .msg__image-wrap { margin-top: -4px; }

.msg__file {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 4px;
  padding: 9px 11px;
  min-width: 190px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  transition: background .15s;
}
.msg--me .msg__file { border-color: rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .12); }
.msg__file:hover { background: var(--surface-2); }
.msg__file-ico {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--grad);
  color: #fff;
}
.msg__file-ico .ico { width: 18px; height: 18px; }
.msg__file-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.msg__file-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg__file-size { font-size: 11.6px; opacity: .75; }
.msg__file > .ico:last-child { opacity: .6; flex: none; }

.msg__audio-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 4px;
  padding: 7px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.msg--me .msg__audio-wrap { border-color: rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .12); }
.msg__audio-wrap > .ico { color: var(--accent); flex: none; }
.msg__audio { height: 34px; max-width: 230px; }
.msg__audio-dur { font-size: 11.8px; opacity: .8; font-variant-numeric: tabular-nums; }

/* --------------------------------- lightbox ------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  gap: 12px;
  padding: 40px;
  background: rgba(4, 6, 14, .82);
  backdrop-filter: blur(14px);
  animation: fadeIn .16s ease both;
}
.lightbox__img {
  max-width: min(92vw, 1200px);
  max-height: 82vh;
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .55);
  cursor: zoom-out;
}
.lightbox__close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  cursor: pointer;
}
.lightbox__close:hover { background: rgba(255, 255, 255, .2); }
.lightbox__caption {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 16px;
  border-radius: 99px;
  background: rgba(10, 14, 26, .78);
  border: 1px solid rgba(255, 255, 255, .14);
  color: #e8ecff;
  font-size: 13px;
}
.lightbox__caption span { max-width: 40vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lightbox__open { color: #9db2ff; text-decoration: none; }
.lightbox__open:hover { text-decoration: underline; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ------------------------------- drop overlay ----------------------------- */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(7, 10, 22, .55);
  pointer-events: none;
}
.drop-overlay[hidden] { display: none; }
.drop-overlay__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 30px 46px;
  border-radius: 20px;
  border: 2px dashed rgba(158, 178, 255, .75);
  background: rgba(16, 22, 44, .85);
  color: #e8ecff;
  text-align: center;
}
.drop-overlay__card .ico { width: 34px; height: 34px; color: #9db2ff; }
.drop-overlay__card b { font-size: 16px; }
.drop-overlay__card span { font-size: 12.8px; opacity: .75; }

/* --------------------------------- voice ---------------------------------- */
.mic--recording {
  color: #ff5d73 !important;
  background: rgba(255, 93, 115, .14) !important;
  animation: pulseRing 1.4s infinite;
}

/* --------------------------------- calls ---------------------------------- */
.call-card {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 85;
  width: 300px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2, var(--surface));
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(18px);
  animation: slideUp .24s ease both;
}
.call-card--incoming {
  right: 50%;
  bottom: 50%;
  transform: translate(50%, 50%);
  width: 320px;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border-strong));
  animation: callIn .22s ease both;
}
.call-card__head { display: flex; align-items: center; gap: 13px; margin-bottom: 14px; }
.call-card__meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.call-card__name { font-size: 15.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-card__phase { font-size: 12.8px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.call-card--incoming .call-card__phase { color: var(--accent); font-weight: 600; }
.call-card__tools { display: flex; justify-content: center; gap: 14px; }
.call-btn {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  transition: transform .14s, filter .14s;
}
.call-btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.call-btn .ico { width: 20px; height: 20px; }
.call-btn--accept { background: linear-gradient(135deg, #22c58b, #14a06b); }
.call-btn--decline { background: linear-gradient(135deg, #ff5d73, #e0344f); }
.call-btn--ghost { background: var(--surface-3, rgba(127, 127, 127, .18)); color: var(--text); }
.call-btn--ghost.is-on { background: rgba(255, 93, 115, .18); color: #ff5d73; }
.call-card--incoming .call-btn { width: 52px; height: 52px; }
.call-card--incoming .call-btn .ico { width: 22px; height: 22px; }
@keyframes callIn {
  from { opacity: 0; transform: translate(50%, 50%) scale(.92); }
  to   { opacity: 1; transform: translate(50%, 50%) scale(1); }
}
.call-card--incoming .call-card__avatar { animation: pulseRing 1.8s infinite; }
