body.viewer-open { overflow: hidden; }

.file-list button.view-file {
    display: inline;
    margin: 0 8px 0 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--new);
}

.file-list button.shot-button {
    display: block;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    cursor: zoom-in;
}

.file-list button.shot-button .shot { cursor: zoom-in; }

.viewer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(28, 25, 23, .55);
}

.viewer-backdrop[hidden] { display: none; }

@media (max-width: 720px) {
    .viewer-backdrop { padding: 8px; }
    .viewer { height: calc(100vh - 16px); height: calc(100dvh - 16px); border-radius: 12px; }
    .viewer-bar { flex-wrap: wrap; }
    .viewer-actions { width: 100%; justify-content: flex-end; }
}

.viewer {
    width: min(1100px, 100%);
    height: min(860px, calc(100vh - 48px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--card);
    border-radius: 16px;
    box-shadow: 0 16px 50px rgba(28, 25, 23, .28);
}

.viewer-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
}

.viewer-bar h2 {
    flex: 1;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font-size: 16px;
    letter-spacing: 0;
    text-transform: none;
    color: var(--ink);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.viewer-actions { display: flex; gap: 8px; flex: none; }

.viewer-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 16px 18px 24px;
    background: var(--paper);
}

.viewer-body .viewer-image,
.viewer-doc img,
.viewer-slide img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 8px auto;
    background: white;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.viewer-body iframe,
.viewer-body video {
    width: 100%;
    height: calc(100% - 8px);
    min-height: 420px;
    border: 0;
    background: white;
    border-radius: 8px;
}

.viewer-body audio { width: min(640px, 100%); }

.viewer-doc, .viewer-slide {
    background: white;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px 18px;
}

.viewer-slide { margin-bottom: 12px; }

.viewer-doc p, .viewer-slide p { margin: 0 0 10px; white-space: pre-wrap; }

.viewer-doc h3, .viewer-slide h3 {
    margin: 14px 0 8px;
    font-size: 18px;
    letter-spacing: 0;
    text-transform: none;
    color: var(--ink);
}

.viewer-doc p.viewer-item { padding-left: 16px; }

.viewer-doc table, .viewer-sheet table {
    border-collapse: collapse;
    background: white;
    font-size: 13px;
}

.viewer-doc td, .viewer-sheet td, .viewer-sheet th {
    border: 1px solid var(--line);
    padding: 4px 8px;
    vertical-align: top;
}

.viewer-sheet { overflow: auto; }

.viewer-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

.viewer-tabs button.active { background: var(--sidebar); color: white; border-color: var(--sidebar); }

.viewer-text {
    margin: 0;
    padding: 14px;
    overflow: auto;
    white-space: pre-wrap;
    background: white;
    border: 1px solid var(--line);
    border-radius: 12px;
    font: 13px/1.45 Consolas, "Courier New", monospace;
}

.viewer-note { margin: 12px 0 0; color: var(--muted); font-size: 13px; }

@media (max-width: 720px) {
    .viewer-backdrop { padding: 0; }
    .viewer { width: 100%; height: 100%; border-radius: 0; }
    .viewer-bar { align-items: flex-start; }
    .viewer-bar h2 { white-space: normal; }
}
