:root {
  --ink: #fff8ff;
  --hot: #ff2bd6;
  --cyan: #00f5ff;
  --lime: #b8ff00;
  --orange: #ff6a00;
  --violet: #7a00ff;
  --bpm: 120;
  --energy: 0;
  font-family: Rubik, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  color: var(--ink);
  background: #050012;
  overflow: hidden;
}

body.is-dragging {
  outline: 3px dashed var(--cyan);
  outline-offset: -12px;
}

#disco {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
}

.haze {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 43, 214, 0.22), transparent 35%),
    radial-gradient(circle at 80% 20%, rgba(0, 245, 255, 0.18), transparent 40%),
    radial-gradient(circle at 50% 80%, rgba(184, 255, 0, 0.14), transparent 45%);
  mix-blend-mode: screen;
  animation: hazeShift calc(60s / var(--bpm, 120) * 4) ease-in-out infinite alternate;
  opacity: calc(0.55 + var(--energy, 0) * 0.45);
}

@keyframes hazeShift {
  from { filter: hue-rotate(0deg) saturate(1.15); }
  to { filter: hue-rotate(55deg) saturate(1.55); }
}

.brand {
  position: fixed;
  top: 0.85rem;
  left: 0.85rem;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--ink);
  opacity: 0.92;
  filter: drop-shadow(0 0 18px rgba(0, 245, 255, 0.35));
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.brand img {
  width: auto;
  height: clamp(42px, 7vh, 72px);
  object-fit: contain;
}

.brand span {
  font-family: Bungee, cursive;
  font-size: clamp(1.1rem, 2.4vw, 1.7rem);
  letter-spacing: 0.06em;
  background: linear-gradient(90deg, var(--hot), var(--cyan), var(--lime));
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: marquee calc(60s / var(--bpm, 120) * 2) linear infinite;
}

@keyframes marquee {
  to { background-position: 200% center; }
}

.drop-hint {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: rgba(5, 0, 18, 0.72);
  font-family: Bungee, cursive;
  font-size: clamp(1.2rem, 4vw, 2rem);
  color: var(--cyan);
  letter-spacing: 0.04em;
}

.drop-hint[hidden] { display: none; }

.ctx-menu {
  position: fixed;
  z-index: 30;
  min-width: 11rem;
  padding: 0.3rem;
  border-radius: 10px;
  background: rgba(10, 0, 24, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
}

.ctx-menu[hidden] { display: none; }

.ctx-menu button {
  appearance: none;
  width: 100%;
  border: 0;
  border-radius: 7px;
  padding: 0.55rem 0.75rem;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.ctx-menu button:hover,
.ctx-menu button:focus-visible {
  background: rgba(0, 245, 255, 0.18);
  outline: none;
}

body.is-fullscreen .brand,
body.is-fullscreen .dock {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.dock {
  position: fixed;
  right: max(0.75rem, env(safe-area-inset-right));
  bottom: max(0.75rem, env(safe-area-inset-bottom));
  z-index: 5;
  width: min(340px, calc(100vw - 1.5rem));
  padding: 0.7rem;
  border-radius: 16px;
  background: rgba(8, 0, 22, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  display: grid;
  gap: 0.55rem;
  transition:
    width 0.9s cubic-bezier(0.4, 0, 0.2, 1),
    padding 0.9s cubic-bezier(0.4, 0, 0.2, 1),
    gap 0.9s cubic-bezier(0.4, 0, 0.2, 1),
    background 0.9s ease,
    border-color 0.9s ease,
    box-shadow 0.9s ease,
    opacity 0.45s ease,
    visibility 0.45s ease;
}

.dock-panel {
  display: grid;
  gap: 0.55rem;
  overflow: hidden;
  max-height: 28rem;
  opacity: 1;
  transition:
    max-height 0.9s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.7s ease,
    margin 0.9s ease;
}

.dock.is-minimized {
  width: min(168px, 34vw);
  padding: 0.3rem;
  gap: 0;
  background: rgba(8, 0, 22, 0.45);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.dock.is-minimized .dock-panel {
  max-height: 0;
  opacity: 0;
  margin: 0;
  pointer-events: none;
}

.dock.is-minimized .stage {
  border-radius: 10px;
  box-shadow: 0 0 16px rgba(255, 43, 214, 0.22);
  cursor: pointer;
}

.dock.is-minimized .stage.is-empty {
  min-height: 72px;
}

.stage {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
  background:
    linear-gradient(#050012, #050012) padding-box,
    linear-gradient(120deg, var(--hot), var(--cyan), var(--lime), var(--violet)) border-box;
  box-shadow: 0 0 24px rgba(255, 43, 214, 0.28);
  animation: stagePulse calc(60s / var(--bpm, 120)) ease-in-out infinite;
}

.stage.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 96px;
  aspect-ratio: auto;
}

.stage.is-empty #yt-mount,
.stage.is-empty #media { display: none; }
.stage:not(.is-empty) .empty-msg { display: none; }
.stage.mode-youtube #media { display: none; }
.stage.mode-media #yt-mount { display: none; }
.stage.mode-audio { aspect-ratio: 2.4 / 1; }

.empty-msg {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  opacity: 0.7;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#yt-mount,
#yt-mount iframe,
#media {
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
  object-fit: contain;
}

@keyframes stagePulse {
  0%, 100% { transform: scale(1); filter: saturate(1); }
  50% { transform: scale(1.015); filter: saturate(1.25) brightness(1.05); }
}

.load {
  display: grid;
  gap: 0.4rem;
}

.load input[type="url"] {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid rgba(0, 245, 255, 0.55);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: var(--ink);
  font: inherit;
  font-size: 0.85rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.load button,
.ghost,
.file-btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  color: #120018;
  background: linear-gradient(120deg, var(--lime), var(--cyan), var(--hot));
  background-size: 200% auto;
  animation: marquee 3s linear infinite;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ghost,
.file-btn.ghost {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.3);
  animation: none;
}

.tools {
  display: grid;
  gap: 0.35rem;
}

.bpm-wrap {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.4rem;
  align-items: center;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.68rem;
  opacity: 0.92;
}

.bpm-wrap select,
.bpm-wrap input[type="range"] {
  width: 100%;
}

.bpm-wrap select {
  grid-column: 2 / -1;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.45);
  color: var(--ink);
  font: inherit;
  font-size: 0.75rem;
  padding: 0.25rem 0.4rem;
}

.support {
  margin: 0;
  font-size: 0.62rem;
  line-height: 1.35;
  opacity: 0.72;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

body.is-beat .haze {
  filter: brightness(1.35) contrast(1.15);
}

@media (max-width: 520px) {
  .brand span { display: none; }
  .dock { width: calc(100vw - 1.2rem); }
  .dock.is-minimized { width: min(148px, 42vw); }
}

@media (prefers-reduced-motion: reduce) {
  .haze,
  .brand span,
  .stage,
  .load button,
  .dock,
  .dock-panel {
    animation: none !important;
    transition: none !important;
  }
}
