/* Room actions keep their reading order at every screen width. */
.chat-room-header .chat-room-actions{display:flex;flex-direction:row;flex-wrap:nowrap;align-items:center;gap:7px;flex-shrink:0}
.chat-room-header .chat-room-more{display:flex;align-items:center;justify-content:center;width:30px;height:32px;padding:6px;border:1px solid #d8e1ec;border-radius:8px;background:#fff;color:#52657d;cursor:pointer}
.chat-room-header .chat-room-more:hover{background:#f1f5fa;border-color:#bdcddd}
.chat-room-header .chat-room-more:focus-visible{outline:2px solid #3974bd;outline-offset:2px}
.chat-room-actions .chat-leave{white-space:nowrap}
.chat-composer .chat-composer-note{display:block;text-align:left;line-height:1.6;overflow-wrap:anywhere}
.chat-date-separator{display:flex;align-items:center;justify-content:center;gap:12px;width:100%;margin:20px 0 14px;color:#6b7280;font-size:11px;line-height:1.5}
.chat-date-separator::before,.chat-date-separator::after{content:"";height:1px;flex:1;background:#e5e9ef}
.chat-date-separator time{white-space:nowrap}
.chat-preference-note{margin:0;padding:7px 16px;color:#58677b;background:#f1f5fa;font-size:11px;border-bottom:1px solid #e4eaf1}
.chat-preference-note[hidden]{display:none}

/* Only the result area scrolls; network and result states cannot resize the dialog. */
.chat-records-dialog{width:min(760px,calc(100vw - 24px));height:min(650px,calc(100dvh - 32px));max-width:calc(100vw - 24px);max-height:calc(100dvh - 32px);padding:20px;margin:auto;border:1px solid #dce4ee;box-sizing:border-box;overflow:hidden}
.chat-records-dialog[open]{display:flex;flex-direction:column;gap:12px}
.chat-records-dialog::backdrop{background:rgba(15,23,42,.52);backdrop-filter:blur(3px)}
.chat-records-dialog> :not(.chat-records-content){flex-shrink:0}
.chat-records-header{display:flex;align-items:center;justify-content:space-between;gap:12px;min-width:0}
.chat-records-dialog .chat-records-header h2{margin:0;min-width:0;font-size:18px;line-height:1.4}
.chat-records-dialog .chat-records-close{display:flex;align-items:center;justify-content:center;flex:none;width:32px;height:32px;min-width:32px;min-height:32px;padding:0;border:0;border-radius:8px;background:#eef2f7;color:#475569;line-height:1;cursor:pointer;box-sizing:border-box}
.chat-records-close svg{display:block;width:18px;height:18px;flex:none;pointer-events:none;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round}
.chat-records-close:hover{background:#e2e9f2}
.chat-records-close:focus-visible{outline:2px solid #3974bd;outline-offset:2px}
.chat-records-search{display:flex;gap:8px;margin:0;width:100%;min-width:0;align-items:stretch}
.chat-records-search input{min-width:0;flex:1;width:100%;box-sizing:border-box;margin:0}
.chat-records-search button{flex-shrink:0;margin:0}
.chat-records-content{position:relative;flex:1 1 0;min-height:0;min-width:0;overflow:hidden}
.chat-records-list{height:100%;min-height:0;min-width:0;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable;display:flex;flex-direction:column;gap:8px;padding:1px 2px 2px;box-sizing:border-box}
.chat-records-list> *{flex-shrink:0}
.chat-search-result{display:flex;flex-direction:column;gap:6px;width:100%;text-align:left;border:1px solid #e3e9f1;background:#f9fbfd;border-radius:10px;padding:12px;cursor:pointer;color:#263447;box-sizing:border-box}
.chat-search-result:hover,.chat-search-result:focus-visible{border-color:#93b4dd;background:#f0f6ff}
.chat-search-result small{color:#718096;font-size:11px}
.chat-search-result>span{font-size:13px;white-space:pre-wrap;overflow-wrap:anywhere;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:5;overflow:hidden}
.chat-search-result mark,.chat-message mark,.chat-attachment-record mark{background:#fff1a6;color:inherit;border-radius:2px}
.chat-records-dialog .chat-records-status{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:24px;color:#718096;font-size:12px;line-height:1.7;margin:0;text-align:center;box-sizing:border-box;pointer-events:none;overflow-wrap:anywhere}
.chat-records-dialog .chat-records-status:empty{display:none}
.chat-records-filters{display:flex;gap:6px;flex-wrap:wrap}
.chat-records-filters button{padding:6px 12px;border:1px solid #dfe6ef;border-radius:8px;background:#fff;color:#5b6d83;font-size:12px;cursor:pointer}
.chat-records-filters button[aria-pressed="true"]{background:#e8f0fc;color:#245da9;border-color:#bad0ee}
.chat-records-dialog>[data-records-more]{align-self:center;min-height:34px;font-size:12px;padding:7px 14px}
.chat-records-dialog>[data-records-more][hidden]{display:none}
.chat-records-dialog>.chat-error{max-height:54px;overflow:auto}

/* Attachment history is grouped by day and uses the same compact tiles for every file. */
.chat-attachment-date-group{min-width:0;margin:0 0 12px}
.chat-attachment-date{margin:0 0 10px;padding:7px 1px;color:#58677b;font-size:12px;font-weight:650;line-height:1.4;border-bottom:1px solid #e6ecf3}
.chat-attachment-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;align-items:stretch;min-width:0}
.chat-attachment-record{padding:0;border:1px solid #e0e7ef;border-radius:10px;display:flex;flex-direction:column;min-width:0;height:216px;overflow:hidden;background:#f9fbfd;box-sizing:border-box}
.chat-attachment-record .chat-file{width:100%;max-width:100%;min-width:0;min-height:0;flex:1 1 0;border:0;border-radius:0;background:#eff4fa;display:flex;flex-direction:column;overflow:hidden}
.chat-attachment-record .chat-image-file{width:100%;max-width:100%;margin:0;padding:0}
.chat-attachment-record .chat-image-preview{width:100%;height:100%;min-height:0;max-height:none;max-width:none;aspect-ratio:auto;border-radius:0;flex:1 1 0;display:block}
.chat-attachment-record .chat-image-preview img{width:100%;height:100%;max-width:none;max-height:none;object-fit:cover}
.chat-attachment-record .chat-file-link{min-width:0;max-width:100%;min-height:0;padding:10px;flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;text-align:center;box-sizing:border-box}
.chat-attachment-record .chat-file-link>span:last-child{max-width:100%}
.chat-attachment-record .chat-file-link strong{overflow-wrap:anywhere;font-size:11px;line-height:1.4;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.chat-attachment-record .chat-file-icon{width:36px;height:40px;font-size:26px}
.chat-attachment-record .chat-file-expiry{text-align:center;padding:0 7px 7px;font-size:9px;line-height:1.3}
.chat-attachment-meta{padding:9px 10px;min-width:0;min-height:49px;max-height:72px;box-sizing:border-box;overflow:hidden;line-height:1.4;background:#fff}
.chat-attachment-meta strong,.chat-attachment-meta small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chat-attachment-meta strong{font-size:11px;font-weight:600;color:#3f526b}
.chat-attachment-meta small{font-size:10px;color:#718096;margin-top:3px}
.chat-attachment-meta button{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:10px}
.chat-attachment-record.is-expired{background:#f0f2f5;color:#8290a0}

/* Personal room labels and indicators share the same layout on the first page and live updates. */
.chat-pinned-section{min-width:0;margin:0;padding:0}
.chat-pinned-section[hidden]{display:none}
.chat-pinned-section>.chat-list-heading{color:#426fa8}
.chat-pinned{min-width:0}
.chat-conversation .chat-conversation-title{display:flex;align-items:center;gap:6px;min-width:0;flex:1;overflow:hidden}
.chat-conversation-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chat-room-icons{display:inline-flex;align-items:center;justify-content:center;gap:4px;flex:none;vertical-align:middle;color:#6b7d93}
.chat-room-icons:empty{display:none}
.chat-room-icon{display:block;width:14px;height:14px;flex:none;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.chat-room-icon[data-room-icon="pin"]{color:#3e70ad}
.chat-conversation-title .chat-member-total{flex:none}
.chat-conversation .communication-count{flex:none}
.chat-room-header>div:first-child>strong{display:flex;align-items:center;gap:6px;min-width:0}
.chat-room-header [data-chat-room-name]{min-width:0;overflow-wrap:anywhere}
.chat-room-header [data-chat-room-icons],.chat-room-header .chat-member-total{flex:none}

/* The glyph stays geometrically centered in the existing attachment-chip hover target. */
.chat-file-chip>button{display:flex;align-items:center;justify-content:center;padding:0;box-sizing:border-box}
.chat-file-chip>button svg{display:block;width:14px;height:14px;flex:none;pointer-events:none;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}

.chat-rename-dialog{width:min(440px,calc(100vw - 28px));max-height:calc(100dvh - 32px);margin:auto;overflow:auto;box-sizing:border-box}
.chat-rename-dialog::backdrop{background:rgba(15,23,42,.52);backdrop-filter:blur(3px)}
.chat-rename-dialog form{margin:0}
.chat-rename-dialog .chat-rename-note{color:#66788f;font-size:12px;line-height:1.6;margin:0 0 18px;overflow-wrap:anywhere}
.chat-rename-dialog label{display:block;margin:0 0 7px;color:#3d5069;font-size:12px;font-weight:650;text-align:left}
.chat-rename-dialog input{width:100%;min-width:0;margin:0;box-sizing:border-box;font-size:13px}
.chat-rename-dialog .chat-error{color:#b42318;font-size:12px;margin-top:12px}
.chat-rename-dialog .app-dialog-actions{margin-top:20px}
.chat-rename-dialog .app-dialog-actions .button{margin:0}

@media(max-width:600px){
 .chat-room-header{gap:8px}
 .chat-room-header>div:first-child{min-width:0}
 .chat-room-header>div:first-child>strong{overflow-wrap:anywhere}
 .chat-room-header .chat-room-actions{flex-direction:row;align-items:center;gap:4px}
 .chat-room-actions .chat-leave{padding:5px 6px;font-size:10px}
 .chat-composer .chat-composer-note{font-size:9px}
 .chat-records-dialog{padding:14px;gap:10px}
 .chat-records-dialog .chat-records-header h2{font-size:16px}
 .chat-records-search input{font-size:12px}
 .chat-records-search button{padding:8px;font-size:11px}
 .chat-records-filters{gap:5px}
 .chat-records-filters button{font-size:11px;padding:6px 9px}
 .chat-attachment-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
 .chat-attachment-record{height:204px}
 .chat-date-separator{font-size:10px}
 .chat-rename-dialog{padding:20px}
}

/* Membership events remain distinct from messages sent by a participant. */
.chat-message.chat-system-message{align-self:stretch;display:block;width:100%;max-width:100%;margin:12px 0;text-align:center;box-sizing:border-box;color:#718096}
.chat-system-text{display:inline-block;max-width:92%;margin:0;padding:7px 13px;border-radius:12px;background:#edf1f6;color:#64748b;font-size:11px;line-height:1.65;overflow-wrap:anywhere;white-space:pre-wrap}
.chat-system-message>time{display:block;margin-top:4px;font-size:10px;color:#8b98aa}
.chat-rooms{min-width:0}
