/* RHINO Chat is a companion surface; the approved Mail palette owns its colors. */
:root { --chat-width: 360px; }
.chat-frame-mount { flex: 1; min-height: 0; display: flex; }
.chat-auth-frame { flex: 1; min-width: 0; width: 100%; height: 100%; border: 0; background: var(--panel); }
.chat-frame-focus-guard { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.chat-toggle { color: var(--secondary); }
.chat-toggle[aria-expanded="true"] { color: var(--accent-readable); background: rgb(var(--accent-rgb) / .08); }
.chat-panel { position: fixed; z-index: 8; inset: 84px 0 0 auto; width: var(--chat-width); background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden; animation: chat-enter 180ms ease-out both; }
.chat-open .workspace { width: calc(100% - var(--chat-width)); }
.chat-head { display: flex; align-items: center; justify-content: space-between; min-height: 90px; gap: 10px; padding: 20px 20px 18px 24px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.chat-head h2 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .16em; }
.chat-head h2 span { color: var(--accent-readable); font-weight: 400; }
#chat-connection { margin: 7px 0 0; font-size: 10px; color: var(--muted); line-height: 1.4; max-width: 205px; }
.chat-head-actions { display: flex; gap: 2px; }
.chat-head .icon-button { width: 32px; height: 36px; }
.chat-head .icon-button svg { width: 18px; height: 18px; }
.chat-list-view { min-height: 0; flex: 1; display: flex; flex-direction: column; }
.chat-search { margin: 22px 20px 12px; height: 40px; flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--muted); }
.chat-search:focus-within { border-color: var(--accent-readable); }
.chat-search svg { width: 16px; height: 16px; }
.chat-search input { min-width: 0; width: 100%; height: 100%; border: 0; outline: 0; font-size: 12px; background: transparent; }
.chat-conversations { overflow-y: auto; min-height: 0; padding: 0 12px 20px; scrollbar-width: thin; scrollbar-color: #414b54 transparent; }
.chat-conversation { width: 100%; min-height: 98px; padding: 22px 10px; display: flex; align-items: flex-start; gap: 12px; border-bottom: 1px solid var(--line); text-align: left; }
.chat-conversation:last-child { border-bottom-color: transparent; }
.chat-conversation:hover { background: #ffffff05; border-radius: 6px; }
.chat-avatar { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--bg); border: 1px solid #ffffff14; color: var(--accent-readable); font-size: 11px; font-weight: 500; flex: 0 0 auto; }
.chat-conversation-copy { display: grid; gap: 8px; min-width: 0; flex: 1; padding-top: 2px; }
.chat-conversation-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; min-width: 0; }
.chat-conversation-name { font-size: 12px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-time { font-size: 10px; color: var(--muted); white-space: nowrap; }
.chat-preview { font-size: 11px; color: var(--muted); line-height: 1.6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-empty { padding: 50px 18px; text-align: center; color: var(--muted); font-size: 12px; line-height: 1.8; }
.chat-disconnected { margin: auto 20px; padding: 30px 0 70px; text-align: center; }
.chat-disconnected > svg { width: 52px; height: 52px; stroke-width: 1; color: var(--accent-readable); margin-bottom: 18px; }
.chat-disconnected h3 { margin: 0 0 14px; font-size: 15px; font-weight: 500; color: var(--secondary); }
.chat-disconnected p { margin: 0; font-size: 12px; line-height: 1.8; color: var(--muted); }
.chat-retry { margin: 12px auto 24px; flex: 0 0 auto; font-size: 12px; }
.chat-thread-view { flex: 1; min-height: 0; display: flex; flex-direction: column; animation: chat-thread-in 150ms ease-out both; }
.chat-peer { display: flex; align-items: center; gap: 10px; min-height: 82px; padding: 14px 18px 14px 10px; border-bottom: 1px solid var(--line); }
.chat-peer > div { min-width: 0; }
.chat-peer .icon-button { width: 28px; height: 40px; flex: 0 0 auto; }
.chat-peer .icon-button svg { width: 18px; height: 18px; }
.chat-peer h3 { margin: 0; font-size: 12px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-peer p { color: var(--muted); margin: 5px 0 0; font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-history { flex: 1; min-height: 0; padding: 24px 20px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #414b54 transparent; }
.chat-message { display: flex; flex-direction: column; align-items: flex-start; margin: 0 0 22px; }
.chat-message-bubble { max-width: 92%; background: var(--raised); border: 1px solid var(--line); border-radius: 9px 9px 9px 2px; padding: 12px 14px; }
.chat-message-body { margin: 0; font-size: 12px; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-message[data-own="true"] { align-items: flex-end; }
.chat-message[data-own="true"] .chat-message-bubble { border-radius: 9px 9px 2px 9px; background: var(--bg); border-color: #566674; }
.chat-message[data-own="true"] .chat-message-bubble { border-inline-end: 2px solid var(--accent-readable); }
.chat-message-meta { color: var(--muted); font-size: 9px; line-height: 1.6; margin: 7px 2px 0; }
.chat-compose { margin: 0; padding: 16px 20px 20px; border-top: 1px solid var(--line); background: var(--panel); }
.chat-input-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.chat-compose textarea { display: block; width: 100%; min-height: 82px; max-height: 150px; resize: vertical; padding: 12px; background: var(--bg); border: 1px solid #46535e; border-radius: 7px; font-size: 12px; line-height: 1.7; }
.chat-compose textarea:focus-visible { outline-offset: 2px; }
.chat-compose-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-top: 12px; }
#chat-character-count { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.chat-compose .button { min-height: 36px; padding: 7px 13px; font-size: 12px; }
.chat-compose .button svg { width: 16px; height: 16px; }
.chat-send-status { min-height: 16px; margin: 10px 0 0; color: var(--secondary); font-size: 10px; line-height: 1.6; }
@keyframes chat-enter { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@keyframes chat-thread-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@media (min-width: 1600px) { :root { --chat-width: 380px; } }
@media (max-width: 1280px) {
  .chat-open .workspace { width: 100%; }
  .chat-panel { box-shadow: -18px 0 45px #0003; }
}
@media (max-width: 820px) {
  .chat-panel { inset: 70px 0 0; width: 100%; box-shadow: none; border-left: 0; }
  .chat-head { min-height: 70px; padding-block: 12px; }
  .chat-open { overflow: hidden; }
  .chat-head .icon-button { width: 40px; height: 40px; }
  .chat-conversations { padding-inline: 14px; }
  .chat-peer { min-height: 74px; }
  .chat-history { padding: 20px; }
  .chat-message-bubble { max-width: 85%; }
  .chat-message-body { font-size: 13px; }
  .chat-compose { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
}
@media (max-width: 560px) {
  .masthead { grid-template-columns: 34px minmax(0, 1fr) 110px; }
  .chat-toggle { width: 34px; height: 38px; }
  .chat-compose textarea { font-size: 16px; min-height: 75px; }
  .chat-send-status { margin-top: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .chat-panel, .chat-thread-view { animation: none; }
}
