:root {
  --accent: #7C5CFF;
  --accent-dark: #6142e6;
  --accent-soft: #F1EEFF;
  --ink: #16151A;
  --ink-soft: #6B6975;
  --ink-faint: #A6A3B0;
  --paper: #FAF9FC;
  --card: #FFFFFF;
  --line: #EBE9F2;
  --danger: #E5484D;
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--paper);
  color: var(--ink);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
}
.topbar-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.topbar-tag {
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 4px 10px;
  border-radius: 999px;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }

.layout {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 80px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ---------- Tabs ---------- */
.tab-nav {
  display: flex;
  gap: 4px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 24px 0;
}
@media (max-width: 640px) {
  /* Seven tabs no longer fit one row at phone widths - scroll
     horizontally within the nav itself rather than letting it push
     the whole page wider than the viewport. */
  .tab-nav { overflow-x: auto; padding-bottom: 2px; }
  .tab-btn { flex-shrink: 0; }
}
.tab-btn {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
  background: none;
  border: none;
  padding: 10px 16px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab-btn:hover { color: var(--ink); background: var(--paper); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-pane { display: flex; flex-direction: column; gap: 24px; }
.tab-pane[hidden] { display: none; }

/* ---------- Panels ---------- */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px 8px;
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
h1 { font-size: 16px; margin: 0 0 3px; }
h2 { font-size: 16px; margin: 0; }
.muted { color: var(--ink-soft); font-size: 12.5px; margin: 0; line-height: 1.5; }

/* ---------- Buttons ---------- */
.btn-primary, .btn-secondary, .btn-danger {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: var(--paper); color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { background: var(--line); }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid #F6C7C8; margin-top: 20px; }
.btn-danger:hover { background: #FFF3F3; }
.btn-small { padding: 6px 12px; font-size: 12px; margin-top: 10px; }

/* ---------- Data tables ---------- */
.table-wrap { padding-bottom: 18px; }
.table-wrap-scroll {
  max-height: 320px;
  overflow-y: auto;
}
.table-wrap-scroll .data-table thead th {
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  padding: 0 10px 10px;
  border-bottom: 1px solid var(--line);
}
.data-table tbody tr {
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.12s ease;
}
.data-table tbody tr:hover { background: var(--paper); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table td { padding: 10px; vertical-align: middle; }
.col-thumb { width: 62px; }
.col-check { width: 34px; }
.row-check {
  width: 16px; height: 16px; cursor: pointer;
  opacity: 0; transition: opacity 0.1s ease;
}
.data-table tbody tr:hover .row-check,
.row-check:checked { opacity: 1; }
.data-table tbody tr.row-pinned { background: #FFF8E1; }
.data-table tbody tr.row-pinned:hover { background: #FFF1C2; }
.data-table tbody tr.row-selected { background: var(--accent-soft); }

.bulk-action-bar {
  display: flex; align-items: center; gap: 12px;
  background: var(--accent-soft);
  border: 1px solid #E3DBFF;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 14px;
}
.bulk-action-bar[hidden] { display: none; } /* wins the specificity tie against the rule above */
.bulk-count { font-size: 13px; font-weight: 600; color: var(--accent-dark); }
.col-actions { width: 40px; }
.col-menu { width: 30px; }

/* ---------- Row menu ("⋯") - Pin/Unpin, Edit, Duplicate, Delete -
   reused identically across every list tab (Products, Actions,
   Library, Playlists, Layouts), each wired to that tab's own
   handlers. ---------- */
.row-menu { position: relative; display: inline-flex; }
.row-menu-btn {
  background: none; border: none; cursor: pointer;
  font-size: 16px; font-weight: 700; line-height: 1; letter-spacing: 1px;
  color: var(--ink-faint);
  padding: 5px 6px; border-radius: 6px;
}
.row-menu-btn:hover { background: var(--paper); color: var(--ink); }
.row-menu-dropdown {
  display: none;
  position: absolute;
  top: 100%; right: 0;
  margin-top: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.14);
  min-width: 140px;
  padding: 4px;
  z-index: 20;
}
.row-menu-dropdown.open { display: block; }
.row-menu-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 13px; font-weight: 500;
  color: var(--ink);
  background: none; border: none; cursor: pointer;
  padding: 8px 10px;
  border-radius: 6px;
}
.row-menu-dropdown button:hover { background: var(--paper); }
.row-menu-item-danger { color: var(--danger) !important; }
.row-menu-item-danger:hover { background: #FFF3F3 !important; }

.pin-badge {
  display: inline-block;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 2px 6px; border-radius: 999px;
  background: #FDECC8; color: #92400E;
  margin-left: 7px;
  vertical-align: middle;
}
.row-thumb {
  width: 50px; height: 50px; border-radius: 8px;
  object-fit: cover; background: #000; display: block;
}
.row-thumb-img {
  width: 40px; height: 40px; border-radius: 8px;
  object-fit: cover; background: var(--paper); display: block;
  border: 1px solid var(--line);
}
.row-title { font-weight: 600; font-size: 13.5px; }
.row-sub { color: var(--ink-soft); font-size: 12px; margin-top: 1px; }
.row-arrow { color: var(--ink-faint); text-align: right; display: block; }
.empty-state { color: var(--ink-soft); font-size: 13px; padding: 24px 10px; text-align: center; margin: 0; }

.library-actions { display: flex; gap: 8px; flex-shrink: 0; }

.status-badge-processing {
  display: inline-block;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 2px 6px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-dark);
  margin-left: 7px;
  vertical-align: middle;
}
.status-badge-failed {
  display: inline-block;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 2px 6px; border-radius: 999px;
  background: #FDEDED; color: var(--danger);
  margin-left: 7px;
  vertical-align: middle;
}
/* Distinct from -processing (still normal) and -failed (Bunny said so
   explicitly) - this is HoverReel's own "it's been way too long"
   signal for a video Bunny never actually marked failed. Amber sits
   deliberately between the two. */
.status-badge-stalled {
  display: inline-block;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 2px 6px; border-radius: 999px;
  background: #FFF4E5; color: #B75E00;
  margin-left: 7px;
  vertical-align: middle;
}
.retry-status-link {
  background: none; border: none; padding: 0; margin-left: 7px;
  font-size: 11.5px; font-weight: 600; color: var(--accent);
  cursor: pointer; text-decoration: underline; vertical-align: middle;
}

/* ---------- Native video upload ---------- */
.upload-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  padding: 40px 20px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  transition: border-color 0.15s, background 0.15s;
}
.upload-dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.upload-dropzone-title { font-weight: 600; font-size: 14px; margin: 0; }
.upload-dropzone-or { color: var(--ink-faint); font-size: 12px; margin: 0; }
.upload-dropzone-hint { color: var(--ink-faint); font-size: 11.5px; margin: 4px 0 0; }

.upload-file-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.upload-file-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
}
.upload-file-row-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.upload-file-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-file-status { font-size: 12px; color: var(--ink-soft); flex-shrink: 0; }
.upload-file-status.upload-status-failed { color: var(--danger); }
.upload-file-status.upload-status-ready { color: #1a7f37; }
.upload-progress-track { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.upload-progress-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.15s; }
.upload-file-actions { display: flex; gap: 8px; }
.upload-file-actions button { font-size: 12px; padding: 4px 10px; }

/* ---------- Forms ---------- */
form { display: flex; flex-direction: column; gap: 14px; }
label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.optional-tag { font-weight: 400; color: var(--ink-faint); text-transform: none; }
.field-hint { font-size: 11.5px; color: var(--ink-faint); margin: -8px 0 0; line-height: 1.4; }
/* Overrides the negative margin above specifically for Settings hints
   that follow a <select> - selects have more bottom spacing than a
   plain text input, so the same negative margin that tucks a hint
   neatly under an input instead overlapped the dropdown itself. */
.settings-field .field-hint { margin: 8px 0 0; }

input, select, textarea {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 400;
  color: var(--ink);
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  outline: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: #fff; }
input[type="color"] { padding: 4px; height: 38px; width: 60px; cursor: pointer; }
input[type="file"] { padding: 7px 8px; background: #fff; }

.image-preview-row { display: flex; align-items: center; gap: 10px; margin-top: -6px; }
.image-preview { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); }

/* ---------- Modals ---------- */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(22,21,26,0.45);
  align-items: center; justify-content: center;
  z-index: 999;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 22px 26px 26px;
  width: 440px;
  max-width: 100%;
  max-height: 88vh;
  overflow-y: auto;
}
.modal-wide { width: 740px; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.modal-close {
  border: none; background: none; font-size: 20px; cursor: pointer; color: var(--ink-soft);
  line-height: 1;
}
.modal-split {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 26px;
}
@media (max-width: 640px) {
  .modal-split { grid-template-columns: 1fr; }
  .modal-wide { width: 100%; }
}
.modal-form { min-width: 0; }

.code-block {
  background: var(--ink);
  color: #E9E7F5;
  font-size: 11.5px;
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.stats-row { display: flex; gap: 10px; margin: 18px 0 4px; }
.stat-box {
  flex: 1;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
}
.stat-num { font-size: 18px; font-weight: 700; }
.stat-label { font-size: 11px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.03em; }

/* ---------- Chip picker (tagged videos/products) ---------- */
.chip-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 20px;
}
.chip {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--accent-soft);
  border: 1px solid #E3DBFF;
  border-radius: 999px;
  padding: 4px 6px 4px 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent-dark);
}
.chip img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; background: #000; }
.chip-action { background: #FFF3E0; border-color: #FBD9A5; color: #B45309; }
.chip-action .chip-remove { color: #B45309; }
.chip-remove {
  border: none; background: none; cursor: pointer; color: var(--accent-dark);
  font-size: 14px; line-height: 1; padding: 0 2px;
}
.picker-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px;
  margin-top: 8px;
}
.picker-list-hidden { display: none; }
.picker-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  font-size: 13px;
  cursor: pointer;
  border-radius: 6px;
}
.picker-row:hover { background: var(--paper); }
.picker-empty { font-size: 13px; color: var(--ink-soft); padding: 6px 4px; margin: 0; }

/* ---------- Catalog picker modal (search + sort + checkbox tagging) ---------- */
.picker-controls { display: flex; gap: 8px; margin-bottom: 12px; }
.picker-search { flex: 1; }
.picker-sort { width: 150px; }
.catalog-picker-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px;
}
/* 3-column layout: image | name | price - single-select rows, click to
   tag (no checkbox anymore, since a video only ever has one product
   or one action tagged at a time). */
.catalog-picker-header,
.catalog-picker-row {
  display: grid;
  grid-template-columns: 44px 1fr 90px;
  align-items: center;
  gap: 12px;
}
.catalog-picker-header {
  padding: 4px 8px 8px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.catalog-picker-header span:nth-child(1) { grid-column: 1 / span 2; } /* label spans the image+name columns */
.catalog-picker-header span:nth-child(2) { grid-column: 3; text-align: right; }

/* 4-column variant with a SKU column inserted (product picker only) */
.catalog-picker-header-4col,
.catalog-picker-row-4col {
  grid-template-columns: 44px 1fr 70px 90px !important;
}
.catalog-picker-header-4col span:nth-child(2) { grid-column: 3; text-align: right; }
.catalog-picker-header-4col span:nth-child(3) { grid-column: 4; text-align: right; }
.catalog-picker-sku { font-size: 12px; color: var(--ink-soft); text-align: right; }

/* Variant with no thumbnail column at all (playlist picker) - just name + a right-aligned count. */
.catalog-picker-row-noimg { grid-template-columns: 1fr 90px !important; }
.catalog-picker-row {
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
}
.catalog-picker-row:hover { background: var(--paper); }
.catalog-picker-row input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; }
.catalog-picker-thumb {
  width: 36px; height: 36px; border-radius: 7px; object-fit: cover;
  background: var(--paper); border: 1px solid var(--line);
}
.catalog-picker-name {
  font-size: 13px; font-weight: 600; margin: 0; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.catalog-picker-price { font-size: 12.5px; color: var(--ink-soft); margin: 0; text-align: right; }

/* ---------- Live preview mock widget ---------- */
.preview-pane { display: flex; flex-direction: column; }
.preview-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--ink-faint); margin: 0 0 8px;
}
.preview-stage {
  background: repeating-linear-gradient(45deg, #F4F3F8, #F4F3F8 8px, #EFEDF6 8px, #EFEDF6 16px);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}
.mock-panel {
  width: 150px;
  border-radius: 12px;
  overflow: hidden;
  background: #111;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  transition: width 0.15s ease;
}
.mock-panel.mock-panel-square { border-radius: 0; }
/* When the aspect ratio is set to horizontal, the video area (set via
   JS below) goes wide/short instead of tall/narrow - widen the panel
   to match so the preview doesn't look cramped. */
.mock-panel:has(.mock-panel-video[style*="16/9"]) { width: 230px; }
.mock-panel-video {
  aspect-ratio: 9 / 16; /* overridden inline by JS to match the selected ratio */
  background: linear-gradient(135deg, #2a2a33, #17171c);
  position: relative;
}
.mock-panel-title {
  position: absolute; top: 8px; left: 8px; right: 30px;
  color: #fff; font-size: 9px; font-weight: 600; line-height: 1.3;
  margin: 0;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
.mock-panel-close {
  position: absolute; top: 6px; right: 6px;
  width: 16px; height: 16px; border-radius: 50%;
  background: rgba(0,0,0,0.5); color: #fff; border: none;
  font-size: 10px; line-height: 1; cursor: default;
}
/* Lightly transparent "frosted glass" bar rather than solid white - the
   panel's own dark background still shows through slightly, and text
   stays high-contrast enough to read clearly. */
.mock-cta-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; text-decoration: none;
  background: rgba(20,20,24,0.68);
  backdrop-filter: blur(6px);
}
.mock-cta-bar.mock-theme-light { background: rgba(255,255,255,0.9); }
.mock-cta-image {
  width: 32px; height: 32px; border-radius: 7px; flex-shrink: 0;
  background: var(--accent) center/cover no-repeat;
}
.mock-cta-text { flex: 1; min-width: 0; }
.mock-cta-headline {
  font-size: 9.5px; font-weight: 600; color: #fff; margin: 0 0 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mock-cta-bar.mock-theme-light .mock-cta-headline { color: #16151A; }
.mock-cta-bottom-row { display: flex; align-items: center; gap: 6px; }
/* Price is always this fixed light color - the accent only ever applies
   to the Shop now button below, never the price text. */
.mock-cta-price { font-size: 9.5px; font-weight: 700; color: rgba(255,255,255,0.75); margin: 0; white-space: nowrap; }
.mock-cta-bar.mock-theme-light .mock-cta-price { color: rgba(0,0,0,0.6); }
.mock-cta-shop-btn {
  flex: 1;
  background: var(--accent);
  font-size: 9px; font-weight: 700; text-align: center;
  padding: 5px 6px; border-radius: 6px;
}
.preview-hint { font-size: 11.5px; color: var(--ink-soft); line-height: 1.5; margin-top: 10px; }

/* ---------- Settings (Brand + Player) ---------- */
.settings-field { margin-bottom: 22px; }
.settings-field:last-of-type { margin-bottom: 18px; }
.settings-label {
  display: block;
  font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
  margin-bottom: 8px;
}
.settings-field select {
  width: 100%;
  max-width: 320px;
}
.image-preview {
  width: 44px; height: 44px; border-radius: 8px; object-fit: cover;
  border: 1px solid var(--line); background: var(--paper);
}

.swatch-row { display: flex; gap: 22px; align-items: flex-start; }
.swatch-option {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500; color: var(--ink);
  cursor: pointer;
}
.swatch-option-row { display: flex; align-items: center; gap: 6px; }
.swatch-option input[type="radio"] { width: 15px; height: 15px; cursor: pointer; margin: 0; }
/* All swatches - default, custom, and the black/white font-color pair -
   share one fixed size and shape (rounded square) so they read as a
   consistent set rather than some circles and one odd oval. */
.swatch {
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid var(--line);
  flex-shrink: 0;
  box-sizing: border-box;
}
.swatch-fixed { padding: 0; }
.swatch-white { background: #ffffff; border: 1px solid #D8D6E2; }
.swatch-picker {
  padding: 0; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
/* Color inputs render their swatch inside a padded box by default in
   most browsers - these strip that so it matches the fixed swatches
   next to it exactly, same size and corner radius. */
.swatch-picker::-webkit-color-swatch-wrapper { padding: 0; border-radius: 7px; }
.swatch-picker::-webkit-color-swatch { border: none; border-radius: 7px; }
.swatch-picker::-moz-color-swatch { border: none; border-radius: 7px; }

.swatch-hex {
  width: 84px;
  font-family: inherit;
  font-size: 12.5px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  text-transform: uppercase;
}
.swatch-hex:focus { border-color: var(--accent); background: #fff; outline: none; }

/* CTA preset dropdown + link field, side by side - matches the pattern
   of picking a common action ("Learn more," "Get started"...) next to
   where it links to, instead of a bare text field for button copy. */
.cta-preset-row {
  display: flex;
  gap: 8px;
}
.cta-preset-row select {
  flex: 0 0 150px;
}
.cta-preset-row input[type="url"] {
  flex: 1;
}
.tag-btn-row { display: flex; gap: 8px; }
.swatch-picker::-moz-color-swatch { border: none; border-radius: 50%; }

/* Player Corner Style - a small "vertical player" silhouette per
   option (a rounded-rect or square-rect outline with a play triangle),
   reusing .swatch-option's existing radio-then-preview-then-label
   column layout rather than a one-off. */
.corner-preview {
  width: 44px; height: 68px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
}

/* ---------- Catalog entry type toggle ---------- */
.type-toggle-row {
  display: flex;
  gap: 6px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 18px;
}
.type-toggle {
  flex: 1;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  background: none;
  border: none;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
}
.type-toggle.active { background: #fff; color: var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.catalog-fields { display: flex; flex-direction: column; gap: 14px; }
.catalog-fields[hidden] { display: none; } /* wins the specificity tie against the rule above */

/* Small colored badge shown in the catalog table's Type column */
.type-badge {
  display: inline-block;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 3px 8px; border-radius: 999px;
}
.type-badge-product { background: #EAF2FF; color: #1D4ED8; }
.type-badge-action { background: #FFF3E0; color: #B45309; }

/* ---------- Layout type picker (visual grid, like Firework's own
   "choose a layout" screen) - built so adding an 5th/6th/10th type
   later is just one more tile, never a new dashboard tab. ---------- */
.layout-type-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
@media (max-width: 640px) {
  .layout-type-grid { grid-template-columns: repeat(2, 1fr); }
}
.layout-type-tile {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 14px 8px;
  font-size: 11.5px; font-weight: 600; color: var(--ink-soft);
  cursor: pointer;
}
.layout-type-tile.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.layout-type-icon {
  width: 100%; height: 92px; /* taller, so each pattern reads clearly */
  background: #E4E1EF;
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}
.layout-type-tile.active .layout-type-icon { background: #DCD3FF; }

/* Floating Player - unchanged, a single bubble anchored bottom-right */
.layout-type-icon-floating::after {
  content: ""; position: absolute; right: 8px; bottom: 8px;
  width: 22px; height: 30px; border-radius: 4px; background: var(--accent);
}

/* Carousel - four full-width video silhouettes in a row, plus a fifth,
   narrower and faded one at the end suggesting the next card is about
   to scroll into view. */
.layout-type-icon-carousel {
  display: flex; align-items: center; gap: 4px;
  padding: 10px 8px;
}
.ico-card {
  flex: 1 1 0; align-self: stretch;
  background: var(--accent);
  border-radius: 3px;
}
.ico-card-peek { flex: 0 0 8px; opacity: 0.45; }

/* Grid - two full rows of four video silhouettes each. */
.layout-type-icon-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 5px;
  padding: 10px 8px;
}
.ico-grid-cell { background: var(--accent); border-radius: 3px; }

/* Shop Stack - the same two-row, four-column arrangement as Grid, but
   each cell gets a slim second bar underneath it standing in for the
   CTA strip that sits below every video in this layout. */
.layout-type-icon-stack {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 5px;
  padding: 10px 8px;
}
.ico-stack-card { display: flex; flex-direction: column; gap: 3px; min-height: 0; }
.ico-stack-video { flex: 1; background: var(--accent); border-radius: 3px; min-height: 0; }
.ico-stack-cta { height: 5px; flex-shrink: 0; background: var(--accent); opacity: 0.5; border-radius: 1px; }

/* ---------- Video thumbnails / library relationships ---------- */
.library-entry-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 190px;
}
.library-entry-thumb {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 7px;
  object-fit: cover;
  background: var(--paper);
  border: 1px solid var(--line);
}
.library-entry-cell > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.playlist-name-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 230px;
}
.playlist-name-chip {
  display: inline-block;
  max-width: 210px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Playlist video list ---------- */
.playlist-video-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 4px 7px 4px 4px;
  border-radius: 9px;
  background: var(--accent-soft);
  border: 1px solid #E3DBFF;
  color: var(--accent-dark);
  font-size: 12.5px;
  font-weight: 600;
}
.playlist-video-thumb {
  width: 48px;
  height: 32px;
  flex: 0 0 48px;
  border-radius: 6px;
  object-fit: cover;
  background: #000;
}
.playlist-video-chip-title {
  min-width: 0;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Save sits on the left, Delete sits on the far right - keeping them
   apart so a slightly mis-aimed click can't hit "Delete" when the
   person meant "Save." Shared by the Playlist and Layout detail
   modals. */
.playlist-detail-actions,
.layout-detail-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 20px;
}
.detail-actions-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.playlist-detail-actions .btn-danger,
.layout-detail-actions .btn-danger {
  margin-top: 0; /* .btn-danger's own margin-top is meant for standalone placement below other content, not as a flex sibling here */
}
.video-picker-table {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-height: 360px;
  overflow-y: auto;
}
.video-picker-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 70px minmax(150px, 190px) 90px 140px;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
}
.video-picker-grid-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--card);
  color: var(--ink-faint);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.video-picker-row {
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.video-picker-row:last-child { border-bottom: none; }
.video-picker-row:hover { background: var(--paper); }
.video-picker-title-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.playlist-picker-thumb {
  width: 54px;
  height: 36px;
  flex: 0 0 54px;
  border-radius: 6px;
  object-fit: cover;
  background: #000;
}
.video-picker-meta {
  min-width: 0;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .video-picker-grid { grid-template-columns: minmax(210px, 1fr) 70px 130px; }
  .video-picker-grid > :nth-child(4),
  .video-picker-grid > :nth-child(5) { display: none; }
}

/* ---------- Insights ---------- */

.insights-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.insights-custom-range { display: flex; align-items: center; gap: 8px; }
.insights-custom-range[hidden] { display: none; } /* wins the specificity tie against the rule above - documented CSS gotcha in this codebase */
.insights-custom-range input[type="date"] { width: 150px; }
.insights-compare-toggle {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}
.insights-compare-toggle input { width: 15px; height: 15px; cursor: pointer; }
.insights-range-label { font-size: 12.5px; color: var(--ink-faint); margin-left: auto; }

.insights-subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.insights-subtab-btn {
  padding: 8px 14px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.insights-subtab-btn:hover { color: var(--ink); }
.insights-subtab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.insights-subtab-pane[hidden] { display: none; } /* wins the specificity tie against the flex rule below */
.insights-subtab-pane { display: flex; flex-direction: column; gap: 24px; }

.info-icon {
  display: inline-block;
  font-size: 11px;
  color: var(--ink-faint);
  cursor: help;
  margin-left: 2px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.kpi-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: var(--card);
}
.kpi-card-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-faint);
  margin: 0 0 6px;
  display: flex;
  align-items: center;
}
.kpi-card-value { font-size: 22px; font-weight: 700; line-height: 1.1; }
.kpi-card-delta { font-size: 12px; font-weight: 600; margin-top: 6px; }
.kpi-card-delta.kpi-delta-up { color: #1a7f37; }
.kpi-card-delta.kpi-delta-down { color: var(--danger); }
.kpi-card-delta.kpi-delta-flat { color: var(--ink-faint); }
.kpi-card-delta-sub { font-weight: 400; color: var(--ink-faint); }

.insights-chart-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.insights-chart-card h3 { font-size: 14px; margin: 0; }
.insights-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.insights-section-head h3 { font-size: 14px; margin: 0; }
.insights-chart { width: 100%; overflow-x: auto; }
.insights-chart svg { display: block; width: 100%; height: auto; }

.insights-top-videos { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.insights-video-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.insights-video-row:last-child { border-bottom: none; }
.insights-video-row .row-thumb { width: 44px; height: 44px; flex-shrink: 0; }
.insights-video-title { font-weight: 600; font-size: 13.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.insights-video-metrics { display: flex; gap: 18px; font-size: 12.5px; color: var(--ink-soft); flex-shrink: 0; }
.insights-video-metrics strong { color: var(--ink); font-weight: 700; }

.insights-sort-th { cursor: pointer; user-select: none; white-space: nowrap; }
.insights-sort-th:hover { color: var(--ink-soft); }
.insights-sort-th.insights-sort-active { color: var(--accent); }
.insights-sort-arrow { font-size: 9px; margin-left: 2px; }

.insights-error-state { text-align: center; padding: 30px 10px; }

.insights-skeleton {
  background: linear-gradient(90deg, var(--paper) 25%, var(--line) 50%, var(--paper) 75%);
  background-size: 200% 100%;
  animation: insights-shimmer 1.4s ease-in-out infinite;
  border-radius: 6px;
}
@keyframes insights-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.kpi-card .insights-skeleton { height: 22px; width: 70%; }
.insights-chart .insights-skeleton { height: 220px; width: 100%; border-radius: var(--radius-sm); }

@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .insights-range-label { margin-left: 0; flex-basis: 100%; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .insights-video-row { flex-wrap: wrap; }
  .insights-video-metrics { flex-shrink: 1; flex-basis: 100%; flex-wrap: wrap; gap: 8px 14px; margin-top: 2px; }
}
