/* Shared design system: tokens + primitives used by the player and the admin panel. */

:root {
  --bg: #05060a;
  --fg: #f5f6fa;
  --fg-2: rgba(245, 246, 250, 0.68);
  --fg-3: rgba(245, 246, 250, 0.42);
  --glass: rgba(255, 255, 255, 0.055);
  --glass-strong: rgba(255, 255, 255, 0.09);
  --glass-line: rgba(255, 255, 255, 0.11);
  --glass-hi: rgba(255, 255, 255, 0.16);
  --shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.55);
  --accent: #9fb4ff;
  --accent-2: #c79bff;
  --glow: rgba(150, 170, 255, 0.45);
  --ok: #7fe0a8;
  --warn: #ffc070;
  --danger: #ff6b81;
  --radius: 28px;
  --radius-sm: 16px;
  --gutter: clamp(16px, 3.2vw, 40px);
  --font: 'Manrope', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
svg { display: block; }
:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.7); outline-offset: 3px; }
[hidden] { display: none !important; }
/* No transitions until the first frame, so panels do not slide in on page load. */
.preload *, .preload *::before, .preload *::after { transition: none !important; }

/* ---------- glass surfaces ---------- */
.glass {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.085), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09), var(--shadow);
  backdrop-filter: blur(26px) saturate(150%);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
}
.glass-pill {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-radius: 999px;
}

/* ---------- buttons ---------- */
.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.3s, transform 0.2s var(--ease);
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.bare { background: none; border: 0; width: 36px; height: 36px; border-radius: 50%; }

.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--glass-line);
  background: rgba(255, 255, 255, 0.08);
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.25s, opacity 0.25s, transform 0.2s var(--ease);
}
.pill-btn:active { transform: scale(0.97); }
.pill-btn:disabled { opacity: 0.45; cursor: default; }
.pill-btn.primary { background: #fff; color: #0b0c10; border-color: transparent; }
.pill-btn.accent { background: linear-gradient(120deg, var(--accent), var(--accent-2)) border-box; color: #0b0c10; border-color: transparent; }
.pill-btn.danger { color: var(--danger); }
.pill-btn.sm { height: 26px; padding: 0 10px; font-size: 12px; }

/* ---------- chips ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-2);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip b { color: var(--fg); font-weight: 700; }
/* "border-box" on accent gradients: by default they are sized to the inside and repeat under the
   transparent border, so each rounded end showed a sliver of the opposite colour. */
.chip.new, .chip.accent { color: #111; background: linear-gradient(120deg, var(--accent), var(--accent-2)) border-box; border-color: transparent; }

.chip.ok { color: var(--ok); border-color: rgba(127, 224, 168, 0.3); }
.chip.warn { color: var(--warn); border-color: rgba(255, 192, 112, 0.3); }
.chip.danger { color: var(--danger); border-color: rgba(255, 107, 129, 0.3); }
/* 18+: explicit lyrics */
.chip.adult { color: var(--fg); font-weight: 800; letter-spacing: 0.02em; border-color: rgba(255, 255, 255, 0.32); background: rgba(255, 255, 255, 0.1); }
.chip.tappable { cursor: pointer; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--c, var(--accent)); box-shadow: 0 0 10px var(--c, var(--accent)); }

/* ---------- form controls ---------- */
.field {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--glass-line);
  background: rgba(0, 0, 0, 0.25);
  outline: none;
  transition: border-color 0.25s, background 0.25s;
}
textarea.field { height: auto; min-height: 120px; padding: 12px 14px; resize: vertical; line-height: 1.5; }
.field:focus { border-color: rgba(255, 255, 255, 0.35); background: rgba(0, 0, 0, 0.35); }
.field::placeholder { color: var(--fg-3); }
select.field { appearance: none; -webkit-appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--fg-2) 50%), linear-gradient(135deg, var(--fg-2) 50%, transparent 50%); background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px; background-size: 5px 5px; background-repeat: no-repeat; }
select.field option { background: #15161d; }

/* ---------- styled drop-down (js/select.js): the native select stays, hidden ---------- */
.select { position: relative; min-width: 0; }
.select > select { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.select-btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; cursor: pointer; }
.select-btn:disabled { opacity: 0.5; cursor: default; }
.select-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.select-chevron { flex: none; width: 16px; height: 16px; fill: none; stroke: var(--fg-2); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.25s var(--ease); }
.select.open .select-chevron { transform: rotate(180deg); }
.select.open .select-btn { border-color: rgba(255, 255, 255, 0.35); }
.select-pop {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 0;
  min-width: 100%;
  width: max-content;
  max-width: min(440px, calc(100vw - 24px));
  padding: 6px;
  border-radius: 16px;
  background: rgba(20, 21, 28, 0.97);
  border: 1px solid var(--glass-line);
  box-shadow: 0 18px 50px -12px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: select-in 0.16s var(--ease);
}
.select-pop.up { top: auto; bottom: calc(100% + 6px); }
.select-pop.end { left: auto; right: 0; }
@keyframes select-in { from { opacity: 0; transform: translateY(-4px); } }
.select-search { height: 36px; margin-bottom: 6px; border-radius: 10px; font-size: 13px; }
.select-list { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.select-opt { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 6px 10px 6px 30px; border-radius: 10px; font-size: 13px; font-weight: 600; color: var(--fg-2); cursor: pointer; position: relative; overflow-wrap: anywhere; }
.select-opt.active { background: rgba(255, 255, 255, 0.08); color: var(--fg); }
.select-opt[aria-selected='true'] { color: var(--fg); }
.select-opt[aria-selected='true']::before { content: ''; position: absolute; left: 11px; top: 50%; width: 9px; height: 5px; border: solid var(--accent); border-width: 0 0 2px 2px; transform: translateY(-70%) rotate(-45deg); }
.select-empty { padding: 10px; font-size: 13px; color: var(--fg-3); }
/* iPhone zooms the page into any text field under 16px on focus: touch screens get 16px. */
@media (pointer: coarse) {
  input.field, textarea.field, .select-search { font-size: 16px; }
}

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 96px;
  height: 24px;
  background: transparent;
  cursor: pointer;
  --v: 100%;
}
input[type='range']::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, #fff var(--v), rgba(255, 255, 255, 0.18) var(--v)); }
input[type='range']::-moz-range-track { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.18); }
input[type='range']::-moz-range-progress { height: 4px; border-radius: 4px; background: #fff; }
input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4); }
input[type='range']::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; }

.toggle { display: flex; align-items: center; gap: 14px; padding: 10px 0; cursor: pointer; }
.toggle input { appearance: none; -webkit-appearance: none; flex: none; width: 44px; height: 26px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); position: relative; cursor: pointer; transition: background 0.3s; margin: 0; }
.toggle input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.3s var(--ease); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); }
.toggle input:checked { background: linear-gradient(120deg, var(--accent), var(--accent-2)) border-box; }
.toggle input:checked::after { transform: translateX(18px); }
.toggle span { display: grid; gap: 2px; }
.toggle b { font-size: 14px; font-weight: 700; }
.toggle small { font-size: 12px; color: var(--fg-3); }

/* ---------- copyable link ---------- */
.copy-link { display: flex; gap: 8px; align-items: center; padding: 4px 4px 4px 12px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--glass-line); min-width: 0; }
.copy-link code { flex: 1; min-width: 0; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-2); background: none; padding: 0; }
.copy-link .tag { font-size: 11px; font-weight: 800; color: var(--fg-3); letter-spacing: 0.08em; }

/* Hover feedback only where there is a real pointer: on touch screens :hover sticks after a tap. */
@media (hover: hover) {
  .icon-btn:hover { background: rgba(255, 255, 255, 0.12); }
  .icon-btn.bare:hover { background: rgba(255, 255, 255, 0.08); }
  .pill-btn:hover { background: rgba(255, 255, 255, 0.14); }
  .pill-btn.primary:hover { background: #fff; box-shadow: 0 6px 24px -6px var(--glow); }
  .tab:hover { color: var(--fg); }
}

/* ---------- text helpers ---------- */
.eyebrow-label { margin: 0 0 12px; font-size: 11px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: var(--fg-3); }
.hint { margin: 0 0 12px; font-size: 13px; color: var(--fg-2); line-height: 1.5; }
.muted { color: var(--fg-3); }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* ---------- tabs (segmented control) ---------- */
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: rgba(0, 0, 0, 0.22); border: 1px solid var(--glass-line); }
.tab {
  position: relative;
  flex: 1;
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
  color: var(--fg-2);
  cursor: pointer;
  transition: background 0.3s var(--ease), color 0.3s;
  white-space: nowrap;
}
.tab[aria-selected='true'] { background: rgba(255, 255, 255, 0.14); color: var(--fg); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12); }
.tabs.seg .tab { height: 30px; font-size: 12px; padding: 0 10px; }
.tabs.seg .tab[aria-checked='true'] { background: rgba(255, 255, 255, 0.14); color: var(--fg); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12); }
/* slidingTabs() (dom.js): one highlight moves between tabs; it slides on the compositor (transform),
   so it reacts at once even while the page is busy. */
.tabs.sliding { position: relative; isolation: isolate; }
.tabs.sliding .tab { transition: color 0.25s; }
.tabs.sliding .tab[aria-selected='true'], .tabs.sliding .tab[aria-checked='true'] { background: transparent; box-shadow: none; }
.tabs.sliding::before {
  content: '';
  position: absolute;
  z-index: -1;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: var(--tab-w, 0);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transform: translateX(var(--tab-x, 0));
  will-change: transform;
}
.tabs.sliding.placed::before { transition: transform 0.4s var(--ease), width 0.4s var(--ease); }
.setting { display: grid; gap: 10px; padding: 10px 0; }
.setting > span { display: grid; gap: 2px; }
.setting b { font-size: 14px; font-weight: 700; }
.setting small { font-size: 12px; color: var(--fg-3); }
.tab-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 6px; padding: 0 5px; border-radius: 9px; font-style: normal; font-size: 11px; background: linear-gradient(120deg, var(--accent), var(--accent-2)) border-box; color: #111; vertical-align: 1px; }

/* ---------- hover hints: data-tip="…" on any control ---------- */
[data-tip] { position: relative; }
@media (hover: hover) {
  [data-tip]:hover::after, [data-tip]:focus-visible::after {
    content: attr(data-tip);
    position: absolute;
    z-index: 50;
    left: 50%;
    bottom: calc(100% + 8px);
    width: max-content;
    max-width: 280px;
    padding: 8px 11px;
    border-radius: 10px;
    background: rgba(14, 15, 21, 0.97);
    border: 1px solid var(--glass-line);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.7);
    color: var(--fg-2);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.45;
    letter-spacing: 0;
    text-transform: none;
    white-space: normal;
    text-align: left;
    pointer-events: none;
    transform: translateX(-50%);
    animation: tip-in 0.15s 0.4s both; /* a short delay: no flashes while the mouse passes by */
  }
}
@keyframes tip-in { from { opacity: 0; transform: translate(-50%, 4px); } }

/* ---------- dialog (ask() in dom.js) ---------- */
.dialog-scrim { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, 0.45); animation: dialog-fade 0.2s ease; }
.dialog { width: min(420px, 100%); padding: 22px; display: grid; gap: 12px; animation: dialog-in 0.25s var(--ease); }
.dialog h2 { margin: 0; font-size: 18px; font-weight: 700; }
.dialog p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--fg-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.dialog-actions .pill-btn { height: 38px; padding: 0 18px; }
.pill-btn.danger-fill { background: var(--danger); color: #1a0508; border-color: transparent; }
@keyframes dialog-fade { from { opacity: 0; } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }

/* ---------- the pulse logo (player and studio) ---------- */
.brand-mark { flex: none; overflow: visible; filter: drop-shadow(0 0 8px var(--glow)); }
.bm-disc { fill: rgba(255, 255, 255, 0.06); stroke: rgba(255, 255, 255, 0.14); stroke-width: 0.75; }
.bm-line, .bm-glint { fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.bm-line { stroke: url(#bm-grad); }
/* A short bright stretch running along the line. */
.bm-glint { stroke: #fff; stroke-dasharray: 18 82; animation: bm-glint 6s linear infinite; }
@keyframes bm-glint { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: calc(var(--safe-b) + 24px);
  transform: translate(-50%, 20px);
  max-width: min(480px, calc(100vw - 32px));
  padding: 12px 18px;
  border-radius: 18px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- media row (cover + two lines), used in lists everywhere ---------- */
/* minmax(0, 1fr): the text column may shrink below its content, so long titles never push the row sideways. */
.media-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 6px; border-radius: 14px; }
.media-row img, .media-row .thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: rgba(255, 255, 255, 0.06); }
.media-row .mr-text { min-width: 0; display: grid; gap: 1px; }
.media-row .mr-title {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.3;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.media-row .mr-sub { font-size: 12px; color: var(--fg-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Tap a row to read the full title. */
.media-row.expanded .mr-title { -webkit-line-clamp: unset; }
.media-row.expanded .mr-sub { white-space: normal; overflow-wrap: anywhere; }
.list, .media-list { grid-template-columns: minmax(0, 1fr); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; }
  .bm-glint { animation-duration: 6s !important; }
}
