:root {
    --bg: #1a1d2e;
    --bg2: #252840;
    --bg3: #2d3150;
    --primary: #7c6ff7;
    --secondary: #5ce1e6;
    --accent: #ff7eb9;
    --text: #e8eaf0;
    --text2: #a8aec8;
    --text3: #6b7394;
    --border: rgba(124, 111, 247, 0.18);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
    margin: 0;
    min-height: 100vh;
    line-height: 1.6;
    position: relative;
}

/* 背景图片 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -2;
    opacity: 0.15;
}

/* PC端背景 */
@media (min-width: 769px) {
    body::before {
        background-image: url('https://bing.img.run/rand.php');
    }
}

/* 手机端背景 */
@media (max-width: 768px) {
    body::before {
        background-image: url('https://bing.img.run/rand_m.php');
    }
}

/* 深色遮蔽层 */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(10, 12, 25, 0.55);
    z-index: -1;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.container.has-player { max-width: 100%; }

nav { 
    height: 60px; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border);
}
.nav-brand { 
    font-size: 22px; 
    font-weight: 700; 
    color: var(--primary);
    letter-spacing: -0.5px;
}
.nav-tag { font-size: 13px; color: var(--text2); }

.search-section { max-width: 600px; margin: 60px auto 50px; text-align: center; }
.clock {
    font-size: 64px;
    font-weight: 700;
    color: var(--secondary);
    margin-bottom: 10px;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 20px rgba(92, 225, 230, 0.25);
}
h1 { 
    font-size: 28px; 
    font-weight: 600; 
    margin: 0 0 35px; 
    color: var(--text2);
}

.search-bar {
    display: flex;
    background: var(--bg2);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 6px;
    transition: all 0.3s;
}
.search-bar:focus-within { 
    border-color: var(--primary);
    box-shadow: 0 4px 20px rgba(124, 111, 247, 0.25);
}

#kw {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    padding: 12px 16px;
    color: var(--text);
    font-size: 15px;
}
#kw::placeholder { color: var(--text3); }

.btn-go {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 28px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.btn-go:hover { 
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(124, 111, 247, 0.35);
}

.grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); 
    gap: 20px;
    /* 限制最大列数，避免结果太多时太密集 */
    max-width: 1200px;
    margin: 0 auto;
}

.movie-card { 
    cursor: pointer; 
    transition: transform 0.3s; 
    /* 防止卡片内容溢出 */
    overflow: hidden;
}
.movie-card:hover { transform: translateY(-5px); }

.poster {
    aspect-ratio: 2/3;
    background: var(--bg2);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    border: 2px solid transparent;
    transition: all 0.3s;
}
.movie-card:hover .poster {
    border-color: var(--primary);
    box-shadow: 0 10px 30px rgba(124, 111, 247, 0.25);
}
.poster img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s; }
.movie-card:hover .poster img { transform: scale(1.05); }

.remarks {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px;
    background: linear-gradient(transparent, rgba(0,0,0,.85));
    font-size: 11px;
    color: #fff;
    font-weight: 500;
}

.m-title { 
    margin-top: 10px; 
    font-size: 14px; 
    font-weight: 500; 
    /* 最多两行，超出省略 */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
    min-height: 39px;
}
.m-source { 
    margin-top: 4px; 
    font-size: 12px; 
    color: var(--text3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 播放器 */
.player-view { display: none; animation: fadeIn 0.4s; }
@keyframes fadeIn { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:none} }

.player-view.active {
    display: block !important;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
}

.player-header { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    margin-bottom: 15px; 
}

.player-title {
    text-align: center;
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 15px;
    color: var(--text);
}

.back-btn {
    cursor: pointer;
    color: var(--text2);
    padding: 8px 16px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
}
.back-btn:hover { 
    color: var(--text); 
    border-color: var(--primary);
    background: rgba(124, 111, 247, 0.15);
}
.back-btn::before { content: '← '; }

.control-btn {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 16px;
    color: var(--text2);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}
.control-btn:hover { 
    color: var(--text); 
    border-color: var(--secondary);
    background: rgba(92, 225, 230, 0.12);
}
.control-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
}

.main-stage {
    background: #0d0f1a;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 16/9;
    position: relative;
    border: none;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

iframe { 
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

.player-loading {
    position: absolute;
    inset: 0;
    background: rgba(13, 15, 26, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}
.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(124, 111, 247, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to{transform:rotate(360deg)} }
.loading-text { color: var(--text2); margin-top: 15px; font-size: 14px; }

.player-error {
    position: absolute;
    inset: 0;
    background: rgba(13, 15, 26, 0.98);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 11;
    padding: 40px;
    text-align: center;
}
.error-icon { font-size: 48px; margin-bottom: 15px; }
.error-title { font-size: 18px; margin-bottom: 8px; font-weight: 600; }
.error-message { color: var(--text3); margin-bottom: 20px; font-size: 14px; }
.error-actions { display: flex; gap: 10px; }
.error-btn {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: transform 0.2s;
}
.error-btn:hover { transform: translateY(-2px); }
.error-btn.secondary { 
    background: var(--bg2); 
    border: 1px solid var(--border); 
    color: var(--text2);
}
.error-btn.secondary:hover { color: var(--text); }

.player-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    margin-top: 10px;
    border-bottom: 1px solid var(--border);
}

.toolbar-left, .toolbar-right {
    display: flex;
    gap: 12px;
}

.toolbar-btn {
    background: transparent;
    border: none;
    color: var(--text2);
    font-size: 14px;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.2s;
}
.toolbar-btn:hover {
    color: var(--text);
}

/* 当前线路名称高亮 */
#currentLineName {
    color: var(--secondary);
    font-weight: 500;
}

.toolbar-btn.icon-btn {
    font-size: 18px;
}

.toolbar-btn.dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
}

.toolbar-btn.dropdown-toggle .arrow {
    font-size: 10px;
    transition: transform 0.2s;
}

.toolbar-btn.dropdown-toggle.active .arrow {
    transform: rotate(180deg);
}

/* 下拉菜单 */
.dropdown-container {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 150px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 100;
    display: none;
    margin-top: 8px;
    backdrop-filter: blur(10px);
}

.dropdown-menu.show {
    display: block;
    animation: dropdownFade 0.2s ease-out;
}

@keyframes dropdownFade {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-items {
    padding: 6px;
    max-height: 250px;
    overflow-y: auto;
}

.dropdown-items::-webkit-scrollbar {
    width: 4px;
}

.dropdown-items::-webkit-scrollbar-track {
    background: transparent;
}

.dropdown-items::-webkit-scrollbar-thumb {
    background: rgba(108, 92, 231, 0.3);
    border-radius: 2px;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: none;
    color: var(--text2);
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    border-radius: 6px;
    transition: all 0.2s;
    font-weight: 500;
}

.dropdown-item:hover {
    background: rgba(108, 92, 231, 0.15);
    color: var(--text);
}

.dropdown-item.active {
    background: var(--primary);
    color: white;
}

.dropdown-item.active:hover {
    background: var(--primary);
    color: white;
}

.video-info-card {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    padding: 15px;
    background: var(--bg2);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.poster-small {
    width: 100px;
    height: 140px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
}

.poster-small img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.info-content {
    flex: 1;
    min-width: 0;
}

.video-info-card h2 {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 8px;
    color: var(--text);
}

.video-meta {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.meta-tag {
    font-size: 12px;
    color: var(--text2);
    padding: 3px 8px;
    background: var(--bg3);
    border-radius: 4px;
}

.director-info, .actor-info, .status-info, .date-info {
    font-size: 13px;
    color: var(--text2);
    margin-bottom: 6px;
    line-height: 1.6;
}

.director-info .label, .actor-info .label, .status-info .label, .date-info .label {
    color: var(--text3);
}

.director-info .value, .actor-info .value, .status-info .value, .date-info .value {
    color: var(--text2);
}

.view-intro {
    color: var(--primary);
    cursor: pointer;
    margin-left: 5px;
}

.intro-text {
    color: var(--text3);
    font-size: 13px;
    margin: 10px 0 0;
    line-height: 1.6;
    display: none;
    max-height: 100px;
    overflow-y: auto;
}

.play-area {
    margin-top: 20px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
}

.source-tabs { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 8px; 
    margin-bottom: 15px; 
}

.source-tab {
    padding: 6px 14px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text2);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}
.source-tab:hover { 
    color: var(--text); 
    border-color: var(--primary);
    background: rgba(124, 111, 247, 0.2);
}
.source-tab.active { 
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.ep-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.ep-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.ep-count {
    font-size: 13px;
    color: var(--text3);
}

.ep-sort {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: var(--text2);
}

.sort-btn {
    background: transparent;
    border: none;
    color: var(--text2);
    cursor: pointer;
    padding: 2px 5px;
    font-size: 14px;
}

.ep-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); 
    gap: 8px; 
    max-height: 240px;
    overflow-y: auto;
    padding-right: 5px;
}

.ep-grid::-webkit-scrollbar {
    width: 6px;
}

.ep-grid::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.ep-grid::-webkit-scrollbar-thumb {
    background: rgba(108, 92, 231, 0.3);
    border-radius: 3px;
}

.ep-item {
    background: var(--bg3);
    padding: 10px 6px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    text-align: center;
    color: var(--text2);
    border: 1px solid var(--border);
    transition: all 0.2s;
    font-weight: 500;
}
.ep-item:hover { 
    color: var(--text); 
    border-color: var(--primary);
    background: rgba(124, 111, 247, 0.2);
    transform: translateY(-2px);
}
.active-ep { 
    background: var(--primary); 
    color: white; 
    border-color: var(--primary);
}

.status-text { margin-top: 15px; font-size: 13px; color: var(--text2); }

.empty-state, .error-state { text-align: center; padding: 60px 20px; grid-column: 1/-1; }
.empty-state svg, .error-state svg { 
    width: 60px; 
    height: 60px; 
    margin-bottom: 15px; 
    opacity: 0.5; 
    color: var(--primary);
}
.empty-state h3, .error-state h3 { font-size: 16px; font-weight: 600; margin: 0 0 8px; color: var(--text); }
.empty-state p, .error-state p { color: var(--text3); margin: 0; font-size: 14px; }

.search-history { margin-top: 25px; text-align: left; }
.search-history-header { margin-bottom: 10px; }
.search-history-title { font-size: 14px; color: var(--text2); font-weight: 500; }
.history-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.hot-tag {
    padding: 8px 16px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text2);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}
.hot-tag:hover { 
    color: var(--text); 
    border-color: var(--primary);
    background: rgba(124, 111, 247, 0.2);
    transform: translateY(-2px);
}

/* 更多结果提示 */
.more-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 30px 20px;
    color: var(--text3);
    font-size: 14px;
}
.more-results p {
    margin: 5px 0;
}
.more-hint {
    font-size: 12px;
    opacity: 0.7;
}

footer {
    border-top: 1px solid var(--border);
    padding: 40px 0;
    margin-top: 60px;
    text-align: center;
    color: var(--text3);
    font-size: 13px;
}
footer span {
    color: var(--primary);
    font-weight: 600;
}

.hidden { display: none; }

@media (max-width: 768px) {
    .container { padding: 0 12px; }
    nav { height: 50px; margin-bottom: 20px; }
    .clock { font-size: 48px; }
    h1 { font-size: 22px; }
    .search-section { margin: 40px auto 30px; }
    
    /* 移动端优化网格 - 3列布局，更紧凑 */
    .grid { 
        grid-template-columns: repeat(3, 1fr); 
        gap: 10px; 
    }
    
    .movie-card:hover { transform: none; } /* 移动端禁用hover效果 */
    
    .poster { border-radius: 6px; }
    .m-title { font-size: 12px; margin-top: 6px; min-height: 34px; line-height: 1.3; }
    .m-source { font-size: 11px; margin-top: 2px; }
    
    .player-view.active { padding: 0 12px; margin: 0 auto; }
    
    .player-header {
        margin-bottom: 10px;
    }
    
    .player-title {
        font-size: 14px;
        margin-bottom: 12px;
    }
    
    .video-info-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .poster-small {
        width: 120px;
        height: 168px;
    }
    
    .info-content {
        width: 100%;
    }
    
    .video-info-card h2 {
        font-size: 18px;
    }
    
    .video-meta {
        justify-content: center;
    }
    
    .director-info, .actor-info, .status-info, .date-info {
        text-align: left;
    }
    
    .ep-grid { 
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        max-height: 200px;
    }
}

@media (max-width: 480px) {
    /* 超小屏幕使用2列布局 */
    .grid { 
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .m-title { font-size: 11px; min-height: 30px; }
    .m-source { font-size: 10px; }
    
    .ep-grid { 
        grid-template-columns: repeat(auto-fill, minmax(65px, 1fr)); 
        max-height: 180px;
    }
    
    .source-tab {
        padding: 5px 10px;
        font-size: 12px;
    }
}