/* Shared file reader: one header, one toolbar, one scrollable canvas. */
.overlay-backdrop:has(.modal[data-kind="file-viewer"]) { padding:24px; background:#0005; backdrop-filter:none; align-items:center; }
.modal[data-kind="file-viewer"] { width:min(1440px,calc(100vw - 48px)); max-width:none; height:calc(100dvh - 48px); max-height:none; display:flex; flex-direction:column; overflow:hidden; border-radius:18px; background:var(--surface); box-shadow:0 24px 100px #0003; }
.modal[data-kind="file-viewer"] .modal-head { flex:none; min-height:66px; padding:14px 22px; gap:16px; background:var(--surface); }
.modal[data-kind="file-viewer"] .modal-head h2 { display:flex; align-items:center; gap:12px; min-width:0; font-size:14px; font-weight:600; }
.preview-filename { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.modal[data-kind="file-viewer"] .modal-head>.icon-btn { flex:none; border-radius:50%; }
.modal[data-kind="file-viewer"] .modal-body { flex:1; min-height:0; padding:0; overflow:hidden; scrollbar-gutter:auto; }
#file-viewer-body { display:flex; flex-direction:column; height:100%; min-height:0; }
#file-viewer-body .file-viewer-bar { display:flex; align-items:center; gap:16px; flex:none; flex-wrap:wrap; min-height:58px; padding:10px 22px; margin:0; border:0; border-bottom:1px solid var(--border); border-radius:0; background:var(--surface); }
.preview-caption { font-size:12px; color:var(--muted); }
.file-preview-tools { display:flex; align-items:center; gap:10px; margin-left:auto; }
.file-preview-tools .btn { border-radius:9px; gap:7px; }
.file-preview-tools .icon-btn { width:30px; height:30px; border-radius:7px; }
.preview-zoom { display:flex; align-items:center; padding:0 6px; border-inline:1px solid var(--border); }
.preview-zoom>button { display:flex; align-items:center; justify-content:center; border:0; background:transparent; color:var(--muted); min-height:30px; min-width:36px; font-size:12px; cursor:pointer; border-radius:6px; }
.preview-zoom>button:hover { background:var(--surface-hover); color:var(--ink); }
#file-viewer-body .file-viewer-modes { padding:3px; background:var(--surface-alt); border:1px solid var(--border); border-radius:8px; }
#file-viewer-body .file-viewer-mode { gap:6px; font-size:12px; border-radius:5px; padding:5px 10px; }
#file-viewer-body .file-viewer-mode.active { color:var(--ink); background:var(--surface); box-shadow:0 1px 4px #0001; }
#file-viewer-canvas { flex:1; min-height:0; overflow:auto; background:var(--bg); }
#file-viewer-canvas.preview-sheet { overflow:hidden; background:var(--surface); }
#file-viewer-canvas .word-viewer-wrap { padding:32px 24px 64px; margin:0; border:0; border-radius:0; background:transparent; max-height:none; overflow:visible; }
#file-viewer-canvas .word-page { box-sizing:border-box; width:calc(794px * var(--preview-scale)); max-width:none; min-height:calc(1020px * var(--preview-scale)); margin:0 auto; padding:calc(64px * var(--preview-scale)); border:1px solid var(--border); border-radius:3px; background:var(--surface); box-shadow:0 3px 16px #00000008; font-size:calc(15px * var(--preview-scale)); line-height:1.8; overflow-wrap:anywhere; }
#file-viewer-canvas .word-page h1 { font-size:1.9em; line-height:1.3; }
#file-viewer-canvas .word-page h2 { font-size:1.45em; }
#file-viewer-canvas .word-page h3 { font-size:1.2em; }
#file-viewer-canvas .word-page p { font-size:inherit; }
#file-viewer-canvas .excel-viewer-wrap { display:flex; flex-direction:column; height:100%; max-height:none; border:0; border-radius:0; margin:0; }
.preview-formula { flex:none; display:flex; align-items:center; min-height:38px; border-bottom:1px solid var(--border); background:var(--surface); font-size:12px; }
.preview-cell-ref { flex:none; min-width:76px; padding:8px 16px; border-right:1px solid var(--border); text-align:center; color:var(--ink); font-variant-numeric:tabular-nums; }
.preview-fx { flex:none; padding:0 14px; font-family:Georgia,serif; font-style:italic; font-size:16px; color:var(--muted); }
.preview-cell-value { padding:7px 12px 7px 0; white-space:nowrap; overflow:auto; color:var(--ink); }
#file-viewer-canvas .excel-grid-scroll { flex:1; min-height:0; max-height:none; background:var(--surface-alt); }
#file-viewer-canvas .excel-grid { width:max-content; min-width:100%; font-size:calc(13px * var(--preview-scale)); }
#file-viewer-canvas .excel-grid th,#file-viewer-canvas .excel-grid td { min-width:140px; height:calc(36px * var(--preview-scale)); padding:8px 14px; }
#file-viewer-canvas .excel-grid .excel-row-num { min-width:48px; width:48px; padding:8px; background:var(--surface-alt); font-size:11px; color:var(--muted); }
#file-viewer-canvas .excel-col-head { font-size:11px; font-weight:500; background:var(--surface-alt); color:var(--muted); }
#file-viewer-canvas .excel-header-row td:not(.excel-row-num) { background:var(--surface); color:var(--ink); font-weight:600; }
.excel-grid td[data-action="preview-select-cell"] { cursor:cell; position:relative; outline:none; }
.excel-grid td.is-selected { box-shadow:inset 0 0 0 2px var(--accent); background:var(--accent-light,var(--surface-hover)) !important; }
#file-viewer-canvas .excel-sheet-tabs { flex:none; padding:0 16px; gap:4px; min-height:44px; border-top:1px solid var(--border); border-bottom:0; background:var(--surface); overflow-x:auto; }
#file-viewer-canvas .excel-sheet-tab { flex:none; border:0; border-radius:0; padding:10px 14px; border-bottom:2px solid transparent; background:transparent; color:var(--muted); font-size:12px; }
#file-viewer-canvas .excel-sheet-tab.active { color:var(--accent); border-bottom-color:var(--accent); background:var(--surface-alt); box-shadow:none; }
#file-viewer-canvas .excel-status-bar { flex:none; min-height:30px; padding:6px 20px; background:var(--surface-alt); font-size:11px; }
.preview-empty { height:100%; min-height:200px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:14px; text-align:center; padding:32px; color:var(--muted); }
.preview-empty strong { color:var(--ink); font-size:15px; }
.preview-empty p { font-size:13px; }
.preview-loader { width:24px; height:24px; border:2px solid var(--border); border-top-color:var(--accent); border-radius:50%; animation:preview-spin .8s linear infinite; }
@keyframes preview-spin { to { transform:rotate(360deg); } }
@media (max-width:900px) {
  #file-viewer-canvas .word-page { width:calc(100% * var(--preview-scale)); min-height:80vh; padding:clamp(24px,5vw,48px); }
  .preview-caption { display:none; }
}
@media (max-width:600px) {
  .overlay-backdrop:has(.modal[data-kind="file-viewer"]) { padding:0; }
  .modal[data-kind="file-viewer"] { width:100vw; height:100dvh; border-radius:0; }
  .modal[data-kind="file-viewer"] .modal-head { padding:12px 16px; min-height:58px; }
  #file-viewer-body .file-viewer-bar { padding:8px 12px; gap:8px; }
  .file-preview-tools { gap:4px; }
  .file-preview-tools .btn span { display:none; }
  .preview-zoom { padding:0 2px; }
  #file-viewer-canvas .word-viewer-wrap { padding:16px 12px 32px; }
  #file-viewer-canvas .excel-status-bar>span:last-child { display:none; }
}
@media (prefers-reduced-motion:reduce) { .preview-loader { animation:none; border-style:dotted; } }
