/* tiktok-swipe v2 — design tokens copied from ai-content-pipeline */
:root {
  --bg: #0e0613;
  --bg-2: #16091e;
  --panel: #1a0e23;
  --panel-2: #221031;
  --line: #2a1638;
  --text: #f3e7ff;
  --muted: #a387b6;
  --accent: #ff3ea5;
  --accent-2: #c7259f;
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
body {
  background: radial-gradient(ellipse at 15% -10%, #2a0d3a 0%, var(--bg) 55%);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* === Topbar ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);   /* solid — Safari mis-lays-out sticky+backdrop-filter in iframes */
  position: sticky;
  top: 0;
  z-index: 10;
  gap: 10px;
  flex-wrap: nowrap;
  min-height: 0;
  max-height: 96px;          /* hard guard: the bar can never push the video down a screen */
  overflow: hidden;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
  flex-shrink: 0;
  white-space: nowrap;
}
.brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}
.badge {
  font-size: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 1px;
}
/* Stat pills: never wrap or stack (a squeezed column of 4 pills = the 150px
   Safari bar). Low-value in the embed — hidden below 900px. */
.stats { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; flex-shrink: 0; }
@media (max-width: 900px) { .stats { display: none; } }

/* Toolbar controls: collapse (⌃) + dock top/bottom (⇅) */
.tb-ctrl { display: flex; gap: 4px; flex-shrink: 0; margin-left: 6px; }
.mini-btn.ghosty { padding: 4px 7px; opacity: 0.75; }
.mini-btn.ghosty:hover { opacity: 1; }
/* Banned-creators panel (⛔ in the toolbar) — unban with one tap. */
.bans-panel {
  position: fixed;
  inset: 0;
  background: rgba(14, 6, 19, 0.82);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 56px 12px 12px;
  z-index: 190;
}
.bans-panel.hidden { display: none; }
.bans-card {
  width: min(520px, 100%);
  max-height: min(70vh, 640px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 24px 60px -20px rgba(255, 62, 165, 0.35);
  overflow: hidden;
}
.bans-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.bans-head .muted { flex: 1; font-size: 12px; }
.bans-list { overflow-y: auto; padding: 6px 0; }
.bans-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 13px;
}
.bans-row:last-child { border-bottom: 0; }
.bans-row .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bans-row .who small { display: block; color: var(--muted); font-size: 11px; }
.bans-row .mini-btn.unban { border-color: var(--good); color: var(--good); }
.bans-row .mini-btn.unban:hover { background: rgba(80, 220, 140, 0.12); }
.tool-msg .tool-act {
  margin-left: 8px;
  padding: 1px 7px;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 6px;
  cursor: pointer;
}
.tb-expand {
  display: none;
  width: 100%;
  height: 22px;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: var(--bg-2);
  border: 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  position: sticky;
  top: 0;
  z-index: 10;
}
.tb-expand:hover { color: var(--accent); }
body.tb-collapsed .topbar { display: none; }
body.tb-collapsed .tb-expand { display: block; }
/* dock the whole toolbar at the BOTTOM (under the vote buttons) */
body.tb-bottom .topbar,
body.tb-bottom .tb-expand {
  position: fixed;
  left: 0; right: 0;
  bottom: 0; top: auto;
  border-top: 1px solid var(--line);
  border-bottom: 0;
  z-index: 30;
}
body.tb-bottom main { padding-bottom: 80px; }
.pill {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.pill.up   { color: var(--good); border-color: rgba(74, 222, 128, 0.3); }
.pill.down { color: var(--bad);  border-color: rgba(248, 113, 113, 0.3); }
.pill.skip { color: var(--muted); }
.pill.buffer { color: var(--text); }

/* === Check / Scrape tools (top-left) =================================== */
.tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 14px;
  margin-right: auto;   /* keep buttons left-adjacent to the brand */
  flex: 1 1 auto;
  min-width: 0;         /* lets the status message shrink instead of overflowing the row */
}
.mini-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 8px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, transform 0.05s, filter 0.15s;
}
.mini-btn:hover { background: var(--panel-2); border-color: var(--accent); }
.mini-btn:active { transform: translateY(1px); }
.mini-btn[disabled] { opacity: 0.5; cursor: default; }
.mini-btn.accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: #170018;
}
.mini-btn.accent:hover { filter: brightness(1.06); }
.tool-msg {
  font-size: 12px;
  color: var(--muted);
  max-width: 360px;
  flex: 1 1 0;          /* Safari: a nowrap span won't shrink without min-width:0 —
  min-width: 0;            it overflowed the row and stacked the stat pills 4-high */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s;
}
.tool-msg.show { opacity: 1; }
.tool-msg.ok   { color: var(--good); }
.tool-msg.warn { color: var(--warn); }
.tool-msg.bad  { color: var(--bad); }
.add-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.add-row.hidden { display: none; }
.add-row input {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  padding: 5px 9px;
  border-radius: 8px;
  width: 210px;
  color-scheme: dark;
}
.add-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 62, 165, 0.18);
}
@media (max-width: 640px) {
  .tool-msg { display: none; }   /* keep the bar tidy on phones; buttons still work */
  .tools { margin-left: 6px; gap: 6px; }
  /* phone/embedded-mobile: tight topbar, full-width card, frame capped so the
     vote row stays reachable without scrolling */
  .topbar { flex-wrap: wrap; padding: 8px 10px; gap: 8px; }
  .stats { display: none; }      /* buffer/vote pills — not worth the space on a phone */
  .brand { font-size: 13px; }
  .mini-btn { padding: 5px 8px; font-size: 11px; }
  .add-row input { width: 150px; }
  main { padding: 10px; gap: 10px; }
  .card { max-width: 100%; }
  .frame { aspect-ratio: auto; height: min(58vh, 560px); }
  .votes .btn { padding: 12px 0; font-size: 12px; }
  .hint { display: none; }       /* keyboard hints are meaningless on touch */
}

/* === Layout ============================================================ */
main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
  padding: 22px;
  max-width: 1180px;
  margin: 0 auto;
  align-items: start;
}
@media (max-width: 900px) {
  main { grid-template-columns: 1fr; padding: 14px; }
  .panel-side { display: none; }
}
.stage {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* === Name gate ========================================================= */
.name-gate {
  position: fixed;
  inset: 0;
  background: rgba(14, 6, 19, 0.92);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 200;
}
.name-gate label { color: var(--muted); font-size: 13px; }
.name-gate input {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  padding: 10px 14px;
  border-radius: 10px;
  min-width: 260px;
  text-align: center;
  color-scheme: dark;
}
.name-gate input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 62, 165, 0.18);
}

/* === Card / video frame =============================================== */
.card {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
}
.frame {
  position: relative;
  aspect-ratio: 9 / 16;
  width: 100%;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow:
    0 24px 60px -20px rgba(255, 62, 165, 0.35),
    0 0 0 1px rgba(255, 62, 165, 0.1) inset;
}
.frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
}
/* The off-screen buffer stays in layout (so it keeps preloading) but invisible. */
.frame video.standby {
  opacity: 0;
  pointer-events: none;
}

.tap-flash {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.tap-flash span {
  font-size: 56px;
  color: white;
  background: rgba(0,0,0,0.5);
  border-radius: 50%;
  width: 92px;
  height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tap-flash.show { opacity: 1; }

/* Audio pill */
.audio-pill {
  position: absolute;
  bottom: 10px;
  left: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(14, 6, 19, 0.7);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  backdrop-filter: blur(10px);
}
.pill-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.pill-btn:hover { background: var(--panel); }
.vol {
  width: 84px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  margin-left: 4px;
}
.vol::-webkit-slider-runnable-track {
  height: 3px;
  background: var(--line);
  border-radius: 2px;
}
.vol::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 12px;
  width: 12px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: -4.5px;
  box-shadow: 0 0 8px var(--accent);
}
.vol::-moz-range-thumb {
  height: 12px;
  width: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}

.meta-overlay {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 56px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}
.author {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  pointer-events: auto;
}
.author img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  object-fit: cover;
  background: var(--panel);
}
.author strong {
  font-size: 14px;
  display: block;
  line-height: 1.15;
}
.author small { color: var(--muted); font-size: 11px; }
.vid-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.95);
}
.vid-stats b { color: var(--accent); font-weight: 700; }
.vid-stats b.ratio-good { color: var(--good); }
.vid-stats b.ratio-mid  { color: var(--warn); }
.vid-stats b.ratio-bad  { color: var(--bad); }
.desc {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.92);
  max-height: 48px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Empty state */
.empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  gap: 6px;
  background: rgba(14, 6, 19, 0.7);
  backdrop-filter: blur(6px);
}
.empty.hidden { display: none; }
.empty-title { font-size: 18px; color: var(--accent); font-weight: 600; }

/* === Modifier row ====================================================== */
.modifiers {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0 2px;
}
.frame-pick {
  display: flex;
  align-items: center;
  gap: 6px;
}
.frame-pick .muted { color: var(--muted); font-size: 12px; }
.frame-pick input {
  width: 56px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  padding: 5px 6px;
  font: inherit;
  font-size: 13px;
  text-align: center;
  -moz-appearance: textfield;
  color-scheme: dark;
}
.frame-pick input::-webkit-outer-spin-button,
.frame-pick input::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  font-size: 13px;
}
.toggle input { accent-color: var(--accent); }

/* === Buttons (matched to pipeline .btn) ================================ */
.btn {
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}
.btn:hover { background: var(--panel-2); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 8px;
}
.btn.ghost:hover { color: var(--text); border-color: var(--accent); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: #170018;
  box-shadow: 0 6px 24px -8px var(--accent);
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger {
  border-color: rgba(248, 113, 113, 0.5);
  color: var(--bad);
}
.btn.danger:hover { background: rgba(248, 113, 113, 0.12); }

/* === Vote row ========================================================== */
.votes {
  display: grid;
  grid-template-columns: 0.55fr 1fr 1fr 1fr;   /* ↺ | SKIP | DOWN | UP */
  gap: 8px;
}
.btn.rewind {
  font-size: 18px;
  padding: 10px 0;
  color: var(--muted);
}
.btn.rewind:not([disabled]):hover { color: var(--accent); border-color: var(--accent); }
.votes .btn {
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 13px;
  padding: 14px 0;
}

.hint {
  color: var(--muted);
  text-align: center;
  font-size: 11px;
  margin-top: 2px;
  letter-spacing: 0.02em;
}

/* === Sub-row under the votes: Blacklist + Launch Links ================= */
.votes.sub { margin-top: -6px; }
.votes.sub .blacklist { grid-column: 1 / 4; }  /* under ↺ + SKIP + DOWN */
.votes.sub .launch    { grid-column: 4; }      /* under UP */
.btn.blacklist,
.btn.launch {
  padding: 8px 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  background: transparent;
}
.btn.blacklist {
  color: var(--muted);
  border-color: rgba(248, 113, 113, 0.3);
}
.btn.launch {
  color: var(--muted);
  border-color: rgba(255, 62, 165, 0.35);
}
.btn.launch:hover {
  color: var(--accent);
  background: rgba(255, 62, 165, 0.08);
  border-color: var(--accent);
}
.btn.blacklist:hover {
  color: var(--bad);
  background: rgba(248, 113, 113, 0.08);
  border-color: rgba(248, 113, 113, 0.55);
}
.btn.blacklist.armed {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
  font-weight: 700;
}

/* === Side panel ======================================================== */
.panel-side {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  position: sticky;
  top: 78px;
}
.panel-side h3 {
  margin: 0 0 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 700;
}
.panel-side h3:not(:first-child) { margin-top: 18px; }
.rank {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rank li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
}
.rank li:hover {
  background: var(--panel-2);
  border-color: var(--line);
}
.rank .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  color: var(--text);
}
.rank .w {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 600;
}
.rank .empty-rank {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  padding: 8px;
  font-style: italic;
}
