/* =========================================
   1. 全局变量与深色模式自适应 (Dark Mode)
   ========================================= */
:root {
    /* 默认浅色主题（二次元明快风格） */
    --bg-color: #f4f6f8;
    --header-bg: #ffffff;
    --card-bg: #ffffff;
    --text-main: #333333;
    --text-muted: #888888;
    --primary-color: #ff6b81; 
    --primary-hover: #ff4757;
    --border-color: #eeeeee;
    --shadow: 0 4px 12px rgba(0,0,0,0.05);
}

/* 当系统开启深色模式时自动切换 */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #121212;
        --header-bg: #1e1e1e;
        --card-bg: #252525;
        --text-main: #e0e0e0;
        --text-muted: #999999;
        --primary-color: #ff4757;
        --primary-hover: #ff6b81;
        --border-color: #333333;
        --shadow: 0 4px 12px rgba(0,0,0,0.3);
    }
}

/* =========================================
   2. 基础重置与排版 (Reset)
   ========================================= */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color-scheme: light dark; /* 原生滚动条适配深色 */
}
a { text-decoration: none; color: inherit; transition: color 0.2s; }
ul { list-style: none; }
button { font-family: inherit; }

/* =========================================
   3. 核心布局 (Layout)
   ========================================= */
.container { max-width: 1200px; margin: 20px auto; padding: 0 20px; }
.main-layout { display: flex; gap: 20px; max-width: 1200px; margin: 20px auto; padding: 0 20px; }
.content-left { flex: 1; min-width: 0; } /* min-width:0 防止被子元素撑破 flex 布局 */
.sidebar-right { width: 300px; flex-shrink: 0; }
.section-title { font-size: 20px; border-left: 4px solid var(--primary-color); padding-left: 10px; margin-bottom: 15px; }
.breadcrumbs { max-width: 1200px; margin: 10px auto; padding: 0 20px; font-size: 14px; color: var(--text-muted); }
.breadcrumbs a:hover { color: var(--primary-color); }

/* =========================================
   4. 导航栏与页脚 (Header & Footer)
   ========================================= */
.header { background: var(--header-bg); box-shadow: var(--shadow); position: sticky; top: 0; z-index: 100; }
.nav-container { max-width: 1200px; margin: 0 auto; padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; }
.logo { font-size: 24px; font-weight: bold; color: var(--primary-color); }
.nav-links { display: flex; gap: 20px; }
.nav-links a:hover { color: var(--primary-color); }
.search-form { display: flex; }
.search-input { background: var(--bg-color); border: 1px solid var(--border-color); color: var(--text-main); padding: 8px 15px; border-radius: 20px 0 0 20px; outline: none; transition: border 0.3s; }
.search-input:focus { border-color: var(--primary-color); }
.search-btn { background: var(--primary-color); color: white; border: none; padding: 8px 15px; border-radius: 0 20px 20px 0; cursor: pointer; transition: background 0.3s; }
.search-btn:hover { background: var(--primary-hover); }

/* =========================================
   5. 视频网格与卡片 (Video Cards)
   ========================================= */
.vod-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 15px; margin-bottom: 30px; }
.vod-card { background: var(--card-bg); border-radius: 8px; overflow: hidden; box-shadow: var(--shadow); transition: transform 0.2s, box-shadow 0.2s; position: relative; display: flex; flex-direction: column; }
.vod-card:hover { transform: translateY(-5px); box-shadow: 0 8px 20px rgba(255, 71, 87, 0.2); }
.vod-pic { position: relative; width: 100%; padding-top: 140%; background: var(--border-color); overflow: hidden; }
.vod-pic img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; }
.vod-badge { position: absolute; top: 5px; left: 5px; background: linear-gradient(45deg, #ff4757, #ff6b81); color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 4px; z-index: 2; }
.vod-remarks { position: absolute; bottom: 5px; right: 5px; background: rgba(0,0,0,0.7); color: #fff; font-size: 12px; padding: 2px 6px; border-radius: 4px; z-index: 2; }
.vod-info { padding: 10px; }
.vod-info h3 { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vod-info p { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
/* 图片懒加载 */
img.lazyload { opacity: 0; transition: opacity 0.3s; }
img.lazyload.loaded { opacity: 1; }

/* =========================================
   6. 通用组件：Tabs切换与排行榜 (Tabs & Ranks)
   ========================================= */
.schedule-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; border-bottom: 1px solid var(--border-color); padding-bottom: 10px; }
.schedule-tabs { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; }
.schedule-tabs::-webkit-scrollbar { display: none; }
.tab-btn { padding: 6px 16px; border-radius: 20px; cursor: pointer; background: var(--bg-color); color: var(--text-muted); border: 1px solid var(--border-color); white-space: nowrap; font-size: 14px; transition: 0.3s; }
.tab-btn:hover { color: var(--primary-color); border-color: var(--primary-color); }
.tab-btn.active { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.rank-box { background: var(--card-bg); border-radius: 8px; padding: 15px; margin-bottom: 20px; box-shadow: var(--shadow); }
.rank-list li { display: flex; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--border-color); }
.rank-list li:last-child { border-bottom: none; }
.rank-num { width: 24px; height: 24px; text-align: center; line-height: 24px; background: var(--border-color); color: var(--text-muted); border-radius: 4px; margin-right: 12px; font-weight: bold; font-size: 12px; }
.rank-list li:nth-child(1) .rank-num { background: #ff4757; color: #fff; }
.rank-list li:nth-child(2) .rank-num { background: #ff7f50; color: #fff; }
.rank-list li:nth-child(3) .rank-num { background: #ffa502; color: #fff; }
.rank-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.rank-name:hover { color: var(--primary-color); }
.rank-hits { font-size: 12px; color: var(--text-muted); }

/* =========================================
   7. 首页专属：轮播图 (Hero Slider)
   ========================================= */
.hero-slider { position: relative; width: 100%; height: 380px; border-radius: 12px; overflow: hidden; margin-bottom: 30px; box-shadow: var(--shadow); }
.slide-item { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 0.5s ease; z-index: 1; }
.slide-item.active { opacity: 1; z-index: 2; }
.slide-img { width: 100%; height: 100%; object-fit: cover; }
.slide-mask { position: absolute; bottom: 0; left: 0; width: 100%; height: 50%; background: linear-gradient(to top, rgba(0,0,0,0.8), transparent); display: flex; align-items: flex-end; padding: 20px; }
.slide-title { color: #fff; font-size: 24px; font-weight: bold; margin-bottom: 5px; }
.slide-desc { color: #ccc; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.slider-dots { position: absolute; bottom: 20px; right: 20px; z-index: 3; display: flex; gap: 8px; }
.dot { width: 10px; height: 10px; background: rgba(255,255,255,0.5); border-radius: 50%; cursor: pointer; transition: 0.3s; }
.dot.active { background: var(--primary-color); width: 25px; border-radius: 5px; }

/* =========================================
   8. 详情页专属：资料卡与简介 (Detail Hero & Plot)
   ========================================= */
.detail-hero { position: relative; border-radius: 12px; overflow: hidden; margin-bottom: 25px; box-shadow: var(--shadow); background: #000; }
.hero-bg { position: absolute; top: -10%; left: -10%; width: 120%; height: 120%; background-size: cover; background-position: center; filter: blur(30px) brightness(0.6); opacity: 0.8; z-index: 1; }
.hero-mask { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(to right, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.4) 100%); z-index: 2; }
.hero-content { position: relative; z-index: 3; display: flex; padding: 30px; gap: 30px; }
.hero-poster { width: 200px; flex-shrink: 0; position: relative; border-radius: 8px; overflow: hidden; box-shadow: 0 10px 20px rgba(0,0,0,0.5); border: 2px solid rgba(255,255,255,0.1); }
.hero-poster img { width: 100%; display: block; }
.hero-info { flex: 1; color: #fff; display: flex; flex-direction: column; justify-content: center; }
.hero-title { font-size: 28px; font-weight: bold; margin-bottom: 10px; display: flex; align-items: center; gap: 15px;}
.hero-score { font-size: 18px; color: #ffa502; font-weight: bold; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 4px 15px; font-size: 14px; color: #ccc; margin-bottom: 15px; line-height: 1.8; }
.meta-truncate { width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-actions { display: flex; gap: 15px; margin-top: auto; }
.btn-play, .btn-collect { padding: 10px 25px; border-radius: 30px; font-size: 16px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: 0.3s; border: none; }
.btn-play { background: var(--primary-color); color: #fff; box-shadow: 0 4px 15px rgba(255, 71, 87, 0.4); }
.btn-play:hover { background: var(--primary-hover); transform: translateY(-2px); color: #fff;}
.btn-collect { background: rgba(255,255,255,0.1); color: #fff; border: 1px solid rgba(255,255,255,0.3); backdrop-filter: blur(5px); }
.btn-collect:hover { background: rgba(255,255,255,0.2); color: #fff; }

.plot-box { position: relative; color: var(--text-main); font-size: 14px; line-height: 1.8; }
.plot-text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; transition: all 0.3s; }
.plot-text.expanded { display: block; -webkit-line-clamp: unset; }
.btn-expand-plot { display: inline-block; color: var(--primary-color); cursor: pointer; margin-top: 5px; font-weight: bold; }

/* =========================================
   9. 选集网格与分组 (Episodes List)
   ========================================= */
.play-box { background: var(--card-bg); border-radius: 12px; padding: 20px; margin-bottom: 25px; box-shadow: var(--shadow); }
.play-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.btn-sort { background: var(--bg-color); border: 1px solid var(--border-color); color: var(--text-main); padding: 5px 15px; border-radius: 20px; cursor: pointer; font-size: 13px; transition: 0.3s; }
.btn-sort:hover { color: var(--primary-color); border-color: var(--primary-color); }

.ep-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 10px; }
.ep-btn { display: block; text-align: center; padding: 8px 5px; border-radius: 6px; background: var(--bg-color); border: 1px solid var(--border-color); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: all 0.2s; }
.ep-btn:hover { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }
.ep-btn:visited { background: transparent; color: var(--text-muted); border-style: dashed; } /* 历史记录变灰 */
.ep-btn.playing { background: var(--primary-color) !important; color: #fff !important; border-color: var(--primary-color) !important; box-shadow: 0 4px 10px rgba(255, 71, 87, 0.3); }

/* 分组区间胶囊 */
.ep-ranges { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 15px; padding-bottom: 8px; scrollbar-width: none; }
.ep-ranges::-webkit-scrollbar { display: none; }
.range-btn { padding: 4px 12px; border-radius: 4px; background: rgba(0,0,0,0.05); color: var(--text-muted); font-size: 13px; cursor: pointer; white-space: nowrap; transition: 0.2s; }
.range-btn:hover { color: var(--primary-color); }
.range-btn.active { background: var(--bg-color); color: var(--primary-color); border-color: var(--primary-color); font-weight: bold; }
@media (prefers-color-scheme: dark) { .range-btn { background: rgba(255,255,255,0.05); } .range-btn.active { background: var(--card-bg); } }

/* =========================================
   10. 播放页专属 (Play Page UI)
   ========================================= */
.play-wrapper { background: #000; border-radius: 12px 12px 0 0; overflow: hidden; width: 100%; position: relative; aspect-ratio: 16 / 9; box-shadow: 0 10px 20px rgba(0,0,0,0.2); z-index: 10; }
.play-wrapper iframe { width: 100%; height: 100%; border: none; display: block; }
.play-toolbar-bottom { background: var(--card-bg); padding: 12px 20px; border-radius: 0 0 12px 12px; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center; box-shadow: var(--shadow); }
.play-title { font-size: 16px; font-weight: bold; display: flex; align-items: center; gap: 10px; }
.play-title .ep-tag { background: var(--primary-color); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 4px; font-weight: normal;}
.play-actions { display: flex; gap: 15px; }
.action-btn { background: transparent; border: none; color: var(--text-main); font-size: 14px; cursor: pointer; display: flex; align-items: center; gap: 5px; transition: 0.2s; }
.action-btn:hover { color: var(--primary-color); }

/* 侧边栏选集区滚动限制 (PC端) */
.playlist-scroll-area { max-height: 400px; overflow-y: auto; padding-right: 5px; }
.playlist-scroll-area::-webkit-scrollbar { width: 6px; }
.playlist-scroll-area::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
.playlist-scroll-area::-webkit-scrollbar-thumb:hover { background: var(--primary-color); }

/* 关灯模式 */
.light-off-mask { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.95); z-index: 9; opacity: 0; visibility: hidden; transition: 0.4s ease; }
.light-off-mask.active { opacity: 1; visibility: visible; }
body.is-light-off .play-wrapper, body.is-light-off .play-toolbar-bottom { z-index: 11; position: relative; }

/* =========================================
   11. 分类筛选页专属 (Type/Filter Page)
   ========================================= */
.filter-box { background: var(--card-bg); border-radius: 12px; padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow); }
.filter-line { display: flex; align-items: flex-start; margin-bottom: 15px; border-bottom: 1px dashed var(--border-color); padding-bottom: 15px; }
.filter-line:last-child { margin-bottom: 0; border-bottom: none; padding-bottom: 0; }
.filter-label { flex-shrink: 0; width: 60px; color: var(--text-muted); font-size: 14px; font-weight: bold; line-height: 28px; }
.filter-list { display: flex; flex-wrap: wrap; gap: 10px; flex: 1; }
.filter-list a { padding: 2px 14px; border-radius: 20px; font-size: 14px; color: var(--text-main); transition: all 0.2s; line-height: 24px; }
.filter-list a:hover { color: var(--primary-color); }
.filter-list a.active { background: var(--primary-color); color: #fff; font-weight: bold; box-shadow: 0 4px 10px rgba(255, 71, 87, 0.3); }

.sort-bar { display: flex; justify-content: space-between; align-items: center; background: var(--card-bg); padding: 12px 20px; border-radius: 8px; margin-bottom: 20px; box-shadow: var(--shadow); }
.sort-links { display: flex; gap: 20px; }
.sort-links a { font-size: 14px; color: var(--text-main); font-weight: 500; transition: 0.2s; }
.sort-links a:hover, .sort-links a.active { color: var(--primary-color); }
.sort-stat { font-size: 13px; color: var(--text-muted); }
.sort-stat span { color: var(--primary-color); font-weight: bold; margin: 0 3px; }

/* 分页组件 */
.page-nav { display: flex; flex-direction: column; align-items: center; gap: 15px; margin: 40px 0; }
.page-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.page-links a { min-width: 36px; height: 36px; display: flex; justify-content: center; align-items: center; padding: 0 10px; background: var(--card-bg); border-radius: 6px; font-size: 14px; color: var(--text-main); box-shadow: var(--shadow); transition: 0.2s; }
.page-links a:hover { color: var(--primary-color); }
.page-links a.active { background: var(--primary-color); color: #fff; font-weight: bold; }
.page-info { font-size: 13px; color: var(--text-muted); }

/* =========================================
   12. 全局悬浮与移动端适配 (Responsive)
   ========================================= */
.back-to-top { position: fixed; bottom: 30px; right: 30px; width: 40px; height: 40px; background: var(--primary-color); color: white; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 20px; cursor: pointer; box-shadow: var(--shadow); opacity: 0; visibility: hidden; transition: 0.3s; z-index: 99; }
.back-to-top.show { opacity: 1; visibility: visible; }
.menu-toggle { display: none; font-size: 24px; cursor: pointer; }

@media (max-width: 900px) {
    .main-layout { flex-direction: column; }
    .sidebar-right { width: 100%; }
    .hero-slider { height: 200px; }
    .slide-title { font-size: 18px; }
}

@media (max-width: 768px) {
    /* 视频卡片 */
    .vod-list { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
    /* 导航栏折叠 */
    .menu-toggle { display: block; }
    .nav-links { display: none; position: absolute; top: 60px; left: 0; right: 0; background: var(--header-bg); flex-direction: column; padding: 10px 20px; box-shadow: 0 10px 10px rgba(0,0,0,0.1); }
    .nav-links.active { display: flex; }
    .search-form { display: none; }
    /* 详情页资料卡 */
    .hero-content { flex-direction: column; align-items: center; text-align: center; padding: 20px; }
    .hero-poster { width: 140px; }
    .hero-title { flex-direction: column; gap: 5px; font-size: 22px; }
    .hero-actions { justify-content: center; width: 100%; margin-top: 15px; }
    .btn-play, .btn-collect { flex: 1; justify-content: center; }
    /* 选集网格 */
    .ep-list { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); }
    /* 播放页 */
    .play-toolbar-bottom { flex-direction: column; gap: 12px; align-items: flex-start; }
    .play-actions { width: 100%; justify-content: space-between; border-top: 1px dashed var(--border-color); padding-top: 10px; }
    .playlist-scroll-area { max-height: none; overflow-y: visible; padding-right: 0; }
    /* 筛选页 */
    .filter-box { padding: 15px; }
    .filter-line { align-items: center; }
    .filter-list { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
    .filter-list::-webkit-scrollbar { display: none; }
    /* ★ 新增 flex-shrink: 0 防止被挤压，确保能够触发滑动 ★ */
    .filter-list a { white-space: nowrap; flex-shrink: 0; }
    .sort-bar { flex-direction: column; gap: 10px; align-items: flex-start; }
}