.file-viewer { width: min(1100px, calc(100vw - 24px)); height: min(900px, 92dvh); max-height: 92dvh; padding: 20px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: var(--paper); }
.file-viewer[open] { display: flex; flex-direction: column; gap: 12px; }
.file-viewer::backdrop { background: #000a; }
.file-viewer header { display: flex; align-items: center; gap: 14px; }
.file-viewer h2 { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 18px; margin: 0; }
.file-viewer [data-file-close] { font-size: 28px; padding: 8px; }
.file-viewer [data-file-status] { margin: 0; font-size: 13px; }
.file-viewer-content { flex: 1; min-height: 0; overflow: auto; text-align: center; }
.file-viewer-content > img { max-width: 100%; max-height: 100%; object-fit: contain; }
.file-viewer-content iframe { width: 100%; height: 100%; border: 0; background: white; }
.file-viewer-content canvas { background: white; }
.file-viewer-controls { display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap; }
.pdf-thumbnail { display: flex; height: 140px; width: 100%; justify-content: center; align-items: center; overflow: hidden; background: var(--brand-soft); }
.pdf-thumbnail canvas { max-width: 100%; max-height: 100%; object-fit: contain; }
.pdf-thumbnail-fallback { font-weight: 700; color: var(--brand); }
.chat-attachment .pdf-thumbnail { height: 110px; }
.file-viewer button:disabled { opacity: .5; cursor: default; }
.link-preview { display: flex; width: 100%; max-width: 520px; gap: 12px; margin: 12px 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; color: var(--ink); background: var(--paper); text-decoration: none; }
.link-preview:hover { border-color: var(--brand); }
.link-preview > img { width: 110px; max-height: 150px; object-fit: cover; flex: none; }
.link-preview-copy { display: flex; flex-direction: column; gap: 5px; padding: 12px; min-width: 0; }
.link-preview-copy small { color: var(--muted); font-size: 11px; }
.link-preview-copy strong, .link-preview-copy > span { overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; font-size: 13px; }
.link-preview-copy > span { color: var(--muted); font-size: 12px; }
@media(max-width:600px) { .link-preview > img { width: 75px; } }

.link-preview [hidden] { display: none; }

/* Keep titles aligned regardless of thumbnail format, loading, or availability. */
.document-preview-slot { height: 160px; margin-bottom: 16px; overflow: hidden; border-radius: 7px; background: var(--brand-soft); }
.document-preview-slot > a { display: flex; width: 100%; height: 100%; margin: 0; max-width: none; }
.document-preview-slot .document-thumbnail,
.document-preview-slot .pdf-thumbnail { display: block; width: 100%; height: 160px; margin: 0; object-fit: contain; }
.document-preview-slot .pdf-thumbnail { display: flex; }
.document-preview-slot .link-preview { border: 0; border-radius: 0; align-items: center; }
.document-preview-slot .link-preview > img { height: 160px; max-height: none; object-fit: contain; }
.document-preview-slot .link-preview-copy > span { -webkit-line-clamp: 2; }
.document-card > h2 { margin: 0; }
