:root {
  --bg: #fafaf7;
  --bg-alt: #f2f1ec;
  --text: #1a1a1a;
  --text-soft: #6b6b6b;
  --text-muted: #a8a8a3;
  --accent: #c65d3a;
  --accent-soft: #f5e6df;
  --border: #e8e8e3;
  --white: #ffffff;
  --shadow: rgba(20, 14, 10, 0.08);
  --shadow-lg: rgba(20, 14, 10, 0.14);
  --radius: 12px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Fraunces', Georgia, serif;
  --ease: cubic-bezier(.22,.61,.36,1);
}
[data-theme="dark"] {
  --bg: #0e0d0c;
  --bg-alt: #181614;
  --text: #f4f1ec;
  --text-soft: #b3ada4;
  --text-muted: #6b655d;
  --accent: #e67e5a;
  --accent-soft: #2a1d16;
  --border: #2a2724;
  --white: #1a1816;
  --shadow: rgba(0, 0, 0, 0.4);
  --shadow-lg: rgba(0, 0, 0, 0.6);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background .4s var(--ease), color .4s var(--ease);
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }

/* Fondo ambient sutil que respira */
.ambient {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60vw 40vh at 12% -5%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%),
    radial-gradient(50vw 50vh at 100% 110%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 60%);
  opacity: .9;
}

.app {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-height: 100vh;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 32px;
}

/* Header */
.header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; padding: 30px 0 22px;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-dot {
  width: 11px; height: 11px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent);
  animation: pulse 2.6s var(--ease) infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent); }
  70% { box-shadow: 0 0 0 9px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.brand h1 { font-family: var(--font-serif); font-size: 25px; font-weight: 600; letter-spacing: -.02em; }
.brand-tag {
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-muted); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 999px;
}
.header-actions { display: flex; gap: 8px; align-items: center; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-soft); transition: all .2s var(--ease);
}
.icon-btn:hover { background: var(--bg-alt); color: var(--text); transform: translateY(-1px); }
.icon-btn.small { width: 32px; height: 32px; }
.icon-btn.active { color: var(--accent); background: var(--accent-soft); }

.ghost-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text-soft);
  font-size: 13px; font-weight: 500; transition: all .2s var(--ease);
}
.ghost-btn:hover { border-color: var(--text); color: var(--text); transform: translateY(-1px); }

/* Tabs */
.add-section { padding: 24px 0 0; position: relative; }
.add-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tab-btn {
  padding: 10px 18px; border-radius: 999px; background: var(--bg-alt);
  color: var(--text-soft); font-size: 14px; font-weight: 500;
  transition: all .2s var(--ease);
}
.tab-btn:hover { background: var(--border); color: var(--text); }
.tab-btn.active { background: var(--text); color: var(--bg); }
.tab-content { display: none; animation: fadeUp .35s var(--ease); }
.tab-content.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.search-box { position: relative; max-width: 620px; }
.search-box svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search-box input {
  width: 100%; padding: 14px 16px 14px 48px; background: var(--white);
  border: 1px solid var(--border); border-radius: 999px; color: var(--text);
  font-size: 15px; transition: all .2s var(--ease);
}
.search-box input:focus { outline: none; border-color: var(--text); box-shadow: 0 0 0 4px var(--shadow); }
.search-loading { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.search-results {
  position: absolute; top: 100%; left: 0; right: 0; max-width: 620px;
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
  margin-top: 8px; max-height: 420px; overflow-y: auto;
  box-shadow: 0 14px 40px var(--shadow-lg); z-index: 100; display: none;
}
.search-results.visible { display: block; animation: fadeUp .25s var(--ease); }
.search-results ul { list-style: none; }
.search-results li {
  display: grid; grid-template-columns: 48px 1fr; gap: 12px; padding: 11px 12px;
  cursor: pointer; transition: background .15s var(--ease);
}
.search-results li:hover { background: var(--bg-alt); }
.search-results li img { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; }
.search-results .title { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-results .channel { color: var(--text-soft); font-size: 13px; }
.search-error { padding: 24px; text-align: center; color: var(--text-soft); font-size: 14px; }
.search-error .hint { margin-top: 8px; font-size: 12px; color: var(--text-muted); }

.add-box { display: flex; gap: 8px; max-width: 620px; }
.add-box input {
  flex: 1; padding: 14px 16px; background: var(--white); border: 1px solid var(--border);
  border-radius: 999px; color: var(--text); font-size: 15px; transition: all .2s var(--ease);
}
.add-box input:focus { outline: none; border-color: var(--text); box-shadow: 0 0 0 4px var(--shadow); }
.add-btn {
  width: 48px; height: 48px; border-radius: 50%; background: var(--text); color: var(--bg);
  display: flex; align-items: center; justify-content: center; transition: all .2s var(--ease); flex-shrink: 0;
}
.add-btn:hover { background: var(--accent); transform: scale(1.06) rotate(90deg); }
.hint { margin-top: 9px; font-size: 12px; color: var(--text-muted); max-width: 620px; }

.upload-box {
  text-align: center; padding: 26px; background: var(--white);
  border: 2px dashed var(--border); border-radius: var(--radius); max-width: 620px;
  transition: border-color .2s var(--ease);
}
.upload-box:hover { border-color: var(--accent); }
.upload-btn {
  display: inline-flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 30px; background: var(--bg-alt); border-radius: var(--radius);
  color: var(--text); font-size: 14px; font-weight: 500; transition: all .2s var(--ease);
}
.upload-btn:hover { background: var(--accent-soft); color: var(--accent); transform: translateY(-2px); }

/* Main */
.main { padding: 26px 0 32px; overflow-y: auto; }

/* Playlists */
.playlists-section { margin-bottom: 28px; }
.playlists-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.playlists-head h3 {
  font-family: var(--font-serif); font-size: 15px; font-weight: 600;
  letter-spacing: .02em; color: var(--text-soft); text-transform: uppercase;
}
.playlists-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.playlist-chip {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  padding: 9px 8px 9px 15px; border-radius: 999px;
  background: var(--white); border: 1px solid var(--border);
  font-size: 13px; font-weight: 500; transition: all .2s var(--ease);
  animation: fadeUp .3s var(--ease);
}
.playlist-chip:hover { border-color: var(--text); transform: translateY(-1px); }
.playlist-chip .pl-name { cursor: pointer; white-space: nowrap; }
.playlist-chip .pl-count { color: var(--text-muted); font-size: 11px; }
.playlist-chip .pl-act {
  width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all .15s var(--ease);
}
.playlist-chip .pl-act:hover { background: var(--bg-alt); color: var(--accent); }
.playlist-chip .pl-act.del:hover { color: #d04545; }

/* Queue */
.section-header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 14px; }
.section-title { display: flex; align-items: baseline; gap: 14px; }
.section-header h2 { font-family: var(--font-serif); font-size: 30px; font-weight: 500; letter-spacing: -.025em; }
.big-count { font-family: var(--font-serif); font-size: 42px; font-weight: 400; color: var(--accent); line-height: .8; }
.queue-actions { display: flex; align-items: center; gap: 8px; }
.text-btn { padding: 7px 13px; font-size: 13px; color: var(--text-soft); border-radius: 8px; transition: all .2s var(--ease); }
.text-btn:hover { background: var(--bg-alt); color: var(--text); }

.queue { list-style: none; display: flex; flex-direction: column; }
.queue li {
  display: grid; grid-template-columns: 50px 1fr auto auto; align-items: center; gap: 16px;
  padding: 12px 8px; border-bottom: 1px solid var(--border);
  transition: background .2s var(--ease), padding-left .2s var(--ease);
  cursor: pointer; position: relative;
  animation: rowIn .4s var(--ease) backwards;
}
@keyframes rowIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
.queue li:hover { background: var(--bg-alt); padding-left: 14px; }
.queue li.playing { background: var(--accent-soft); }
.queue li.playing .title { color: var(--accent); }
.queue li img { width: 50px; height: 50px; border-radius: 7px; object-fit: cover; background: var(--bg-alt); }
.queue li .info { min-width: 0; }
.queue li .title { font-weight: 500; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 8px; }
.queue li .channel { color: var(--text-soft); font-size: 13px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue li .duration { font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.queue li .row-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .2s var(--ease); }
.queue li:hover .row-actions, .queue li.playing .row-actions { opacity: 1; }
.queue li .row-actions button {
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all .15s var(--ease);
}
.queue li .row-actions button:hover { background: var(--white); color: var(--accent); }
.queue li .row-actions button.del:hover { color: #d04545; }

.badge-preview { font-size: 9px; color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); padding: 2px 6px; border-radius: 4px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.badge-local { font-size: 9px; color: #2f8f5b; background: color-mix(in srgb, #2f8f5b 14%, transparent); padding: 2px 6px; border-radius: 4px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }

/* Ecualizador animado en pista activa */
.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.eq span { width: 3px; background: var(--accent); border-radius: 2px; animation: eq 1s ease-in-out infinite; }
.eq span:nth-child(1){ animation-delay: -.4s; }
.eq span:nth-child(2){ animation-delay: -.2s; }
.eq span:nth-child(3){ animation-delay: -.6s; }
.eq span:nth-child(4){ animation-delay: -.1s; }
@keyframes eq { 0%,100%{ height: 25%; } 50%{ height: 100%; } }

.empty-state { text-align: center; padding: 80px 20px; color: var(--text-soft); font-family: var(--font-serif); font-size: 20px; line-height: 1.6; display: none; }
.empty-state span { display: block; font-family: var(--font-sans); font-size: 13px; color: var(--text-muted); margin-top: 8px; }
.empty-state.visible { display: block; animation: fadeUp .4s var(--ease); }

/* Player */
.player {
  display: grid; grid-template-columns: 1fr 1.5fr 1fr; align-items: center; gap: 24px;
  padding: 16px 0; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); position: sticky; bottom: 0;
}
.now-playing { display: flex; align-items: center; gap: 14px; min-width: 0; }
.thumb-wrap { width: 50px; height: 50px; border-radius: 7px; overflow: hidden; background: var(--bg-alt); flex-shrink: 0; }
.thumb-wrap img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s var(--ease); }
.now-playing:hover .thumb-wrap img { transform: scale(1.06); }
.track-info { min-width: 0; }
.track-title { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-channel { font-size: 12px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.controls { display: flex; align-items: center; justify-content: center; gap: 8px; }
.ctrl-btn { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text-soft); transition: all .2s var(--ease); }
.ctrl-btn:hover { color: var(--text); background: var(--bg-alt); }
.ctrl-btn.active { color: var(--accent); background: var(--accent-soft); }
.play-btn {
  width: 46px; height: 46px; border-radius: 50%; background: var(--text); color: var(--bg);
  display: flex; align-items: center; justify-content: center; transition: transform .15s var(--ease), background .2s var(--ease);
}
.play-btn:hover { background: var(--accent); transform: scale(1.08); }
.play-btn:active { transform: scale(.95); }

.progress-wrap { display: flex; align-items: center; gap: 10px; }
.progress-wrap span { font-size: 11px; color: var(--text-soft); font-variant-numeric: tabular-nums; min-width: 34px; }
.volume { display: flex; align-items: center; gap: 10px; justify-content: flex-end; color: var(--text-soft); }

input[type="range"] { -webkit-appearance: none; appearance: none; height: 4px; background: var(--border); border-radius: 2px; cursor: pointer; flex: 1; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; background: var(--text); border-radius: 50%; transition: transform .15s var(--ease), background .15s var(--ease); }
input[type="range"]:hover::-webkit-slider-thumb, input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.35); background: var(--accent); }
input[type="range"]::-moz-range-thumb { width: 13px; height: 13px; background: var(--text); border: none; border-radius: 50%; cursor: pointer; }
.volume input[type="range"] { max-width: 100px; }

/* Toasts */
.toast-stack { position: fixed; bottom: 104px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; background: var(--text); color: var(--bg);
  padding: 11px 18px; border-radius: 999px; font-size: 13px; font-weight: 500;
  box-shadow: 0 10px 30px var(--shadow-lg); display: flex; align-items: center; gap: 9px;
  animation: toastIn .35s var(--ease);
}
.toast.out { animation: toastOut .3s var(--ease) forwards; }
.toast.success { background: #2f8f5b; color: #fff; }
.toast.error { background: #c0392b; color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(.96); } }

@media (max-width: 768px) {
  .app { padding: 0 18px; }
  .header { padding: 18px 0; gap: 12px; }
  .brand h1 { font-size: 21px; }
  .ghost-btn span { display: none; }
  .ghost-btn { padding: 9px 11px; }
  .section-header h2 { font-size: 24px; }
  .big-count { font-size: 34px; }
  .player { grid-template-columns: 1fr auto; grid-template-rows: auto auto; gap: 12px; padding: 12px 0; }
  .now-playing { grid-column: 1 / 2; }
  .controls { grid-column: 2 / 3; grid-row: 1; }
  .progress-wrap { grid-column: 1 / 3; grid-row: 2; }
  .volume { display: none; }
  .queue-actions { width: 100%; justify-content: space-between; }
  .queue li { grid-template-columns: 44px 1fr auto; }
  .queue li .duration { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
} 