@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* Variables de diseño unificadas y homologadas */
:root {
  /* Colores - Modo Claro (Por Defecto) */
  --color-bg: #ffffff;
  --color-bg-alt: #fcfcfc;
  --color-text-main: #000000;
  --color-text-muted: #8e8e93;
  --color-border: #f2f2f7; /* Gris iOS ultra suave */
  --color-hover: #f4f4f5;
  --color-system-bg: #000000; /* Fondo detrás de la app siempre negro para ocultar los bordes de pantalla */
  --color-shadow: rgba(0, 0, 0, 0.03);
  --color-shadow-play: rgba(0, 0, 0, 0.08);

  /* Tipografía */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-size-title: 1.05rem;
  --font-size-normal: 0.875rem;
  --font-size-small: 0.75rem;
  --font-size-input: 0.85rem;

  /* Pesos de fuente */
  --font-weight-light: 300;
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Redondeado de esquinas */
  --radius-sm: 4px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 9999px;

  /* Transiciones */
  --transition-normal: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-elastic: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  transition: var(--transition-normal);
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--color-system-bg);
  color: var(--color-text-main);
  font-family: var(--font-family);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  touch-action: manipulation;
}

input, textarea {
  user-select: text !important;
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
}

/* Tipografía Controlada - Clases de Utilidad Homologadas */
.txt-title {
  font-size: var(--font-size-title);
  font-weight: var(--font-weight-semibold);
  letter-spacing: -0.02em;
  color: var(--color-text-main);
  line-height: 1.25;
}

.txt-normal {
  font-size: var(--font-size-normal);
  font-weight: var(--font-weight-regular);
  color: var(--color-text-main);
  line-height: 1.4;
}

.txt-small {
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-muted);
  line-height: 1.3;
}

.txt-muted {
  color: var(--color-text-muted);
}

/* Contenedor Principal */
.app-container {
  width: 100%;
  max-width: 390px;
  height: 84vh;
  max-height: 780px;
  background-color: var(--color-bg);
  border-radius: 32px;
  box-shadow: 0 20px 40px var(--color-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.02);
  position: relative;
}

/* Área de contenido scrollable */
.content-area {
  flex: 1;
  overflow: hidden;
  padding: 28px 24px 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.content-area::-webkit-scrollbar {
  display: none; /* Interfaz limpia sin barras */
}

/* Panel de Controles inferior */
.bar-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  padding: 12px 24px 4px 24px;
}

/* Contenedor de la línea de tiempo */
.progress-wrapper {
  padding: 0 28px;
  width: 100%;
}

/* Barra inferior de Shuffle y Añadir */
.bar-bottom {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 40px;
  padding: 4px 24px 28px 24px;
}

/* Botones Nativos Desactivados y Personalizados */
button {
  background: none;
  border: none;
  cursor: pointer;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.btn-action {
  width: 44px;
  height: 44px;
  border: 1px solid var(--color-border);
  color: var(--color-text-main);
  background-color: var(--color-bg);
}

.btn-action:hover {
  background-color: var(--color-hover);
  transform: scale(1.04);
}

.btn-action:active {
  transform: scale(0.96);
}

/* Botones de la barra inferior: solo iconos flotantes sin fondo ni borde */
.bar-bottom .btn-action {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  color: var(--color-text-muted) !important;
  transition: color 0.2s, transform 0.2s;
}

.bar-bottom .btn-action:hover {
  color: var(--color-text-main) !important;
  background: none !important;
  transform: scale(1.1) !important;
}

.bar-bottom .btn-action:active {
  transform: scale(0.9) !important;
}

/* Estado activo/habilitado en verde sutil que respira (animación de pulso) */
@keyframes pulse-green {
  0% { opacity: 0.65; color: #98c379; }
  50% { opacity: 1; color: #a3e635; filter: drop-shadow(0 0 4px rgba(152, 195, 121, 0.7)); }
  100% { opacity: 0.65; color: #98c379; }
}

.bar-bottom .btn-action.active-btn {
  animation: pulse-green 2.5s infinite ease-in-out !important;
  color: #98c379 !important;
}

.btn-action svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Botones de acción activos en UI (ej. botón STT al voltear la tarjeta) */
.btn-action.active {
  background-color: var(--color-text-main) !important;
  color: var(--color-bg) !important;
}

.icon-small {
  width: 16px;
  height: 16px;
}

/* Botón de reproducción central - Icono destacado */
#play-btn {
  width: 54px;
  height: 54px;
  background-color: var(--color-text-main);
  color: var(--color-bg);
  border-color: var(--color-text-main);
  box-shadow: 0 4px 12px var(--color-shadow-play);
}

#play-btn:hover {
  background-color: #1c1c1e;
}

#play-btn svg {
  fill: var(--color-bg);
  stroke: var(--color-bg);
  width: 20px;
  height: 20px;
}

/* Inputs y Cargas */
.input-custom {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  background-color: var(--color-bg);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--font-size-input);
  text-align: center;
  outline: none;
}

.input-custom:focus {
  border-color: var(--color-text-main);
  background-color: var(--color-bg);
}

/* Tarjeta del Reproductor "Now Playing" */
.player-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

/* 3D Flip Card */
.flip-card {
  background-color: transparent;
  width: 100%;
  aspect-ratio: 16/9;
  perspective: 1000px;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.flip-card.flipped .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.flip-card-front {
  background-color: #000000 !important;
  background-image: url('favicon.png');
  background-size: 60% !important; /* Rellenar el contenedor con tamaño adaptado y centrado */
  background-position: center !important;
  background-repeat: no-repeat !important;
  border: 1px solid var(--color-border);
}

.flip-card-back {
  background-color: var(--color-bg-alt);
  border: 1px solid var(--color-text-main);
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  padding: 20px;
  text-align: left;
}

.thumbnail-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.visualizer-canvas {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 45%;
  pointer-events: none;
  z-index: 2;
}

.thumbnail-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.03); /* Previene bordes vacíos durante el desplazamiento */
  transition: transform 0.5s ease;
}

/* Solo animar la carátula cuando se está reproduciendo */
.app-container.playing .thumbnail-img {
  animation: kenburns 22s ease-in-out infinite alternate;
}

@keyframes kenburns {
  0% {
    transform: scale(1.03) translate(0, 0);
  }
  50% {
    transform: scale(1.14) translate(-2%, -1%);
  }
  100% {
    transform: scale(1.03) translate(1%, -2%);
  }
}

.player-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  overflow: hidden;
  position: relative;
  height: 36px;
  padding-right: 48px; /* Espacio reservado a la derecha para el botón de buscar */
  box-sizing: border-box;
}

.player-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex: 1;
  min-width: 0;
  gap: 12px;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.player-info.searching .player-title-row {
  opacity: 0;
  transform: translateX(-10px);
  pointer-events: none;
}

.player-info .txt-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

.player-info #current-track-time {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* Transcripción (STT) Estilo Subtítulos */
.stt-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: space-between;
}

.stt-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.stt-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-text-muted);
}

.stt-dot.active {
  background-color: var(--color-text-main);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { opacity: 0.4; }
  50% { opacity: 1; }
  100% { opacity: 0.4; }
}

.stt-content-box {
  flex: 1;
  overflow-y: auto;
  font-size: var(--font-size-small);
  line-height: 1.4;
}

.stt-content-box p {
  white-space: pre-wrap;
}

.stt-content-box::-webkit-scrollbar {
  display: none;
}

.stt-empty-msg {
  font-style: italic;
  opacity: 0.7;
}

/* Sección Canciones / Buscador */
.library-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}



.search-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  height: 36px;
  width: 36px;
  padding: 0;
  transition: var(--transition-elastic);
  overflow: hidden;
  position: absolute;
  right: 0;
  top: 0;
  box-sizing: border-box;
}

.search-wrapper.active {
  width: 100%;
  border-color: var(--color-text-main);
  padding: 0 0 0 12px;
}

.search-input {
  flex: 1;
  border: none;
  background: none;
  color: var(--color-text-main);
  font-family: inherit;
  font-size: var(--font-size-input);
  padding: 0;
  width: 0;
  opacity: 0;
  transition: opacity 0.2s ease;
  outline: none;
}

.search-wrapper.active .search-input {
  opacity: 1;
  padding-right: 8px;
}

#search-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: var(--color-text-main);
  flex-shrink: 0;
}

/* Contenedor de canciones */
.list-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  padding: 0 0 12px 0;
}

.list-container::-webkit-scrollbar {
  display: none;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}

.list-item-text {
  flex: 1;
  min-width: 0;
  cursor: pointer;
  margin-right: 8px;
  position: relative;
}

/* Tooltip flotante global (Portal) que previene desbordamientos y recortes */
.custom-tooltip {
  position: fixed;
  background-color: var(--color-text-main);
  color: var(--color-bg);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: var(--font-size-small);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  box-shadow: 0 4px 12px var(--color-shadow-play);
  z-index: 9999;
  transform: translate(-50%, -100%) translateY(-6px);
}

.custom-tooltip.active {
  opacity: 1;
  transform: translate(-50%, -100%) translateY(-10px);
}

.list-item-text .txt-normal {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.list-item:last-child {
  border-bottom: none;
}

.list-item:hover {
  opacity: 0.8;
}

.list-item.active {
  font-weight: var(--font-weight-semibold);
}

.list-item.active .txt-normal {
  font-weight: var(--font-weight-semibold);
  letter-spacing: -0.01em;
}

/* Contenedores de botones de acción en cada fila */
.list-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Botón de descarga para offline */
.btn-download {
  width: 24px;
  height: 24px;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.4;
  transition: var(--transition-normal);
}

.list-item:hover .btn-download {
  opacity: 1;
}

.btn-download:hover {
  color: var(--color-text-main);
  background-color: var(--color-hover);
}

.btn-download.downloaded {
  color: #34c759 !important; /* Verde sutil de iOS */
  opacity: 0.9 !important;
  cursor: pointer;
}

.btn-download.downloaded:hover {
  background-color: rgba(52, 199, 89, 0.1);
  transform: scale(1.15);
}

.btn-download.downloading {
  opacity: 1 !important;
  color: var(--color-text-main);
}

.btn-download.error {
  color: #ff3b30 !important; /* Rojo sutil iOS */
  opacity: 1 !important;
  animation: blink-red 0.5s ease-in-out 3;
}

@keyframes blink-red {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; transform: scale(1.15); }
}

/* Botón eliminar ultra minimalista */
.btn-remove {
  width: 24px;
  height: 24px;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.4;
  transition: var(--transition-normal);
}

.list-item:hover .btn-remove {
  opacity: 1;
}

.btn-remove:hover {
  color: var(--color-text-main);
  background-color: var(--color-hover);
}

.btn-download svg,
.btn-remove svg {
  width: 14px;
  height: 14px;
}

/* Animación del cargador de descarga */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Menú de Carga Colapsable */
.upload-menu {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--color-bg);
  z-index: 10;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.4s;
  overflow: hidden; /* Evitar que el contenedor general se desplace */
  visibility: hidden; /* Ocultar completamente cuando está inactivo para evitar scroll accidental */
}

.upload-menu.active {
  transform: translateY(0);
  visibility: visible;
}

.menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid var(--color-border);
}

.menu-content {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  flex: 1;
  overflow-y: auto; /* Permitir scroll interno sutil en el contenido */
}

.menu-content-center {
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex: 1;
  overflow-y: auto;
  text-align: center;
}

.menu-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-section-title {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: var(--font-weight-bold);
  margin-bottom: 4px;
}

.menu-drop-zone {
  border: 1px dashed var(--color-border);
  padding: 36px 16px;
  text-align: center;
  border-radius: var(--radius-lg);
  background-color: var(--color-bg-alt);
  cursor: pointer;
  transition: var(--transition-normal);
}

.menu-drop-zone:hover {
  background-color: var(--color-hover);
  border-color: var(--color-text-main);
}

.menu-drop-zone.dragover {
  background-color: var(--color-hover);
  border-color: var(--color-text-main);
  border-style: solid;
}

.drop-zone-sub {
  margin-top: 4px;
}

/* Línea de tiempo / Barra de progreso sutil */
.progress-container {
  width: 100%;
  height: 4px;
  background-color: var(--color-border);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
  margin: 18px 0 10px 0;
}

/* Zona táctil y de hover expandida sin desalinear la línea de progreso */
.progress-container::after {
  content: '';
  position: absolute;
  top: -8px;
  bottom: -8px;
  left: 0;
  right: 0;
}

.progress-bar {
  height: 4px;
  width: 0%;
  background-color: var(--color-text-main);
  border-radius: 2px;
  pointer-events: none;
}

.progress-knob {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 8px;
  height: 8px;
  background-color: var(--color-text-main);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Mostrar la bolita al pasar el ratón o hacer click */
.progress-container:hover .progress-knob,
.progress-container:active .progress-knob {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.4);
}

/* Ocultar el iframe del player oficial de YouTube de manera no intrusiva */
.hidden-yt-player {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

/* Líneas de letra estilo Karaoke */
.lyrics-line {
  font-size: var(--font-size-normal);
  color: var(--color-text-muted);
  padding: 8px 0;
  transition: all 0.3s ease;
  transform-origin: left center;
  opacity: 0.4;
}

.lyrics-line.active {
  color: var(--color-text-main);
  font-weight: var(--font-weight-semibold);
  opacity: 1;
  transform: scale(1.04);
}

/* Buscador de YouTube en menú (consistente, alineado y sin encimar el botón) */
.menu-search-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.menu-search-field {
  flex: 1;
  display: flex;
  align-items: center;
  background-color: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  height: 44px; /* Misma altura que el botón para alineación perfecta */
  padding: 0 16px;
  box-sizing: border-box;
  transition: border-color 0.25s ease;
}

.menu-search-field:focus-within {
  border-color: var(--color-text-main);
}

.menu-search-field .search-input {
  width: 100%;
  border: none;
  background: none;
  color: var(--color-text-main);
  font-family: inherit;
  font-size: var(--font-size-input);
  outline: none;
  opacity: 1;
}

.youtube-search-results {
  max-height: 180px;
  overflow-y: auto;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.youtube-search-results::-webkit-scrollbar {
  display: none;
}

.yt-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: rgba(255, 255, 255, 0.03);
  padding: 6px 10px;
  border-radius: var(--radius-card);
  border: 1px solid var(--color-border);
  transition: background-color 0.2s ease;
}

.yt-result-item:hover {
  background-color: rgba(255, 255, 255, 0.06);
}

.yt-result-thumb {
  width: 48px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.yt-result-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.yt-result-title {
  font-size: var(--font-size-small) !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  margin: 0;
  color: var(--color-text-main);
}

.yt-result-channel {
  font-size: 11px !important;
  text-align: left;
  margin: 0;
  color: var(--color-text-muted);
}

.btn-add-result {
  width: 28px !important;
  height: 28px !important;
  border-radius: 50% !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.btn-add-result svg {
  width: 14px !important;
  height: 14px !important;
}

/* Responsividad para móviles / WebViews nativos: Pantalla completa y sin bordes */
@media (max-width: 768px) {
  html, body {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
    background-color: #000000 !important;
  }
  .app-container {
    max-width: 100% !important;
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    border: none !important;
  }
}

/* Soporte Dinámico de Modo Oscuro (se activa según la preferencia del sistema) */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #141419;          /* Fondo de tarjeta oscuro */
    --color-bg-alt: #1c1c24;      /* Fondo alternativo oscuro */
    --color-text-main: #ffffff;   /* Texto blanco */
    --color-text-muted: #8e92a4;  /* Texto gris atenuado */
    --color-border: rgba(255, 255, 255, 0.08); /* Borde oscuro suave */
    --color-hover: rgba(255, 255, 255, 0.04);
    --color-system-bg: #000000;   /* El canvas trasero sigue siendo negro puro */
    --color-shadow: rgba(0, 0, 0, 0.5);
    --color-shadow-play: rgba(0, 0, 0, 0.8);
  }
}

/* Layout adaptativo para pantallas grandes (Desktop Split Layout) */
@media (min-width: 769px) {
  body {
    background-color: #0d0e12 !important; /* Fondo oscuro detrás del reproductor en escritorio */
  }
  
  .app-container {
    display: grid !important;
    grid-template-columns: 460px 1fr !important; /* Columna izquierda más ancha para carátula prominente */
    grid-template-rows: auto 1fr auto auto auto !important; /* 5 filas: buscador, playlist, controles, progreso, barra_inferior */
    max-width: 1100px !important;
    width: 90% !important;
    height: 75vh !important;
    max-height: 780px !important;
    border-radius: 28px !important;
    border: 1px solid var(--color-border) !important;
    padding: 32px !important;
    gap: 20px 32px !important;
    box-sizing: border-box !important;
    background-color: var(--color-bg) !important;
  }

  /* Desvanecer contenedores intermedios para que sus hijos participen directamente del grid */
  .content-area,
  .player-card,
  .player-info {
    display: contents !important;
  }

  /* Columna Izquierda: Carátula e Info del video debajo */
  .flip-card {
    grid-column: 1 !important;
    grid-row: 1 / span 3 !important; /* Ocupa las primeras 3 filas de la izquierda */
    aspect-ratio: 1/1 !important;
    height: 380px !important;
    max-height: 380px !important;
    margin: 0 !important;
  }

  .player-title-row {
    grid-column: 1 !important;
    grid-row: 4 !important; /* Se posiciona debajo de la carátula */
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    margin-top: 8px !important;
  }

  /* Columna Derecha: Buscador arriba de la playlist (siempre expandido y fijo) */
  .search-wrapper {
    grid-column: 2 !important;
    grid-row: 1 !important;
    position: static !important;
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    background-color: var(--color-bg-alt) !important;
    border: 1px solid var(--color-border) !important;
    border-radius: var(--radius-pill) !important;
    height: 44px !important;
    padding: 0 16px !important;
    box-sizing: border-box !important;
  }

  .search-wrapper .search-input {
    width: 100% !important;
    opacity: 1 !important;
    flex: 1 !important;
    border: none !important;
    background: none !important;
    outline: none !important;
    padding: 0 !important;
  }

  .search-wrapper #search-toggle-btn {
    pointer-events: none !important; /* Deshabilitado ya que no necesita colapsar */
  }

  /* Playlist en columna derecha debajo del buscador */
  .library-wrapper {
    grid-column: 2 !important;
    grid-row: 2 !important;
    margin: 0 !important;
    height: 100% !important;
    overflow-y: auto !important;
  }

  /* Forzar visibilidad de scrollbars sutiles en pantallas grandes */
  .library-wrapper::-webkit-scrollbar,
  .youtube-search-results::-webkit-scrollbar,
  .list-container::-webkit-scrollbar,
  .stt-content-box::-webkit-scrollbar {
    display: block !important;
    width: 6px !important;
    height: 6px !important;
  }
  
  .library-wrapper::-webkit-scrollbar-track,
  .youtube-search-results::-webkit-scrollbar-track,
  .list-container::-webkit-scrollbar-track,
  .stt-content-box::-webkit-scrollbar-track {
    background: transparent !important;
  }
  
  .library-wrapper::-webkit-scrollbar-thumb,
  .youtube-search-results::-webkit-scrollbar-thumb,
  .list-container::-webkit-scrollbar-thumb,
  .stt-content-box::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15) !important;
    border-radius: 9999px !important;
  }
  
  .library-wrapper::-webkit-scrollbar-thumb:hover,
  .youtube-search-results::-webkit-scrollbar-thumb:hover,
  .list-container::-webkit-scrollbar-thumb:hover,
  .stt-content-box::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3) !important;
  }

  .bar-controls {
    grid-column: 2 !important;
    grid-row: 3 !important;
    padding: 4px 0 !important;
  }

  .progress-wrapper {
    grid-column: 2 !important;
    grid-row: 4 !important;
    padding: 0 !important;
  }

  .bar-bottom {
    grid-column: 1 / span 2 !important;
    grid-row: 5 !important;
    border-top: 1px solid var(--color-border) !important;
    padding-top: 16px !important;
    margin-top: 8px !important;
  }

  /* Mejorar la UX de la ventana Añadir Música en Escritorio transformándola en Modal Flotante */
  .upload-menu {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -30%) scale(0.95) !important;
    width: 480px !important;
    height: auto !important;
    max-height: 85vh !important;
    border-radius: 24px !important;
    border: 1px solid var(--color-border) !important;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4) !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    z-index: 100 !important;
    background-color: var(--color-bg-alt) !important;
    visibility: hidden !important; /* Deshabilitado por defecto */
  }

  .upload-menu.active {
    transform: translate(-50%, -50%) scale(1) !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    visibility: visible !important;
  }
}

/* Layout adaptativo para pantallas EXTRA grandes (TVs / Monitores Grandes) */
@media (min-width: 1200px) {
  .app-container {
    max-width: 1320px !important;
    width: 95% !important;
    height: 85vh !important;
    max-height: 840px !important;
    grid-template-columns: 520px 1fr !important; /* Carátula gigante 1:1 */
    gap: 24px 40px !important;
    padding: 40px !important;
    border-radius: 36px !important;
  }

  .player-card .flip-card {
    height: 440px !important;
    max-height: 440px !important;
  }

  /* Agrandar botones un 50% en pantallas extra grandes */
  .bar-controls .btn-action {
    transform: scale(1.5) !important;
    margin: 0 20px !important;
  }

  .bar-bottom .btn-action {
    transform: scale(1.4) !important;
  }

  /* Textos y tipografías aumentadas para excelente legibilidad a distancia */
  .txt-title {
    font-size: 1.35rem !important;
  }

  .txt-normal {
    font-size: 1.05rem !important;
  }

  .txt-small {
    font-size: 0.9rem !important;
  }
  
  .search-input {
    font-size: 1.05rem !important;
    padding: 10px 16px !important;
  }
}

/* Barra de scroll sutil para pantallas que no sean touch o en escritorios con mouse */
@media (hover: hover) and (pointer: fine) {
  .library-wrapper::-webkit-scrollbar,
  .youtube-search-results::-webkit-scrollbar,
  .list-container::-webkit-scrollbar,
  .stt-content-box::-webkit-scrollbar {
    display: block !important;
    width: 6px !important;
    height: 6px !important;
  }
  
  .library-wrapper::-webkit-scrollbar-track,
  .youtube-search-results::-webkit-scrollbar-track,
  .list-container::-webkit-scrollbar-track,
  .stt-content-box::-webkit-scrollbar-track {
    background: transparent !important;
  }
  
  .library-wrapper::-webkit-scrollbar-thumb,
  .youtube-search-results::-webkit-scrollbar-thumb,
  .list-container::-webkit-scrollbar-thumb,
  .stt-content-box::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15) !important;
    border-radius: 9999px !important;
    transition: background-color 0.2s ease !important;
  }
  
  .library-wrapper::-webkit-scrollbar-thumb:hover,
  .youtube-search-results::-webkit-scrollbar-thumb:hover,
  .list-container::-webkit-scrollbar-thumb:hover,
  .stt-content-box::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3) !important;
  }
}

/* Estilos premium para la sincronización y vinculación remota */
.sync-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
  gap: 16px;
  padding: 16px 0;
}

.sync-input {
  width: 100%;
  height: 52px;
  background-color: var(--color-bg-alt) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-pill) !important;
  color: var(--color-text-main) !important;
  text-align: center;
  font-family: inherit;
  font-size: 1.3rem;
  font-weight: bold;
  letter-spacing: 4px;
  text-transform: uppercase;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.sync-input:focus {
  border-color: rgba(255, 255, 255, 0.4) !important;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.08) !important;
}

.sync-submit-btn {
  width: 100%;
  height: 48px;
  border-radius: var(--radius-pill) !important;
  background: #000000 !important; /* Fondo negro sólido para móviles/apps */
  color: #ffffff !important; /* Texto blanco legible */
  border: 1px solid var(--color-border) !important;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: bold;
  letter-spacing: 1px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sync-submit-btn:active {
  transform: scale(0.98) !important;
  opacity: 0.9 !important;
}

/* Color verde para retroalimentación de sincronización activa en el botón de Cast */
.btn-action.active-cast {
  color: #98c379 !important;
}

/* Auditoría de Estilo: Elementos internos de vinculación homologados */
#cast-instructions-text {
  max-width: 320px !important;
  line-height: 1.4 !important;
  color: var(--color-text-muted) !important;
}

#cast-qr-container {
  background: #ffffff !important;
  padding: 12px !important;
  border-radius: 16px !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

#cast-code-text {
  font-size: 2rem !important;
  letter-spacing: 6px !important;
  margin: 10px 0 !important;
  font-weight: bold !important;
  color: var(--color-text-main) !important;
}
