.chat-mode .hero,.chat-mode #summary,.chat-mode #focus-scope-note{display:none}
@media(min-width:701px){body .topbar{grid-template-columns:auto 44px minmax(0,1fr) auto;gap:clamp(8px,1.2vw,18px)}}
.topbar #mode-chat{position:relative;flex:0 0 44px;width:44px;min-height:44px;padding:10px;display:flex;align-items:center;justify-content:center;border:1px solid var(--line,#e2e4e7);border-radius:12px;background:var(--soft,#f4f5f6);color:var(--ink,#34373b)}
.topbar #mode-chat .chat-icon{display:block;width:22px;height:22px;flex-shrink:0}
#chat-badge{position:absolute;right:-5px;top:-6px;min-width:20px;padding:2px 5px;border-radius:12px;font-size:11px;line-height:16px;background:#a95560;color:#fff}
#chat-badge[hidden],#chat-view[hidden],#chat-people[hidden],#chat-more[hidden],#chat-upload-preview[hidden]{display:none!important}
#chat-view{display:grid;grid-template-columns:270px minmax(0,1fr);border:1px solid var(--line,#e2e4e7);border-radius:16px;background:var(--panel,#fff);overflow:hidden;min-height:520px;height:min(760px,calc(100dvh - 160px));margin:12px 0}
#chat-sidebar{padding:16px;border-right:1px solid var(--line,#e2e4e7);overflow:auto;min-width:0}
.chat-sidebar-heading,.chat-room-heading{display:flex;align-items:center;gap:12px;justify-content:space-between}
#chat-sidebar h2,#chat-room-title{font-size:18px;margin:0}
#chat-sidebar label{display:block;font-size:12px;color:var(--muted,#737980);margin:16px 0 6px}
#chat-search{box-sizing:border-box;width:100%;min-width:0;border:1px solid var(--line,#e2e4e7);border-radius:10px;padding:10px;background:var(--soft,#f4f5f6);font:inherit;color:var(--ink,#34373b)}
#chat-rooms h3,#chat-people h3{font-size:12px;color:var(--muted,#737980);margin:18px 0 8px}
#chat-rooms button,#chat-people button{width:100%;box-sizing:border-box;display:flex;align-items:center;justify-content:space-between;gap:8px;text-align:left;background:transparent;color:var(--ink,#34373b);border:0;box-shadow:none;padding:12px 8px;font-size:14px;border-radius:10px;overflow-wrap:anywhere}
#chat-rooms button.chat-active{background:var(--hover,#e9ebed)}
.chat-unread{flex-shrink:0;background:#a95560;color:#fff;border-radius:12px;padding:1px 6px;font-size:11px}
#chat-conversation{display:flex;flex-direction:column;min-width:0;min-height:0}
.chat-room-heading{padding:14px 18px;border-bottom:1px solid var(--line,#e2e4e7);flex:0 0 auto;justify-content:flex-start}
.chat-room-heading>div{flex:1;min-width:0;overflow-wrap:anywhere}
#chat-room-note{font-size:12px;color:var(--muted,#737980);margin:4px 0 0}
#chat-back{display:none}
#chat-messages{display:flex;flex-direction:column;gap:12px;flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;padding:18px;background:var(--soft,#f4f5f6);scrollbar-gutter:stable}
#chat-messages .chat-message{position:relative;flex-shrink:0;align-self:flex-start;max-width:85%;min-width:160px;background:var(--panel,#fff);padding:10px 13px 7px;border:1px solid var(--line,#e2e4e7);border-radius:15px 15px 15px 4px;overflow-wrap:anywhere}
#chat-messages .chat-mine{align-self:flex-end;background:#e8ecea;border-radius:14px 14px 4px 14px}
.chat-message p{font-size:14px;line-height:1.5;white-space:pre-wrap;margin:5px 0 8px;font-weight:400}
.chat-message small,.chat-message time{display:block;font-size:11px;color:var(--muted,#737980)}
.chat-message time{text-align:right;margin-top:6px}
.chat-receipt{display:inline-block;margin-left:3px;font-size:13px;font-weight:600;color:#818b87;letter-spacing:-3px;padding-right:3px}
.chat-receipt-read{color:#397ba1}
#chat-messages .chat-message-author{font-size:12px;font-weight:500;text-align:left;line-height:1.5}
#chat-messages .chat-mine .chat-message-author{padding-right:32px}
.chat-message img,.chat-message video{display:block;max-width:100%;max-height:280px;border-radius:8px}
.chat-message audio{display:block;max-width:100%;width:280px;margin:6px 0}
.chat-message .chat-video-download{display:inline-flex;align-items:center;gap:7px;min-height:44px;max-width:100%;margin-top:6px;padding:0 10px;border:1px solid var(--line,#e2e4e7);border-radius:8px;color:var(--ink,#34373b);background:var(--panel,#fff);text-decoration:none;font-size:13px;box-sizing:border-box}
.chat-message .chat-video-download:hover{background:var(--hover,#e9ebed)}
.chat-message .chat-video-download:focus-visible{outline:2px solid currentColor;outline-offset:2px}
.chat-expired{font-size:12px;color:var(--muted,#737980)}
#chat-compose{display:flex;align-items:center;gap:8px;padding:12px 14px 6px;flex:0 0 auto}
#chat-compose textarea{flex:1;width:100%;min-width:0;box-sizing:border-box;border:1px solid var(--line,#e2e4e7);border-radius:10px;background:var(--soft,#f4f5f6);color:var(--ink,#34373b);padding:10px;resize:vertical;font:inherit;max-height:180px}
#chat-compose button{font-size:13px;padding:10px;min-width:40px;flex-shrink:0}
#chat-status,.chat-retention,#chat-upload-preview{padding:0 16px;margin:4px 0 8px;font-size:12px;color:var(--muted,#737980)}
#chat-upload-preview{display:flex;align-items:center;flex-wrap:wrap;gap:8px;overflow-wrap:anywhere}
#chat-messages .chat-message-menu{position:absolute;top:3px;right:3px;z-index:2}
#chat-messages .chat-message-menu[open]{z-index:3}
#chat-messages .chat-message-menu summary{display:flex;align-items:center;justify-content:center;width:32px;height:30px;list-style:none;border-radius:8px;color:var(--muted,#737980);font:400 22px/1 Arial,sans-serif;cursor:pointer}
#chat-messages .chat-message-menu summary::-webkit-details-marker{display:none}
#chat-messages .chat-message-menu summary:hover,#chat-messages .chat-message-menu[open] summary{background:var(--hover,#e9ebed)}
#chat-messages .chat-message-menu summary:focus-visible{outline:2px solid currentColor;outline-offset:2px}
#chat-messages .chat-message-actions{position:absolute;right:0;top:32px;display:flex;flex-direction:column;gap:0;min-width:145px;padding:4px;border:1px solid var(--line,#e2e4e7);border-radius:10px;background:var(--panel,#fff);box-shadow:0 5px 15px #00000018}
#chat-messages .chat-message-menu:not([open]) .chat-message-actions{display:none!important}
#chat-messages .chat-message-menu.chat-menu-above .chat-message-actions{top:auto;bottom:32px}
#chat-messages .chat-message-actions button{display:block;width:100%;text-align:left;background:transparent;color:var(--ink,#34373b);border:0;box-shadow:none;padding:8px 10px;font:400 13px/1.5 Arial,sans-serif;min-height:36px;border-radius:6px;white-space:nowrap}
#chat-messages .chat-message-actions button:hover{background:var(--hover,#e9ebed)}
#chat-messages .chat-message-actions [data-chat-delete]{color:#a24f48}
@media(pointer:coarse){#chat-messages .chat-message-menu summary{width:44px;height:44px}#chat-messages .chat-mine .chat-message-author{padding-right:44px}#chat-messages .chat-message-actions{top:44px}#chat-messages .chat-message-menu.chat-menu-above .chat-message-actions{top:auto;bottom:44px}#chat-messages .chat-message-actions button{min-height:44px}}
#chat-edit-cancel[hidden]{display:none!important}
@media(max-width:700px){.topbar #mode-chat{margin-right:auto}.topbar .top-view-switch{flex-basis:100%;order:3}#chat-view{grid-template-columns:minmax(0,1fr);height:calc(100dvh - 210px);min-height:400px}#chat-sidebar{display:none;border-right:0}#chat-back{display:block}#chat-view.chat-show-list #chat-sidebar{display:block}#chat-view.chat-show-list #chat-conversation{display:none}#chat-search,#chat-compose textarea{font-size:16px}#chat-compose{gap:4px;padding:8px 6px}#chat-compose button{padding:8px;font-size:12px}#chat-messages{padding:10px}.chat-room-heading{padding:10px}#chat-messages .chat-message{max-width:95%}}

#chat-messages .chat-message-author{padding-right:32px}
#chat-messages .chat-message-actions .chat-file-download{display:block;box-sizing:border-box;width:100%;padding:10px 12px;min-height:40px;border:0;border-radius:7px;background:transparent;color:var(--ink,#34373b);text-decoration:none;font-size:13px;line-height:20px;text-align:left}
#chat-messages .chat-message-actions .chat-file-download:hover{background:var(--hover,#e9ebed)}
#chat-messages .chat-message-actions .chat-file-download:focus-visible{outline:2px solid currentColor;outline-offset:-2px}

#chat-photo-viewer{width:100vw;height:100dvh;max-width:100vw;max-height:100dvh;margin:0;padding:0;border:0;border-radius:0;background:#f2f3f5;color:#34373b;overflow:hidden;box-sizing:border-box}
#chat-photo-viewer[open]{display:flex;flex-direction:column}#chat-photo-viewer::backdrop{background:#0008}
#chat-photo-viewer .chat-photo-toolbar{display:flex;align-items:center;gap:12px;flex-shrink:0;padding:max(12px,env(safe-area-inset-top)) 14px 12px;background:#fff;border-bottom:1px solid #dde1e5}
#chat-photo-viewer .chat-photo-toolbar button{min-height:44px;min-width:44px;padding:8px 14px;border:1px solid #d9dfe4;border-radius:12px;background:#eef0f2;color:#34373b;font:600 16px system-ui,sans-serif}
#chat-photo-viewer .chat-photo-toolbar a{margin-left:auto;color:#526475;font:14px system-ui,sans-serif;padding:12px 4px}
#chat-photo-viewer .chat-photo-image{display:block;flex:1;min-height:0;min-width:0;width:100%;height:100%;object-fit:contain;padding:8px 8px max(8px,env(safe-area-inset-bottom));box-sizing:border-box}
#chat-photo-viewer .chat-photo-status{flex-shrink:0;margin:0;padding:4px 14px;font:13px/1.5 system-ui,sans-serif;color:#717b85}#chat-photo-viewer .chat-photo-status:empty{display:none}

#chat-compose[hidden]{display:none!important}

body.chat-mode #chat-view{touch-action:pan-y}@media(max-width:700px){body.chat-mode #chat-search,body.chat-mode #chat-text{font-size:16px}}
#chat-photo-viewer{touch-action:none}#chat-photo-viewer .chat-photo-toolbar{position:relative;z-index:2}
#chat-photo-viewer .chat-photo-viewport{flex:1;min-height:0;position:relative;overflow:hidden;touch-action:none}
#chat-photo-viewer .chat-photo-image{width:100%;height:100%;padding:8px;transform-origin:center;will-change:transform;touch-action:none}
#chat-photo-viewer .chat-photo-zoom-controls{position:absolute;z-index:1;right:12px;bottom:max(12px,env(safe-area-inset-bottom));display:flex;gap:4px;padding:4px;border-radius:12px;background:#ffffffeb;box-shadow:0 2px 8px #0002}
#chat-photo-viewer .chat-photo-zoom-controls button{min-height:44px;min-width:44px;padding:6px;border:1px solid #d9dfe4;border-radius:8px;background:#eef0f2;color:#34373b;font:14px system-ui,sans-serif}

.chat-avatar{display:inline-flex;align-items:center;justify-content:center;flex:none;vertical-align:middle;width:30px;height:30px;margin-right:8px;border-radius:50%;overflow:hidden;background:#dde3e8;color:#566573;font:600 11px system-ui}
#chat-messages .chat-avatar img,.chat-avatar img{display:block;width:100%;height:100%;object-fit:cover;border-radius:50%}
.chat-room-label{display:flex;align-items:center;min-width:0}
#chat-messages .chat-reply-quote{display:block;max-width:100%;width:100%;margin:8px 0;padding:7px 10px;border:0;border-left:3px solid #879fae;border-radius:6px;background:#ffffff80;color:#566573;text-align:left;box-shadow:none;font:12px/1.4 system-ui;white-space:normal;overflow-wrap:anywhere}
.chat-reply-quote b,.chat-reply-quote span{display:block}.chat-reply-quote span{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
#chat-reply-preview{display:flex;gap:8px;align-items:center;padding:8px 14px;background:#e8edf0;border-top:1px solid #dce2e7;font-size:13px;flex-shrink:0}
#chat-reply-preview[hidden],#focus-avatar-crop[hidden]{display:none!important}#chat-reply-preview-text{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#chat-reply-preview button{min-width:44px;min-height:44px;padding:4px}
#chat-messages .chat-reply-highlight{outline:2px solid #7390a5;outline-offset:2px}
#focus-my-profile{display:block;margin:12px 16px;min-height:44px;text-align:left}
.focus-avatar-panel{border-top:1px solid #dde2e6;padding-top:12px;margin-top:14px}.focus-avatar-panel h3{margin:0 0 12px}.focus-avatar-panel p{font-size:12px;color:#747d84}
#focus-avatar-current .chat-avatar{width:72px;height:72px;font-size:22px;margin:0 0 12px}.focus-avatar-actions{display:flex;gap:8px;flex-wrap:wrap}.focus-avatar-panel button{min-height:44px}
#focus-avatar-canvas{display:block;width:160px;height:160px;border-radius:50%;margin:14px auto}#focus-avatar-crop label{display:block;margin:10px 0}#focus-avatar-crop input{max-width:100%}

#chat-messages .chat-reaction-picker{display:grid;grid-template-columns:repeat(4,44px);gap:2px;padding:3px;border-bottom:1px solid #e1e5e8;margin-bottom:4px}
#chat-messages .chat-reaction-picker button{display:flex;align-items:center;justify-content:center;width:44px;min-height:44px;padding:0;font-size:22px;border:1px solid transparent}
#chat-messages .chat-reaction-picker button[aria-pressed=true]{background:#dce6ee;border-color:#a2b8c9}
#chat-messages .chat-reactions{display:flex;flex-wrap:wrap;gap:5px;margin-top:8px}
#chat-messages .chat-reactions button{display:inline-flex;align-items:center;gap:5px;min-height:34px;padding:4px 9px;border:1px solid #d6dee4;border-radius:18px;box-shadow:none;background:#f3f5f6;color:#576674;font:13px system-ui}
#chat-messages .chat-reactions button span:first-child{font-size:18px}
#chat-messages .chat-reactions button[aria-pressed=true]{background:#dae6ef;border-color:#90afc4;color:#375b76}
#chat-messages .chat-reactions button:focus-visible,#chat-messages .chat-reaction-picker button:focus-visible{outline:2px solid #7596ae;outline-offset:2px}
@media(pointer:coarse){#chat-messages .chat-reactions button{min-height:44px}}

/* Names and decorative markers share a center line, not an inline baseline. */
#chat-sidebar #chat-rooms button,#chat-sidebar #chat-people button{align-items:center}
#chat-sidebar #chat-rooms .chat-room-label,#chat-sidebar #chat-people .chat-room-label{display:flex;flex-direction:row;align-items:center;justify-content:flex-start;gap:8px;min-width:0;flex:1;text-align:left;line-height:1.35}
#chat-sidebar .chat-room-label>svg{display:block;flex-shrink:0;align-self:center;margin:0!important;vertical-align:initial}
#chat-sidebar .chat-room-label>.chat-avatar{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;align-self:center;margin:0;vertical-align:initial}
#chat-sidebar #chat-rooms .chat-unread{align-self:center;flex-shrink:0}

/* Attachment progress only; do not alter chat layout or other controls. */
#focus-chat-upload-progress[hidden]{display:none!important}
#focus-chat-upload-progress{box-sizing:border-box;flex-shrink:0;min-width:0;width:100%;margin:8px 0;padding:10px 12px;border:1px solid #c8cdd2;border-radius:12px;background:#f0f2f4;color:#3d444a;text-align:left;font-size:14px;line-height:1.4;overflow-wrap:anywhere}
#focus-chat-upload-progress .focus-chat-upload-label{display:block;font-weight:600}
#focus-chat-upload-progress progress{display:block;box-sizing:border-box;width:100%;height:9px;margin:7px 0;accent-color:#687681;border:0;border-radius:8px;overflow:hidden}
#focus-chat-upload-progress progress::-webkit-progress-bar{background:#d9dee2;border-radius:8px}
#focus-chat-upload-progress progress::-webkit-progress-value{background:#687681;border-radius:8px}
#focus-chat-upload-progress progress::-moz-progress-bar{background:#687681;border-radius:8px}
#focus-chat-upload-progress small{display:block;color:#59636c;font-size:12px}
#focus-chat-upload-progress[data-phase="error"]{border-color:#b96a6a}
#focus-chat-upload-progress[data-phase="error"] .focus-chat-upload-label{color:#8a3636}
