/* SeeSound — app.css
   The canvas is the page; everything else is glass floating over it (§8). Dark only. Mobile first,
   scaled up for 4K through the root tokens. */

/* ---- Tokens ------------------------------------------------------------------------------------ */
:root {
  color-scheme: dark;
  --bg: #07090e;
  --surface: rgba(13, 17, 26, 0.72);
  --surface-solid: #0f141f;
  --surface-2: rgba(22, 28, 42, 0.85);
  --surface-hover: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e8ecf3;
  --text-dim: rgba(232, 236, 243, 0.64);
  --text-faint: rgba(232, 236, 243, 0.38);
  --accent: #00f3ff;
  --accent-rgb: 0, 243, 255;
  --accent-soft: rgba(0, 243, 255, 0.14);
  --accent-ink: #04202a;
  --violet: #a855f7;
  --violet-rgb: 168, 85, 247;
  --violet-soft: rgba(168, 85, 247, 0.18);
  --green: #22c55e;
  --red: #f43f5e;
  --red-soft: rgba(244, 63, 94, 0.16);
  --amber: #f59e0b;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --blur: blur(16px);
  --shadow: 0 10px 40px -12px rgba(0, 0, 0, 0.65);
  --shadow-glow: 0 0 0 1px rgba(var(--accent-rgb), 0.35), 0 14px 44px -12px rgba(var(--accent-rgb), 0.4);
  --font-head: 'Outfit', system-ui, sans-serif;
  --font-body: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur: 0.22s;
  --gap: 12px;
  --hud-h: 56px;
  --transport-h: 68px;
  --panel-w: 380px;
  --drawer-w: 400px;
  --control-h: 36px;
  --control-h-sm: 28px;
  --track-h: 4px;
  --thumb: 16px;
  --z-hud: 10;
  --z-rec: 15;
  --z-panel: 20;
  --z-overlay: 40;
  --z-modal: 50;
  --z-popover: 60;
  --z-veil: 70;
  --z-drop: 80;
  --z-toast: 90;
  --z-boot: 100;
}

/* ---- Base --------------------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.45 var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  touch-action: manipulation;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--font-head);
  font-weight: 600;
  letter-spacing: -0.01em;
}

p {
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

ul,
ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

legend {
  padding: 0;
}

img,
canvas {
  display: block;
}

[hidden] {
  display: none !important;
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::selection {
  background: rgba(var(--accent-rgb), 0.35);
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
  background-clip: padding-box;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.dim {
  color: var(--text-dim);
}

.small {
  font-size: 12px;
}

.glass {
  background: var(--surface);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---- Stage -------------------------------------------------------------------------------------- */
.app,
.stage-wrap {
  position: fixed;
  inset: 0;
  background: var(--bg);
}

.stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.stage-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.stage-canvas:not(.is-active) {
  visibility: hidden;
}

body.hud-idle .stage {
  cursor: none;
}

/* ---- Brand -------------------------------------------------------------------------------------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-icon {
  color: var(--accent);
  filter: drop-shadow(0 0 8px rgba(var(--accent-rgb), 0.6));
}

.brand-lg {
  font-size: 30px;
  gap: 12px;
}

/* ---- Buttons ------------------------------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--control-h);
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.btn:hover {
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn-sm {
  height: var(--control-h-sm);
  padding: 0 11px;
  font-size: 12px;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 6px 18px -8px rgba(var(--accent-rgb), 0.7);
}

.btn-primary:hover {
  background: #5ff7ff;
}

.btn-secondary {
  background: var(--violet-soft);
  color: #d8b4fe;
  border-color: rgba(var(--violet-rgb), 0.35);
}

.btn-secondary:hover {
  background: rgba(var(--violet-rgb), 0.3);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-ghost:hover {
  background: var(--surface-hover);
  border-color: rgba(255, 255, 255, 0.28);
}

.btn-danger {
  background: var(--red-soft);
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.35);
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.3);
}

.btn.is-busy {
  opacity: 0.6;
  pointer-events: none;
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-weight: 500;
  font-size: inherit;
}

.link:hover {
  text-decoration: underline;
}

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: var(--control-h);
  height: var(--control-h);
  border-radius: var(--radius-pill);
  color: var(--text-dim);
  font-size: 15px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn[aria-pressed="true"] {
  color: var(--accent);
  background: var(--accent-soft);
}

.icon-btn-sm {
  width: var(--control-h-sm);
  height: var(--control-h-sm);
  font-size: 12px;
}

.icon-btn.is-armed {
  color: #fff;
  background: var(--red);
}

/* ---- HUD ---------------------------------------------------------------------------------------- */
.hud {
  position: absolute;
  top: var(--gap);
  left: var(--gap);
  right: var(--gap);
  z-index: var(--z-hud);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  padding: 6px 8px;
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}

.hud-left,
.hud-center,
.hud-right,
.hud-actions,
.preset-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.hud-left {
  order: 1;
  flex: 1 1 auto;
}

.hud-right {
  display: contents;
}

.preset-chip {
  order: 2;
}

.hud-center {
  order: 3;
  flex: 1 1 100%;
}

.hud-actions {
  order: 4;
  flex: 1 1 100%;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.hud-actions::-webkit-scrollbar {
  display: none;
}

.offline-pill,
.hud-fps,
.hud-bpm {
  order: 5;
}

.hud-brand {
  padding: 0 6px;
}

.brand-text {
  display: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: var(--control-h);
  padding: 0 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
  min-width: 0;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.pill:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.pill-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill-caret {
  font-size: 10px;
  color: var(--text-faint);
}

.pill-icon {
  color: var(--text-dim);
}

.source-pill {
  max-width: 220px;
}

.status-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.source-pill[data-status="live"] .status-dot {
  background: var(--accent);
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.9);
}

.source-pill[data-status="starting"] .status-dot {
  background: var(--amber);
  animation: pulse 1s ease-in-out infinite;
}

.source-pill[data-status="error"] .status-dot {
  background: var(--red);
}

.hud-bpm {
  font-size: 12px;
  color: var(--text-dim);
  padding: 0 6px;
}

.offline-pill {
  height: var(--control-h-sm);
  padding: 0 10px;
  font-size: 12px;
  color: var(--amber);
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.1);
  cursor: default;
}

.hud-fps {
  font-size: 12px;
  color: var(--text-dim);
  min-width: 56px;
  text-align: right;
}

.viz-tabs {
  display: flex;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 12px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 12px), transparent);
}

.viz-tabs::-webkit-scrollbar {
  display: none;
}

.viz-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  height: var(--control-h);
  padding: 0 14px;
  border-radius: var(--radius-pill);
  color: var(--text-dim);
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.viz-tab:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.viz-tab[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.35);
}

.viz-tab:disabled {
  opacity: 0.35;
}

.viz-tab-label {
  display: none;
}

.preset-pill {
  max-width: 240px;
  padding-right: 10px;
}

.preset-pill .pill-icon {
  color: var(--amber);
}

.preset-name {
  display: none;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dirty-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.8);
}

.save-btn.is-dirty {
  color: var(--accent);
}

.rec-btn.is-recording {
  color: #fff;
  background: var(--red);
  animation: rec-glow 1.2s ease-in-out infinite;
}

.like-btn[aria-pressed="true"] {
  color: var(--red);
  background: var(--red-soft);
}

.account-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: var(--control-h);
  padding: 0 10px;
  border-radius: var(--radius-pill);
  color: var(--text-dim);
  border: 1px solid transparent;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.account-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.account-btn.is-member {
  color: var(--accent);
  border-color: rgba(var(--accent-rgb), 0.3);
  background: var(--accent-soft);
}

.account-name {
  display: none;
  font-weight: 600;
  font-size: 13px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Auto-hide and pinning */
body.hud-idle .hud,
body.hud-idle .transport,
body.hud-idle .rec-indicator {
  opacity: 0;
  pointer-events: none;
}

body.hud-idle .hud {
  transform: translateY(-6px);
}

body.hud-idle .transport {
  transform: translate(-50%, 6px);
}

body.hud-hidden .hud,
body.hud-hidden .transport {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

/* ---- Popover menus ------------------------------------------------------------------------------ */
.popover {
  position: absolute;
  z-index: var(--z-popover);
  min-width: 230px;
  max-width: min(360px, calc(100vw - 24px));
  padding: 6px;
  background: var(--surface-2);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  transform-origin: top;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.popover.is-open {
  opacity: 1;
  transform: none;
}

.menu-title {
  padding: 8px 10px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  transition: background var(--dur) var(--ease);
}

.menu-item:hover,
.menu-item:focus-visible {
  background: var(--surface-hover);
  text-decoration: none;
  outline-offset: -2px;
}

.menu-item.is-danger {
  color: #fda4af;
}

.menu-icon {
  width: 18px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

.menu-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-hint {
  font-size: 11px;
  color: var(--text-faint);
}

.menu-check {
  font-size: 11px;
  color: transparent;
}

.menu-check.is-checked {
  color: var(--accent);
}

.menu-sep {
  height: 1px;
  margin: 6px 4px;
  background: var(--border);
}

/* ---- Panel (right drawer / bottom sheet) and playlist drawer --------------------------------------- */
.panel,
.drawer {
  position: absolute;
  z-index: var(--z-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transition: opacity var(--dur) var(--ease), transform 0.28s var(--ease);
}

.panel.is-open,
.drawer.is-open {
  opacity: 1;
  transform: none;
}

.panel {
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(74dvh, 720px);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-bottom: 0;
  transform: translateY(24px);
}

.drawer {
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(74dvh, 720px);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-bottom: 0;
  transform: translateY(24px);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 10px 8px 18px;
  flex: 0 0 auto;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
}

.title-icon {
  color: var(--accent);
}

.panel-tabs {
  display: flex;
  gap: 4px;
  margin: 0 12px 8px;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  flex: 0 0 auto;
}

.panel-tab {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 32px;
  border-radius: 8px;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 12px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.panel-tab:hover {
  color: var(--text);
}

.panel-tab[aria-selected="true"] {
  background: var(--surface-2);
  color: var(--accent);
  box-shadow: 0 2px 10px -4px rgba(0, 0, 0, 0.7);
}

.panel-tab-label {
  display: none;
}

.panel-body,
.drawer-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 16px 20px;
}

.panel-tabpanel:empty::before {
  content: attr(data-empty);
  display: block;
  padding: 24px 8px;
  text-align: center;
  color: var(--text-faint);
}

.viz-intro {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 0 14px;
}

.viz-intro-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-soft), var(--violet-soft));
  color: var(--accent);
  font-size: 18px;
  flex: 0 0 auto;
}

.viz-intro-name {
  font-size: 16px;
}

.viz-intro-desc {
  font-size: 12px;
}

.group {
  margin: 0 0 14px;
  padding: 12px 14px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.025);
}

.group-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 6px;
}

.panel-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.panel-actions .btn {
  flex: 1 1 auto;
}

/* ---- Fields and controls ------------------------------------------------------------------------- */
.field {
  margin: 0 0 12px;
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.field-label {
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
}

.field-hint {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-faint);
}

.field-error {
  margin-top: 6px;
  font-size: 12px;
  color: #fda4af;
}

.field-stack .field-label {
  display: block;
  margin-bottom: 6px;
}

.readout {
  font-size: 12px;
  color: var(--text-dim);
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  min-width: 44px;
  text-align: right;
}

.input {
  display: block;
  width: 100%;
  height: var(--control-h);
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.input::placeholder {
  color: var(--text-faint);
}

.input:focus {
  border-color: rgba(var(--accent-rgb), 0.6);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}

.input[aria-invalid="true"] {
  border-color: rgba(244, 63, 94, 0.7);
}

.input-sm {
  height: var(--control-h-sm);
  padding: 0 10px;
  font-size: 13px;
}

.textarea {
  height: auto;
  padding: 8px 12px;
  resize: vertical;
  min-height: 72px;
}

.select {
  display: block;
  width: 100%;
  height: var(--control-h);
  padding: 0 34px 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: rgba(0, 0, 0, 0.25) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%2394a3b8' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.select:focus {
  border-color: rgba(var(--accent-rgb), 0.6);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}

.select option {
  background: var(--surface-solid);
  color: var(--text);
}

.select-sm {
  height: var(--control-h-sm);
  padding: 0 28px 0 10px;
  font-size: 13px;
  width: auto;
}

/* Ranges look the same in Chrome and Firefox: a thin track, a cyan thumb. */
.range {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 28px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.range:disabled {
  opacity: 0.4;
  cursor: default;
}

.range::-webkit-slider-runnable-track {
  height: var(--track-h);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.14);
}

.range::-moz-range-track {
  height: var(--track-h);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.14);
}

.range::-moz-range-progress {
  height: var(--track-h);
  border-radius: 2px;
  background: rgba(var(--accent-rgb), 0.6);
}

.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: var(--thumb);
  height: var(--thumb);
  margin-top: calc((var(--track-h) - var(--thumb)) / 2);
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.18), 0 2px 8px rgba(0, 0, 0, 0.5);
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.range::-moz-range-thumb {
  width: var(--thumb);
  height: var(--thumb);
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.18), 0 2px 8px rgba(0, 0, 0, 0.5);
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.range:hover::-webkit-slider-thumb,
.range:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 6px rgba(var(--accent-rgb), 0.22), 0 2px 8px rgba(0, 0, 0, 0.5);
}

.range:hover::-moz-range-thumb,
.range:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 6px rgba(var(--accent-rgb), 0.22), 0 2px 8px rgba(0, 0, 0, 0.5);
}

.range:focus-visible {
  outline: none;
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid var(--border-strong);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}

.switch[aria-checked="true"] {
  background: rgba(var(--accent-rgb), 0.45);
  border-color: rgba(var(--accent-rgb), 0.6);
}

.switch[aria-checked="true"] .switch-knob {
  transform: translateX(18px);
  background: var(--accent);
}

.field-toggle .field-head {
  margin-bottom: 0;
  min-height: 30px;
}

.field-toggle .field-label {
  cursor: pointer;
}

.segmented {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
}

.seg-btn {
  flex: 1 1 0;
  min-width: 0;
  height: 28px;
  padding: 0 6px;
  border-radius: 7px;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.seg-btn:hover {
  color: var(--text);
}

.seg-btn[aria-checked="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.35);
}

.color-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color {
  -webkit-appearance: none;
  appearance: none;
  width: 48px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.color::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.color::-webkit-color-swatch {
  border: 0;
  border-radius: 5px;
}

.color::-moz-color-swatch {
  border: 0;
  border-radius: 5px;
}

.color-sm {
  width: 34px;
  height: 26px;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
}

.swatch {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 5px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.swatch:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.swatch[aria-pressed="true"] {
  border-color: transparent;
  box-shadow: 0 0 0 2px var(--accent), 0 0 18px -4px rgba(var(--accent-rgb), 0.7);
  color: var(--text);
}

.swatch-bar {
  display: block;
  height: 22px;
  border-radius: 6px;
}

.swatch-label {
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  transition: box-shadow var(--dur) var(--ease);
}

.custom-row.is-active {
  box-shadow: 0 0 0 2px var(--accent);
  border-color: transparent;
}

.custom-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}

.custom-colors {
  display: flex;
  gap: 4px;
  flex: 1 1 auto;
}

.checkbox {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 13px;
  cursor: pointer;
}

/* ---- Transport ---------------------------------------------------------------------------------- */
.transport {
  position: absolute;
  bottom: var(--gap);
  left: 50%;
  z-index: var(--z-hud);
  width: min(980px, calc(100% - 2 * var(--gap)));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "now controls"
    "seek seek";
  align-items: center;
  gap: 4px 10px;
  padding: 8px 12px;
  transform: translateX(-50%);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}

.tp-now {
  grid-area: now;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tp-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tp-sub {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tp-controls {
  grid-area: controls;
  display: flex;
  align-items: center;
  gap: 2px;
}

.tp-play {
  width: 44px;
  height: 44px;
  margin: 0 4px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 16px;
}

.tp-play:hover {
  background: #5ff7ff;
  color: var(--accent-ink);
}

.tp-repeat {
  position: relative;
}

.tp-repeat[data-mode="one"]::after {
  content: "1";
  position: absolute;
  top: 5px;
  right: 6px;
  font: 700 9px/1 var(--font-mono);
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 50%;
  width: 12px;
  height: 12px;
  display: grid;
  place-items: center;
}

.tp-seek-wrap {
  grid-area: seek;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.tp-seek {
  flex: 1 1 auto;
  height: 22px;
}

.tp-time {
  font-size: 11.5px;
  color: var(--text-dim);
  min-width: 38px;
}

.tp-time:last-child {
  text-align: right;
}

.tp-right {
  grid-area: right;
  display: none;
  align-items: center;
  gap: 4px;
}

.tp-volume {
  width: 90px;
  height: 22px;
}

/* ---- REC indicator and FPS ----------------------------------------------------------------------- */
.rec-indicator {
  position: absolute;
  top: calc(var(--hud-h) + 2 * var(--gap) + 84px);
  left: var(--gap);
  z-index: var(--z-rec);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 6px 0 12px;
  border-radius: var(--radius-pill);
  border-color: rgba(244, 63, 94, 0.45);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: #fda4af;
  transition: opacity 0.5s var(--ease);
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 10px var(--red);
  animation: blink 1s steps(2, start) infinite;
}

.rec-timer {
  color: var(--text);
  letter-spacing: 0;
}

.rec-stop {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #fff;
  background: var(--red);
  font-size: 10px;
}

/* ---- Overlays, modals ---------------------------------------------------------------------------- */
.overlay,
.modal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gap);
  background: rgba(4, 6, 10, 0.7);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}

.overlay {
  z-index: var(--z-overlay);
}

.modal {
  z-index: var(--z-modal);
}

.save-dialog {
  z-index: calc(var(--z-modal) + 5);
}

.overlay.is-open,
.modal.is-open {
  opacity: 1;
}

.modal-card,
.start-shell,
.gallery-shell {
  transform: translateY(10px) scale(0.985);
  transition: transform 0.28s var(--ease);
}

.is-open > .modal-card,
.is-open > .start-shell,
.is-open > .gallery-shell {
  transform: none;
}

.modal-card {
  width: min(480px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.help-card {
  width: min(720px, 100%);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 12px 10px 20px;
  flex: 0 0 auto;
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
}

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 20px 20px;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 20px 18px;
  border-top: 1px solid var(--border);
  flex: 0 0 auto;
}

.section-title {
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 16px 0 8px;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.form-actions-end {
  justify-content: flex-end;
}

.form-actions-split {
  justify-content: space-between;
  margin-top: 20px;
}

.form-error {
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  background: var(--red-soft);
  border: 1px solid rgba(244, 63, 94, 0.35);
  color: #fecdd3;
  font-size: 13px;
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid rgba(var(--accent-rgb), 0.25);
  color: var(--text);
  font-size: 13px;
}

.notice .fa-solid {
  color: var(--accent);
  margin-top: 2px;
}

.auth-switch {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-dim);
}

.account-id {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--violet));
  color: var(--accent-ink);
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 15px;
}

/* ---- Help --------------------------------------------------------------------------------------- */
.help-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px 20px;
}

.help-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.help-keys {
  display: flex;
  gap: 4px;
  flex: 0 0 118px;
}

kbd {
  display: inline-block;
  min-width: 24px;
  padding: 3px 7px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  background: rgba(255, 255, 255, 0.06);
  font: 500 11.5px/1.2 var(--font-mono);
  color: var(--text);
  text-align: center;
}

.help-label {
  font-size: 13px;
  color: var(--text-dim);
}

.help-notes {
  margin-top: 18px;
}

.help-notes h3 {
  font-size: 13px;
  margin: 14px 0 4px;
  color: var(--accent);
}

.help-notes p {
  font-size: 13px;
  color: var(--text-dim);
}

/* ---- Start overlay ------------------------------------------------------------------------------- */
.start-overlay {
  align-items: flex-start;
  overflow-y: auto;
}

.start-shell {
  width: min(960px, 100%);
  margin: auto;
  padding: 16px 4px 24px;
}

.start-head {
  position: relative;
  text-align: center;
  padding: 18px 48px 22px;
}

.start-tagline {
  margin-top: 10px;
  font-size: 15px;
  color: var(--text-dim);
}

.start-close {
  position: absolute;
  top: 10px;
  right: 0;
}

.start-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.start-card-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.start-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 22px;
  text-align: left;
  background: var(--surface);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.start-card:hover:not(:disabled),
.start-card:focus-visible {
  transform: translateY(-3px);
  border-color: transparent;
  box-shadow: var(--shadow-glow);
}

.start-card:disabled {
  opacity: 0.55;
}

.start-card-icon {
  display: inline-grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.25), rgba(var(--violet-rgb), 0.25));
  color: var(--accent);
  font-size: 22px;
}

.start-card-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 19px;
}

.start-card-text {
  font-size: 13px;
  color: var(--text-dim);
}

.start-card-note {
  font-size: 12px;
  color: var(--amber);
}

.device-select {
  width: 100%;
}

.start-remember {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 18px 0 8px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
}

.featured {
  margin-top: 18px;
}

.featured-title {
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 10px 4px;
}

.featured-strip {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 4px 4px 10px;
}

.featured-card {
  flex: 0 0 176px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.featured-card:hover,
.featured-card:focus-visible {
  transform: translateY(-2px);
  border-color: transparent;
  box-shadow: var(--shadow-glow);
}

.featured-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  object-fit: cover;
  background: #000;
}

.featured-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 4px 4px;
  min-width: 0;
}

.featured-name {
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.featured-viz {
  font-size: 11.5px;
  color: var(--text-dim);
}

.start-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  margin-top: 18px;
  font-size: 13px;
}

/* ---- Gallery and preset browser ------------------------------------------------------------------ */
.gallery {
  padding: 0;
}

.gallery-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: var(--surface);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: 0;
  overflow: hidden;
}

.gallery-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 16px 20px;
}

.preset-browser {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.browser-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.scope-tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
}

.scope-tab {
  height: 26px;
  padding: 0 12px;
  border-radius: 7px;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 12px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.scope-tab[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.browser-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1 1 auto;
}

.search {
  flex: 1 1 140px;
  min-width: 120px;
}

.browser-status {
  font-size: 12px;
}

.browser-more {
  display: flex;
  justify-content: center;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  gap: 10px;
}

.in-gallery .preset-grid {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.preset-card {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.preset-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.preset-card.is-current {
  border-color: transparent;
  box-shadow: 0 0 0 2px var(--accent), 0 0 24px -6px rgba(var(--accent-rgb), 0.7);
}

.card-main {
  position: relative;
  display: block;
  width: 100%;
  color: var(--text);
}

.card-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #000;
  transition: transform 0.4s var(--ease);
}

.card-main:hover .card-thumb {
  transform: scale(1.04);
}

.card-viz {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: rgba(4, 6, 10, 0.7);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  font-size: 11px;
  font-weight: 600;
}

.card-meta {
  padding: 10px 10px 4px;
  min-width: 0;
}

.card-name {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-owner {
  font-size: 11.5px;
  margin-top: 2px;
}

.card-owner-icon {
  color: var(--amber);
}

.card-desc {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px 6px;
}

.like-wrap {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-right: auto;
}

.card-like[aria-pressed="true"] {
  color: var(--red);
  background: var(--red-soft);
}

.like-count {
  font-size: 12px;
  color: var(--text-dim);
}

/* ---- Playlist and queue -------------------------------------------------------------------------- */
.playlist {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.section-head .section-title {
  margin: 0;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.inline-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.inline-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 26px 16px;
  text-align: center;
  color: var(--text-dim);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  font-size: 13px;
}

.empty-icon {
  font-size: 26px;
  color: var(--text-faint);
}

.track-list,
.playlist-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.track-row,
.playlist-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 4px 4px 2px;
  border-radius: 10px;
  transition: background var(--dur) var(--ease);
}

.track-row:hover,
.playlist-row:hover {
  background: var(--surface-hover);
}

.track-row.is-current,
.playlist-row.is-active {
  background: var(--accent-soft);
}

.track-row.is-dragging {
  opacity: 0.4;
}

.track-row.drop-before {
  box-shadow: inset 0 2px 0 var(--accent);
}

.track-row.drop-after {
  box-shadow: inset 0 -2px 0 var(--accent);
}

.drag-handle {
  flex: 0 0 auto;
  width: 22px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  color: var(--text-faint);
  cursor: grab;
  border-radius: 6px;
}

.drag-handle:active {
  cursor: grabbing;
}

.track-main,
.playlist-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  border-radius: 8px;
  color: var(--text);
  text-align: left;
}

.track-index {
  flex: 0 0 22px;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}

.is-current .track-index {
  color: var(--accent);
}

.playlist-icon {
  flex: 0 0 22px;
  text-align: center;
  color: var(--text-dim);
}

.is-active .playlist-icon {
  color: var(--accent);
}

.track-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.track-title {
  font-weight: 500;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-sub {
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-duration {
  flex: 0 0 auto;
  font-size: 11.5px;
}

.track-actions {
  display: inline-flex;
  gap: 2px;
  flex: 0 0 auto;
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}

.track-row:hover .track-actions,
.playlist-row:hover .track-actions,
.track-row:focus-within .track-actions,
.playlist-row:focus-within .track-actions {
  opacity: 1;
}

.track-edit {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  padding: 6px;
}

.upload-drop {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  margin-bottom: 8px;
  border: 2px dashed rgba(var(--accent-rgb), 0.5);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
}

.upload-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.upload-row {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  transition: opacity 0.4s var(--ease);
}

.upload-row.is-done {
  border-color: rgba(34, 197, 94, 0.4);
}

.upload-row.is-failed {
  border-color: rgba(244, 63, 94, 0.45);
}

.upload-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  margin-bottom: 6px;
}

.upload-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--violet));
  transition: width 0.2s linear;
}

.is-done .progress-bar {
  background: var(--green);
}

.is-failed .progress-bar {
  background: var(--red);
}

/* ---- Toasts ------------------------------------------------------------------------------------- */
.toasts {
  position: absolute;
  right: var(--gap);
  bottom: var(--gap);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  width: min(400px, calc(100% - 2 * var(--gap)));
  pointer-events: none;
}

body.has-transport .toasts {
  bottom: calc(var(--transport-h) + 2 * var(--gap) + 36px);
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 10px 8px 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  font-size: 13px;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.toast.is-open {
  opacity: 1;
  transform: none;
}

.toast-icon {
  margin-top: 3px;
  color: var(--accent);
}

.toast-success .toast-icon {
  color: var(--green);
}

.toast-error .toast-icon {
  color: var(--red);
}

.toast-error {
  border-color: rgba(244, 63, 94, 0.4);
}

.toast-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toast-text {
  overflow-wrap: anywhere;
}

.toast-action {
  align-self: flex-start;
  color: var(--accent);
  font-weight: 600;
  font-size: 12.5px;
}

.toast-action:hover {
  text-decoration: underline;
}

.toast-close {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: var(--text-faint);
  display: inline-grid;
  place-items: center;
}

.toast-close:hover {
  color: var(--text);
  background: var(--surface-hover);
}

/* ---- Veil, drop zone, boot ----------------------------------------------------------------------- */
.veil {
  position: absolute;
  inset: 0;
  z-index: var(--z-veil);
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(4, 6, 10, 0.3), rgba(4, 6, 10, 0.72));
  cursor: pointer;
}

.veil-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  padding: 24px;
}

.veil-icon {
  font-size: 34px;
  color: var(--accent);
  animation: tap 1.6s ease-in-out infinite;
}

.veil-text {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 28px;
}

.veil-sub {
  color: var(--text-dim);
  font-size: 14px;
}

.veil-alt {
  margin-top: 10px;
  font-size: 13px;
}

.drop-zone {
  position: absolute;
  inset: 0;
  z-index: var(--z-drop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(var(--accent-rgb), 0.08);
  pointer-events: none;
}

.drop-zone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 100%;
  border: 2px dashed rgba(var(--accent-rgb), 0.7);
  border-radius: var(--radius-lg);
  justify-content: center;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 22px;
  color: var(--accent);
  text-shadow: 0 0 20px rgba(var(--accent-rgb), 0.6);
}

.drop-zone-inner .fa-solid {
  font-size: 40px;
}

.drop-zone-upload {
  display: none;
}

.drop-zone.over-upload .drop-zone-play {
  display: none;
}

.drop-zone.over-upload .drop-zone-upload {
  display: inline;
}

.boot {
  position: absolute;
  inset: 0;
  z-index: var(--z-boot);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg);
}

.boot .brand-icon {
  animation: pulse 1.4s ease-in-out infinite;
}

.boot-status {
  color: var(--text-dim);
  font-size: 13px;
  max-width: 420px;
  text-align: center;
  padding: 0 16px;
}

.boot.is-failed .boot-status {
  color: #fda4af;
}

.boot.is-failed .brand-icon {
  animation: none;
  color: var(--red);
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-boot) + 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: var(--bg);
}

/* ---- Animations ---------------------------------------------------------------------------------- */
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.35;
  }
}

@keyframes blink {
  to {
    visibility: hidden;
  }
}

@keyframes rec-glow {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.6);
  }

  50% {
    box-shadow: 0 0 0 8px rgba(244, 63, 94, 0);
  }
}

@keyframes tap {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}

/* ---- Responsive: tablets and up ------------------------------------------------------------------ */
@media (min-width: 520px) {
  .preset-name,
  .brand-text {
    display: inline;
  }

  .transport {
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas:
      "now controls right"
      "seek seek seek";
  }

  .tp-right {
    display: flex;
  }

  .help-grid {
    grid-template-columns: 1fr 1fr;
  }

  .start-cards {
    grid-template-columns: repeat(3, 1fr);
  }

  .inline-form {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .inline-form .input {
    flex: 1 1 160px;
    width: auto;
  }
}

@media (min-width: 720px) {
  .hud {
    flex-wrap: nowrap;
    height: var(--hud-h);
    padding: 0 10px;
  }

  .hud-right {
    display: flex;
    order: 3;
    flex: 0 0 auto;
    gap: 8px;
  }

  .hud-center {
    order: 2;
    flex: 1 1 auto;
    justify-content: center;
  }

  .hud-actions,
  .preset-chip,
  .offline-pill,
  .hud-fps,
  .hud-bpm {
    order: 0;
    flex: 0 0 auto;
    overflow: visible;
    padding-bottom: 0;
  }

  .viz-tabs {
    flex: 0 1 auto;
  }

  .viz-tab-label,
  .panel-tab-label,
  .account-name {
    display: inline;
  }

  .panel {
    top: calc(var(--hud-h) + 2 * var(--gap));
    right: var(--gap);
    bottom: var(--gap);
    left: auto;
    width: var(--panel-w);
    max-height: none;
    border-radius: var(--radius);
    border-bottom: 1px solid var(--border);
    transform: translateX(24px);
  }

  .drawer {
    top: calc(var(--hud-h) + 2 * var(--gap));
    left: var(--gap);
    bottom: var(--gap);
    right: auto;
    width: var(--drawer-w);
    max-height: none;
    border-radius: var(--radius);
    border-bottom: 1px solid var(--border);
    transform: translateX(-24px);
  }

  body.has-transport .panel,
  body.has-transport .drawer {
    bottom: calc(var(--transport-h) + 2 * var(--gap));
  }

  .transport {
    grid-template-columns: minmax(140px, 1fr) auto minmax(200px, 2.2fr) auto;
    grid-template-areas: "now controls seek right";
    height: var(--transport-h);
    padding: 0 16px;
    gap: 14px;
  }

  .rec-indicator {
    top: calc(var(--hud-h) + 2 * var(--gap));
  }

  .overlay,
  .modal {
    padding: 24px;
  }

  .gallery {
    padding: var(--gap);
  }

  .gallery-shell {
    width: min(1280px, 100%);
    height: min(100%, 900px);
    border-radius: var(--radius-lg);
  }

  .gallery-body {
    padding: 0 20px 24px;
  }

  .start-shell {
    padding: 24px 12px 32px;
  }
}

@media (min-width: 1100px) {
  .viz-tab {
    padding: 0 16px;
  }
}

/* Wide and 4K: larger type and chrome so the UI does not shrink into the corners. */
@media (min-width: 2200px) {
  :root {
    --hud-h: 72px;
    --transport-h: 86px;
    --panel-w: 500px;
    --drawer-w: 520px;
    --control-h: 46px;
    --control-h-sm: 36px;
    --gap: 18px;
    --thumb: 20px;
    --track-h: 5px;
  }

  body {
    font-size: 18px;
  }

  .btn,
  .pill,
  .viz-tab,
  .field-label,
  .menu-item,
  .track-title,
  .card-name {
    font-size: 16px;
  }

  .icon-btn {
    font-size: 19px;
  }

  .brand {
    font-size: 22px;
  }

  .preset-grid,
  .in-gallery .preset-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }

  .gallery-shell {
    width: min(1800px, 100%);
    height: min(100%, 1300px);
  }

  .start-shell {
    width: min(1300px, 100%);
  }

  .modal-card {
    width: min(620px, 100%);
  }

  .help-card {
    width: min(920px, 100%);
  }
}

/* ---- Reduced motion ------------------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .rec-dot {
    animation: none;
  }
}

/* ---- Fullscreen ---------------------------------------------------------------------------------- */
.stage-wrap:fullscreen {
  background: var(--bg);
}

.stage-wrap:-webkit-full-screen {
  background: var(--bg);
}
