* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f0f2f5;
    color: #333;
}

.preview-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.preview-header {
    flex-shrink: 0;
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
    padding: 12px 24px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.preview-header__title {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    word-break: break-all;
}

.preview-header__meta {
    margin-top: 4px;
    font-size: 13px;
    color: #888;
}

.preview-main {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    overflow: auto;
}

.preview-content {
    width: 100%;
    max-width: 1200px;
    max-height: 100%;
}

.preview-panel {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.preview-panel--hidden,
.preview-content--hidden,
.preview-state--hidden,
.preview-footer--hidden {
    display: none !important;
}

.preview-state {
    text-align: center;
    color: #666;
}

.preview-state p {
    margin-top: 12px;
    font-size: 15px;
}

.preview-state__hint {
    font-size: 13px !important;
    color: #999 !important;
}

.preview-state__icon {
    font-size: 48px;
    line-height: 1;
}

.preview-state__icon--error {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #fff2f0;
    color: #ff4d4f;
    font-size: 28px;
    font-weight: bold;
}

.preview-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto;
    border: 3px solid #e8e8e8;
    border-top-color: #1890ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#videoPanel {
    padding: 0;
    background: #000;
    max-height: 100%;
}

#videoPanel .video-js {
    width: 100%;
    max-height: calc(100vh - 140px);
}

/* fluid 模式下限制高度，避免把下载按钮挤出视口 */
#videoPanel .video-js.vjs-fluid:not(.vjs-audio-only-mode) {
    padding-top: 0 !important;
    height: calc(100vh - 140px);
    max-height: 675px;
}

#videoPanel .video-js .vjs-tech {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* 倍速菜单：去掉默认高度限制，避免出现滚动条 */
#videoPanel .vjs-playback-rate .vjs-menu .vjs-menu-content {
    max-height: none;
    overflow: visible;
    bottom: 1.5em;
}

#audioPanel {
    padding: 32px 24px;
    text-align: center;
}

#previewAudio {
    width: 100%;
    max-width: 600px;
}

.audio-speed {
    margin-top: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

.audio-speed__label {
    font-size: 13px;
    color: #666;
}

.speed-btn {
    padding: 4px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    background: #fff;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: all 0.2s;
}

.speed-btn:hover {
    border-color: #1890ff;
    color: #1890ff;
}

.speed-btn--active {
    background: #1890ff;
    border-color: #1890ff;
    color: #fff;
}

#imagePanel {
    padding: 16px;
    text-align: center;
    background: #fafafa;
}

#previewImage {
    max-width: 100%;
    max-height: calc(100vh - 200px);
    object-fit: contain;
}

#pdfPanel {
    height: calc(100vh - 180px);
    min-height: 500px;
}

#previewPdf {
    width: 100%;
    height: 100%;
    border: none;
}

#textPanel {
    max-height: calc(100vh - 180px);
    overflow: auto;
}

#previewText {
    padding: 20px 24px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
    color: #333;
    background: #fafafa;
}

.preview-footer {
    flex-shrink: 0;
    background: #fff;
    border-top: 1px solid #e8e8e8;
    padding: 10px 24px;
    text-align: center;
}

.preview-btn {
    display: inline-block;
    padding: 8px 20px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    background: #fff;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.preview-btn:hover {
    border-color: #1890ff;
    color: #1890ff;
}

.preview-btn--primary {
    background: #1890ff;
    border-color: #1890ff;
    color: #fff;
}

.preview-btn--primary:hover {
    background: #40a9ff;
    border-color: #40a9ff;
    color: #fff;
}

.preview-warning {
    margin-bottom: 16px;
    padding: 10px 16px;
    background: #fffbe6;
    border: 1px solid #ffe58f;
    border-radius: 4px;
    font-size: 13px;
    color: #ad8b00;
    text-align: center;
}

@media (max-width: 768px) {
    .preview-header {
        padding: 10px 16px;
    }

    .preview-main {
        padding: 8px 12px;
    }

    #videoPanel .video-js.vjs-fluid:not(.vjs-audio-only-mode) {
        height: calc(100vh - 150px);
        max-height: none;
    }

    #pdfPanel {
        height: calc(100vh - 160px);
        min-height: 300px;
    }
}
