dialog.preview:has(.document-viewer){width:min(1180px,96vw);max-width:96vw}
dialog.preview:has(.document-viewer) .dialog-body{padding:0;background:#edf1f3;display:block;min-height:0;overflow:hidden}
.document-viewer{display:flex;flex-direction:column;width:100%;height:min(72dvh,860px);min-height:240px;color:#173448}
.document-tools{display:flex;align-items:center;flex-wrap:wrap;gap:10px;padding:12px 18px;background:#fff;border-bottom:1px solid #dce4e7}
.document-tools[hidden]{display:none}.document-tools label{display:flex;align-items:center;gap:8px;font-size:12px}
dialog.preview .document-tools .btn{background:#fff;color:#173448;border:1px solid #cdd9df}dialog.preview .document-tools .btn:hover:not(:disabled){background:#e6f5f4;color:#075e64}dialog.preview .document-tools .btn:disabled{color:#718197;background:#f4f6f7;opacity:.65}
.document-tools input{width:65px;min-height:36px;border:1px solid #cdd9df;border-radius:7px;padding:6px;background:#fff;color:#173448}
.document-tools select{max-width:170px;min-height:36px;border:1px solid #cdd9df;border-radius:7px;background:white;color:#173448}
.document-zoom-label{margin-left:auto}.document-status{padding:8px 18px;color:#52697b;font-size:12px;flex-shrink:0;background:#f8fafb}
.document-canvas{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;padding:16px;text-align:center;-webkit-overflow-scrolling:touch}
dialog.preview .document-page{display:block;width:100%;height:auto;max-height:none;object-fit:initial;background:white;box-shadow:0 3px 16px #17344820;margin:0 auto}
.document-text{font:14px/1.7 Consolas,"SFMono-Regular",monospace;white-space:pre-wrap;overflow-wrap:anywhere;tab-size:4;text-align:left;margin:0;padding:20px;background:white;color:#172c45;border-radius:8px;min-height:100%;user-select:text}
@media(max-width:600px){dialog.preview:has(.document-viewer){width:100vw;max-width:100vw;margin:auto 0;max-height:100dvh;border-radius:14px 14px 0 0}.document-viewer{height:72dvh}.document-tools{gap:8px;padding:10px}.document-tools .btn{padding:8px;min-height:40px}.document-zoom-label{margin-left:0}.document-canvas{padding:8px}.document-text{font-size:13px;padding:14px}.document-status{padding:8px 12px}dialog.preview:has(.document-viewer) .dialog-head{padding:14px}dialog.preview:has(.document-viewer) .dialog-foot{padding:10px;gap:8px;flex-wrap:wrap}}

/* Long names must never displace the close button or widen a mobile dialog. */
dialog .dialog-head{min-width:0;gap:12px}dialog .dialog-head h2{min-width:0;flex:1;overflow-wrap:anywhere;word-break:break-word;font-size:clamp(15px,2vw,20px);line-height:1.4;margin:0}
dialog .dialog-head .icon-btn,dialog .dialog-head button{flex-shrink:0}
dialog.preview .dialog-head h2{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
dialog.preview .dialog-foot{flex-wrap:wrap;min-width:0}dialog.preview .dialog-body{min-width:0}
.office-paper{background:white;color:#173448;border-radius:8px;padding:24px;text-align:left;max-width:100%;min-height:100%;font:15px/1.65 system-ui,sans-serif}
.office-paper p{white-space:pre-wrap;overflow-wrap:anywhere}.office-table-wrap{overflow:auto;max-width:100%;margin:16px 0}
.office-paper table{border-collapse:collapse;font:13px/1.5 system-ui,sans-serif}.office-paper td{border:1px solid #dce4e7;padding:8px 12px;white-space:pre-wrap;min-width:80px;max-width:320px;overflow-wrap:anywhere;vertical-align:top}
@media(max-width:600px){dialog.preview .dialog-head{padding:12px!important}dialog.preview .dialog-head h2{font-size:15px!important}.office-paper{padding:12px}.document-tools{flex-shrink:0}.document-status{max-height:100px;overflow:auto}}
.document-tools label[hidden]{display:none}
