/* ===========================
   THEME PALETTE
   =========================== */
:root {
  color-scheme: dark;
  --bg: #020617;
  --bg-elevated: #020817;
  --bg-card: #020817;
  --bg-accent: #0b1220;
  --border-subtle: #1f2937;
  --border-strong: #334155;
  --text: #e5e7eb;
  --text-muted: #94a3b8;
  --brand: #93c5fd;
  --chip-bg: rgba(15,23,42,.9);
  --danger: #ef4444;
  --like: #f97316;
  --primary: #38bdf8;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f4f6;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-accent: #e5e7eb;
  --border-subtle: #e5e7eb;
  --border-strong: #cbd5e1;
  --text: #020617;
  --text-muted: #6b7280;
  --brand: #2563eb;
  --chip-bg: #e0ecff;
  --danger: #b91c1c;
  --like: #fb923c;
  --primary: #0ea5e9;
}
/* ===========================
   GLOBAL RESET & BASE
   =========================== */
{
box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
a {
  color: var(--brand);
}
/* generic buttons (can be overridden) */
button {
  font-family: inherit;
}
/* ===========================
   TOPBAR & DRAWER (shared)
   =========================== */
.topbar {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--bg-elevated);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border-subtle);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.theme-toggle {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-accent);
  color: var(--text);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.brand {
  font-weight: 700;
  color: var(--brand);
  letter-spacing: .3px;
}
.burger {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--bg-accent);
  cursor: pointer;
}
.burger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  position: relative;
}
.burger span::before,
.burger span::after {
  content: "";
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  background: var(--text);
}
.burger span::before { top: -6px; }
.burger span::after  { top:  6px; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 78%;
  max-width: 320px;
  height: 100vh;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border-subtle);
  transform: translateX(100%);
  transition: transform .22s ease;
  z-index: 50;
  display: flex;
  flex-direction: column;
}
.drawer.open {
  transform: translateX(0);
}
.drawer .head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.drawer .x {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--bg-accent);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.drawer .user {
  padding: 12px;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}
.drawer a,
.drawer button.link {
  text-align: left;
  padding: 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  text-decoration: none;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.drawer a small {
  color: var(--text-muted);
  font-size: 12px;
}
.drawer a:hover,
.drawer button.link:hover {
  background: var(--bg-card);
}
/* ===========================
   MAIN LAYOUT
   =========================== */
main {
  max-width: 980px;
  margin: 0 auto;
  padding: 12px;
}
/* ===========================
   INDEX: VIDEO VIEWER
   =========================== */
.videos-wrapper {
  background: transparent;
  border: none;
  padding: 0;
  box-shadow: none;
}
.video-shell {
    width: 100%;
    max-width: 420px;          /* tweak if you want wider/narrower /
    height: calc(110vh - 90px);/ room for browser UI etc /
    max-height: 680px;         / safety cap on tall phones */
    display: flex;
    flex-direction: column;
  }
.video-shell {
  position: relative;
  margin: 14px auto;
  max-width: 420px;
  background: var(--bg-card);
  border-radius: 18px;
  padding: 10px;
  box-shadow: 0 12px 40px rgba(15,23,42,.35);
  overflow: hidden;
}
.video-frame {
  position: relative;
  width: 100%;
  height: min(72vh, 720px);
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.player-host,
.player-host iframe,
iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}
/* Twitch: just fill the frame, no weird crop */
.player-host .tw-player {
  width: 100%;
  height: 100%;
  transform: none;
}
/* Avatar-style profile button in viewer */
#profile-btn {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 2px solid var(--border-subtle);
  background: var(--bg) center/cover no-repeat;
  overflow: hidden;
  font-size: 16px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#profile-btn span {
  transition: opacity .15s ease;
}
/* Side actions (like/comm/share/mute/delete) */
.side-actions {
  position: absolute;
  right: 10px;
  bottom: 70px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  z-index: 7;
}
.side-actions button {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: none;
  background: var(--chip-bg);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
}
.side-actions button span.count {
  display: block;
  font-size: 10px;
  margin-top: 2px;
  color: var(--text);
}
.side-actions button.like.active {
  background: var(--like);
  color: #111827;
}
.side-actions button.delete {
  font-size: 16px;
  background: var(--danger);
  color: #0f172a;
}
/* Views overlay (inside frame) */
.views-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  text-shadow: 0 1px 2px #000;
  text-align: center;
}
.view-badge {
  position: absolute;
  left: 10px;
  bottom: 10px;
  background: var(--chip-bg);
  color: var(--text);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 8;
  border: 1px solid var(--border-subtle);
}
.view-badge .eye {
  font-size: 13px;
}
/* Meta under video */
.video-meta {
  padding: 6px 4px 0;
  color: var(--text);
  font-size: 12px;
}
.video-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--brand);
}
.video-by {
  color: var(--text-muted);
  font-size: 11px;
}
/* Arrow nav under video (desktop) */
.video-nav-row {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  max-width: 180px;
  margin-inline: auto;
}
.video-nav-row button {
  flex: 1;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-accent);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.video-nav-row button:hover {
  background: var(--bg-elevated);
}
/* Invisible edge swipe zones – mobile only */
.swipe-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 20%;
  max-width: 80px;
  z-index: 5;
}
.swipe-left  { left: 0; }
.swipe-right { right: 0; }
/* First-time swipe hint */
.swipe-hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-accent);
  border: 1px solid var(--border-strong);
  font-size: 11px;
  color: var(--text);
  box-shadow: 0 4px 16px rgba(0,0,0,.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  white-space: nowrap;
}
.swipe-hint.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(-2px);
}
.swipe-hint span {
  opacity: .9;
}
/* Comments sheet */
.comments-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
  z-index: 12;
}
.comments-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.comments-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 64vh;
  max-height: 540px;
  min-height: 280px;
  background: var(--bg-elevated);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  transform: translateY(100%);
  transition: transform .22s ease;
  z-index: 13;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border-subtle);
}
.comments-sheet.open {
  transform: translateY(0);
}
.sheet-handle {
  width: 44px;
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
  margin: 8px auto 6px;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px 8px;
  border-bottom: 1px solid var(--border-subtle);
  font-weight: 600;
  color: var(--text);
}
.comments-list {
  flex: 1;
  overflow: auto;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text);
}
.comment {
  margin-bottom: 8px;
  line-height: 1.3;
}
.comment b {
  color: var(--brand);
  margin-right: 6px;
  font-weight: 700;
}
.comment small {
  color: var(--text-muted);
  margin-left: 6px;
  font-size: 10px;
}
.comments-form {
  display: flex;
  gap: 6px;
  padding: 8px 10px 12px;
  border-top: 1px solid var(--border-subtle);
}
.comments-form input[type="text"] {
  flex: 1;
  padding: 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-accent);
  color: var(--text);
  font-size: 13px;
}
.comments-form button {
  padding: 10px 14px;
  border-radius: 999px;
  border: 0;
  background: var(--primary);
  color: #0f172a;
  font-weight: 700;
  font-size: 12px;
}
/* Share toast */
.share-toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 8px);
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 11px;
  box-shadow: 0 6px 22px rgba(0,0,0,.6);
  border: 1px solid var(--border-subtle);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}
.share-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}
.share-toast.error {
  background: rgba(239,68,68,.97);
  color: #fff;
}
/* ===========================
   PROFILE PAGE
   =========================== */
/* links use brand colour, buttons will style themselves */
a {
  color: var(--brand);
}
/* header */
.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
}
.user-head {
  display: flex;
  gap: 10px;
  align-items: center;
}
.avatar {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: var(--bg-card);
  background-size: cover;
  background-position: center;
  border: 2px solid var(--border-subtle);
  flex-shrink: 0;
}
.name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.handle {
  font-size: 12px;
  color: var(--text-muted);
}
.stats {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.stats span {
  margin-right: 10px;
}
.top-actions {
  display: flex;
  gap: 6px;
}
/* profile form */
.profile-form {
  padding: 10px 14px 2px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-card);
}
.profile-form h2 {
  font-size: 13px;
  margin: 0 0 6px;
  color: var(--brand);
}
.profile-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.profile-row label {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 80px;
}
.profile-row input[type="text"],
.profile-row textarea {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 12px;
}
.profile-row input[type="file"] {
  font-size: 11px;
  color: var(--text);
}
.profile-row textarea {
  min-height: 60px;
  resize: vertical;
}
.profile-form .btn-save {
  margin-top: 4px;
}
/* socials */
.socials {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
  background: var(--bg-card);
}
.socials a {
  margin-right: 8px;
  text-decoration: none;
  color: var(--brand);
}
.socials a span {
  opacity: .75;
}
/* grid + cards (profile/videos) */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  padding: 12px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 8px;
}
.badge {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
/* small thumbnail player in profile grid */
.player {
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.player iframe {
  width: 100%;
  height: 100%;
  border: 0;
}
.tt-holder {
  width: 100%;
  height: 100%;
}
/* views under card */
.views {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.views .eye {
  font-size: 12px;
}
/* forms / buttons (shared with profile & forms) */
.row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 6px 0;
  flex-wrap: wrap;
}
/* generic text inputs used in profile cards */
input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 12px;
}
select {
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 12px;
}
.actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.btn {
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-accent);
  color: var(--text);
  text-decoration: none;
  display: inline-block;
  font-size: 12px;
  cursor: pointer;
}
.btn.primary {
  background: var(--primary);
  color: #0b1220;
  border-color: transparent;
}
/* readonly title on profile cards */
.title-line {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
/* ===========================
   SIMPLE CARD PAGES (upload, etc.)
   =========================== */
.page-card-main {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px;
}
.card-full {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 16px;
}
p.muted {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 14px;
}
label {
  font-size: 12px;
  color: var(--text-muted);
  display: block;
  margin: 8px 0 6px;
}
/* ===========================
   AUTH PAGES (login / signup)
   =========================== */
/* Use:  on login/signup */
.page-auth {
  background: var(--bg);
}
.page-auth-center {
  min-height: 100vh;
  display: grid;
  place-items: center;
}
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 18px 16px;
  border-radius: 12px;
  max-width: 360px;
  width: 92%;
}
.auth-card h1 {
  font-size: 18px;
  margin: 0 0 12px;
  color: var(--brand);
}
.auth-card label {
  font-size: 12px;
  color: var(--text-muted);
  display: block;
  margin: 10px 0 6px;
}
.auth-card input {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-accent);
  color: var(--text);
}
.auth-card button {
  width: 100%;
  margin-top: 14px;
  padding: 10px;
  border-radius: 10px;
  border: 0;
  background: var(--primary);
  color: #0b1220;
  font-weight: 700;
}
.auth-card a {
  color: var(--brand);
}
/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 720px) {
  main {
    padding: 0;
  }
  .video-shell {
    max-width: 100%;
    width: 100%;
    height: 100vh;
    border-radius: 0;
    padding: 0;
    margin: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    background: #000;
  }
  .video-frame {
    flex: 1;
    width: 100%;
    height: auto;
    border-radius: 0;
  }
  .video-meta {
    padding: 4px 10px 0;
  }
  .side-actions {
    right: 10px;
    bottom: 90px;
  }
  .video-nav-row {
    display: none;   /* hide arrows on mobile */
  }
  .swipe-zone {
    display: block;  /* use swipe zones on mobile */
  }
  .top {
    flex-direction: column;
    gap: 10px;
  }
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 8px;
  }
  .card {
    padding: 6px;
  }
  .player {
    height: 200px;
    border-radius: 8px;
  }
}
@media (min-width: 721px) {
  .swipe-zone {
    display: none; /* desktop uses arrows only */
  }
}
/* Wider layout for tool pages like Add URL */
.tool-main {
  max-width: 720px;
  margin: 32px auto;
  padding: 0 16px 40px;
}
.card-wide input[type="text"] {
  width: 100%;
  max-width: 100%;
  font-size: 15px;
  padding: 12px 14px;
  box-sizing: border-box;
}
.card-wide {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 18px 16px 20px;
}
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.modal.hidden {
  display: none;
}
.modal-content {
  width: 90%;
  max-width: 360px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  padding: 16px;
  border-radius: 14px;
  color: var(--text);
}
.modal-content h3 {
  margin-top: 0;
  margin-bottom: 12px;
  color: var(--brand);
}
.modal-content select,
.modal-content textarea {
  width: 100%;
  margin-bottom: 12px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-accent);
  color: var(--text);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.feed-toggle-overlay {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  display: inline-flex;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.5);
  backdrop-filter: blur(8px);
}
.feed-toggle-overlay .btn {
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 999px;
}
/* Slightly smaller on very small phones */
@media (max-width: 480px) {
  .feed-toggle-overlay {
    top: 8px;
    gap: 4px;
    padding: 3px 5px;
  }
  .feed-toggle-overlay .btn {
    font-size: 10px;
    padding: 3px 8px;
  }
}
/* ===========================
   TOPBAR ICON BUTTON
   =========================== */
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-accent);
  color: var(--text);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
/* ===========================
   SEARCH OVERLAY
   =========================== */
.search-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
  z-index: 40;
}
.search-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.search-sheet {
  position: fixed;
  inset: 0;
  background: rgba(2,6,23,.98);
  backdrop-filter: blur(10px);
  transform: translateY(100%);
  transition: transform .22s ease;
   