/* Keep conversation text in the portal type family. */
#chat-root {
  font-family: inherit;
}
#chat-root :is(button, textarea, input, select, h2, h3) { font-family: inherit; }
#chat-root .chat-message-body { font-size: 16px; line-height: 1.48; }
#chat-root .chat-message-by { gap: 7px; margin: 0 0 3px; }
#chat-root .chat-message-by strong { font-size: 15px; font-weight: 700; }
#chat-root .chat-message-by time { color: var(--muted); font-size: 12px; font-weight: 400; }
.chat-message > .chat-avatar { width: 36px; height: 36px; }
.chat-message .chat-thread-link { font-size: 13px; font-weight: 600; }
.chat-view-bar, .chat-room-bar { display: flex; align-items: center; gap: 8px; }
.chat-view-bar { min-width: 0; margin-bottom: 10px; }
.chat-view-bar .chat-tabs { flex: 1; min-width: 0; margin: 0; border: 0; padding: 0; }
.chat-room-bar { position: relative; flex: none; padding: 5px 12px; border-bottom: 1px solid var(--line); }
.chat-room-bar .chat-room-heading { min-height: 50px; padding: 4px; flex: 1; min-width: 0; border: 0; }
.chat-room-heading h2 { margin: 0; line-height: 1.2; font-weight: 700; }
.chat-room-heading p:not(:empty) { margin-top: 3px; }
.chat-room-options { position: relative; flex: none; }
.chat-room-options summary {
  display: grid; place-items: center; width: 44px; height: 44px; cursor: pointer;
  border-radius: 10px; list-style: none; color: var(--gray); letter-spacing: .08em;
}
.chat-room-options summary::-webkit-details-marker { display: none; }
.chat-room-options[open] summary, .chat-room-options summary:hover { background: var(--subtle); }
.chat-room-options .chat-room-secondary {
  position: absolute; top: 100%; right: 0; z-index: 8; width: 200px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 28px #0002;
}
.chat-room-tools { display: grid; padding: 5px; }
.chat-room-tools button { text-align: start; padding: 10px 12px; }
.chat-rail-content { display: flex; flex-direction: column; flex: 1 0 auto; }
.chat-exit, .chat-rail-scrim { display: none; }
.chat-compose .chat-notify-agency, .chat-compose .chat-priority-note { margin: 8px 12px 0; font-size: 12px; }
.chat-compose .chat-notify-agency { font-weight: 500; }
.chat-compose textarea { min-height: 42px; height: 46px; }
.chat-compose .chat-compose-footer { padding: 4px 8px 7px; }
.chat-room { font-size: 15px; }
.chat-room-symbol { display: inline-grid; place-items: center; }
#chat-root .chat-avatar, #people-root .chat-avatar { border-radius: 50%; object-fit: cover; }
.chat-room > .chat-avatar { width: 26px; height: 26px; }
.chat-profile-identity { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.chat-profile-identity .chat-avatar { width: 48px; height: 48px; }
.chat-rail-label { letter-spacing: 0; font-size: 13px; }

body:has(#chat-root.chat-expanded) { overflow: hidden; }
.app-shell:has(#chat-root.chat-expanded) > .sidebar,
.main-shell:has(#chat-root.chat-expanded) > .topbar,
.main:has(#chat-root.chat-expanded) > .page-heading { display: none; }
#chat-root.chat-expanded:has(.chat-workspace) {
  position: fixed; inset: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); z-index: 12;
  display: flex; flex-direction: column; padding: 12px; background: var(--panel);
}
#chat-root.chat-expanded .chat-workspace { flex: 1; height: auto; min-height: 0; max-height: none; }
#chat-root.chat-expanded .chat-demo:not(:has(select)) { display: none; }

@media (min-width: 961px) {
  /* Size the conversation from the actual space below the portal toolbar. */
  .main-shell:has(.main #chat-root .chat-workspace) {
    display: flex; flex-direction: column; height: 100dvh; min-height: 440px;
  }
  .main-shell:has(#chat-root .chat-workspace) > .topbar { flex: none; }
  .main:has(> #chat-root .chat-workspace) {
    display: flex; flex-direction: column; flex: 1; min-height: 0;
    width: 100%; max-width: none; margin: 0; padding: 12px clamp(12px, 1.4vw, 24px);
  }
  /* Chat is already named in both the navigation and the workspace breadcrumb. */
  .main:has(> #chat-root .chat-workspace) > .page-heading {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); margin: 0;
  }
  .main > #chat-root:has(.chat-workspace) {
    display: flex; flex-direction: column; flex: 1; min-height: 0;
    container: portal-chat / inline-size;
  }
  .main > #chat-root .chat-demo:not(:has(select)) { display: none; }
  .main > #chat-root .chat-workspace { flex: 1; min-height: 0; max-height: none; height: auto; }
  #chat-root .chat-message-body { max-inline-size: 80ch; }

  /* Keep the original conversation in view when a reply opens. */
  @container portal-chat (min-width: 680px) {
    .chat-workspace.thread-open { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
    .chat-workspace.thread-open .chat-rail { display: none; }
    .chat-workspace.thread-open .chat-main { visibility: visible; }
    .chat-workspace.thread-open .chat-thread {
      position: static; width: auto; box-shadow: none; border-left: 1px solid var(--line);
    }
  }
  @container portal-chat (min-width: 1020px) {
    .chat-workspace.thread-open { grid-template-columns: clamp(175px, 16cqi, 225px) minmax(0, 1.25fr) minmax(0, 1fr); }
    .chat-workspace.thread-open .chat-rail { display: flex; }
  }
}

@media (max-width: 960px) {
  body:has(.main #chat-root .chat-workspace) { overflow: hidden; }
  .app-shell:has(#chat-root .chat-workspace) > .sidebar { display: none; }
  .main-shell:has(#chat-root .chat-workspace) > .topbar,
  .main:has(#chat-root .chat-workspace) > .page-heading { display: none; }
  .main #chat-root:has(.chat-workspace), #chat-root.chat-expanded:has(.chat-workspace) {
    position: fixed; z-index: 12; inset: var(--portal-visible-top) 0 auto;
    width: 100%; height: var(--portal-visible-height); box-sizing: border-box;
    padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
    background: var(--panel); display: flex; flex-direction: column;
  }
  #chat-root .chat-workspace, #chat-root .chat-workspace.thread-open {
    flex: 1; position: relative; min-height: 0; height: auto; max-height: none;
    grid-template-columns: minmax(0, 1fr); border: 0; border-radius: 0; box-shadow: none;
  }
  #chat-root .chat-workspace.thread-open .chat-thread { position: absolute; inset: 0; width: 100%; border: 0; box-shadow: none; }
  #chat-root .chat-demo:not(:has(select)), .chat-view-bar { display: none; }
  #chat-root .chat-demo:has(select) { padding: 3px 10px; margin: 0; flex-direction: row; align-items: center; flex-wrap: wrap; }
  #chat-root .chat-rail { display: none; }
  #chat-root .rail-open .chat-rail {
    display: flex; position: absolute; inset: 0 auto 0 0; width: min(340px, 86%); z-index: 11;
    padding: 12px 10px 0; background: var(--panel); box-shadow: 4px 0 18px #0002;
  }
  .rail-open .chat-rail-scrim { display: block; position: absolute; inset: 0; z-index: 10; width: 100%; height: 100%; background: #0c17154d; border: 0; }
  .chat-mobile-rail-heading { display: flex; align-items: center; justify-content: space-between; font-size: 17px; font-weight: 700; padding: 0 5px 10px; }
  .chat-mobile-rail-heading .icon-btn { width: 42px; height: 42px; }
  .chat-mobile-rail-heading svg { width: 18px; height: 18px; }
  .chat-drawer-views .chat-tabs { display: flex; gap: 5px; overflow-x: auto; padding: 0 0 9px; margin-bottom: 4px; }
  .chat-drawer-views .chat-tabs button { white-space: nowrap; flex: none; }
  .chat-rail-label .icon-btn { background: transparent; border-color: transparent; }
  .chat-exit, .chat-room-bar .chat-rail-toggle { display: inline-grid; place-items: center; width: 44px; height: 44px; min-width: 44px; border: 0; background: transparent; }
  .chat-room-bar { padding: 2px 8px; gap: 2px; }
  #chat-root .chat-room-heading { padding: 4px; min-height: 50px; }
  #chat-root .chat-room-heading h2 { font-size: 17px; }
  #chat-root .chat-room-heading p { font-size: 12px; }
  #chat-root .chat-message-list { scrollbar-gutter: auto; }
  #chat-root .chat-message { padding: 8px clamp(12px, 3vw, 24px); gap: 10px; }
  #chat-root .chat-message > .chat-avatar { width: 34px; height: 34px; }
  #chat-root .chat-compose { margin: 4px 10px 7px; border-radius: 14px; }
  .chat-room-tools button { min-height: 44px; }
}
@media (hover: none) {
  .chat-message:hover { background: transparent; }
}

.chat-message blockquote,.chat-quote-draft blockquote{margin:4px 0 6px;padding:7px 12px;border-inline-start:3px solid var(--brand-text,currentColor);background:var(--subtle);border-radius:5px;overflow-wrap:anywhere}
.chat-message blockquote b,.chat-quote-draft b{display:block;font-size:.86em}
.chat-quote-draft{display:flex;align-items:center;justify-content:space-between}

.chat-more { position: relative; flex: none; }
.chat-more > summary { cursor: pointer; padding: 8px 10px; white-space: nowrap; }
.chat-more > div { display: flex; gap: 4px; }
@media (min-width: 961px) {
  .chat-more > div {
    position: absolute; z-index: 6; inset: calc(100% + 5px) 0 auto auto;
    display: grid; min-width: 140px; padding: 6px; background: var(--panel);
    border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 20px #0003;
  }
  .chat-more button { text-align: start; }
}
@media (max-width: 960px) {
  .chat-rail-toggle { width: auto!important; max-width: 48vw; padding-inline: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .chat-room-bar:has(.is-current-room) .chat-room-heading h2 { display: none; }
}
@media (max-width: 960px) {
  .chat-drawer-views .chat-tabs { flex-wrap: wrap; overflow-x: visible; }
  .chat-drawer-views .chat-more[open] { width: 100%; }
  .chat-drawer-views .chat-more > div { flex-wrap: wrap; }
}
@media (min-width: 961px) {
  .chat-view-bar .chat-tabs:has(.chat-more) { overflow: visible; }
}
