:root {
  --bg: #0a0a0a; --bg2: #141414; --bg3: #1e1e1e; --bg4: #2a2a2a;
  --text: #f0f0f0; --text2: #b0b0b0; --text3: #707070;
  --accent: #e50914; --accent2: #ff3d47; --accent3: #b20710;
  --gold: #f5c518; --green: #2ecc71; --blue: #3498db;
  --radius: 8px; --radius-lg: 16px;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
  --nav-h: 56px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; overflow-x: hidden; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent2); }
img { max-width: 100%; height: auto; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { background: var(--bg3); border: 1px solid var(--bg4); color: var(--text); border-radius: var(--radius); padding: 10px 14px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

/* Nav */
#main-nav { position: fixed; top: 0; left: 0; right: 0; height: var(--nav-h); background: rgba(10,10,10,0.95); backdrop-filter: blur(10px); z-index: 1000; border-bottom: 1px solid var(--bg3); }
.nav-inner { max-width: 1200px; margin: 0 auto; height: 100%; display: flex; align-items: center; padding: 0 16px; gap: 20px; }
.nav-logo { font-size: 1.3rem; font-weight: 700; color: var(--accent) !important; white-space: nowrap; }
.nav-links { display: flex; gap: 6px; margin-left: auto; align-items: center; flex-wrap: nowrap; overflow-x: auto; }
.nav-links a, .nav-links button { padding: 6px 12px; border-radius: var(--radius); font-size: 0.85rem; white-space: nowrap; transition: background 0.2s; color: var(--text2); }
.nav-links a:hover, .nav-links button:hover { background: var(--bg3); color: var(--text); }
.nav-links a.active { background: var(--accent); color: #fff; }
.nav-links .coins-badge { background: var(--gold); color: #000; padding: 4px 10px; border-radius: 20px; font-weight: 700; font-size: 0.8rem; }
.nav-toggle { display: none; font-size: 1.5rem; margin-left: auto; }
.nav-mobile { display: none; background: var(--bg2); border-bottom: 1px solid var(--bg3); padding: 8px 16px; }
.nav-mobile.open { display: flex; flex-direction: column; gap: 4px; }
.nav-mobile a, .nav-mobile button { padding: 10px; border-radius: var(--radius); color: var(--text2); text-align: left; }
.nav-mobile a:hover, .nav-mobile button:hover { background: var(--bg3); }

/* Main content */
#main-content { margin-top: var(--nav-h); min-height: calc(100vh - var(--nav-h)); }

/* Container */
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.container-sm { max-width: 480px; margin: 0 auto; padding: 20px 16px; }

/* Hero */
.hero { position: relative; min-height: 400px; background: linear-gradient(135deg, var(--accent3) 0%, var(--bg) 70%); display: flex; align-items: flex-end; padding: 40px 0; overflow: hidden; }
.hero::before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: linear-gradient(to top, var(--bg) 0%, transparent 60%); }
.hero-content { position: relative; z-index: 2; }
.hero h1 { font-size: 2.5rem; font-weight: 800; margin-bottom: 8px; }
.hero p { color: var(--text2); font-size: 1.1rem; margin-bottom: 20px; max-width: 500px; }
.hero-stats { display: flex; gap: 24px; margin-bottom: 20px; }
.hero-stats span { font-size: 0.9rem; color: var(--text2); }
.hero-stats strong { color: var(--gold); }

/* Sections */
.section { padding: 32px 0; }
.section-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.section-title .badge { background: var(--accent); color: #fff; font-size: 0.7rem; padding: 2px 8px; border-radius: 20px; }

/* Genre tabs */
.genre-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 16px; scrollbar-width: none; }
.genre-tabs::-webkit-scrollbar { display: none; }
.genre-tab { padding: 6px 16px; border-radius: 20px; background: var(--bg3); color: var(--text2); font-size: 0.85rem; white-space: nowrap; transition: all 0.2s; cursor: pointer; border: none; }
.genre-tab:hover { background: var(--bg4); color: var(--text); }
.genre-tab.active { background: var(--accent); color: #fff; }

/* Drama grid */
.drama-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
.drama-card { border-radius: var(--radius-lg); overflow: hidden; background: var(--bg2); transition: transform 0.2s, box-shadow 0.2s; cursor: pointer; }
.drama-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.drama-card .poster { aspect-ratio: 3/4; background: var(--bg3); position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 3rem; }
.drama-card .poster .badge-free { position: absolute; top: 8px; left: 8px; background: var(--green); color: #fff; font-size: 0.65rem; padding: 2px 8px; border-radius: 20px; font-weight: 700; }
.drama-card .poster .badge-featured { position: absolute; top: 8px; right: 8px; background: var(--gold); color: #000; font-size: 0.65rem; padding: 2px 8px; border-radius: 20px; font-weight: 700; }
.drama-card .poster .genre-tag { position: absolute; bottom: 8px; left: 8px; background: rgba(0,0,0,0.7); color: var(--text2); font-size: 0.7rem; padding: 2px 8px; border-radius: 4px; }
.drama-card .info { padding: 10px; }
.drama-card .info h3 { font-size: 0.9rem; font-weight: 600; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.drama-card .info .meta { font-size: 0.75rem; color: var(--text3); display: flex; gap: 8px; }

/* Drama detail */
.drama-detail { padding-top: 0; }
.drama-banner { height: 280px; background: linear-gradient(135deg, var(--accent3), var(--bg3)); position: relative; display: flex; align-items: flex-end; }
.drama-banner .overlay { position: absolute; inset: 0; background: linear-gradient(to top, var(--bg) 10%, transparent 70%); }
.drama-banner .content { position: relative; z-index: 2; padding: 20px; width: 100%; }
.drama-banner h1 { font-size: 1.8rem; font-weight: 800; margin-bottom: 4px; }
.drama-banner .genre-badge { display: inline-block; background: var(--accent); color: #fff; font-size: 0.75rem; padding: 2px 10px; border-radius: 20px; margin-bottom: 8px; }
.drama-meta { display: flex; gap: 16px; margin: 16px 0; flex-wrap: wrap; }
.drama-meta .stat { display: flex; align-items: center; gap: 4px; color: var(--text2); font-size: 0.85rem; }
.drama-actions { display: flex; gap: 10px; margin: 16px 0; flex-wrap: wrap; }
.drama-desc { color: var(--text2); font-size: 0.95rem; line-height: 1.6; margin-bottom: 24px; }

/* Episode list */
.episode-list { display: flex; flex-direction: column; gap: 8px; }
.episode-item { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--bg2); border-radius: var(--radius); cursor: pointer; transition: background 0.2s; }
.episode-item:hover { background: var(--bg3); }
.episode-item.locked { opacity: 0.85; }
.episode-num { width: 36px; height: 36px; border-radius: 50%; background: var(--bg4); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; flex-shrink: 0; }
.episode-item.playing .episode-num { background: var(--accent); color: #fff; }
.episode-info { flex: 1; min-width: 0; }
.episode-info h4 { font-size: 0.9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.episode-info p { font-size: 0.75rem; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.episode-lock { display: flex; align-items: center; gap: 4px; color: var(--gold); font-size: 0.8rem; font-weight: 600; flex-shrink: 0; }

/* Video player */
.video-player-page { padding: 0; }
.video-container { position: relative; width: 100%; max-width: 420px; margin: 0 auto; background: #000; aspect-ratio: 9/16; max-height: 80vh; }
.video-container video { width: 100%; height: 100%; object-fit: contain; }
.video-overlay { position: absolute; bottom: 0; left: 0; right: 0; padding: 20px; background: linear-gradient(to top, rgba(0,0,0,0.8), transparent); }
.video-overlay h3 { font-size: 1rem; margin-bottom: 4px; }
.video-overlay p { font-size: 0.8rem; color: var(--text2); }
.video-nav { display: flex; justify-content: center; gap: 16px; padding: 16px; }
.video-unlock-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.85); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; z-index: 10; }
.video-unlock-overlay .lock-icon { font-size: 3rem; }
.video-unlock-overlay p { color: var(--text2); text-align: center; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px; border-radius: var(--radius); font-weight: 600; font-size: 0.9rem; transition: all 0.2s; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--bg4); }
.btn-secondary:hover { background: var(--bg4); }
.btn-gold { background: var(--gold); color: #000; }
.btn-gold:hover { background: #e0b400; }
.btn-green { background: var(--green); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Coin store */
.coin-packages { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.coin-card { background: var(--bg2); border: 2px solid var(--bg3); border-radius: var(--radius-lg); padding: 24px; text-align: center; transition: all 0.2s; cursor: pointer; }
.coin-card:hover { border-color: var(--gold); transform: translateY(-4px); box-shadow: 0 0 30px rgba(245,197,24,0.15); }
.coin-card.popular { border-color: var(--gold); position: relative; }
.coin-card.popular::before { content: 'POPULAR'; position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background: var(--gold); color: #000; font-size: 0.65rem; font-weight: 700; padding: 2px 12px; border-radius: 20px; }
.coin-card h3 { font-size: 1rem; margin-bottom: 8px; }
.coin-card .amount { font-size: 2rem; font-weight: 800; color: var(--gold); }
.coin-card .bonus { color: var(--green); font-size: 0.85rem; margin: 4px 0 12px; }
.coin-card .price { font-size: 1.3rem; font-weight: 700; }

/* Forms / Auth */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: calc(100vh - var(--nav-h)); }
.auth-card { background: var(--bg2); border-radius: var(--radius-lg); padding: 40px; width: 100%; max-width: 400px; margin: 20px; }
.auth-card h2 { text-align: center; margin-bottom: 24px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 0.85rem; color: var(--text2); font-weight: 600; }
.form-error { color: var(--accent); font-size: 0.8rem; margin-top: 4px; }
.form-divider { text-align: center; margin: 16px 0; color: var(--text3); font-size: 0.85rem; }

/* Coin balance widget */
.coin-widget { background: linear-gradient(135deg, var(--bg3), var(--bg2)); border: 1px solid var(--bg4); border-radius: var(--radius-lg); padding: 20px; margin-bottom: 24px; }
.coin-widget .balance { font-size: 2.5rem; font-weight: 800; color: var(--gold); }
.coin-widget .label { color: var(--text2); font-size: 0.85rem; }
.coin-widget .actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* Library */
.library-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.library-tab { padding: 8px 16px; border-radius: var(--radius); background: var(--bg3); color: var(--text2); font-size: 0.85rem; cursor: pointer; border: none; }
.library-tab.active { background: var(--accent); color: #fff; }

/* Admin */
.admin-layout { display: flex; min-height: calc(100vh - var(--nav-h)); }
.admin-sidebar { width: 240px; background: var(--bg2); border-right: 1px solid var(--bg3); padding: 20px 0; flex-shrink: 0; }
.admin-sidebar a { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: var(--text2); font-size: 0.9rem; transition: all 0.2s; }
.admin-sidebar a:hover { background: var(--bg3); color: var(--text); }
.admin-sidebar a.active { background: rgba(229,9,20,0.15); color: var(--accent); border-right: 3px solid var(--accent); }
.admin-main { flex: 1; padding: 24px; overflow-x: auto; }
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.admin-header h1 { font-size: 1.5rem; }

/* Stats cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--bg2); border-radius: var(--radius-lg); padding: 20px; }
.stat-card .label { color: var(--text3); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .value { font-size: 2rem; font-weight: 800; margin: 4px 0; }
.stat-card .value.accent { color: var(--accent); }
.stat-card .value.gold { color: var(--gold); }
.stat-card .value.green { color: var(--green); }
.stat-card .value.blue { color: var(--blue); }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--bg2); border-radius: var(--radius-lg); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 16px; text-align: left; border-bottom: 1px solid var(--bg3); font-size: 0.85rem; white-space: nowrap; }
th { color: var(--text3); font-weight: 600; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.5px; background: var(--bg3); }
tr:hover td { background: rgba(255,255,255,0.02); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 0.7rem; font-weight: 600; }
.badge-green { background: rgba(46,204,113,0.15); color: var(--green); }
.badge-red { background: rgba(229,9,20,0.15); color: var(--accent); }
.badge-yellow { background: rgba(245,197,24,0.15); color: var(--gold); }
.badge-blue { background: rgba(52,152,219,0.15); color: var(--blue); }
.badge-gray { background: var(--bg4); color: var(--text3); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 2000; display: flex; align-items: center; justify-content: center; }
.modal-overlay.hidden { display: none; }
.modal { background: var(--bg2); border-radius: var(--radius-lg); padding: 24px; width: 90%; max-width: 500px; max-height: 90vh; overflow-y: auto; }
.modal h2 { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* Toast */
#toast-container { position: fixed; top: 70px; right: 16px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 20px; border-radius: var(--radius); font-size: 0.85rem; animation: slideIn 0.3s ease; max-width: 340px; box-shadow: var(--shadow); }
.toast-success { background: var(--green); color: #fff; }
.toast-error { background: var(--accent); color: #fff; }
.toast-info { background: var(--blue); color: #fff; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text3); }
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { color: var(--text2); margin-bottom: 8px; }

/* Responsive */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-toggle { display: block; }
  .hero h1 { font-size: 1.8rem; }
  .drama-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .coin-packages { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .admin-sidebar { display: none; }
  .admin-layout { flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .drama-banner { height: 220px; }
}
@media (max-width: 480px) {
  .drama-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .coin-packages { grid-template-columns: 1fr; }
  .hero { min-height: 300px; }
  .stats-grid { grid-template-columns: 1fr; }
}
