/* Native chat forms and disclosures, using the shared reference theme. */
.chat-page { max-width: 1220px; padding-bottom: 48px; color: var(--ink, #171717); }
.chat-page a { text-underline-offset: 3px; }
.chat-page [hidden] { display: none !important; }
.chat-heading { margin: 8px 0 24px; }
.chat-heading h1 { font-size: 32px; line-height: 1.2; letter-spacing: -.025em; margin: 0 0 8px; }
.chat-heading p { margin: 0; color: var(--muted, #666); font-size: 16px; }
.chat-install { max-width: 36rem; }
.chat-install summary { min-height: 44px; padding-block: .625rem; cursor: pointer; font-weight: 700; }
.chat-install[open] summary { margin-bottom: .5rem; }
.chat-install p { margin: 0 0 .5rem; font-size: .875rem; }
.chat-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 640px; border: 1px solid var(--line, #e5e5e5); border-radius: 14px; overflow: hidden; background: #fff; }
.chat-sidebar { display: flex; flex-direction: column; padding: 24px 14px; border-right: 1px solid var(--line, #e5e5e5); }
.chat-sidebar h2 { margin: 0 10px 22px; font-size: 22px; }
.chat-room-list { display: grid; gap: 8px; }
.chat-room-list a { display: flex; align-items: center; gap: 12px; min-height: 66px; padding: 12px; border: 1px solid transparent; border-radius: 10px; color: var(--ink, #171717); font-size: 15px; line-height: 1.45; text-decoration: none; overflow-wrap: anywhere; }
.chat-room-list a::before { content: '#'; display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%; background: #f2f2f3; color: #666; font-size: 20px; }
.chat-room-list a:hover { background: #fafafa; border-color: var(--line, #e5e5e5); }
.chat-room-list a[aria-current=page] { background: #f1f1f3; border-color: #e5e5e8; font-weight: 700; }
.chat-room-list a[aria-current=page]::before { background: #e5e3ff; color: #4338ca; }
.chat-sidebar-note { margin: auto 10px 12px; padding-top: 36px; color: var(--muted, #666); font-size: 14px; line-height: 1.6; }
.chat-sidebar>a { display: flex; align-items: center; min-height: 44px; margin: 0 10px; font-size: 15px; }
.chat-conversation { min-width: 0; display: flex; flex-direction: column; background: #f5f5f5; }
.chat-room-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 90px; padding: 20px 24px; border-bottom: 1px solid var(--line, #e5e5e5); background: #fff; }
.chat-room-heading h2 { margin: 0; font-size: 20px; line-height: 1.4; overflow-wrap: anywhere; }
.chat-room-heading p { margin: 4px 0 0; color: var(--muted, #666); font-size: 14px; }
.chat-room-heading>a { display: flex; align-items: center; min-height: 44px; flex: none; font-size: 14px; }
.chat-room-picker { display: none; }
.chat-info { background: #fff; border-bottom: 1px solid var(--line, #e5e5e5); font-size: 14px; }
.chat-info summary { padding: 12px 24px; min-height: 44px; cursor: pointer; }
.chat-info>div { padding: 0 24px 20px; max-width: 78ch; line-height: 1.65; }
.chat-info p { margin: 0 0 12px; color: #525252; }
.chat-history { padding: 18px 24px 28px; flex: 1; min-height: 300px; max-height: 680px; max-height: min(680px, 70vh); overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.chat-history-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 20px; color: var(--muted, #666); font-size: 14px; }
.chat-history-tools a { min-height: 44px; display: inline-flex; align-items: center; }
.chat-empty { display: flex; align-items: center; justify-content: center; flex-direction: column; min-height: 280px; padding: 32px 16px; text-align: center; }
.chat-empty>span { display: grid; place-items: center; width: 52px; height: 52px; border: 1px solid #dedee2; border-radius: 14px; margin-bottom: 16px; font-size: 28px; color: #737373; background: #fff; }
.chat-empty h3,.chat-empty h2 { font-size: 22px; margin: 0 0 10px; }
.chat-empty p { max-width: 48ch; margin: 0 0 16px; font-size: 15px; line-height: 1.7; color: var(--muted, #666); }
.chat-empty>a { display: inline-flex; align-items: center; min-height: 44px; }
.chat-messages { list-style: none; padding: 0; margin: 16px 0 0; }
.chat-message { margin-bottom: 20px; }
.chat-message article { padding: 18px 20px; border: 1px solid var(--line, #e5e5e5); border-radius: 12px; background: #fff; }
.chat-message header { display: flex; align-items: center; gap: 12px; }
.chat-avatar { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; background: #eeeef1; color: #525252; font-size: 16px; font-weight: 700; }
.chat-author-profile { position: relative; flex: none; }
.chat-author-profile > summary { display: grid; place-items: center; width: 44px; height: 44px; cursor: pointer; border-radius: 50%; }
.chat-author-profile > summary::-webkit-details-marker { display: none; }
.chat-author-profile > summary:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; }
.chat-author-inline { position: absolute; top: 100%; left: 0; z-index: 1; width: max-content; max-width: min(220px, 65vw); padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface, #fff); color: var(--ink); overflow-wrap: anywhere; }
.chat-author-dialog { width: min(360px, calc(100% - 32px)); max-height: calc(100% - 32px); padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface, #fff); color: var(--ink); }
.chat-author-dialog::backdrop { background: rgba(20, 44, 58, .62); }
.chat-author-dialog-header { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.chat-author-dialog-header h2 { margin: 0; overflow-wrap: anywhere; }
.chat-author-dialog-header button { min-height: 44px; }
.chat-message h3 { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.chat-message header p { margin: 2px 0 0; font-size: 12px; line-height: 1.5; color: var(--muted, #666); }
.chat-message-body { margin: 14px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; line-height: 1.7; }
.chat-image { margin: 14px 0 0; }
.chat-image img { display: block; max-width: min(100%,420px); height: auto; border-radius: 8px; border: 1px solid #e2e2e8; background: #f5f5f7; }
.chat-image figcaption { margin-top: 6px; color: var(--muted, #666); font-size: 12px; }
.chat-image-dialog { max-width: min(94vw,1100px); max-height: 92vh; padding: 16px; border: 1px solid #aaa; border-radius: 10px; background: white; }
.chat-image-dialog::backdrop { background: #000b; }
.chat-image-dialog img { display: block; max-width: 100%; max-height: 76vh; object-fit: contain; margin-top: 12px; }
.chat-image-dialog button { min-height: 44px; padding: 8px 16px; cursor: pointer; }
.chat-image-status { font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.chat-file-field input { max-width: 100%; }
.chat-message[data-chat-focus] article { border-color: #8b83e8; box-shadow: 0 0 0 2px #eceafe; }
.chat-message-actions { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 8px; font-size: 13px; }
.chat-message-actions a { display: inline-flex; min-height: 44px; align-items: center; }
.chat-reply-preview,.chat-compose-context { margin-top: 14px; padding: 10px 14px; border-left: 3px solid #b6b0e8; background: #f7f6fc; border-radius: 0 6px 6px 0; font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.chat-reply-preview p,.chat-compose-context p,.chat-compose-context blockquote { margin: 4px 0 0; white-space: pre-wrap; }
.chat-reply-preview>a { font-weight: 700; }
.chat-compose-context { margin: 0 0 16px; }
.chat-compose-context>a { display: inline-flex; align-items: center; min-height: 44px; }
.chat-reactions { margin-top: 12px; }
.chat-reactions summary { min-height: 44px; padding: 4px 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; cursor: pointer; font-size: 13px; color: #525252; }
.chat-reactions summary::after { content: '+'; display: grid; place-items: center; border: 1px dashed #bbb; border-radius: 6px; width: 28px; height: 28px; font-size: 18px; }
.chat-reaction-counts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chat-reaction-count { display: inline-flex; align-items: center; min-height: 28px; gap: 4px; padding: 2px 8px; border: 1px solid #e5e5e8; border-radius: 6px; background: #f7f7f9; color: #525252; font-size: 13px; }
.chat-reaction-picker { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 6px; max-width: 380px; padding: 10px; border: 1px solid #dddde4; border-radius: 8px; background: #fafafa; }
.chat-reaction-picker button { min-width: 0; min-height: 44px; padding: 8px 4px; gap: 4px; color: #222; border-color: #e4e4e8; background: #fff; font-size: 18px; }
.chat-reaction-picker button span { font-size: 12px; }
.chat-reaction-picker button:hover { color: #222; background: #eeecff; }
.chat-reaction-picker button[aria-pressed=true] { border-color: #6d5ce7; background: #ece9ff; }
.chat-live-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px 14px; padding: 8px 24px; min-height: 60px; border-bottom: 1px solid #e5e5e8; background: #fafafa; }
.chat-live-tools p { margin: 0; font-size: 12px; color: #666; line-height: 1.5; }
.chat-live-tools button { border: 1px solid #d4cff4; border-radius: 6px; color: #4338a3; background: #f1eeff; min-height: 36px; padding: 6px 12px; cursor: pointer; font: inherit; font-size: 13px; }
.chat-unread-badge { margin-left: auto; flex: none; padding: 2px 6px; min-width: 22px; border-radius: 12px; color: #fff; background: #5b4bc4; font-size: 12px; text-align: center; }
.chat-character-count { display: block; color: #666; font-size: 12px; margin-top: 4px; }
.chat-character-count[data-over-limit=true] { color: #9a3412; }
.chat-form button:disabled { cursor: not-allowed; opacity: .55; }
.chat-reaction-form button[aria-disabled=true] { cursor: progress; opacity: .55; }
.chat-composer-area { padding: 20px 24px; border-top: 1px solid var(--line, #e5e5e5); background: #fff; }
.chat-composer-area>a { display: inline-flex; min-height: 44px; align-items: center; font-weight: 700; }
.chat-form { margin: 0; }
.chat-field { display: flex; flex-direction: column; gap: 8px; font-size: 15px; margin-bottom: 16px; }
.chat-field>span { font-weight: 700; }
.chat-field :is(input,textarea) { width: 100%; box-sizing: border-box; padding: 12px 14px; border: 1px solid #d4d4d8; border-radius: 8px; background: #fff; color: var(--ink, #171717); font: inherit; font-size: 16px; line-height: 1.5; }
.chat-field textarea { resize: vertical; min-height: 92px; }
.chat-field small { color: var(--muted, #666); line-height: 1.6; }
.chat-file-field { display: grid; gap: 8px; margin: 0 0 10px; font-size: 15px; }
.chat-file-field>span { font-weight: 700; }
.chat-file-field input { width: 100%; box-sizing: border-box; padding: 12px; border: 1px dashed #a9a9b4; border-radius: 8px; background: #fafafa; color: var(--ink, #171717); font: inherit; font-size: 15px; }
.chat-image-previews { display: grid; grid-template-columns: repeat(auto-fit,minmax(128px,1fr)); gap: 10px; margin: 0 0 12px; }
.chat-image-previews:empty { display: none; }
.chat-image-preview { display: grid; gap: 6px; margin: 0; padding: 8px; border: 1px solid #d4d4d8; border-radius: 8px; background: #fff; }
.chat-image-preview[aria-invalid=true] { border-color: #f59f0b; background: #fff7ed; }
.chat-image-preview img { display: block; width: 100%; height: 108px; object-fit: contain; border-radius: 4px; background: #f5f5f7; }
.chat-image-preview figcaption { display: grid; gap: 5px; color: var(--muted, #666); font-size: 12px; line-height: 1.4; }
.chat-image-preview button { min-height: 34px; padding: 5px 8px; border: 1px solid #c9c9d2; border-radius: 6px; background: #fff; color: #3f3f46; font: inherit; font-size: 12px; cursor: pointer; }
.chat-image-preview button:hover { background: #f1f1f4; }
.chat-composer .chat-field { margin-bottom: 10px; }
.chat-composer-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.chat-composer-footer p { margin: 0; max-width: 40ch; font-size: 13px; color: var(--muted, #666); line-height: 1.5; }
.chat-form button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 16px; border: 1px solid #171717; border-radius: 8px; background: #171717; color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.chat-form button:hover { background: #333; }
.chat-composer-footer button { flex: none; }
.chat-withdraw { margin-top: 10px; }
.chat-withdraw button { min-height: 44px; padding: 6px 0; color: #666; background: transparent; border: 0; font-size: 13px; font-weight: 400; text-decoration: underline; text-underline-offset: 3px; }
.chat-withdraw button:hover { color: #171717; background: transparent; }
.chat-notice { margin: 0; padding: 14px 18px; background: #f2f2f5; border-bottom: 1px solid #dedee2; color: #414147; font-size: 15px; line-height: 1.65; overflow-wrap: anywhere; }
.chat-notice[role=alert] { background: #fff7ed; color: #9a3412; border-color: #fed7aa; }
.chat-composer-area>.chat-notice { padding: 0; border: 0; background: transparent; margin-bottom: 6px; }
.chat-workspace { max-width: 1000px; }
.chat-workspace-nav { display: flex; gap: 12px 24px; flex-wrap: wrap; margin-bottom: 20px; font-size: 15px; }
.chat-workspace-nav a { display: inline-flex; align-items: center; min-height: 44px; }
.chat-settings-panel { padding: 28px; max-width: 700px; border: 1px solid var(--line, #e5e5e5); border-radius: 12px; background: #fff; }
.chat-settings-panel h2 { margin: 0 0 12px; font-size: 22px; }
.chat-settings-panel>p { margin: 0 0 24px; color: var(--muted, #666); line-height: 1.7; font-size: 16px; }
.chat-check { display: flex; align-items: flex-start; gap: 12px; padding-block: 10px; font-size: 16px; line-height: 1.65; }
.chat-check input { width: 20px; height: 20px; flex: none; margin: 3px 0 0; accent-color: #4338ca; }
.chat-help { margin: 12px 0 20px; font-size: 14px; line-height: 1.7; color: var(--muted, #666); }
.chat-settings-panel>.chat-notice { margin-top: 20px; }
.chat-review-list { display: grid; gap: 20px; margin-top: 20px; }
.chat-review-card { padding: 24px; border: 1px solid var(--line, #e5e5e5); border-radius: 12px; background: #fff; min-width: 0; }
.chat-review-card>header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.chat-review-card :is(h2,h3) { margin: 0; font-size: 20px; overflow-wrap: anywhere; }
.chat-own-history { margin-top: 32px; }
.chat-own-history>h2 { margin: 0; font-size: 24px; }
.chat-badge { display: inline-flex; border: 1px solid #d4d4d8; padding: 3px 8px; border-radius: 5px; color: #525252; font-size: 13px; }
.chat-presence { padding: 0 24px; color: #46606c; font-size: 13px; }
.chat-presence details { padding-block: 8px; }
.chat-presence summary { cursor: pointer; min-height: 32px; display: list-item; }
.chat-presence ul { display: flex; flex-wrap: wrap; gap: 8px 20px; list-style: none; margin: 8px 0 16px; padding: 0; }
.chat-presence li { overflow-wrap: anywhere; }
.chat-presence p { margin: 6px 0 12px; min-height: 20px; }
.chat-mention { background: #e4f1ed; color: #07564f; border-radius: 4px; padding-inline: 3px; font-weight: 650; }
.chat-mentioned-label { display: inline-block; color: #086b63; font-size: 12px; font-weight: 700; margin-bottom: 8px; }
.chat-message[data-mentioned="true"] article { border-left: 3px solid #086b63; }
.chat-mention-controls { min-width: 0; }
.chat-mention-controls select,.chat-mention-controls input[type="text"] { width: 100%; box-sizing: border-box; padding: 10px 12px; min-height: 44px; border: 1px solid var(--line,#c9d3d7); border-radius: 8px; font: inherit; color: #142c3a; background: #fff; }
.chat-mention-options { max-height: 230px; overflow: auto; padding: 4px; margin-top: 6px; border: 1px solid #c9d3d7; border-radius: 8px; background: #fff; }
.chat-mention-options button { display: block; width: 100%; min-height: 44px; padding: 10px 12px; border: 0; border-radius: 6px; text-align: left; background: transparent; color: #142c3a; font: inherit; overflow-wrap: anywhere; }
.chat-mention-options button[aria-selected="true"] { background: #e4f1ed; color: #07564f; }
.chat-settings-panel+.chat-settings-panel { margin-top: 24px; }
.chat-page [hidden] { display: none !important; }
.chat-page select:focus-visible { outline: 3px solid #086b63; outline-offset: 3px; }
.chat-moderation-actions { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 24px; }
.chat-moderation-actions .chat-form { padding-top: 16px; border-top: 1px solid var(--line, #e5e5e5); }
.chat-page :is(a,button,input,textarea,summary):focus-visible { outline: 3px solid var(--reference-focus, #4338ca); outline-offset: 3px; }
@media (max-width: 800px) {
 .chat-layout { grid-template-columns: 220px minmax(0,1fr); }
 .chat-sidebar { padding: 20px 10px; }
 .chat-room-list a { font-size: 14px; padding: 10px; gap: 8px; }
 .chat-room-list a::before { width: 28px; height: 28px; }
 .chat-room-heading,.chat-composer-area { padding: 16px; }
 .chat-history { padding: 14px 16px 20px; }
 .chat-live-tools { padding-inline: 16px; flex-wrap: wrap; }
 .chat-room-heading { flex-wrap: wrap; gap: 6px 14px; }
 .chat-info summary { padding-inline: 16px; }
 .chat-info>div { padding-inline: 16px; }
 .chat-composer-footer { flex-wrap: wrap; }
}
@media (max-width: 650px) {
 .chat-page { padding-bottom: 24px; }
 .chat-heading { margin-bottom: 18px; }
 .chat-heading h1 { font-size: 28px; }
 .chat-heading p { font-size: 15px; }
 .chat-layout { display: block; min-height: 0; border-radius: 10px; }
 .chat-sidebar { display: none; }
 .chat-room-picker { display: block; width: 100%; border-bottom: 1px solid var(--line, #e5e5e5); padding-bottom: 8px; margin-bottom: 8px; }
 .chat-room-picker summary { min-height: 44px; padding: 10px 0; box-sizing: border-box; cursor: pointer; font-weight: 700; }
 .chat-room-picker .chat-room-list { padding: 8px 0; }
 .chat-room-picker .chat-room-list a { min-height: 50px; font-size: 16px; }
 .chat-room-heading { padding: 8px 16px 12px; }
 .chat-room-heading h2 { font-size: 18px; }
 .chat-room-heading>a { font-size: 14px; }
 .chat-history { min-height: 260px; }
 .chat-empty { min-height: 230px; padding: 26px 4px; }
 .chat-empty h3 { font-size: 20px; }
 .chat-history-tools { font-size: 13px; }
 .chat-message article { padding: 14px; }
 .chat-message-body { font-size: 16px; }
 .chat-reaction-picker { grid-template-columns: repeat(4,minmax(0,1fr)); }
 .chat-composer-footer { align-items: flex-start; flex-direction: column; }
 .chat-composer-footer button { width: 100%; }
 .chat-settings-panel,.chat-review-card { padding: 20px; }
 .chat-moderation-actions { grid-template-columns: 1fr; gap: 20px; }
 .chat-workspace-nav { gap: 8px 20px; }
}
.chat-mode-nav { display:flex; flex-wrap:wrap; gap:.5rem; margin-top:1rem; }
.chat-mode-nav a { display:inline-flex; align-items:center; min-height:44px; padding:0 .85rem; border:1px solid #bdcbc7; border-radius:.55rem; color:#203a45; }
.chat-mode-nav a[aria-current=page] { background:#142c3a; color:white; border-color:#142c3a; }
.chat-safety { margin-top:.6rem; font-size:.88rem; }
.chat-safety summary { cursor:pointer; padding:.45rem 0; }
.chat-safety form { display:flex; flex-wrap:wrap; align-items:center; gap:.5rem; margin:.5rem 0; }
.chat-safety select { max-width:100%; }
.chat-theme-choice { display:inline-flex; align-items:center; flex-wrap:wrap; gap:.5rem; font-size:.88rem; padding-inline:.5rem; }
.chat-theme-choice select { min-height:44px; padding:.3rem .5rem; border:1px solid var(--line); border-radius:.5rem; font:inherit; color:var(--ink); background:var(--chat-surface,#fff); }

html[data-chat-theme=dark] {
 color-scheme:dark;
 --ink:#e1edf1; --muted:#b2c6ce; --line:#48606d; --teal:#93ddd0; --pale:#284450;
 --reference-canvas:#12232b; --reference-focus:#93ddd0;
 --chat-surface:#1b2b34; --chat-raised:#243f4b;
 background:var(--reference-canvas);
}
[data-chat-theme=dark] body[data-page] :is(.reference-header,.reference-menu>summary,.reference-menu nav,.site-footer),
[data-chat-theme=dark] .chat-page :is(.chat-layout,.chat-room-heading,.chat-info,.chat-composer-area,.chat-settings-panel,.chat-review-card,.chat-message article,.chat-empty>span,.chat-mention-options),
[data-chat-theme=dark] .chat-image-dialog { background:var(--chat-surface); color:var(--ink); border-color:var(--line); }
[data-chat-theme=dark] body[data-page] .site-footer :is(p,.footer-note,.footer-groups a) { color:var(--muted); }
[data-chat-theme=dark] .chat-page a { color:var(--teal); }
[data-chat-theme=dark] .chat-page :is(.chat-conversation,.chat-live-tools,.chat-room-list a:hover,.chat-room-list a[aria-current=page],.chat-room-list a::before,.chat-reaction-picker,.chat-reaction-count,.chat-avatar,.chat-reply-preview,.chat-compose-context,.chat-notice,.chat-image-preview,.chat-image img,.chat-mention,.chat-mention-options button[aria-selected=true]) { background:var(--chat-raised); color:var(--ink); border-color:var(--line); }
[data-chat-theme=dark] .chat-page :is(.chat-live-tools p,.chat-info p,.chat-reactions summary,.chat-character-count,.chat-badge) { color:var(--muted); }
[data-chat-theme=dark] .chat-page :is(input,textarea,select,.chat-reaction-picker button,.chat-live-tools button,.chat-image-preview button,.chat-mention-options button) { color:var(--ink); background:var(--chat-surface); border-color:var(--line); }
[data-chat-theme=dark] .chat-page :is(.chat-mode-nav a[aria-current=page],.chat-form button:not(.chat-withdraw button,.chat-reaction-picker button)) { color:#12232b; background:#a4ded3; border-color:#a4ded3; }
[data-chat-theme=dark] .chat-page .chat-notice[role=alert] { color:#ffdab1; background:#4a3027; }
[data-chat-theme=dark] .chat-page :is(.chat-character-count[data-over-limit=true],.chat-error) { color:#ffdab1; }
[data-chat-theme=dark] .chat-page :is(.chat-mentioned-label,.chat-presence,.chat-withdraw button) { color:var(--teal); }
