:root {
  --bg-dark: #12151b;
  --bg-card: #1c212b;
  --bg-bar: #181d26;
  --text-main: #f0f3f8;
  --text-muted: #8b97a8;
  --accent: #ff2a85; /* Tomplay fuchsia */
  --accent-glow: rgba(255, 42, 133, 0.4);
  --accent-light: #ff60a8;
  --border: #2b3342;
  --green: #10b981;
  --yellow: #f59e0b;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --score-cursor-width: 3.5px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
}

.app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  position: relative;
}

/* ==========================================================================
   TOP BAR
   ========================================================================== */
.top-bar {
  height: 64px;
  background: var(--bg-bar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 20;
  flex-shrink: 0;
}

.top-left, .top-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.song-info-header {
  text-align: center;
  overflow: hidden;
  max-width: 50%;
}

.song-info-header h1 {
  font-size: 1.15rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.composer-subtitle {
  font-size: 0.82rem;
  color: var(--accent-light);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 10px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  transition: all 0.15s ease;
}

.btn-icon:hover, .btn-icon:active {
  background: var(--border);
  transform: translateY(-1px);
}

.btn-icon.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 12px var(--accent-glow);
}

/* ==========================================================================
   SCORE VIEWPORT (Lienzo blanco 100% limpio idéntico a Tomplay)
   ========================================================================== */
.score-viewport {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  background: #ffffff; /* Blanco puro para atril profesional */
  display: flex;
  justify-content: center;
  padding: 10px 0 160px 0;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.score-container {
  width: 100%;
  max-width: 1024px;
  background: #ffffff;
  display: block; /* Flujo vertical continuo sin colapso flex */
  padding: 0 16px 80px 16px;
}

/* Strip Wrapper: flujo continuo sin bordes de caja, fondo blanco y cursor contenido */
.score-strip {
  position: relative;
  background: #ffffff;
  border: none;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden; /* Cursor perfectamente contenido dentro del pentagrama */
  line-height: 0;
  margin: 0;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  width: 100%;
  min-height: 120px; /* Asegura altura completa de visualización */
}

.score-strip img {
  width: 100%;
  height: auto;
  display: block;
  background: #ffffff;
}

/* Playhead / Cursor (Identical to Tomplay's glowing cursor) */
.playhead-cursor {
  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--score-cursor-width);
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent), 0 0 20px var(--accent-glow);
  z-index: 10;
  pointer-events: none;
  transform: translateX(-50%);
  display: none;
  border-radius: 2px;
}

.playhead-cursor.visible {
  display: block;
}

/* Measure hover highlight */
.measure-highlight {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(255, 42, 133, 0.08);
  pointer-events: none;
  border-radius: 4px;
}

.score-loading-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: #4b5563;
  gap: 16px;
  font-size: 1.1rem;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid #e5e7eb;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   MODO PAPEL / SOLO BACKING TRACK DASHBOARD
   ========================================================================== */
.paper-dashboard {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 800px;
  margin: auto;
  padding: 20px;
}

.paper-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.paper-section-badge {
  background: rgba(255, 42, 133, 0.15);
  color: var(--accent-light);
  border: 1px solid var(--accent);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 20px;
}

.paper-measure-huge {
  font-size: 4.5rem;
  font-weight: 900;
  color: var(--text-main);
  letter-spacing: -0.02em;
  margin-bottom: 24px;
  font-family: var(--font-sans);
}

.beat-pulse-row {
  display: flex;
  gap: 16px;
  margin-bottom: 30px;
}

.beat-dot {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-bar);
  border: 2px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  font-family: var(--font-mono);
  transition: all 0.08s ease;
}

.beat-dot.active-beat {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: scale(1.18);
  box-shadow: 0 0 20px var(--accent-glow);
}

.paper-progress-bar-wrap {
  width: 100%;
  height: 8px;
  background: var(--bg-bar);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 16px;
}

.paper-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.1s linear;
}

.paper-info-row {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.paper-instructions {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
  border-top: 1px solid var(--border);
  padding-top: 16px;
  width: 100%;
}

/* ==========================================================================
   LOOP BANNER
   ========================================================================== */
.loop-banner {
  position: absolute;
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(28, 33, 43, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--accent);
  border-radius: 30px;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 15;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.loop-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.loop-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 1.5s infinite;
}

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

.btn-loop-point {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
}

.btn-loop-point strong {
  color: var(--accent-light);
}

.btn-text {
  background: transparent;
  border: none;
  color: #ef4444;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
}

/* ==========================================================================
   BOTTOM TRANSPORT BAR
   ========================================================================== */
.bottom-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 84px;
  background: rgba(24, 29, 38, 0.96);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 25;
}

.transport-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-transport {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 50%;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-play-main {
  width: 64px;
  height: 64px;
  background: var(--accent);
  border: none;
  color: #fff;
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn-play-main:hover, .btn-play-main:active {
  transform: scale(1.05);
  box-shadow: 0 0 28px rgba(255, 42, 133, 0.6);
}

.time-readout {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
}

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

.badge-measure {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 8px;
  color: var(--accent-light);
  font-size: 0.82rem;
  margin-left: 8px;
}

/* Solo Quick Mute */
.transport-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-quick-mute {
  background: var(--bg-card);
  border: 2px solid var(--green);
  color: var(--text-main);
  padding: 10px 20px;
  border-radius: 30px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn-quick-mute strong {
  color: var(--green);
}

.btn-quick-mute.sax-muted {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.btn-quick-mute.sax-muted strong {
  color: #ef4444;
}

/* Tempo Control */
.transport-right {
  display: flex;
  align-items: center;
}

.tempo-control-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 6px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 250px;
}

.tempo-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.bpm-badge {
  color: var(--accent-light);
  font-family: var(--font-mono);
  font-weight: 700;
}

.tempo-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-tempo-step, .btn-tempo-reset {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-tempo-reset {
  width: auto;
  padding: 0 6px;
  font-size: 0.7rem;
}

input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
  height: 5px;
}

/* ==========================================================================
   DRAWERS (Mezclador y Biblioteca)
   ========================================================================== */
.drawer {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 380px;
  max-width: 90vw;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 30;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.7);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.drawer-right {
  right: 0;
}

.drawer-left {
  left: 0;
  border-left: none;
  border-right: 1px solid var(--border);
}

.drawer.hidden {
  display: flex !important; /* override */
}

.drawer-right.hidden {
  transform: translateX(100%);
  pointer-events: none;
}

.drawer-left.hidden {
  transform: translateX(-100%);
  pointer-events: none;
}

.drawer-header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
}

.drawer-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
}

.drawer-search {
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.drawer-search input,
.drawer-search select {
  width: 100%;
  background: var(--bg-bar);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text-main);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s ease;
}

.drawer-search select {
  margin-top: 8px;
}

.drawer-search input:focus,
.drawer-search select:focus {
  border-color: var(--accent);
}

.drawer-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-bar);
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 12px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab-btn.active {
  color: var(--accent-light);
  border-bottom-color: var(--accent);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.drawer-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.4;
}

/* Mixer Track Item */
.mixer-track {
  background: var(--bg-bar);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}

.mixer-track-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.mixer-track-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.btn-mute-pill {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-mute-pill.muted {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
}

.mixer-slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.volume-val {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  width: 38px;
  text-align: right;
}

/* Song Card */
.song-card {
  background: var(--bg-bar);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.song-card:hover {
  border-color: var(--accent);
  background: rgba(255, 42, 133, 0.05);
}

.song-card.current {
  border-color: var(--accent);
  background: rgba(255, 42, 133, 0.1);
}

.song-thumb {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg-dark);
}

.song-details {
  flex: 1;
  overflow: hidden;
}

.song-details h4 {
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-details p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.song-badges-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.badge-status {
  display: inline-block;
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
}

.badge-status.ready {
  background: rgba(46, 213, 115, 0.15);
  color: #2ed573;
  border: 1px solid rgba(46, 213, 115, 0.3);
}

.badge-status.cloud {
  background: rgba(116, 125, 140, 0.15);
  color: #a4b0be;
  border: 1px solid rgba(116, 125, 140, 0.3);
}

.badge-level {
  display: inline-block;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

/* Backdrop */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 28;
}

.hidden {
  display: none !important;
}

/* Responsive adjustments for Tablet/iPad */
@media (max-width: 800px) {
  .btn-label { display: none; }
  .btn-quick-mute { padding: 8px 14px; font-size: 0.85rem; }
  .tempo-control-box { width: 170px; }
  .time-readout { font-size: 0.82rem; }
  .badge-measure { display: none; }
}
