body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: #f0f9ff;
    color: #1e293b;
    padding-top: 37px;
}

/* ========== 深色模式适配 ========== */
[data-theme="dark"] body,
[data-theme="dark"] html {
    background-color: var(--bg-primary, #18191c);
    color: var(--text-primary, #f5f5f5);
}

/* Critical header and navigation styles */
.player-header {
    position: relative;
    z-index: 2147483647 !important;
    pointer-events: auto !important;
}

.player-header-fixed {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw;
    z-index: 9000 !important;
    pointer-events: auto !important;
    background: #ffffff;
}

[data-theme="dark"] .player-header-fixed {
    background: var(--header-bg, rgba(24, 25, 28, 0.95));
    border-color: var(--border-color, #2d2e35);
}

[data-theme="dark"] .player-header-fixed h1,
[data-theme="dark"] .player-header-fixed .logo-text {
    color: var(--accent-primary, #fb7299) !important;
}

[data-theme="dark"] .player-header-fixed .logo-icon {
    color: var(--accent-primary, #fb7299) !important;
}

[data-theme="dark"] #videoTitle {
    color: var(--text-secondary, #a2a7ae) !important;
}

[data-theme="dark"] #goBack {
    color: var(--accent-primary, #fb7299) !important;
}

#homeButton { 
    pointer-events: auto !important; 
}

.home-button {
    background: none !important;
    border: none !important;
    padding: 0 !important;
}

/* Critical loading styles to prevent FOUC */
.player-placeholder {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 16/9 !important;
    background-color: #e0f2fe !important;
    position: relative !important;
    display: block !important;
    border-radius: 8px !important;
    overflow: hidden !important;
}

.player-loading-container {
    width: 100% !important;
    height: 0 !important;
    padding-bottom: 56.25% !important;
    position: relative !important;
    background-color: #e0f2fe !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    display: block !important;
}

.player-loading-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background-color: rgba(0, 0, 0, 0.4) !important;
    backdrop-filter: blur(4px) !important;
    z-index: 50 !important;
}
    z-index: 100 !important;
    background: transparent !important;
    max-width: 90% !important;
}

@keyframes player-spinner-rotate {
    to { transform: rotate(360deg); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ArtPlayer specific styles */
.art-video-player, .art-video-player video {
    width: 100% !important;
    height: 100% !important;
    min-height: 150px !important;
    max-height: 100vh !important;
    background: #000 !important;
    object-fit: contain !important;
    display: block !important;
}

/* Fix for Chrome-specific issues */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    .art-video-player video {
        transform: translateZ(0) !important;
        will-change: transform !important;
    }

    /* Force visibility of video element */
    .art-video-player.art-playing video {
        visibility: visible !important;
        opacity: 1 !important;
    }
}

.player-container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}

#player {
    width: 100%;
    height: 60vh; /* 视频播放器高度 */
}

.loading-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 100;
    backdrop-filter: blur(4px);
}

.loading-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.loading-spinner-box {
    position: relative;
    width: 64px;
    height: 64px;
}

.loading-ring-bg {
    width: 64px;
    height: 64px;
    border: 4px solid #e0f2fe;
    border-radius: 50%;
}

.loading-ring-spin {
    position: absolute;
    top: 0;
    left: 0;
    width: 64px;
    height: 64px;
    border: 4px solid transparent;
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-ring-inner {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 48px;
    height: 48px;
    border: 4px solid transparent;
    border-bottom-color: #67e8f9;
    border-radius: 50%;
    animation: spin-reverse 1s linear infinite;
}

.loading-text-box {
    text-align: center;
}

.loading-text-main {
    color: #0284c7;
    font-weight: 500;
    font-size: 1.125rem;
    margin-bottom: 4px;
}

.loading-text-sub {
    color: #6b7280;
    font-size: 0.875rem;
}

/* 反向旋转动画 */
@keyframes spin-reverse {
    from {
        transform: rotate(360deg);
    }
    to {
        transform: rotate(0deg);
    }
}

.animate-spin-reverse {
    animation: spin-reverse 1s linear infinite;
}

/* 缓冲 UI 旋转动画 */
@keyframes bufferSpin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* 隐藏 ArtPlayer 原生加载动画，使用自定义智能缓冲 UI */
.art-loading-icon {
    display: none !important;
}

.error-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background-color: rgba(15, 23, 42, 0.4);
    color: #f9fafb;
    z-index: 100;
    flex-direction: column;
    text-align: center;
    padding: 1rem;
}

.error-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.error-message-sub {
    margin-top: 10px;
    font-size: 14px;
    color: #aaa;
}

/* 集数按钮 - 浅色风格 */
#episodesList button,
#episodesGrid button {
    background: #f0f9ff;
    border: 1px solid #e0f2fe;
    color: #0284c7;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 0.875rem;
    transition: all 0.15s ease;
    min-width: 48px;
}

#episodesList button:hover,
#episodesGrid button:hover {
    background: #e0f2fe;
    border-color: #7dd3fc;
}

.episode-active {
    background-color: var(--accent-primary) !important;
    border-color: var(--accent-primary) !important;
    color: white !important;
}

/* 集数列表容器 */
#episodesList {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
    gap: 0.5rem;
}

.episode-grid {
    max-height: 30vh;
    overflow-y: auto;
}

/* 恢复播放位置提示样式 - 浅色版 */
.position-restore-hint {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    background-color: rgba(255, 255, 255, 0.95);
    color: #334155;
    padding: 10px 20px;
    border-radius: 12px;
    border: 1px solid #e0f2fe;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 1000;
    transition: transform 0.3s ease;
    font-size: 14px;
}

.position-restore-hint.show {
    transform: translateX(-50%) translateY(0);
}

.hint-content {
    display: flex;
    align-items: center;
    justify-content: center;
}

.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent-primary);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

/* 快捷键提示样式 - 浅色版 */
.shortcut-hint {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 255, 255, 0.95);
    color: #334155;
    padding: 1rem 2rem;
    border-radius: 12px;
    border: 1px solid #e0f2fe;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.shortcut-hint.show {
    opacity: 1;
}

/* 原生全屏时，播放器容器铺满 */
.player-container:-webkit-full-screen,
.player-container:fullscreen {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    z-index: 10000;
    background-color: #000;
}

.player-container:-webkit-full-screen #player,
.player-container:fullscreen #player {
    width: 100%; height: 100%;
}

/* 资源信息卡片区 */
#resourceInfoBarContainer {
    align-items: center;
    border-radius: 0.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.resource-info-bar-left {
    align-items: center;
    font-size: 1.1rem;
    font-weight: bold;
    color: #fff;
    flex: 1;
}

.resource-info-bar-videos {
    font-size: 1rem;
    font-weight: normal;
    margin-left: 10px;
    color: #ccc;
}

.resource-switch-btn {
    align-items: center;
    background: none;
    border: none;
    color: #a67c2d;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 0.5rem;
    transition: background 0.2s;
}

.resource-switch-btn:hover {
    background: #f5e9d7;
}

.resource-switch-btn:active {
    background: #f5e9d7;
}

.resource-switch-icon {
    width: 20px;
    height: 20px;
    margin-right: 0;
    color: #a67c2d;
    vertical-align: middle;
    transition: transform 0.3s;
}

/* 新增：移动端响应式样式 */
@media (max-width: 640px) {
    .episode-grid {
        max-height: 40vh; /* 移动端增加集数列表高度 */
    }

    /* 改进移动端按钮显示 */
    button {
        white-space: nowrap;
    }

    /* 控制栏在小屏幕上可能需要换行 */
    .player-container .flex-wrap {
        margin-bottom: 4px;
    }
}

/* 隐藏用户名输入框 */
#username {
    display: none !important;
}

/* 加载动画 */
@keyframes spin-reverse {
    from {
        transform: rotate(360deg);
    }
    to {
        transform: rotate(0deg);
    }
}

@keyframes pulse-scale {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

.animate-spin-reverse {
    animation: spin-reverse 1.2s linear infinite;
}

.animate-pulse-scale {
    animation: pulse-scale 2s ease-in-out infinite;
}

/* 视频信息卡片样式 */
.video-info-card {
    padding: 12px 16px;
}

.video-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.video-tag {
    display: inline-block;
    padding: 2px 10px;
    background: var(--btn-primary-bg);
    color: white;
    font-size: 12px;
    border-radius: 12px;
    font-weight: 500;
}

.video-meta {
    display: flex;
    align-items: flex-start;
    margin-bottom: 4px;
    font-size: 13px;
    line-height: 1.5;
}

.meta-label {
    color: #64748b;
    min-width: 40px;
    flex-shrink: 0;
}

.meta-value {
    color: #334155;
    flex: 1;
}

.video-desc {
    border-top: 1px solid #e0f2fe;
    padding-top: 8px;
}

.desc-content {
    color: #64748b;
    font-size: 13px;
    line-height: 1.6;
    margin: 4px 0 0 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ========== 深色模式 - 播放器页面完整适配 ========== */

/* 主容器背景 */
[data-theme="dark"] main {
    background: var(--bg-primary, #18191c) !important;
}

/* 播放器占位背景 */
[data-theme="dark"] .player-placeholder {
    background-color: var(--bg-tertiary, #2d2e35) !important;
}

[data-theme="dark"] .player-loading-container {
    background-color: var(--bg-tertiary, #2d2e35) !important;
}

/* 集数按钮 */
[data-theme="dark"] #episodesList button,
[data-theme="dark"] #episodesGrid button {
    background: var(--bg-secondary, #21222c);
    border-color: var(--border-color, #2d2e35);
    color: var(--accent-primary, #fb7299);
}

[data-theme="dark"] #episodesList button:hover,
[data-theme="dark"] #episodesGrid button:hover {
    background: var(--bg-tertiary, #2d2e35);
    border-color: var(--accent-primary, #fb7299);
}

[data-theme="dark"] .episode-active {
    background: var(--accent-primary, #fb7299) !important;
    border-color: var(--accent-primary, #fb7299) !important;
    color: white !important;
}

/* 加载动画颜色 */
[data-theme="dark"] .loading-ring-bg {
    border-color: var(--bg-tertiary, #2d2e35);
}

[data-theme="dark"] .loading-ring-spin {
    border-top-color: var(--accent-primary, #fb7299);
}

[data-theme="dark"] .loading-ring-inner {
    border-bottom-color: var(--accent-tertiary, #ff9eb3);
}

[data-theme="dark"] .loading-text-main {
    color: var(--accent-primary, #fb7299);
}

[data-theme="dark"] .loading-text-sub {
    color: var(--text-muted, #6d757a);
}

/* 恢复播放位置提示 */
[data-theme="dark"] .position-restore-hint {
    background-color: var(--bg-secondary, #21222c);
    color: var(--text-primary, #f5f5f5);
    border-color: var(--border-color, #2d2e35);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* 快捷键提示 */
[data-theme="dark"] .shortcut-hint {
    background-color: var(--bg-secondary, #21222c);
    color: var(--text-primary, #f5f5f5);
    border-color: var(--border-color, #2d2e35);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* 滑块开关 */
[data-theme="dark"] .slider {
    background-color: var(--bg-tertiary, #2d2e35);
}

[data-theme="dark"] input:checked + .slider {
    background-color: var(--accent-primary, #fb7299);
}

/* 视频信息卡片 */
[data-theme="dark"] .video-info-card {
    background: var(--bg-secondary, #21222c);
}

[data-theme="dark"] .video-tag {
    background: linear-gradient(135deg, var(--accent-primary, #fb7299), var(--accent-secondary, #f06292));
}

[data-theme="dark"] .meta-label {
    color: var(--text-muted, #6d757a);
}

[data-theme="dark"] .meta-value {
    color: var(--text-secondary, #a2a7ae);
}

[data-theme="dark"] .video-desc {
    border-top-color: var(--border-color, #2d2e35);
}

[data-theme="dark"] .desc-content {
    color: var(--text-muted, #6d757a);
}

/* 资源切换按钮 */
[data-theme="dark"] .resource-switch-btn {
    color: var(--accent-primary, #fb7299);
}

[data-theme="dark"] .resource-switch-btn:hover {
    background: rgba(251, 114, 153, 0.1);
}

[data-theme="dark"] .resource-switch-icon {
    color: var(--accent-primary, #fb7299);
}

/* ========== 智能缓冲 UI 样式 ========== */

/* 动画关键帧 */
@keyframes smartBufferSpin {
    to { transform: rotate(360deg); }
}

@keyframes smartBufferPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes smartBufferShimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* 容器 */
.smart-buffer-ui {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(145deg, rgba(15,15,25,0.95) 0%, rgba(25,25,40,0.98) 100%);
    backdrop-filter: blur(20px);
    color: white;
    padding: 28px 36px;
    border-radius: 20px;
    text-align: center;
    z-index: 100;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.08), inset 0 1px 0 rgba(255,255,255,0.05);
    min-width: 260px;
    pointer-events: none;
    border: 1px solid rgba(35,173,229,0.15);
}

/* 头部区域 */
.smart-buffer-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 18px;
}

/* 旋转图标容器 */
.smart-buffer-spinner {
    position: relative;
    width: 36px;
    height: 36px;
}

.smart-buffer-spinner-bg {
    position: absolute;
    inset: 0;
    border: 3px solid rgba(35,173,229,0.2);
    border-radius: 50%;
}

.smart-buffer-spinner-outer {
    position: absolute;
    inset: 0;
    border: 3px solid transparent;
    border-top-color: #23ade5;
    border-radius: 50%;
    animation: smartBufferSpin 1s linear infinite;
}

.smart-buffer-spinner-inner {
    position: absolute;
    inset: 6px;
    border: 2px solid transparent;
    border-top-color: #67e8f9;
    border-radius: 50%;
    animation: smartBufferSpin 0.6s linear infinite reverse;
}

/* 标题区域 */
.smart-buffer-title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.smart-buffer-subtitle {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    font-weight: 400;
}

/* 进度条 */
.smart-buffer-progress {
    width: 220px;
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    overflow: hidden;
    margin: 0 auto;
    position: relative;
}

.smart-buffer-progress-shimmer {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    background-size: 200% 100%;
    animation: smartBufferShimmer 2s infinite;
}

.smart-buffer-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #23ade5, #67e8f9, #23ade5);
    background-size: 200% 100%;
    border-radius: 4px;
    transition: width 0.3s ease-out;
    box-shadow: 0 0 12px rgba(35,173,229,0.6), inset 0 1px 0 rgba(255,255,255,0.3);
}

/* 数字显示 */
.smart-buffer-count {
    margin-top: 14px;
    font-size: 15px;
    color: rgba(255,255,255,0.9);
    font-weight: 500;
}

.smart-buffer-count-current {
    color: #67e8f9;
    font-weight: 600;
    font-size: 17px;
}

.smart-buffer-count-total {
    color: rgba(255,255,255,0.4);
    font-size: 13px;
}

/* 提示区域 */
.smart-buffer-tips {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.smart-buffer-tip-text {
    font-size: 12px;
    color: rgba(255,255,255,0.45);
    line-height: 1.5;
    animation: smartBufferPulse 3s ease-in-out infinite;
}

/* ========== 移动端适配 (≤480px) ========== */
@media (max-width: 480px) {
    .smart-buffer-ui {
        padding: 18px 24px;
        min-width: 200px;
        max-width: 85vw;
        border-radius: 16px;
    }

    .smart-buffer-header {
        gap: 10px;
        margin-bottom: 14px;
    }

    .smart-buffer-spinner {
        width: 28px;
        height: 28px;
    }

    .smart-buffer-spinner-bg,
    .smart-buffer-spinner-outer {
        border-width: 2.5px;
    }

    .smart-buffer-spinner-inner {
        inset: 5px;
        border-width: 1.5px;
    }

    .smart-buffer-title {
        font-size: 15px;
    }

    .smart-buffer-subtitle {
        font-size: 10px;
    }

    .smart-buffer-progress {
        width: 160px;
        height: 6px;
    }

    .smart-buffer-count {
        margin-top: 10px;
        font-size: 13px;
    }

    .smart-buffer-count-current {
        font-size: 14px;
    }

    .smart-buffer-count-total {
        font-size: 11px;
    }

    /* 移动端隐藏底部提示区域 */
    .smart-buffer-tips {
        display: none;
    }
}
