:root {
  --bg: #0f0f0f;
  --bg-card: #1a1a1a;
  --bg-hover: #2a2a2a;
  --text: #f1f1f1;
  --text-muted: #aaa;
  --primary: #ff4444;
  --primary-hover: #cc3333;
  --border: #333;
  --radius: 8px;
}
* { margin:0; padding:0; box-sizing:border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--text); text-decoration: none; }
.navbar { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 1.5rem; background: var(--bg-card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.logo { font-size: 1.3rem; font-weight: 800; }
.logo span { color: var(--primary); }
.nav-center { flex: 1; max-width: 600px; margin: 0 2rem; }
.search-bar { display: flex; }
.search-bar input { flex: 1; padding: 0.5rem 1rem; border: 1px solid var(--border); border-radius: var(--radius) 0 0 var(--radius); background: var(--bg); color: var(--text); font-size: 0.9rem; outline: none; }
.search-bar button { padding: 0.5rem 1rem; border: 1px solid var(--border); border-left: none; border-radius: 0 var(--radius) var(--radius) 0; background: var(--bg-hover); color: var(--text); cursor: pointer; }
.nav-right { display: flex; align-items: center; gap: 0.75rem; }
.btn { padding: 0.5rem 1rem; border: none; border-radius: var(--radius); cursor: pointer; font-size: 0.85rem; font-weight: 600; transition: all 0.2s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg-hover); }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-full { width: 100%; padding: 0.7rem; font-size: 1rem; }
.user-menu { display: flex; align-items: center; gap: 0.75rem; }

/* Main Content */
#mainContent { padding: 1.5rem; max-width: 1400px; margin: 0 auto; flex: 1 0 auto; width: 100%; }

/* Video Grid */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.5rem; }
.video-card { background: var(--bg-card); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: transform 0.2s; }
.video-card:hover { transform: translateY(-2px); }
.video-thumb { width: 100%; aspect-ratio: 16/9; background: #000; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.video-thumb video { width: 100%; height: 100%; object-fit: cover; }
.video-thumb .duration { position: absolute; bottom: 6px; right: 6px; background: rgba(0,0,0,0.8); padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; }
.video-info { padding: 0.75rem; display: flex; gap: 0.75rem; }
.video-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8rem; flex-shrink: 0; }
.video-info h3 { font-size: 0.9rem; margin-bottom: 0.25rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.video-info .channel-name { font-size: 0.8rem; color: var(--text-muted); cursor: pointer; }
.video-info .channel-name:hover { color: var(--text); }
.video-info .video-stats { font-size: 0.75rem; color: var(--text-muted); }
.empty-state { text-align: center; padding: 4rem 1rem; color: var(--text-muted); }
.empty-state h3 { margin-bottom: 0.5rem; color: var(--text); }
.load-more { text-align: center; padding: 2rem; }

/* Watch Page */
.watch-container { max-width: 1100px; margin: 0 auto; }
.watch-player { width: 100%; aspect-ratio: 16/9; background: #000; border-radius: var(--radius); overflow: hidden; }
.watch-player video { width: 100%; height: 100%; }
.watch-info { padding: 1rem 0; }
.watch-info h1 { font-size: 1.3rem; margin-bottom: 0.5rem; }
.watch-meta { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; }
.watch-channel { display: flex; align-items: center; gap: 0.75rem; cursor: pointer; }
.watch-channel .avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; }
.watch-channel .name { font-weight: 600; }
.watch-channel .subs { font-size: 0.8rem; color: var(--text-muted); }
.watch-actions { display: flex; gap: 0.5rem; }
.like-btn { display: flex; align-items: center; gap: 0.3rem; padding: 0.5rem 1rem; border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--text); cursor: pointer; font-size: 0.85rem; }
.like-btn:hover { background: var(--bg-hover); }
.like-btn.liked { background: var(--primary); border-color: var(--primary); color: #fff; }
.watch-desc { background: var(--bg-card); padding: 1rem; border-radius: var(--radius); margin-bottom: 1.5rem; font-size: 0.9rem; white-space: pre-wrap; }

/* Comments */
.comments-section h2 { font-size: 1rem; margin-bottom: 1rem; }
.comment-form { display: flex; gap: 0.75rem; margin-bottom: 1.5rem; }
.comment-form input { flex: 1; padding: 0.7rem 1rem; border: 1px solid var(--border); border-radius: 999px; background: var(--bg-card); color: var(--text); outline: none; }
.comment-form button { padding: 0.5rem 1.2rem; border-radius: 999px; }
.comment { display: flex; gap: 0.75rem; margin-bottom: 1rem; }
.comment .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.75rem; flex-shrink: 0; }
.comment .name { font-weight: 600; font-size: 0.85rem; }
.comment .name span { font-weight: 400; color: var(--text-muted); margin-left: 0.5rem; font-size: 0.75rem; }
.comment .content { font-size: 0.9rem; margin-top: 0.2rem; }

/* Shorts Page */
.shorts-container { height: calc(100vh - 60px); overflow-y: scroll; scroll-snap-type: y mandatory; -ms-overflow-style: none; scrollbar-width: none; }
.shorts-container::-webkit-scrollbar { display: none; }
.short-video { height: calc(100vh - 60px); scroll-snap-align: start; display: flex; align-items: center; justify-content: center; position: relative; background: #000; }
.short-video video { height: 100%; max-width: 100%; object-fit: contain; }
.short-overlay { position: absolute; bottom: 0; left: 0; right: 0; padding: 2rem 1rem 1.5rem; background: linear-gradient(transparent, rgba(0,0,0,0.8)); }
.short-overlay h3 { font-size: 1rem; margin-bottom: 0.3rem; }
.short-overlay .channel { font-size: 0.85rem; color: var(--text-muted); cursor: pointer; }
.short-sidebar { position: absolute; right: 1rem; bottom: 6rem; display: flex; flex-direction: column; gap: 1rem; }
.short-action { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; cursor: pointer; }
.short-action .icon { width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,0.1); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; }
.short-action .count { font-size: 0.7rem; }

/* Upload Page */
.upload-container { max-width: 600px; margin: 0 auto; }
.upload-container h1 { margin-bottom: 1.5rem; }
.upload-form { display: flex; flex-direction: column; gap: 1rem; }
.upload-form label { font-weight: 600; font-size: 0.9rem; }
.upload-form input, .upload-form textarea, .upload-form select { padding: 0.7rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); color: var(--text); font-size: 0.9rem; outline: none; }
.upload-form textarea { resize: vertical; min-height: 80px; }
.upload-form input[type="file"] { padding: 0.5rem; }
.upload-form .file-hint { font-size: 0.8rem; color: var(--text-muted); }
.drop-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 3rem; text-align: center; cursor: pointer; transition: all 0.2s; }
.drop-zone:hover, .drop-zone.dragover { border-color: var(--primary); background: rgba(255,68,68,0.05); }
.drop-zone .icon { font-size: 3rem; margin-bottom: 0.5rem; }
.drop-zone p { color: var(--text-muted); }
.drop-zone .filename { margin-top: 0.5rem; color: var(--primary); font-weight: 600; }
.toggle-group { display: flex; gap: 1rem; }
.toggle-btn { flex: 1; padding: 0.7rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); color: var(--text); cursor: pointer; text-align: center; font-weight: 600; }
.toggle-btn.active { border-color: var(--primary); background: rgba(255,68,68,0.1); color: var(--primary); }

/* Channel Page */
.channel-header { display: flex; align-items: center; gap: 1.5rem; padding: 2rem 0; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.channel-avatar { width: 80px; height: 80px; border-radius: 50%; background: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 700; }
.channel-info h1 { font-size: 1.5rem; }
.channel-info p { color: var(--text-muted); font-size: 0.9rem; }
.channel-tabs { display: flex; gap: 1rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; }
.channel-tab { padding: 0.5rem 0; cursor: pointer; color: var(--text-muted); font-weight: 600; font-size: 0.9rem; }
.channel-tab.active { color: var(--text); border-bottom: 2px solid var(--primary); }

/* Modal */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7); z-index: 200; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal { background: var(--bg-card); padding: 2rem; border-radius: var(--radius); width: 100%; max-width: 400px; position: relative; }
.modal-close { position: absolute; top: 1rem; right: 1rem; background: none; border: none; color: var(--text); font-size: 1.5rem; cursor: pointer; }
.modal h2 { margin-bottom: 1.5rem; }
.modal input { width: 100%; padding: 0.7rem 1rem; margin-bottom: 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text); font-size: 0.9rem; outline: none; }
.auth-error { color: var(--primary); font-size: 0.85rem; margin-bottom: 0.5rem; display: none; }
.auth-switch { text-align: center; margin-top: 1rem; font-size: 0.85rem; color: var(--primary); cursor: pointer; }

/* Search */
.search-results h2 { margin-bottom: 1rem; }
.search-results .video-grid { margin-bottom: 1rem; }

/* Theme Toggle */
.theme-toggle { position: fixed; bottom: 1rem; right: 1rem; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-card); color: var(--text); font-size: 1.3rem; cursor: pointer; z-index: 300; display: flex; align-items: center; justify-content: center; transition: all 0.3s; box-shadow: 0 2px 10px rgba(0,0,0,0.3); }
.theme-toggle:hover { transform: scale(1.1); }

/* Light theme */
body.light { --bg: #f9f9f9; --bg-card: #ffffff; --bg-hover: #f0f0f0; --text: #0f0f0f; --text-muted: #606060; --border: #ddd; }
body.light .navbar { border-bottom-color: #ddd; }
body.light .video-card { box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* Subscribe button */
.subscribe-btn { padding: 0.5rem 1.2rem; border-radius: 999px; font-weight: 600; font-size: 0.9rem; border: none; cursor: pointer; transition: all 0.2s; }
.subscribe-btn.subscribed { background: var(--bg-hover); color: var(--text-muted); }
.subscribe-btn:not(.subscribed) { background: var(--primary); color: #fff; }

/* Creator Dashboard */
.creator-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.creator-card { background: var(--bg-card); padding: 1.25rem; border-radius: var(--radius); border: 1px solid var(--border); }
.creator-card h3 { font-size: 0.95rem; margin-bottom: 0.75rem; }
.creator-card .big { font-size: 2rem; font-weight: 700; }
.creator-card .big.green { color: var(--success); }
.creator-card .big.blue { color: var(--primary); }
.creator-card .big.yellow { color: var(--warning); }
.creator-card .stat-row { display: flex; justify-content: space-between; padding: 0.4rem 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.creator-card .stat-row:last-child { border-bottom: none; }
.creator-card .stat-label { color: var(--text-muted); }
.creator-card .stat-value { font-weight: 600; }
.requirements-list { list-style: none; padding: 0; }
.requirements-list li { padding: 0.5rem 0; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; }
.requirements-list li:last-child { border-bottom: none; }
.requirements-list .check { color: var(--success); font-weight: 700; }
.requirements-list .cross { color: var(--danger); font-weight: 700; }

/* Ad container */
.ad-container { margin: 1rem auto; text-align: center; min-height: 90px; background: var(--bg-card); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-size: 0.8rem; color: var(--text-muted); border: 1px dashed var(--border); overflow: hidden; }

/* Footer */
.footer { background: var(--bg-card); padding: 2rem 1.5rem; border-top: 1px solid var(--border); margin-top: 4rem; text-align: center; }
.footer h2 { font-size: 1.2rem; font-weight: 800; margin-bottom: 0.5rem; }
.footer h2 span { color: var(--primary); }
.footer p { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 0.5rem; }
.footer .copyright { font-size: 0.8rem; margin-top: 1rem; }

@media (max-width: 768px) {
  .nav-center { margin: 0 1rem; }
  .video-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
  #mainContent { padding: 1rem; }
}
