:root {
  color-scheme: dark;
  --yt-bg: #0f0f0f;
  --yt-nav: #0f0f0f;
  --yt-surface: #1f1f1f;
  --yt-surface-hover: #272727;
  --yt-line: #2e2e2e;
  --yt-text: #f1f1f1;
  --yt-muted: #aaaaaa;
  --yt-dim: #717171;
  --wz-gold: #E2CA8C;
  --wz-cyan: #86D6E5;
  --wz-teal: #56B2C4;
  --font-stack: "Roboto", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font: 14px/1.5 var(--font-stack);
  background: var(--yt-bg);
  color: var(--yt-text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--yt-bg); color: var(--yt-text); overflow-x: hidden; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--wz-teal); outline-offset: 2px; }

/* YouTube Splash Screen */
#tube-splash {
  position: fixed; inset: 0; z-index: 9999;
  background: #0a0d13;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}
#tube-splash.fade-out { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-inner { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.splash-logo-wrap { position: relative; width: 72px; height: 72px; display: grid; place-items: center; }
.splash-hex { animation: splashPulse 1.8s ease-in-out infinite; }
.splash-play-badge {
  position: absolute; width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #1b263b, #0f1624);
  border: 1px solid rgba(214, 184, 120, 0.4);
  display: grid; place-items: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6);
}
.splash-title { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.splash-title .sw { color: #ffffff; }
.splash-title .sr { color: var(--wz-cyan); }
.splash-title .stube {
  background: #cc0000; color: #fff; padding: 2px 7px; border-radius: 6px;
  font-size: 15px; vertical-align: middle; margin-left: 4px;
}
.splash-loader { width: 140px; height: 3px; background: #1f1f1f; border-radius: 3px; overflow: hidden; margin-top: 8px; }
.splash-bar { width: 45%; height: 100%; background: var(--wz-cyan); border-radius: 3px; animation: splashLoad 1.2s infinite ease-in-out; }
@keyframes splashPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes splashLoad { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }

/* Top Navbar */
header#top-nav {
  height: 56px; position: sticky; top: 0; z-index: 100;
  background: var(--yt-nav); border-bottom: 1px solid var(--yt-line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; gap: 16px;
}
.nav-left { display: flex; align-items: center; gap: 16px; }
.icon-btn {
  background: transparent; border: 0; color: var(--yt-text); cursor: pointer;
  border-radius: 50%; width: 40px; height: 40px; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--yt-surface-hover); }
.brand-link { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; letter-spacing: -0.5px; }
.brand-text-container { display: flex; align-items: center; overflow: hidden; }
.brand-text-revealer .w { color: #ffffff; }
.brand-text-revealer .r { color: var(--wz-cyan); }
.badge-tube {
  background: #cc0000; color: #fff; font-size: 12px; font-weight: 800;
  padding: 1px 6px; border-radius: 4px; margin-left: 4px; vertical-align: middle;
}

/* Header brand sequential reveal animation */
.wordmark span, .brand-text-revealer { display: inline-flex; align-items: center; animation:reveal 10s infinite both; }
@keyframes reveal {
  0%, 5% { opacity: 0.2; transform: translateY(2px); }
  12%, 85% { opacity: 1; transform: translateY(0); }
  92%, 100% { opacity: 0.2; transform: translateY(-2px); }
}
body.motion-paused .wordmark span, body.motion-paused .brand-text-revealer { animation-play-state:paused !important; }
body.motion-off .wordmark span, body.motion-off .brand-text-revealer { animation: none !important; opacity: 1 !important; transform: none !important; }

/* YouTube Search Bar */
.nav-center { flex: 1; max-width: 640px; display: flex; justify-content: center; }
#search { display: flex; width: 100%; max-width: 540px; height: 40px; }
.search-input-wrap { flex: 1; position: relative; }
#search input {
  width: 100%; height: 100%; background: #121212; border: 1px solid var(--yt-line);
  border-right: 0; border-radius: 20px 0 0 20px; padding: 0 16px;
  color: var(--yt-text); font-size: 14px;
}
#search input:focus { border-color: var(--wz-cyan); outline: none; }
.search-btn {
  width: 60px; height: 100%; background: #222222; border: 1px solid var(--yt-line);
  border-radius: 0 20px 20px 0; color: var(--yt-text); cursor: pointer;
  display: grid; place-items: center;
}
.search-btn:hover { background: #2a2a2a; }

/* Navbar Right Buttons */
.nav-right { display: flex; align-items: center; gap: 8px; }
.yt-pill-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px;
  background: var(--yt-surface); border: 1px solid var(--yt-line); border-radius: 18px;
  font-weight: 600; font-size: 13px; color: var(--yt-text); cursor: pointer;
}
.yt-pill-btn:hover { background: var(--yt-surface-hover); }
.nav-profile-btn { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 18px; }
.nav-profile-btn:hover { background: var(--yt-surface); }
.avatar-circle {
  width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #1b263b, #0f1624);
  border: 1px solid var(--wz-gold); display: grid; place-items: center; font-size: 13px; font-weight: 700;
}
.user-name-label { font-size: 13px; font-weight: 500; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* App Layout & Sidebar */
.app-layout { display: flex; min-height: calc(100vh - 56px); }
nav#app-nav {
  width: 72px; background: var(--yt-bg); padding: 12px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  border-right: 1px solid var(--yt-line); position: sticky; top: 56px; height: calc(100vh - 56px);
}
.nav-item {
  width: 64px; padding: 10px 0; border-radius: 10px; display: flex; flex-direction: column;
  align-items: center; gap: 6px; font-size: 10px; color: var(--yt-muted); text-align: center;
}
.nav-item:hover { background: var(--yt-surface); color: var(--yt-text); }
.nav-item[aria-current="page"] { color: #fff; background: var(--yt-surface); font-weight: 700; }
.nav-spacer { flex: 1; }
.motion-toggle-btn {
  background: transparent; border: 0; color: var(--yt-dim); font-size: 9px;
  cursor: pointer; padding: 4px 6px; border-radius: 4px;
}
.motion-toggle-btn:hover { color: var(--yt-muted); }

/* Main Content Area */
main#main { flex: 1; padding: 16px 24px 48px; max-width: 1680px; min-width: 0; }
#notice {
  font-size: 13px; color: var(--wz-gold); margin-bottom: 12px; min-height: 20px;
  empty-cells: hide; transition: opacity 0.2s;
}

/* Category Chips Bar */
.toolbar {
  display: flex; gap: 10px; overflow-x: auto; padding: 4px 0 16px;
  scrollbar-width: none; -ms-overflow-style: none; position: sticky; top: 56px;
  background: var(--yt-bg); z-index: 10;
}
.toolbar::-webkit-scrollbar { display: none; }
.chip-btn {
  white-space: nowrap; border: 0; border-radius: 8px; height: 32px; padding: 0 12px;
  background: var(--yt-surface); color: var(--yt-text); font-size: 13px; font-weight: 500; cursor: pointer;
}
.chip-btn:hover { background: var(--yt-surface-hover); }
.chip-btn[aria-pressed="true"] { background: #f1f1f1; color: #0f0f0f; font-weight: 700; }
.chip-btn.event-chip { border: 1px solid rgba(226, 202, 140, 0.5); color: var(--wz-gold); }
.chip-btn.event-chip[aria-pressed="true"] { background: var(--wz-gold); color: #0a0d13; }

/* Video Grid (Pure YouTube Style) */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 24px 16px; margin-top: 12px; }
.card { display: flex; flex-direction: column; cursor: pointer; }
.thumb {
  aspect-ratio: 16 / 9; background: #1c1c1c; border-radius: 12px; overflow: hidden;
  position: relative; display: grid; place-items: center;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-fallback { color: var(--yt-dim); font-size: 12px; }
.duration {
  position: absolute; right: 8px; bottom: 8px; background: rgba(0, 0, 0, 0.82);
  color: #fff; font-size: 11px; font-weight: 600; padding: 1px 4px; border-radius: 4px;
}
.card-details { display: flex; gap: 12px; margin-top: 12px; }
.card-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: #262626;
  border: 1px solid var(--yt-line); display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: var(--wz-cyan); flex-shrink: 0;
}
.card-info { flex: 1; min-width: 0; }
.card-info h2 {
  font-size: 14px; font-weight: 600; line-height: 1.35; margin: 0 0 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  color: var(--yt-text);
}
.card:hover .card-info h2 { color: #ffffff; }
.card-channel { font-size: 12px; color: var(--yt-muted); margin: 0 0 2px; display: flex; align-items: center; gap: 4px; }
.verified-badge { color: var(--wz-teal); font-size: 11px; }
.card-meta { font-size: 12px; color: var(--yt-dim); margin: 0; }

/* YouTube Watch Page Layout */
.watch-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; }
.watch-main { min-width: 0; }
.player-wrap {
  width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 12px;
  overflow: hidden; max-height: 72vh;
}
.player-wrap video { width: 100%; height: 100%; object-fit: contain; display: block; }
.watch-title { font-size: 19px; font-weight: 700; line-height: 1.3; margin: 14px 0 10px; }
.watch-row {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--yt-line);
}
.channel-box { display: flex; align-items: center; gap: 12px; }
.channel-avatar {
  width: 40px; height: 40px; border-radius: 50%; background: #262626;
  border: 1px solid var(--wz-gold); display: grid; place-items: center; font-weight: 700;
}
.channel-meta { display: flex; flex-direction: column; }
.channel-name { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 4px; }
.channel-subs { font-size: 12px; color: var(--yt-muted); }
.sub-btn {
  height: 36px; padding: 0 16px; border-radius: 18px; border: 0;
  background: #f1f1f1; color: #0f0f0f; font-weight: 600; font-size: 13px; cursor: pointer; margin-left: 8px;
}
.sub-btn:hover { background: #d9d9d9; }

/* Watch Action Buttons */
.action-pills { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.like-group {
  display: flex; align-items: center; background: var(--yt-surface);
  border-radius: 18px; overflow: hidden; height: 36px;
}
.like-btn {
  background: transparent; border: 0; color: var(--yt-text); padding: 0 14px;
  display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; cursor: pointer; height: 100%;
}
.like-btn:hover { background: var(--yt-surface-hover); }
.like-divider { width: 1px; height: 20px; background: var(--yt-line); }

/* Description Box */
.description-box {
  background: var(--yt-surface); border-radius: 12px; padding: 12px 14px;
  margin: 16px 0; font-size: 13px; line-height: 1.5; color: var(--yt-text);
}
.desc-stats { font-weight: 700; margin-bottom: 6px; font-size: 13px; color: #fff; }
.desc-text { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Comments Section */
.comments-wrap { margin-top: 24px; }
.comments-header { font-size: 17px; font-weight: 700; margin-bottom: 16px; }
.comment-input-row { display: flex; gap: 12px; margin-bottom: 24px; }
.comment-avatar {
  width: 40px; height: 40px; border-radius: 50%; background: #262626;
  display: grid; place-items: center; font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.comment-form { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.comment-input {
  width: 100%; background: transparent; border: 0; border-bottom: 1px solid var(--yt-line);
  color: var(--yt-text); padding: 8px 0; font-size: 14px; resize: vertical; min-height: 40px;
}
.comment-input:focus { border-bottom-color: var(--wz-cyan); outline: none; }
.comment-actions { display: flex; justify-content: flex-end; gap: 8px; }
.comment-submit-btn {
  background: var(--wz-teal); color: #0a0d13; border: 0; border-radius: 18px;
  height: 36px; padding: 0 16px; font-weight: 700; font-size: 13px; cursor: pointer;
}
.comment-submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.comment-item { display: flex; gap: 12px; margin-bottom: 18px; }
.comment-author { font-size: 13px; font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.pending-badge {
  background: #362908; color: var(--wz-gold); border: 1px solid rgba(226, 202, 140, 0.4);
  font-size: 11px; padding: 1px 6px; border-radius: 4px; font-weight: 500;
}
.comment-body { font-size: 13px; line-height: 1.45; }

/* Related Videos Column */
.related-col h3 { font-size: 16px; font-weight: 700; margin: 0 0 14px; }
.related-list { display: flex; flex-direction: column; gap: 12px; }
.related-card { display: flex; gap: 10px; cursor: pointer; }
.related-thumb {
  width: 160px; aspect-ratio: 16 / 9; background: #1c1c1c; border-radius: 8px;
  overflow: hidden; position: relative; flex-shrink: 0; display: grid; place-items: center;
}
.related-thumb img { width: 100%; height: 100%; object-fit: cover; }
.related-info { flex: 1; min-width: 0; }
.related-info h4 {
  font-size: 13px; font-weight: 600; line-height: 1.35; margin: 0 0 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.related-card:hover .related-info h4 { color: #fff; }
.related-channel { font-size: 12px; color: var(--yt-muted); margin: 0 0 2px; }
.related-meta { font-size: 11px; color: var(--yt-dim); margin: 0; }

/* Studio & Moderation Panel */
.studio-box, .admin-box { background: var(--yt-surface); border-radius: 12px; padding: 24px; border: 1px solid var(--yt-line); }
.status-pill { padding: 3px 8px; border-radius: 12px; font-size: 11px; font-weight: 700; }
.status-approved { background: rgba(114, 203, 189, 0.15); color: var(--wz-teal); border: 1px solid var(--wz-teal); }
.status-pending { background: rgba(226, 202, 140, 0.15); color: var(--wz-gold); border: 1px solid var(--wz-gold); }
.status-rejected { background: rgba(235, 87, 87, 0.15); color: #eb5757; border: 1px solid #eb5757; }

/* Theater Mode */
body.theater .watch-layout { display: flex; flex-direction: column; }
body.theater .player-wrap { max-height: 82vh; border-radius: 0; }

/* YouTube Studio Upload Modal & Drag-Drop */
.yt-upload-container { max-width: 960px; margin: 20px auto; }
.yt-auth-banner {
  background: rgba(226, 202, 140, 0.1); border: 1px solid rgba(226, 202, 140, 0.3);
  border-radius: 12px; padding: 14px 18px; margin-bottom: 20px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
}
.yt-auth-banner-text { font-size: 13px; color: var(--wz-gold); }
.yt-auth-banner-btn {
  background: var(--wz-gold); color: #0a0d13; border: 0; border-radius: 18px;
  padding: 8px 16px; font-weight: 700; font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.yt-dropzone {
  position: relative;
  border: 2px dashed #3e3e3e; border-radius: 16px; background: #161616;
  padding: 48px 20px; text-align: center; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.yt-dropzone:hover, .yt-dropzone.dragover { border-color: var(--wz-cyan); background: #1c1c1c; }
.yt-file-overlay {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0;
  cursor: pointer; z-index: 10;
}
.yt-upload-icon-circle {
  width: 100px; height: 100px; border-radius: 50%; background: #222222;
  display: grid; place-items: center; color: var(--wz-cyan); margin-bottom: 6px;
}
.yt-dropzone h2 { font-size: 18px; font-weight: 600; margin: 0; color: #f1f1f1; }
.yt-dropzone p { font-size: 13px; color: var(--yt-muted); margin: 0; max-width: 460px; }
.yt-select-btn {
  background: var(--wz-teal); color: #0a0d13; border: 0; border-radius: 20px;
  height: 38px; padding: 0 24px; font-weight: 700; font-size: 13px; cursor: pointer;
  margin-top: 6px;
}
.yt-select-btn:hover { filter: brightness(1.1); }
.yt-disk-pill {
  font-size: 11px; color: var(--wz-gold); background: rgba(226, 202, 140, 0.1);
  padding: 4px 10px; border-radius: 12px; border: 1px solid rgba(226, 202, 140, 0.3);
}

/* Studio Editor Dialog */
.yt-studio-editor {
  background: #1f1f1f; border: 1px solid var(--yt-line); border-radius: 16px;
  overflow: hidden; display: flex; flex-direction: column;
}
.yt-editor-header {
  padding: 16px 20px; border-bottom: 1px solid var(--yt-line);
  display: flex; align-items: center; justify-content: space-between;
}
.yt-editor-header h2 { font-size: 17px; font-weight: 700; margin: 0; }
.yt-stepper { display: flex; gap: 14px; font-size: 12px; color: var(--yt-muted); }
.yt-stepper .step-active { color: var(--wz-cyan); font-weight: 700; }
.yt-editor-body {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; padding: 20px;
}
.yt-field-group { display: flex; flex-direction: column; gap: 16px; }
.yt-input-box {
  background: #121212; border: 1px solid #3c3c3c; border-radius: 8px; padding: 10px 14px;
}
.yt-input-box:focus-within { border-color: var(--wz-cyan); }
.yt-input-label { font-size: 11px; font-weight: 600; color: var(--yt-muted); margin-bottom: 4px; }
.yt-field-input {
  width: 100%; background: transparent; border: 0; color: #fff; font-size: 14px; padding: 0;
}
.yt-field-input:focus { outline: none; }
.yt-textarea { resize: vertical; min-height: 80px; font-family: inherit; }
.yt-select {
  width: 100%; background: #121212; border: 1px solid #3c3c3c; border-radius: 8px;
  color: #fff; padding: 10px 14px; font-size: 13px;
}
.yt-preview-card {
  background: #121212; border: 1px solid #333; border-radius: 10px; padding: 14px;
  display: flex; flex-direction: column; gap: 10px; height: fit-content;
}
.yt-preview-thumb {
  width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 6px;
  display: grid; place-items: center; color: var(--yt-dim); font-size: 12px;
}
.yt-preview-title { font-size: 13px; font-weight: 600; line-height: 1.3; }
.yt-preview-filename { font-size: 11px; color: var(--yt-dim); word-break: break-all; }
.yt-progress-bar-wrap {
  width: 100%; height: 6px; background: #2a2a2a; border-radius: 3px; overflow: hidden;
}
.yt-progress-bar {
  width: 0%; height: 100%; background: var(--wz-teal); border-radius: 3px;
  transition: width 0.2s ease;
}
.yt-editor-footer {
  padding: 14px 20px; border-top: 1px solid var(--yt-line); background: #181818;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
}
.yt-footer-status { font-size: 13px; color: var(--yt-muted); }
.yt-footer-actions { display: flex; gap: 10px; }

@media (max-width: 800px) {
  .yt-editor-body { grid-template-columns: 1fr; }
  .yt-stepper { display: none; }
}

/* Mobile Responsiveness */
@media (max-width: 900px) {
  .watch-layout { display: block; }
  .related-col { margin-top: 32px; }
  nav#app-nav {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: 52px; width: 100%;
    flex-direction: row; justify-content: space-around; border-right: 0; border-top: 1px solid var(--yt-line);
    padding: 0; background: var(--yt-bg); z-index: 99;
  }
  .nav-item { width: auto; flex: 1; padding: 6px 0; border-radius: 0; }
  .nav-item span { font-size: 10px; }
  .nav-spacer, .nav-footer { display: none; }
  main#main { padding-bottom: 74px; }
}
@media (max-width: 600px) {
  .nav-center { min-width: 0; }
  .nav-left { gap: 0; flex-shrink: 0; }
  .nav-right { flex-shrink: 0; gap: 4px; }
  .user-name-label, .upload-btn, .menu-btn { display: none; }
  #search { min-width: 0; }
  .search-input-wrap { min-width: 0; }
  #logout { padding: 8px; }
  header#top-nav { padding: 0 10px; }
  .brand-text-container { display: none; }
  .grid { grid-template-columns: 1fr; gap: 20px; }
  main#main { padding: 12px 12px 36px; }
  .player-wrap { border-radius: 0; width: calc(100% + 24px); margin-left: -12px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
