/* Nexus — компоненты: кнопки, инпуты, чипы, поповеры, тосты, строки списка, пузыри, композер, панели. */

/* ============ кнопки ============ */
.icon-btn{
  width:36px;height:36px;display:inline-grid;place-items:center;flex:none;position:relative;
  border-radius:var(--r-sm);color:var(--text-2);background:transparent;
  transition:background .15s ease-out,color .15s ease-out;
}
.icon-btn:hover{background:var(--surface-2);color:var(--text)}
.icon-btn.is-active,.icon-btn[aria-pressed="true"],.icon-btn[aria-expanded="true"]{color:var(--violet-600);background:var(--surface-2)}
.icon-btn--xs{width:30px;height:30px;border-radius:var(--r-sm)}
.icon-btn--danger:hover{color:var(--danger);background:var(--danger-soft)}

.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:8px;height:36px;padding:0 14px;
  border-radius:var(--r-md);font-weight:600;font-size:14px;white-space:nowrap;
  background:var(--surface-2);color:var(--text);transition:background .15s ease-out,filter .15s ease-out,box-shadow .15s ease-out;
}
.btn:hover{background:var(--border)}
.btn--primary{background:var(--grad-brand);color:var(--on-brand);box-shadow:var(--shadow-brand)}
.btn--primary:hover{background:var(--grad-brand);filter:brightness(1.06)}
.btn--soft{background:var(--surface-2);color:var(--violet-600)}
.btn--soft:hover{background:var(--border)}
.btn--ghost{background:transparent;color:var(--text-2)}
.btn--ghost:hover{background:var(--surface-2);color:var(--text)}
.btn--danger{background:var(--danger);color:var(--on-brand)}
.btn--danger:hover{background:var(--danger);filter:brightness(1.06)}
.btn--sm{height:30px;padding:0 11px;font-size:13px;border-radius:var(--r-sm);gap:6px}
.btn--lg{height:46px;font-size:15px;border-radius:var(--r-md)}
.btn--block{width:100%}
.link-btn{color:var(--violet-600);font-weight:500;border-radius:4px}
.link-btn:hover{text-decoration:underline;text-underline-offset:2px}

/* ============ поля ============ */
.input{
  width:100%;height:42px;padding:0 12px;border-radius:var(--r-md);border:1px solid var(--border);
  background:var(--surface);color:var(--text);transition:border-color .15s ease-out,box-shadow .15s ease-out;
}
.input::placeholder{color:var(--text-3)}
.input:focus{outline:none;border-color:var(--violet-500);box-shadow:var(--focus)}
.input--sm{height:34px;font-size:13px;border-radius:var(--r-sm)}
textarea.input{height:auto;padding:9px 12px;resize:vertical;line-height:1.45}
select.input{padding-right:8px;cursor:pointer}
.input.is-invalid{border-color:var(--danger);box-shadow:0 0 0 3px var(--danger-ring)}
.field{display:grid;gap:6px;font-size:13px;font-weight:500;color:var(--text-2)}
.field-error{color:var(--danger);font-size:13px;margin-top:-4px}
.input-wrap{position:relative;display:block}
.input-wrap .input{padding-right:44px}
.input-wrap__btn{position:absolute;right:4px;top:3px}

/* ============ чипы ============ */
.chip{
  height:32px;padding:0 12px;border-radius:var(--r-pill);border:1px solid var(--border);background:var(--surface);
  color:var(--text-2);font-weight:500;font-size:13px;display:inline-flex;align-items:center;gap:6px;
  transition:border-color .15s ease-out,background .15s ease-out,color .15s ease-out;
}
.chip:hover{border-color:var(--note-border);color:var(--text)}
.chip[aria-pressed="true"]{background:var(--grad-soft);border-color:var(--violet-500);color:var(--violet-600)}
.tag-chip{
  height:26px;padding:0 3px 0 10px;border-radius:var(--r-pill);background:var(--grad-soft);color:var(--violet-600);
  font-size:12px;font-weight:500;display:inline-flex;align-items:center;gap:2px;
}
.tag-chip button{width:20px;height:20px;border-radius:50%;display:grid;place-items:center;color:var(--violet-600)}
.tag-chip button:hover{background:var(--surface)}

/* ============ аватар ============ */
.avatar{
  --s:44px;width:var(--s);height:var(--s);border-radius:50%;flex:none;display:grid;place-items:center;
  color:var(--on-brand);font-weight:600;font-size:calc(var(--s) * .36);letter-spacing:.02em;user-select:none;background:var(--av-0);
}
.av-0{background:var(--av-0)}.av-1{background:var(--av-1)}.av-2{background:var(--av-2)}
.av-3{background:var(--av-3)}.av-4{background:var(--av-4)}.av-5{background:var(--av-5)}

/* ============ поповеры и меню ============ */
.popover{
  position:fixed;z-index:100;min-width:220px;max-width:min(360px,calc(100vw - 16px));max-height:calc(100vh - 16px);overflow:auto;
  background:var(--surface);border:1px solid var(--border);border-radius:var(--r-lg);box-shadow:var(--shadow-lg);padding:6px;
  animation:pop-in .16s ease-out;
}
@keyframes pop-in{from{opacity:0;transform:translateY(4px) scale(.985)}to{opacity:1;transform:none}}
.menu{display:flex;flex-direction:column;gap:1px}
.menu-item{
  display:flex;align-items:center;gap:10px;width:100%;padding:8px 10px;min-height:38px;border-radius:var(--r-sm);
  text-align:left;color:var(--text);font-size:14px;transition:background .12s ease-out;
}
.menu-item:hover,.menu-item.is-active,.menu-item:focus-visible{background:var(--surface-2)}
.menu-item > .ic{color:var(--text-2)}
.menu-item--danger,.menu-item--danger > .ic{color:var(--danger)}
.menu-item--danger:hover{background:var(--danger-soft)}
.menu-item__body{display:flex;flex-direction:column;min-width:0;flex:1}
.menu-item__label{font-weight:500}
.menu-item__hint{font-size:12px;color:var(--text-3);line-height:1.35}
.menu-item__check{margin-left:auto;color:var(--violet-600)}
.menu-item__chev{margin-left:auto;color:var(--text-3)}
.menu-item--person{padding:6px 10px}
.menu-sep{height:1px;background:var(--border);margin:6px 4px}
.menu--tools{width:300px;max-width:100%}
.pop-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:6px 8px 8px}
.pop-title{display:inline-flex;align-items:center;gap:6px;font-weight:600;font-size:14px;color:var(--text)}
.pop-title .ic{color:var(--violet-600)}
.pop-foot{display:flex;gap:8px;justify-content:flex-end;padding:10px 4px 4px;margin-top:6px;border-top:1px solid var(--border)}
.pop-search{position:relative;margin:0 4px 6px}
.pop-search .ic{position:absolute;left:10px;top:9px;color:var(--text-3)}
.pop-search__input{width:100%;height:34px;padding:0 10px 0 32px;border-radius:var(--r-sm);border:1px solid var(--border);background:var(--surface-2);font-size:13px}
.pop-search__input:focus{outline:none;border-color:var(--violet-500);background:var(--surface);box-shadow:var(--focus)}
.pop-custom{padding:8px 8px 4px;border-top:1px solid var(--border);margin-top:4px}
.pop-custom__label{display:block;font-size:12px;color:var(--text-2);font-weight:500;margin-bottom:6px}
.pop-custom__row{display:flex;gap:6px}
.pop-custom__row .input{flex:1;min-width:0}
.confirm{width:280px;max-width:100%;padding:8px 8px 2px}
.confirm__title{font-weight:600;font-size:15px}
.confirm__text{font-size:13px;color:var(--text-2);margin-top:4px}

/* switch */
.switch{width:34px;height:20px;border-radius:var(--r-pill);background:var(--border);position:relative;flex:none;transition:background .15s ease-out;margin-left:auto}
.switch::after{content:"";position:absolute;top:2px;left:2px;width:16px;height:16px;border-radius:50%;background:var(--surface);box-shadow:var(--shadow-sm);transition:transform .15s ease-out}
.switch.is-on{background:var(--violet-500)}
.switch.is-on::after{transform:translateX(14px)}

/* фильтры */
.filters-pop{width:360px}
.check-row span:last-child{white-space:nowrap}
.fgroup{padding:6px 8px 10px}
.fgroup__label{font-size:12px;font-weight:600;color:var(--text-3);text-transform:uppercase;letter-spacing:.05em;margin-bottom:8px}
.fgroup__chips{display:flex;flex-wrap:wrap;gap:6px}
.fgroup__list{display:grid;grid-template-columns:1fr 1fr;gap:2px 8px}
.check-row{display:flex;align-items:center;gap:8px;padding:5px 4px;border-radius:var(--r-sm);font-size:13px;cursor:pointer;color:var(--text)}
.check-row:hover{background:var(--surface-2)}
.check-row input{position:absolute;opacity:0;pointer-events:none}
.check-row__box{width:18px;height:18px;border-radius:5px;border:1.5px solid var(--note-border);display:grid;place-items:center;color:transparent;flex:none;background:var(--surface);transition:background .12s,border-color .12s}
.check-row input:checked + .check-row__box{background:var(--violet-500);border-color:var(--violet-500);color:var(--on-brand)}
.check-row input:focus-visible + .check-row__box{box-shadow:var(--focus)}

/* эмодзи-реакции */
.emoji-pop{min-width:0}
.emoji-grid{display:grid;grid-template-columns:repeat(6,36px);gap:2px}
.react-btn{width:32px;height:32px;border-radius:50%;font-size:18px;line-height:1;display:grid;place-items:center;transition:transform .12s ease-out,background .12s ease-out}
.emoji-grid .react-btn{width:36px;height:36px;font-size:20px}
.react-btn:hover{background:var(--surface-2);transform:scale(1.15)}

/* профиль */
.profile-pop{width:300px}
.profile-card{display:flex;align-items:center;gap:12px;padding:8px 8px 6px}
.profile-card__name{font-weight:600}
.profile-card__role{font-size:12px;color:var(--text-2)}

/* быстрые ответы */
.qr-pop{width:380px}
.qr__list{display:flex;flex-direction:column;gap:2px;max-height:260px;overflow:auto;padding:0 2px}
.qr__item{display:block;width:100%;text-align:left;padding:8px 10px;border-radius:var(--r-sm);font-size:13px;line-height:1.4;color:var(--text)}
button.qr__item:hover,.qr__item.is-active{background:var(--surface-2)}
.qr__item--edit{display:flex;align-items:flex-start;gap:4px}
.qr__text{flex:1;min-width:0;padding-top:5px}
.qr__empty{padding:16px 10px;text-align:center;color:var(--text-2);font-size:13px}
.qr__foot{border-top:1px solid var(--border);margin-top:6px;padding-top:4px}
.qr__editor{padding:6px 4px}
.qr__editor textarea{font-size:13px;min-height:72px}
.qr__editor-actions{display:flex;justify-content:flex-end;gap:6px;margin-top:6px}
.timer-pop{width:300px}

/* ============ тосты ============ */
.toasts{position:fixed;right:20px;bottom:20px;z-index:200;display:flex;flex-direction:column;gap:10px;width:min(360px,calc(100vw - 32px));pointer-events:none}
.toast{
  pointer-events:auto;display:flex;gap:12px;align-items:flex-start;padding:12px 8px 12px 14px;
  background:var(--surface);border:1px solid var(--border);border-radius:var(--r-lg);box-shadow:var(--shadow-lg);
  animation:toast-in .2s ease-out;
}
.toast.is-clickable{cursor:pointer}
.toast.is-clickable:hover{border-color:var(--note-border)}
.toast.is-leaving{animation:toast-out .18s ease-in forwards}
.toast--alert{border-color:var(--note-border)}
@keyframes toast-in{from{opacity:0;transform:translateX(28px)}to{opacity:1;transform:none}}
@keyframes toast-out{to{opacity:0;transform:translateX(28px)}}
.toast__icon{width:36px;height:36px;border-radius:50%;display:grid;place-items:center;background:var(--grad-soft);color:var(--violet-600);flex:none}
.toast__body{flex:1;min-width:0;padding-top:1px}
.toast__title{font-weight:600;font-size:14px;line-height:1.35}
.toast__text{font-size:13px;color:var(--text-2);display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.toast__action{margin-top:8px}
.toast__close{width:28px;height:28px;margin-top:-2px}

/* ============ topbar ============ */
.seg{display:inline-flex;padding:3px;background:var(--surface-2);border-radius:var(--r-pill);gap:2px;flex:none}
.seg__btn{height:30px;padding:0 16px;border-radius:var(--r-pill);font-weight:500;font-size:13px;color:var(--text-2);transition:background .15s,color .15s}
.seg__btn:hover{color:var(--text)}
.seg__btn[aria-selected="true"]{background:var(--surface);color:var(--violet-600);box-shadow:var(--shadow-sm);font-weight:600}
.profile-btn{display:flex;align-items:center;gap:10px;padding:4px 8px 4px 4px;border-radius:var(--r-pill);text-align:left;min-width:0;transition:background .15s}
.profile-btn:hover,.profile-btn[aria-expanded="true"]{background:var(--surface-2)}
.profile-btn__text{display:flex;flex-direction:column;min-width:0}
.profile-btn__name{font-weight:600;font-size:13px;line-height:1.25;white-space:nowrap}
.profile-btn__role{font-size:12px;color:var(--text-2);line-height:1.25;white-space:nowrap}
.profile-btn__chev{color:var(--text-3)}

/* ============ rail ============ */
.rail__btn{width:44px;height:44px;border-radius:var(--r-md);display:grid;place-items:center;color:var(--text-2);position:relative;transition:background .15s,color .15s}
.rail__btn:hover{background:var(--surface-2);color:var(--text)}
.rail__btn[aria-current="page"]{background:var(--grad-brand);color:var(--on-brand);box-shadow:var(--shadow-brand)}
.rail__label{display:none}
.rail__badge{position:absolute;top:2px;right:0;min-width:18px;height:18px;padding:0 5px;border-radius:var(--r-pill);background:var(--surface);color:var(--violet-600);border:1.5px solid var(--violet-500);font-size:10px;font-weight:700;display:grid;place-items:center;line-height:1}

/* ============ левая колонка ============ */
.side-head{padding:12px 12px 8px;display:flex;flex-direction:column;gap:10px;position:relative;flex:none}
.side-title{display:flex;flex-direction:column;padding:4px 4px 0;font-weight:700;font-size:18px}
.side-title__sub{font-size:12px;font-weight:500;color:var(--text-2)}
.search{position:relative}
.search__input{
  width:100%;height:44px;padding:0 40px 0 42px;border-radius:var(--r-md);background:var(--surface-2);border:1px solid transparent;
  color:var(--text);font-size:14px;transition:background .15s,border-color .15s,box-shadow .15s;
}
.search__input::placeholder{color:var(--text-3)}
.search__input:focus{outline:none;background:var(--surface);border-color:var(--violet-500);box-shadow:var(--focus)}
.search__ic{position:absolute;left:12px;top:12px;color:var(--text-3);pointer-events:none}
.search__kbd{position:absolute;right:10px;top:12px;font-size:11px;line-height:18px;color:var(--text-3);border:1px solid var(--border);border-radius:6px;padding:0 6px;background:var(--surface);pointer-events:none}
.search__clear{position:absolute;right:4px;top:4px}
.suggest{
  position:absolute;left:0;right:0;top:calc(100% + 6px);z-index:50;background:var(--surface);border:1px solid var(--border);
  border-radius:var(--r-lg);box-shadow:var(--shadow-lg);max-height:min(480px,62vh);overflow:auto;padding:6px;animation:pop-in .15s ease-out;
}
.suggest__group + .suggest__group{border-top:1px solid var(--border);margin-top:4px;padding-top:4px}
.suggest__group-title{padding:8px 10px 4px;font-size:11px;font-weight:600;color:var(--text-3);text-transform:uppercase;letter-spacing:.06em}
.suggest__item{display:flex;gap:10px;align-items:center;padding:7px 10px;border-radius:var(--r-sm);cursor:pointer}
.suggest__item:hover,.suggest__item[aria-selected="true"]{background:var(--surface-2)}
.suggest__ic{width:32px;height:32px;border-radius:50%;background:var(--surface-2);display:grid;place-items:center;color:var(--text-2);flex:none}
.suggest__item[aria-selected="true"] .suggest__ic,.suggest__item:hover .suggest__ic{background:var(--surface)}
.suggest__main{min-width:0;flex:1;display:flex;flex-direction:column}
.suggest__title{display:block;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}
.suggest__date{float:right;margin-left:8px;font-size:12px;font-weight:400;color:var(--text-3)}
.suggest__sub{font-size:12px;color:var(--text-2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.suggest__empty{display:flex;flex-direction:column;align-items:center;gap:4px;padding:18px 16px 20px;text-align:center;color:var(--text);font-weight:600}
.suggest__empty-sub{font-size:12px;font-weight:400;color:var(--text-2);max-width:240px}

.side-tools{display:flex;gap:8px;align-items:center}
.awaiting-pill{
  display:inline-flex;align-items:center;gap:7px;height:36px;padding:0 12px 0 10px;border-radius:var(--r-pill);
  background:var(--surface-2);color:var(--text-2);font-size:13px;flex:1;min-width:0;border:1px solid transparent;transition:background .15s,border-color .15s,color .15s;
}
.awaiting-pill:hover{border-color:var(--border)}
.awaiting-pill b{color:var(--text);font-weight:700;font-size:14px}
.awaiting-pill__label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.awaiting-pill[aria-pressed="true"]{background:var(--grad-soft);border-color:var(--violet-500);color:var(--violet-600)}
.awaiting-pill[aria-pressed="true"] b{color:var(--violet-600)}
.awaiting-pill__overdue{margin-left:auto;display:inline-flex;align-items:center;gap:5px;color:var(--danger);font-weight:500;white-space:nowrap;font-size:12px}
.dot{width:7px;height:7px;border-radius:50%;background:var(--danger);flex:none}
.filters-btn{
  display:inline-grid;place-items:center;width:40px;height:36px;border-radius:var(--r-pill);background:var(--surface-2);position:relative;
  color:var(--text-2);border:1px solid transparent;flex:none;transition:background .15s,border-color .15s,color .15s;
}
.filters-btn .filters-btn__count{position:absolute;top:-5px;right:-5px;box-shadow:0 0 0 2px var(--surface)}
.filters-btn:hover{border-color:var(--border);color:var(--text)}
.filters-btn.is-active,.filters-btn[aria-expanded="true"]{color:var(--violet-600);background:var(--grad-soft);border-color:var(--violet-500)}
.filters-btn__count{min-width:18px;height:18px;border-radius:var(--r-pill);background:var(--grad-brand);color:var(--on-brand);font-size:11px;font-weight:700;padding:0 5px;display:grid;place-items:center}
.filter-chips{display:flex;flex-wrap:wrap;gap:6px}

.chat-list{flex:1;overflow-y:auto;padding:0 8px 12px;min-height:0}
.list-label{display:flex;align-items:center;gap:6px;padding:12px 10px 6px;font-size:11px;font-weight:600;color:var(--text-3);text-transform:uppercase;letter-spacing:.06em}
.chat-row{display:flex;align-items:center;gap:12px;height:72px;padding:0 10px;border-radius:var(--r-md);cursor:pointer;position:relative;transition:background .12s ease-out}
.chat-row:hover{background:var(--row-hover-bg)}
.chat-row.is-active{background:var(--row-active-bg)}
.chat-row:focus-visible{box-shadow:var(--focus)}
.chat-row.is-closed .chat-row__name{color:var(--text-2)}
.chat-row__body{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}
.chat-row__top,.chat-row__bottom{display:flex;align-items:center;gap:8px;min-width:0}
.chat-row__name{flex:1;min-width:0;font-weight:600;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-row__time{font-size:12px;color:var(--text-3);display:inline-flex;align-items:center;gap:4px;flex:none}
.chat-row__time.is-unread{color:var(--violet-600);font-weight:500}
.chat-row__timer{display:inline-flex;color:var(--text-2)}
.chat-row__timer.is-overdue{color:var(--danger)}
.chat-row__preview{flex:1;min-width:0;font-size:13px;color:var(--text-2);display:flex;align-items:center;gap:4px}
.chat-row__preview .txt{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-row__preview.is-typing{color:var(--violet-600);font-weight:500}
.chat-row__type{color:var(--text-3)}
.chat-row__badges{display:flex;align-items:center;gap:6px;flex:none}
.chat-row__pin{color:var(--text-3)}
.unread-badge{min-width:20px;height:20px;padding:0 6px;border-radius:var(--r-pill);background:var(--grad-brand);color:var(--on-brand);font-size:11px;font-weight:700;display:grid;place-items:center}
.chat-row__more{position:absolute;right:8px;top:50%;transform:translateY(-50%);width:30px;height:30px;opacity:0;background:var(--surface);box-shadow:var(--shadow-md)}
.chat-row:hover .chat-row__more,.chat-row:focus-within .chat-row__more,.chat-row__more[aria-expanded="true"]{opacity:1}
.chat-row:hover .chat-row__badges,.chat-row:focus-within .chat-row__badges{visibility:hidden}
@media (hover:none){.chat-row__more{display:none}.chat-row:hover .chat-row__badges{visibility:visible}}
.ticks{display:inline-flex;color:var(--text-3);flex:none}
.ticks.is-read{color:var(--blue-500)}

.empty-state{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:10px;padding:32px 24px;color:var(--text-2);margin:auto;max-width:360px}
.empty-state h3{color:var(--text)}
.empty-state p{font-size:13px}
.empty-state--list{margin:24px auto}

/* ============ шапка чата ============ */
.chat-head{display:flex;align-items:center;gap:12px;height:64px;padding:0 12px 0 16px;background:var(--surface);border-bottom:1px solid var(--border);flex:none;min-width:0}
.chat-head__back{display:none;margin-left:-8px}
.chat-head__avatar{border-radius:50%;flex:none}
.chat-head__text{min-width:0;flex:1;display:flex;flex-direction:column;align-items:flex-start}
.chat-head__name,.chat-head__title{font-weight:600;font-size:16px;color:var(--text);max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:left;line-height:1.3;border-radius:4px}
.chat-head__name:hover{color:var(--violet-600)}
.chat-head__meta{font-size:12px;color:var(--text-2);display:flex;align-items:center;gap:5px;min-width:0;max-width:100%;white-space:nowrap}
.chat-head__meta-text{overflow:hidden;text-overflow:ellipsis;min-width:0}
.chat-head__phone{color:var(--text-2);font-weight:400;flex:none}
.chat-head__phone:hover{color:var(--violet-600)}
.chat-head__meta.is-typing{color:var(--violet-600);font-weight:500}
.chat-head__actions{display:flex;gap:2px;flex:none}
.typing-dots{display:inline-flex;gap:3px;margin-right:2px}
.typing-dots i{width:5px;height:5px;border-radius:50%;background:var(--violet-500);animation:typing 1s infinite ease-in-out}
.typing-dots i:nth-child(2){animation-delay:.15s}.typing-dots i:nth-child(3){animation-delay:.3s}
@keyframes typing{0%,80%,100%{opacity:.3;transform:translateY(0)}40%{opacity:1;transform:translateY(-2px)}}
.notes-head__ic{width:40px;height:40px;border-radius:50%;background:var(--grad-brand);color:var(--on-brand);display:grid;place-items:center;flex:none}

/* ============ лента ============ */
.feed-wrap{position:relative;flex:1;min-height:0;display:flex}
.feed{flex:1;overflow-y:auto;overflow-x:hidden}
.feed__inner{max-width:880px;margin:0 auto;padding:44px 24px 16px;display:flex;flex-direction:column}
.date-sep{align-self:center;position:sticky;top:8px;z-index:3;margin:12px 0 8px}
.date-sep span{display:block;padding:4px 12px;border-radius:var(--r-pill);background:var(--surface);color:var(--text-2);font-size:12px;font-weight:500;box-shadow:var(--shadow-sm);border:1px solid var(--border)}
.date-sep--sched span{background:var(--grad-soft);color:var(--violet-600);border-color:var(--note-border)}
.sys-pill{align-self:center;max-width:86%;margin:8px 0;padding:5px 12px;border-radius:var(--r-pill);background:var(--sys-bg);color:var(--text-2);font-size:12px;text-align:center;line-height:1.4}
.sys-pill__time{margin-left:6px;color:var(--text-3)}

.msg{display:flex;flex-direction:column;max-width:min(560px,78%);position:relative;margin:3px 0;border-radius:var(--r-lg)}
.msg--in{align-self:flex-start;align-items:flex-start}
.msg--out{align-self:flex-end;align-items:flex-end}
.msg--note{align-self:flex-end;align-items:flex-end;max-width:min(560px,70%)}
.bubble{
  padding:8px 12px 5px;border-radius:var(--r-lg);background:var(--surface);color:var(--text);box-shadow:var(--shadow-sm);
  position:relative;overflow-wrap:anywhere;line-height:1.45;max-width:100%;border:1px solid var(--border);
}
.msg--in .bubble{border-bottom-left-radius:6px}
.msg--out .bubble{background:var(--grad-brand);color:var(--on-brand);border-color:transparent;border-bottom-right-radius:6px}
.bubble__text{white-space:pre-wrap}
.bubble__meta{display:flex;align-items:center;justify-content:flex-end;gap:4px;font-size:11px;color:var(--text-3);margin-top:2px;white-space:nowrap}
.bubble__author{max-width:180px;overflow:hidden;text-overflow:ellipsis}
.msg--out .bubble__meta,.msg--out .ticks{color:var(--on-brand-muted)}
.msg--out .ticks.is-read{color:var(--read-tick)}
.bubble--media{padding:4px}
.bubble--media .bubble__text{padding:6px 8px 0}
.bubble--media .bubble__meta{padding:0 8px 3px}
.bubble--sticker{background:transparent;box-shadow:none;border-color:transparent;padding:0}
.bubble--sticker .bubble__meta{background:var(--surface);color:var(--text-2);padding:1px 8px;border-radius:var(--r-pill);width:max-content;margin:2px 0 0 auto}
.bubble--file{padding:6px 10px 5px}
.msg__img{display:block;width:300px;max-width:100%;height:auto;border-radius:12px}
.msg__img--empty{height:160px;display:grid;place-items:center;align-content:center;gap:4px;background:var(--surface-2);color:var(--text-3);font-size:12px}
.msg__sticker{width:140px;height:140px}
.file-card{display:flex;align-items:center;gap:10px;min-width:220px;max-width:100%;padding:4px 2px;text-align:left;color:inherit;border-radius:var(--r-sm)}
.file-card__ic{width:42px;height:42px;border-radius:10px;background:var(--surface-2);color:var(--violet-600);display:grid;place-items:center;flex:none}
.msg--out .file-card__ic{background:var(--on-brand-soft);color:var(--on-brand)}
.file-card__info{display:flex;flex-direction:column;min-width:0}
.file-card__name{font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:240px}
.file-card__size{font-size:12px;opacity:.75}
.voice{display:flex;align-items:center;gap:10px;min-width:230px;padding:4px 2px 2px}
.voice__btn{width:38px;height:38px;border-radius:50%;background:var(--grad-brand);color:var(--on-brand);display:grid;place-items:center;flex:none}
.msg--out .voice__btn{background:var(--surface);color:var(--violet-600)}
.voice__track{flex:1;height:4px;border-radius:var(--r-pill);background:var(--border);overflow:hidden}
.voice__fill{height:100%;width:0;background:var(--violet-500);border-radius:inherit}
.msg--out .voice__track{background:var(--on-brand-soft)}
.msg--out .voice__fill{background:var(--on-brand)}
.voice__time{font-size:12px;color:var(--text-2);min-width:34px;font-variant-numeric:tabular-nums}
.msg--out .voice__time{color:var(--on-brand-muted)}
.quote{display:flex;flex-direction:column;align-items:flex-start;width:100%;text-align:left;border-left:3px solid var(--violet-500);background:var(--surface-2);border-radius:8px;padding:4px 8px;margin:2px 0 6px;font-size:13px}
.msg--out .quote{background:var(--on-brand-soft);border-color:var(--on-brand);color:var(--on-brand)}
.quote__name{font-weight:600;font-size:12px;color:var(--violet-600)}
.msg--out .quote__name{color:var(--on-brand)}
.quote__text{max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;opacity:.9}

.note-bubble{background:var(--note-bg);border:1px dashed var(--note-border);border-radius:var(--r-lg);padding:8px 12px 6px;color:var(--text);overflow-wrap:anywhere;line-height:1.45}
.note-bubble__meta{display:flex;align-items:center;gap:5px;font-size:11px;color:var(--violet-600);margin-top:4px;font-weight:500}

.reactions{display:flex;gap:4px;margin-top:-6px;padding:0 8px;position:relative;z-index:1;flex-wrap:wrap}
.reaction{height:24px;padding:0 7px;border-radius:var(--r-pill);background:var(--surface);border:1px solid var(--border);font-size:13px;display:inline-flex;align-items:center;gap:3px;box-shadow:var(--shadow-sm);transition:transform .12s}
.reaction:hover{transform:scale(1.06)}
.reaction.is-mine{border-color:var(--violet-500);background:var(--grad-soft)}
.reaction__n{font-size:11px;color:var(--text-2);font-weight:600}

.msg__tools{
  position:absolute;top:-38px;display:none;align-items:center;gap:1px;padding:3px;z-index:6;
  background:var(--surface);border:1px solid var(--border);border-radius:var(--r-pill);box-shadow:var(--shadow-md);white-space:nowrap;
}
.msg--in .msg__tools{left:0}
.msg--out .msg__tools,.msg--note .msg__tools{right:0}
.msg:hover .msg__tools,.msg:focus-within .msg__tools{display:flex}
.msg__tools::after{content:"";position:absolute;left:0;right:0;top:100%;height:8px}
.msg__tools .icon-btn{border-radius:50%}
.msg__tools-sep{width:1px;height:20px;background:var(--border);margin:0 2px}
@media (hover:none){.msg:hover .msg__tools{display:none}}

.msg--scheduled .bubble{opacity:.6}
.sched-meta{display:flex;align-items:center;flex-wrap:wrap;justify-content:flex-end;gap:5px;font-size:12px;color:var(--text-2);margin-top:5px}
.sched-meta .ic{color:var(--violet-600)}
.msg.is-highlight .bubble,.msg.is-highlight .note-bubble,.note-card.is-highlight{animation:flash 2s ease-out}
@keyframes flash{0%,55%{box-shadow:0 0 0 4px var(--highlight)}100%{box-shadow:var(--shadow-sm)}}

.to-bottom{position:absolute;right:24px;bottom:16px;width:44px;height:44px;border-radius:50%;background:var(--surface);border:1px solid var(--border);box-shadow:var(--shadow-md);color:var(--text-2);display:grid;place-items:center;z-index:8}
.to-bottom:hover{color:var(--violet-600)}
.to-bottom__count{position:absolute;top:-6px;right:-4px;min-width:20px;height:20px;padding:0 5px;border-radius:var(--r-pill);background:var(--grad-brand);color:var(--on-brand);font-size:11px;font-weight:700;display:grid;place-items:center}
.drop-overlay{position:absolute;inset:10px;border:2px dashed var(--violet-500);border-radius:var(--r-xl);background:var(--drop-bg);display:none;place-items:center;align-content:center;gap:8px;z-index:20;color:var(--violet-600);font-weight:600;font-size:16px;pointer-events:none}
.main__view.is-dragging .drop-overlay{display:grid}

/* ============ композер ============ */
.composer-slot{flex:none}
.composer{flex:none;background:var(--surface);border-top:1px solid var(--border);padding:10px 16px 12px}
.composer__inner{max-width:880px;margin:0 auto;display:flex;flex-direction:column;gap:8px}
.composer__bars{display:flex;flex-direction:column;gap:6px}
.composer__bars:empty{display:none}
.composer-bar{display:flex;align-items:center;gap:8px;min-height:34px;padding:4px 6px 4px 10px;border-radius:var(--r-md);background:var(--surface-2);font-size:13px;color:var(--text-2)}
.composer-bar > .ic{color:var(--violet-600)}
.composer-bar.is-overdue{background:var(--danger-soft);color:var(--danger)}
.composer-bar.is-overdue > .ic,.composer-bar.is-overdue .link-btn{color:var(--danger)}
.composer-bar--note{background:var(--note-bg);color:var(--violet-600)}
.composer-bar--reply{border-left:3px solid var(--violet-500)}
.composer-bar__text{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.composer-bar__text b{color:var(--violet-600);font-weight:600;margin-right:4px}
.composer-bar .link-btn{padding:0 6px}
.attach-strip{display:flex;gap:8px;overflow-x:auto;padding:2px 0}
.attach-item{position:relative;flex:none;width:64px;height:64px;border-radius:var(--r-md);overflow:hidden;background:var(--surface-2);border:1px solid var(--border);display:grid;place-items:center;color:var(--violet-600)}
.attach-item img{width:100%;height:100%;object-fit:cover}
.attach-item__name{position:absolute;bottom:0;left:0;right:0;font-size:10px;padding:2px 4px;background:var(--surface);color:var(--text-2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.attach-item__x{position:absolute;top:3px;right:3px;width:20px;height:20px;border-radius:50%;background:var(--surface);box-shadow:var(--shadow-sm);display:grid;place-items:center;color:var(--text-2)}
.attach-item__x:hover{color:var(--danger)}
.composer__row{display:flex;align-items:flex-end;gap:8px}
.tools-btn{width:44px;height:44px;border-radius:50%;background:var(--surface-2);color:var(--text-2);display:grid;place-items:center;flex:none;transition:background .15s,color .15s}
.tools-btn:hover,.tools-btn[aria-expanded="true"]{color:var(--violet-600);background:var(--border)}
.composer__field{flex:1;min-width:0;display:flex;align-items:flex-start;gap:8px;background:var(--surface-2);border:1px solid transparent;border-radius:22px;padding:0 16px;transition:background .15s,border-color .15s,box-shadow .15s}
.composer__field:focus-within{background:var(--surface);border-color:var(--violet-500);box-shadow:var(--focus)}
.composer__field textarea{flex:1;min-width:0;border:0;background:transparent;resize:none;padding:11px 0;line-height:20px;height:42px;max-height:142px;font-size:14px;color:var(--text);outline:none;overflow-y:hidden;box-shadow:none}
.composer__field textarea::placeholder{color:var(--text-3)}
.composer__lock{display:none;color:var(--violet-600);margin-top:12px}
.composer.is-note .composer__field{background:var(--note-bg);border:1px dashed var(--note-border)}
.composer.is-note .composer__field:focus-within{border-style:dashed;border-color:var(--violet-500)}
.composer.is-note .composer__lock{display:block}
.send-split{display:flex;height:44px;border-radius:22px;background:var(--grad-brand);box-shadow:var(--shadow-brand);overflow:hidden;flex:none}
.send-btn{display:flex;align-items:center;gap:8px;padding:0 14px 0 16px;color:var(--on-brand);font-weight:600;height:100%;transition:background .15s;user-select:none;-webkit-touch-callout:none}
.send-split--single .send-btn{padding:0 18px}
.send-chev{width:34px;display:grid;place-items:center;color:var(--on-brand);border-left:1px solid var(--on-brand-soft);height:100%;transition:background .15s}
.send-btn:hover,.send-chev:hover,.send-chev[aria-expanded="true"]{background:var(--on-brand-hover)}
.send-btn:focus-visible,.send-chev:focus-visible{box-shadow:inset 0 0 0 2px var(--on-brand)}
.closed-bar{display:flex;align-items:center;justify-content:center;gap:12px;padding:14px 16px;background:var(--surface);border-top:1px solid var(--border);color:var(--text-2);font-size:14px;font-weight:500}
.closed-bar > .ic{color:var(--text-3)}

/* ============ панель контакта ============ */
.cp-head{height:64px;display:flex;align-items:center;justify-content:space-between;padding:0 10px 0 18px;border-bottom:1px solid var(--border);flex:none}
.cp-head__title{font-weight:600;font-size:15px}
.cp-body{flex:1;overflow-y:auto;padding:20px 18px 24px}
.cp-hero{display:flex;flex-direction:column;align-items:center;text-align:center;gap:6px;padding-bottom:16px}
.cp-hero .avatar{margin-bottom:4px}
.cp-hero__name{font-weight:600;font-size:16px;line-height:1.3}
.cp-hero__phone{display:inline-flex;align-items:center;gap:6px;color:var(--text-2);font-weight:500}
.cp-hero__phone:hover{color:var(--violet-600)}
.cp-badge{display:inline-flex;align-items:center;gap:5px;margin-top:4px;padding:3px 10px;border-radius:var(--r-pill);background:var(--grad-soft);color:var(--violet-600);font-size:12px;font-weight:500}
.cp-section{padding:14px 0 6px;border-top:1px solid var(--border)}
.cp-section__head{display:flex;align-items:center;justify-content:space-between;min-height:30px;margin-bottom:6px}
.cp-section__title{font-size:11px;font-weight:600;color:var(--text-3);text-transform:uppercase;letter-spacing:.06em}
.kv{display:grid;grid-template-columns:auto 1fr;gap:8px 12px;font-size:13px;margin:0 0 8px}
.kv dt{color:var(--text-2)}
.kv dd{margin:0;text-align:right;font-weight:500;overflow-wrap:anywhere}
.source-pill{white-space:nowrap;display:inline-flex;align-items:center;gap:4px;padding:1px 8px;border-radius:var(--r-pill);background:var(--surface-2);color:var(--text)}
.source-pill .ic{color:var(--violet-600)}
.cp-form{display:grid;gap:10px;margin-bottom:10px}
.cp-form__actions{display:flex;justify-content:flex-end;gap:6px;margin-top:2px}
.cp-owner{display:flex;align-items:center;gap:10px;margin-bottom:10px}
.cp-owner__name{flex:1;min-width:0;font-weight:500;font-size:13px}
.cp-note{background:var(--note-bg);border:1px dashed var(--note-border);border-radius:var(--r-md);padding:8px 10px;font-size:13px;margin-bottom:8px}
.cp-note__meta{display:flex;align-items:center;gap:4px;font-size:11px;color:var(--violet-600);margin-top:4px}
.cp-muted{font-size:13px;color:var(--text-2);margin-bottom:10px}

/* ============ заметки ============ */
.notes-list{flex:1;overflow-y:auto;padding:0 8px 12px;min-height:0}
.note-row{display:flex;gap:10px;padding:10px;border-radius:var(--r-md);cursor:pointer;transition:background .12s}
.note-row:hover,.note-row.is-active{background:var(--surface-2)}
.note-row:focus-visible{box-shadow:var(--focus)}
.note-row__ic{width:38px;height:38px;border-radius:12px;background:var(--grad-soft);color:var(--violet-600);display:grid;place-items:center;flex:none}
.note-row__body{min-width:0;flex:1;display:flex;flex-direction:column;gap:2px}
.note-row__top{display:flex;gap:8px;align-items:baseline}
.note-row__title{flex:1;min-width:0;font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.note-row__date{font-size:12px;color:var(--text-3);flex:none}
.note-row__text{font-size:13px;color:var(--text-2);display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.note-card{align-self:flex-end;width:min(560px,88%);background:var(--surface);border:1px solid var(--border);border-radius:var(--r-lg);box-shadow:var(--shadow-sm);padding:10px 12px 8px;margin:4px 0}
.note-card.is-active{border-color:var(--note-border)}
.note-card__src{display:flex;align-items:center;flex-wrap:wrap;gap:6px;font-size:12px;color:var(--violet-600);margin-bottom:6px}
.note-card__src b{font-weight:600}
.note-card__src span{color:var(--text-2)}
.note-card__src--own{color:var(--text-2)}
.note-card__text{white-space:pre-wrap;overflow-wrap:anywhere}
.note-card__img{width:280px;max-width:100%;height:auto;border-radius:12px;margin-bottom:6px}
.note-card__sticker{width:96px;height:96px}
.note-card__file{display:flex;align-items:center;gap:8px;padding:8px 10px;border-radius:var(--r-md);background:var(--surface-2);font-size:13px;margin-bottom:6px;color:var(--text)}
.note-card__file .ic{color:var(--violet-600)}
.note-card__foot{display:flex;align-items:center;gap:8px;margin-top:8px}
.note-card__date{font-size:11px;color:var(--text-3);margin-right:auto}

/* ============ вход ============ */
body.login-page{min-height:100vh;display:grid;place-items:center;background:var(--grad-app);padding:24px 16px}
.login{width:100%;display:grid;place-items:center}
.login-card{width:min(420px,100%);background:var(--surface);border:1px solid var(--border);border-radius:var(--r-xl);box-shadow:var(--shadow-lg);padding:32px 28px 24px}
.login-card__brand{display:flex;flex-direction:column;align-items:center;text-align:center;gap:4px;margin-bottom:24px}
.login-card__logo{margin-bottom:10px;filter:var(--logo-glow)}
.login-card__sub{color:var(--text-2);font-size:14px}
.login-form{display:grid;gap:14px}
.login-form .btn--primary{margin-top:4px}
.demo-access{margin-top:24px}
.demo-access__title{display:flex;align-items:center;gap:12px;color:var(--text-3);font-size:12px;font-weight:600;text-transform:uppercase;letter-spacing:.06em;margin-bottom:12px}
.demo-access__title::before,.demo-access__title::after{content:"";flex:1;height:1px;background:var(--border)}
.demo-access__list{display:grid;gap:8px}
.demo-card{display:flex;align-items:center;gap:12px;width:100%;padding:10px 12px;border-radius:var(--r-md);border:1px solid var(--border);background:var(--surface);text-align:left;transition:border-color .15s,background .15s,box-shadow .15s}
.demo-card:hover{border-color:var(--violet-500);background:var(--surface-2)}
.demo-card__body{flex:1;min-width:0;display:flex;flex-direction:column}
.demo-card__role{font-weight:600}
.demo-card__name{font-size:12px;color:var(--text-2)}
.demo-card__arrow{color:var(--text-3)}
.demo-card:hover .demo-card__arrow{color:var(--violet-600)}
.demo-access__hint{text-align:center;font-size:12px;color:var(--text-3);margin-top:10px}

/* ============ адаптив компонентов ============ */
@media (max-width:1279px){
  .profile-btn__role{display:none}
}
@media (max-width:1079px){
  .awaiting-pill > .ic,.search__kbd{display:none}
}
@media (max-width:899px){
  .brand__name{display:none}
  .profile-btn__text,.profile-btn__chev{display:none}
  .profile-btn{padding:2px}
  .seg__btn{padding:0 12px}
  .rail__btn{width:auto;flex:1;max-width:160px;height:48px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;border-radius:var(--r-md)}
  .rail__label{display:block;font-size:11px;font-weight:600}
  .rail__btn[aria-current="page"]{background:var(--grad-soft);color:var(--violet-600);box-shadow:none}
  .rail__badge{right:calc(50% - 26px)}
  .chat-head{padding:0 8px;gap:8px}
  .chat-head__back{display:inline-grid}
  .chat-head__phone,.chat-head__dot{display:none}
  .chat-head__meta.is-typing .typing-dots{display:inline-flex}
  .feed__inner{padding:40px 12px 12px}
  .msg{max-width:88%}
  .msg--note{max-width:88%}
  .composer{padding:8px 8px calc(8px + env(safe-area-inset-bottom,0px))}
  .composer__row{gap:6px}
  .send-btn__label{display:none}
  .send-btn{padding:0 12px}
  .send-split--single .send-btn{padding:0 14px}
  .tools-btn{width:42px;height:42px}
  .to-bottom{right:14px}
  .toasts{right:12px;left:12px;bottom:12px;width:auto}
  .app:not(.mobile-chat) ~ .toasts{bottom:76px}
  .note-card{width:100%}
  [data-tip]::after{display:none}
}
@media (max-width:420px){
  .seg__btn{padding:0 10px;font-size:12px}
  .voice{min-width:180px}
  .file-card{min-width:0}
  .file-card__name{max-width:160px}
}
