:root {
  --bg: #0f0f0f;
  --bg-elevated: #212121;
  --bg-hover: #303030;
  --text: #f1f1f1;
  --text-muted: #aaa;
  --accent: #ff0000;
  --accent-hover: #cc0000;
  --border: #303030;
  --radius: 12px;
  --topbar-h: 56px;
  --sidebar-w: 240px;
  --font: 'Roboto', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }

/* Topbar */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 160px; }
.logo { display: flex; align-items: center; gap: 4px; font-weight: 700; font-size: 1.1rem; }
.logo-icon { color: var(--accent); font-size: 1.3rem; }
.search-form {
  flex: 1; max-width: 640px; margin: 0 auto;
  display: flex; height: 40px;
}
.search-input {
  flex: 1; background: #121212; border: 1px solid var(--border);
  border-right: none; border-radius: 40px 0 0 40px;
  padding: 0 16px; color: var(--text);
}
.search-btn {
  width: 64px; background: var(--bg-hover); border: 1px solid var(--border);
  border-radius: 0 40px 40px 0; cursor: pointer; color: var(--text);
}
.topbar-right { display: flex; align-items: center; gap: 12px; min-width: 160px; justify-content: flex-end; }
.icon-btn {
  background: none; border: none; color: var(--text);
  font-size: 1.2rem; cursor: pointer; padding: 8px; border-radius: 50%;
  position: relative;
}
.icon-btn:hover { background: var(--bg-hover); }
.notif-btn .badge {
  position: absolute; top: 2px; right: 2px;
  background: var(--accent); color: #fff; font-size: 10px;
  padding: 1px 5px; border-radius: 10px;
}

/* Layout */
.layout { display: flex; padding-top: var(--topbar-h); min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  padding: 12px; position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h)); overflow-y: auto;
}
.sidebar.collapsed { display: none; }
.sidebar-item {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 12px; border-radius: 10px; margin-bottom: 2px;
}
.sidebar-item:hover, .sidebar-item.active { background: var(--bg-hover); }
.sidebar-divider { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.main-content { flex: 1; padding: 24px; min-width: 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 16px; border-radius: 999px; border: none;
  cursor: pointer; font-weight: 500; transition: background .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: var(--bg-hover); color: var(--text); }
.btn-ghost:hover { background: #3f3f3f; }
.btn-danger { background: #5c1a1a; color: #ffb4b4; }
.btn-sm { padding: 6px 14px; font-size: .875rem; }
.btn-block { width: 100%; }

/* Cards & chips */
.card {
  background: var(--bg-elevated); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.chip {
  padding: 8px 16px; border-radius: 8px; background: var(--bg-hover);
  font-size: .9rem; white-space: nowrap;
}
.chip.active, .chip:hover { background: #fff; color: #000; }

/* Video grid */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px 12px;
}
.video-card { display: block; position: relative; }
.video-card-link { display: block; color: inherit; text-decoration: none; }
.card-download-btn {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 34px; height: 34px; border-radius: 999px;
  background: rgba(0,0,0,0.72); color: #fff; border: 1px solid rgba(255,255,255,0.2);
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; font-size: 0.95rem;
}
.card-download-btn:hover { background: var(--accent); }
.related-card-wrap { position: relative; margin-bottom: 12px; }
.related-download-btn {
  position: absolute; top: 6px; right: 0; width: 28px; height: 28px; border-radius: 999px;
  background: rgba(0,0,0,0.72); color: #fff; display: inline-flex; align-items: center;
  justify-content: center; text-decoration: none; font-size: 0.8rem;
}
.related-download-btn:hover { background: var(--accent); }
.action-btn[download], a.action-btn { text-decoration: none; }
.thumb-wrap {
  position: relative; aspect-ratio: 16/9;
  border-radius: var(--radius); overflow: hidden;
  background: #000; margin-bottom: 12px;
}
.thumb-wrap img { width: 100%; height: 100%; object-fit: cover; }
.thumb-placeholder {
  width: 100%; height: 100%; display: flex;
  align-items: center; justify-content: center;
  background: #1a1a1a; color: var(--text-muted); font-size: 2rem;
}
.thumb-placeholder.sm { font-size: 1rem; }
.duration {
  position: absolute; bottom: 8px; right: 8px;
  background: rgba(0,0,0,.8); padding: 2px 6px;
  border-radius: 4px; font-size: .75rem;
}
.card-meta { display: flex; gap: 12px; }
.card-title {
  font-size: .95rem; font-weight: 500;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin-bottom: 4px;
}
.card-channel, .card-stats { font-size: .85rem; color: var(--text-muted); }

/* Avatars */
.avatar-sm, .avatar-md, .avatar-xs { border-radius: 50%; object-fit: cover; }
.avatar-sm, .avatar-xs { width: 32px; height: 32px; }
.avatar-md { width: 40px; height: 40px; }
.avatar-sm.placeholder, .avatar-md.placeholder, .avatar-xs.placeholder {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font-weight: 700;
}

/* Watch page */
.watch-layout { display: grid; grid-template-columns: 1fr 400px; gap: 24px; }
.watch-primary { min-width: 0; }
.player-wrap {
  background: #000; border-radius: var(--radius);
  margin-bottom: 16px; width: 100%; min-height: 220px;
  position: relative; overflow: visible;
}
.player-wrap.theater {
  margin-left: -24px; margin-right: -24px;
  border-radius: 0; max-height: 80vh;
}
.player-wrap .video-js {
  width: 100% !important;
  max-width: 100%;
  font-size: 14px;
}
.player-wrap .video-js.paradise-ready,
.player-wrap .video-js.vjs-user-inactive.paradise-ready {
  height: auto !important;
}
.player-wrap .video-js .vjs-tech {
  object-fit: contain;
  background: #000;
}
.player-wrap .video-js .vjs-tech::-webkit-media-controls {
  display: none !important;
}
.player-wrap .video-js .vjs-tech::-webkit-media-controls-enclosure {
  display: none !important;
}
.player-wrap .video-js .vjs-control-bar {
  display: flex !important;
  opacity: 1 !important;
  visibility: visible !important;
  transform: none !important;
  z-index: 5;
}
.player-wrap .video-js.vjs-user-inactive .vjs-control-bar {
  opacity: 1 !important;
  visibility: visible !important;
  transform: none !important;
}
.player-wrap .video-js .vjs-loop-button {
  cursor: pointer;
  width: 3em;
}
.player-wrap .video-js .vjs-loop-button .vjs-loop-icon {
  font-size: 1.05rem;
  line-height: 1.8;
}
.player-wrap .video-js .vjs-loop-button.vjs-loop-on {
  color: #3ea6ff;
}
.post-media {
  border-radius: 8px; margin-top: 12px; max-height: 480px;
  width: 100%; max-width: 100%; background: #000;
}
.post-media::-webkit-media-controls-panel {
  display: flex !important;
}
.player-placeholder {
  min-height: 300px; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); background: #000; border-radius: var(--radius);
}
.watch-title { font-size: 1.25rem; margin-bottom: 12px; }
.watch-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.channel-bar { display: flex; align-items: center; gap: 12px; }
.channel-link { display: flex; align-items: center; gap: 12px; }
.sub-count { display: block; font-size: .85rem; color: var(--text-muted); }
.action-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.action-btn {
  background: var(--bg-hover); border: none; color: var(--text);
  padding: 8px 16px; border-radius: 999px; cursor: pointer;
}
.action-btn:hover, .action-btn.active { background: #3f3f3f; }
.action-btn-danger:hover { background: #5c1a1a; color: #ffb4b4; }
.reaction-group { display: flex; }
.reaction-group .action-btn:first-child { border-radius: 999px 0 0 999px; }
.reaction-group .action-btn:last-child { border-radius: 0 999px 999px 0; border-left: 1px solid var(--border); }
.watch-description { margin-bottom: 24px; }
.desc-stats { font-weight: 500; margin-bottom: 8px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tag { color: #3ea6ff; font-size: .9rem; }
.comments-section h2 { margin-bottom: 0; }
.comments-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.comment-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.comment-delete-btn {
  margin-left: auto; background: transparent; border: none; color: #ff8a8a;
  font-size: 0.8rem; cursor: pointer; padding: 2px 6px; border-radius: 4px;
}
.comment-delete-btn:hover { background: #3a1515; }
.comment-form { display: flex; gap: 12px; margin-bottom: 20px; align-items: flex-start; }
.comment-form textarea {
  flex: 1; background: var(--bg-hover); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px; color: var(--text); resize: vertical;
}
.comment { display: flex; gap: 12px; margin-bottom: 16px; }
.comment-avatar { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; background: var(--accent); }
.comment-time { color: var(--text-muted); font-size: .85rem; margin-left: 8px; }
.watch-sidebar h3 { margin-bottom: 12px; }
.related-card { display: flex; gap: 8px; margin-bottom: 12px; }
.related-thumb { width: 168px; flex-shrink: 0; aspect-ratio: 16/9; border-radius: 8px; overflow: hidden; background: #000; }
.related-thumb img { width: 100%; height: 100%; object-fit: cover; }
.related-info h4 { font-size: .9rem; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.related-info p { font-size: .8rem; color: var(--text-muted); }

/* Channel */
.channel-header { margin: -24px -24px 24px; }
.channel-banner {
  height: 180px; background: linear-gradient(135deg, #1a1a2e, #16213e);
  background-size: cover; background-position: center;
}
.channel-info-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 24px;
  padding: 16px 24px; background: var(--bg-elevated);
}
.channel-avatar-lg {
  width: 80px; height: 80px; border-radius: 50%; overflow: hidden;
  margin-top: -40px; border: 4px solid var(--bg-elevated);
  background: var(--accent); display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 700;
}
.channel-avatar-lg img { width: 100%; height: 100%; object-fit: cover; }
.channel-meta { flex: 1; }
.channel-tabs {
  display: flex; gap: 0; padding: 0 24px; border-bottom: 1px solid var(--border);
}
.channel-tabs a {
  padding: 14px 20px; border-bottom: 2px solid transparent;
}
.channel-tabs a.active { border-color: var(--text); }
.post-composer textarea {
  width: 100%; background: var(--bg-hover); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px; color: var(--text); margin-bottom: 12px;
}

/* Auth */
.auth-card { max-width: 400px; margin: 48px auto; }
.auth-card h1 { margin-bottom: 20px; }
.auth-form label { display: block; margin-bottom: 16px; }
.auth-form input {
  display: block; width: 100%; margin-top: 6px;
  padding: 10px 12px; background: var(--bg-hover);
  border: 1px solid var(--border); border-radius: 8px; color: var(--text);
}
.auth-footer { text-align: center; margin-top: 16px; color: var(--text-muted); }
.auth-footer a { color: #3ea6ff; }

/* Studio */
.studio-layout { display: flex; gap: 24px; }
.studio-sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--bg-elevated); border-radius: var(--radius); padding: 16px;
}
.studio-sidebar nav a {
  display: block; padding: 10px 12px; border-radius: 8px; margin-bottom: 4px;
}
.studio-sidebar nav a:hover, .studio-sidebar nav a.active { background: var(--bg-hover); }
.studio-main { flex: 1; }
.studio-form label, .studio-upload-form label {
  display: block; margin-bottom: 16px;
}
.studio-form input, .studio-form textarea, .studio-form select,
.studio-upload-form input, .studio-upload-form textarea, .studio-upload-form select {
  display: block; width: 100%; margin-top: 6px;
  padding: 10px; background: var(--bg-hover); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Stats & tables */
.stat-row { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 24px; }
.stat {
  background: var(--bg-elevated); border-radius: var(--radius);
  padding: 16px 24px; min-width: 140px;
}
.stat .label { font-size: .85rem; color: var(--text-muted); }
.stat .val { font-size: 1.5rem; font-weight: 700; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
  text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.data-table th { color: var(--text-muted); font-weight: 500; font-size: .85rem; }
.badge-status.processing { color: #f5a623; }
.badge-status.ready { color: #6bcb77; }

/* Misc */
.empty-state { text-align: center; padding: 64px 24px; color: var(--text-muted); }
.empty-state h2 { color: var(--text); margin-bottom: 8px; }
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }
.alert-error { background: #3d1515; color: #ffb4b4; }
.alert-ok { background: #153d1f; color: #b4ffca; }
.muted { color: var(--text-muted); }
.list-feed .list-item {
  display: flex; flex-direction: column; padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.search-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 24px; }
.search-input-lg { flex: 1; min-width: 200px; padding: 10px 16px; background: var(--bg-hover); border: 1px solid var(--border); border-radius: 8px; color: var(--text); }
.notif-item.unread { border-left: 3px solid var(--accent); }

@media (max-width: 1024px) {
  .watch-layout { grid-template-columns: 1fr; }
  .watch-sidebar { display: none; }
  .sidebar { display: none; }
  .sidebar.open { display: block; position: fixed; z-index: 99; background: var(--bg); height: 100%; }
}
@media (max-width: 600px) {
  .search-form { display: none; }
  .video-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .studio-layout { flex-direction: column; }
}

.stat-row.compact { margin-bottom: 16px; }
.compact-table td, .compact-table th { padding: 8px 10px; font-size: 0.85rem; }
.small-cell { font-size: 0.8rem; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-analytics { margin-bottom: 24px; }
.viewer-analytics-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.viewer-analytics-head h2 { margin: 0; }
.admin-badge {
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; background: #3a2510; color: #f5a623;
  padding: 2px 8px; border-radius: 999px; vertical-align: middle;
}
.analytics-disclosure-toggle {
  width: 100%; text-align: left; margin-top: 12px; padding: 12px 14px;
  background: var(--bg-hover); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); cursor: pointer; font-size: 0.95rem;
}
.analytics-disclosure-toggle:hover { background: #333; }
.analytics-disclosure-toggle .toggle-icon { display: inline-block; width: 1rem; }
.analytics-disclosure-toggle[aria-expanded="true"] .toggle-icon { transform: rotate(90deg); display: inline-block; }
.analytics-disclosure-panel { margin-top: 12px; }
.analytics-disclosure { margin-top: 16px; }
.analytics-disclosure-summary {
  cursor: pointer; font-weight: 600; padding: 10px 0; list-style: none;
}
.analytics-disclosure-summary::-webkit-details-marker { display: none; }
.pagination {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; align-items: center;
}
.page-link {
  min-width: 34px; height: 34px; padding: 0 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-hover); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; font-size: 0.9rem; cursor: pointer;
}
.page-link:hover, .page-link.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-link:disabled { opacity: 0.4; cursor: default; }
code { background: var(--bg-hover); padding: 2px 6px; border-radius: 4px; font-size: 0.85rem; }
