.unread-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 1.375rem; height: 1.375rem; padding: 0 .375rem; border-radius: 1rem; background: var(--action); color: var(--on-action); font-size: .6875rem; font-weight: 650; flex-shrink: 0; }
.unread-badge[hidden] { display: none; }
.main-nav .unread-badge { margin-left: auto; }
body:has(#chat-shell) .workspace { height: 100svh; }
body:has(#chat-shell) .content { display: flex; flex-direction: column; min-height: 0; }
.chat-page-heading { flex-shrink: 0; }
.chat-page-heading h1 { margin-bottom: 0; }
.chat-shell { flex: 1; display: grid; grid-template-columns: 18rem minmax(0,1fr); min-height: 24rem; position: relative; }
.chat-sidebar { border-right: 1px solid var(--border); min-width: 0; min-height: 0; overflow: auto; }
.chat-sidebar-heading { padding: 1.25rem 1rem; border-bottom: 1px solid var(--border); position: relative; }
.chat-sidebar-heading h2 { font-size: .9375rem; margin-bottom: .75rem; }
.new-dialog>summary { color: var(--accent); display: inline-flex; align-items: center; gap: .375rem; font-size: .8125rem; cursor: pointer; min-height: 2rem; }
.new-dialog>summary::-webkit-details-marker { display: none; }
.new-dialog form { margin-top: .75rem; }
.new-dialog select { font-size: .8125rem; }
.conversation-list { display: flex; flex-direction: column; padding: .5rem; gap: .25rem; }
.conversation-link { display: flex; align-items: center; gap: .75rem; padding: .875rem .625rem; min-width: 0; border-radius: .375rem; border: 1px solid transparent; }
.conversation-link:hover { background: var(--soft); }
.conversation-link[aria-current] { background: var(--accent-soft); border-color: var(--border); }
.chat-avatar { width: 2.25rem; height: 2.25rem; flex-shrink: 0; border-radius: .5rem; background: var(--soft); display: inline-flex; align-items: center; justify-content: center; color: var(--muted); font-size: .75rem; }
.conversation-link[aria-current] .chat-avatar { color: var(--accent); }
.conversation-text { min-width: 0; flex: 1; }
.conversation-text strong { display: block; font-size: .875rem; font-weight: 550; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.conversation-preview { display: block; margin-top: .25rem; color: var(--muted); font-size: .75rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-conversation { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.chat-heading { display: flex; gap: 1rem; align-items: center; justify-content: space-between; padding: 1.125rem 1.5rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.chat-heading>div { min-width: 0; }
.chat-heading h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-heading .muted { font-size: .75rem; margin-top: .25rem; }
.chat-feedback { font-size: .8125rem; background: var(--soft); padding: .625rem 1.5rem; flex-shrink: 0; }
.chat-feedback:empty { display: none; }
.chat-messages { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 1.25rem 1.5rem; scrollbar-width: thin; }
.older-messages { text-align: center; margin-bottom: 1.25rem; }
.older-messages[hidden] { display: none; }
.message-list { display: flex; flex-direction: column; gap: .875rem; min-height: 100%; }
.chat-message { display: flex; align-items: flex-start; }
.chat-message.mine { justify-content: flex-end; }
.message-bubble { background: var(--soft); border: 1px solid var(--border); border-radius: .5rem .5rem .5rem .125rem; padding: .75rem 1rem; max-width: min(85%,42rem); min-width: 8rem; }
.mine .message-bubble { background: var(--accent-soft); border-color: transparent; border-radius: .5rem .5rem .125rem .5rem; }
.message-bubble header { display: flex; justify-content: space-between; gap: 1.25rem; align-items: baseline; margin-bottom: .375rem; }
.message-bubble strong { font-size: .75rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-bubble time { color: var(--muted); white-space: nowrap; font-size: .6875rem; flex-shrink: 0; }
.message-bubble p { font-size: .9375rem; line-height: 1.55; overflow-wrap: anywhere; white-space: pre-wrap; }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--muted); padding: 2rem; min-height: 14rem; }
.chat-empty>.icon { width: 2rem; height: 2rem; margin-bottom: 1rem; }
.chat-empty h3 { color: var(--text); margin-bottom: .5rem; }
.chat-empty p { font-size: .875rem; max-width: 22rem; }
.chat-composer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); flex-shrink: 0; }
.chat-composer textarea { display: block; width: 100%; min-height: 4.5rem; height: 4.5rem; max-height: 9rem; font-size: .9375rem; resize: vertical; }
.chat-composer textarea[hidden] { display: none; }
.chat-rich-input { width: 100%; min-height: 4.5rem; max-height: 9rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; padding: .75rem; border: 1px solid var(--border); border-radius: .375rem; background: var(--bg); color: var(--text); font-size: .9375rem; cursor: text; }
.chat-rich-input:empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.chat-rich-input[aria-disabled=true] { opacity: .7; cursor: default; }
.emoji-packs { display: flex; padding: 0 1rem .5rem; gap: .375rem; }
.emoji-packs button { flex: 1; border: 1px solid var(--border); border-radius: .375rem; padding: .375rem .75rem; background: var(--soft); color: var(--muted); font-size: .8125rem; }
.emoji-packs button[aria-pressed=true] { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }
.chat-emoji.memoji { width: 1.65em; height: 1.65em; vertical-align: -.4em; }
.emoji-choice img.memoji { width: 1.8rem; height: 1.8rem; }
.composer-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: .75rem; }
.composer-tools { display: flex; align-items: center; gap: .625rem; min-width: 0; }
#composer-caption { font-size: .6875rem; }
.chat-emoji { width: 1.2em; height: 1.2em; vertical-align: -.2em; object-fit: contain; display: inline-block; margin: 0 .025em; }
.message-bubble p.emoji-only { font-size: 1.875rem; line-height: 1.4; }
.emoji-toggle,.emoji-close { display: inline-flex; align-items: center; justify-content: center; width: 2.5rem; height: 2.5rem; flex-shrink: 0; border: 1px solid transparent; border-radius: .375rem; background: transparent; color: var(--muted); }
.emoji-toggle { font-size: 1.25rem; }
.emoji-toggle[hidden] { display: none; }
.emoji-toggle:hover,.emoji-toggle[aria-expanded="true"],.emoji-close:hover { background: var(--soft); border-color: var(--border); }
.emoji-picker { display: none; position: fixed; inset: auto; margin: 0; padding: 0; width: 22.5rem; max-width: calc(100vw - 1.5rem); max-height: min(28.75rem,calc(100svh - 1.5rem)); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: .625rem; box-shadow: 0 8px 32px #0003; overflow: hidden; }
.emoji-picker:popover-open { display: flex; flex-direction: column; animation: message-in 140ms ease-out; }
.emoji-picker>header { display: flex; justify-content: space-between; align-items: center; padding: .5rem .75rem .25rem 1rem; flex-shrink: 0; }
.emoji-filters { padding: .25rem 1rem .5rem; display: flex; flex-direction: column; gap: .5rem; flex-shrink: 0; }
.emoji-filters input,.emoji-filters select { font-size: .8125rem; min-height: 2.5rem; padding: .5rem .625rem; }
.emoji-status { font-size: .6875rem; padding: 0 1rem .5rem; flex-shrink: 0; }
.emoji-results { padding: 0 .75rem .75rem; min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.emoji-results h4 { margin: .5rem .25rem; font-size: .6875rem; font-weight: 550; color: var(--muted); }
#emoji-frequent { margin-bottom: .75rem; }
#emoji-frequent[hidden],#emoji-results-title[hidden] { display: none; }
.emoji-grid { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); gap: .125rem; }
.emoji-choice { border: 0; background: transparent; color: var(--text); border-radius: .375rem; display: flex; justify-content: center; align-items: center; height: 2.5rem; padding: .375rem; min-width: 0; }
.emoji-choice:hover,.emoji-choice:focus-visible { background: var(--accent-soft); }
.emoji-choice img { display: block; width: 1.5rem; height: 1.5rem; }
#emoji-more { width: 100%; margin-top: .5rem; }
#emoji-more[hidden] { display: none; }
.emoji-picker>footer { display: flex; justify-content: space-between; gap: .5rem; padding: .625rem 1rem; border-top: 1px solid var(--border); font-size: .625rem; color: var(--muted); flex-shrink: 0; }
.emoji-picker>footer a:hover { color: var(--accent); text-decoration: underline; }
.chat-composer .errorlist { margin-bottom: .75rem; }
button:disabled { opacity: .6; cursor: default; }
.new-message-notice { position: absolute; bottom: 11rem; left: 50%; transform: translateX(-50%); background: var(--surface)!important; box-shadow: 0 4px 16px #0002; z-index: 1; }
.new-message-notice[hidden] { display: none; }
.message-arrive { animation: message-in 180ms ease-out both; }
@keyframes message-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@media(max-width:1100px) { .chat-shell { grid-template-columns: 15rem minmax(0,1fr); } .chat-messages,.chat-heading,.chat-composer { padding-left: 1rem; padding-right: 1rem; } }
@media(max-width:850px) {
  body:has(#chat-shell) .app-shell { display: flex; flex-direction: column; height: 100svh; min-height: 0; }
  body:has(#chat-shell) .sidebar { flex-shrink: 0; }
  body:has(#chat-shell) .workspace { height: auto; flex: 1; min-height: 0; }
  .chat-shell { min-height: 0; grid-template-columns: 14rem minmax(0,1fr); }
  .chat-page-heading { margin-bottom: 1rem; }
  .chat-page-heading .eyebrow,.chat-page-heading>.muted { display: none; }
}
@media(max-width:600px) {
  body:has(#chat-shell) .content { padding: .75rem; }
  body:has(#chat-shell) .topbar,.chat-page-heading { display: none; }
  .chat-shell { display: flex; flex-direction: column; }
  .chat-sidebar { border-right: 0; border-bottom: 1px solid var(--border); flex-shrink: 0; overflow: visible; }
  .chat-sidebar-heading { padding: .5rem .75rem; }
  .chat-sidebar-heading h2 { display: none; }
  .new-dialog form { position: absolute; z-index: 5; top: 2.25rem; left: .5rem; right: .5rem; background: var(--surface); padding: 1rem; border: 1px solid var(--border); border-radius: .375rem; }
  .conversation-list { flex-direction: row; overflow: auto; padding: .25rem .5rem; gap: .375rem; }
  .conversation-link { min-width: 10rem; max-width: 13rem; padding: .5rem; }
  .chat-avatar { width: 1.75rem; height: 1.75rem; font-size: .6875rem; }
  .conversation-text strong { font-size: .75rem; }
  .conversation-preview { font-size: .6875rem; max-width: 8rem; }
  .chat-conversation { flex: 1; }
  .chat-heading { padding: .625rem .75rem; }
  .chat-heading h2 { font-size: .9375rem; }
  .chat-messages { padding: .75rem; }
  .chat-composer { padding: .625rem .75rem; }
  .chat-composer textarea { height: 3rem; min-height: 3rem; }
  .composer-footer { margin-top: .5rem; gap: .5rem; }
  #composer-caption { font-size: .625rem; }
  .composer-tools { gap: .375rem; }
  .composer-footer .button { min-height: 2.5rem; padding: .5rem .75rem; }
  .message-bubble { max-width: 95%; padding: .625rem .75rem; }
  .message-bubble header { gap: .625rem; }
  .message-bubble p { font-size: .875rem; }
  .chat-empty { min-height: 8rem; padding: 1rem; }
  .chat-feedback { padding: .5rem .75rem; font-size: .75rem; }
  .new-message-notice { bottom: 8rem; }
}
@media(prefers-reduced-motion:reduce) { .message-arrive,.emoji-picker:popover-open { animation: none; } }
/* Ticket cards and mentions share the existing graphite surfaces. */
.chat-ticket-card { display:grid; gap:.5rem; min-width:0; margin-top:.75rem; padding:.875rem; border:1px solid var(--border); border-left:3px solid var(--accent); border-radius:.5rem; background:var(--surface); color:var(--text); text-decoration:none; overflow-wrap:anywhere; transition:border-color .18s, transform .18s; }
.chat-ticket-card:hover { border-color:var(--accent); transform:translateY(-1px); }
.chat-ticket-meta { display:flex; flex-wrap:wrap; justify-content:space-between; gap:.5rem; font-size:.75rem; color:var(--muted); }
.chat-ticket-card>span:not(.chat-ticket-meta) { font-size:.8125rem; }
.chat-ticket-card small { color:var(--accent); }
.chat-ticket-unavailable { padding:.75rem 0; font-size:.75rem; color:var(--muted); }
.chat-attachments { display:flex; gap:1rem; align-items:start; flex-wrap:wrap; position:relative; }
.chat-attach { position:relative; min-width:0; max-width:100%; flex:1; font-size:.8125rem; }
.attachment-panel { position:absolute; bottom:100%; left:0; width:min(22rem,calc(100vw - 3.5rem)); padding:.75rem; z-index:12; border:1px solid var(--border); border-radius:.75rem; background:var(--surface); box-shadow:0 .5rem 2rem #0003; }
.chat-attach select { width:100%; margin-top:.5rem; }
.chat-attach small { display:block; font-size:.6875rem; margin:.375rem 0; }
.chat-mention-picker { position:relative; font-size:.8125rem; }
.chat-mention-picker summary,.chat-attach summary { cursor:pointer; padding:.375rem 0; }
.mention-panel { position:absolute; bottom:100%; right:0; width:min(19rem,75vw); padding:.75rem; z-index:12; border:1px solid var(--border); border-radius:.75rem; background:var(--surface); box-shadow:0 .5rem 2rem #0003; }
.mention-results { max-height:15rem; overflow:auto; margin-top:.5rem; }
.mention-person { display:flex; flex-direction:column; gap:.25rem; width:100%; padding:.75rem; border:0; background:transparent; color:var(--text); text-align:left; border-radius:.375rem; }
.mention-person:hover,.mention-person:focus-visible { background:var(--soft); }
.mention-person.is-active { background:var(--accent-soft); }
.chat-composer { position:relative; }
.mention-autocomplete { bottom:calc(100% - .25rem);left:.75rem;right:.75rem;width:auto; }
.mention-autocomplete[hidden] { display:none; }
.mention-caption { font-size:.75rem;color:var(--muted); }
.mention-person small { color:var(--muted); }
.message-bubble header a { color:inherit; text-decoration:none; }
.message-bubble header a:hover { color:var(--accent); }
.message-highlight .message-bubble { outline:2px solid var(--accent); outline-offset:3px; }
@media(prefers-reduced-motion:reduce) { .chat-ticket-card { transition:none; } .chat-ticket-card:hover { transform:none; } }
