:root {
    --bg-main: #0b0f17;
    --bg-card: #131926;
    --bg-card-hover: #1a2234;
    --bg-surface: #192236;
    --bg-glass: rgba(11, 15, 23, 0.88);
    
    --primary: #f43f5e;
    --primary-hover: #e11d48;
    --primary-glow: rgba(244, 63, 94, 0.3);
    
    --accent: #6366f1;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    
    --border: #1e293b;
    --border-highlight: #334155;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-full: 9999px;
    
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    padding-bottom: 72px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: var(--border-highlight);
    border-radius: var(--radius-full);
}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.header-container {
    max-width: 1380px;
    margin: 0 auto;
    padding: 0 20px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-main);
    user-select: none;
}

.brand-icon {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    color: #fff;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-name {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #fff;
}

/* Desktop Nav */
.nav-menu {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius-full);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.nav-link:hover {
    color: var(--text-main);
    background: var(--bg-card);
}

.nav-link.active {
    color: #fff;
    background: var(--bg-surface);
    border-color: var(--border-highlight);
}

/* Controls */
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-box {
    position: relative;
    width: 240px;
}

.search-input {
    width: 100%;
    padding: 8px 14px 8px 36px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text-main);
    font-size: 0.85rem;
    outline: none;
    transition: all 0.2s ease;
}

.search-input:focus {
    border-color: var(--primary);
    background: var(--bg-surface);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    pointer-events: none;
}

.lang-select-wrapper {
    position: relative;
}

.lang-select {
    appearance: none;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text-main);
    padding: 8px 30px 8px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.lang-select:focus {
    border-color: var(--primary);
}

.lang-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-dim);
    font-size: 0.6rem;
}

/* Container */
.container {
    max-width: 1380px;
    margin: 0 auto;
    padding: 24px 20px;
}

/* Hero Spotlight */
.hero-spotlight {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 36px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    min-height: 420px;
    display: flex;
    align-items: flex-end;
}

.hero-backdrop {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center 25%;
    filter: brightness(0.4) saturate(1.15);
}

.hero-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(0deg, var(--bg-card) 5%, rgba(19, 25, 38, 0.8) 50%, rgba(19, 25, 38, 0.3) 100%),
                linear-gradient(90deg, var(--bg-card) 0%, rgba(19, 25, 38, 0.7) 50%, transparent 100%);
}

.hero-content {
    position: relative;
    z-index: 2;
    padding: 36px;
    max-width: 720px;
}

.hero-badge-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.badge-tag {
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-tag.hot {
    background: var(--primary);
    color: #fff;
}

.badge-tag.sub {
    background: var(--bg-surface);
    color: var(--text-muted);
    border: 1px solid var(--border-highlight);
}

.hero-title {
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 14px;
    color: #fff;
    letter-spacing: -0.02em;
}

.hero-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 22px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hero-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--primary);
    color: #fff;
    padding: 11px 22px;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(8px);
    color: #fff;
    padding: 11px 22px;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: translateY(-1px);
}

/* Section Header */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.section-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: #fff;
}

.section-count {
    font-size: 0.8rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    background: var(--bg-surface);
    color: var(--text-dim);
    border: 1px solid var(--border);
}

/* Drama Grid */
.drama-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.drama-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
}

.drama-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-highlight);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.4);
}

.drama-poster-wrap {
    position: relative;
    width: 100%;
    padding-top: 140%;
    background: var(--bg-surface);
    overflow: hidden;
}

.drama-poster {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.drama-card:hover .drama-poster {
    transform: scale(1.05);
}

.poster-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    background: rgba(11, 15, 23, 0.8);
    backdrop-filter: blur(4px);
    color: #fff;
    text-transform: uppercase;
}

.poster-episodes {
    position: absolute;
    bottom: 8px;
    right: 8px;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    background: var(--primary);
    color: #fff;
}

.play-hover-overlay {
    position: absolute;
    inset: 0;
    background: rgba(11, 15, 23, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.drama-card:hover .play-hover-overlay {
    opacity: 1;
}

.play-hover-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 16px var(--primary-glow);
}

.drama-info {
    padding: 12px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.drama-card-title {
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.35;
    color: #fff;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.drama-card-meta {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(6, 8, 14, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal-container {
    background: var(--bg-card);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.7);
}

.modal-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(11, 15, 23, 0.8);
    border: 1px solid var(--border-highlight);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
}

.modal-close-btn:hover {
    background: var(--primary);
}

/* Detail Modal */
.detail-hero {
    padding: 30px;
    display: flex;
    gap: 24px;
    background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-card) 100%);
    border-bottom: 1px solid var(--border);
}

.detail-poster {
    width: 170px;
    height: 240px;
    border-radius: var(--radius-md);
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.detail-info {
    flex: 1;
}

.detail-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 10px;
    line-height: 1.3;
}

.detail-meta-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.detail-synopsis {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 20px;
    max-height: 110px;
    overflow-y: auto;
}

.detail-actions {
    display: flex;
    gap: 10px;
}

/* Episodes Grid */
.episodes-section {
    padding: 24px 30px;
}

.episodes-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.episodes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
}

.ep-btn {
    padding: 10px 0;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
}

.ep-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-highlight);
}

.ep-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.ep-btn.watched {
    border-color: rgba(16, 185, 129, 0.4);
    color: #34d399;
}

/* Video Player Modal */
.player-modal {
    max-width: 1060px;
    background: #000;
}

.player-layout {
    display: flex;
    height: 78vh;
    min-height: 500px;
}

.video-container {
    flex: 1;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#dramaVideo {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: 100%;
    object-fit: contain;
}

.player-sidebar {
    width: 300px;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.player-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.player-drama-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-ep-title {
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 600;
}

.player-ep-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    align-content: flex-start;
}

.player-bottom-controls {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.control-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: #fff;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.control-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.control-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    background: var(--bg-surface);
}

/* Spinner & States */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 0;
    color: var(--text-muted);
    gap: 14px;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.load-more-wrap {
    text-align: center;
    padding: 20px 0 40px;
}

/* Mobile Bottom Navigation */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    height: 56px;
    justify-content: space-around;
    align-items: center;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 600;
    cursor: pointer;
}

.mobile-nav-item.active {
    color: var(--primary);
}

.mobile-nav-item svg {
    width: 18px;
    height: 18px;
}

/* Responsive Breakpoints */
@media (max-width: 900px) {
    .nav-menu {
        display: none;
    }
    .mobile-nav {
        display: flex;
    }
    .search-box {
        width: 160px;
    }
    .hero-content {
        padding: 24px;
    }
    .hero-title {
        font-size: 1.6rem;
    }
    .player-layout {
        flex-direction: column;
        height: 85vh;
    }
    .player-sidebar {
        width: 100%;
        height: 220px;
    }
    .detail-hero {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .detail-meta-row,
    .detail-actions {
        justify-content: center;
    }
    .drama-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }
}
