.chat-shell{display:grid;grid-template-columns:minmax(190px,30%) minmax(0,1fr);gap:12px;min-width:0}.chat-sidebar,.chat-room{min-width:0}.chat-sidebar{border-right:1px solid var(--line);padding-right:12px}.chat-sidebar input,.chat-tools input{max-width:100%}.chat-list{display:grid;gap:4px;margin:10px 0;max-height:55dvh;overflow:auto}.chat-list button{display:flex;align-items:center;gap:8px;text-align:left;width:100%;overflow-wrap:anywhere}.chat-avatar{flex:none;width:34px;height:34px;display:grid;place-items:center;border-radius:50%;background:var(--bg);color:var(--ink);font-size:12px}.chat-selected{background:var(--bg);border-color:var(--accent)}.chat-unread{margin-left:auto;background:var(--accent);color:white;border-radius:20px;padding:3px 7px}.chat-room{display:flex;flex-direction:column;gap:8px}.chat-head{padding:8px;border-bottom:1px solid var(--line)}.chat-head p{margin:4px 0;overflow-wrap:anywhere}.chat-feed{display:flex;flex-direction:column;gap:8px;height:clamp(240px,48dvh,650px);overflow:auto;background:var(--bg);border-radius:16px;padding:12px;overscroll-behavior:contain}.chat-feed .bubble{align-self:flex-start;background:var(--panel);max-width:88%;padding:9px 12px;margin:0}.chat-feed .outgoing{align-self:flex-end;background:color-mix(in srgb,var(--accent) 16%,var(--panel))}.chat-feed .bubble p{margin:5px 0;white-space:pre-wrap}.chat-feed small{display:block;font-size:11px;opacity:.85}.chat-feed audio{max-width:100%;width:250px}.chat-actions{margin-top:5px}.chat-actions summary,.chat-tools summary,.chat-sidebar summary{cursor:pointer;font-size:13px;padding:6px}.chat-actions button,.chat-actions select,.chat-tools button{font-size:12px;padding:6px 9px}.chat-composer{display:flex;flex-wrap:wrap;gap:5px;align-items:center}.chat-composer .field{flex:1 0 100%;margin:0;font-size:0}.chat-composer textarea{font-size:16px;min-height:48px;max-height:120px;resize:vertical}.chat-composer p:empty{display:none}.chat-composer p{margin:0;font-size:12px}.chat-composer button{font-size:13px;padding:8px}.chat-back{display:none}.chat-tools{border:1px solid var(--line);border-radius:10px;padding:4px 8px}.chat-tools[open]{max-height:30dvh;overflow:auto}.chat-sidebar details{overflow-wrap:anywhere}.chat-sidebar select{max-width:100%}
@media(max-width:700px){.chat-shell{display:block!important;padding:10px!important}.chat-sidebar{border:0;padding:0}.chat-shell:not(.chat-open) .chat-room{display:none}.chat-open .chat-sidebar{display:none}.chat-back{display:inline-block}.chat-feed{height:clamp(160px,42dvh,500px);padding:8px}.chat-composer input[type=file]{width:100%;font-size:12px}.chat-list{max-height:65dvh}.chat-room{min-width:0}}

/* Compact chat controls */
.chat-head{position:relative;padding-right:52px}.chat-head .chat-tools{position:absolute;right:6px;top:4px;padding:0;border:0;z-index:8;overflow:visible;max-height:none}.chat-tools summary,.chat-actions summary{list-style:none;text-align:center}.chat-tools summary::-webkit-details-marker,.chat-actions summary::-webkit-details-marker{display:none}.chat-tools>summary{font-size:24px;width:40px;height:40px;display:grid;place-items:center;padding:0}.chat-tool-body{position:absolute;right:0;top:42px;width:min(340px,75vw);max-height:55dvh;overflow:auto;background:var(--panel);color:var(--ink);border:1px solid var(--line);border-radius:12px;padding:12px;box-shadow:0 8px 24px #0003}.chat-actions{margin:0}.chat-actions>summary{width:32px;height:28px;padding:0;display:grid;place-items:center;font-size:18px;margin-left:auto}.chat-composer input[type=file][hidden]{display:none!important}.chat-composer .field{flex:1 1 100px;min-width:0;order:2}.chat-composer .chat-icon{flex:none;width:42px;height:42px;padding:0;display:grid;place-items:center;border-radius:50%;font-size:26px}.chat-attach{order:1}.chat-voice{order:3}.chat-send{order:4}.chat-voice.recording{background:#b91c1c!important;color:white!important}.chat-composer>p{flex:1 0 100%;order:0}.chat-composer>button:not(.chat-icon),.chat-composer>details{order:5}.chat-composer textarea{width:100%;box-sizing:border-box}.chat-composer .chat-icon:focus-visible,.chat-tools summary:focus-visible,.chat-actions summary:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
/* Refined chat layout: scoped overrides for Classic and Premium. */
html .chat-shell{grid-template-columns:minmax(170px,25%) minmax(0,1fr);gap:10px}
html[data-interface] main>.chat-shell{padding:14px}
html .chat-feed{gap:4px;height:clamp(220px,calc(100dvh - 265px),1100px);padding:8px}
html .chat-feed .bubble{position:relative;width:fit-content;max-width:85%;padding:7px 30px 7px 10px;border-radius:12px;flex:none}
html .chat-feed .bubble p{margin:2px 0;overflow-wrap:anywhere}
html .chat-feed .chat-actions{position:absolute;right:3px;top:3px;margin:0;padding:0;border:0;background:transparent;box-shadow:none;border-radius:0}
html .chat-feed .chat-actions>summary{width:24px;height:24px;padding:0;font-size:16px;line-height:1}
.chat-action-menu{position:fixed;z-index:45;width:210px;max-width:calc(100vw - 16px);max-height:min(60dvh,420px);overflow:auto;background:var(--panel);color:var(--ink);border:1px solid var(--line);border-radius:12px;padding:5px;box-shadow:0 6px 22px #0003}
html .chat-action-menu button,html .chat-action-menu select{display:block;width:100%;text-align:left;min-height:34px;margin:0;padding:6px 9px;border:0;border-radius:6px;background:var(--panel);color:var(--ink);font-size:13px}
html .chat-action-menu button:hover{background:var(--bg)}
html .chat-composer{display:grid;grid-template-columns:42px minmax(0,1fr) 42px 42px;gap:5px;align-items:end}
html .chat-composer .field{grid-column:2;grid-row:2;margin:0;min-width:0}
html .chat-composer textarea{margin:0;min-height:42px;height:42px;max-height:120px;padding:9px 12px;resize:none;overflow-y:auto}
html .chat-composer .chat-attach{grid-column:1;grid-row:2}html .chat-composer .chat-voice{grid-column:3;grid-row:2}html .chat-composer .chat-send{grid-column:4;grid-row:2}
html .chat-composer .chat-icon{margin:0;min-height:42px}
html .chat-composer>p{grid-column:1/4;grid-row:1;min-width:0;overflow-wrap:anywhere;border-left:3px solid var(--accent);padding:5px 8px;background:var(--bg);border-radius:6px}
html .chat-composer>p:empty{display:none}
html .chat-composer .chat-cancel-reply{grid-column:4;grid-row:1;min-height:30px;padding:2px;margin:0;font-size:20px}
html .chat-composer:has(>p:empty) .chat-cancel-reply{display:none}
@media(max-width:700px){html .chat-feed{height:clamp(160px,calc(100dvh - 330px),650px)}html .chat-feed .bubble{max-width:92%}html .chat-feed .chat-actions>summary{width:26px;height:28px}}
html .chat-composer .field{font-size:0}html .chat-composer .field textarea{font-size:16px}

.chat-direct-heading{display:flex;align-items:center;justify-content:space-between;gap:8px}.chat-direct-heading h2{margin:0}.chat-direct-icon{width:36px;height:36px;padding:0!important;font-size:22px}.chat-direct-list{max-height:260px;overflow:auto}.chat-direct-person{display:flex;align-items:center;gap:8px;width:100%;text-align:left;margin:4px 0}.chat-direct-person span:last-child{margin-left:auto;font-size:.75rem}.chat-direct-directory{margin-top:8px}

.chat-inline-image{display:block;max-width:min(100%,240px);max-height:200px;object-fit:contain;cursor:zoom-in;border-radius:8px}.chat-file-detail{display:block;overflow-wrap:anywhere}.chat-media-dialog{width:min(94vw,900px);max-height:90dvh;overflow:auto}.chat-media-scroll{overflow:auto;max-height:65dvh}.chat-media-scroll img{width:100%;max-width:none;height:auto}.chat-media-dialog iframe{width:100%;height:65dvh;border:0}.chat-feed[data-chat-background=rose]{background:repeating-linear-gradient(135deg,transparent 0 24px,#e88ca51a 24px 48px)}.chat-feed[data-chat-background=mint]{background:repeating-linear-gradient(135deg,transparent 0 24px,#65cba51a 24px 48px)}.chat-feed[data-chat-background=slate]{background:repeating-linear-gradient(135deg,transparent 0 24px,#8494ad22 24px 48px)}.chat-feed[data-chat-background=lavender]{background:repeating-linear-gradient(135deg,transparent 0 24px,#a58ce522 24px 48px)}

/* V1.6.1 media viewer refinement */
.chat-attachment-compact{display:grid;gap:3px;min-width:0;max-width:100%;margin-top:3px}.chat-attachment-compact a{overflow-wrap:anywhere}.chat-attachment-compact .chat-inline-image{max-width:min(100%,220px);max-height:150px;margin:0;object-fit:contain}.chat-attachment-compact button{justify-self:start;padding:4px 8px}.chat-media-dialog.media-refined{box-sizing:border-box;position:fixed;inset:0;margin:auto;width:min(94vw,1100px);height:min(88dvh,850px);max-width:none;max-height:none;padding:10px;overflow:hidden;border:1px solid var(--line);border-radius:16px;background:var(--panel);color:var(--ink);box-shadow:0 18px 70px #0005}.chat-media-dialog.media-refined[open]{display:flex;flex-direction:column;gap:8px}.chat-media-dialog.media-full{width:100vw;height:100dvh;border-radius:0;padding:max(8px,env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left))}.media-top{display:flex;align-items:center;gap:8px;min-width:0}.media-top strong{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.media-top-actions,.media-footer{display:flex;align-items:center;justify-content:center;gap:6px;flex-wrap:wrap}.media-top-actions{flex-shrink:0}.media-refined button,.media-top-actions a{padding:6px 10px;min-height:36px;border:1px solid var(--line);border-radius:8px;background:var(--panel);color:var(--ink);font-size:13px}.media-top-actions a[hidden],.media-footer[hidden]{display:none}.media-stage{position:relative;flex:1;min-height:0;min-width:0;overflow:hidden;display:flex;align-items:center;justify-content:center;background:var(--bg);border-radius:10px}.media-image-stage{touch-action:none;user-select:none}.media-image-stage img{position:absolute;left:50%;top:50%;max-width:none!important;max-height:none!important;object-fit:contain;transform-origin:center;pointer-events:none}.media-stage iframe{width:100%;height:100%;border:0;flex:1;min-height:0}.media-stage:has(iframe){flex-direction:column}.media-pdf-note{padding:5px;text-align:center}.media-footer span{font-size:12px;min-width:38px;text-align:center}.media-refined::backdrop{background:#0009}@media(max-width:700px){.chat-media-dialog.media-refined{width:98vw;height:94dvh;padding:8px}.media-refined button,.media-top-actions a{min-height:44px;padding:5px 8px}.media-top{gap:4px}.media-top-actions{gap:3px}.media-footer{gap:4px}.chat-attachment-compact .chat-inline-image{max-height:130px}}

.chat-media-dialog.media-refined.media-full{width:100vw;height:100dvh;border-radius:0}.media-refined .media-stage iframe{height:100%;min-height:0}.media-refined .media-top-actions a{display:inline-flex;align-items:center}.media-refined .media-top-actions a[hidden]{display:none}

.pdf-corrected .pdf-pages{flex:1;min-height:0;min-width:0;overflow:auto;overscroll-behavior:contain;background:var(--bg);padding:10px;display:block}.pdf-corrected .pdf-page{position:relative;margin:0 auto 12px;background:white;box-shadow:0 2px 8px #0003;max-width:none;flex:none}.pdf-corrected canvas{display:block;width:100%;height:100%;max-width:none}.pdf-corrected .media-footer{flex:none}.pdf-corrected>small:empty{display:none}.pdf-corrected .media-top strong{min-width:0}.pdf-corrected .media-footer button{margin:0}.pdf-corrected .pdf-page{margin-left:max(0px,calc((100% - var(--unused,0px))/2));margin-left:auto;margin-right:auto}
.office-viewer .office-stage{flex:1;min-height:0;min-width:0;overflow:auto;overscroll-behavior:contain;background:var(--bg);padding:12px}.office-word{box-sizing:border-box;width:794px;min-height:100%;padding:36px;background:#fff;color:#202124;margin:0 auto;overflow-wrap:anywhere;line-height:1.55}.office-word img{max-width:100%;height:auto}.office-word table{border-collapse:collapse;max-width:100%}.office-word td,.office-word th{border:1px solid #b9bec5;padding:6px}.office-tabs,.office-navigation{display:flex;gap:5px;align-items:center;flex-wrap:wrap;flex:none}.office-tabs[hidden]{display:none}.office-tabs{flex-wrap:nowrap;overflow:auto}.office-tabs button{white-space:nowrap}.office-tabs button[aria-selected=true]{outline:2px solid currentColor;outline-offset:-2px}.office-navigation input{min-width:100px;max-width:180px}.office-navigation span{font-size:12px}.office-grid{width:max-content;min-width:100%;color:var(--ink)}.office-grid table{border-collapse:separate;border-spacing:0;table-layout:auto;width:max-content}.office-grid th,.office-grid td{border:1px solid var(--line);padding:5px 9px;min-width:60px;max-width:320px;white-space:pre-wrap;overflow-wrap:anywhere;background:var(--panel)}.office-grid thead th{position:sticky;top:0;z-index:1;background:var(--panel)}.office-grid .office-number{text-align:right}.office-grid .office-match{background:#ffe68a;color:#222}.office-viewer>small{overflow-wrap:anywhere;flex:none}.office-viewer .media-footer button,.office-navigation button{margin:0}.office-viewer .media-top strong{min-width:0}.office-viewer .office-navigation{max-height:25dvh;overflow:auto}
