:root {
  --bg: #090d16;
  --card: #111827;
  --border: #1f2937;
  --text: #f9fafb;
  --muted: #9ca3af;
  --primary: #10b981;
  --primary-dim: #059669;
  --accent: #3b82f6;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.lab-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  max-width: 720px;
  margin: 0 auto;
}
.lab-header h1 { margin: 0; font-size: 1.35rem; }
.lab-main { max-width: 720px; margin: 0 auto; padding: 1.25rem 1.5rem 3rem; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.muted, .muted-card { color: var(--muted); }
.muted-card h2 { color: var(--text); }
label { display: block; font-weight: 600; margin-bottom: .4rem; }
input[type=file] { width: 100%; margin: .5rem 0 1rem; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .5rem .9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #1f2937;
  color: var(--text);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
}
.btn.primary { background: var(--primary); color: #042f1a; border-color: var(--primary-dim); }
.delete-track-btn { border-color: #7f1d1d; color: #fecaca; background: #35151b; }
.delete-track-btn:disabled { opacity: .65; cursor: wait; }
.btn:hover { filter: brightness(1.08); }
.job-list { list-style: none; margin: 0; padding: 0; }
.job-list li {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.job-list li:last-child { border-bottom: 0; }
.job-meta { display: flex; flex-direction: column; gap: 2px; }
.job-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.album-card .job-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  width: 100%;
}
.album-card .job-actions .btn {
  flex: 1 1 0;
  text-align: center;
  padding: 0.4rem 0.45rem;
  font-size: 0.82rem;
  white-space: nowrap;
  min-width: 0;
}
.path { font-size: .75rem; word-break: break-all; opacity: .85; }
code { background: #0b1220; padding: .12rem .35rem; border-radius: 4px; font-size: .85em; }
pre {
  background: #0b1220;
  padding: .75rem;
  border-radius: 8px;
  overflow: auto;
  white-space: pre-wrap;
  font-size: .85rem;
}
.err { color: #fca5a5; }
ol { line-height: 1.55; padding-left: 1.25rem; }

.header-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ok { color: #6ee7b7; }
input[type=text], input[type=number] {
  width: 100%; max-width: 100%;
  background: #0b1220; color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; margin: .35rem 0 .75rem;
}
.check { display: flex; align-items: center; gap: 8px; margin: .75rem 0; font-weight: 500; }
.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  gap: 16px;
}
.album-card {
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.album-cover {
  aspect-ratio: 1; border-radius: 8px; background: #1f2937 center/cover no-repeat;
  display: grid; place-items: center; color: var(--muted); font-size: 1.5rem;
}
.cover-preview {
  width: 100%; max-width: 220px; aspect-ratio: 1; border-radius: 12px;
  background: #1f2937 center/cover no-repeat; border: 1px solid var(--border);
  display: grid; place-items: center; color: var(--muted); margin-bottom: 12px;
}

.lab-nav {
  max-width: 720px; margin: 0 auto; padding: 0 1.5rem;
  display: flex; gap: 8px; border-bottom: 1px solid var(--border);
}
.lab-nav a {
  color: var(--muted); text-decoration: none; padding: 10px 14px;
  border-bottom: 2px solid transparent; font-weight: 600; font-size: .95rem;
}
.lab-nav a.active, .lab-nav a:hover { color: var(--text); border-bottom-color: var(--primary); }
.hero-card .hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 1rem; }
.btn-lg { padding: .75rem 1.25rem !important; font-size: 1rem !important; }
.banner { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.banner.ok { background: #064e3b; color: #6ee7b7; }
.banner.err { background: #450a0a; color: #fca5a5; }
.highlight-card { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary-dim); }
.subh { margin: 1.25rem 0 .5rem; font-size: 1rem; }
.album-cover { position: relative; }
.album-cover-link { text-decoration: none; color: inherit; }
.play-badge {
  position: absolute; right: 8px; bottom: 8px;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: #042f1a;
  display: grid; place-items: center; font-size: .9rem;
  box-shadow: 0 4px 12px #0006;
}
.track-list li { align-items: center; }

.progress-panel { text-align: center; }
.progress-ring-wrap {
  position: relative; width: 120px; height: 120px; margin: 1rem auto;
}
.progress-ring { transform: rotate(-90deg); }
.progress-ring-bg {
  fill: none; stroke: #1f2937; stroke-width: 8;
}
.progress-ring-fg {
  fill: none; stroke: var(--primary); stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.35s ease;
}
.progress-ring-label {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 1.35rem; font-weight: 700; color: var(--text);
}
.progress-log {
  list-style: none; margin: 1rem 0 0; padding: 0; text-align: left;
  max-height: 180px; overflow: auto; font-size: .85rem;
}
.progress-log li { padding: 4px 0; border-bottom: 1px solid var(--border); color: var(--muted); }
.progress-log li.ok { color: #6ee7b7; }
.progress-log li.err { color: #fca5a5; }
.play-cta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  border-color: var(--primary);
}

.album-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}
.album-menu-btn {
  background: #1f2937;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  flex: none;
}
.ctx-menu {
  position: fixed;
  z-index: 100;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 10px;
  padding: 6px;
  min-width: 180px;
  box-shadow: 0 12px 40px #0008;
  display: flex;
  flex-direction: column;
}
.ctx-menu[hidden] { display: none !important; }
.ctx-menu button {
  background: transparent;
  border: 0;
  color: #e5e7eb;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}
.ctx-menu button:hover { background: #1f2937; }
.ctx-menu button.danger { color: #fca5a5; }

.lab-dialog {
  border: 1px solid #374151;
  border-radius: 14px;
  background: #111827;
  color: #e5e7eb;
  padding: 1rem 1.25rem;
  max-width: min(520px, 94vw);
}
.lab-dialog::backdrop { background: #000a; }
.match-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-height: 50vh;
  overflow: auto;
  margin: 12px 0;
}
.match-item {
  display: flex;
  gap: 10px;
  align-items: center;
  background: #0b1220;
  border: 1px solid #374151;
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  color: inherit;
  text-align: left;
}
.match-item img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  background: #1f2937;
}
.match-item span { display: flex; flex-direction: column; gap: 2px; }
.match-item small { color: #9ca3af; }
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}


.album-cover-wrap {
  position: relative;
  width: 100%;
}
.album-cover-wrap .album-cover {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  background: #1f2937 center/cover no-repeat;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 1.75rem;
}
.album-menu-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid #475569;
  color: #f8fafc;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  display: grid;
  place-items: center;
  backdrop-filter: blur(4px);
}
.album-menu-btn:hover {
  background: rgba(30, 41, 59, 0.95);
}
.album-card-title {
  font-size: 0.98rem;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay[hidden] { display: none !important; }
.modal-card {
  background: #111827;
  border: 1px solid #374151;
  border-radius: 14px;
  color: #e5e7eb;
  padding: 1rem 1.15rem 1.15rem;
  width: min(520px, 100%);
  max-height: min(88vh, 720px);
  overflow: auto;
  box-shadow: 0 20px 50px #000a;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 0.35rem;
}
.modal-head h3 { margin: 0; font-size: 1.1rem; }
.modal-x {
  background: #1f2937;
  border: 1px solid #374151;
  color: #e5e7eb;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.2rem;
}
.match-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 50vh;
  overflow: auto;
  margin: 12px 0;
}
.match-item {
  display: flex;
  gap: 12px;
  align-items: center;
  background: #0b1220;
  border: 1px solid #374151;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  color: inherit;
  text-align: left;
  width: 100%;
}
.match-item:hover { border-color: var(--primary); }
.match-item img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  background: #1f2937;
  flex: none;
}
.match-item span { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.match-item strong { font-size: 0.95rem; }
.match-item small { color: #9ca3af; font-size: 0.8rem; }

/* Reproductor como contenedor sobre el índice */
.lab-player-host {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(5, 8, 14, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.lab-player-host[hidden] { display: none !important; }
.lab-player-host.is-min {
  display: block !important;
  inset: auto;
  width: 2px;
  height: 2px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  padding: 0;
  background: transparent;
}
.lab-player-frame {
  width: min(440px, 100%);
  height: min(92vh, 820px);
  border: 0;
  border-radius: 16px;
  background: transparent;
  box-shadow: 0 20px 60px #000a;
}
body.lab-player-open { overflow: hidden; }
body.player-body.is-embed {
  background: transparent;
  padding: 0;
  min-height: 0;
}
body.player-body.is-embed .music-player {
  margin: 0 auto;
  max-width: 420px;
}
.lab-shell-mini { z-index: 95; }

.lab-config-host {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 8, 14, 0.75);
  display: flex;
  flex-direction: column;
  padding: 12px;
}
.lab-config-host[hidden] { display: none !important; }
.lab-config-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 720px;
  width: 100%;
  margin: 0 auto 8px;
  color: #e5e7eb;
}
.lab-config-frame {
  flex: 1;
  width: min(720px, 100%);
  margin: 0 auto;
  border: 0;
  border-radius: 14px;
  background: var(--bg, #0b1220);
  box-shadow: 0 20px 50px #000a;
  min-height: 70vh;
}
body.config-embed .lab-header,
body.config-embed .lab-nav { display: none !important; }
body.config-embed { padding: 12px; background: #0b1220; }
.win-close:disabled { opacity: 0.35; }
.win-close:not(:disabled) { color: #f87171 !important; cursor: pointer; }


/* Buscador de biblioteca: usable en escritorio y móvil */
.library-search { display:flex; align-items:center; gap:.55rem; width:100%; box-sizing:border-box; margin:1rem 0 1.1rem; padding:.65rem; border:1px solid var(--border, #d5dbe5); border-radius:12px; background:var(--surface, rgba(127,127,127,.04)); }
.library-search input[type="search"] { flex:1 1 auto; min-width:0; width:100%; box-sizing:border-box; padding:.78rem .9rem; border:1px solid var(--border, #cbd5e1); border-radius:8px; background:var(--input-bg, transparent); color:inherit; font:inherit; }
.library-search .btn { flex:0 0 auto; white-space:nowrap; }
.search-summary { margin:.4rem 0 1rem; }
.empty-search { padding:1rem; border:1px dashed var(--border, #cbd5e1); border-radius:10px; text-align:center; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
@media (max-width: 560px) { .library-search { flex-wrap:wrap; padding:.55rem; } .library-search input[type="search"] { flex:1 0 100%; } .library-search .btn { flex:1 1 auto; } }

/* Sparrow-Fy Stage 2: shell de navegación y biblioteca de ancho completo.
   Solo presentación: no altera rutas, sesiones ni contratos de la API móvil. */
:root {
  --bg: #061013;
  --card: #0e1b20;
  --border: #1b3437;
  --text: #f4f7f5;
  --muted: #9aafb0;
  --primary: #10b99a;
  --primary-dim: #087f70;
  --accent: #d5b46b;
  --surface-raised: #122328;
}
body { background: radial-gradient(ellipse at 75% -20%, #103638 0, transparent 42%), var(--bg); }
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "top top" "side content";
}
.lab-header {
  grid-area: top;
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 14px 24px;
  display: grid;
  grid-template-columns: auto minmax(180px, 440px) auto;
  gap: 22px;
  border-bottom: 1px solid #1b3537;
  background: rgba(7, 20, 23, .92);
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(16px);
}
.sparrow-brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; color: inherit; text-decoration: none; }
.sparrow-brand h1 { margin: 0; }
.sparrow-brand__logo { border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1px #b89b55; }
.sparrow-brand__text { display: flex; flex-direction: column; line-height: 1.15; }
.sparrow-brand__text strong { color: #f1d79c; font-size: .98rem; letter-spacing: .055em; text-transform: uppercase; }
.sparrow-brand__text small { color: #9fb5b4; font-size: .72rem; margin-top: 3px; }
.lab-header > div:first-child p { display: none; }
.top-search { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 0 12px; border: 1px solid #213b3e; background: #102126; border-radius: 12px; color: #8ea5a6; }
.top-search > span { font-size: 1.35rem; line-height: 1; }
.top-search input { flex: 1; width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); padding: 11px 0; font: inherit; }
.top-search button { border: 0; background: transparent; color: #b8c9c6; font-size: 1.15rem; cursor: pointer; padding: 5px; }
.header-actions { justify-content: flex-end; align-items: center; gap: 7px; }
.header-actions .btn { white-space: nowrap; font-size: .82rem; }
.icon-btn { width: 38px; height: 38px; display: inline-grid; place-items: center; color: #dce9e5; text-decoration: none; border: 1px solid transparent; border-radius: 11px; background: transparent; font-size: 1.05rem; }
.icon-btn:hover { background: #153438; border-color: #285456; color: #4de0c2; }
.lab-nav {
  grid-area: side;
  width: 100%; max-width: none; margin: 0; padding: 22px 13px 18px;
  border: 0; border-right: 1px solid #183033; background: rgba(7, 19, 22, .76);
  display: flex; flex-direction: column; align-items: stretch; gap: 5px; min-height: calc(100vh - 72px);
  position: sticky; top: 72px; height: calc(100vh - 72px); overflow-y: auto;
}
.lab-nav a { display: flex; align-items: center; gap: 11px; border: 0; border-radius: 9px; padding: 11px 12px; font-size: .9rem; color: #aabbbb; }
.lab-nav a.active, .lab-nav a:hover { color: #f4fffc; background: linear-gradient(100deg, #087c70, #104c4b); border: 0; }
.nav-icon { width: 20px; text-align: center; font-size: 1.1rem; color: #9eb7b4; }
.lab-nav a.active .nav-icon, .lab-nav a:hover .nav-icon { color: #62ead0; }
.nav-section-label { padding: 8px 12px 5px; color: #597778; font-size: .67rem; font-weight: 800; letter-spacing: .12em; }
.nav-divider { height: 1px; background: #1a3435; margin: 13px 8px; }
.nav-spacer { flex: 1; min-height: 28px; }
.nav-brand-note { margin: 12px 9px 0; padding: 12px 10px; border-top: 1px solid #1a3435; color: #8ca8a5; font-size: .75rem; }
.nav-brand-note small { display: block; margin: 4px 0 0 15px; color: #587b78; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #18d1a9; box-shadow: 0 0 10px #18d1a966; }
.lab-main { grid-area: content; width: 100%; max-width: none; min-width: 0; margin: 0; padding: 26px clamp(18px, 2.6vw, 42px) 100px; }
.lab-main > .card, .lab-main > section { width: 100%; }
.card { background: linear-gradient(145deg, rgba(17, 34, 39, .97), rgba(12, 25, 30, .97)); border-color: #1b3639; box-shadow: 0 12px 34px #0002; }
.card h2 { letter-spacing: -.02em; }
.album-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 17px; }
.album-card { padding: 10px; border-color: #1a3337; background: linear-gradient(160deg, #102126, #0b171b); transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.album-card:hover { transform: translateY(-3px); border-color: #217e70; box-shadow: 0 12px 24px #0003; }
.album-cover { border-radius: 9px; box-shadow: 0 5px 14px #0003; }
.album-card-title { line-height: 1.35; }
.btn { transition: background .16s ease, border-color .16s ease, transform .16s ease; }
.btn.primary { color: #031b18; background: linear-gradient(135deg, #17c7a5, #0da88d); border-color: #118b79; }
.btn.primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.library-search { background: #0a171b; border-color: #1d383b; }
.library-search input[type="search"] { background: #0e2025; border-color: #244144; }
.lab-main h2, .lab-main h3 { scroll-margin-top: 90px; }
#albums, #tracks { scroll-margin-top: 95px; }
@media (min-width: 1500px) { .album-grid { grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap: 19px; } }
@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 190px minmax(0, 1fr); }
  .lab-header { grid-template-columns: auto minmax(140px, 1fr); gap: 12px; }
  .top-search { grid-column: 2; grid-row: 1; }
  .header-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .lab-nav { top: 108px; height: calc(100vh - 108px); }
}
@media (max-width: 720px) {
  .app-shell { display: flex; flex-direction: column; }
  .lab-header { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: 12px 14px; gap: 11px; }
  .sparrow-brand__logo { width: 36px; height: 36px; }
  .sparrow-brand__text strong { font-size: .85rem; }
  .top-search { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .header-actions { grid-column: 1 / -1; justify-content: flex-start; flex-wrap: wrap; }
  .header-actions form { margin-left: auto !important; }
  .header-actions .btn { padding: 8px 10px; font-size: .78rem; }
  .lab-nav { position: sticky; top: 0; z-index: 15; height: auto; min-height: 0; flex-direction: row; align-items: center; gap: 5px; overflow-x: auto; overflow-y: hidden; padding: 8px 10px; border-right: 0; border-bottom: 1px solid #183033; }
  .lab-nav .nav-section-label, .lab-nav .nav-divider, .lab-nav .nav-spacer, .lab-nav .nav-brand-note { display: none; }
  .lab-nav a { flex: 0 0 auto; padding: 9px 11px; font-size: .82rem; white-space: nowrap; }
  .lab-nav a .nav-icon { width: auto; }
  .lab-main { padding: 16px 12px 90px; }
  .album-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .album-card { padding: 8px; gap: 7px; }
  .album-card .job-actions { flex-wrap: wrap; }
  .album-card .job-actions .btn { white-space: normal; }
  .library-search { flex-wrap: wrap; padding: 9px; }
  .library-search input[type="search"] { flex-basis: 100%; }
  .lab-player-frame { width: 100%; height: min(88vh, 820px); }
}
@media (max-width: 380px) {
  .album-grid { grid-template-columns: 1fr 1fr; gap: 7px; }
  .album-card-title { font-size: .86rem; }
  .header-actions .btn { font-size: .72rem; }
}
@media (prefers-reduced-motion: reduce) {
  .album-card, .btn { transition: none !important; }
}

/* Sparrow-Fy stage 4: artist and song exploration views. Album-card markup and
   album context-menu behavior are intentionally left untouched. */
.browse-heading { display:flex; align-items:flex-end; justify-content:space-between; gap:1rem; margin-bottom:1rem; }
.browse-heading h2 { margin:.1rem 0 .25rem; }
.eyebrow { margin:0; color:#50cdb1; font-size:.72rem; font-weight:800; letter-spacing:.16em; }
.artist-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(245px,1fr)); gap:12px; margin-top:1.2rem; }
.artist-card { min-width:0; display:flex; align-items:center; gap:13px; padding:13px; border:1px solid #1b3a3d; border-radius:14px; color:var(--text); text-decoration:none; background:linear-gradient(135deg,#102327,#0b171b); transition:border-color .18s ease,background .18s ease,transform .18s ease; }
.artist-card:hover { border-color:#2a9e88; background:linear-gradient(135deg,#15312f,#0d1d20); transform:translateY(-1px); }
.artist-avatar { flex:0 0 54px; width:54px; height:54px; display:grid; place-items:center; border-radius:50%; background-color:#16443e; background-size:cover; background-position:center; color:#b9f1df; font-size:1.3rem; font-weight:800; box-shadow:inset 0 0 0 1px #3aa58a55; }
.artist-card-copy { min-width:0; display:flex; flex:1; flex-direction:column; gap:4px; }
.artist-card-copy strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.artist-card-copy small { color:var(--muted,#91a6a8); font-size:.8rem; }
.artist-card-arrow { color:#57d8b9; font-size:1.2rem; }
.track-table-wrap { width:100%; overflow-x:auto; margin-top:1rem; border:1px solid #1b373b; border-radius:13px; }
.library-track-table { width:100%; border-collapse:collapse; min-width:640px; }
.library-track-table th { padding:12px 14px; color:#91aaa9; background:#102126; text-align:left; text-transform:uppercase; font-size:.7rem; letter-spacing:.08em; white-space:nowrap; }
.library-track-table td { padding:12px 14px; border-top:1px solid #1b3336; vertical-align:middle; }
.library-track-table tbody tr { background:#0c191d; transition:background .15s ease; }
.library-track-table tbody tr:hover { background:#122629; }
.library-track-table td strong,.library-track-table td small { display:block; }
.library-track-table td small { margin-top:3px; color:#819899; font-size:.76rem; }
.track-number { width:42px; color:#86a09f; font-variant-numeric:tabular-nums; }
.track-table-action { width:130px; text-align:right !important; white-space:nowrap; }
@media(max-width:720px) {
  .artist-grid { grid-template-columns:1fr; gap:9px; }
  .artist-card { padding:11px; }
  .artist-avatar { width:48px; height:48px; flex-basis:48px; }
  .track-table-wrap { border:0; overflow:visible; }
  .library-track-table { min-width:0; }
  .library-track-table thead { display:none; }
  .library-track-table,.library-track-table tbody,.library-track-table tr,.library-track-table td { display:block; width:100%; }
  .library-track-table tr { padding:11px; margin-bottom:9px; border:1px solid #1b373b; border-radius:12px; }
  .library-track-table td { padding:4px 0; border:0; }
  .library-track-table .track-number { display:none; }
  .library-track-table td:nth-child(3)::before { content:'Álbum: '; color:#819899; }
  .library-track-table td:nth-child(4)::before { content:'Artista: '; color:#819899; }
  .track-table-action { text-align:left !important; padding-top:9px !important; }
}
@media(prefers-reduced-motion:reduce) { .artist-card { transition:none; } .artist-card:hover { transform:none; } }

/* Sparrow-Fy Stage 6: mobile-first finishing pass.
   Deliberately does not target .album-card, album menus, library.js, API routes or data contracts. */
:root { --mobile-safe-bottom: env(safe-area-inset-bottom, 0px); }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { min-width: 0; overflow-x: clip; }
button, .btn, .icon-btn, input, select, textarea { touch-action: manipulation; }
.lab-main, .app-shell, .lab-header, .lab-nav { min-width: 0; }
.top-search { min-width: 0; }
.top-search input { font-size: 16px; }
.lab-nav a { min-height: 42px; }
.header-actions .btn, .header-actions .icon-btn { min-height: 40px; }
.track-table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.library-track-table { min-width: 690px; }
.artist-card, .artist-card-copy, .browse-page, .card { min-width: 0; }
img { max-width: 100%; }

@media (max-width: 720px) {
  .app-shell { min-height: 100svh; }
  .lab-header { gap: 10px; padding: 10px 12px; }
  .sparrow-brand { gap: 8px; }
  .sparrow-brand__text small { font-size: .66rem; }
  .top-search { min-height: 44px; }
  .top-search input { padding: 10px 0; }
  .header-actions { gap: 6px; align-items: center; }
  .header-actions .btn { min-height: 40px; }
  .lab-nav { scroll-snap-type: x proximity; scrollbar-width: thin; padding-bottom: 9px; }
  .lab-nav a { scroll-snap-align: start; min-height: 42px; }
  .lab-main { padding: 14px 11px calc(100px + var(--mobile-safe-bottom)); }
  .lab-main > .card, .lab-main > section { border-radius: 14px; }
  .browse-heading { align-items: flex-start; flex-direction: column; gap: .4rem; }
  .artist-grid { grid-template-columns: minmax(0, 1fr); gap: 9px; }
  .artist-card { padding: 11px; }
  .library-search { gap: 8px; }
  .library-search input[type="search"] { min-height: 44px; font-size: 16px; }
  .library-search .btn { min-height: 42px; }
  .empty-search { overflow-wrap: anywhere; }
  .lab-player-frame { height: calc(100svh - 20px); max-height: 900px; border-radius: 14px; }
  .lab-config-frame { width: 100%; }
  body.lab-mini-open .lab-main { padding-bottom: calc(112px + var(--mobile-safe-bottom)); }
}

@media (max-width: 420px) {
  .sparrow-brand__text small { display: none; }
  .sparrow-brand__text strong { letter-spacing: .025em; }
  .header-actions { display: flex; }
  .header-actions .btn { padding: 8px 9px; }
  .lab-main { padding-left: 9px; padding-right: 9px; }
  .album-grid { gap: 8px; }
  .artist-avatar { flex-basis: 46px; width: 46px; height: 46px; }
}

@media (hover: none) and (pointer: coarse) {
  .btn, .icon-btn, .lab-nav a, .mini-control { -webkit-tap-highlight-color: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}


/* Sparrow-Fy Stage 8: user-selectable color themes. Album-card structure and
   context-menu JavaScript remain untouched; only presentation colors change. */
.theme-menu { position:relative; z-index:10001; margin:5px 0 0; }
.theme-menu > summary { display:flex; align-items:center; gap:11px; padding:11px 12px; min-height:42px; border-radius:9px; cursor:pointer; list-style:none; color:var(--muted); font-size:.9rem; user-select:none; }
.theme-menu > summary::-webkit-details-marker { display:none; }
.theme-menu > summary::after { content:'⌄'; margin-left:auto; opacity:.75; }
.theme-menu[open] > summary { color:var(--text); background:var(--surface-raised); }
.theme-menu__panel { position:fixed; z-index:10000; left:calc(100% + 12px); bottom:0; width:270px; max-width:min(300px, calc(100vw - 28px)); padding:12px; border:1px solid var(--border); border-radius:15px; background:var(--card); color:var(--text); box-shadow:0 18px 48px #0005; }
.theme-menu__title { margin:3px 5px 10px; font-size:.88rem; font-weight:800; }
.theme-choice { display:flex; align-items:center; gap:10px; width:100%; padding:9px; border:1px solid transparent; border-radius:10px; text-align:left; background:transparent; color:var(--text); cursor:pointer; }
.theme-choice:hover, .theme-choice:focus-visible { background:var(--surface-raised); outline:2px solid var(--primary); outline-offset:1px; }
.theme-choice[aria-pressed="true"] { border-color:var(--primary); background:var(--surface-raised); }
.theme-choice > span:nth-child(2) { display:flex; flex:1; min-width:0; flex-direction:column; gap:2px; }
.theme-choice strong { font-size:.82rem; }
.theme-choice small { color:var(--muted); font-size:.72rem; }
.theme-check { opacity:0; color:var(--primary); font-weight:900; }
.theme-choice[aria-pressed="true"] .theme-check { opacity:1; }
.theme-swatch { flex:0 0 31px; width:31px; height:31px; border:1px solid #ffffff2b; border-radius:9px; background:linear-gradient(135deg,var(--swatch-a),var(--swatch-b)); box-shadow:inset 0 0 0 4px #00000010; }
.swatch-dark-teal { --swatch-a:#061013; --swatch-b:#17c7a5; }
.swatch-dark-blue { --swatch-a:#0b1222; --swatch-b:#4f8cff; }
.swatch-dark-purple { --swatch-a:#171023; --swatch-b:#b58aff; }
.swatch-light { --swatch-a:#f8fafc; --swatch-b:#64748b; }
.swatch-light-sand { --swatch-a:#fffaf0; --swatch-b:#b77936; }
.swatch-solarized { --swatch-a:#002b36; --swatch-b:#b58900; }
.swatch-monokai { --swatch-a:#272822; --swatch-b:#a6e22e; }
.swatch-deep-black { --swatch-a:#000000; --swatch-b:#36d7ff; }
.swatch-ruby-blue { --swatch-a:#0b1f33; --swatch-b:#ff5d73; }
.theme-menu__note { margin:9px 5px 2px; color:var(--muted); font-size:.7rem; line-height:1.4; }

html[data-theme="dark-blue"] { --bg:#080f1d; --card:#111c30; --border:#263956; --text:#f1f6ff; --muted:#a2b3ce; --primary:#5794ff; --primary-dim:#326bd0; --accent:#8eb8ff; --surface-raised:#172842; }
html[data-theme="dark-purple"] { --bg:#100b19; --card:#1b1428; --border:#382747; --text:#fbf5ff; --muted:#b8a9c9; --primary:#b58aff; --primary-dim:#8053c6; --accent:#e0c0ff; --surface-raised:#261a35; }
html[data-theme="light"] { --bg:#eef2f6; --card:#ffffff; --border:#d4dde7; --text:#17212b; --muted:#596979; --primary:#0c8b78; --primary-dim:#087060; --accent:#8a641f; --surface-raised:#e5edf2; color-scheme:light; }
html[data-theme="light-sand"] { --bg:#f4f0e7; --card:#fffaf1; --border:#e2d5bd; --text:#30291f; --muted:#746858; --primary:#9a632c; --primary-dim:#75471e; --accent:#8a5a22; --surface-raised:#eee3d0; color-scheme:light; }
html[data-theme="dark-teal"] { color-scheme:dark; }
html[data-theme="dark-blue"], html[data-theme="dark-purple"] { color-scheme:dark; }

html[data-theme="dark-blue"] body { background:radial-gradient(ellipse at 75% -20%,#162b52 0,transparent 42%),var(--bg); }
html[data-theme="dark-purple"] body { background:radial-gradient(ellipse at 75% -20%,#38204c 0,transparent 42%),var(--bg); }
html[data-theme="light"] body, html[data-theme="light-sand"] body { background:var(--bg); }
html[data-theme="dark-blue"] .lab-header, html[data-theme="dark-blue"] .lab-nav { background:rgba(8,15,29,.94); border-color:#263956; }
html[data-theme="dark-purple"] .lab-header, html[data-theme="dark-purple"] .lab-nav { background:rgba(16,11,25,.94); border-color:#382747; }
html[data-theme="dark-blue"] .lab-nav a.active, html[data-theme="dark-blue"] .lab-nav a:hover { background:linear-gradient(100deg,#214f9b,#19365e); }
html[data-theme="dark-purple"] .lab-nav a.active, html[data-theme="dark-purple"] .lab-nav a:hover { background:linear-gradient(100deg,#65409a,#39254f); }
html[data-theme="dark-blue"] .btn.primary { background:linear-gradient(135deg,#5794ff,#3677e8); border-color:#326bd0; color:#07152b; }
html[data-theme="dark-purple"] .btn.primary { background:linear-gradient(135deg,#c09aff,#9b6fe2); border-color:#8053c6; color:#211034; }
html[data-theme="dark-blue"] .lab-nav a.active .nav-icon, html[data-theme="dark-blue"] .lab-nav a:hover .nav-icon, html[data-theme="dark-blue"] .eyebrow { color:#8eb8ff; }
html[data-theme="dark-purple"] .lab-nav a.active .nav-icon, html[data-theme="dark-purple"] .lab-nav a:hover .nav-icon, html[data-theme="dark-purple"] .eyebrow { color:#e0c0ff; }

/* Additional editor-inspired palettes: Solarized, Monokai, Deep Black and Ruby Blue. */
html[data-theme="solarized"] { --bg:#002b36; --card:#073642; --border:#31545b; --text:#fdf6e3; --muted:#aabfc1; --primary:#2aa198; --primary-dim:#268b83; --accent:#b58900; --surface-raised:#0b414d; color-scheme:dark; }
html[data-theme="monokai"] { --bg:#272822; --card:#1e1f1c; --border:#49483e; --text:#f8f8f2; --muted:#b7b7a8; --primary:#a6e22e; --primary-dim:#7aa51f; --accent:#f92672; --surface-raised:#383930; color-scheme:dark; }
html[data-theme="deep-black"] { --bg:#000000; --card:#0b0b0b; --border:#303030; --text:#f5f5f5; --muted:#b5b5b5; --primary:#36d7ff; --primary-dim:#1299ba; --accent:#ffcc66; --surface-raised:#171717; color-scheme:dark; }
html[data-theme="ruby-blue"] { --bg:#0b1f33; --card:#102b45; --border:#294b69; --text:#e8f1ff; --muted:#a9bfd8; --primary:#ff5d73; --primary-dim:#cf4057; --accent:#7fc8ff; --surface-raised:#183a59; color-scheme:dark; }
html[data-theme="solarized"] body { background:radial-gradient(ellipse at 75% -20%,#0b414d 0,transparent 42%),var(--bg); }
html[data-theme="monokai"] body { background:radial-gradient(ellipse at 75% -20%,#3d3e31 0,transparent 42%),var(--bg); }
html[data-theme="ruby-blue"] body { background:radial-gradient(ellipse at 75% -20%,#163d5d 0,transparent 42%),var(--bg); }
html[data-theme="solarized"] .lab-header, html[data-theme="solarized"] .lab-nav { background:rgba(0,43,54,.96); border-color:var(--border); }
html[data-theme="monokai"] .lab-header, html[data-theme="monokai"] .lab-nav { background:rgba(39,40,34,.96); border-color:var(--border); }
html[data-theme="deep-black"] .lab-header, html[data-theme="deep-black"] .lab-nav { background:rgba(0,0,0,.97); border-color:var(--border); }
html[data-theme="ruby-blue"] .lab-header, html[data-theme="ruby-blue"] .lab-nav { background:rgba(11,31,51,.96); border-color:var(--border); }
html[data-theme="solarized"] .card, html[data-theme="solarized"] .artist-card, html[data-theme="solarized"] .album-card { background:linear-gradient(145deg,#073642,#052e38); border-color:var(--border); color:var(--text); }
html[data-theme="monokai"] .card, html[data-theme="monokai"] .artist-card, html[data-theme="monokai"] .album-card { background:linear-gradient(145deg,#303127,#1e1f1c); border-color:var(--border); color:var(--text); }
html[data-theme="deep-black"] .card, html[data-theme="deep-black"] .artist-card, html[data-theme="deep-black"] .album-card { background:#090909; border-color:var(--border); color:var(--text); }
html[data-theme="ruby-blue"] .card, html[data-theme="ruby-blue"] .artist-card, html[data-theme="ruby-blue"] .album-card { background:linear-gradient(145deg,#102b45,#0b2035); border-color:var(--border); color:var(--text); }
html[data-theme="solarized"] .lab-nav a.active, html[data-theme="solarized"] .lab-nav a:hover { background:linear-gradient(100deg,#126d69,#0b414d); color:#fdf6e3; }
html[data-theme="monokai"] .lab-nav a.active, html[data-theme="monokai"] .lab-nav a:hover { background:linear-gradient(100deg,#596b1f,#3b4123); color:#f8f8f2; }
html[data-theme="deep-black"] .lab-nav a.active, html[data-theme="deep-black"] .lab-nav a:hover { background:linear-gradient(100deg,#252525,#111); color:#fff; }
html[data-theme="ruby-blue"] .lab-nav a.active, html[data-theme="ruby-blue"] .lab-nav a:hover { background:linear-gradient(100deg,#8f2948,#183d5c); color:#fff; }
html[data-theme="solarized"] .btn.primary { background:linear-gradient(135deg,#2aa198,#167d78); color:#fdf6e3; border-color:#268b83; }
html[data-theme="monokai"] .btn.primary { background:linear-gradient(135deg,#a6e22e,#78a51e); color:#1e1f1c; border-color:#7aa51f; }
html[data-theme="deep-black"] .btn.primary { background:linear-gradient(135deg,#36d7ff,#1299ba); color:#001014; border-color:#1299ba; }
html[data-theme="ruby-blue"] .btn.primary { background:linear-gradient(135deg,#ff5d73,#d83b59); color:#fff; border-color:#cf4057; }
html[data-theme="solarized"] .library-search, html[data-theme="solarized"] .top-search, html[data-theme="solarized"] .library-search input[type="search"] { background:#073642; color:var(--text); border-color:var(--border); }
html[data-theme="monokai"] .library-search, html[data-theme="monokai"] .top-search, html[data-theme="monokai"] .library-search input[type="search"] { background:#1e1f1c; color:var(--text); border-color:var(--border); }
html[data-theme="deep-black"] .library-search, html[data-theme="deep-black"] .top-search, html[data-theme="deep-black"] .library-search input[type="search"] { background:#080808; color:var(--text); border-color:var(--border); }
html[data-theme="ruby-blue"] .library-search, html[data-theme="ruby-blue"] .top-search, html[data-theme="ruby-blue"] .library-search input[type="search"] { background:#102b45; color:var(--text); border-color:var(--border); }
html[data-theme="solarized"] .theme-menu__panel, html[data-theme="monokai"] .theme-menu__panel, html[data-theme="deep-black"] .theme-menu__panel, html[data-theme="ruby-blue"] .theme-menu__panel { box-shadow:0 18px 48px #0008; }

/* Light themes override hard-coded dark surfaces without changing component behavior. */
html[data-theme="light"] body, html[data-theme="light-sand"] body { color:var(--text); }
html[data-theme="light"] .lab-header, html[data-theme="light"] .lab-nav { background:rgba(255,255,255,.94); border-color:var(--border); }
html[data-theme="light-sand"] .lab-header, html[data-theme="light-sand"] .lab-nav { background:rgba(255,250,241,.96); border-color:var(--border); }
html[data-theme="light"] .sparrow-brand__text strong, html[data-theme="light-sand"] .sparrow-brand__text strong { color:var(--accent); }
html[data-theme="light"] .sparrow-brand__text small, html[data-theme="light-sand"] .sparrow-brand__text small { color:var(--muted); }
html[data-theme="light"] .top-search, html[data-theme="light"] .library-search { background:#f3f6f9; border-color:var(--border); color:var(--muted); }
html[data-theme="light-sand"] .top-search, html[data-theme="light-sand"] .library-search { background:#f6eddd; border-color:var(--border); color:var(--muted); }
html[data-theme="light"] .top-search input, html[data-theme="light"] .library-search input[type="search"], html[data-theme="light-sand"] .top-search input, html[data-theme="light-sand"] .library-search input[type="search"] { background:transparent; color:var(--text); }
html[data-theme="light"] .lab-nav a, html[data-theme="light-sand"] .lab-nav a { color:var(--muted); }
html[data-theme="light"] .lab-nav a.active, html[data-theme="light"] .lab-nav a:hover { color:#fff; background:linear-gradient(100deg,#0c8b78,#086d62); }
html[data-theme="light-sand"] .lab-nav a.active, html[data-theme="light-sand"] .lab-nav a:hover { color:#fffaf1; background:linear-gradient(100deg,#9a632c,#75471e); }
html[data-theme="light"] .nav-section-label, html[data-theme="light-sand"] .nav-section-label { color:var(--muted); }
html[data-theme="light"] .nav-divider, html[data-theme="light-sand"] .nav-divider { background:var(--border); }
html[data-theme="light"] .card, html[data-theme="light"] .artist-card, html[data-theme="light"] .library-track-table tbody tr, html[data-theme="light"] .album-card { background:#fff; border-color:var(--border); box-shadow:0 8px 24px #25364a12; }
html[data-theme="light-sand"] .card, html[data-theme="light-sand"] .artist-card, html[data-theme="light-sand"] .library-track-table tbody tr, html[data-theme="light-sand"] .album-card { background:#fffaf1; border-color:var(--border); box-shadow:0 8px 24px #5e472012; }
html[data-theme="light"] .library-track-table th { background:#e8eef4; color:#405365; }
html[data-theme="light-sand"] .library-track-table th { background:#eee3d0; color:#5f4c36; }
html[data-theme="light"] .library-track-table td, html[data-theme="light"] .track-table-wrap, html[data-theme="light-sand"] .library-track-table td, html[data-theme="light-sand"] .track-table-wrap { border-color:var(--border); }
html[data-theme="light"] .artist-card, html[data-theme="light-sand"] .artist-card { color:var(--text); }
html[data-theme="light"] .artist-card-copy small, html[data-theme="light"] .library-track-table td small, html[data-theme="light"] .track-number { color:var(--muted); }
html[data-theme="light-sand"] .artist-card-copy small, html[data-theme="light-sand"] .library-track-table td small, html[data-theme="light-sand"] .track-number { color:var(--muted); }
html[data-theme="light"] .icon-btn { color:var(--text); }
html[data-theme="light-sand"] .icon-btn { color:var(--text); }
html[data-theme="light"] .icon-btn:hover { background:#e5edf2; border-color:var(--border); color:#0c8b78; }
html[data-theme="light-sand"] .icon-btn:hover { background:#eee3d0; border-color:var(--border); color:#9a632c; }
html[data-theme="light"] .btn:not(.primary), html[data-theme="light-sand"] .btn:not(.primary) { background:var(--surface-raised); color:var(--text); border-color:var(--border); }
html[data-theme="light"] .btn.primary { background:linear-gradient(135deg,#0c9e87,#087060); color:white; border-color:#087060; }
html[data-theme="light-sand"] .btn.primary { background:linear-gradient(135deg,#b77936,#8d5626); color:white; border-color:#75471e; }
html[data-theme="light"] .theme-menu__panel, html[data-theme="light-sand"] .theme-menu__panel { box-shadow:0 18px 48px #0002; }
html[data-theme="light"] .nav-brand-note, html[data-theme="light-sand"] .nav-brand-note { color:var(--muted); border-color:var(--border); }
html[data-theme="light"] .empty-search, html[data-theme="light-sand"] .empty-search { color:var(--text); }
html[data-theme="light"] .muted, html[data-theme="light-sand"] .muted { color:var(--muted); }

@media (max-width:720px) {
  .theme-menu { flex:0 0 auto; }
  .theme-menu > summary { padding:9px 11px; white-space:nowrap; }
  .theme-menu__panel { position:fixed; left:12px; right:12px; bottom:calc(12px + env(safe-area-inset-bottom, 0px)); width:auto; max-width:none; z-index:10000; }
}

/* Shared theme polish for secondary pages that also load lab.css. */
html[data-theme="light"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
html[data-theme="light"] select, html[data-theme="light"] textarea,
html[data-theme="light-sand"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
html[data-theme="light-sand"] select, html[data-theme="light-sand"] textarea { background:var(--card); color:var(--text); border-color:var(--border); }
html[data-theme="light"] code, html[data-theme="light"] pre,
html[data-theme="light-sand"] code, html[data-theme="light-sand"] pre { background:var(--surface-raised); color:var(--text); }
html[data-theme="light"] .notice { background:#dcfce7; color:#166534; }
html[data-theme="light-sand"] .notice { background:#f3e5c8; color:#67461f; }
html[data-theme="light"] .protected-account-note, html[data-theme="light-sand"] .protected-account-note { color:var(--text); }
html[data-theme="light"] .cp-ok { background:#dcfce7; color:#166534; }
html[data-theme="light-sand"] .cp-ok { background:#f3e5c8; color:#67461f; }

/* Sparrow-Fy Stage 16b: ensanchar SOLO el modal de Configuración en escritorio.
   El iframe de configuración antes quedaba limitado a 720px, por debajo
   del breakpoint de 850px de la cuadrícula interior de Stage 16. */
@media (min-width: 900px) {
  .lab-config-host .lab-config-bar,
  .lab-config-host .lab-config-frame {
    width: min(1100px, calc(100vw - 32px));
    max-width: none;
    box-sizing: border-box;
  }
  .lab-config-host .lab-config-frame {
    min-width: 0;
  }
  body.config-embed .lab-main {
    max-width: none;
    width: 100%;
    box-sizing: border-box;
    padding: 14px 16px 28px;
  }
}
