/* ANTON D2 messenger, using the main app tokens. */
.chat-layout { display: grid; grid-template-columns: minmax(220px,29%) minmax(0,1fr); min-height: 560px; height: min(690px,calc(100dvh - 240px)); border: 1px solid var(--bd); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.chat-sidebar { min-width: 0; min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--bd); background: var(--surface); padding: 16px; gap: 12px; }
.chat-tabs { display: flex; gap: 4px; background: var(--gs); padding: 4px; border-radius: 11px; }
.chat-tabs button { min-width: 0; flex: 1; padding: 7px 8px; border: 0; font-size: .78em; background: transparent; }
.chat-tabs button.active { background: var(--surface); color: var(--g); font-weight: 750; }
.chat-search { display: grid; gap: 7px; margin: 0; font-size: .82em; }
#chatSideList { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px; margin: 0 -4px; }
.chat-side-item { width: 100%; display: grid; grid-template-columns: 36px minmax(0,1fr); gap: 11px; align-items: center; text-align: left; padding: 12px 9px; margin-bottom: 5px; border: 1px solid transparent; background: transparent; border-radius: 12px; }
.chat-side-item.active { background: var(--gs); border-color: var(--bd); }
.chat-side-item strong { font-size: .83em; display: block; overflow-wrap: anywhere; }
.chat-side-item small { font-size: .71em; display: block; color: var(--mut); margin-top: 3px; }
.person-dot { display: grid; place-items: center; background: var(--gs); color: var(--g); width: 36px; height: 36px; border-radius: 50%; font-size: 12px; font-weight: 750; }
.chat-side-item.active .person-dot { background: var(--surface); }
.chat-new { margin-top: auto; flex-shrink: 0; border: 1px solid var(--bd); background: var(--surface); color: var(--g); padding: 10px 12px; font-size: .82em; font-weight: 700; }
.chat-room { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0,1fr) auto auto auto; }
#chatHead { display: flex; align-items: center; gap: 12px; padding: 17px 20px; border-bottom: 1px solid var(--bd); min-height: 80px; }
#chatHead b { display: block; font-size: .95em; line-height: 1.3; }
#chatHead small { display: block; font-size: .75em; color: var(--mut); margin-top: 4px; }
.chat-back { display: none; padding: 8px 12px; border: 1px solid var(--bd); background: var(--surface); color: var(--g); }
#chatMessages { min-height: 0; overflow: auto; overscroll-behavior: contain; background: var(--bg); padding: 22px; }
.chat-empty { color: var(--mut); padding: 24px; font-size: .92em; text-align: center; }
.chat-message { width: fit-content; max-width: 91%; margin: 0 0 14px; background: var(--surface); border: 1px solid var(--bd); border-radius: 16px 16px 16px 5px; padding: 12px 15px; }
.chat-message.mine { margin-left: auto; background: var(--gs); border-radius: 16px 16px 5px 16px; }
.chat-message > small { display: block; color: var(--mut); font-size: .72em; margin-bottom: 5px; }
.chat-message p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .94em; }
.reply-preview { padding-left: 10px; border-left: 3px solid var(--g); color: var(--mut); margin-bottom: 8px; font-size: .79em; overflow-wrap: anywhere; }
.message-tools { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; }
.message-tools button { min-width: 44px; min-height: 44px; border: 0; padding: 7px 8px; border-radius: 8px; background: transparent; color: var(--mut); font-size: .72em; }
#chatForm { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--bd); margin: 0; }
#chatInput { resize: none; height: 50px; min-height: 50px; max-height: 120px; line-height: 1.5; }
#chatForm button { color: #fff; background: #075b43; padding: 10px 14px; border: 0; font-size: .86em; font-weight: 700; }
#chatStatus { padding: 0 18px 12px; margin: 0; font-size: .76em; color: var(--mut); min-height: 1.5em; }
#replyBar { display: flex; align-items: center; gap: 10px; padding: 8px 18px; font-size: .8em; background: var(--gs); }
#replyBar strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#replyBar button { flex-shrink: 0; margin-left: auto; width: 44px; border: 0; background: transparent; color: var(--g); }
@media(hover:hover) { .chat-side-item:hover, .message-tools button:hover { background: var(--gs); } }
@media(max-width:700px) {
  [data-view=chat] .page-title { margin-bottom: 18px; }
  .chat-layout { display: block; height: auto; min-height: 420px; overflow: hidden; }
  .chat-sidebar { border-right: 0; }
  #chatSideList { max-height: 60dvh; overflow-y: auto; }
  .chat-side-item { grid-template-columns: 42px minmax(0,1fr); padding: 13px 10px; }
  .person-dot { width: 40px; height: 40px; }
  .chat-side-item strong { font-size: .94em; }
  .chat-side-item small { font-size: .78em; }
  .chat-room { display: none; }
  .chat-layout.chat-open .chat-sidebar { display: none; }
  .chat-layout.chat-open .chat-room { display: grid; height: max(400px,calc(100dvh - 260px - var(--safe-bottom))); }
  .chat-back { display: block; }
  #chatMessages { padding: 16px; }
  #chatHead { padding: 12px; min-height: 72px; }
  #chatForm { padding: 12px; gap: 8px; }
  .chat-message { max-width: 95%; padding: 10px 12px; }
  body.keyboard-open .bottom-nav { display: none; }
  body.keyboard-open [data-view=chat] .page-title { display: none; }
  body.keyboard-open .chat-layout.chat-open .chat-room { height: max(280px,calc(var(--visual-height,100dvh) - 102px)); }
  body.keyboard-open .app-main { padding-bottom: 14px; }
}
