:root {
    --bg-primary: #0a0c0f;
    --bg-secondary: #161a22;
    --brand-color: #00aeec;
    --text-main: #f1f2f3;
    --text-muted: #9499a0;
    --card-radius: 12px;
    --transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    --header-bg: rgba(10, 12, 15, 0.9);
    --input-bg: rgba(255, 255, 255, 0.06);
    --border-color: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] {
    --bg-primary: #f4f6f9;
    --bg-secondary: #ffffff;
    --brand-color: #00aeec;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --header-bg: rgba(255, 255, 255, 0.9);
    --input-bg: rgba(0, 0, 0, 0.05);
    --border-color: rgba(0, 0, 0, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    background-color: var(--bg-primary);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    overflow-x: hidden;
    padding-bottom: 70px;
    touch-action: pan-x pan-y;
    transition: background-color var(--transition), color var(--transition);
}

header {
    position: fixed; top: 0; left: 0; width: 100%; height: 60px;
    background: var(--header-bg) !important; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    display: flex; align-items: center; justify-content: space-between; padding-left: 14px; padding-right: 7px;
    z-index: 100; border-bottom: 1px solid var(--border-color) !important; gap: 15px;
    transition: background var(--transition), border-color var(--transition);
}

.logo-container { display: flex; flex-direction: column; justify-content: center; flex-shrink: 0; }
.logo { font-size: 22px; font-weight: 900; color: var(--brand-color); letter-spacing: 1px; display: flex; align-items: center; line-height: 1; }
.logo i { margin-right: 5px; }
.logo span { color: var(--text-main) !important; transition: color var(--transition); }

nav.top-nav { display: flex; gap: 5px; }
.nav-item { padding: 6px 12px; color: var(--text-muted); font-size: 13px; font-weight: 600; border-radius: 20px; cursor: pointer; transition: var(--transition); white-space: nowrap; }
.nav-item:hover, .nav-item.active { color: #fff !important; background-color: var(--brand-color); }

.header-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.icon-btn { background: none; border: none; color: var(--text-main); font-size: 18px; cursor: pointer; transition: var(--transition); width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.icon-btn:hover { background: rgba(255,255,255,0.08); color: var(--brand-color); }

[data-theme="light"] .icon-btn:hover {
    background: rgba(0,0,0,0.05);
}

.theme-btn { color: #ffb300; }
[data-theme="light"] .theme-btn { color: #ff9100; }

.gift-btn { color: #ffca28; }
.gift-btn:hover { color: #ffe082; }

.search-container { display: none; position: relative; }
.search-input-wrapper { position: relative; width: 100%; }
.search-input-wrapper input { width: 100%; background: var(--input-bg) !important; border: 1px solid var(--border-color) !important; padding: 6px 35px 6px 12px; border-radius: 20px; color: var(--text-main) !important; font-size: 13px; outline: none; transition: var(--transition); height: 29px; }
.search-input-wrapper input:focus { border-color: var(--brand-color) !important; background: rgba(255,255,255,0.1); }
[data-theme="light"] .search-input-wrapper input:focus { background: rgba(0,0,0,0.02); }
.search-input-wrapper i { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 13px; pointer-events: none; }

.mobile-search-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 60px; background: var(--bg-primary) !important; z-index: 101; display: none; align-items: center; padding: 0 15px; gap: 10px; border-bottom: 1px solid var(--border-color) !important; transition: background var(--transition); }
.mobile-search-wrapper { position: relative; flex-grow: 1; display: flex; align-items: center; }
.mobile-search-wrapper input { width: 100%; background: var(--input-bg) !important; border: 1px solid var(--border-color) !important; padding: 10px 40px 10px 15px; border-radius: 20px; color: var(--text-main) !important; font-size: 14px; outline: none; transition: var(--transition); }
.mobile-search-wrapper input:focus { border-color: var(--brand-color) !important; }
.mobile-search-clear { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; color: var(--text-muted); font-size: 14px; background: none; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.mobile-search-clear:hover { color: var(--text-main); background: rgba(255,255,255,0.05); }

.qris-popup-overlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(10,12,15,0.85); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    display: none; align-items: center; justify-content: center; 
    z-index: 100000; opacity: 0; transition: opacity 0.3s ease; 
    padding: 20px;
}

[data-theme="light"] .qris-popup-overlay {
    background: rgba(244, 246, 249, 0.85);
}

.qris-popup-overlay.show { display: flex; opacity: 1; }

.qris-card { 
    background: transparent; border: none; border-radius: 16px; 
    padding: 0; width: auto; max-width: 90vw; max-height: 85vh; 
    text-align: center; position: relative; 
    transform: scale(0.8); transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1); 
    display: flex; align-items: center; justify-content: center;
}
.qris-popup-overlay.show .qris-card { transform: scale(1); }

.qris-qr-frame { 
    background: transparent; padding: 0; 
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: auto; max-height: 85vh;
}
.qris-qr-frame img { 
    width: auto; height: auto; 
    max-width: 100%; max-height: 80vh; 
    object-fit: contain; border-radius: 16px; display: block; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.app-layout {
    margin-top: 60px; display: flex; flex-direction: column; width: 100%;
    max-width: 1600px; margin-left: auto; margin-right: auto;
}

.player-section {
    width: 100%; background-color: var(--bg-secondary); display: none; 
    position: -webkit-sticky; position: sticky; top: 60px;
    aspect-ratio: 16 / 9; transition: var(--transition); z-index: 30;
}
.player-section iframe { width: 100%; height: 100%; border: none; }

.player-section.pip-mode {
    display: block !important; position: fixed; bottom: 80px; right: 15px;
    width: 340px; height: 190px; border-radius: 12px; overflow: hidden;
    box-shadow: 0 10px 25px rgba(0,0,0,0.8); z-index: 999;
    cursor: move;
    touch-action: none;
}

.close-pip-btn {
    position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,0.6); color: #fff;
    border: none; border-radius: 50%; width: 24px; height: 24px; display: none;
    align-items: center; justify-content: center; font-size: 11px; cursor: pointer; z-index: 1000;
}
.close-pip-btn:hover { background: rgba(255,0,0,0.8); }
.player-section.pip-mode .close-pip-btn { display: flex; }

.content-section { padding: 20px; width: 100%; }

.episode-box { 
    background-color: var(--bg-secondary); 
    padding: 15px; 
    border-radius: var(--card-radius); 
    margin-bottom: 20px; 
    display: none; 
    position: -webkit-sticky; position: sticky;
    top: calc(60px + 56.25vw); 
    z-index: 20;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    transition: background-color var(--transition);
}
.episode-title { font-size: 13px; font-weight: 700; margin-bottom: 10px; color: var(--text-main); transition: color var(--transition); }
.episode-list { display: flex; gap: 10px; overflow-x: auto; scroll-behavior: smooth; padding-bottom: 5px; -webkit-overflow-scrolling: touch; }
.episode-list::-webkit-scrollbar { height: 4px; }
.episode-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
[data-theme="light"] .episode-list::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); }
.episode-btn {
    flex: 0 0 auto; padding: 10px 20px; background-color: rgba(255,255,255,0.05);
    color: var(--text-main); border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; transition: var(--transition);
}
[data-theme="light"] .episode-btn { background-color: rgba(0,0,0,0.04); }
.episode-btn.active { background-color: var(--brand-color); color: #fff; font-weight: 700; }

.video-grid { 
    display: grid; 
    grid-template-columns: repeat(2, 1fr); 
    gap: 12px; 
}

.video-card {
    background-color: var(--bg-secondary); border-radius: var(--card-radius);
    overflow: hidden; cursor: pointer; transition: var(--transition);
    display: flex; flex-direction: column; border: 1px solid var(--border-color) !important;
}
.video-card:hover { transform: translateY(-4px); border-color: rgba(0, 174, 236, 0.3) !important; box-shadow: 0 6px 16px rgba(0,0,0,0.1); }
/* Backup Kode Asli
.thumb-wrap { position: relative; width: 100%; padding-top: 56.25%; background-color: var(--bg-secondary); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.thumb-wrap img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; } */
.thumb-wrap { position: relative; width: 100%; padding-top: 56.25%; background-color: var(--bg-secondary); overflow: hidden; }
.thumb-wrap img { position: absolute; top: 50%; left: 0; width: 100% !important; height: auto !important; transform: translateY(-50%); object-fit: fill !important; }

.badge-tag { position: absolute; top: 6px; left: 6px; background: var(--brand-color); color: #fff; padding: 2px 6px; font-size: 10px; font-weight: bold; border-radius: 4px; z-index: 2; }

.card-info { padding: 12px; display: flex; flex-direction: column; justify-content: space-between; flex-grow: 1; }
.video-title { font-size: 13px; font-weight: 600; line-height: 1.4; color: var(--text-main); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 6px; transition: color var(--transition); }
.video-meta { font-size: 11px; display: flex; justify-content: space-between; align-items: center; width: 100%; } 
.video-rating { color: #ffca28; font-weight: 600; display: flex; align-items: center; gap: 3px; }

.bottom-nav { position: fixed; bottom: 0; left: 0; width: 100%; height: 56px; background-color: var(--bg-secondary); border-top: 1px solid var(--border-color); display: flex; justify-content: space-around; align-items: center; z-index: 99; transition: background-color var(--transition), border-color var(--transition); }
.bottom-nav-item { display: flex; flex-direction: column; align-items: center; color: var(--text-muted); font-size: 10px; gap: 4px; cursor: pointer; transition: color var(--transition); }
.bottom-nav-item i { font-size: 16px; }
.bottom-nav-item.active { color: var(--brand-color); }

@media (max-width: 768px) {
    header { height: 45px; }
    .app-layout { margin-top: 45px; }
    .player-section { top: 45px !important; }
    .episode-box { top: calc(45px + 56.25vw) !important; }
    nav.top-nav { display: none; }
    header { justify-content: space-between; }
    .search-btn-desktop { display: none; }
    .search-btn-mobile { display: flex; }
    .content-section { padding: 12px; }
    
    .mobile-search-overlay { 
        height: 45px; 
    }
    .mobile-search-wrapper input {
        padding: 6px 40px 6px 15px; 
        font-size: 13px;
    }
    .mobile-search-clear {
        width: 28px;
        height: 28px;
    }

    .player-section.pip-mode {
        display: block !important;
        position: fixed !important;
        width: calc(65% - 18px) !important;
        aspect-ratio: 16 / 9 !important;
        height: auto !important;
        bottom: 64px !important;
        right: 12px !important;
        top: auto !important;
        left: auto !important;
        border-radius: var(--card-radius);
        box-shadow: 0 4px 20px rgba(0,0,0,0.7);
        z-index: 9999 !important;
    }

    .player-section.pip-mode .close-pip-btn {
        width: 22px;
        height: 22px;
        font-size: 11px;
        top: 6px;
        left: 6px;
    }
}

@media (min-width: 769px) or (orientation: landscape) {
    .bottom-nav { display: none; }
    nav.top-nav { display: flex; gap: 3px; } 
    .search-btn-mobile { display: none; }
    header { display: flex; align-items: center; justify-content: space-between; }
    .search-container { display: block; flex-grow: 1; margin: 0 20px; max-width: 300px; } 
    .header-actions { gap: 10px; } 
    .player-section.pip-mode { bottom: 20px; right: 20px; width: 340px; height: 190px; }
}

@media (orientation: landscape) or (min-width: 1024px) {
    .app-layout.playing { display: flex; flex-direction: row; height: calc(100vh - 60px); }
    
    .app-layout.playing .player-section:not(.pip-mode) { position: relative; top: 0; flex: 0 0 65%; height: 100%; max-height: calc(100vh - 60px); }
    .app-layout.playing .content-section { flex: 0 0 35%; height: 100%; overflow-y: auto; padding: 5px 15px 15px 15px; border-left: 1px solid var(--border-color); }
    .app-layout.playing .video-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px; }
    .app-layout.playing .episode-box { top: 0px; margin-top: -5px; margin-bottom: 12px; }

    .app-layout.playing .player-section.pip-mode { 
        position: fixed !important; 
        top: 65px !important; 
        right: 20px !important; 
        bottom: auto !important;
        left: auto !important;
        width: calc(40% - 20px) !important; 
        height: auto !important; 
        aspect-ratio: 16 / 9 !important; 
        background-color: var(--bg-secondary) !important; 
        border: 1px solid var(--border-color) !important; 
        border-radius: var(--card-radius) !important; 
        box-shadow: 0 10px 30px rgba(0,0,0,0.8) !important; 
        flex: none !important; 
        z-index: 9999 !important; 
    }
    
    .app-layout.playing.import-pip-grid .content-section { 
        flex: 0 0 100%; 
        max-width: 100%; 
        height: auto; 
        overflow-y: visible; 
        border-left: none; 
        padding-right: calc(40% + 10px); 
    }
    
    .app-layout.playing.import-pip-grid .video-grid { grid-template-columns: repeat(4, 1fr) !important; gap: 12px; }
}

@media (min-width: 601px) and (max-width: 1024px) {
    .video-grid { grid-template-columns: repeat(3, 1fr); gap: 15px; }
    .app-layout.playing.import-pip-grid .video-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 15px; }
    .app-layout.playing.import-pip-grid .content-section { padding-right: calc(40% + 15px); }
}

@media (min-width: 1025px) {
    .app-layout:not(.playing) .video-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
    .app-layout.playing.import-pip-grid .video-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)) !important; gap: 16px; }
}

.pip-info-box {
    display: none; 
    background-color: var(--bg-secondary);
    padding: 10px 12px;
    border-top: 1px solid var(--border-color);
    width: 100%;
    box-sizing: border-box;
    transition: background-color var(--transition);
}

.pip-info-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-main);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
    text-align: left;
    transition: color var(--transition);
}

.pip-info-meta {
    font-size: 11px;
    color: var(--brand-color);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    text-align: left;
}

@media (orientation: landscape) or (min-width: 1024px) {
    .app-layout.playing .player-section.pip-mode { 
        position: fixed !important; 
        top: 65px !important; 
        right: 20px !important; 
        bottom: auto !important;
        left: auto !important;
        
        width: calc(40% - 20px) !important; 
        height: auto !important; 
        aspect-ratio: unset !important; 
        
        background-color: var(--bg-secondary) !important; 
        border: 1px solid var(--border-color) !important; 
        border-radius: var(--card-radius) !important; 
        box-shadow: 0 10px 30px rgba(0,0,0,0.8) !important; 
        flex: none !important; 
        z-index: 9999 !important; 
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        transition: background-color var(--transition), border-color var(--transition);
    }

    .app-layout.playing .player-section.pip-mode iframe {
        width: 100% !important;
        aspect-ratio: 16 / 9 !important;
        height: auto !important;
        display: block !important;
    }

    .app-layout.playing .player-section.pip-mode .pip-info-box {
        display: block !important;
    }
}