.file-viewer { box-sizing: border-box; position: fixed; inset: 0; width: min(1040px, calc(100vw - 32px)); height: min(900px, calc(100dvh - 32px)); max-width: 100vw; max-height: 100dvh; margin: auto; padding: 0; border: 1px solid #e7e7ea; border-radius: 20px; background: #fff; color: #17181b; box-shadow: 0 24px 100px #0004; font: 16px/1.5 system-ui, sans-serif; }
.file-viewer[open] { display: flex; flex-direction: column; }
.file-viewer::backdrop { background: #17181ba6; }
.file-viewer *, .file-viewer *::before, .file-viewer *::after { box-sizing: border-box; }
.fv-header { display: flex; flex: none; align-items: center; gap: 12px; padding: 12px 16px 4px; }
.fv-heading { flex: 1; min-width: 0; margin: 0; font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-viewer button, .file-viewer a { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 8px 14px; border: 1px solid #d3d4d8; border-radius: 12px; background: #fff; color: #17181b; font: inherit; font-size: 16px; line-height: 1.5; text-decoration: none; cursor: pointer; touch-action: manipulation; }
.file-viewer button:disabled { opacity: .45; cursor: default; }
.file-viewer :focus-visible { outline: 3px solid #ef4148; outline-offset: 2px; }
.file-viewer .fv-download { background: #ef4148; border-color: #ef4148; color: #fff; }
.fv-meta { flex: none; margin: 0; padding: 0 16px 8px; color: #656772; font-size: 14px; overflow-wrap: anywhere; }
.fv-status { flex: none; max-height: 25%; overflow: auto; margin: 0; padding: 8px 16px; font-size: 16px; color: #656772; }
.fv-status:empty { display: none; }
.fv-body { flex: 1; min-height: 0; min-width: 0; overflow: auto; overscroll-behavior: contain; padding: 16px; background: #f5f5f7; -webkit-overflow-scrolling: touch; }
.fv-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4; font: 14px/1.65 ui-monospace, monospace; }
.fv-actions { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid #e7e7ea; }
.fv-page, .fv-media { display: block; max-width: 100%; height: auto; margin: 0 auto; object-fit: contain; }
.fv-page { background: #fff; box-shadow: 0 2px 12px #0001; }
.fv-media { width: 100%; max-height: 100%; }
.fv-table { min-width: 100%; border-collapse: collapse; background: #fff; }
.fv-table th, .fv-table td { min-width: 96px; max-width: 320px; padding: 8px 12px; border: 1px solid #d3d4d8; text-align: start; overflow-wrap: anywhere; vertical-align: top; }
.fv-table th { background: #ececf0; }
.fv-archive { padding-inline-start: 24px; overflow-wrap: anywhere; }
.fv-archive li { padding-block: 4px; }
.fv-page-number { font-variant-numeric: tabular-nums; }
@media (max-width: 600px) {
  .file-viewer { width: 100%; height: 100dvh; border: 0; border-radius: 0; }
  .fv-header { padding-top: max(12px, env(safe-area-inset-top)); }
  .fv-actions { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .fv-body { padding: 12px; }
}
@media (prefers-reduced-motion: reduce) { .file-viewer *, .file-viewer::backdrop { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
/* One document workspace below the fixed app topbar. */
:root{--fv-width:min(58vw,960px)}
.file-viewer{inset:var(--fv-top,56px) 0 0 auto;margin:0;width:var(--fv-width);height:calc(100dvh - var(--fv-top,56px));max-height:none;border:0;border-inline-start:1px solid var(--line,#ddd);border-radius:0;background:var(--panel,#fff);color:var(--ink,#242424);box-shadow:-12px 12px 32px #0001;z-index:48;contain:layout style}
.file-viewer button,.file-viewer a{background:var(--panel,#fff);color:var(--ink,#242424);border-color:var(--line,#ddd);font-size:14px}
.file-viewer .fv-close,.file-viewer .fv-fullscreen{border:0;min-width:40px;padding:8px;font-size:20px;background:transparent}
.file-viewer .fv-close{font-size:0}.file-viewer .fv-close::after{content:'×';font-size:26px;line-height:1}
.fv-header{padding:8px 12px;gap:6px}.fv-heading{font-size:16px}.fv-body{background:var(--bg,#f7f7f7)}.fv-meta,.fv-status{color:var(--muted,#666)}.fv-actions{border-color:var(--line,#ddd)}
.file-viewer.fv-fullscreen-open{inset:var(--fv-top,56px) 0 0;width:100vw;border:0}
body.file-workspace-open .page-shell>.transcript-card{margin-inline-end:var(--fv-width)}
.fv-editor-tools,.fv-image-tools{display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin-bottom:10px}
.fv-editor-tools select,.fv-editor-ai select{max-width:100%;min-height:38px;border:1px solid var(--line,#ddd);border-radius:9px;background:var(--panel,#fff);color:var(--ink,#242424)}
.fv-editor-surface{min-height:180px;max-height:65vh;overflow:auto}.fv-edit-image{display:block;max-width:100%;max-height:52vh;object-fit:contain;margin:auto}
.fv-editor-ai{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;margin-top:16px;padding-top:12px;border-top:1px solid var(--line,#ddd)}
.fv-editor-ai textarea{grid-column:1/-1;resize:vertical;padding:12px;border:1px solid var(--line,#ddd);border-radius:14px;background:var(--panel,#fff);color:var(--ink,#242424);font:inherit}
.fv-sheet-scroll{max-width:100%;overflow:auto}.fv-edit-grid{border-collapse:collapse;background:var(--panel,#fff)}.fv-edit-grid th,.fv-edit-grid td{border:1px solid var(--line,#ddd);padding:0;min-width:100px}.fv-edit-grid th{min-width:32px;padding:4px;position:sticky;left:0;background:var(--bg,#f5f5f5);font-size:12px}.fv-edit-grid input{display:block;width:100%;min-width:100px;padding:8px;border:0;border-radius:0;background:transparent;color:var(--ink,#242424);font:14px/1.4 ui-monospace,monospace}.fv-edit-grid input:focus{outline:2px solid var(--red,#ef4148);outline-offset:-2px;background:var(--bg,#f5f5f5)}
.fv-source{display:block;width:100%;min-height:40vh;padding:14px;resize:vertical;background:var(--panel,#fff);color:var(--ink,#242424);border:1px solid var(--line,#ddd);font:14px/1.6 ui-monospace,monospace}
@media(max-width:900px){:root{--fv-width:100vw}.file-viewer{width:100vw;border:0}.file-viewer.fv-fullscreen-open{inset:0;width:100vw;height:100dvh}body.file-workspace-open .page-shell>.transcript-card{margin-inline-end:0}.fv-editor-ai{grid-template-columns:minmax(0,1fr)}.fv-header{padding-top:8px}.fv-body{padding:12px}}

.fv-document-section{display:grid;gap:4px;margin:12px 0}.fv-document-section textarea{width:100%;padding:10px;background:var(--panel,#fff);color:var(--ink,#222);border:1px solid var(--line,#ddd);border-radius:10px;font:inherit;resize:vertical}.fv-document-section span{font-size:12px;color:var(--muted,#666)}

.fv-crop-fields{display:flex;flex-wrap:wrap;gap:8px;margin:8px 0 16px}.fv-crop-fields label{display:grid;gap:3px;font-size:12px;color:var(--muted,#666)}.fv-crop-fields input{width:80px;min-height:36px;padding:6px;border:1px solid var(--line,#ddd);border-radius:8px;background:var(--panel,#fff);color:var(--ink,#222)}.fv-edit-grid th[scope=col]{position:sticky;top:0;z-index:1;text-align:center}

/* Keep editor controls readable after version changes and nested image scroll. */
.file-viewer [hidden]{display:none!important}
.fv-editor-tools{position:sticky;top:0;z-index:3;background:var(--bg,#f7f7f7);padding:4px 0 8px}
.fv-crop-group{min-width:0;margin:0 0 12px;padding:10px;border:1px solid var(--line,#ddd);border-radius:10px;background:var(--bg,#f7f7f7)}
.fv-crop-group legend{padding:0 5px;font-size:13px;font-weight:600;color:var(--ink,#222)}
.fv-crop-fields{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));margin:8px 0 0}
.fv-crop-fields label{min-width:0;align-content:start}.fv-crop-caption{min-height:2.8em;line-height:1.4;overflow-wrap:anywhere;color:var(--ink,#222)}
.fv-crop-fields input{width:100%;min-width:0}.fv-preservation-note{margin:0 0 12px;font-size:12px;line-height:1.5;color:var(--muted,#666)}
@media(max-width:600px){.fv-crop-fields{grid-template-columns:repeat(2,minmax(0,1fr))}.fv-editor-tools{gap:5px}.fv-editor-tools button,.fv-editor-tools a{padding:7px 9px}.fv-crop-caption{min-height:1.4em}}
