:root {
  --bg-0: #0a0a12;
  --bg-1: #11111f;
  --card: rgba(255, 255, 255, 0.04);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-hover: rgba(255, 255, 255, 0.07);
  --text: #eef0f7;
  --muted: #9aa0b4;
  --faint: #6b7088;
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --accent-grad: linear-gradient(135deg, #8b5cf6 0%, #22d3ee 100%);
  --on: #34d399;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  font-synthesis: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body {
  background:
    radial-gradient(1200px 700px at 15% -10%, rgba(139, 92, 246, 0.18), transparent 55%),
    radial-gradient(1000px 600px at 100% 0%, rgba(34, 211, 238, 0.12), transparent 50%),
    var(--bg-0);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

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

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 16px; }
.logo {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center;
  gap: 3px;
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.45);
  flex-shrink: 0;
}
.logo-bar {
  width: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.95);
  animation: eq 1.1s ease-in-out infinite;
}
.logo-bar:nth-child(1) { height: 14px; animation-delay: 0s; }
.logo-bar:nth-child(2) { height: 26px; animation-delay: .15s; }
.logo-bar:nth-child(3) { height: 18px; animation-delay: .3s; }
.logo-bar:nth-child(4) { height: 24px; animation-delay: .45s; }
@keyframes eq { 0%, 100% { transform: scaleY(.5); } 50% { transform: scaleY(1); } }
body.paused .logo-bar { animation-play-state: paused; }

h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.tagline { color: var(--muted); font-size: 13.5px; margin-top: 3px; max-width: 460px; }

.badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px;
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.25);
  color: var(--on); font-size: 13px; font-weight: 600;
  white-space: nowrap;
}
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--on); box-shadow: 0 0 10px var(--on); }

/* ===== Transport ===== */
.transport {
  display: flex; align-items: center; gap: 22px;
  padding: 18px 22px; margin-bottom: 16px;
}
.play-btn {
  width: 64px; height: 64px; flex-shrink: 0;
  border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent-grad); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 8px 30px rgba(139, 92, 246, 0.5);
  transition: transform .15s ease, box-shadow .15s ease;
}
.play-btn:hover { transform: scale(1.06); }
.play-btn:active { transform: scale(0.97); }
.play-btn svg { fill: #fff; }
.play-btn .icon-pause { display: none; }
body.playing .play-btn .icon-play { display: none; }
body.playing .play-btn .icon-pause { display: block; }

.transport-info { flex: 1; min-width: 0; }
.now-playing { display: flex; align-items: baseline; gap: 10px; }
.np-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--faint); font-weight: 700;
}
.np-name {
  font-size: 16px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.timer { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; margin-top: 4px; }

.master-vol { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.master-vol svg { fill: var(--muted); flex-shrink: 0; }
.vol-val { font-size: 12px; color: var(--faint); width: 22px; text-align: right; font-variant-numeric: tabular-nums; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  height: 6px; border-radius: 6px; cursor: pointer; width: 100%;
  background: rgba(255, 255, 255, 0.12);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent); cursor: pointer;
}

/* ===== Visualizer ===== */
.viz-wrap { position: relative; height: 160px; margin-bottom: 28px; overflow: hidden; padding: 0; }
#viz { width: 100%; height: 100%; display: block; }
.viz-hint {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--faint); font-size: 14px; pointer-events: none;
  transition: opacity .4s ease;
}
body.playing .viz-hint { opacity: 0; }

/* ===== Blocks ===== */
.block { margin-bottom: 28px; }
.block-head { margin-bottom: 14px; }
.block-head h2 { font-size: 17px; font-weight: 700; }
.block-head p { color: var(--muted); font-size: 13px; margin-top: 3px; }

/* ===== Presets ===== */
.presets { display: flex; flex-wrap: wrap; gap: 10px; }
.preset {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 16px; border-radius: 12px; cursor: pointer;
  background: var(--card); border: 1px solid var(--card-border);
  color: var(--text); font-size: 14px; font-weight: 500;
  transition: all .15s ease;
}
.preset:hover { background: var(--card-hover); transform: translateY(-1px); }
.preset .emoji { font-size: 17px; }
.preset.active {
  border-color: var(--accent);
  background: rgba(139, 92, 246, 0.15);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

/* ===== Layers ===== */
.layer-group { margin-bottom: 22px; }
.layer-group-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--faint); font-weight: 700; margin-bottom: 10px;
}
.layers-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.layer {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 14px; padding: 14px; cursor: pointer;
  transition: all .15s ease; position: relative; overflow: hidden;
}
.layer:hover { background: var(--card-hover); }
.layer.on { border-color: rgba(139, 92, 246, 0.6); background: rgba(139, 92, 246, 0.1); }
.layer.on::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent-grad);
}
.layer-top { display: flex; align-items: center; gap: 11px; margin-bottom: 12px; }
.layer-emoji {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 19px;
  background: rgba(255, 255, 255, 0.05);
}
.layer.on .layer-emoji { background: rgba(139, 92, 246, 0.2); }
.layer-name { font-size: 14.5px; font-weight: 600; }
.layer-desc { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.layer-switch {
  margin-left: auto; width: 38px; height: 22px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.12); position: relative; flex-shrink: 0;
  transition: background .2s ease;
}
.layer-switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: transform .2s ease;
}
.layer.on .layer-switch { background: var(--on); }
.layer.on .layer-switch::after { transform: translateX(16px); }
.layer-vol { display: flex; align-items: center; gap: 9px; }
.layer-vol svg { fill: var(--faint); flex-shrink: 0; }
.layer-vol input { opacity: .55; transition: opacity .15s ease; }
.layer.on .layer-vol input { opacity: 1; }
.layer-note {
  font-size: 10.5px; color: var(--accent-2); margin-top: 9px;
  display: flex; align-items: center; gap: 5px;
}

/* ===== Export ===== */
.export { padding: 24px; margin-bottom: 22px; }
.export-head h2 { font-size: 17px; font-weight: 700; }
.export-head p { color: var(--muted); font-size: 13px; margin-top: 4px; max-width: 620px; }
.export-controls {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; margin-top: 18px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 600; }
.field select, .field input {
  background: rgba(0, 0, 0, 0.25); border: 1px solid var(--card-border);
  color: var(--text); padding: 10px 12px; border-radius: 10px;
  font-size: 14px; font-family: inherit; min-width: 130px;
}
.field input[type="number"] { min-width: 90px; }
.field select:focus, .field input:focus { outline: none; border-color: var(--accent); }
.export-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent-grad); color: #fff; border: none; cursor: pointer;
  padding: 11px 22px; border-radius: 10px; font-size: 14px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.4);
  transition: transform .15s ease, opacity .15s ease;
}
.export-btn svg { fill: #fff; }
.export-btn:hover { transform: translateY(-1px); }
.export-btn:disabled { opacity: .55; cursor: progress; transform: none; }
.export-status { margin-top: 14px; font-size: 13px; color: var(--muted); min-height: 18px; }
.export-status.ok { color: var(--on); }
.export-status.err { color: #f87171; }

/* ===== Footer ===== */
.footer { text-align: center; color: var(--faint); font-size: 12.5px; margin-top: 12px; }
.footer kbd {
  background: rgba(255, 255, 255, 0.08); border: 1px solid var(--card-border);
  border-radius: 5px; padding: 1px 6px; font-size: 11px; font-family: inherit;
}

@media (max-width: 600px) {
  .transport { flex-wrap: wrap; }
  .master-vol { width: 100%; }
  .layers-grid { grid-template-columns: 1fr; }
}
