/* The chat occupies the available workspace; other operation screens keep their layout. */
.chat-workspace .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.app-shell:has(.chat-workspace) { height: var(--chat-viewport-height, 100dvh); min-height: 0; overflow: hidden; }
.app-shell:has(.chat-workspace) .main-column { height: var(--chat-viewport-height, 100dvh); min-height: 0; display: flex; flex-direction: column; padding-bottom: 0; }
.app-shell:has(.chat-workspace) .topbar, .app-shell:has(.chat-workspace) .subscription-banner, .app-shell:has(.chat-workspace) .offline-banner { flex: 0 0 auto; }
.app-shell:has(.chat-workspace) .page-content { flex: 1; display: flex; min-height: 0; min-width: 0; padding: 0; }
.app-shell:has(.chat-workspace) .mobile-nav { display: none; }
.chats-page { max-width: 1080px; margin: 0 auto; padding: 8px; min-width: 0; }
.chats-page h1 { margin: 8px 0; font-size: 25px; }
.chats-page p { color: var(--muted); }
.chats-page label { display: grid; gap: 8px; font-size: 14px; font-weight: 650; }
.chats-page input:not([type=checkbox]), .chats-page select { min-width: 0; width: 100%; padding: 12px; border: 1px solid var(--line-dark); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: inherit; }
.chat-create-page { max-width: 760px; }
.chat-create-form { display: grid; gap: 24px; margin-top: 24px; padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); }
.chat-create-form fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 20px; min-width: 0; }
.chat-create-form legend { padding: 0 8px; font-weight: 650; }
.chat-create-form fieldset p { font-size: 13px; line-height: 1.6; }
.chat-people { list-style: none; margin: 16px 0; padding: 0; display: grid; gap: 10px; max-height: 330px; overflow-y: auto; }
.chat-people label { display: flex; align-items: center; padding: 10px 0; gap: 12px; }
.chat-people small { display: block; color: var(--muted); font-weight: 400; }

.chat-workspace { flex: 1; display: grid; grid-template-columns: clamp(240px, 23vw, 288px) minmax(0, 1fr); width: 100%; min-width: 0; min-height: 0; height: 100%; background: var(--surface); }
.chat-sidebar { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: #fafbfc; border-right: 1px solid var(--line); }
.chat-sidebar__heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 18px 16px; }
.chat-sidebar__heading > a:first-child { display: flex; align-items: baseline; gap: 9px; color: var(--ink); font-size: 20px; font-weight: 750; text-decoration: none; }
.chat-sidebar__heading > a > span { color: var(--muted); font-size: 11px; font-weight: 500; }
.chat-icon-action, .chat-members-button, .chat-back { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); min-width: 34px; min-height: 34px; text-decoration: none; }
.chat-icon-action:hover, .chat-members-button:hover, .chat-tool:hover { background: var(--action-soft); color: var(--action); }
.chat-icon-action svg, .chat-members-button svg { width: 19px; height: 19px; }
.chat-sidebar__search { margin: 0 14px 12px; min-width: 0; }
.chat-sidebar__search input { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 7px; padding: 9px 11px; font: inherit; font-size: 12px; background: var(--surface); color: var(--ink); }
.chat-sidebar__all { color: var(--muted); font-size: 11px; margin: 0 18px 14px; text-decoration: none; }
.chat-sidebar__all:hover { color: var(--action); }
.chat-sidebar__filters { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 17px 12px; }
.chat-sidebar__filters select { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 12px; padding: 4px 0; max-width: 130px; }
.chat-sidebar__filters button, .chat-admin-link, .chat-pagination button { background: none; border: 0; color: var(--muted); padding: 6px 0; font: inherit; font-size: 11px; text-align: left; }
.chat-sidebar__list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 16px; }
.chat-sidebar__label { margin: 8px 10px 9px; font-size: 10px; font-weight: 650; letter-spacing: .08em; color: var(--muted); }
.chat-sidebar__status, .chat-sidebar__empty { font-size: 12px; color: var(--muted); line-height: 1.5; padding: 4px 12px; }
.chat-sidebar__footer { padding: 10px 18px; border-top: 1px solid var(--line); }
.chat-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 3px; }
.chat-sidebar .chat-list a { min-width: 0; display: flex; align-items: center; gap: 10px; padding: 10px; border: 0; border-radius: 7px; background: transparent; text-decoration: none; color: var(--ink-soft); font-size: 13px; }
.chat-sidebar .chat-list a:hover { background: #eef0f3; }
.chat-sidebar .chat-list a[aria-current=page] { color: var(--action); background: var(--action-soft); font-weight: 650; }
.chat-channel-icon { color: var(--muted); font-size: 21px; line-height: 1; font-weight: 450; flex-shrink: 0; }
.chat-channel-title { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-channel-title small { display: block; font-size: 10px; color: var(--muted); font-weight: 400; }
.chat-count { font-size: 10px; font-weight: 700; color: var(--action); background: var(--action-soft); border-radius: 5px; padding: 2px 6px; flex-shrink: 0; }
.chat-pagination { display: flex; flex-wrap: wrap; gap: 10px; }
.chat-conversation { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); overflow: hidden; }
.chat-conversation__header { flex: 0 0 auto; border-bottom: 1px solid var(--line); }
.chat-conversation__titlebar { display: flex; align-items: center; gap: 12px; min-height: 68px; padding: 12px 24px 8px; }
.chat-conversation__titlebar > div { min-width: 0; flex: 1; }
.chat-conversation__titlebar h1 { margin: 0; font-size: 17px; line-height: 1.35; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-conversation__titlebar p { margin: 3px 0 0; font-size: 11px; color: var(--muted); }
.chat-members-button { padding: 6px 9px; font-size: 12px; }
.chat-back { display: none; }
.chat-conversation__header nav { display: flex; gap: 20px; padding: 0 24px; }
.chat-conversation__header nav button { padding: 9px 0 10px; color: var(--muted); border: 0; background: none; border-bottom: 2px solid transparent; font-size: 12px; }
.chat-conversation__header nav button.active { color: var(--action); border-color: var(--action); font-weight: 650; }
.chat-message-scroll, .chat-activity { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 0; overflow-anchor: none; }
.chat-messages { padding: 0; margin: 0; list-style: none; }
.chat-message { position: relative; display: flex; align-items: flex-start; gap: 11px; min-width: 0; padding: 9px 24px; scroll-margin: 16px; }
.chat-message:hover { background: #fafbfc; }
.chat-message--anchor { background: var(--action-soft); box-shadow: inset 3px 0 var(--action); }
.chat-person-avatar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; flex: 0 0 32px; border-radius: 9px; background: #f6efdb; color: #70613c; font-size: 12px; font-weight: 750; }
.chat-person-avatar--agent { color: var(--action); background: var(--action-soft); }
.chat-message__body { min-width: 0; flex: 1; }
.chat-message header { display: flex; align-items: baseline; flex-wrap: wrap; gap: 9px; padding-right: 58px; }
.chat-message header strong { font-size: 13px; line-height: 1.5; }
.chat-message time { color: var(--muted); font-size: 10px; }
.chat-message p { margin: 3px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.55; }
.chat-inline-mention { padding: 1px 3px; color: var(--action); background: var(--action-soft); border-radius: 3px; }
.chat-reply-link { padding: 2px 0; font-size: 11px; color: var(--muted); background: none; border: 0; text-align: left; }
.chat-reply-link:hover { color: var(--action); }
.chat-message__reply { position: absolute; top: 7px; right: 18px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); opacity: 0; }
.chat-message:hover .chat-message__reply, .chat-message:focus-within .chat-message__reply { opacity: 1; }
.chat-older { margin: 0 auto 12px; display: block; font-size: 11px; padding: 7px 10px; }
.chat-newest { margin: 6px 16px; align-self: center; font-size: 11px; padding: 7px 10px; }
.chat-empty { padding: 24px; margin: 0; font-size: 13px; color: var(--muted); }
.chat-composer { position: relative; flex: 0 0 auto; display: grid; gap: 7px; margin: 10px 20px 16px; min-width: 0; }
.chat-composer__box { border: 1px solid var(--line-dark); border-radius: 10px; background: var(--surface); overflow: hidden; }
.chat-composer__box:focus-within { border-color: var(--action); box-shadow: 0 0 0 2px var(--action-soft); }
.chat-composer .chat-composer__box textarea { display: block; min-width: 0; width: 100%; min-height: 44px; max-height: 144px; padding: 13px 14px 5px; border: 0; border-radius: 0; background: none; color: var(--ink); font: inherit; font-size: 14px; line-height: 1.5; resize: none; outline: none; box-shadow: none; }
.chat-composer__toolbar { display: flex; align-items: center; gap: 8px; padding: 5px 8px 8px; }
.chat-composer__tools { display: flex; gap: 2px; }
.chat-tool { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 30px; border: 0; border-radius: 6px; color: var(--muted); background: none; font-size: 20px; }
.chat-tool svg { width: 18px; height: 18px; }
.chat-composer__hint, .chat-composer__count { color: var(--muted); font-size: 10px; flex: 1; text-align: right; margin-right: 7px; }
.chat-send { min-width: 34px; min-height: 32px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 6px 9px; border: 0; border-radius: 7px; background: var(--action); color: white; margin-left: auto; }
.chat-send svg { width: 18px; height: 18px; }
.chat-send:disabled { background: var(--action-soft); color: var(--muted); opacity: .65; }
.chat-send > span { font-size: 11px; }
.chat-composer p, .chat-reply-banner { font-size: 11px; margin: 0; }
.chat-reply-banner { color: var(--muted); display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; }
.chat-reply-banner button, .chat-discard { background: none; border: 0; color: var(--action); padding: 0; font-size: 11px; }
.chat-selected-mentions { display: flex; flex-wrap: wrap; gap: 5px; }
.chat-selected-mentions > span { display: inline-flex; gap: 5px; align-items: center; padding: 2px 6px; color: var(--action); background: var(--action-soft); border-radius: 4px; font-size: 11px; }
.chat-selected-mentions button { display: inline-flex; align-items: center; justify-content: center; padding: 0; width: 18px; height: 18px; border: 0; background: none; color: inherit; }
.chat-mention-picker { position: absolute; z-index: 40; bottom: calc(100% + 7px); left: 0; width: min(350px, 100%); max-height: min(340px, 50dvh); display: flex; flex-direction: column; padding: 5px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: 0 8px 28px rgb(15 23 42 / 14%); }
.chat-mention-picker > header { display: flex; justify-content: space-between; align-items: center; padding: 8px 9px; gap: 12px; font-size: 12px; }
.chat-mention-picker > header button { border: 0; border-radius: 5px; background: none; color: var(--muted); width: 25px; height: 25px; }
.chat-mention-picker ul { list-style: none; padding: 0; margin: 0; overflow-y: auto; min-height: 0; }
.chat-mention-picker li[aria-selected=true] { background: var(--action-soft); border-radius: 6px; }
.chat-mention-picker li button { display: flex; align-items: center; gap: 10px; text-align: left; width: 100%; padding: 7px 9px; background: transparent; border: 0; color: var(--ink); }
.chat-mention-picker li button > span:last-child { min-width: 0; }
.chat-mention-picker li strong { font-size: 12px; display: block; }
.chat-mention-picker li small { font-size: 10px; color: var(--muted); display: block; margin-top: 2px; }
.chat-mention-picker > p { color: var(--muted); padding: 10px; }
.chat-mention-picker > footer { display: flex; justify-content: space-between; padding: 9px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.chat-welcome { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; padding: 40px; text-align: center; }
.chat-welcome__icon { display: grid; place-items: center; width: 70px; height: 70px; border: 1px solid var(--line); border-radius: 20px; background: #fffaf0; color: #b39444; margin-bottom: 24px; }
.chat-welcome__icon svg { width: 32px; height: 32px; }
.chat-welcome__eyebrow { font-size: 10px; letter-spacing: .13em; font-weight: 650; color: var(--muted); }
.chat-welcome h1 { font-size: 25px; margin: 12px 0; letter-spacing: -.025em; }
.chat-welcome p { max-width: 330px; font-size: 13px; line-height: 1.65; color: var(--muted); margin: 0 0 22px; }
.chat-welcome .button { padding: 10px 18px; font-size: 12px; width: auto; }
.chat-welcome > small { font-size: 10px; color: var(--muted); margin-top: 26px; max-width: 300px; }
.chat-search-results { padding: 24px; overflow-y: auto; }
.chat-search-results h1 { font-size: 20px; margin: 0 0 8px; }
.chat-search-results p { font-size: 12px; color: var(--muted); }
.chat-search-results ul { list-style: none; padding: 0; margin-top: 22px; }
.chat-search-results li a { display: grid; gap: 7px; padding: 14px 0; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 13px; }
.chat-snippet { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); font-size: 12px; line-height: 1.5; }
.chat-activity { padding: 20px 24px; }
.chat-activity h2 { font-size: 16px; }
.chat-activity ol { list-style: none; padding: 0; display: grid; gap: 14px; }
.chat-activity li { display: grid; gap: 7px; border-bottom: 1px solid var(--line); padding-bottom: 14px; font-size: 12px; }
.chat-activity li span { color: var(--muted); font-size: 11px; }
@media (max-width: 760px) {
  .chat-workspace { grid-template-columns: minmax(0, 1fr); }
  .chat-workspace:not(.chat-workspace--index) > .chat-sidebar { display: none; }
  .chat-workspace--index > .chat-sidebar { border-right: 0; }
  .chat-workspace--index > .chat-index-content { display: none; }
  .chat-workspace--index:has(.chat-search-results) { grid-template-rows: minmax(160px, 45%) minmax(0, 1fr); }
  .chat-workspace--index:has(.chat-search-results) > .chat-index-content { display: flex; border-top: 1px solid var(--line); }
  .chat-sidebar__heading { padding: 18px 18px 14px; }
  .chat-conversation__titlebar { min-height: 62px; padding: 9px 14px 7px; gap: 10px; }
  .chat-conversation__titlebar > .chat-channel-icon { display: none; }
  .chat-conversation__titlebar h1 { font-size: 16px; }
  .chat-back { display: inline-flex; border: 0; min-width: 28px; font-size: 20px; }
  .chat-conversation__header nav { padding: 0 17px; }
  .chat-message { padding: 8px 14px; gap: 9px; }
  .chat-message header { padding-right: 0; }
  .chat-message__reply { position: static; border: 0; background: none; padding: 3px 0 0; min-height: 24px; opacity: 1; font-size: 10px; }
  .chat-message p { font-size: 13px; }
  .chat-person-avatar { width: 29px; height: 29px; flex-basis: 29px; font-size: 11px; border-radius: 8px; }
  .chat-composer { margin: 8px 12px calc(10px + env(safe-area-inset-bottom)); }
  .chat-composer__hint { display: none; }
  .chat-tool, .chat-send { min-height: 36px; }
  .chat-activity { padding: 16px; }
  .chats-page { padding: 0; }
  .chat-create-form { padding: 18px; }
  .chat-create-form fieldset { padding: 14px; }
}
.chat-agent-card { margin: 12px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); overflow-wrap: anywhere; }
.chat-agent-card header { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; }
.chat-agent-card p { white-space: pre-wrap; }
.chat-resource { display: inline-flex; gap: 8px; margin: 8px 8px 8px 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.chat-panel-overlay { position: fixed; inset: 0; z-index: 1400; }
.chat-panel-backdrop { position: absolute; inset: 0; border: 0; background: rgb(15 23 42 / 35%); width: 100%; height: 100%; }
.chat-panel { position: absolute; right: 0; top: 0; height: 100dvh; width: min(500px, 100vw); background: var(--surface); box-shadow: -12px 0 36px rgb(15 23 42 / 12%); display: flex; flex-direction: column; padding: 24px max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) 24px; }
.chat-panel > header { display: flex; align-items: start; justify-content: space-between; gap: 16px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.chat-panel h2 { margin: 0; font-size: 20px; }
.chat-panel__body { overflow-y: auto; padding: 20px 2px; display: grid; align-content: start; gap: 20px; }
.chat-panel__body form, .chat-panel__body section { display: grid; gap: 16px; }
.chat-panel__body .field { display: grid; gap: 8px; }
.chat-panel__body input:not([type=checkbox]) { width: 100%; min-width: 0; padding: 12px; border: 1px solid var(--line-dark); border-radius: var(--radius-sm); }
.chat-panel__actions { display: flex; flex-wrap: wrap; gap: 12px; padding-top: 20px; border-top: 1px solid var(--line); }
.chat-members { display: grid; gap: 16px; list-style: none; margin: 0; padding: 0; }
.chat-members li { display: grid; gap: 10px; border-bottom: 1px solid var(--line); padding-bottom: 16px; }
.chat-members li > div { display: flex; flex-wrap: wrap; gap: 8px; }
.chat-members label { display: flex; gap: 10px; }
.chat-members small { display: block; margin-top: 4px; color: var(--muted); }
