/* Telegram-inspired split workspace, isolated from the profile feed. */
.chats-workspace{width:100%!important;max-width:1120px!important;margin:0!important;min-height:0;padding:0!important}
.chats-workspace .chats-layout{display:grid;grid-template-columns:340px minmax(0,1fr);height:calc(100dvh - 48px);min-height:480px;max-height:960px;border:1px solid #27272b;border-radius:18px;overflow:hidden;background:#141416;color:#f2f2f5}
.chats-layout .dialogs-panel,.chats-layout.is-thread-open .dialogs-panel{display:flex!important;min-height:0;width:100%!important;overflow:hidden;background:#19191c;border-right:1px solid #2a2a2e}
.chats-layout .dialogs-head{padding:20px 18px 14px!important;align-items:center}.chats-layout .dialogs-head h1{font-size:23px!important;letter-spacing:-.025em}.chats-layout .dialogs-head span{font-size:12px;color:#a0a0ab}.chats-layout .new-chat-btn{width:32px;height:32px;border-radius:50%;font-size:23px}
.chats-layout .dialogs-search-wrap{height:38px;flex-shrink:0;margin:0 14px 12px;padding:0 12px;background:#252529;border:0;border-radius:10px}.chats-layout .dialogs-search-wrap input{font-size:13px}.chats-layout .dialogs-search-wrap input::placeholder{color:#a0a0aa}
.chats-layout .dialog-tabs{gap:0;flex-shrink:0;padding:0 12px;border-bottom:1px solid #2a2a2e}.chats-layout .dialog-tabs button{height:40px;padding:0 9px;font-size:11px;border-radius:0;color:#a6a6b0}.chats-layout .dialog-tabs button.is-active{background:none;color:#eee9ff;box-shadow:inset 0 -2px #b6a0e6}.chats-layout .dialog-tabs span{color:inherit}
.chats-layout .dialog-list{overflow-y:auto;min-height:0;padding:7px;scrollbar-width:thin;scrollbar-color:#414147 transparent}
.tg-row{position:relative;border-radius:10px}.tg-row[hidden]{display:none}.tg-row:has(.is-selected){background:#34303f}
.chats-layout .dialog-row{height:78px;min-height:78px;grid-template-columns:50px minmax(0,1fr);gap:11px;padding:10px;border-radius:10px}.chats-layout .dialog-avatar{width:50px;height:50px}.chats-layout .dialog-line strong{font-size:14px;font-weight:650;max-width:calc(100% - 42px)}.chats-layout .dialog-line time{font-size:10px;color:#a6a5af}.chats-layout .dialog-preview{max-width:none;padding-right:46px;margin-top:6px;font-size:12px;color:#9c9ca7}.chats-layout .is-unread .dialog-preview{color:#d1d0d8}
.chats-layout .dialog-badge{position:absolute;right:31px;bottom:15px;min-width:18px;height:18px;margin:0;padding:0 5px;background:#c7b3ed;color:#241d31;font-size:10px;box-sizing:border-box}.chats-layout .dialog-badge--dispute{background:#d9b0ab;color:#352321}
.tg-pin{position:absolute;right:6px;bottom:10px;width:25px;height:27px;display:grid;place-items:center;border:0;border-radius:6px;background:none;color:#898590;cursor:pointer;opacity:0}.tg-pin svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}.tg-row:hover .tg-pin,.tg-row:focus-within .tg-pin,.is-pinned .tg-pin{opacity:1}.is-pinned .tg-pin{color:#929098}.tg-pin:hover{background:#49414f}
.chats-layout .dialog-thread{width:100%!important;min-width:0;min-height:0;overflow:hidden;background:#111113}.chats-layout .thread-head{position:relative;padding:13px 18px!important;background:#19191c;border-bottom:1px solid #29292d;gap:10px;flex-shrink:0}.chats-layout .thread-head-avatar .dialog-avatar{width:40px;height:40px}.chats-layout .thread-head-meta strong{font-size:14px}.chats-layout .thread-head-meta span{font-size:12px;color:#a6a2b1}.chats-layout .thread-back-btn{display:none}.chats-layout .thread-messages{padding:24px;scrollbar-width:thin;scrollbar-color:#414147 transparent}.chats-layout .msg{max-width:82%;padding:11px 13px 8px;border:0;border-radius:14px}.chats-layout .msg--in{background:#262629;border-bottom-left-radius:4px}.chats-layout .msg--out{background:#393044;border-bottom-right-radius:4px}.chats-layout .msg__text{font-size:14px;line-height:1.5}.chats-layout .msg__time{color:#b4aabd}.chats-layout .thread-day{color:#b1abb9;background:#222126}.chats-layout .thread-composer{position:relative;padding:12px 16px 16px;background:#19191c;flex-shrink:0;align-items:center}.chats-layout .thread-compose-field{background:#27272b;border:0;border-radius:12px;min-height:40px;box-sizing:border-box;font-size:14px}.chats-layout .thread-compose-send{background:#bda3e0;color:#221a2d;border-radius:50%}.chats-layout .thread-compose-plus{background:none}
.tg-empty{display:grid;place-content:center;text-align:center;gap:10px;padding:24px;background:radial-gradient(ellipse at center,#211c29 0%,#141416 65%)}.tg-empty strong{font-size:19px;font-weight:600}.tg-empty p{margin:0;color:#a9a3b1;font-size:13px;line-height:1.6}.is-thread-open>.tg-empty{display:none}.tg-no-results{padding:24px 12px;text-align:center;color:#aaa4b4;font-size:13px}
.chats-layout button:focus-visible{outline:2px solid #c7b3ed;outline-offset:-3px}.chats-layout textarea:focus-visible,.chats-layout input:focus-visible{outline:1px solid #b69adf;outline-offset:3px}
@media(max-width:1080px) and (min-width:761px){.chats-workspace .chats-layout{grid-template-columns:300px minmax(0,1fr)}}
@media(max-width:760px){.chats-workspace .chats-layout{display:block;height:calc(100dvh - 86px);min-height:360px;border-radius:0;border:0}.chats-layout .dialogs-panel,.chats-layout .dialog-thread{height:100%}.chats-layout.is-thread-open .dialogs-panel{display:none!important}.chats-layout .thread-back-btn{display:grid}.tg-empty{display:none}.tg-pin{opacity:1}.chats-layout .thread-messages{padding:16px}.chats-layout .dialog-tabs button{font-size:12px;padding:0 13px}.chats-layout .dialog-row{height:80px}.chats-layout .dialog-preview{font-size:13px}}
@media(prefers-reduced-motion:reduce){.chats-layout *{transition:none!important}}
/* Override legacy profile workspace geometry only inside Chats. */
body[data-view="chats"] .chats-workspace{width:100%!important;max-width:1120px!important;min-height:0!important}
.chats-workspace .chats-layout .dialogs-panel{min-height:0!important;overflow:hidden!important;background:#19191c!important;border-right:1px solid #2a2a2e!important}
/* v752: consistent controls, safe narrow layout and contact picker. */
.chats-workspace .chats-layout{min-height:0;height:calc(100dvh - 48px);grid-template-columns:minmax(280px,32%) minmax(0,1fr)}
.chats-layout .dialogs-panel{min-width:0}.chats-layout .dialog-row{padding-right:12px}.chats-layout .dialog-line strong{font-size:14px}.chats-layout .dialog-preview{padding-right:52px}.chats-layout .thread-head-meta{overflow:hidden}.chats-layout .thread-head-meta strong{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.chats-layout .msg__text{overflow-wrap:anywhere}.chats-layout .thread-compose-send:disabled{opacity:.35;cursor:default}.chats-layout .thread-head-btn[aria-pressed="true"]{background:#393044;color:#d6bff6}.tg-row{margin-bottom:2px}.chats-layout .dialog-badge{right:38px}.tg-pin{width:30px;height:32px;right:3px;bottom:6px}
.tg-contact-picker{width:min(390px,calc(100vw - 32px));max-height:75dvh;box-sizing:border-box;padding:20px;color:#eeeaf4;background:#1e1e22;border:1px solid #39363f;border-radius:18px;font:14px Geist,system-ui,sans-serif;box-shadow:0 24px 80px #0008}.tg-contact-picker::backdrop{background:#0009}.tg-picker-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:16px}.tg-picker-head strong{font-size:18px}.tg-picker-head button{border:0;background:transparent;color:#c6becf;font-size:26px;cursor:pointer}.tg-contact-picker>input{box-sizing:border-box;width:100%;padding:12px;border:1px solid #49414f;border-radius:10px;background:#29282d;color:#eee;font:inherit}.tg-picker-list{display:grid;gap:4px;margin-top:14px}.tg-picker-list>button{display:flex;align-items:center;gap:12px;width:100%;padding:9px;border:0;border-radius:10px;background:none;color:inherit;font:inherit;text-align:left;cursor:pointer}.tg-picker-list>button:hover,.tg-picker-list>button:focus-visible{background:#37303f}.tg-picker-list .dialog-avatar{width:42px;height:42px}
@media(max-width:960px){.chats-workspace .chats-layout{display:block}.chats-layout .dialogs-panel,.chats-layout .dialog-thread{height:100%}.chats-layout.is-thread-open .dialogs-panel{display:none!important}.chats-layout .thread-back-btn{display:grid}.tg-empty{display:none}.tg-pin{opacity:1}.chats-layout .dialog-tabs button{font-size:12px}.chats-layout .thread-messages{padding:16px}}
@media(max-width:760px){.chats-workspace .chats-layout{height:calc(100dvh - 86px)}.tg-pin{width:34px;height:40px;bottom:2px}.chats-layout .dialog-badge{right:43px}}
/* v823: stable chat geometry inside the same content column as the rest of the site.
   Do not stretch to the viewport: that was making Chats jump wide and detach from the sidebar. */
@media(min-width:761px){
  body[data-view="chats"] .ksan-main{
    width:100%!important;
    max-width:1040px!important;
    min-width:0!important;
    overflow:visible!important;
  }
  body[data-view="chats"] .chats-workspace{
    width:100%!important;
    max-width:1040px!important;
    min-width:0!important;
    box-sizing:border-box;
  }
  .chats-workspace .chats-layout{
    width:100%;
    grid-template-columns:320px minmax(0,1fr);
    height:calc(100dvh - 116px);
    min-height:560px;
    max-height:860px;
    box-sizing:border-box;
  }
}
@media(min-width:761px) and (max-width:1100px){
  .chats-workspace .chats-layout{display:block}
  .chats-layout .dialogs-panel,.chats-layout .dialog-thread{height:100%}
  .chats-layout.is-thread-open .dialogs-panel{display:none!important}
  .chats-layout .thread-back-btn{display:grid}
  .tg-empty{display:none}
}
@media(min-width:1101px){
  .chats-workspace .chats-layout{display:grid}
  .chats-layout.is-thread-open .dialogs-panel{display:flex!important}
  .chats-layout .thread-back-btn{display:none}
  .chats-layout:not(.is-thread-open)>.tg-empty{display:grid}
}
.chats-layout{position:relative}
.chats-layout .dialog-row{height:86px;min-height:86px}
.chats-layout .dialog-avatar{overflow:visible;aspect-ratio:1;flex-shrink:0}
.chats-layout .dialog-avatar img{display:block;width:100%!important;height:100%!important;min-height:0!important;max-height:100%!important;object-fit:cover;aspect-ratio:1;border-radius:50%}
.chats-layout .dialog-avatar i{width:10px;height:10px;right:0;bottom:0;border:2px solid #19191c;z-index:1}
.tg-presence{display:block;font-size:10px;margin-top:5px;color:#99949f}
.tg-presence[data-state="online"],#threadStatus[data-state="online"]{color:#65ce91}
.tg-list-receipt{font-size:13px;color:#c9b6e5;order:1;margin-left:auto}
.chats-layout .dialog-line time{order:2;margin-left:0}
.chats-layout .dialog-line strong{flex:1}
.chats-layout .dialog-line{gap:6px}
.tg-delete{position:absolute;right:4px;top:4px;width:28px;height:28px;display:none;place-items:center;border:0;border-radius:7px;background:#28252d;color:#d1a9b1;cursor:pointer}
.tg-delete svg{width:15px;height:15px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
.tg-row:hover .tg-delete,.tg-row:focus-within .tg-delete{display:grid}
.tg-row:hover .dialog-line time,.tg-row:focus-within .dialog-line time{visibility:hidden}
.chats-layout .tg-delete-header{width:auto;padding:0 12px;color:#d8aeb5;font:12px inherit}
.tg-receipt{margin-left:7px;font-size:14px;letter-spacing:-3px;padding-right:3px;color:#aba0b4}
.tg-receipt[data-receipt="read"]{color:#dfc8ff}
.msg__time{display:flex;align-items:center}
.tg-undo{position:absolute;bottom:82px;left:50%;transform:translateX(-50%);z-index:20;display:flex;align-items:center;gap:20px;max-width:90%;padding:14px 18px;border:1px solid #514657;border-radius:12px;background:#302b36;color:#eee;font-size:13px;box-shadow:0 8px 32px #0006}
.tg-undo[hidden]{display:none!important}
.tg-undo button{background:none;border:0;color:#dfc6ff;cursor:pointer;font:inherit;font-weight:600}
@media(max-width:760px){.chats-layout .tg-delete-header{padding:0 7px}.tg-undo{left:12px;right:12px;transform:none;max-width:none;justify-content:space-between}.chats-layout .thread-head{padding:10px!important;gap:7px}}
#appSidebar .ksan-sidebar__badge[hidden]{display:none!important}
.chats-layout>.tg-empty{min-width:0;max-width:100%;box-sizing:border-box;justify-items:center;align-content:center;justify-content:stretch;padding:32px}
.chats-layout>.tg-empty p{max-width:360px;white-space:normal;overflow-wrap:anywhere;line-height:1.65}
.chats-layout>.tg-empty strong{max-width:100%;overflow-wrap:anywhere}

/* Quiet pinned rows: a small pin, no card or colored rail. */
.tg-row{border-radius:8px;margin-bottom:0}
.tg-row.is-pinned{background:transparent;box-shadow:none}
.tg-row:has(.is-selected){background:#34303f}
.tg-row.is-pinned:has(+ .tg-row:not(.is-pinned)){margin-bottom:7px;padding-bottom:7px;border-bottom:1px solid #303034;border-radius:0}
.tg-pin svg{width:13px;height:13px;stroke-width:1.7}
.tg-pin:hover{background:#303034;color:#d1cbd9}


/* v849 — definitive desktop Chats geometry.
   Fill the shared 960px workspace instead of rendering a small floating window. */
@media (min-width: 961px){
  body[data-view="chats"] .ksan-main{
    width:960px!important;
    max-width:960px!important;
    min-width:0!important;
    overflow:hidden!important;
  }

  body[data-view="chats"] .chats-workspace{
    width:960px!important;
    max-width:960px!important;
    min-width:0!important;
    height:calc(100dvh - 82px)!important;
    min-height:620px!important;
    margin:0!important;
    padding:0!important;
    overflow:hidden!important;
  }

  body[data-view="chats"] .chats-workspace .chats-layout{
    display:grid!important;
    grid-template-columns:350px minmax(0,1fr)!important;
    width:100%!important;
    height:100%!important;
    min-height:0!important;
    max-height:none!important;
    margin:0!important;
    border-radius:14px!important;
    border:1px solid #252529!important;
    background:#121214!important;
    overflow:hidden!important;
  }

  body[data-view="chats"] .chats-layout .dialogs-panel,
  body[data-view="chats"] .chats-layout.is-thread-open .dialogs-panel{
    display:flex!important;
    width:350px!important;
    min-width:350px!important;
    height:100%!important;
    min-height:0!important;
    background:#171719!important;
  }

  body[data-view="chats"] .chats-layout .dialog-thread,
  body[data-view="chats"] .chats-layout>.tg-empty{
    width:100%!important;
    min-width:0!important;
    height:100%!important;
    min-height:0!important;
  }

  body[data-view="chats"] .chats-layout>.tg-empty{
    display:grid!important;
    background:#121214!important;
    padding:40px!important;
  }

  body[data-view="chats"] .chats-layout .dialogs-head{
    padding:22px 18px 14px!important;
  }

  body[data-view="chats"] .chats-layout .dialogs-head h1{
    font-size:24px!important;
  }

  body[data-view="chats"] .chats-layout .dialogs-search-wrap{
    height:42px!important;
    margin:0 14px 12px!important;
  }

  body[data-view="chats"] .chats-layout .dialog-row{
    height:82px!important;
    min-height:82px!important;
    padding:10px!important;
  }

  body[data-view="chats"] .chats-layout .dialog-line strong{
    font-size:14.5px!important;
  }

  body[data-view="chats"] .chats-layout .dialog-preview{
    font-size:12.5px!important;
  }

  body[data-view="chats"] .chats-layout>.tg-empty strong{
    font-size:20px!important;
  }

  body[data-view="chats"] .chats-layout>.tg-empty p{
    font-size:13px!important;
    color:#8f8f98!important;
  }
}

/* Keep the split view on normal desktop widths; old rules collapsed it too early. */
@media (min-width: 961px) and (max-width: 1100px){
  body[data-view="chats"] .chats-workspace .chats-layout{
    display:grid!important;
    grid-template-columns:330px minmax(0,1fr)!important;
  }
  body[data-view="chats"] .chats-layout .dialogs-panel,
  body[data-view="chats"] .chats-layout.is-thread-open .dialogs-panel{
    display:flex!important;
    width:330px!important;
    min-width:330px!important;
  }
  body[data-view="chats"] .chats-layout .thread-back-btn{
    display:none!important;
  }
  body[data-view="chats"] .chats-layout:not(.is-thread-open)>.tg-empty{
    display:grid!important;
  }
}
