/* =========================================================
   MatchMate — чаты, как в Telegram. Заменяет chat-v2.css.
   Телефон: список и диалог во весь экран, страница не
   прокручивается, высота берётся из visualViewport, поэтому
   клавиатура поднимает только поле ввода.
   ПК: две колонки, список слева, переписка справа.
   ========================================================= */
html body.chat-body{
  --t-bg:#0b121d;
  --t-panel:#111a26;
  --t-hover:rgba(255,255,255,.045);
  --t-active:rgba(72,160,255,.16);
  --t-line:rgba(255,255,255,.07);
  --t-text:#e9eef6;
  --t-dim:#8595ab;
  --t-accent:#4fb6ff;
  --t-own:linear-gradient(135deg,#2f7fe0 0%,#5b63f0 100%);
  --t-their:#1b2533;
  --t-chat-bg:
    radial-gradient(120% 60% at 100% 0%, rgba(90,110,255,.08), transparent 60%),
    radial-gradient(90% 50% at 0% 100%, rgba(63,215,245,.06), transparent 60%),
    #0d1520;
}

/* ---------------------------------------------------------- общая база */
html body.chat-body .chat-shell{
  display:grid !important;
  grid-template-columns:minmax(0,360px) minmax(0,1fr) !important;
  gap:0 !important;
  width:min(1280px,calc(100% - 40px)) !important;
  height:calc(100dvh - 150px) !important;
  min-height:460px !important;
  margin:18px auto !important;padding:0 !important;
  overflow:hidden !important;
  border-radius:18px !important;
  border:1px solid var(--t-line) !important;
  background:var(--t-panel) !important;
  box-shadow:0 24px 60px rgba(0,0,0,.35) !important;
}

/* ------------------------------------------------------- список чатов */
html body.chat-body .dialogs-panel{
  display:flex !important;flex-direction:column !important;
  min-height:0 !important;height:100% !important;
  margin:0 !important;padding:14px 0 0 !important;
  border:0 !important;border-right:1px solid var(--t-line) !important;border-radius:0 !important;
  background:var(--t-panel) !important;box-shadow:none !important;
  backdrop-filter:none !important;-webkit-backdrop-filter:none !important;
}
html body.chat-body .chat-topline{
  display:flex !important;align-items:center !important;gap:10px !important;
  margin:0 !important;padding:0 14px 12px !important;border:0 !important;background:none !important;
}
html body.chat-body .chat-topline h1{
  margin:0 !important;font-size:21px !important;font-weight:800 !important;letter-spacing:-.02em !important;
  color:var(--t-text) !important;background:none !important;-webkit-text-fill-color:var(--t-text) !important;
}
html body.chat-body .chat-topline p{margin:1px 0 0 !important;font-size:12.5px !important;color:var(--t-dim) !important}
html body.chat-body .mobile-chat-back{display:none !important}
html body.chat-body .chat-refresh{
  margin-left:auto !important;width:38px !important;height:38px !important;
  display:grid !important;place-items:center !important;border-radius:50% !important;cursor:pointer !important;
  background:transparent !important;border:0 !important;color:var(--t-dim) !important;box-shadow:none !important;
}
html body.chat-body .chat-refresh:hover{background:var(--t-hover) !important;color:var(--t-text) !important}
html body.chat-body .chat-refresh svg{width:18px !important;height:18px !important}

html body.chat-body .dialog-search{
  display:flex !important;align-items:center !important;gap:9px !important;
  height:40px !important;margin:0 14px 8px !important;padding:0 14px !important;
  border-radius:999px !important;background:rgba(255,255,255,.055) !important;border:1px solid transparent !important;
}
html body.chat-body .dialog-search:focus-within{border-color:rgba(79,182,255,.5) !important;background:rgba(255,255,255,.07) !important}
html body.chat-body .dialog-search svg{width:16px !important;height:16px !important;color:var(--t-dim) !important;flex:none !important}
html body.chat-body .dialog-search input{
  flex:1 !important;min-width:0 !important;height:100% !important;
  background:none !important;border:0 !important;outline:none !important;box-shadow:none !important;
  color:var(--t-text) !important;font-size:15px !important;font-family:inherit !important;
}
html body.chat-body .dialog-search input::placeholder{color:rgba(133,149,171,.85) !important}

html body.chat-body .dialog-list{
  flex:1 !important;min-height:0 !important;overflow-y:auto !important;overscroll-behavior:contain !important;
  display:flex !important;flex-direction:column !important;gap:0 !important;
  margin:0 !important;padding:2px 8px 10px !important;scrollbar-width:thin !important;
}
html body.chat-body .dialog-list::-webkit-scrollbar{width:6px}
html body.chat-body .dialog-list::-webkit-scrollbar-thumb{background:rgba(255,255,255,.12);border-radius:6px}

html body.chat-body .dialog-item{
  position:relative !important;
  display:grid !important;grid-template-columns:54px minmax(0,1fr) auto !important;
  align-items:center !important;gap:12px !important;
  width:100% !important;min-height:0 !important;height:auto !important;
  margin:0 !important;padding:9px 10px !important;
  border:0 !important;border-radius:12px !important;
  background:transparent !important;box-shadow:none !important;
  color:inherit !important;text-align:left !important;cursor:pointer !important;
  transition:background .15s ease !important;
}
html body.chat-body .dialog-item::before,
html body.chat-body .dialog-item::after{content:none !important;display:none !important}
html body.chat-body .dialog-item:hover{background:var(--t-hover) !important}
html body.chat-body .dialog-item.active{background:var(--t-active) !important}
html body.chat-body .dialog-item > img{
  width:54px !important;height:54px !important;margin:0 !important;
  border-radius:50% !important;object-fit:cover !important;
}
html body.chat-body .dialog-main{display:flex !important;flex-direction:column !important;gap:3px !important;min-width:0 !important}
html body.chat-body .dialog-name{
  font-size:15.5px !important;font-weight:700 !important;line-height:1.25 !important;color:var(--t-text) !important;
  white-space:nowrap !important;overflow:hidden !important;text-overflow:ellipsis !important;
}
html body.chat-body .dialog-last{
  font-size:14px !important;line-height:1.3 !important;color:var(--t-dim) !important;
  white-space:nowrap !important;overflow:hidden !important;text-overflow:ellipsis !important;
}
html body.chat-body .dialog-item.unread .dialog-last{color:#c7d3e3 !important}
html body.chat-body .dialog-muted-mark{color:rgba(133,149,171,.8) !important;margin-right:5px !important}
html body.chat-body .dialog-side{
  display:flex !important;flex-direction:column !important;align-items:flex-end !important;
  align-self:stretch !important;justify-content:flex-start !important;gap:7px !important;padding-top:3px !important;
}
html body.chat-body .dialog-time{font-size:12px !important;color:var(--t-dim) !important;white-space:nowrap !important}
html body.chat-body .dialog-item.unread .dialog-time{color:var(--t-accent) !important}
html body.chat-body .dialog-unread{
  min-width:22px !important;height:22px !important;padding:0 7px !important;
  display:inline-flex !important;align-items:center !important;justify-content:center !important;
  border-radius:999px !important;background:var(--t-accent) !important;color:#05101c !important;
  font-size:12px !important;font-weight:800 !important;
}
html body.chat-body .dialog-item.muted .dialog-unread{background:#56657a !important;color:#e9eef6 !important}

/* ----------------------------------------------------------- переписка */
html body.chat-body .conversation-panel{
  display:flex !important;flex-direction:column !important;
  min-height:0 !important;height:100% !important;
  margin:0 !important;padding:0 !important;
  border:0 !important;border-radius:0 !important;
  background:var(--t-chat-bg) !important;box-shadow:none !important;overflow:hidden !important;
  backdrop-filter:none !important;-webkit-backdrop-filter:none !important;
}
html body.chat-body .conversation-empty{
  flex:1 !important;display:flex !important;flex-direction:column !important;
  align-items:center !important;justify-content:center !important;gap:12px !important;
  padding:30px 20px !important;text-align:center !important;
}
html body.chat-body .conversation-empty[hidden]{display:none !important}
html body.chat-body .conversation-empty-icon{
  width:66px !important;height:66px !important;display:grid !important;place-items:center !important;
  border-radius:50% !important;background:rgba(255,255,255,.05) !important;border:0 !important;color:var(--t-accent) !important;
}
html body.chat-body .conversation-empty-icon svg{width:28px !important;height:28px !important}
html body.chat-body .conversation-empty h2{margin:0 !important;font-size:19px !important;font-weight:800 !important;color:var(--t-text) !important}
html body.chat-body .conversation-empty p{margin:0 !important;max-width:340px !important;font-size:14px !important;line-height:1.5 !important;color:var(--t-dim) !important}

html body.chat-body .conversation-live{
  display:flex !important;flex-direction:column !important;
  flex:1 1 auto !important;min-height:0 !important;height:100% !important;
}
html body.chat-body .conversation-live[hidden]{display:none !important}

/* шапка диалога */
html body.chat-body .conversation-head{
  position:relative !important;
  display:flex !important;align-items:center !important;gap:12px !important;flex:none !important;
  min-height:60px !important;margin:0 !important;padding:8px 14px !important;
  border:0 !important;border-bottom:1px solid var(--t-line) !important;border-radius:0 !important;
  background:rgba(17,26,38,.96) !important;
}
html body.chat-body .conversation-back{display:none !important}
html body.chat-body .conversation-avatar{
  width:42px !important;height:42px !important;flex:none !important;
  border-radius:50% !important;object-fit:cover !important;
}
html body.chat-body .conversation-user{display:flex !important;flex-direction:column !important;min-width:0 !important;flex:1 !important;gap:1px !important}
html body.chat-body .conversation-user strong{
  font-size:16px !important;font-weight:700 !important;color:var(--t-text) !important;
  white-space:nowrap !important;overflow:hidden !important;text-overflow:ellipsis !important;
}
html body.chat-body .conversation-user span{font-size:13px !important;color:var(--t-dim) !important}
html body.chat-body .conversation-profile{
  display:inline-flex !important;align-items:center !important;height:32px !important;padding:0 12px !important;
  border-radius:999px !important;border:0 !important;background:rgba(255,255,255,.06) !important;
  color:var(--t-text) !important;font-size:13px !important;font-weight:700 !important;text-decoration:none !important;
}
html body.chat-body .conversation-profile:hover{background:rgba(255,255,255,.1) !important}
html body.chat-body .conversation-menu-btn{
  width:38px !important;height:38px !important;flex:none !important;
  display:grid !important;place-items:center !important;border-radius:50% !important;
  border:0 !important;background:transparent !important;color:var(--t-dim) !important;cursor:pointer !important;
}
html body.chat-body .conversation-menu-btn:hover{background:var(--t-hover) !important;color:var(--t-text) !important}
html body.chat-body .conversation-menu{
  position:absolute !important;top:calc(100% - 4px) !important;right:10px !important;z-index:30 !important;
  min-width:220px !important;padding:6px !important;border-radius:12px !important;
  background:#1d2836 !important;border:1px solid rgba(255,255,255,.08) !important;
  box-shadow:0 18px 40px rgba(0,0,0,.45) !important;
}
html body.chat-body .conversation-menu[hidden]{display:none !important}
html body.chat-body .conversation-menu button{
  display:block !important;width:100% !important;padding:11px 12px !important;border:0 !important;border-radius:8px !important;
  background:none !important;color:var(--t-text) !important;font-size:14px !important;text-align:left !important;cursor:pointer !important;
}
html body.chat-body .conversation-menu button:hover{background:rgba(255,255,255,.07) !important}
html body.chat-body .conversation-menu button[data-chat-action="hide-dialog"]{color:#ff7a8a !important}

/* лента сообщений */
html body.chat-body .message-list{
  flex:1 1 auto !important;min-height:0 !important;
  display:flex !important;flex-direction:column !important;gap:2px !important;
  margin:0 !important;padding:10px max(14px, calc((100% - 760px) / 2)) 12px !important;
  overflow-y:auto !important;overscroll-behavior:contain !important;
  -webkit-overflow-scrolling:touch !important;scrollbar-width:thin !important;
}
/* мало сообщений — прижимаем их к низу, как в мессенджере */
html body.chat-body .message-list > :first-child{margin-top:auto !important}
html body.chat-body .message-list::-webkit-scrollbar{width:6px}
html body.chat-body .message-list::-webkit-scrollbar-thumb{background:rgba(255,255,255,.12);border-radius:6px}

html body.chat-body .message-day{
  display:flex !important;justify-content:center !important;margin:10px 0 6px !important;
  pointer-events:none !important;
}
html body.chat-body .message-day span{
  padding:4px 11px !important;border-radius:999px !important;
  background:rgba(12,20,31,.78) !important;color:#c9d4e3 !important;
  font-size:12.5px !important;font-weight:700 !important;
  backdrop-filter:blur(8px) !important;-webkit-backdrop-filter:blur(8px) !important;
}

html body.chat-body .message-row{display:flex !important;position:relative !important;margin:0 !important;flex:none !important}
html body.chat-body .message-row.own{justify-content:flex-end !important}
html body.chat-body .message-row.is-first{margin-top:8px !important}

html body.chat-body .message-bubble{
  position:relative !important;
  width:auto !important;max-width:min(78%,540px) !important;
  padding:7px 11px 6px 12px !important;
  border:0 !important;border-radius:17px !important;
  background:var(--t-their) !important;color:var(--t-text) !important;
  box-shadow:0 1px 1px rgba(0,0,0,.25) !important;
  font-size:15px !important;line-height:1.4 !important;
}
html body.chat-body .message-bubble::before{content:none !important;display:none !important}
html body.chat-body .message-row.own .message-bubble{
  max-width:min(78%,540px) !important;
  background:var(--t-own) !important;color:#fff !important;
}
/* «хвостик» у последнего сообщения в группе */
html body.chat-body .message-row.their:not(:has(+ .message-row.their)) .message-bubble{border-bottom-left-radius:5px !important}
html body.chat-body .message-row.own:not(:has(+ .message-row.own)) .message-bubble{border-bottom-right-radius:5px !important}
html body.chat-body .message-row.deleted .message-bubble{opacity:.6 !important}

html body.chat-body .message-body{
  display:inline !important;white-space:pre-wrap !important;overflow-wrap:anywhere !important;
  font-size:15px !important;line-height:1.4 !important;
}
/* время и галочки справа внизу внутри пузыря */
html body.chat-body .message-meta{
  float:right !important;display:inline-flex !important;align-items:center !important;gap:4px !important;
  position:relative !important;top:6px !important;margin:0 0 0 10px !important;
  font-size:11.5px !important;line-height:1 !important;
}
html body.chat-body .message-time{font-size:11.5px !important;opacity:1 !important;color:rgba(233,238,246,.55) !important}
html body.chat-body .message-row.own .message-time,
html body.chat-body .message-row.own .message-edited{color:rgba(255,255,255,.72) !important}
html body.chat-body .message-edited{font-size:11px !important;opacity:1 !important;color:rgba(233,238,246,.5) !important}
html body.chat-body .message-receipt{
  font-size:12px !important;letter-spacing:-3px !important;margin-right:3px !important;
  color:rgba(255,255,255,.72) !important;
}
html body.chat-body .message-receipt.is-read{color:#9ee7ff !important}
html body.chat-body .deleted-text{font-style:italic !important;opacity:.75 !important}

html body.chat-body .message-media{display:block !important;margin:-3px -7px 6px -8px !important}
html body.chat-body .message-media.image img,
html body.chat-body .message-media.video{
  display:block !important;width:min(320px,100%) !important;max-height:320px !important;
  object-fit:cover !important;border:0 !important;border-radius:13px !important;
}
html body.chat-body .message-media.audio{width:min(300px,100%) !important;margin:0 0 6px !important}
html body.chat-body .message-media.file{
  margin:0 0 6px !important;padding:10px 12px !important;border-radius:10px !important;
  background:rgba(255,255,255,.1) !important;color:inherit !important;text-decoration:none !important;font-weight:700 !important;
}

/* меню действий: наведение на ПК, долгое нажатие на телефоне */
html body.chat-body .message-actions{
  display:flex !important;gap:4px !important;
  position:absolute !important;top:calc(100% + 4px) !important;z-index:6 !important;
  padding:4px !important;border-radius:12px !important;
  background:#1d2836 !important;border:1px solid rgba(255,255,255,.08) !important;
  box-shadow:0 12px 30px rgba(0,0,0,.45) !important;
  opacity:0 !important;pointer-events:none !important;transform:translateY(-4px) !important;
  transition:opacity .14s ease, transform .14s ease !important;
}
html body.chat-body .message-row.own .message-actions{right:0 !important;left:auto !important}
html body.chat-body .message-row.their .message-actions{left:0 !important;right:auto !important}
html body.chat-body .message-row.is-actions{z-index:8 !important}
html body.chat-body .message-row.is-actions .message-actions{
  opacity:1 !important;pointer-events:auto !important;transform:none !important;
}
html body.chat-body .message-actions button{
  display:inline-flex !important;align-items:center !important;gap:6px !important;
  min-height:34px !important;padding:0 11px !important;border:0 !important;border-radius:8px !important;
  background:none !important;box-shadow:none !important;
  color:var(--t-text) !important;font-size:13px !important;font-weight:700 !important;cursor:pointer !important;white-space:nowrap !important;
}
html body.chat-body .message-actions button:hover{background:rgba(255,255,255,.08) !important}
html body.chat-body .message-actions button.danger{color:#ff7a8a !important}
html body.chat-body .message-action-glyph{font-size:14px !important;opacity:.85 !important}
@media (hover:hover) and (pointer:fine){
  html body.chat-body .message-row:hover .message-actions{
    opacity:1 !important;pointer-events:auto !important;transform:none !important;
  }
  html body.chat-body .message-row:hover{z-index:7 !important}
}

/* поле ввода */
html body.chat-body .message-form{
  flex:none !important;
  display:flex !important;align-items:flex-end !important;gap:8px !important;
  margin:0 !important;padding:8px max(12px, calc((100% - 760px) / 2)) 10px !important;
  border:0 !important;border-top:1px solid var(--t-line) !important;
  background:rgba(17,26,38,.96) !important;box-shadow:none !important;
}
html body.chat-body .message-input-wrap{
  flex:1 1 auto !important;min-width:0 !important;min-height:44px !important;
  display:flex !important;align-items:center !important;
  padding:0 4px !important;border-radius:22px !important;
  background:rgba(255,255,255,.06) !important;border:1px solid transparent !important;box-shadow:none !important;
}
html body.chat-body .message-input-wrap:focus-within{border-color:rgba(79,182,255,.45) !important;box-shadow:none !important}
html body.chat-body .message-form textarea,
html body.chat-body #message-input{
  display:block !important;width:100% !important;
  min-height:42px !important;max-height:140px !important;
  margin:0 !important;padding:11px 12px 10px !important;
  border:0 !important;background:none !important;outline:none !important;resize:none !important;
  color:var(--t-text) !important;
  /* 16px — иначе iOS увеличивает страницу при фокусе */
  font-size:16px !important;line-height:1.35 !important;font-family:inherit !important;
}
html body.chat-body .message-form textarea::placeholder{color:rgba(133,149,171,.85) !important}
html body.chat-body .message-form button{
  width:44px !important;height:44px !important;flex:none !important;
  display:grid !important;place-items:center !important;border-radius:50% !important;
  border:0 !important;cursor:pointer !important;box-shadow:none !important;padding:0 !important;
}
html body.chat-body .message-tool-btn{background:transparent !important;color:var(--t-dim) !important}
html body.chat-body .message-tool-btn:hover{background:var(--t-hover) !important;color:var(--t-text) !important}
html body.chat-body .message-send-btn{background:var(--t-own) !important;color:#fff !important}
html body.chat-body .message-form button svg{width:21px !important;height:21px !important}
html body.chat-body .message-form button:disabled{opacity:.55 !important;cursor:wait !important}
html body.chat-body .message-form.is-editing{box-shadow:inset 0 2px 0 #ffd562 !important}
html body.chat-body .message-form.is-editing .message-input-wrap{border-color:rgba(255,213,98,.5) !important}

html body.chat-body .chat-state{padding:26px 14px !important;text-align:center !important;color:var(--t-dim) !important;font-size:14px !important}
html body.chat-body .chat-state.inline{margin:auto !important}

/* ===================================================== телефон ≤ 900px */
@media (max-width:900px){
  /* страница не прокручивается вообще — двигаются только списки внутри */
  html:has(body.chat-body),
  html body.chat-body{
    height:100% !important;overflow:hidden !important;overscroll-behavior:none !important;
  }
  html body.chat-body{position:fixed !important;inset:0 !important;margin:0 !important;padding:0 !important;width:100% !important}
  html body.chat-body .site-header{display:none !important}

  /* высота = видимая часть экрана (её выставляет скрипт по visualViewport) */
  html body.chat-body .chat-page{
    position:fixed !important;left:0 !important;right:0 !important;bottom:auto !important;
    top:0 !important;
    height:var(--chat-viewport-height, 100dvh) !important;max-height:none !important;
    width:100% !important;max-width:none !important;margin:0 !important;padding:0 !important;
    /* сдвиг под видимую часть экрана — через transform, без перерасчёта раскладки */
    z-index:5 !important;transform:translate3d(0,var(--chat-viewport-top, 0px),0) !important;filter:none !important;
    backdrop-filter:none !important;-webkit-backdrop-filter:none !important;
  }
  html body.chat-body .chat-shell{
    display:block !important;position:relative !important;
    width:100% !important;height:100% !important;min-height:0 !important;max-height:none !important;
    margin:0 !important;border:0 !important;border-radius:0 !important;box-shadow:none !important;
    background:var(--t-bg) !important;
  }

  /* список — во весь экран, снизу место под нижнее меню сайта */
  html body.chat-body .dialogs-panel{
    position:absolute !important;inset:0 !important;height:auto !important;
    padding:calc(10px + env(safe-area-inset-top,0px)) 0 calc(74px + env(safe-area-inset-bottom,0px)) !important;
    border:0 !important;background:var(--t-bg) !important;
  }
  html body.chat-body .chat-topline{padding:0 12px 10px !important}
  html body.chat-body .mobile-chat-back{
    display:grid !important;place-items:center !important;flex:none !important;
    width:38px !important;height:38px !important;border-radius:50% !important;
    color:var(--t-text) !important;font-size:26px !important;line-height:1 !important;text-decoration:none !important;
    background:transparent !important;border:0 !important;
  }
  html body.chat-body .dialog-search{margin:0 12px 6px !important}
  html body.chat-body .dialog-list{padding:0 4px 8px !important}
  html body.chat-body .dialog-item{border-radius:10px !important;padding:8px 10px !important}

  /* диалог выезжает справа поверх списка, как в Telegram */
  html body.chat-body .conversation-panel{
    position:absolute !important;inset:0 !important;z-index:20 !important;
    height:auto !important;width:auto !important;max-width:none !important;
    translate:100% 0;visibility:hidden;
    transition:translate .28s cubic-bezier(.2,.8,.2,1), visibility 0s linear .28s !important;
    will-change:translate;
  }
  html body.chat-body .chat-shell.is-chat-open .conversation-panel{
    translate:0 0;visibility:visible;
    transition:translate .28s cubic-bezier(.2,.8,.2,1), visibility 0s !important;
  }
  html body.chat-body .conversation-empty{display:none !important}

  html body.chat-body .conversation-head{
    min-height:56px !important;
    padding:calc(6px + env(safe-area-inset-top,0px)) 8px 6px 4px !important;gap:8px !important;
  }
  html body.chat-body .conversation-back{
    display:grid !important;place-items:center !important;flex:none !important;
    width:40px !important;height:40px !important;border-radius:50% !important;
    border:0 !important;background:transparent !important;color:var(--t-text) !important;cursor:pointer !important;
  }
  html body.chat-body .conversation-back svg{width:24px !important;height:24px !important}
  html body.chat-body .conversation-avatar{width:40px !important;height:40px !important}
  html body.chat-body .conversation-profile{display:none !important}
  html body.chat-body .conversation-menu{right:6px !important}

  html body.chat-body .message-list{padding:6px 8px 10px !important}
  html body.chat-body .message-bubble,
  html body.chat-body .message-row.own .message-bubble{max-width:84% !important}
  /* долгое нажатие открывает меню, а не выделение текста */
  html body.chat-body .message-bubble{-webkit-touch-callout:none !important;-webkit-user-select:none !important;user-select:none !important}

  html body.chat-body .message-form{
    padding:6px 6px calc(6px + env(safe-area-inset-bottom,0px)) !important;gap:4px !important;
  }
  /* с клавиатурой отступ под «домашнюю полоску» не нужен */
  html body.chat-body.chat-keyboard-open .message-form{padding-bottom:6px !important}

  /* нижнее меню сайта — только в списке, в диалоге его нет */
  html body.chat-body > div:has(> .bottom-nav){position:relative !important;z-index:40 !important}
  html body.chat-body.chat-conversation-open .bottom-nav{display:none !important}
}

/* ---------------------------------------------------------------------
   Жёсткий сброс старой раскладки из chat.css: там лента и поле ввода
   стояли абсолютом с отступами под нижнее меню (в том числе с классами
   chat-keyboard-open и mm-ios-standalone). #chat-shell весомее их всех.
   --------------------------------------------------------------------- */
@media (max-width:900px){
  html body.chat-body .chat-page.chat-page{
    top:0 !important;transform:translate3d(0,var(--chat-viewport-top, 0px),0) !important;
    height:var(--chat-viewport-height, 100dvh) !important;max-height:none !important;
    padding:0 !important;margin:0 !important;
  }
  html body #chat-shell .conversation-live,
  html body #chat-shell .dialogs-panel{max-height:none !important}
  /* лента тянется, поле ввода прижато к низу */
  html body #chat-shell .conversation-live:not([hidden]){
    display:flex !important;flex-direction:column !important;height:100% !important;
  }
  html body #chat-shell .conversation-head,
  html body #chat-shell .message-list,
  html body #chat-shell .message-form{
    position:static !important;
    top:auto !important;bottom:auto !important;left:auto !important;right:auto !important;
    transform:none !important;width:auto !important;
  }
  /* меню «…» позиционируется от шапки; ровная полоса без скруглений из старого chat.css */
  html body #chat-shell .conversation-head,
  html body #chat-shell.is-chat-open .conversation-head{position:relative !important;border-radius:0 !important;min-height:56px !important;box-shadow:none !important}
  html body #chat-shell .message-list{flex:1 1 auto !important;min-height:0 !important;height:auto !important}
}

/* ---------------------------------------------------------------------
   Телефон: под чатом только сплошной тёмный цвет. Фоновая картинка сайта
   (theme.css рисует её в body::before) проглядывала, пока выезжает
   клавиатура.
   --------------------------------------------------------------------- */
@media (max-width:900px){
  html:has(body.chat-body){background:#0b121d !important}
  html body.chat-body{background:#0b121d !important;background-image:none !important}
  html body.chat-body:not(.home):not(.aimlab-body)::before,
  html body.chat-body:not(.home):not(.aimlab-body)::after{
    content:none !important;display:none !important;background:none !important;
  }
  /* сама страница не тянется пальцем, прокручиваются только списки */
  html body.chat-body .chat-page{touch-action:none !important}
  html body.chat-body .dialog-list,
  html body.chat-body .message-list{touch-action:pan-y !important}
  html body.chat-body .message-form textarea{touch-action:pan-y !important}
}