:root {
  --bg: #0f1117;
  --panel: #171a23;
  --panel-2: #1f2330;
  --border: #2a2f3d;
  --text: #e7e9ee;
  --muted: #9aa2b1;
  --primary: #6c5ce7;
  --primary-2: #8b7bff;
  --danger: #e74c6f;
  --radius: 12px;
  --sidebar-width: 240px;
}

/* Prevent fixed-width elements from causing horizontal scroll on small screens. */
img, video, canvas {
  max-width: 100%;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

a { color: var(--primary-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.brand { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.5px; }
.brand span { color: var(--primary-2); }
.brand.center { text-align: center; margin-bottom: 1rem; }
.muted { color: var(--muted); font-size: 0.9rem; }
.center { text-align: center; }

/* Utility to hide elements. Uses display:none with !important so it always
   wins over component display rules (flex/block); the HTML `hidden` attribute
   would be ignored by those. */
.is-hidden { display: none !important; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.92rem;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:hover { background: #262b3a; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.block { width: 100%; margin-top: 0.5rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Auth ---- */
.auth-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1rem;
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 2rem;
}
.auth-card h1 { font-size: 1.3rem; margin: 0 0 1rem; }
.auth-card label { display: block; margin-bottom: 1rem; font-size: 0.9rem; color: var(--muted); }
.auth-card input {
  width: 100%; margin-top: 0.35rem;
  padding: 0.6rem 0.75rem;
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 10px;
}
.alert { padding: 0.6rem 0.8rem; border-radius: 10px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert.error { background: rgba(231,76,111,0.15); color: #ffb3c4; border: 1px solid rgba(231,76,111,0.4); }

/* ---- App shell ---- */
.app-body { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-width); flex-shrink: 0;
  background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 1.25rem 1rem;
  position: relative;
}
.sidebar .brand { margin-bottom: 1.5rem; padding-left: 0.3rem; }

/* ---- Sidebar collapse / expand ---- */
.sidebar-collapse {
  position: absolute; top: 0.9rem; right: 0.75rem;
  width: 28px; height: 28px; padding: 0 0 4px 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); border-radius: 8px; cursor: pointer;
  font-size: 1rem; line-height: 1;
}
.sidebar-collapse:hover { color: var(--text); background: var(--panel-2); }

/* Floating button that re-expands the sidebar. Hidden until collapsed. */
.sidebar-expand {
  position: fixed; left: 1rem; bottom: 1rem; z-index: 200;
  width: 44px; height: 44px; padding: 0 0 5px 0;
  display: none; align-items: center; justify-content: center;
  background: var(--primary); border: 1px solid var(--primary); color: #fff;
  border-radius: 50%; cursor: pointer; font-size: 1.3rem; line-height: 1;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}
.sidebar-expand:hover { background: var(--primary-2); }

body.sidebar-collapsed .sidebar { display: none; }
body.sidebar-collapsed .sidebar-expand { display: flex; }
.sidebar nav { display: flex; flex-direction: column; gap: 0.35rem; flex: 1; }
.sidebar nav a {
  color: var(--text); padding: 0.65rem 0.75rem; border-radius: 10px;
  display: flex; align-items: center; gap: 0.6rem; text-decoration: none;
}
.sidebar nav a:hover { background: var(--panel-2); }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar-footer { border-top: 1px solid var(--border); padding-top: 1rem; }
.sidebar-footer .user { font-weight: 600; margin-bottom: 0.5rem; }
.logout-btn {
  width: 100%; padding: 0.5rem; background: transparent;
  border: 1px solid var(--border); color: var(--muted);
  border-radius: 10px; cursor: pointer;
}
.logout-btn:hover { color: var(--text); }

.content { flex: 1; min-width: 0; padding: 1.75rem 2rem; overflow-y: auto; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.page-header h1 { margin: 0; font-size: 1.5rem; }

/* ---- My Videos list ---- */
.upload-progress { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; color: var(--muted); }
.video-list { display: flex; flex-direction: column; gap: 0.75rem; }
.video-row {
  display: grid; grid-template-columns: 140px 1fr auto;
  gap: 1rem; align-items: center;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.75rem;
}
.video-row .thumb {
  width: 140px; height: 80px; object-fit: cover;
  border-radius: 8px; background: #000;
}
.video-row .meta h3 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.video-row .meta .sub { color: var(--muted); font-size: 0.85rem; }
.video-row .badges { margin-top: 0.4rem; display: flex; gap: 0.4rem; }
.badge {
  font-size: 0.72rem; padding: 0.15rem 0.5rem; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted);
}
.badge.private { color: #ffcf7a; border-color: rgba(255,207,122,0.4); }
.badge.public { color: #7ae0a3; border-color: rgba(122,224,163,0.4); }
.video-row .actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ---- Toggle switch ---- */
.switch { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; color: var(--muted); cursor: pointer; }
.switch input { display: none; }
.switch .track {
  width: 38px; height: 22px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 999px; position: relative; transition: background 0.15s;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform 0.15s, background 0.15s;
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(16px); background: #fff; }

.empty { color: var(--muted); padding: 2rem; text-align: center; }

/* ---- Watch grid ---- */
.watch-controls { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 1.25rem; flex-wrap: wrap; }
.watch-controls input[type="search"] {
  flex: 1; min-width: 200px;
  padding: 0.55rem 0.8rem; background: var(--panel-2);
  border: 1px solid var(--border); color: var(--text); border-radius: 10px;
}
.watch-controls select {
  padding: 0.5rem; background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px;
  max-width: 100%;
}
.watch-controls label { color: var(--muted); font-size: 0.85rem; display: flex; align-items: center; gap: 0.4rem; }

.watch-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.watch-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
}
.watch-card:hover { transform: translateY(-3px); border-color: var(--primary); }
.watch-card .thumb { width: 100%; aspect-ratio: 16/9; object-fit: cover; background: #000; display: block; }
.watch-card .card-body { padding: 0.6rem 0.75rem; }
.watch-card h4 { margin: 0 0 0.2rem; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.watch-card .sub { color: var(--muted); font-size: 0.78rem; }

.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: 1.5rem 0; }

/* ---- Modals ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem; z-index: 50;
}
.modal, .play-modal {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 1.5rem; position: relative;
  max-height: 92vh; overflow-y: auto;
}
.modal { width: 100%; max-width: 820px; }
.modal-close {
  position: absolute; top: 0px; right: 1px;
  z-index: 1000;
  background: none; border: none; color: var(--muted);
  font-size: 1.6rem; cursor: pointer; line-height: 1;
}
.modal h2 { margin-top: 0; }
.modal label { display: block; margin-bottom: 0.9rem; font-size: 0.85rem; color: var(--muted); }
.modal input[type="text"], .modal textarea {
  width: 100%; margin-top: 0.35rem; padding: 0.55rem 0.7rem;
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; font-family: inherit;
}
.modal label.checkbox { display: flex; align-items: center; gap: 0.5rem; color: var(--text); }
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.edit-left video { width: 100%; border-radius: 10px; background: #000; margin-bottom: 0.5rem; }
.thumb-preview { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.35rem; }
.thumb-preview img { width: 100%; max-width: 260px; border-radius: 8px; border: 1px solid var(--border); }
.modal-actions { display: flex; gap: 0.6rem; margin-top: 0.5rem; }

/* ---- Playback modal ---- */
/* Start the overlay after the sidebar so it doesn't cover it. When the sidebar
   is collapsed, reclaim the full width. */
.modal-overlay.fullscreen { padding: 0; left: var(--sidebar-width); }
body.sidebar-collapsed .modal-overlay.fullscreen { left: 0; }
.play-modal { width: 100%; height: 100%; max-width: none; max-height: none; border-radius: 0; }
.play-layout { display: grid; grid-template-columns: 1fr 340px; gap: 1.5rem; height: 100%; }
.play-main video { width: 100%; max-height: 65vh; border-radius: 12px; background: #000; }
.play-main h2 { margin: 1rem 0 0.5rem; }
.play-controls {
  position: relative; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 12px; padding: 1rem;
  overflow-y: auto;
}
.control-loading {
  position: absolute; inset: 0; background: rgba(15,17,23,0.6);
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px; z-index: 5;
}
.shot-wrap { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.3rem; }
.shot-img { width: 100%; border-radius: 8px; border: 1px solid var(--border); background: #000; }
.creative-buttons { margin-top: 0.75rem; display: flex; flex-direction: column; }

/* ---- Spinner ---- */
.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--primary-2);
  animation: spin 0.8s linear infinite;
}
.spinner.big { width: 46px; height: 46px; border-width: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .content { padding: 1.25rem; }
  .page-header { gap: 0.75rem; }
  .watch-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .edit-grid { grid-template-columns: 1fr; }
  .play-layout { grid-template-columns: 1fr; }
  .play-main video { max-height: 52vh; }
}

@media (max-width: 780px) {
  .app-body {
    flex-direction: column;
    min-height: 100dvh;
  }

  /* Sidebar is a full-width top bar here, so the play modal covers the full
     viewport and the collapse control isn't needed. */
  .modal-overlay.fullscreen { left: 0; }
  .sidebar-collapse { display: none; }

  .sidebar {
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 1rem;
    gap: 0.8rem;
  }

  .sidebar .brand {
    margin: 0;
    padding-left: 0;
  }

  .sidebar nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    width: 100%;
    flex: 0;
  }

  .sidebar nav a {
    justify-content: center;
    text-align: center;
    padding: 0.6rem;
  }

  .sidebar-footer {
    border-top: 0;
    padding-top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
  }

  .sidebar-footer .user {
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .logout-btn {
    width: auto;
    padding: 0.45rem 0.8rem;
  }

  .content {
    width: 100%;
    padding: 1rem;
  }

  .page-header {
    flex-wrap: wrap;
    align-items: flex-start;
    margin-bottom: 1rem;
  }

  .page-header h1 {
    flex-basis: 100%;
    font-size: 1.3rem;
  }

  .watch-controls {
    gap: 0.6rem;
    margin-bottom: 1rem;
  }

  .watch-controls input[type="search"] {
    min-width: 0;
    width: 100%;
    flex-basis: 100%;
  }

  .watch-controls label {
    flex: 1;
    min-width: 0;
  }

  .watch-controls select,
  .watch-controls label,
  .watch-controls button {
    width: 100%;
  }

  .watch-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .video-row {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .video-row .thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 16/9;
  }

  .video-row .actions {
    justify-content: flex-start;
  }

  .modal,
  .play-modal {
    padding: 1rem;
  }

  .modal-actions {
    flex-wrap: wrap;
  }

  .modal-actions .btn {
    flex: 1;
    min-width: 140px;
  }

  .play-main video {
    max-height: 45vh;
  }
}

@media (max-width: 520px) {
  .auth-body {
    padding: 0.75rem;
  }

  .auth-card {
    padding: 1.25rem;
    border-radius: 14px;
  }

  .btn {
    font-size: 0.88rem;
    padding: 0.55rem 0.85rem;
  }

  .sidebar {
    padding: 0.75rem;
  }

  .sidebar nav {
    grid-template-columns: 1fr;
  }

  .sidebar nav a {
    justify-content: flex-start;
  }

  .sidebar-footer {
    flex-wrap: wrap;
  }

  .logout-btn {
    width: 100%;
  }

  .content {
    padding: 0.85rem;
  }

  .page-header h1 {
    font-size: 1.15rem;
  }

  .upload-progress {
    align-items: flex-start;
  }

  .watch-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .modal-overlay {
    padding: 0.6rem;
  }

  .modal,
  .play-modal {
    border-radius: 12px;
    padding: 0.85rem;
  }

  .modal-close {
    top: 0.55rem;
    right: 0.7rem;
    font-size: 1.35rem;
  }

  .play-main h2 {
    margin-top: 0.7rem;
    font-size: 1.05rem;
  }

  .pager {
    gap: 0.6rem;
    margin: 1rem 0;
  }
}

/* ---- Product grids (admin + watch modals) ---- */
.admin-section { margin-top: 1rem; }
.admin-section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1rem;
}

/* ---- Admin tabs ---- */
.tabs {
  display: flex; gap: 0.25rem;
  border-bottom: 1px solid var(--border); margin-bottom: 1.5rem;
}
.tab {
  background: transparent; border: none; color: var(--muted);
  padding: 0.6rem 0.95rem; cursor: pointer; font-size: 0.95rem;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--primary); }

/* ---- Collapsible admin sections ---- */
.section-title { display: flex; align-items: center; gap: 0.5rem; }
.section-title h2 { margin: 0; }
.collapse-toggle {
  width: 26px; height: 26px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 7px; cursor: pointer; font-size: 0.9rem; line-height: 1;
  transition: transform 0.15s;
}
.collapse-toggle:hover { color: var(--text); background: var(--panel-2); }
.collapse-toggle.collapsed { transform: rotate(-90deg); }
.collapsible-body.is-collapsed { display: none; }

/* ---- User Generated controls ---- */
.ug-controls { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.ug-controls input[type="search"] {
  min-width: 220px; padding: 0.5rem 0.7rem; background: var(--panel-2);
  border: 1px solid var(--border); color: var(--text); border-radius: 8px;
}
.ug-controls select {
  padding: 0.45rem 0.6rem; background: var(--panel-2);
  border: 1px solid var(--border); color: var(--text); border-radius: 8px;
}
.inline-label { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--muted); font-size: 0.85rem; }
.ug-controls .checkbox { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--text); font-size: 0.85rem; }

/* Template card selected as a filter. */
.product-card { position: relative; }
.template-card.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary) inset; }
.ug-card.is-deleted { opacity: 0.55; }

/* Red active-report badge on a user-generated card. */
.report-badge {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--danger); color: #fff; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700;
}

/* ---- User-generated detail modal ---- */
.ug-modal {
  width: 100%; height: 100%; max-width: none; max-height: none;
  background: var(--panel); border: none; border-radius: 0;
  padding: 1.5rem 2rem; position: relative; overflow-y: auto;
}
.ug-detail { display: grid; grid-template-columns: 320px 1fr; gap: 2rem; align-items: start; max-width: 1100px; margin: 0 auto; }
.ug-hero { width: 100%; border-radius: 12px; border: 1px solid var(--border); background: #fff; margin-bottom: 0.75rem; }
.ug-detail-media .btn { width: 100%; margin-top: 0.75rem; }
.ug-detail-main h2 { margin: 0 0 0.75rem; }
.ug-detail-main h3 { margin: 1.25rem 0 0.5rem; }
.ug-detail-main label { display: block; margin-bottom: 0.75rem; font-size: 0.85rem; color: var(--muted); }
.ug-detail-main input[type="text"],
.ug-detail-main input[type="number"],
.ug-detail-main textarea {
  margin-top: 0.3rem; padding: 0.5rem 0.65rem;
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; font-family: inherit;
}
.ug-variants { display: flex; flex-direction: column; gap: 0.5rem; }
.ug-variant-row { display: flex; align-items: center; gap: 0.75rem; }
.ug-variant-name { flex: 1; font-size: 0.9rem; }
.ug-variant-price { width: 120px; }

/* Variants grouped by color, matching the storefront swatch picker — each
   chip is a size + its editable price rather than a select-one control. */
.ug-variant-groups { display: flex; flex-direction: column; gap: 0.9rem; }
.ug-variant-group-head {
  display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.45rem;
  font-size: 0.85rem; color: var(--text); font-weight: 600;
}
.ug-color-dot {
  width: 1.15rem; height: 1.15rem; flex-shrink: 0; border-radius: 999px;
  background: var(--swatch-color, var(--panel-2)); border: 1px solid var(--border);
}
.ug-variant-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.ug-variant-chip {
  display: flex; flex-direction: column; align-items: center; gap: 0.35rem;
  min-width: 84px; padding: 0.5rem; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 8px;
}
.ug-variant-chip-size { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.ug-variant-chip .ug-variant-price { width: 100%; }
.ug-reports { display: flex; flex-direction: column; gap: 0.6rem; }
.ug-report-row {
  display: flex; align-items: flex-start; gap: 1rem;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.6rem 0.75rem;
}
.ug-report-row.inactive { opacity: 0.6; }
.ug-report-info { flex: 1; }
.ug-report-head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.ug-report-reason { margin: 0.35rem 0 0; font-size: 0.9rem; }

@media (max-width: 780px) {
  .ug-detail { grid-template-columns: 1fr; }
}

/* ---- Users table ---- */
.users-table { width: 100%; border-collapse: collapse; }
.users-table th, .users-table td {
  text-align: left; padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border); vertical-align: middle;
}
.users-table th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
.users-table tbody tr:hover { background: var(--panel-2); }
.product-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem; margin-top: 0.5rem;
}
.product-card {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.product-card:hover { transform: translateY(-2px); border-color: var(--primary); }
.product-card .thumb {
  width: 100%; aspect-ratio: 1/1; object-fit: contain;
  background: #fff; display: block;
}
.product-card .card-body { padding: 0.55rem 0.65rem; }
.product-card h4 {
  margin: 0 0 0.2rem; font-size: 0.9rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.product-card .sub { color: var(--muted); font-size: 0.75rem; }
.product-card .card-actions { display: flex; gap: 0.4rem; margin-top: 0.5rem; }
.product-card .card-actions .btn { flex: 1; padding: 0.35rem; font-size: 0.75rem; }

.variant-picker { margin-top: 1.25rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.variant-picker select { width: 100%; }
.variant-list { display: flex; flex-direction: column; gap: 0.4rem; margin: 0.5rem 0 1rem; max-height: 240px; overflow-y: auto; }
.variant-list .checkbox { margin-bottom: 0; }
.generated-images { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.75rem; }
.generated-images img { width: 140px; border-radius: 8px; border: 1px solid var(--border); background: #fff; }
.muted.small, .small { font-size: 0.78rem; }

/* ---- Sidebar cart badge ---- */
.sidebar nav a { position: relative; }
.cart-badge {
  min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--danger); color: #fff; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; margin-left: auto;
}

/* ---- Merch section under a playing video ---- */
.merch-section { margin-top: 1.25rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.merch-section h3 { margin: 0 0 0.75rem; font-size: 1.05rem; }
.merch-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.9rem;
}
.merch-card {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; cursor: pointer;
  display: flex; flex-direction: column;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.merch-card:hover { transform: translateY(-2px); border-color: var(--primary); }
.merch-card .thumb { width: 100%; aspect-ratio: 1/1; object-fit: contain; background: #fff; display: block; }
.merch-card .card-body { padding: 0.5rem 0.6rem; flex: 1; }
.merch-card h4 {
  margin: 0; font-size: 0.85rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.merch-actions {
  display: flex; gap: 0.25rem; padding: 0.4rem 0.5rem 0.55rem;
  border-top: 1px solid var(--border);
}
.icon-btn {
  flex: 1; padding: 0.35rem 0; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); border-radius: 8px;
  cursor: pointer; font-size: 0.95rem; line-height: 1;
}
.icon-btn:hover:not(:disabled) { background: #262b3a; border-color: var(--primary); }
.icon-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.report-modal { max-width: 420px; }
.report-modal textarea {
  width: 100%; margin-top: 0.35rem; padding: 0.55rem 0.7rem;
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; font-family: inherit; resize: vertical;
}

/* ---- Product page ---- */
.product-page { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; align-items: start; }
.product-hero { width: 100%; border-radius: 12px; border: 1px solid var(--border); background: #fff; }
.product-info h2 { margin: 0 0 0.35rem; }
.product-info label { display: block; margin: 0.9rem 0 0; font-size: 0.85rem; color: var(--muted); }
.product-info input[type="number"] {
  width: 100%; margin-top: 0.35rem; padding: 0.55rem 0.7rem;
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px;
}
.product-price { font-size: 1.4rem; font-weight: 700; margin: 1rem 0; }

/* ---- Variant option buttons (Shopify-style choice chips/swatches) ---- */
.option-groups { display: flex; flex-direction: column; gap: 1.1rem; margin: 1.1rem 0; }
.option-group-label {
  display: flex; gap: 0.4rem; align-items: baseline;
  font-size: 0.85rem; color: var(--muted); margin-bottom: 0.5rem;
}
.option-group-value { color: var(--text); font-weight: 600; }
.swatch-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.swatch-btn {
  position: relative;
  min-width: 2.75rem; height: 2.75rem; padding: 0 0.9rem;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; font-size: 0.85rem; font-weight: 500;
  cursor: pointer; transition: border-color 0.12s ease, background 0.12s ease, transform 0.08s ease;
}
.swatch-btn:hover { border-color: var(--primary-2); }
.swatch-btn:active { transform: scale(0.96); }
.swatch-btn:focus-visible { outline: 2px solid var(--primary-2); outline-offset: 2px; }
.swatch-btn.is-selected {
  border-color: var(--primary); background: var(--panel);
  box-shadow: 0 0 0 1px var(--primary);
}
.swatch-btn.is-unavailable { opacity: 0.45; }
.swatch-btn.is-unavailable::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(to top right, transparent calc(50% - 1px), var(--border) 50%, transparent calc(50% + 1px));
}

/* Color options render as filled circular swatches instead of text pills. */
.swatch-btn.swatch-color {
  min-width: 2.25rem; width: 2.25rem; height: 2.25rem; padding: 0;
  border-radius: 999px; background: var(--swatch-color, var(--panel-2));
}
.swatch-btn.swatch-color.is-selected {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--primary);
}

.qty-label { max-width: 140px; }
.qty-input { width: 100%; }

/* ---- Cart page ---- */
.cart-list { display: flex; flex-direction: column; gap: 0.75rem; }
.cart-row {
  display: grid; grid-template-columns: 72px 1fr 90px auto auto;
  gap: 1rem; align-items: center;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.6rem 0.75rem;
}
.cart-row .thumb { width: 72px; height: 72px; object-fit: contain; background: #fff; border-radius: 8px; }
.cart-title { display: block; font-weight: 600; }
.cart-meta .sub { color: var(--muted); font-size: 0.8rem; }
.cart-qty { width: 80px; padding: 0.4rem; background: var(--panel-2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; }
.cart-line { font-weight: 600; white-space: nowrap; }
.cart-summary { display: flex; align-items: center; justify-content: flex-end; gap: 1.25rem; margin-top: 1.25rem; }
.cart-total { font-size: 1.15rem; }

@media (max-width: 900px) {
  .product-page { grid-template-columns: 1fr; }
  .cart-row { grid-template-columns: 56px 1fr auto; row-gap: 0.5rem; }
  .cart-row .thumb { width: 56px; height: 56px; }
}

/* ---- Admin Timestamps tool ---- */
.ts-modal {
  background: var(--panel); border: none;
  width: 100%; height: 100%; border-radius: 0;
  padding: 1.25rem 1.5rem; position: relative; overflow-y: auto;
}
.ts-heading { margin: 0 0 1rem; }
.ts-heading .muted { font-weight: 400; font-size: 1rem; }
/* Video (top-left) | range list | form */
.ts-layout {
  display: grid;
  grid-template-columns: minmax(240px, 26vw) 220px 1fr;
  gap: 1.5rem; align-items: start;
}
.ts-left { position: sticky; top: 0; }
/* Cap the video to a quarter of the viewport, per spec. */
.ts-video { width: 100%; max-width: 25vw; max-height: 25vh; border-radius: 10px; background: #000; }
.ts-frame-controls { display: flex; gap: 0.5rem; margin: 0.6rem 0; }
.ts-frame-controls .btn { flex: 1; }
.ts-inline { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin: 0.5rem 0; font-size: 0.8rem; color: var(--muted); }
.ts-inline input[type="number"] {
  width: 8rem; padding: 0.4rem 0.55rem; background: var(--panel-2);
  border: 1px solid var(--border); color: var(--text); border-radius: 8px; font-family: inherit;
}
.ts-timestamps { margin-top: 0.75rem; border-top: 1px solid var(--border); padding-top: 0.5rem; }

/* Range list */
.ts-ranges-head { display: flex; align-items: center; justify-content: space-between; }
.ts-ranges-head h3 { margin: 0; font-size: 1rem; }
.ts-range-list { margin-top: 0.6rem; max-height: 70vh; overflow-y: auto; display: flex; flex-direction: column; gap: 0.4rem; }
.ts-range-item {
  display: flex; align-items: center; justify-content: space-between; gap: 0.4rem;
  width: 100%; text-align: left; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 0.5rem 0.6rem; font-size: 0.8rem;
}
.ts-range-item:hover { border-color: var(--primary); }
.ts-range-item.active { border-color: var(--primary); background: #262b3a; }
.ts-range-item.disabled { opacity: 0.6; }
.ts-badge { font-size: 0.65rem; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 0.1rem 0.3rem; }

/* Form */
.ts-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.ts-subhead { margin: 1.25rem 0 0.5rem; font-size: 1rem; }
.ts-imgfield { display: flex; flex-direction: column; gap: 0.4rem; }
.ts-label { font-size: 0.78rem; color: var(--muted); }
.ts-drop {
  position: relative; border: 2px dashed var(--border); border-radius: 10px;
  min-height: 120px; display: flex; align-items: center; justify-content: center;
  background: var(--panel-2); overflow: hidden;
}
.ts-drop.dragover { border-color: var(--primary); background: #262b3a; }
.ts-preview { max-height: 160px; width: 100%; object-fit: contain; }
.ts-drop-hint { color: var(--muted); font-size: 0.75rem; padding: 0.5rem; text-align: center; }
.ts-img-actions { display: flex; gap: 0.4rem; }
.ts-img-actions .btn { flex: 1; }

.ts-design { border-top: 1px solid var(--border); padding-top: 0.9rem; margin-top: 0.9rem; }
.ts-design .ts-imgfield { max-width: 320px; }
.ts-products { margin-top: 0.6rem; }
.ts-products summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; }
.ts-prod-list { display: flex; flex-direction: column; gap: 0.4rem; margin: 0.5rem 0; }
.ts-prod-row {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 0.35rem 0.5rem;
}
.ts-prod-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; background: #000; }
.ts-prod-title { flex: 1; font-size: 0.82rem; }
.ts-prod-status { font-size: 0.7rem; }
.ts-prod-btns { display: flex; gap: 0.2rem; }

.ts-actions { display: flex; gap: 0.6rem; margin-top: 1.25rem; }
#tsStatus { margin-top: 0.6rem; }

/* Nested product picker */
.ts-picker {
  position: absolute; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center; z-index: 60; padding: 1.5rem;
}
.ts-picker-inner {
  position: relative; background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 1.5rem; width: 100%; max-width: 720px; max-height: 85vh; overflow-y: auto;
}

@media (max-width: 1100px) {
  .ts-layout { grid-template-columns: 1fr; }
  .ts-left { position: static; }
  .ts-video { max-width: 60vw; max-height: 40vh; }
  .ts-fields { grid-template-columns: 1fr; }
}

/* ---- Timestamps: from-scratch product builder ---- */
.ts-picker-tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.ts-scratch-block { margin: 1rem 0; padding-top: 0.75rem; border-top: 1px solid var(--border); }
#tsScratchTitle {
  width: 100%; max-width: 320px; margin-top: 0.35rem; padding: 0.5rem 0.7rem;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; font-family: inherit;
}
.ts-scratch-drop { min-height: 70px; margin: 0.4rem 0; }
.ts-scratch-thumbs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.ts-scratch-thumb { position: relative; width: 72px; height: 72px; }
.ts-scratch-thumb img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.ts-scratch-thumb button { position: absolute; top: -6px; right: -6px; padding: 0 0.35rem; }
.ts-scratch-types { display: flex; gap: 1.25rem; margin: 0.5rem 0; }
.checkbox-inline { display: flex; align-items: center; gap: 0.4rem; color: var(--text); font-size: 0.85rem; }
.ts-value-group { margin-top: 0.75rem; }
.ts-values { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.4rem 0; }
.ts-value-row { display: flex; align-items: center; gap: 0.2rem; }
.ts-value-row input {
  width: 6.5rem; padding: 0.35rem 0.5rem; background: var(--panel-2);
  border: 1px solid var(--border); color: var(--text); border-radius: 8px; font-family: inherit;
}
.ts-variant-preview { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.4rem; max-height: 240px; overflow-y: auto; }
.ts-variant-row {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 0.35rem 0.6rem;
}
.ts-variant-name { font-size: 0.85rem; }
.ts-variant-price { color: var(--muted); font-size: 0.85rem; }
.ts-variant-price input {
  width: 5.5rem; margin-left: 0.25rem; padding: 0.3rem 0.45rem; background: var(--panel);
  border: 1px solid var(--border); color: var(--text); border-radius: 6px; font-family: inherit;
}
