/* ========== RESET & BASE ========== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-card: #1a1a1a;
    --bg-elevated: #222222;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --text-muted: #737373;
    --accent: #e50914;
    --accent-hover: #f40612;
    --accent-purple: #7c3aed;
    --border: #2a2a2a;
    --success: #22c55e;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow: 0 4px 20px rgba(0,0,0,0.5);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --nav-height: 64px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    display: block;
    max-width: 100%;
}

/* ========== NAVBAR ========== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(10, 10, 10, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    height: calc(var(--nav-height) + var(--safe-top));
    padding-top: var(--safe-top);
}

.nav-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    flex-shrink: 0;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    font-size: 16px;
}

.logo-text {
    background: linear-gradient(135deg, #fff 0%, #ccc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Search */
.search-container {
    position: relative;
    flex: 1;
    max-width: 480px;
}

#search-input {
    width: 100%;
    padding: 10px 16px;
    padding-left: 40px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 50px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

#search-input:focus {
    border-color: var(--accent);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.15);
}

.search-container::before {
    content: '🔍';
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    z-index: 1;
    pointer-events: none;
}

.search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    max-height: 400px;
    overflow-y: auto;
    display: none;
    box-shadow: var(--shadow);
    z-index: 100;
}

.search-dropdown.active {
    display: block;
}

.search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: var(--transition);
    min-height: 44px;
}

.search-item:hover {
    background: var(--bg-elevated);
}

.search-item img {
    width: 40px;
    height: 56px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.search-item-info {
    flex: 1;
    min-width: 0;
}

.search-item-info h4 {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-item-info p {
    font-size: 12px;
    color: var(--text-muted);
}

.nav-links {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.nav-link {
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    color: var(--text-secondary);
    white-space: nowrap;
}

.nav-link:hover, .nav-link.active {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

/* Hamburger button — hidden on desktop */
.nav-hamburger {
    display: none;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.nav-hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition);
    position: relative;
}

.nav-hamburger span::before,
.nav-hamburger span::after {
    content: '';
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    position: absolute;
    transition: var(--transition);
}

.nav-hamburger span::before { top: -7px; }
.nav-hamburger span::after { top: 7px; }

/* Hamburger open state */
.nav-hamburger.open span { background: transparent; }
.nav-hamburger.open span::before { top: 0; transform: rotate(45deg); }
.nav-hamburger.open span::after { top: 0; transform: rotate(-45deg); }

/* Mobile menu overlay — hidden on desktop */
.mobile-menu-overlay {
    display: none;
}

/* ========== MAIN ========== */
#app {
    min-height: calc(100vh - (var(--nav-height) + var(--safe-top)));
    padding-top: calc(var(--nav-height) + var(--safe-top));
}

/* ========== LOADING ========== */
.loading-spinner {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 100px 0;
}

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

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

/* ========== HERO ========== */
.hero {
    position: relative;
    height: 520px;
    overflow: hidden;
    margin-bottom: 40px;
}

.hero-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center top;
    filter: blur(2px);
    transform: scale(1.05);
}

.hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        rgba(10, 10, 10, 0.3) 0%,
        rgba(10, 10, 10, 0.6) 50%,
        rgba(10, 10, 10, 1) 100%
    );
}

.hero-content {
    position: absolute;
    bottom: 60px;
    left: 0;
    right: 0;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    z-index: 2;
}

.hero-content h1 {
    font-size: 48px;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 12px;
    max-width: 600px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.hero-content p {
    font-size: 16px;
    color: var(--text-secondary);
    max-width: 500px;
    margin-bottom: 20px;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hero-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.hero-meta .views {
    color: var(--accent);
    font-weight: 600;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(229, 9, 20, 0.4);
}

.btn-secondary {
    background: rgba(255,255,255,0.1);
    color: white;
    backdrop-filter: blur(10px);
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.2);
}

/* ========== CATEGORIES ========== */
.categories-section {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px 24px;
}

.category-pills {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.category-pills::-webkit-scrollbar {
    display: none;
}

.category-pill {
    flex-shrink: 0;
    padding: 8px 20px;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 500;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    min-height: 40px;
    display: flex;
    align-items: center;
}

.category-pill:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.category-pill.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* ========== SECTION HEADERS ========== */
.section-header {
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px 24px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.section-header h2 {
    font-size: 24px;
    font-weight: 700;
}

/* ========== DRAMA GRID ========== */
.drama-grid {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}

.drama-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    -webkit-tap-highlight-color: transparent;
}

.drama-card:hover {
    transform: translateY(-6px);
    border-color: var(--border);
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}

.drama-card-img {
    position: relative;
    aspect-ratio: 3/4;
    overflow: hidden;
    background: var(--bg-secondary);
}

.drama-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.drama-card:hover .drama-card-img img {
    transform: scale(1.08);
}

.drama-card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px;
    display: flex;
    justify-content: space-between;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.badge-episodes {
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    color: white;
}

.badge-views {
    background: rgba(229, 9, 20, 0.8);
    color: white;
}

.drama-card-info {
    padding: 12px;
}

.drama-card-info h3 {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.drama-card-info .card-cats {
    font-size: 11px;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ========== PAGINATION ========== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 40px 24px;
    flex-wrap: wrap;
}

.pagination button {
    padding: 10px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

.pagination button:hover:not(:disabled) {
    background: var(--bg-elevated);
    border-color: var(--accent);
}

.pagination button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pagination .page-info {
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* ========== DRAMA DETAIL ========== */
.drama-detail {
    padding-bottom: 60px;
}

.drama-banner {
    position: relative;
    height: 400px;
    overflow: hidden;
}

.drama-banner-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center top;
    filter: blur(4px);
    transform: scale(1.1);
}

.drama-banner-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        rgba(10, 10, 10, 0.4),
        rgba(10, 10, 10, 1)
    );
}

.drama-info {
    position: relative;
    max-width: 1400px;
    margin: -120px auto 0;
    padding: 0 24px;
    display: flex;
    gap: 32px;
    z-index: 2;
}

.drama-poster {
    flex-shrink: 0;
    width: 200px;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.drama-poster img {
    width: 100%;
    aspect-ratio: 3/4;
    object-fit: cover;
}

.drama-meta {
    flex: 1;
    padding-top: 20px;
    min-width: 0;
}

.drama-meta h1 {
    font-size: 36px;
    font-weight: 800;
    margin-bottom: 12px;
    line-height: 1.2;
}

.drama-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.drama-stats span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.drama-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.drama-categories .tag {
    padding: 4px 12px;
    background: var(--bg-elevated);
    border-radius: 50px;
    font-size: 12px;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.drama-description {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.7;
    max-width: 700px;
}

/* Episodes */
.episodes-section {
    max-width: 1400px;
    margin: 40px auto 0;
    padding: 0 24px;
}

.episodes-section h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 20px;
}

.episodes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
}

.episode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 14px 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

.episode-btn:hover {
    background: var(--bg-elevated);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.episode-btn .ep-num {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.episode-btn .ep-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
}

.episode-btn .ep-badge.free {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.episode-btn .ep-badge.premium {
    background: rgba(124, 58, 237, 0.15);
    color: var(--accent-purple);
}

/* ========== PLAYER PAGE ========== */
.player-page {
    display: flex;
    min-height: calc(100vh - var(--nav-height));
}

.player-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.video-wrapper {
    position: relative;
    width: 100%;
    background: #000;
    aspect-ratio: 16/9;
    max-height: calc(100vh - 180px);
}

.video-wrapper video {
    width: 100%;
    height: 100%;
    background: #000;
}

.video-error {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    gap: 12px;
    padding: 20px;
    text-align: center;
}

.video-error .error-icon {
    font-size: 48px;
}

.video-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.7);
    gap: 12px;
}

.player-controls {
    padding: 20px 24px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

.player-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
}

.player-nav {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.player-nav button {
    padding: 8px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

.player-nav button:hover:not(:disabled) {
    background: var(--accent);
    border-color: var(--accent);
}

.player-nav button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.player-sidebar {
    width: 320px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    max-height: calc(100vh - var(--nav-height));
    flex-shrink: 0;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 15px;
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sidebar-episode {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid rgba(42,42,42,0.5);
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
}

.sidebar-episode:hover {
    background: var(--bg-elevated);
}

.sidebar-episode.active {
    background: rgba(229, 9, 20, 0.1);
    border-left: 3px solid var(--accent);
}

.sidebar-episode .ep-number {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 30px;
}

.sidebar-episode.active .ep-number {
    color: var(--accent);
}

.sidebar-episode .ep-title {
    font-size: 13px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-episode .ep-free {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
    font-weight: 600;
}

/* ========== BACK LINK ========== */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    color: var(--text-secondary);
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.action-row {
    margin-top: 20px;
}

.player-back-link {
    padding: 0 0 12px;
}

.back-link:hover {
    color: var(--text-primary);
}

/* ========== FOOTER ========== */
.footer {
    border-top: 1px solid var(--border);
    padding: 32px 24px;
    text-align: center;
    padding-bottom: calc(32px + var(--safe-bottom));
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    font-size: 13px;
    color: var(--text-muted);
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ========== ANIMATIONS ========== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.4s ease forwards;
}

.no-results {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-muted);
    font-size: 18px;
}

/* ========== LOKLOK INTEGRATION STYLES ========== */

.search-source-label {
    padding: 8px 14px 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

.search-source-label:first-child {
    border-top: none;
}

.search-source-badge {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
}

.search-source-badge.popkon {
    background: rgba(229, 9, 20, 0.2);
    color: var(--accent);
}

.search-source-badge.loklok {
    background: rgba(99, 102, 241, 0.2);
    color: #818cf8;
}

.nav-link[href="#/loklok"] {
    position: relative;
}

.nav-link[href="#/loklok"].active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(168, 85, 247, 0.15));
    color: #a78bfa;
}

.loklok-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 50px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    color: white;
}

.loklok-search-bar {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px 24px;
    display: flex;
    gap: 10px;
}

.loklok-grid {
    padding-top: 0;
}

.loklok-search-bar input {
    flex: 1;
    padding: 12px 18px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
    min-width: 0;
}

.loklok-search-btn,
.loklok-back-btn {
    flex-shrink: 0;
}

.loklok-more-wrap {
    max-width: 1400px;
    margin: 24px auto;
    padding: 0 24px;
    text-align: center;
}

.loklok-search-bar input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.loklok-scan-prompt {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 24px;
    display: flex;
    justify-content: center;
}

.scan-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    text-align: center;
    max-width: 500px;
    width: 100%;
}

.scan-card h3 {
    font-size: 22px;
    margin-bottom: 12px;
}

.scan-card p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

.loklok-source-tag {
    background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
    color: white !important;
    border: none !important;
    font-weight: 600;
}

.loklok-tag-small {
    display: inline-flex;
    padding: 2px 8px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 50px;
    font-size: 10px;
    font-weight: 700;
    color: white;
    letter-spacing: 0.5px;
}

.loklok-quality-inline {
    display: flex;
    align-items: center;
}

.loklok-quality-selector {
    margin-top: 16px;
}

.quality-label {
    color: var(--text-secondary);
    font-size: 13px;
    margin-right: 8px;
}

.quality-select {
    min-height: 44px;
    padding: 6px 12px;
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
}

/* ========== AUTO-PLAY NEXT EPISODE OVERLAY ========== */
.autoplay-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: autoplayFadeIn 0.3s ease;
}

@keyframes autoplayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.autoplay-content {
    text-align: center;
    color: white;
    max-width: 320px;
    padding: 20px;
}

.autoplay-text {
    font-size: 14px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.autoplay-countdown {
    font-size: 64px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 12px;
}

.autoplay-next-title {
    font-size: 16px;
    color: white;
    margin-bottom: 24px;
    font-weight: 500;
    opacity: 0.9;
}

.autoplay-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.autoplay-buttons .btn {
    min-width: 120px;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
    min-height: 44px;
}

.autoplay-buttons .btn:hover {
    transform: scale(1.05);
}

.autoplay-now {
    background: var(--accent) !important;
    border: none !important;
    color: white !important;
}

.autoplay-cancel {
    background: rgba(255,255,255,0.15) !important;
    border: 1px solid rgba(255,255,255,0.3) !important;
    color: white !important;
}

@keyframes countdown-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}


/* ========== CUSTOM FULLSCREEN BUTTON ========== */
.custom-fullscreen-btn {
    position: absolute;
    bottom: 52px;  /* above native controls bar */
    right: 12px;
    z-index: 50;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 6px;
    padding: 6px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.25s ease, background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.video-wrapper:hover .custom-fullscreen-btn,
.video-wrapper.is-fullscreen .custom-fullscreen-btn {
    opacity: 1;
}

.custom-fullscreen-btn:hover {
    background: rgba(0, 0, 0, 0.85);
}

/* Hide native fullscreen button so users use our wrapper-based one */
video::-webkit-media-controls-fullscreen-button {
    display: none !important;
}

/* Wrapper-based fullscreen: video + overlay all visible */
.video-wrapper:-webkit-full-screen,
.video-wrapper:fullscreen {
    width: 100vw;
    height: 100vh;
    max-height: none;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-wrapper:-webkit-full-screen video,
.video-wrapper:fullscreen video {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    object-fit: contain;
}

.video-wrapper:-webkit-full-screen .autoplay-overlay,
.video-wrapper:fullscreen .autoplay-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
}

.video-wrapper:-webkit-full-screen .custom-fullscreen-btn,
.video-wrapper:fullscreen .custom-fullscreen-btn {
    position: fixed;
    bottom: 60px;
    right: 20px;
    z-index: 9998;
    opacity: 0;
}

.video-wrapper:-webkit-full-screen:hover .custom-fullscreen-btn,
.video-wrapper:fullscreen:hover .custom-fullscreen-btn {
    opacity: 1;
}

/* When video-wrapper is fullscreen, also hide native controls fullscreen btn */
.video-wrapper:-webkit-full-screen video::-webkit-media-controls-fullscreen-button,
.video-wrapper:fullscreen video::-webkit-media-controls-fullscreen-button {
    display: none !important;
}

/* =========================================================
   RESPONSIVE — TABLET (≤ 1024px)
   ========================================================= */
@media (max-width: 1024px) {
    .player-page {
        flex-direction: column;
    }

    .player-sidebar {
        width: 100%;
        max-height: 40vh;
        border-left: none;
        border-top: 1px solid var(--border);
    }

    .video-wrapper {
        max-height: 50vh;
    }

    .drama-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 16px;
    }

    .hero {
        height: 450px;
    }

    .hero-content h1 {
        font-size: 40px;
    }

    .drama-banner {
        height: 350px;
    }
}


/* =========================================================
   RESPONSIVE — MOBILE LANDSCAPE & SMALL TABLETS (≤ 768px)
   ========================================================= */
@media (max-width: 768px) {
    :root {
        --nav-height: 108px;
    }

    /* Show hamburger, hide nav links */
    .nav-hamburger {
        display: flex;
    }

    .nav-links {
        display: none;
    }

    /* Mobile menu overlay */
    .mobile-menu-overlay {
        position: fixed;
        top: calc(var(--nav-height) + var(--safe-top));
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(10, 10, 10, 0.97);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        z-index: 999;
        display: none;
        flex-direction: column;
        padding: 24px;
        gap: 8px;
        animation: mobileMenuSlide 0.2s ease;
    }

    .mobile-menu-overlay.open {
        display: flex;
    }

    @keyframes mobileMenuSlide {
        from { opacity: 0; transform: translateY(-10px); }
        to { opacity: 1; transform: translateY(0); }
    }

    .mobile-menu-overlay .nav-link {
        display: flex;
        align-items: center;
        padding: 16px 20px;
        font-size: 18px;
        font-weight: 600;
        border-radius: var(--radius-md);
        min-height: 56px;
    }

    .mobile-menu-overlay .nav-link.active {
        background: var(--bg-elevated);
    }

    .mobile-menu-overlay .nav-link[href="#/loklok"].active {
        background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(168, 85, 247, 0.15));
        color: #a78bfa;
    }

    /* Navbar */
    .nav-content {
        display: grid;
        grid-template-columns: auto 1fr auto;
        align-items: center;
        gap: 10px 12px;
        padding: 12px 16px 14px;
    }

    .logo {
        font-size: 18px;
    }

    .logo-icon {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .search-container {
        grid-column: 1 / -1;
        max-width: none;
    }

    #search-input {
        font-size: 16px; /* prevent iOS zoom */
        padding: 8px 14px 8px 36px;
    }

    .search-container::before {
        left: 12px;
    }

    .search-dropdown {
        position: fixed;
        top: calc(var(--nav-height) + var(--safe-top));
        left: 0;
        right: 0;
        max-height: 60vh;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    /* Hero */
    .hero {
        height: 380px;
        margin-bottom: 24px;
    }

    .hero-content {
        bottom: 40px;
        padding: 0 16px;
    }

    .hero-content h1 {
        font-size: 28px;
        max-width: 100%;
    }

    .hero-content p {
        font-size: 14px;
        -webkit-line-clamp: 2;
    }

    .hero-meta {
        gap: 12px;
        font-size: 13px;
    }

    .btn {
        padding: 10px 22px;
        font-size: 14px;
    }

    /* Grid */
    .drama-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
        padding: 0 16px;
    }

    .drama-card:hover {
        transform: none; /* disable hover lift on touch */
    }

    /* Section headers */
    .section-header {
        padding: 24px 16px 12px;
        align-items: flex-start;
    }

    .section-header h2 {
        font-size: 20px;
    }

    /* Categories */
    .categories-section {
        padding: 0 16px 16px;
    }

    /* Drama Detail */
    .drama-banner {
        height: 280px;
    }

    .drama-info {
        flex-direction: column;
        align-items: center;
        text-align: center;
        margin-top: -80px;
        padding: 0 16px;
        gap: 20px;
    }

    .drama-poster {
        width: 140px;
    }

    .drama-meta {
        padding-top: 0;
    }

    .drama-meta h1 {
        font-size: 24px;
    }

    .drama-stats {
        justify-content: center;
    }

    .drama-categories {
        justify-content: center;
    }

    .drama-description {
        font-size: 14px;
        text-align: left;
    }

    .episodes-section {
        padding: 0 16px;
        margin-top: 32px;
    }

    .episodes-section h2 {
        font-size: 20px;
    }

    .episodes-grid {
        grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
        gap: 8px;
    }

    /* Player */
    .player-page {
        flex-direction: column;
    }

    .player-sidebar {
        width: 100%;
        max-height: 35vh;
        border-left: none;
        border-top: 1px solid var(--border);
    }

    .video-wrapper {
        aspect-ratio: 16/9;
        max-height: 40vh;
    }

    .player-controls {
        padding: 16px;
    }

    .player-title {
        font-size: 16px;
    }

    .player-nav {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .player-nav button {
        padding: 8px 14px;
        font-size: 12px;
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    .loklok-quality-inline {
        grid-column: 1 / -1;
        width: 100%;
    }

    .quality-label {
        display: block;
        margin: 0 0 8px;
        text-align: left;
    }

    .quality-select,
    .loklok-quality-inline .quality-select {
        width: 100%;
    }

    .back-link {
        padding: 8px 0;
        font-size: 13px;
    }

    /* Autoplay overlay */
    .autoplay-countdown {
        font-size: 48px;
    }

    .autoplay-next-title {
        font-size: 14px;
    }

    .autoplay-buttons {
        flex-direction: column;
        gap: 8px;
    }

    .autoplay-buttons .btn {
        min-width: 100%;
    }

    /* LokLok search bar */
    .loklok-search-bar {
        padding: 0 16px 16px;
        flex-direction: column;
        gap: 8px;
    }

    .loklok-search-btn,
    .loklok-back-btn {
        width: 100%;
    }

    .loklok-more-wrap {
        padding: 0 16px;
    }

    .loklok-search-bar input {
        font-size: 16px; /* prevent iOS zoom */
    }

    .loklok-scan-prompt {
        padding: 24px 16px;
    }

    .scan-card {
        padding: 24px;
    }

    .scan-card h3 {
        font-size: 18px;
    }

    /* Pagination */
    .pagination {
        padding: 32px 16px;
        gap: 6px;
    }

    .sidebar-episode .ep-title {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    /* Footer */
    .footer {
        padding: 24px 16px;
    }

    .no-results {
        padding: 40px 16px;
        font-size: 16px;
    }
}


/* =========================================================
   RESPONSIVE — SMALL MOBILE (≤ 480px)
   ========================================================= */
@media (max-width: 480px) {
    :root {
        --nav-height: 102px;
    }

    .hero {
        height: 320px;
        margin-bottom: 20px;
    }

    .hero-content {
        bottom: 30px;
    }

    .hero-content h1 {
        font-size: 24px;
    }

    .hero-content p {
        font-size: 13px;
        margin-bottom: 14px;
    }

    .drama-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 0 12px;
    }

    .drama-card-info {
        padding: 10px;
    }

    .drama-card-info h3 {
        font-size: 13px;
    }

    .categories-section {
        padding: 0 12px 12px;
    }

    .section-header {
        padding: 20px 12px 10px;
    }

    .nav-content {
        padding: 10px 12px 12px;
        gap: 8px 10px;
    }

    .logo {
        font-size: 16px;
        gap: 8px;
    }

    .logo-text {
        font-size: 16px;
    }

    .search-dropdown {
        max-height: 55vh;
    }

    /* Drama detail */
    .drama-info {
        padding: 0 12px;
    }

    .drama-poster {
        width: 120px;
    }

    .drama-meta h1 {
        font-size: 22px;
    }

    .drama-stats {
        gap: 12px;
        font-size: 13px;
    }

    .episodes-section {
        padding: 0 12px;
    }

    .episodes-grid {
        grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
        gap: 6px;
    }

    .episode-btn {
        padding: 10px 6px;
    }

    .episode-btn .ep-num {
        font-size: 16px;
    }

    /* Player */
    .player-controls {
        padding: 12px;
    }

    .player-title {
        font-size: 15px;
        margin-bottom: 10px;
    }

    .sidebar-episode {
        padding: 10px 12px;
    }

    .player-nav {
        grid-template-columns: 1fr;
    }

    /* Autoplay */
    .autoplay-content {
        padding: 16px;
    }

    .autoplay-countdown {
        font-size: 40px;
    }

    .autoplay-text {
        font-size: 12px;
    }

    .autoplay-next-title {
        font-size: 13px;
        margin-bottom: 16px;
    }
}


/* =========================================================
   RESPONSIVE — LANDSCAPE MOBILE (short + wide)
   ========================================================= */
@media (max-height: 500px) and (orientation: landscape) {
    .video-wrapper {
        aspect-ratio: unset;
        max-height: calc(100vh - var(--nav-height));
        height: calc(100vh - var(--nav-height));
    }

    .player-page {
        flex-direction: row;
    }

    .player-sidebar {
        width: 280px;
        max-height: calc(100vh - var(--nav-height));
        border-left: 1px solid var(--border);
        border-top: none;
    }

    .player-controls {
        display: none; /* controls are on the video in landscape */
    }
}


/* =========================================================
   TOUCH DEVICE OPTIMIZATIONS
   ========================================================= */
@media (hover: none) and (pointer: coarse) {
    .drama-card:hover {
        transform: none;
        box-shadow: none;
        border-color: transparent;
    }

    .drama-card:hover .drama-card-img img {
        transform: none;
    }

    .drama-card:active {
        transform: scale(0.97);
        transition: transform 0.1s ease;
    }

    .episode-btn:hover {
        transform: none;
    }

    .episode-btn:active {
        background: var(--bg-elevated);
        border-color: var(--accent);
    }

    .sidebar-episode:active {
        background: var(--bg-elevated);
    }

    .btn:hover {
        transform: none;
    }

    .btn:active {
        transform: scale(0.97);
    }
}
