/* Reset & Base */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/inter-latin-var.woff2') format('woff2');
}
:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; font-family: var(--font-sans); }
html { font-size: 16px; font-family: var(--font-sans); }
body {
  font-family: var(--font-sans);
  background: #0a0a0f;
  color: #e5e5e5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button, input, select, textarea, option { font-family: inherit; }

/* Navbar */
.navbar {
  background: #12121a;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: fixed;
  width: 100%;
  top: 0;
  z-index: 100;
}
.navbar-logo {
  display: flex;
  align-items: center;
}
.navbar-logo .logo-img {
  height: 36px;
  width: auto;
  display: block;
}
.navbar-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
}
.navbar-links a {
  color: #888;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s;
}
.navbar-links a:hover {
  color: #4da6ff;
}
.navbar-links a.active {
  color: #4da6ff;
}
.navbar-actions .user-menu {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.navbar-actions button {
  background: #1a1a24;
  border: 1px solid #2a2a3d;
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  color: #cfcfda;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.navbar-actions button:hover { background: #25253a; color: #4da6ff; border-color: #4da6ff; }
.navbar-actions button:active { background: #2a2a3d; }
#msgBtn, #notifBtn {
  font-size: 0.95rem;
  line-height: 1;
  padding: 0.4rem 0.65rem;
  position: relative;
}
#uploadBtn {
  background: #4da6ff;
  border-color: #4da6ff;
  color: #fff;
}
#uploadBtn:hover { background: #6bb8ff; color: #fff; border-color: #6bb8ff; }
#historyBtn {
  background: #101a2b;
  border-color: #23395c;
  color: #9cc7ff;
}
#historyBtn:hover { background: #16243c; border-color: #4da6ff; color: #cfe3ff; }
#subsBtn {
  background: #101a2b;
  border-color: #23395c;
  color: #9cc7ff;
}
#subsBtn:hover { background: #16243c; border-color: #4da6ff; color: #cfe3ff; }
#accountBtn {
  background: #101a2b;
  border-color: #23395c;
  color: #9cc7ff;
}
#accountBtn:hover { background: #16243c; border-color: #4da6ff; color: #cfe3ff; }
#logoutBtn {
  background: transparent;
  border-color: #24395c;
  color: #7fb8ff;
}
#logoutBtn:hover { background: #12233d; color: #a8d2ff; border-color: #2b6fb0; }
.navbar-actions span {
  color: #e5e5e5;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.8);
  justify-content: center;
  /* flex-start plus margin:auto on the panel, rather than align-items:center.
     A centred flex item that is taller than the viewport is centred: its top
     lands above the top edge and its bottom below the bottom edge, so half the
     content is off-screen with no scrollbar anywhere to reach it. That is what
     made a long notification list unreachable. margin:auto centres the panel
     only while it fits, and top-aligns it once it does not. */
  align-items: flex-start;
  /* And the overlay itself scrolls, so nothing is ever truly out of reach. */
  overflow-y: auto;
  padding: 1rem;
  box-sizing: border-box;
  z-index: 200;
}
.modal.active { display: flex; }
/* Modals that can open on top of another modal (2FA flows) */
.modal.modal-top { z-index: 400; }
.modal-content {
  background: #1a1a24;
  padding: 2rem;
  border-radius: 8px;
  width: 320px;
  max-width: 100%;
  /* The panel, not just the overlay, has to be bounded: notifications, DMs and
     reports are all unbounded lists, and without a cap they grow until the
     top is off-screen. The vh line is the fallback and the dvh line wins where
     supported, so mobile browser chrome is not counted twice. */
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  /* Scrolling the list should not chain to the page behind the overlay. */
  overscroll-behavior: contain;
  margin: auto;
  animation: slideIn 0.3s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
.modal-close {
  position: absolute; top: 1rem; right: 1.5rem;
  color: #666; font-size: 1.5rem; cursor: pointer; transition: color 0.3s;
}
.modal-close:hover { color: #fff; }
.modal form { display: flex; flex-direction: column; gap: 1rem; }
.modal input {
  background: #0d0d13;
  border: none;
  padding: 0.75rem;
  border-radius: 4px;
  color: #fff;
  font-size: 1rem;
}
.modal textarea {
  background: #0d0d13;
  border: none;
  padding: 0.75rem;
  border-radius: 4px;
  color: #fff;
  font-size: 1rem;
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}
.modal button {
  background: #4da6ff;
  border: none;
  padding: 0.75rem;
  border-radius: 4px;
  color: #fff;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.3s;
}
.modal button:hover { background: #6bb8ff; }
.modal a {
  color: #4da6ff;
  text-decoration: underline;
}

/* Hero/Sections */
.hero {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 2rem;
}
.hero h1 { font-size: 3rem; margin-bottom: 1rem; }
.hero p { font-size: 1.2rem; color: #666; margin-bottom: 2rem; }

/* Search */
.search-box {
  width: 100%;
  max-width: 400px;
  margin-bottom: 2rem;
}
.search-box input {
  width: 100%;
  background: #0d0d13;
  border: 1px solid #333;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  color: #fff;
  font-size: 1rem;
}

/* Videos Grid */
.videos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
}
.video-card {
  background: #111;
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.3s;
  cursor: pointer;
}
.video-card:hover { transform: translateY(-4px); }
.video-card video {
  width: 100%;
  height: 180px;
  object-fit: cover;
}
.card-media { position: relative; background: #000; overflow: hidden; }
.video-card video.card-video { display: block; width: 100%; height: 180px; object-fit: cover; background: #000; }
.preview-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 0;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
  z-index: 2;
}
.preview-btn svg { width: 26px; height: 26px; fill: currentColor; margin-left: 3px; }
.video-card:hover .preview-btn { opacity: 1; }
.preview-btn:hover { background: rgba(0, 0, 0, 0.78); }
.preview-btn.is-playing { opacity: 0; }
@media (hover: none) {
  .preview-btn { opacity: 1; }
  .video-card video.card-video { height: auto; aspect-ratio: 16 / 9; }
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  max-width: 1400px;
  margin: 1.75rem auto 0;
}
.page-info { width: 100%; text-align: center; opacity: 0.6; font-size: 0.8rem; margin-bottom: 0.35rem; }
.page-btn {
  min-width: 38px;
  height: 38px;
  padding: 0 0.6rem;
  border-radius: 8px;
  border: 1px solid #2f2f3f;
  background: #15151f;
  color: #ddd;
  font-size: 0.9rem;
  cursor: pointer;
}
.page-btn:hover:not([disabled]) { background: #22223a; color: #fff; }
.page-btn.active { background: #2f80d6; border-color: #2f80d6; color: #fff; font-weight: 600; }
.page-btn[disabled] { opacity: 0.35; cursor: not-allowed; }
.page-gap { opacity: 0.5; padding: 0 0.15rem; }
.video-info {
  padding: 1rem;
}
.video-info h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
  color: #fff;
}
.video-meta {
  font-size: 0.75rem;
  color: #666;
  margin-bottom: 0.5rem;
}
.video-comments {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.7rem;
  color: #555;
}
.tiny-btn {
  background: #222;
  color: #888;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.65rem;
  cursor: pointer;
  border: none;
}
.tiny-btn.danger {
  background: #14243d;
  color: #8ec6ff;
}
.tiny-btn.danger:hover {
  background: #1b3557;
}
.video-description {
  color: #999;
  font-size: 0.85rem;
  margin: 0.25rem 0 0.5rem;
}
.video-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
}
.video-page-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
}
.tiny-btn:hover {
  background: #333;
}
.tiny-btn.active {
  background: #1c3a1c;
  color: #6bff6b;
}
.tiny-btn.active.danger {
  background: #14243d;
  color: #8ec6ff;
}
.video-stats {
  display: flex;
  gap: 0.5rem;
  margin: 0.25rem 0 0.5rem;
}
.upload-progress {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: #888;
}
.upload-progress-track {
  flex: 1;
  height: 8px;
  background: #222;
  border-radius: 4px;
  overflow: hidden;
}
.upload-progress-bar {
  height: 100%;
  width: 0%;
  background: #4caf50;
  border-radius: 4px;
  transition: width 0.3s;
}
.view-heading {
  font-size: 1.1rem;
  color: #ccc;
  margin-bottom: 0.5rem;
}
.channels-bar {
  font-size: 0.75rem;
  color: #888;
  margin-bottom: 0.5rem;
}
.video-page-actions .tiny-btn {
  font-size: 0.8rem;
  padding: 0.4rem 0.9rem;
}

/* Sections */
.section { display: none; padding: 6rem 2rem 2rem; }
.section.active { display: block; }

/* Spacey's Community Corner */
.corner-container { max-width: 1100px; margin: 0 auto; }
.corner-container > h2 { margin-bottom: 0.25rem; }
.corner-intro { opacity: 0.7; margin-bottom: 2rem; }
.corner-block {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(60, 60, 110, 0.18), rgba(20, 20, 30, 0.25));
  border-radius: 14px;
  padding: 1.25rem 1.25rem 1.5rem;
  margin-bottom: 1.75rem;
}
.corner-title {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-size: 1.15rem;
  margin-bottom: 1rem;
}
.corner-sub { font-size: 0.9rem; font-weight: 400; opacity: 0.65; }
.corner-block .videos-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.private-badge {
  background: #2f80d6;
  color: #fff;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  vertical-align: middle;
}

.notif-count {
  background: #2f80d6;
  color: #fff;
  border-radius: 8px;
  font-size: 10px;
  padding: 0 5px;
  margin-left: 4px;
}

.notification-item {
  display: block;
  padding: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  color: inherit;
  text-decoration: none;
}
.notification-item.unread { background: rgba(80, 140, 255, 0.12); }
.notification-item .notif-time { display: block; font-size: 11px; opacity: 0.6; margin-top: 2px; }

/* Messages */
.msg-modal { width: 420px; max-height: 80vh; display: flex; flex-direction: column; }
.new-msg-row { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.new-msg-row input { flex: 1; background: #0d0d13; border: 1px solid #333; padding: 0.5rem; border-radius: 4px; color: #fff; }
.conversation-item { padding: 0.75rem; border-radius: 6px; cursor: pointer; margin-bottom: 0.5rem; background: #15151f; transition: background 0.2s; position: relative; }
.conversation-item:hover { background: #1d1d2b; }
.conversation-item.unread { border-left: 3px solid #4da6ff; }
.conversation-item p { font-size: 0.85rem; color: #999; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.conversation-item .notif-count { position: absolute; top: 0.75rem; right: 0.75rem; }
.conversation-item .notif-time { display: block; font-size: 10px; opacity: 0.5; margin-top: 4px; }
.msg-thread { flex: 1; min-height: 260px; max-height: 50vh; overflow-y: auto; display: flex; flex-direction: column; gap: 0.5rem; padding: 0.5rem; background: #0d0d13; border-radius: 6px; margin-bottom: 0.75rem; }
.msg-bubble { max-width: 75%; padding: 0.5rem 0.75rem; border-radius: 12px; font-size: 0.9rem; word-wrap: break-word; }
.msg-bubble.mine { align-self: flex-end; background: #2f80d6; color: #fff; border-bottom-right-radius: 3px; }
.msg-bubble.theirs { align-self: flex-start; background: #26263a; color: #eee; border-bottom-left-radius: 3px; }
.msg-bubble .notif-time { display: block; font-size: 9px; opacity: 0.7; margin-top: 3px; }
.msg-empty { color: #666; text-align: center; margin: auto; }
.msg-send-row { display: flex; gap: 0.5rem; }
.msg-send-row input { flex: 1; background: #0d0d13; border: 1px solid #333; padding: 0.6rem; border-radius: 4px; color: #fff; }

/* Site banner (moderation) */
.site-banner {
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.65rem 2.5rem 0.65rem 1.5rem;
  font-weight: 500;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.site-banner em.banner-by { opacity: 0.7; font-weight: 400; font-size: 0.85em; }
.banner-info { background: #1c3a5e; color: #cfe6ff; border-bottom: 1px solid #2d5a8e; }
.banner-warning { background: #5e4a1c; color: #ffe9b8; border-bottom: 1px solid #8e732d; }
.banner-critical { background: #123a63; color: #cfe6ff; border-bottom: 1px solid #2b6fb0; }
.banner-close {
  position: absolute;
  right: 1rem;
  background: none;
  border: none;
  color: inherit;
  font-size: 1.4rem;
  cursor: pointer;
  opacity: 0.7;
  line-height: 1;
}
.banner-close:hover { opacity: 1; }
.section h2 {
  text-align: center;
  font-size: 2.5rem;
  margin-bottom: 2rem;
  color: #fff;
}

/* Algorithm */
.algorithm-insight {
  background: #151520;
  padding: 1.5rem;
  border-radius: 8px;
  margin-top: 2rem;
  max-width: 600px;
  margin: 0 auto;
}
.algorithm-container {
  max-width: 800px;
  margin: 0 auto;
}
.algorithm-details p {
  margin: 0.5rem 0;
  line-height: 1.6;
}

/* Explore */
.explore-container {
  max-width: 1000px;
  margin: 0 auto;
}

/* Video Page */
.video-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 6rem 2rem 2rem;
}
.back-link {
  display: inline-block;
  color: #4da6ff;
  text-decoration: none;
  margin-bottom: 1.5rem;
  font-weight: 500;
}
.back-link:hover {
  text-decoration: underline;
}
.video-player {
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.video-player video {
  display: block;
  max-height: 70vh;
}
.video-page h2 {
  color: #fff;
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}
.video-page .video-meta {
  margin-bottom: 2rem;
}
.video-page .video-description {
  margin: -1rem 0 2rem;
  color: #aaa;
  line-height: 1.6;
}
.comments-section {
  background: #151520;
  border-radius: 8px;
  padding: 1.5rem;
}
.comments-section h3 {
  color: #fff;
  margin-bottom: 1rem;
}
.comments-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.comment-item {
  background: #1a1a24;
  border-radius: 6px;
  padding: 0.75rem 1rem;
}
.comment-item.pinned {
  background: #241a1a;
  border: 1px solid #4da6ff;
}
.pin-badge {
  display: inline-block;
  background: #4da6ff;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 10px;
  margin-bottom: 0.4rem;
}
.comment-item strong {
  color: #4da6ff;
  margin-right: 0.5rem;
}
.comment-item span {
  color: #666;
  font-size: 0.75rem;
}
.comment-item p {
  margin-top: 0.25rem;
  color: #ccc;
  font-size: 0.9rem;
}
.no-comments {
  color: #666;
  font-size: 0.9rem;
}
.comment-form {
  display: flex;
  gap: 0.5rem;
}
.comment-form input {
  flex: 1;
  background: #0d0d13;
  border: 1px solid #333;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  color: #fff;
  font-size: 1rem;
}
.comment-form button {
  background: #4da6ff;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
  color: #fff;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.3s;
}
.comment-form button:hover {
  background: #6bb8ff;
}

/* Responsive */
@media (max-width: 600px) {
  .navbar { padding: 1rem; }
  .hero h1 { font-size: 2rem; }
  .section { padding: 5rem 0.75rem 2rem; }
  .videos-grid { grid-template-columns: 1fr; gap: 1.25rem; }
  .corner-block .videos-grid { grid-template-columns: 1fr; }
  .video-card video.card-video { height: auto; aspect-ratio: 16 / 9; }
  .preview-btn { opacity: 1; width: 48px; height: 48px; }
  .page-btn { height: 42px; min-width: 42px; }
  .pagination { gap: 0.3rem; }
}
.video-player { position: relative; }
.quality-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 4px;
  z-index: 10;
  pointer-events: none;
}

/* Custom video player */
.player-shell {
  position: relative;
  background: #000;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
.player-shell video {
  display: block;
  width: 100%;
  max-height: 70vh;
  background: #000;
}
.cp-big-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 0;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 12;
  transition: opacity 0.2s, transform 0.15s, background 0.2s;
}
.cp-big-play svg { width: 34px; height: 34px; fill: currentColor; margin-left: 4px; }
.cp-big-play:hover { background: rgba(0, 0, 0, 0.78); transform: translate(-50%, -50%) scale(1.06); }
.cp-big-play.is-hidden { opacity: 0; pointer-events: none; }

/* Loading overlay. Sits above the video but below the controls, and is removed
   as soon as there is a frame to show - a poster alone is not enough, because
   the user would then sit on a still image with no idea the video was broken. */
.cp-loading {
  position: absolute;
  inset: 0;
  z-index: 11;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  opacity: 1;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.cp-loading.is-done { opacity: 0; visibility: hidden; }
.cp-loading-inner { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 0 24px; text-align: center; }
.cp-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.22);
  border-top-color: #fff;
  animation: cp-spin 0.85s linear infinite;
}
.cp-loading.is-error .cp-spinner { display: none; }
.cp-loading.is-error .cp-spinner::before {
  content: "!";
  display: block;
  width: 34px;
  height: 34px;
  line-height: 30px;
  text-align: center;
  border-radius: 50%;
  border: 3px solid #ff6b6b;
  color: #ff6b6b;
  font-weight: 700;
  font-size: 20px;
}
@keyframes cp-spin { to { transform: rotate(360deg); } }
/* Respect a reduced-motion preference: keep the text, drop the spin. */
@media (prefers-reduced-motion: reduce) {
  .cp-spinner { animation: none; border-top-color: rgba(255, 255, 255, 0.22); border-right-color: #fff; }
}
.cp-loading-text { margin: 0; color: #fff; font-size: 14px; font-weight: 600; }
.cp-loading-sub { margin: 0; color: rgba(255, 255, 255, 0.72); font-size: 12.5px; max-width: 34ch; }
.cp-loading-sub:empty { display: none; }
.cp-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  padding: 0.35rem 0.75rem 0.5rem;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.55) 55%, rgba(0, 0, 0, 0) 100%);
  transition: opacity 0.25s, transform 0.25s;
  touch-action: manipulation;
}
.player-shell.controls-hidden .cp-controls { opacity: 0; transform: translateY(8px); pointer-events: none; }
.cp-progress {
  height: 16px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
}
.cp-progress:focus-visible { outline: 2px solid #4da6ff; outline-offset: 2px; border-radius: 4px; }
.cp-track {
  position: relative;
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 3px;
  overflow: visible;
}
.cp-buffer { position: absolute; inset: 0 auto 0 0; height: 100%; background: rgba(255, 255, 255, 0.32); border-radius: 3px; }
.cp-played { position: absolute; inset: 0 auto 0 0; height: 100%; background: #4da6ff; border-radius: 3px; }
.cp-thumb {
  position: absolute;
  top: 50%;
  width: 13px;
  height: 13px;
  margin-left: -6.5px;
  border-radius: 50%;
  background: #fff;
  transform: translateY(-50%) scale(0);
  transition: transform 0.15s;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
}
.cp-progress:hover .cp-thumb, .cp-progress:focus .cp-thumb { transform: translateY(-50%) scale(1); }
.cp-row { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.cp-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  padding: 0;
  flex: 0 0 auto;
}
.cp-btn svg { width: 22px; height: 22px; fill: currentColor; }
.cp-btn:hover { background: rgba(255, 255, 255, 0.16); }
.cp-btn.is-on { color: #6bb8ff; background: rgba(77, 166, 255, 0.2); }
.cp-time { color: #eee; font-size: 0.8rem; font-variant-numeric: tabular-nums; padding: 0 0.35rem; white-space: nowrap; }
.cp-sep { opacity: 0.55; margin: 0 0.25rem; }
.cp-grow { flex: 1 1 auto; }
.cp-volume {
  width: 90px;
  accent-color: #4da6ff;
  cursor: pointer;
  flex: 0 0 auto;
}
.cp-field { display: inline-flex; align-items: center; gap: 0.3rem; flex: 0 0 auto; }
.cp-field-label { color: #cfd0d8; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.cp-field select {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 0.28rem 0.4rem;
  font-size: 0.8rem;
  cursor: pointer;
}
.cp-field select option { background: #14141c; color: #fff; }
.cp-field.is-disabled { opacity: 0.4; }
.cp-field.is-disabled select { cursor: not-allowed; }
.player-shell:fullscreen { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: #000; }
.player-shell:fullscreen video { max-height: 100%; height: 100%; object-fit: contain; }
.player-shell:-webkit-full-screen { width: 100%; height: 100%; }
.player-shell:-webkit-full-screen video { max-height: 100%; object-fit: contain; }

@media (max-width: 700px) {
  .player-shell video { max-height: 56vh; }
  .cp-controls { padding: 0.25rem 0.5rem calc(0.4rem + env(safe-area-inset-bottom)); }
  .cp-row { gap: 0.2rem; }
  .cp-btn { width: 40px; height: 40px; }
  .cp-btn svg { width: 24px; height: 24px; }
  .cp-progress { height: 22px; }
  .cp-track { height: 6px; }
  .cp-thumb { width: 15px; height: 15px; margin-left: -7.5px; }
  .cp-thumb { transform: translateY(-50%) scale(1); }
  .cp-field-label { display: none; }
  .cp-volume { width: 64px; }
  .cp-time { font-size: 0.75rem; }
  .cp-big-play { width: 64px; height: 64px; }
  .cp-big-play svg { width: 30px; height: 30px; }
}

/* Profile pictures (initials fallback when no avatar is set) */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, #2b4a7d, #16233a);
  color: #cfe3ff;
  font-weight: 600;
  flex: 0 0 auto;
  border: 1px solid #2f4a7d;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-letter { line-height: 1; }
.avatar-sm { width: 30px; height: 30px; font-size: 0.85rem; }
.avatar-md { width: 48px; height: 48px; font-size: 1.2rem; }
.avatar-lg { width: 88px; height: 88px; font-size: 2rem; }
.account-avatar-row { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
.account-avatar-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; }
.avatar-hint { font-size: 0.75rem; opacity: 0.6; margin-top: 0.15rem; max-width: 260px; }
.channel-header { display: flex; align-items: center; gap: 1.25rem; }
.channel-header-text { flex: 1 1 auto; min-width: 0; }

/* Channel card under the video player */
.video-channel {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: #14141c;
  border: 1px solid #26263a;
  border-radius: 12px;
  padding: 0.8rem 1rem;
  margin-bottom: 1.1rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.video-channel:hover { border-color: #4da6ff; background: #171b28; transform: translateY(-2px); }
.video-channel-text { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; flex: 1 1 auto; }
.video-channel-name { font-weight: 600; color: #fff; }
.video-channel-meta { font-size: 0.78rem; opacity: 0.6; }
.video-channel-cta {
  flex: 0 0 auto;
  font-size: 0.78rem;
  color: #9cc7ff;
  border: 1px solid #23395c;
  background: #101a2b;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
}
.video-channel:hover .video-channel-cta { border-color: #4da6ff; color: #cfe3ff; }
.channel-sub-btn { flex: 0 0 auto; }
@media (max-width: 600px) {
  .video-channel { padding: 0.65rem 0.75rem; gap: 0.7rem; }
  .video-channel-cta { display: none; }
}

/* @mention autocomplete */
.mention-menu {
  position: absolute;
  z-index: 60;
  background: #14141c;
  border: 1px solid #2f2f3f;
  border-radius: 8px;
  overflow: hidden;
  min-width: 190px;
  max-height: 210px;
  overflow-y: auto;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
}
.mention-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  background: transparent;
  border: 0;
  color: #e5e5e5;
  text-align: left;
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
  cursor: pointer;
}
.mention-item:hover, .mention-item.active { background: rgba(77, 166, 255, 0.18); color: #fff; }
.mention-role {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: #9cc7ff;
  border: 1px solid rgba(77, 166, 255, 0.4);
  border-radius: 999px;
  padding: 0 6px;
}
.mention-link {
  background: rgba(77, 166, 255, 0.14);
  border: 0;
  color: #9cc7ff;
  padding: 0 3px;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
}
.mention-link:hover { background: rgba(77, 166, 255, 0.28); color: #fff; }
.msg-input-wrap { position: relative; flex: 1 1 auto; }
.msg-input-wrap .mention-menu { bottom: calc(100% + 4px); left: 0; }

/* Message stickers */
.sticker-picker {
  border: 1px solid #2f2f3f;
  border-radius: 10px;
  background: #12121a;
  padding: 0.6rem;
  margin-top: 0.6rem;
}
.sticker-picker-head { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; opacity: 0.8; margin-bottom: 0.5rem; }
.sticker-grid { display: flex; flex-wrap: wrap; gap: 0.4rem; max-height: 180px; overflow-y: auto; }
.sticker-item {
  width: 56px;
  height: 56px;
  padding: 2px;
  background: #0d0d13;
  border: 1px solid #2a2a3d;
  border-radius: 8px;
  cursor: pointer;
}
.sticker-item:hover { border-color: #4da6ff; }
.sticker-item img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.msg-sticker { max-width: 180px; max-height: 180px; border-radius: 10px; display: block; margin-bottom: 0.35rem; }

/* Message reactions */
.msg-meta { display: flex; align-items: center; gap: 0.4rem; }
.msg-text { white-space: pre-wrap; word-break: break-word; }
.msg-react-btn {
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0 2px;
  line-height: 1;
}
.msg-react-btn:hover { color: #fff; }
.msg-reactions { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.35rem; }
.msg-reaction {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid transparent;
  color: #e5e5e5;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  font-size: 0.75rem;
  cursor: pointer;
}
.msg-reaction:hover { border-color: #4da6ff; }
.msg-reaction.active { background: rgba(77, 166, 255, 0.25); border-color: #4da6ff; color: #fff; }
.msg-reaction-picker {
  position: absolute;
  bottom: calc(100% - 4px);
  right: 6px;
  display: flex;
  gap: 0.15rem;
  background: #14141c;
  border: 1px solid #2f2f3f;
  border-radius: 999px;
  padding: 0.25rem 0.4rem;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.5);
  z-index: 20;
}
.msg-reaction-picker button {
  background: transparent;
  border: 0;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.1rem;
}
.msg-reaction-picker button:hover { transform: scale(1.2); }
.msg-bubble { position: relative; }

/* Kudos */
.kudos-section { margin-top: 1.5rem; }
.kudos-section h3 { margin-bottom: 0.6rem; }
.kudos-list { display: flex; flex-direction: column; gap: 0.6rem; }
.kudos-item { display: flex; gap: 0.7rem; align-items: flex-start; background: #14141c; border: 1px solid #26263a; border-radius: 10px; padding: 0.7rem 0.85rem; }
.kudos-body { min-width: 0; }
.kudos-from { font-weight: 600; color: #fff; display: block; }
.kudos-video-link { color: #9cc7ff; text-decoration: none; font-weight: 400; font-size: 0.8rem; }
.kudos-video-link:hover { text-decoration: underline; }
.kudos-note { margin: 0.25rem 0; line-height: 1.45; }
#kudosNote { width: 100%; min-height: 90px; }

/* Thumbnail editor (edit video modal) */
.thumb-editor { display: flex; gap: 0.85rem; align-items: flex-start; }
.thumb-preview {
  width: 132px;
  height: 74px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #2f2f3f;
  background: #0d0d13;
  flex: 0 0 auto;
}
.thumb-actions { display: flex; flex-direction: column; gap: 0.4rem; align-items: flex-start; }
.thumb-actions .avatar-hint { margin-top: 0; }

/* Two-factor authentication */
.account-2fa { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid #26263a; }
.account-2fa h3 { font-size: 0.95rem; margin-bottom: 0.6rem; }
.twofa-panel p { margin-bottom: 0.6rem; }
.twofa-muted { opacity: 0.65; font-size: 0.85rem; }
.twofa-ok { font-size: 0.85rem; color: #9cc7ff; }
.twofa-error { color: #ff9b9b; font-size: 0.8rem; margin: 0.35rem 0; }
/* Non-blocking notice under a form field, e.g. when a stored value had to be
   trimmed to fit a new limit. Amber rather than red: nothing failed. */
.form-warning { color: #ffcf6b; font-size: 0.8rem; margin: 0.35rem 0 0; line-height: 1.4; }
.twofa-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.qr-wrap { display: flex; justify-content: center; margin-bottom: 0.75rem; }
.qr-wrap img { width: 190px; height: 190px; background: #fff; padding: 8px; border-radius: 10px; }
.secret-code { text-align: center; margin-bottom: 0.85rem; }
.secret-code code {
  display: inline-block;
  padding: 0.5rem 0.75rem;
  background: #0d0d13;
  border: 1px solid #333;
  border-radius: 8px;
  letter-spacing: 0.12em;
  font-size: 0.95rem;
  word-break: break-all;
}
.backup-codes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.4rem;
  margin-bottom: 0.9rem;
}
.backup-codes code {
  background: #0d0d13;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 0.4rem;
  text-align: center;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
}
#twoFactorBody input, #login2faModal input {
  width: 100%;
  background: #0d0d13;
  border: 1px solid #333;
  border-radius: 6px;
  color: #fff;
  padding: 0.65rem;
  margin-bottom: 0.6rem;
  font-size: 1rem;
  letter-spacing: 0.05em;
}
#twoFactorBody button, #login2faModal button { width: 100%; }
#twoFactorBody button.danger { background: #2f80d6; }

/* Staff / mod badges */
.role-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: middle;
  background: rgba(77, 166, 255, 0.18);
  color: #9cc7ff;
  border: 1px solid rgba(77, 166, 255, 0.45);
}
.role-badge.role-mod, .role-badge.role-owner, .role-badge.role-admin {
  background: rgba(168, 85, 247, 0.18);
  color: #d8b4fe;
  border-color: rgba(168, 85, 247, 0.5);
}

/* Community posts */
.posts-panel {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(180deg, rgba(60, 60, 110, 0.16), rgba(20, 20, 30, 0.22));
  border-radius: 14px;
  padding: 1.25rem;
  margin-bottom: 1.75rem;
}
.posts-title { font-size: 1.05rem; margin-bottom: 0.9rem; }
.post-composer textarea {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  background: #0d0d13;
  border: 1px solid #333;
  border-radius: 8px;
  color: #fff;
  padding: 0.7rem;
  font-size: 0.95rem;
}
.post-composer-row { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.6rem; flex-wrap: wrap; }
.post-grow { flex: 1 1 auto; }
.post-image-name { font-size: 0.75rem; opacity: 0.6; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-login-hint, .post-empty { opacity: 0.6; font-size: 0.9rem; margin: 0.5rem 0; }
.posts-list { display: flex; flex-direction: column; gap: 0.9rem; margin-top: 1rem; }
.post {
  background: #14141c;
  border: 1px solid #26263a;
  border-radius: 12px;
  padding: 0.9rem 1rem;
}
.post-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.post-head-text { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.post-author { font-weight: 600; color: #fff; }
.post-time { font-size: 0.72rem; opacity: 0.5; }
.post-text { margin: 0.25rem 0 0.6rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.post-image { display: block; max-width: 100%; border-radius: 10px; margin-bottom: 0.6rem; border: 1px solid #26263a; }
.post-actions { display: flex; gap: 0.5rem; align-items: center; }

/* Channel page */
.channel-container { max-width: 1100px; margin: 0 auto; }
.channel-header { background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%); border: 1px solid #2a2a3d; border-radius: 12px; padding: 1.8rem; margin-bottom: 1.5rem; }
.channel-header h2 { font-size: 2rem; margin-bottom: 0.4rem; }
.channel-description { color: #aab; margin-bottom: 0.6rem; line-height: 1.5; }
.channel-stats { font-size: 0.85rem; color: #777; margin-bottom: 0.8rem; }
.channel-edit-form { background: #1a1a24; border: 1px solid #2a2a3d; border-radius: 10px; padding: 1rem; display: flex; flex-direction: column; gap: 0.7rem; margin-bottom: 1.2rem; }
.channel-edit-form input, .channel-edit-form textarea { background: #0d0d13; border: 1px solid #333; padding: 0.7rem; border-radius: 6px; color: #fff; font-size: 0.95rem; }
.channel-edit-form textarea { min-height: 80px; resize: vertical; }
.channel-link { color: #4da6ff; text-decoration: none; font-weight: 600; cursor: pointer; }
.channel-link:hover { color: #6bb8ff; text-decoration: underline; }

/* Patreon member badge. Deliberately amber rather than any of the role-badge
   colours (purple = mod, etc) so a billing badge is never mistaken for rank. */
.patreon-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid rgba(255, 176, 32, 0.55);
  background: rgba(255, 176, 32, 0.16);
  color: #ffd27a;
  white-space: nowrap;
  vertical-align: middle;
}
.patreon-badge.patreon-free {
  border-color: rgba(255, 176, 32, 0.3);
  background: rgba(255, 176, 32, 0.08);
  color: rgba(255, 210, 122, 0.75);
}

/* Ambient background video: sits behind the whole watch page, dimmed, with the
   main player on top. Fixed + aria-hidden so it never takes focus or affects
   document flow. */
#ambientLayer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background: #05050a;
}
#ambientLayer video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.28;
  filter: saturate(0.85);
}
body.has-ambient #videoPage,
body.has-ambient .navbar,
body.has-ambient .site-banner { position: relative; z-index: 1; }

/* Non-members get this instead of the ambient video. Intentionally not gated. */
.ambient-upsell {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0.75rem 0 0;
  padding: 0.6rem 0.85rem;
  border: 1px dashed rgba(255, 176, 32, 0.4);
  border-radius: 8px;
  background: rgba(255, 176, 32, 0.06);
  font-size: 0.85rem;
  color: #e8e8f0;
}
.ambient-upsell a {
  color: #ffd27a;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 210, 122, 0.4);
}
.ambient-upsell a:hover { border-bottom-color: #ffd27a; }

/* Playlists, blocks, and the modtools permission matrix. Kept minimal and
   built on the existing tokens so these match the rest of the dark UI. */
.playlist-item summary { list-style: none; }
.playlist-item summary::-webkit-details-marker { display: none; }
.playlist-item[open] summary { margin-bottom: 0.25rem; }
.block-row + .block-row { margin-top: 0; }
#roleMatrix th, #roleMatrix td { border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
#roleMatrix input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
#roleMatrix input[type="checkbox"]:disabled { opacity: 0.35; cursor: not-allowed; }
#roleMatrix tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
#roleConfigNotice { min-height: 1.2em; }
#newRoleName { background: #1a1a1a; color: #fff; border: 1px solid #444; border-radius: 6px; }

/* Community Corner pagination: a "Load more" row under each corner's grid, with
   an n-of-total counter so it is obvious how much is left. */
.corner-more-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}
.corner-count { font-size: 0.78rem; opacity: 0.6; }
/* Subscriber list badges. */
.tiny-badge {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  opacity: 0.85;
  white-space: nowrap;
}

/* --- Captions --------------------------------------------------------------
   The overlay is positioned and styled entirely from the viewer's settings,
   applied as CSS custom properties, so nothing here has to be recomputed in JS
   when a preference changes. The font-size is a multiplier on a base that
   scales with the player, which keeps captions legible in fullscreen on a large
   display and on a phone. */
.cc-overlay {
  position: absolute;
  left: 50%;
  width: min(92%, 60em);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15em;
  pointer-events: none;
  /* Sits above the video but below the controls and the big play button. */
  z-index: 4;
  text-align: center;
  font-size: calc(var(--cc-size, 1) * clamp(0.95rem, 2.6vmin, 1.7rem));
  line-height: 1.28;
  font-family: var(--cc-font, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  font-weight: 500;
  color: var(--cc-colour, #fff);
  text-wrap: balance;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .85), 0 0 1px rgba(0, 0, 0, .9);
}
/* The backdrop is per-cue rather than on the container so a two-line caption
   reads as one box instead of two, and so the position variants can move the
   group without leaving a box floating on its own. */
.cc-cue {
  display: inline-block;
  max-width: 100%;
  padding: 0.12em 0.45em;
  border-radius: 0.25em;
  background: var(--cc-bg, rgba(0, 0, 0, .6));
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.cc-overlay:empty { display: none; }

.cc-pos-bottom { bottom: 4.2rem; top: auto; }
.cc-pos-top { top: 1.1rem; bottom: auto; }
.cc-pos-middle { top: 50%; bottom: auto; transform: translate(-50%, -50%); }

.cc-font-sans { --cc-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.cc-font-serif { --cc-font: Georgia, "Times New Roman", serif; }
.cc-font-mono { --cc-font: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.cc-font-rounded { --cc-font: "Trebuchet MS", "Segoe UI", Verdana, sans-serif; }

/* Keep captions clear of the control bar when it is showing. */
.player-shell:not(.controls-hidden) .cc-overlay.cc-pos-bottom { bottom: 5rem; }

.cc-cc-group { display: flex; align-items: center; gap: 0.1rem; }
.cp-btn.is-on { color: #7fd1ff; }

.cc-settings {
  position: absolute;
  right: 0.5rem;
  bottom: 3.4rem;
  z-index: 30;
  width: min(20rem, calc(100% - 1rem));
  padding: 0.7rem 0.8rem 0.6rem;
  border-radius: 10px;
  background: rgba(18, 18, 20, .97);
  border: 1px solid #3a3a40;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .6);
  font-size: 0.82rem;
  color: #eee;
}
.cc-settings[hidden] { display: none; }
.cc-settings-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.cc-settings-label { width: 4.2rem; flex: none; opacity: .8; }
.cc-settings-value { width: 3rem; text-align: right; opacity: .75; font-variant-numeric: tabular-nums; }
.cc-settings input[type="range"] { flex: 1; min-width: 6rem; }
.cc-swatches { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.cc-swatch {
  width: 1.4rem; height: 1.4rem; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer; padding: 0;
}
.cc-swatch[aria-pressed="true"] { border-color: #7fd1ff; }
.cc-segmented { display: flex; border: 1px solid #444; border-radius: 6px; overflow: hidden; }
.cc-segmented button {
  border: 0; background: #232327; color: #ddd; padding: 0.25rem 0.5rem; cursor: pointer; font-size: 0.78rem;
}
.cc-segmented button[aria-pressed="true"] { background: #7fd1ff; color: #06121a; font-weight: 600; }
.cc-preview {
  margin: 0.4rem 0 0.5rem; padding: 0.4rem 0.5rem; border-radius: 6px;
  font-size: calc(var(--cc-size, 1) * 0.95rem);
  line-height: 1.3; text-align: center; text-wrap: balance;
  color: var(--cc-colour, #fff);
  background: var(--cc-bg, rgba(0, 0, 0, .6));
  font-family: var(--cc-font, sans-serif);
}
.cc-settings-foot { display: flex; justify-content: flex-end; }

/* --- Caption manager ------------------------------------------------------- */
.captions-manager {
  margin: 1rem 0;
  border: 1px solid #333;
  border-radius: 8px;
  background: #141416;
  padding: 0.5rem 0.75rem;
}
.captions-manager summary { cursor: pointer; font-weight: 600; padding: 0.2rem 0; }
.captions-manager-body { padding-top: 0.6rem; }
.cc-track-list { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.7rem; }
.cc-track {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  padding: 0.4rem 0.5rem; border: 1px solid #2e2e33; border-radius: 6px; background: #1a1a1d;
}
.cc-track-name { font-weight: 600; }
.cc-track-meta { opacity: .75; font-size: 0.8rem; }
.cc-track.is-processing { border-color: #7a5c00; }
.cc-track.is-failed { border-color: #7a2020; }
.cc-track-error { color: #ff9d9d; font-size: 0.8rem; width: 100%; }
.cc-manager-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.cc-file { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; }
.cc-file input[type="file"] { max-width: 14rem; font-size: 0.8rem; }

/* --- View password --------------------------------------------------------
   The wrapper exists so the button can overlay the input without becoming its
   own flex row in the column-flex forms these live in. The input keeps the width
   it had, so nothing shifts when the toggle appears. */
.pw-wrap { position: relative; display: block; width: 100%; }
.pw-wrap > input.pw-input {
  width: 100%;
  /* Room for the button, and caret-safe: clicking near the end of the text still
     places the caret rather than hitting the button. */
  padding-right: 2.75rem;
}
.pw-toggle {
  position: absolute;
  top: 50%;
  right: 0.4rem;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #8b8b9a;
  cursor: pointer;
  line-height: 0;
}
.pw-toggle:hover { color: #fff; background: rgba(255,255,255,.08); }
.pw-toggle:focus-visible { outline: 2px solid #7fd1ff; outline-offset: 1px; }
.pw-toggle svg { width: 1.15rem; height: 1.15rem; fill: currentColor; }
.pw-toggle.is-on { color: #7fd1ff; }

/* --- Mobile navigation ---------------------------------------------------------
   The horizontal link list used to be `display: none` below 600px, which left a
   phone with the logo and the auth buttons and no way to reach any section at
   all. The same <ul> is moved into an off-canvas drawer instead of being
   replaced by a copy: one source of truth means the `.active` class the router
   sets, and the user-search input with its menu and its ids, keep working
   without a single change. */
.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid #333;
  border-radius: 8px;
  color: #fff;
  width: 44px;
  height: 44px;
  padding: 0;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  line-height: 0;
}
/* 44px is the smallest reliably tappable target; anything smaller and it lands
   between the fingers rather than under one. */
.nav-toggle svg { width: 22px; height: 22px; fill: currentColor; }
.nav-toggle:hover { background: rgba(255, 255, 255, 0.08); }
.nav-toggle:focus-visible { outline: 2px solid #7fd1ff; outline-offset: 2px; }

.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 98;
  opacity: 0;
  transition: opacity 0.2s ease;
}
body.nav-open .nav-backdrop { display: block; opacity: 1; }

@media (max-width: 600px) {
  .nav-toggle { display: flex; }

  /* The drawer. Fixed rather than absolutely positioned so it spans the
     viewport, and clear of the notched area on the left edge. */
  .navbar-links {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 99;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
    margin: 0;
    padding: calc(env(safe-area-inset-top, 0px) + 4.5rem) 0.75rem
             calc(env(safe-area-inset-bottom, 0px) + 1rem)
             calc(env(safe-area-inset-left, 0px) + 0.75rem);
    background: #12121a;
    border-right: 1px solid #26262f;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.55);
    width: min(20rem, 84vw);
    max-width: 84vw;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateX(-102%);
    transition: transform 0.24s ease;
  }
  body.nav-open .navbar-links { transform: translateX(0); }

  /* While closed the drawer is off-screen, not gone, so it stays out of the tab
     order only while it is. focus-visible keeps the keyboard user oriented. */
  body:not(.nav-open) .navbar-links { visibility: hidden; }
  body.nav-open .navbar-links { visibility: visible; }

  .navbar-links > li { width: 100%; }
  .navbar-links a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 0.75rem;
    border-radius: 8px;
    font-size: 1rem;
  }
  .navbar-links a:hover { background: rgba(255, 255, 255, 0.06); }
  .navbar-links a.active { background: rgba(127, 209, 255, 0.12); }

  /* The user search lives inside the list, so it has to go full width here or it
     keeps its 130px desktop width in a 20rem column. */
  .navbar-links #userSearchWrap { width: 100%; }
  .navbar-links #userSearchInput { width: 100% !important; }
  .navbar-links #userSearchMenu { left: 0; right: 0; min-width: 0; }

  /* The auth buttons stay in the bar. They are the only way in or out on a
     phone, and the drawer is navigation, not authentication. */
  #navbarActions { gap: 0.35rem; }
  #navbarActions button { min-height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .navbar-links, .nav-backdrop { transition: none; }
}

/* ---- live streaming ---------------------------------------------------- */

/* The one badge that means "something is happening right now". Red is reserved
   for this and nothing else, so it is never diluted by another use. */
.live-badge {
  background: #e02b2b;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: 4px;
  vertical-align: middle;
}
.live-badge::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 5px;
  border-radius: 50%;
  background: #fff;
  /* A pulsing dot is the only animation on the site that conveys state rather
     than decoration, so it stops for anyone who asked for less motion. */
  animation: live-pulse 1.6s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}
@media (prefers-reduced-motion: reduce) {
  .live-badge::before { animation: none; }
}

/* Buttons. The site's existing controls are bare <button> elements, so these are
   scoped to the live pages rather than restyling every button on the site. */
.broadcast .btn,
.broadcast-queue .btn {
  display: inline-block;
  background: #2b2f36;
  color: #fff;
  border: 1px solid #3d434d;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
}
.broadcast .btn:disabled,
.broadcast-queue .btn:disabled { opacity: 0.55; cursor: not-allowed; }
.broadcast .btn-primary { background: #2f80d6; border-color: #2f80d6; }
.broadcast .btn-danger { background: #b32b2b; border-color: #b32b2b; }

.broadcast {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}
.broadcast-lede { color: #b9c0cc; }
.broadcast-card {
  background: #16191f;
  border: 1px solid #262b34;
  border-radius: 10px;
  padding: 1.1rem 1.2rem;
  margin: 1rem 0;
}
.broadcast-card h2 { margin-top: 0; font-size: 1.05rem; }
.broadcast-label {
  display: block;
  margin: 0.7rem 0 0.25rem;
  font-size: 13px;
  color: #b9c0cc;
}
.broadcast input[type='text'],
.broadcast select {
  width: 100%;
  background: #0f1116;
  color: #fff;
  border: 1px solid #2d333d;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
  box-sizing: border-box;
}
.broadcast-hint { color: #8b93a1; font-size: 13px; }
.broadcast-status { color: #d6dbe4; }
.broadcast-error { color: #ff8a8a; font-size: 13px; }

/* The key is shown once. It gets a monospace block with room to actually read
   it, because "copy" failing on a locked-down browser is a real case. */
.broadcast-key {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  background: #0f1116;
  border: 1px solid #2d333d;
  border-radius: 6px;
  padding: 0.6rem 0.7rem;
}
.broadcast-key code {
  flex: 1 1 240px;
  font-size: 13px;
  word-break: break-all;
  color: #9fe6a0;
}

.broadcast-preview {
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
}
.broadcast-preview video { width: 100%; height: 100%; object-fit: contain; display: block; }

.broadcast-controls,
.broadcast-actions {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 0.8rem 0;
}
.broadcast-check { font-size: 14px; color: #d6dbe4; }

.broadcast-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.6rem;
  margin: 0.8rem 0 0;
}
.broadcast-stats dt { font-size: 12px; color: #8b93a1; }
.broadcast-stats dd { margin: 0.1rem 0 0; font-size: 1.05rem; font-variant-numeric: tabular-nums; }

.broadcast-queue-row {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.6rem 0;
  border-bottom: 1px solid #23282f;
}
.broadcast-queue-who { flex: 1 1 240px; }
.broadcast-queue-meta { color: #8b93a1; font-size: 13px; flex: 0 1 auto; }
.broadcast-queue-actions { display: flex; gap: 0.4rem; }

/* A live card on the home page. */
.live-card {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  background: #16191f;
  border: 1px solid #262b34;
  border-left: 3px solid #e02b2b;
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  margin: 0.5rem 0;
  color: inherit;
  text-decoration: none;
}
.live-card:hover { background: #1b1f26; }
.live-card-title { font-weight: 600; }
.live-card-meta { color: #8b93a1; font-size: 13px; }
