*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}

:root {
  --background: #1a1a1a;
  --foreground: #f0f0f0;
  --card: #242424;
  --card-foreground: #f0f0f0;
  --popover: #2a2a2a;
  --popover-foreground: #f0f0f0;
  --primary: #1db954;
  --primary-foreground: #fff;
  --secondary: #333;
  --secondary-foreground: #f0f0f0;
  --muted: #2a2a2a;
  --muted-foreground: #999;
  --accent: #2a2a2a;
  --accent-foreground: #f0f0f0;
  --destructive: #ef4444;
  --border: rgba(255,255,255,0.1);
  --input: rgba(255,255,255,0.1);
  --ring: #1db954;
  --radius: 10px;
  --font: 'Inter', 'Plus Jakarta Sans', system-ui, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--background);
  color: var(--foreground);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#root {
  display: flex;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* --- Animated background particles --- */
.particles-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.dust {
  position: absolute;
  bottom: -40px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary);
  opacity: var(--op);
  transform: scale(var(--sc));
  animation: dustFloat var(--d) var(--dl) linear infinite;
}
.dust-green  { background: #1db954; }
.dust-lime  { background: #1ed760; }
.dust-mint  { background: #a7ffc4; }
.dust-neon  { background: #00ff88; }
@keyframes dustFloat {
  0% { bottom: -40px; }
  100% { bottom: 105%; }
}
.particle {
  position: absolute;
  bottom: -30px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  opacity: var(--op);
  transform: scale(var(--sc));
  animation: particleFloat var(--d) var(--dl) ease-in-out infinite;
}
.particle-green { background: #1db954; box-shadow: 0 0 10px #1db954; }
.particle-lime { background: #1ed760; box-shadow: 0 0 10px #1ed760; }
.particle-mint { background: #a7ffc4; box-shadow: 0 0 10px #a7ffc4; }
.particle-neon { background: #00ff88; box-shadow: 0 0 12px #00ff88; }
@keyframes particleFloat {
  0%   { bottom: -30px; }
  25%  { transform: scale(var(--sc)) translateX(15px); }
  50%  { transform: scale(var(--sc)) translateX(-8px); }
  75%  { transform: scale(var(--sc)) translateX(12px); }
  100% { bottom: 105%; transform: scale(var(--sc)) translateX(-5px); }
}

/* --- Sidebar --- */
.sidebar {
  width: 56px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  z-index: 30;
}
.sidebar-icons {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sbtn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  position: relative;
}
.sbtn:hover { background: var(--muted); color: var(--foreground); }
.sbtn.active { background: rgba(29,185,84,0.15); color: var(--primary); }
.tools-btn { position: relative; }
.tools-dropdown {
  position: absolute;
  left: 48px;
  top: 0;
  background: var(--popover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 220px;
  padding: 4px;
  z-index: 50;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
.tools-dropdown.hidden { display: none; }
.tools-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--foreground);
  font-size: 0.875rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
}
.tools-dropdown button:hover { background: var(--muted); }

/* --- Main --- */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
  display: flex;
  flex-direction: column;
}

/* --- Header --- */
.header {
  text-align: center;
  margin-bottom: 32px;
}
.logo {
  width: 48px;
  height: 48px;
  cursor: pointer;
  margin-bottom: 8px;
}
.brand {
  font-size: 2.5rem;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: -1px;
}
.version-badge {
  display: inline-block;
  background: var(--muted);
  color: var(--muted-foreground);
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  margin-left: 8px;
  font-weight: 500;
  cursor: pointer;
  vertical-align: middle;
}
.subtitle {
  color: var(--muted-foreground);
  margin-top: 8px;
  font-size: 0.9rem;
}

/* --- Fetch Bar --- */
.fetch-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}
.mode-toggle {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted-foreground);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.mode-toggle:hover { color: var(--foreground); border-color: var(--ring); }
.input-wrap {
  flex: 1;
  position: relative;
}
.input-wrap input {
  width: 100%;
  height: 40px;
  padding: 0 32px 0 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--foreground);
  font-size: 0.875rem;
  outline: none;
  font-family: var(--font);
  transition: border-color 0.15s;
}
.input-wrap input:focus { border-color: var(--ring); }
.input-wrap input::placeholder { color: var(--muted-foreground); }
.clear-btn {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  color: var(--muted-foreground);
  font-size: 1.2rem;
  cursor: pointer;
  transition: color 0.1s;
}
.clear-btn:hover { color: var(--foreground); }
.region-select {
  height: 40px;
  width: 70px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--foreground);
  padding: 0 4px;
  font-size: 0.8rem;
  outline: none;
  cursor: pointer;
  flex-shrink: 0;
}
.fetch-btn {
  height: 40px;
  padding: 0 16px;
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.fetch-btn:hover { opacity: 0.9; }
.fetch-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Search Tabs --- */
.search-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
  flex-wrap: wrap;
  align-items: center;
}
.search-tabs .tab {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
  font-weight: 500;
}
.search-tabs .tab:hover { color: var(--foreground); }
.search-tabs .tab.active { color: var(--primary); background: rgba(29,185,84,0.1); }
.filter-input {
  height: 32px;
  padding: 0 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--foreground);
  font-size: 0.8rem;
  outline: none;
  margin-left: auto;
  width: 180px;
}
.sort-select {
  height: 32px;
  padding: 0 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--foreground);
  font-size: 0.8rem;
  outline: none;
  margin-left: 6px;
}

/* --- Loading --- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 0;
  color: var(--muted-foreground);
}
.spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Welcome --- */
.welcome {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted-foreground);
}
.welcome svg { margin-bottom: 16px; }
.welcome p { font-size: 0.95rem; }

/* --- Result Info --- */
.result-info {
  max-width: 800px;
  margin: 0 auto 24px;
  width: 100%;
}
.result-card {
  display: flex;
  gap: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
}
.result-card .cover {
  width: 160px;
  height: 160px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.result-card .meta { flex: 1; min-width: 0; }
.result-card .meta h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; word-break: break-word; }
.result-card .meta .artists { color: var(--muted-foreground); font-size: 0.95rem; }
.result-card .meta .details { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; font-size: 0.82rem; }
.result-card .meta .details .label { color: var(--muted-foreground); font-size: 0.7rem; }
.result-card .close-btn {
  width: 32px; height: 32px;
  border: none; background: transparent;
  color: var(--muted-foreground);
  font-size: 1.5rem;
  cursor: pointer;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.result-card .close-btn:hover { background: var(--muted); color: var(--foreground); }

.result-actions {
  position: absolute; top: 12px; right: 12px;
  display: flex; align-items: center; gap: 8px;
}
.spotify-open-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--primary);
  color: var(--primary-foreground);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.spotify-open-btn:hover { opacity: 0.85; }

/* --- Track List --- */
.track-list-container {
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}
.track-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s;
}
.track-item:hover { background: var(--card); border-color: var(--border); }
.track-item.playing { background: rgba(29,185,84,0.12); border-color: var(--primary); }
.track-item .track-cover {
  width: 40px; height: 40px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}
.track-item .track-no {
  width: 24px;
  text-align: right;
  color: var(--muted-foreground);
  font-size: 0.8rem;
  flex-shrink: 0;
}
.track-item .track-info { flex: 1; min-width: 0; }
.track-item .track-name { font-size: 0.9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-item .track-artist { font-size: 0.78rem; color: var(--muted-foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-item .track-duration {
  font-size: 0.8rem;
  color: var(--muted-foreground);
  flex-shrink: 0;
}
.track-item .explicit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  background: var(--destructive);
  color: #fff;
  border-radius: 2px;
  font-size: 10px;
  font-weight: 700;
  margin-left: 4px;
  vertical-align: middle;
}

/* --- Embed Player --- */
.embed-player {
  max-width: 800px;
  margin: 24px auto;
  width: 100%;
}
.embed-player iframe {
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* --- YouTube Mini Player --- */
.youtube-player {
  position: fixed;
  bottom: -120px;
  right: -120px;
  width: 100px;
  height: 100px;
  z-index: -1;
  opacity: 1;
  pointer-events: none;
  clip-path: inset(0 0 0 0);
}
.youtube-player iframe {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: var(--radius);
}

/* --- Error --- */
.error-box {
  text-align: center;
  padding: 20px;
  color: var(--destructive);
  font-size: 0.9rem;
}

/* --- History --- */
.history-list { max-width: 800px; margin: 0 auto; }
.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.12s;
}
.history-item:hover { border-color: var(--ring); }
.history-item img {
  width: 40px; height: 40px;
  border-radius: 4px;
  object-fit: cover;
}
.history-item .hist-info { flex: 1; }
.history-item .hist-url { font-size: 0.82rem; color: var(--muted-foreground); word-break: break-all; }
.history-del {
  width: 28px; height: 28px;
  border: none; background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  border-radius: 4px;
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
}
.history-del:hover { color: var(--destructive); background: var(--muted); }

/* --- Settings --- */
.settings-group { max-width: 500px; margin: 20px auto; }
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.setting-row span { font-size: 0.9rem; }
.setting-row select {
  padding: 6px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--foreground);
  font-size: 0.85rem;
  outline: none;
}

/* --- Pages --- */
.page { flex: 1; display: flex; flex-direction: column; }
.page h2 { font-size: 1.3rem; margin-bottom: 20px; color: var(--primary); }
.placeholder { color: var(--muted-foreground); text-align: center; padding: 40px; }

/* --- Projects --- */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; max-width: 800px; margin: 0 auto; }
.project-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.project-card:hover { border-color: var(--ring); }
.project-card h3 { font-size: 1rem; margin-bottom: 4px; }
.project-card p { font-size: 0.82rem; color: var(--muted-foreground); }

/* --- Support --- */
.support-content { max-width: 500px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.support-link {
  display: flex; align-items: center; gap: 12px;
  padding: 16px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none; color: var(--foreground);
  transition: border-color 0.15s;
}
.support-link:hover { border-color: var(--ring); }
.support-link span { font-size: 0.95rem; }

/* --- Debug --- */
.debug-log {
  background: #0d0d0d; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem; color: var(--muted-foreground);
  max-height: 400px; overflow-y: auto;
  line-height: 1.6;
}

/* --- Playback Bar --- */
.playback-bar {
  background: var(--card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 8px 12px;
  gap: 8px;
  border-radius: var(--radius);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--card) 85%, transparent);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.pb-skip {
  width: 32px; height: 32px;
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s;
}
.pb-skip:hover { color: var(--foreground); }
.playback-btn {
  width: 36px; height: 36px;
  border: none;
  background: var(--primary);
  color: var(--primary-foreground);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.1s;
}
.playback-btn:hover { opacity: 0.85; }
.playback-btn:active { transform: scale(0.95); }
.pb-progress-container {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.pb-time {
  font-size: 0.7rem;
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  min-width: 32px;
}
.pb-progress {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--muted);
  outline: none;
  cursor: pointer;
  min-width: 40px;
}
.pb-progress::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
}
.pb-progress::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  cursor: pointer;
}
.pb-track-info {
  max-width: 200px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex-shrink: 1;
}
.playback-title {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.playback-artist {
  font-size: 0.7rem;
  color: var(--muted-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 768px) {
  /* Ocultar partículas en mobile: consumen mucha CPU en dispositivos antiguos */
  .particles-bg { display: none; }

  .playback-bar {
    padding: 8px 10px;
    gap: 4px;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--card);
  }
  .pb-track-info { max-width: 120px; }
  .pb-progress-container { gap: 4px; }
  .pb-time { font-size: 0.65rem; min-width: 26px; }
  .playback-btn { width: 32px; height: 32px; }
  .pb-skip { width: 28px; height: 28px; }
  body { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
}

/* --- Utility --- */
.hidden { display: none !important; }

/* --- Responsive --- */
@media (max-width: 768px) {
  #root { flex-direction: column; }

  .sidebar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    width: 100%; height: 56px;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--border);
    padding: 0 8px;
    background: var(--card);
    z-index: 100;
    overflow-x: auto;
  }
  .sidebar-icons {
    flex-direction: row;
    gap: 2px;
    flex: 1;
    justify-content: center;
  }
  .sidebar-bottom { display: none; }
  .sbtn { width: 40px; height: 40px; }
  .tools-dropdown {
    left: auto; right: 0; bottom: 50px; top: auto;
    min-width: 180px;
  }

  .main {
    padding: 12px 10px 72px 10px;
    overflow-y: auto;
  }

  .header { margin-bottom: 16px; }
  .brand { font-size: 1.6rem; }
  .subtitle { font-size: 0.78rem; padding: 0 8px; }
  .logo { width: 36px; height: 36px; }

  .fetch-bar {
    flex-wrap: wrap;
    gap: 6px;
  }
  .fetch-bar .mode-toggle,
  .fetch-bar .fetch-btn { height: 36px; }
  .fetch-btn { padding: 0 10px; font-size: 0.8rem; }
  .input-wrap input { height: 36px; font-size: 0.85rem; }
  .region-select { display: none; }

  .search-tabs {
    overflow-x: auto;
    padding-bottom: 8px;
    gap: 2px;
    -webkit-overflow-scrolling: touch;
  }
  .search-tabs .tab {
    padding: 6px 10px;
    font-size: 0.78rem;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .filter-input { width: 100px; height: 28px; }
  .sort-select { display: none; }

  .result-card {
    flex-direction: column;
    padding: 12px;
  }
  .result-card .cover {
    width: 80px; height: 80px;
    border-radius: 6px;
  }
  .result-card .meta h2 { font-size: 1.1rem; }
  .result-card .meta .details { grid-template-columns: 1fr; }

  .result-actions {
    position: static;
    margin-top: 10px;
    justify-content: flex-end;
  }
  .spotify-open-btn {
    padding: 6px 12px;
    font-size: 0.75rem;
  }

  .track-item { padding: 8px 6px; gap: 6px; }
  .track-item .track-name { font-size: 0.82rem; }
  .track-item .track-artist { font-size: 0.72rem; }

  .youtube-player iframe { height: 220px; }
  .embed-player iframe { height: 220px; }

  .welcome { padding: 30px 12px; }
  .welcome svg { width: 48px; height: 48px; }
  .welcome p { font-size: 0.85rem; }

  .settings-group { padding: 0 8px; }
  .projects-grid { grid-template-columns: 1fr; padding: 0 8px; }
  .support-content { padding: 0 8px; }

  .page h2 { font-size: 1.1rem; margin-bottom: 12px; }
  .placeholder { font-size: 0.85rem; padding: 20px; }
}

@media (max-width: 400px) {
  .brand { font-size: 1.3rem; }
  .fetch-bar { gap: 4px; }
  .input-wrap input { font-size: 16px; }
  .fetch-btn span { display: none; }
  .youtube-player iframe { height: 180px; }
  .embed-player iframe { height: 180px; }
}
