:root {
  color-scheme: dark;
  --bg: radial-gradient(circle at top, #020617 0, #020617 40%, #000 100%);
  --card-glass: rgba(15, 23, 42, 0.9);
  --border: rgba(148, 163, 184, 0.25);
  --accent: #22c55e;
  --accent-soft: rgba(34, 197, 94, 0.22);
  --accent-blue: #38bdf8;
  --danger: #ef4444;
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --player-height: 440px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.4rem clamp(1.2rem, 2.6vw, 2.2rem) 3rem;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.6rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

h1 {
  margin: 0 0 0.4rem;
  font-size: clamp(2rem, 2.8vw, 2.3rem);
  letter-spacing: 0.05em;
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 0.9rem;
  line-height: 1.7;
}

.badge {
  border-radius: 999px;
  padding: 0.3rem 1.1rem;
  font-size: 0.85rem;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.95);
  color: var(--text-muted);
  white-space: nowrap;
}

/* Botão tipo “logo” home */

.home-btn {
  position: fixed;
  top: 1.6rem;
  left: 1.2rem;
  z-index: 1000;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: radial-gradient(circle at top, #1f2937, #020617);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.7);
  transition: transform 0.08s ease-out, box-shadow 0.08s ease-out,
    border-color 0.12s ease-out, filter 0.12s ease-out;
}

.home-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.8);
  filter: brightness(1.05);
}

.home-btn:active {
  transform: translateY(0);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6);
}

.home-icon {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 2px solid #f9fafb;
  position: relative;
}

.home-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 2px;
  transform: translateX(-50%);
  width: 12px;
  height: 8px;
  border-radius: 3px;
  background: #f9fafb;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "controls"
    "player"
    "playlist"
    "history";
  gap: 1.6rem;
  margin-top: 1.6rem;
}

@media (min-width: 960px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr);
    grid-template-areas:
      "controls player playlist"
      "history  history history";
    column-gap: 1.6rem;
    align-items: stretch;
  }

  .controls-card,
  .player-shell,
  .playlist-panel {
    height: 100%;
  }
}

.controls-card {
  grid-area: controls;
}

.player-shell {
  grid-area: player;
}

.playlist-panel {
  grid-area: playlist;
}

.history {
  grid-area: history;
}

.card {
  border-radius: 1.1rem;
  padding: 1.4rem 1.5rem 1.5rem;
  border: 1px solid var(--border);
  box-shadow: 0 32px 80px rgba(15, 23, 42, 0.96);
}

.card-glass {
  background: linear-gradient(
    145deg,
    rgba(15, 23, 42, 0.97),
    rgba(30, 64, 175, 0.8)
  );
  backdrop-filter: blur(22px) saturate(160%);
}

.controls-card {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: center;
}

.grow {
  flex: 1 1 280px;
}

label {
  display: block;
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 0.32rem;
}

input[type="text"] {
  width: 100%;
  border-radius: 0.8rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  background: rgba(2, 6, 23, 0.98);
  color: var(--text);
  font-size: 1rem;
  outline: none;
}

input[type="text"]::placeholder {
  color: rgba(148, 163, 184, 0.8);
}

input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}

.chip-group {
  display: inline-flex;
  padding: 0.22rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.97);
  border: 1px solid rgba(37, 99, 235, 0.85);
}

.chip {
  border-radius: 999px;
  border: none;
  padding: 0.35rem 1rem;
  font-size: 0.9rem;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s ease-out, color 0.12s ease-out,
    transform 0.06s ease-out;
}

.chip:hover {
  transform: translateY(-1px);
  color: #e5e7eb;
}

.chip.active {
  background: radial-gradient(circle at top, #38bdf8, #1d4ed8);
  color: #e0f2fe;
}

.btn {
  border-radius: 0.9rem;
  border: none;
  cursor: pointer;
  font-size: 0.96rem;
  padding: 0.6rem 1.3rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: transform 0.08s ease-out, box-shadow 0.08s ease-out,
    background 0.15s ease-out, border-color 0.12s ease-out;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, #22c55e, #4ade80);
  color: #052e16;
  box-shadow: 0 14px 36px rgba(34, 197, 94, 0.55);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 44px rgba(34, 197, 94, 0.65);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 12px 32px rgba(34, 197, 94, 0.5);
}

.btn-ghost {
  background: rgba(15, 23, 42, 0.97);
  border: 1px solid rgba(51, 65, 85, 0.98);
  color: var(--text-muted);
}

.btn-ghost:hover {
  border-color: rgba(148, 163, 184, 0.98);
  color: #e5e7eb;
}

.btn-ghost.danger {
  border-color: rgba(248, 113, 113, 0.95);
  color: #fecaca;
}

.btn-ghost.danger:hover {
  background: rgba(127, 29, 29, 0.78);
  color: #fee2e2;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.switch input {
  accent-color: var(--accent);
}

/* Playback em cima, botões em baixo */

.controls {
  margin-top: 0.6rem;
  display: grid;
  grid-template-columns: auto auto auto;
  column-gap: 0.6rem;
  row-gap: 0.4rem;
  align-items: center;
}

.controls-label {
  grid-column: 1 / -1;
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #ffffff;
  white-space: nowrap;
}

.controls .btn {
  white-space: nowrap;
}

@media (max-width: 480px) {
  .controls {
    grid-template-columns: auto auto;
  }

  #prevBtn,
  #nextBtn {
    justify-content: center;
  }
}

/* PLAYER */

.player-shell {
  border-radius: 1.2rem;
  border: 1px solid rgba(15, 23, 42, 0.98);
  background: radial-gradient(
    circle at top,
    rgba(34, 197, 94, 0.24),
    rgba(15, 23, 42, 0.98)
  );
  padding: 0.6rem;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.player-frame {
  position: relative;
  border-radius: 1rem;
  overflow: hidden;
  background: #000;
  box-shadow: 0 32px 90px rgba(15, 23, 42, 1);
  flex: 1;
  min-height: var(--player-height);
  width: 100%;
}

#player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* HISTORY */

.history {
  border-radius: 1rem;
  background: rgba(15, 23, 42, 0.97);
  border: 1px solid rgba(55, 65, 81, 0.96);
  overflow: hidden;
}

.history-header {
  width: 100%;
  padding: 0.8rem 1rem;
  border: none;
  background: linear-gradient(
    125deg,
    rgba(15, 23, 42, 0.98),
    rgba(37, 99, 235, 0.92)
  );
  color: #e5e7eb;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 0.18rem 0.6rem;
  align-items: center;
  cursor: pointer;
}

.history-header .small {
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.history-subtitle {
  font-size: 0.8rem;
  color: rgba(209, 213, 219, 0.9);
}

.chevron {
  grid-row: 1 / span 2;
  grid-column: 2 / 3;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  font-size: 0.95rem;
  transition: transform 0.18s ease-out, background 0.18s ease-out;
}

.history:not(.collapsed) .chevron {
  transform: rotate(180deg);
  background: rgba(15, 23, 42, 0.97);
}

.history-body {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-4px);
  transition: max-height 0.2s ease-out, opacity 0.2s ease-out,
    transform 0.2s ease-out, padding-bottom 0.2s ease-out;
  padding: 0 1rem 0;
}

.history:not(.collapsed) .history-body {
  max-height: 280px;
  opacity: 1;
  transform: translateY(0);
  padding-bottom: 0.9rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.55rem;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  padding: 0.48rem 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(55, 65, 81, 0.98);
  background: radial-gradient(
    circle at top left,
    rgba(56, 189, 248, 0.24),
    rgba(15, 23, 42, 0.98)
  );
  cursor: pointer;
  transition: border-color 0.12s ease-out, background 0.12s ease-out,
    transform 0.06s ease-out;
}

.history-item:hover {
  border-color: rgba(96, 165, 250, 0.98);
  background: radial-gradient(
    circle at top left,
    rgba(59, 130, 246, 0.34),
    rgba(15, 23, 42, 0.98)
  );
  transform: translateY(-1px);
}

.history-item-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 0.8rem;
  color: rgba(148, 163, 184, 0.96);
  white-space: nowrap;
  text-align: right;
}

/* PLAYLIST */

.playlist-panel {
  border-radius: 1.1rem;
  border: 1px solid rgba(55, 65, 81, 0.96);
  background: rgba(15, 23, 42, 0.98);
  padding: 0.9rem 0.7rem 0.9rem;
  display: flex;
  flex-direction: column;
}

.playlist-panel-header {
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}

.playlist-items {
  max-height: 480px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.24rem;
}

.playlist-item {
  display: flex;
  align-items: center;
  gap: 0.32rem;
  padding: 0.2rem 0.26rem;
  border-radius: 0.55rem;
  border: 1px solid rgba(51, 65, 85, 0.9);
  background: rgba(15, 23, 42, 0.98);
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.playlist-item:hover {
  border-color: rgba(96, 165, 250, 0.98);
  color: #e5e7eb;
}

.playlist-item-thumb {
  width: 34px;
  height: 20px;
  border-radius: 0.3rem;
  object-fit: cover;
}

.playlist-item-index {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 0.76rem;
  opacity: 0.88;
}

.playlist-item-current {
  border-color: var(--accent-blue);
  background: radial-gradient(
    circle at top left,
    rgba(56, 189, 248, 0.4),
    rgba(15, 23, 42, 0.98)
  );
  color: #e5e7eb;
}

@media (max-width: 720px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
.app-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  padding-bottom: 0.4rem;
  border-top: 1px solid rgba(31, 41, 55, 0.9);
  font-size: 0.85rem;
  text-align: center;
  color: rgba(148, 163, 184, 0.9);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-align: right;
}
