@property --accent {
  syntax: "<color>";
  inherits: true;
  initial-value: hsl(240 6% 62%);
}

:root {
  --bg: #E7E7EC;
  --stage: #F4F4F7;
  --text: #16161B;
  --text-2: #6B6B76;
  --line: rgba(17, 17, 22, .12);
  --accent-ink: color-mix(in oklab, var(--accent) 78%, #000);
  --font: "Inter", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* liquid glass da casa */
  --lg-fill: radial-gradient(ellipse 65% 95% at 50% 50%, rgba(255,255,255,.62) 0%, rgba(255,255,255,.18) 60%, rgba(255,255,255,0) 100%);
  --lg-fill-hover: radial-gradient(ellipse 70% 100% at 50% 50%, rgba(255,255,255,.85) 0%, rgba(255,255,255,.28) 60%, rgba(255,255,255,.04) 100%);
  --lg-shadow: -1px 0 0 rgba(17,17,22,.32), 1px 0 0 rgba(17,17,22,.32), 0 0 0 .5px rgba(17,17,22,.16), inset 0 1px 0 rgba(255,255,255,.75);
  --lg-shadow-hover: -1px 0 0 rgba(17,17,22,.42), 1px 0 0 rgba(17,17,22,.42), 0 0 0 .5px rgba(17,17,22,.2), inset 0 1px 0 #fff;

  /* placas grandes: mesma linguagem, branco mais denso */
  --card-fill: radial-gradient(ellipse 85% 85% at 50% 42%, rgba(255,255,255,.66) 0%, rgba(255,255,255,.34) 62%, rgba(255,255,255,.18) 100%);
  --card-shadow: -1px 0 0 rgba(17,17,22,.2), 1px 0 0 rgba(17,17,22,.2), 0 0 0 .5px rgba(17,17,22,.14), inset 0 1px 0 rgba(255,255,255,.95), 0 30px 60px -24px rgba(17,17,22,.28);

  transition: --accent 1.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(60% 50% at 100% 0%, color-mix(in oklab, var(--accent) 14%, transparent), transparent 70%),
    var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
img { display: block; }
::selection { background: color-mix(in oklab, var(--accent) 35%, transparent); }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 3px; }

/* ---------- Liquid glass ---------- */
.liquid-glass {
  background: var(--lg-fill);
  border: 1px solid rgba(255,255,255,.85);
  backdrop-filter: blur(4px) saturate(1.3);
  -webkit-backdrop-filter: blur(4px) saturate(1.3);
  box-shadow: var(--lg-shadow);
  transition: background .25s var(--ease), box-shadow .25s var(--ease), transform .2s var(--ease);
}
.liquid-glass:hover { background: var(--lg-fill-hover); box-shadow: var(--lg-shadow-hover); }
.liquid-glass:active { transform: scale(.96); }
.liquid-glass--round {
  position: relative; border-radius: 50%;
  box-shadow: 0 0 0 .5px rgba(17,17,22,.16), inset 0 1px 0 rgba(255,255,255,.75);
}
.liquid-glass--round:hover { box-shadow: 0 0 0 .5px rgba(17,17,22,.2), inset 0 1px 0 #fff; }
.liquid-glass--round::after {
  content: ""; position: absolute; inset: -1.5px; padding: 1px; border-radius: 50%;
  background: linear-gradient(90deg, rgba(17,17,22,.38) 0%, transparent 22%, transparent 78%, rgba(17,17,22,.38) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  pointer-events: none;
}
.glass-card {
  background: var(--card-fill);
  border: 1px solid rgba(255,255,255,.9);
  backdrop-filter: blur(8px) saturate(1.4);
  -webkit-backdrop-filter: blur(8px) saturate(1.4);
  box-shadow: var(--card-shadow);
}

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 16px;
  padding: 20px;
  height: 100vh;
  height: 100dvh;
}

/* ---------- Palco ---------- */
.stage {
  position: relative;
  border-radius: 28px;
  overflow: hidden;
  isolation: isolate;
  background: var(--stage);
  box-shadow: 0 0 0 .5px rgba(17,17,22,.1), inset 0 1px 0 rgba(255,255,255,.9);
  display: grid;
  place-items: center;
}
.stage::before { /* gradiente da cor da música: borda esquerda até o meio */
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(90deg,
    color-mix(in oklab, var(--accent) 70%, transparent) 0%,
    color-mix(in oklab, var(--accent) 25%, transparent) 30%,
    transparent 55%);
}
.net-pill {
  position: absolute; top: 16px; left: 16px; z-index: 3;
  display: flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 16px;
  font-size: .8rem; font-weight: 500;
}
.net-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #d4542f; }
.net-pill[hidden] { display: none; }
.center {
  display: flex; flex-direction: column; align-items: center;
  gap: clamp(18px, 3.5vh, 32px);
  width: 100%;
  padding: 24px;
}

/* ---------- Player ---------- */
.device {
  --size: min(340px, 60vmin);
  position: relative;
  width: var(--size);
  aspect-ratio: 1;
}
.aura {
  position: absolute; inset: -14%; z-index: 0;
  border-radius: 40%;
  overflow: hidden;
  filter: blur(48px) saturate(1.5);
  opacity: 0;
  transition: opacity .8s var(--ease);
  pointer-events: none;
}
.aura img { width: 100%; height: 100%; object-fit: cover; }
.device.has-track .aura { opacity: .55; }

.body {
  position: absolute; inset: 0; z-index: 2;
  border-radius: 34px;
  overflow: hidden;
}
.body::after { /* reflexo diagonal */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(125deg, rgba(255,255,255,.32) 0%, transparent 32%);
}

.well {
  position: absolute; inset: 18%;
  border-radius: 24px;
  overflow: hidden;
  background: rgba(17,17,22,.06);
  box-shadow: inset 0 2px 8px rgba(17,17,22,.22), inset 0 0 0 .5px rgba(17,17,22,.18), 0 1px 0 rgba(255,255,255,.9);
  display: grid; place-items: center;
}
.well img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.well-empty { display: none; }
.well.empty { background: rgba(255,255,255,.25); box-shadow: inset 0 1px 4px rgba(17,17,22,.08); }
.well.empty::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  border: 1.5px dashed rgba(17,17,22,.28);
}
.well.empty img, .well.empty .play { display: none; }
.well.empty .well-empty {
  display: block; position: relative;
  padding: 0 14%;
  font-size: .82rem; line-height: 1.35; text-align: center; color: var(--text-2);
}

.play {
  position: relative; z-index: 1;
  width: 32%; aspect-ratio: 1;
  display: grid; place-items: center;
  color: var(--text);
}
.play svg { width: 42%; fill: currentColor; grid-area: 1 / 1; }
.play .i-pause { display: none; }
.is-playing .play .i-play { display: none; }
.is-playing .play .i-pause { display: block; }

/* Aba (lingueta) */
.tab {
  position: absolute; z-index: 1;
  left: 100%; top: 31%; height: 38%;
  width: 34px; margin-left: -8px; padding-left: 8px;
  border-radius: 0 14px 14px 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: .82rem; font-weight: 600; font-variant-numeric: tabular-nums;
  transition: transform .25s var(--ease);
}
.tab:hover { transform: translateX(2px); }
.tab svg { width: 14px; transition: transform .45s var(--ease); }
.device.open .tab svg { transform: rotate(180deg); }

/* Gaveta: atrás do corpo, abre para a esquerda */
.drawer {
  position: absolute; z-index: 1;
  top: 18%; left: 0; width: 72%; height: 64%;
  border-radius: 22px;
  padding: 12px calc(14.4% + 10px) 12px 12px; /* % do .device: parte coberta pelo corpo */
  display: flex; flex-direction: column; gap: 8px;
  opacity: 0;
  transform: translateX(0);
  transition: transform .45s cubic-bezier(.3, 1.3, .5, 1), opacity .25s ease;
}
.device.open .drawer { transform: translateX(-80%); opacity: 1; }
.drawer-title { font-size: .78rem; font-weight: 600; color: var(--text-2); padding-left: 2px; }
.queue {
  list-style: none; padding: 0;
  flex: 1; min-height: 0;
  overflow-y: auto; scrollbar-width: none;
  display: flex; flex-direction: column; gap: 6px;
}
.queue::-webkit-scrollbar { display: none; }
.queue:empty { display: none; }
.queue li {
  display: flex; align-items: center; gap: 8px;
  padding: 3px; border-radius: 12px;
  cursor: pointer;
  transition: background .2s;
}
.queue li:hover { background: rgba(255,255,255,.5); }
.q-thumb {
  width: 34px; height: 34px; flex: none;
  border-radius: 9px; object-fit: cover;
  box-shadow: 0 0 0 .5px rgba(17,17,22,.2);
}
.queue li span {
  flex: 1; min-width: 0;
  font-size: .76rem; font-weight: 500; line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.q-remove {
  width: 20px; height: 20px; flex: none; border-radius: 50%;
  font-size: .9rem; line-height: 1; color: var(--text-2);
  opacity: 0; transition: opacity .2s;
}
.queue li:hover .q-remove, .q-remove:focus-visible { opacity: 1; }
.queue li.ghost { cursor: default; }
.queue li.ghost .q-thumb { box-shadow: none; border: 1.5px dashed rgba(17,17,22,.3); background: rgba(255,255,255,.3); }
.queue-empty { font-size: .76rem; color: var(--text-2); padding-left: 2px; }
.queue-empty[hidden] { display: none; }

/* ---------- Título / progresso ---------- */
.meta { text-align: center; width: min(420px, 100%); }
.title {
  font-size: clamp(1.05rem, 2.2vw, 1.3rem); font-weight: 600; letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.artist {
  margin-top: 4px; font-size: .9rem; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.transport { width: min(380px, 100%); }
.progress {
  --p: 0;
  position: relative;
  height: 18px;
  cursor: pointer;
  touch-action: none;
}
.progress::before { /* trilho */
  content: ""; position: absolute; left: 0; right: 0; top: 7px; height: 4px;
  border-radius: 4px; background: var(--line);
}
.progress-fill {
  position: absolute; left: 0; right: 0; top: 7px; height: 4px;
  border-radius: 4px; background: var(--accent-ink);
  transform: scaleX(var(--p)); transform-origin: left;
  transition: transform .25s linear;
}
.progress-knob-track {
  position: absolute; inset: 0;
  transform: translateX(calc(var(--p) * 100%));
  transition: transform .25s linear;
  pointer-events: none;
}
.progress-knob {
  position: absolute; left: -7px; top: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #fff, rgba(255,255,255,.75));
  box-shadow: -1px 0 0 rgba(17,17,22,.3), 1px 0 0 rgba(17,17,22,.3), 0 0 0 .5px rgba(17,17,22,.2), 0 2px 6px rgba(17,17,22,.2);
  transform: scale(.7);
  transition: transform .2s var(--ease);
}
.progress:hover .progress-knob, .progress.dragging .progress-knob, .progress:focus-visible .progress-knob { transform: scale(1); }
.progress.dragging .progress-fill, .progress.dragging .progress-knob-track { transition: none; }

.controls {
  margin-top: 8px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
}
.time { font-size: .78rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.time:last-child { text-align: right; }
.buttons { display: flex; gap: 14px; }
.ctrl { width: 46px; height: 46px; display: grid; place-items: center; }
.ctrl svg { width: 18px; fill: currentColor; }

.repeat { color: var(--text-2); }
.repeat[aria-pressed="true"] { color: var(--accent-ink); }
.repeat .one {
  display: none; place-items: center;
  position: absolute; top: 5px; right: 5px;
  min-width: 14px; height: 14px; border-radius: 7px;
  font-size: .6rem; font-weight: 700; line-height: 1;
  color: #fff; background: var(--accent-ink);
}
.repeat[data-mode="one"] .one { display: grid; }

.volume-row {
  margin-top: 14px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.mute { width: 34px; height: 34px; flex: none; display: grid; place-items: center; color: var(--text-2); }
.mute svg { width: 18px; }
.mute .spk { fill: currentColor; }
.mute .x { display: none; }
.mute[data-level="low"] .w2 { display: none; }
.mute[data-level="mute"] .w1, .mute[data-level="mute"] .w2 { display: none; }
.mute[data-level="mute"] .x { display: block; }
.volume { width: 132px; }
.volume .progress-fill { background: var(--text-2); }

/* ---------- Biblioteca ---------- */
.library {
  border-radius: 28px;
  padding: 16px 0 14px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  min-height: 0;
}
.add { width: 46px; height: 46px; flex: none; display: grid; place-items: center; }
.add svg { width: 20px; }
.lib-empty { padding: 0 14px; font-size: .78rem; line-height: 1.35; text-align: center; color: var(--text-2); }
.lib-empty[hidden] { display: none; }
.lib-list {
  list-style: none;
  width: 100%;
  flex: 1; min-height: 0;
  padding: 6px 16px;
  overflow-y: auto; scrollbar-width: none;
  display: flex; flex-direction: column; gap: 14px;
}
.lib-list::-webkit-scrollbar { display: none; }
.cover-item { position: relative; flex: none; }
.cover {
  display: block; width: 100%; aspect-ratio: 1;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 0 0 .5px rgba(17,17,22,.18), 0 8px 18px -10px rgba(17,17,22,.5);
  transition: transform .25s var(--ease), box-shadow .3s var(--ease);
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover:hover { transform: translateY(-2px); }
.cover-item.current .cover {
  box-shadow: 0 0 0 2.5px #fff, 0 0 0 5px var(--accent), 0 10px 22px -10px var(--accent);
}
.badge {
  position: absolute; left: -5px; top: -5px;
  min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: .7rem; font-weight: 700; font-variant-numeric: tabular-nums;
  color: #fff; background: var(--accent-ink);
  box-shadow: 0 0 0 2px #fff;
  pointer-events: none;
}
.remove {
  position: absolute; right: -6px; top: -6px;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  font-size: .95rem; line-height: 1;
  opacity: 0; transform: scale(.8);
  transition: opacity .2s, transform .2s var(--ease);
}
.cover-item:hover .remove, .remove:focus-visible { opacity: 1; transform: scale(1); }

/* equalizer simulado na capa tocando */
.eq {
  position: absolute; left: 7px; bottom: 7px;
  display: none; gap: 2px; align-items: flex-end;
  height: 14px; padding: 3px 4px; border-radius: 6px;
  background: rgba(255,255,255,.8);
  pointer-events: none;
}
.cover-item.current .eq { display: flex; }
.eq i { width: 2.5px; height: 100%; border-radius: 1px; background: var(--accent-ink); transform-origin: bottom; transform: scaleY(.35); }
.is-playing .eq i { animation: eq .9s ease-in-out infinite alternate; }
.eq i:nth-child(2) { animation-delay: -.3s !important; }
.eq i:nth-child(3) { animation-delay: -.6s !important; }
@keyframes eq { from { transform: scaleY(.25); } to { transform: scaleY(1); } }

.lib-tools { display: flex; gap: 8px; flex: none; }
.tool { width: 34px; height: 34px; display: grid; place-items: center; color: var(--text-2); }
.tool svg { width: 16px; }

/* ---------- Modal ---------- */
.modal {
  margin: auto;
  width: min(480px, calc(100vw - 32px));
  padding: 24px;
  border-radius: 26px;
  color: var(--text);
  background: radial-gradient(ellipse 90% 90% at 50% 40%, rgba(255,255,255,.92), rgba(255,255,255,.72));
}
.modal::backdrop { background: rgba(22,22,28,.22); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.modal[open] { animation: pop .35s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.modal h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 18px; }
.modal label { display: block; margin-bottom: 14px; }
.modal label span { display: block; font-size: .8rem; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.field {
  width: 100%; height: 44px; padding: 0 14px;
  border-radius: 14px;
  font: inherit; font-size: .92rem; color: var(--text);
  outline: none;
}
.field:focus { background: var(--lg-fill-hover); box-shadow: -1px 0 0 rgba(17,17,22,.5), 1px 0 0 rgba(17,17,22,.5), 0 0 0 .5px rgba(17,17,22,.32), inset 0 1px 0 #fff; }
.field::placeholder { color: #9b9ba5; }
.search-status { font-size: .8rem; color: var(--text-2); margin: -4px 0 10px; }
.search-status:empty { display: none; }
.results {
  list-style: none; padding: 0; margin: 0 -8px 12px;
  max-height: min(340px, 50vh);
  overflow-y: auto; scrollbar-width: thin;
  display: none; flex-direction: column; gap: 2px;
}
.results:empty { display: none !important; }
.modal[data-mode="search"] .results { display: flex; }
.modal[data-mode="search"] #nameField, .modal[data-mode="search"] #saveBtn { display: none; }
.results li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 14px; transition: background .2s; }
.results li:hover { background: rgba(255,255,255,.65); }
.results img { width: 64px; height: 36px; flex: none; border-radius: 8px; object-fit: cover; box-shadow: 0 0 0 .5px rgba(17,17,22,.18); }
.r-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.r-title {
  font-size: .84rem; font-weight: 500; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.r-sub { font-size: .74rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-btn { width: 32px; height: 32px; flex: none; display: grid; place-items: center; }
.r-btn svg { width: 14px; }
.r-btn[data-act="play"] svg { fill: currentColor; }
.r-btn:disabled { opacity: .45; cursor: default; }
.form-err { min-height: 1.2em; font-size: .8rem; color: #c23a3a; margin: -4px 0 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.btn, .btn-ghost { height: 42px; padding: 0 18px; border-radius: 21px; font-weight: 600; font-size: .9rem; }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { color: var(--text); }
.btn:disabled { opacity: .6; cursor: progress; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 200;
  max-width: calc(100vw - 32px);
  padding: 11px 18px; border-radius: 22px;
  font-size: .86rem; font-weight: 500;
  background: radial-gradient(ellipse 70% 100% at 50% 50%, rgba(255,255,255,.95), rgba(255,255,255,.75));
  opacity: 0; transform: translate(-50%, 12px);
  transition: opacity .3s var(--ease), transform .3s var(--ease);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Vídeo (canto inferior direito do palco) ---------- */
.video-dock {
  position: absolute; right: 16px; bottom: 16px; z-index: 3;
  transition: transform .5s var(--ease), opacity .3s ease;
}
.video-dock:not(.has-track) { opacity: 0; pointer-events: none; }
.video-dock.collapsed { transform: translateX(calc(100% + 16px)); } /* sai pela borda do palco */
.video-dock.collapsed .dock-frame { box-shadow: none; } /* senão a sombra lateral aparece na borda */
.dock-frame {
  width: 356px; aspect-ratio: 16 / 9; /* 200px de altura: mínimo pedido pelo YouTube */
  box-sizing: content-box;
  padding: 6px;
  border-radius: 20px;
}
.dock-frame iframe { display: block; width: 100%; height: 100%; border: 0; border-radius: 14px; }
.dock-tab {
  position: absolute; right: 100%; top: 50%;
  width: 28px; height: 64px; margin-top: -32px; margin-right: -2px;
  border-radius: 14px 0 0 14px; border-right: 0;
  display: grid; place-items: center;
  color: var(--text-2);
  transition: color .2s;
}
.dock-tab:hover { color: var(--text); }
.dock-tab svg { width: 14px; transition: transform .5s var(--ease); }
.video-dock.collapsed .dock-tab svg { transform: rotate(180deg); }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 12px; padding: 12px; }
  .stage { border-radius: 24px; place-items: end center; }
  .stage::before {
    background: linear-gradient(180deg,
      color-mix(in oklab, var(--accent) 60%, transparent) 0%,
      color-mix(in oklab, var(--accent) 22%, transparent) 30%,
      transparent 55%);
  }
  .center { padding-bottom: 20px; }
  .device { --size: min(260px, 66vw); }

  /* no celular a gaveta sobe, porque não há espaço à esquerda */
  .drawer {
    top: 0; left: 14%; width: 72%; height: 72%;
    padding: 12px 12px calc(14.4% + 10px);
  }
  .device.open .drawer { transform: translateY(-80%); }
  .device.open .tab svg { transform: rotate(-90deg); }
  .tab svg { transform: rotate(90deg); }

  .library { flex-direction: row; padding: 10px 12px; border-radius: 22px; gap: 10px; }
  .lib-list { flex-direction: row; padding: 6px 4px; overflow-x: auto; overflow-y: hidden; gap: 12px; }
  .cover-item { width: 64px; }
  .cover { border-radius: 14px; }
  .lib-empty { padding: 0; text-align: left; flex: 1; }
  .lib-tools { flex-direction: column; gap: 6px; }
  .tool { width: 30px; height: 30px; }
  .remove { opacity: 1; transform: scale(.85); }
}

@media (prefers-reduced-motion: reduce) {
  :root { transition: none; }
  .drawer { transition: opacity .15s; }
  .video-dock, .dock-tab svg { transition: none; }
  .tab svg, .cover, .liquid-glass, .progress-fill, .progress-knob-track, .aura { transition: none; }
  .is-playing .eq i { animation: none; transform: scaleY(.7); }
  .modal[open] { animation: none; }
  .toast { transition: opacity .2s; }
}
