/* ═══════════════════════════════════════════════════════════════════════════
   styles.css — Chords Master
   Tema oscuro, acentos ámbar. Mobile-first + adaptación escritorio.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --color-bg:           #0f0f0f;
  --color-surface:      #1a1a1a;
  --color-surface-2:    #232323;
  --color-border:       #333;
  --color-text:         #e8e8e8;
  --color-text-muted:   #888;
  --color-accent:       #f59e0b;   /* ámbar */
  --color-accent-dark:  #b45309;
  --color-accent-light: #fde68a;
  --color-danger:       #ef4444;
  --color-white-key:    #f5f5f5;
  --color-black-key:    #1c1c1c;
  --color-key-active:   #f59e0b;
  --color-key-bass:     #f97316;   /* naranja para el bajo */
  --color-key-pressed:  #d4d4d4;
  --color-scale-white:  #60a5faaa;   /* azul para notas de escala en teclas blancas */
  --color-scale-black:  #c084fcaa;   /* violeta para notas de escala en teclas negras */
  --color-scale-white-contrast:  #2065baaa;   /* azul para notas de escala en teclas blancas */
  --color-scale-black-contrast:  #60248caa;   /* violeta para notas de escala en teclas negras */

  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   14px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.5);
  --shadow-md: 0 4px 16px rgba(0,0,0,.6);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.75);

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Dimensiones del piano — bases (sin zoom) */
  --key-white-w-base: 38px;
  --key-white-h-base: 160px;
  --key-black-w-base: 24px;
  --key-black-h:      94px;

  /* Zoom del piano (1 = 100 %) — modificado por JS */
  --piano-zoom: 1;

  /* Dimensiones efectivas: base × zoom */
  --key-white-w: calc(var(--key-white-w-base) * var(--piano-zoom));
  --key-white-h: calc(var(--key-white-h-base) * var(--piano-zoom));
  --key-black-w: calc(var(--key-black-w-base) * var(--piano-zoom));

  /* Transiciones */
  --transition-fast: 80ms ease;
  --transition-mid:  180ms ease;
}

/* ── Reset mínimo ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; 
    /* margin: 0;  */
    padding: 0; 
}

/* El atributo [hidden] debe tener prioridad absoluta sobre cualquier display
   declarado en el CSS (p. ej. #favorites-panel { display: flex } lo sobreescribiría) */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  overflow: hidden;         /* Sin scroll en body; el scroll va dentro del piano */
  margin: 0 !important;
  padding: 0 !important;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

/* ── Layout principal ──────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;           /* dvh = dynamic viewport height (móvil) */
  position: relative;
  overflow: hidden;
}

#main-content {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;  /* las barras se anclan: chord arriba, transform abajo */
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

#app-footer {
  display: none; /* oculto en móvil */
}

/* ── Barra de título ───────────────────────────────────────────────────────── */
#top-bar {
  display: none; /* oculto en móvil; restaurado en escritorio */
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  z-index: 30;
}

#top-bar h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--color-accent);
}

/* ── Zona del piano ────────────────────────────────────────────────────────── */
#piano-area {
  flex: none;   /* altura fija; el centrado lo hace #main-content */
  height: calc(var(--key-white-h) + 8px);  /* 8px = padding-top del piano-container */
  position: relative;
  overflow: hidden;
  background: #0a0a0a;
  margin-top: auto;  /* centra verticalmente el piano si hay espacio extra */
  margin-bottom: auto;
}

/* Cuerpo del piano: fondo oscuro que enmarca el teclado */
#piano-container {
  width: 100%;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: relative;
  background: #0a0a0a;
  /* Sombra interior superior que simula el interior del piano */
  box-shadow: inset 0 10px 20px rgba(0,0,0,.85);
  padding-top: 8px;  /* espacio para que las teclas negras no queden cortadas arriba */
}
#piano-container::-webkit-scrollbar { display: none; }

.piano-keys-wrapper {
  display: flex;
  align-items: flex-start;  /* teclas blancas alineadas arriba */
  height: var(--key-white-h);  /* altura fija; nunca estira más allá de la proporción correcta */
  position: relative;       /* contexto de posicionamiento para las teclas negras */
}

/* ══════════════════════════════════════════════════════
   TECLAS BLANCAS — aspecto marfil con gradiente y sombra
   ══════════════════════════════════════════════════════ */
.piano-key--white {
  position: relative;
  flex-shrink: 0;
  width:  var(--key-white-w);
  height: var(--key-white-h);  /* usa la variable; nunca crece con el contenedor */

  /* Gradiente marfil: brillante en la parte superior, más apagado abajo */
  background: linear-gradient(
    to bottom,
    #fdfaf2 0%,
    #fff    8%,
    #fefcf6 35%,
    #f8f3e8 70%,
    #ede6d4 88%,
    #e0d8c3 100%
  );

  border-right: 1px solid #b8ae9e;  /* separador visible entre teclas */
  border-bottom: 3px solid #9e9282;
  border-radius: 0 0 5px 5px;

  /* Sombra lateral que da sensación de volumen */
  box-shadow:
    inset -2px 0   0  rgba(255,255,255,.7),
    inset  1px 0   0  rgba(0,0,0,.06),
    inset  0 -3px  5px rgba(0,0,0,.1),
    2px 6px 12px   rgba(0,0,0,.55);

  z-index: 1;
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 7px;
  outline: none;
  border-top: none;
  border-left: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 120ms ease, background 55ms ease, box-shadow 55ms ease, transform 55ms ease;
}

/* Franja oscura en la parte superior (simula el interior del piano) */
.piano-key--white::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background: linear-gradient(to bottom, rgba(0,0,0,.18), transparent);
  pointer-events: none;
}

/* Estado pulsada */
.piano-key--white:active,
.piano-key--white.piano-key--pressed {
  background: linear-gradient(
    to bottom,
    #e8e3d5 0%,
    #ede8da 15%,
    #f0eadc 55%,
    #e4dece 100%
  );
  box-shadow:
    inset -1px 0   0  rgba(255,255,255,.5),
    inset  0  4px  8px rgba(0,0,0,.18),
    1px 3px 6px rgba(0,0,0,.45);
  transform: perspective(300px) rotateX(2deg);
  transform-origin: top center;
}

/* Nota del acorde activa — ámbar */
.piano-key--white.piano-key--active {
  background: linear-gradient(
    to bottom,
    #fef3c7 0%,
    #fde68a 12%,
    #fbbf24 45%,
    #f59e0b 72%,
    #d97706 100%
  );
  border-right-color: #92400e;
  border-bottom-color: #78350f;
  box-shadow:
    inset -2px 0   0  rgba(255,255,255,.5),
    inset  0 -3px  6px rgba(120,53,15,.3),
    2px 6px 10px rgba(0,0,0,.55);
}

/* Nota de bajo — naranja */
.piano-key--white.piano-key--bass.piano-key--active {
  background: linear-gradient(
    to bottom,
    #ffedd5 0%,
    #fed7aa 10%,
    #fb923c 40%,
    #f97316 70%,
    #c2410c 100%
  );
  border-right-color: #7c2d12;
  border-bottom-color: #7c2d12;
}

/* Etiqueta de nota en tecla blanca */
.piano-key__label {
  font-size: 9px;
  color: #9a8f80;
  pointer-events: none;
  font-family: var(--font-mono);
  letter-spacing: -.02em;
  line-height: 1;
  user-select: none;
}
.piano-key--active .piano-key__label {
  color: rgba(0,0,0,.55);
  font-weight: 700;
}

/* ══════════════════════════════════════════════════════
   TECLAS NEGRAS — posicionadas absolutamente sobre las blancas
   ══════════════════════════════════════════════════════ */
.piano-key--black {
  position: absolute;   /* salen del flujo flex; quedan encima de las blancas */
  top: 0;
  width:  var(--key-black-w);
  height: 63%;              /* ~63% de la tecla blanca, proporción realista */

  /* Gradiente oscuro brillante: más gris en la parte superior */
  background: linear-gradient(
    168deg,
    #464646 0%,
    #2e2e2e 18%,
    #181818 48%,
    #0c0c0c 75%,
    #060606 100%
  );

  border: 1px solid #000;
  border-top: 2px solid #505050;  /* borde superior claro que simula el borde frontal */
  border-radius: 0 0 5px 5px;

  /* Sombra profunda que lo hace "flotar" sobre las blancas */
  box-shadow:
    0  9px 18px rgba(0,0,0,.95),
    0  4px  8px rgba(0,0,0,.7),
    inset  0  2px  0  rgba(255,255,255,.07),
    inset  1px 0   0  rgba(255,255,255,.04),
    inset -1px 0   0  rgba(255,255,255,.04);

  z-index: 2;
  cursor: pointer;
  outline: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 120ms ease, background 55ms ease, box-shadow 55ms ease, transform 55ms ease;
}

/* Reflejo brillante en la parte superior de la tecla negra */
.piano-key--black::after {
  content: '';
  position: absolute;
  top: 4px; left: 4px; right: 4px;
  height: 32%;
  background: linear-gradient(
    to bottom,
    rgba(255,255,255,.10) 0%,
    rgba(255,255,255,.03) 100%
  );
  border-radius: 2px;
  pointer-events: none;
}

/* Estado pulsada */
.piano-key--black:active,
.piano-key--black.piano-key--pressed {
  background: linear-gradient(
    168deg,
    #303030 0%,
    #1c1c1c 25%,
    #0e0e0e 60%,
    #050505 100%
  );
  box-shadow:
    0  4px  8px rgba(0,0,0,.85),
    inset 0  4px  8px rgba(0,0,0,.6);
  transform: translateY(2px);
}

/* Nota del acorde activa — ámbar */
.piano-key--black.piano-key--active {
  background: linear-gradient(
    168deg,
    #fef3c7 0%,
    #fcd34d 18%,
    #f59e0b 45%,
    #d97706 72%,
    #b45309 100%
  );
  border-top-color: #fef9e5;
  border-color: #78350f;
  box-shadow:
    0  7px 14px rgba(120,53,15,.65),
    0  3px  6px rgba(0,0,0,.5),
    inset 0  2px  0  rgba(255,255,255,.35);
}
.piano-key--black.piano-key--active::after {
  background: linear-gradient(
    to bottom,
    rgba(255,255,255,.25) 0%,
    rgba(255,255,255,.05) 100%
  );
}

/* Nota de bajo — naranja */
.piano-key--black.piano-key--bass.piano-key--active {
  background: linear-gradient(
    168deg,
    #ffedd5 0%,
    #fb923c 25%,
    #f97316 55%,
    #ea580c 78%,
    #9a3412 100%
  );
  border-color: #7c2d12;
  border-top-color: #fed7aa;
  box-shadow:
    0  7px 14px rgba(124,45,18,.65),
    0  3px  6px rgba(0,0,0,.5),
    inset 0  2px  0  rgba(255,255,255,.3);
}

/* ── Escalas: punto morado en teclas que pertenecen a la escala ────────────── */
/* Se usa ::after en blancas (::before ya está ocupado por la franja superior)    */
/* Se usa ::before en negras (::after ya está ocupado por el reflejo de brillo)   */
/* El punto se oculta cuando la tecla está activa (acorde) para no solaparse.     */

.piano-key--white.piano-key--scale::after {
  content: '';
  position: absolute;
  bottom: 20px;       /* justo por encima de la etiqueta de nota */
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 14px;
  background: var(--color-scale-white);
  border-radius: 50%;
  z-index: 3;
  pointer-events: none;
}

.piano-key--white.piano-key--scale.piano-key--active::after {
  border: 1px solid var(--color-scale-white-contrast);
}

.piano-key--black.piano-key--scale::before {
  content: '';
  position: absolute;
  bottom: 7px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  background: var(--color-scale-black);
  border-radius: 50%;
  z-index: 3;
  pointer-events: none;
}

.piano-key--black.piano-key--scale.piano-key--active::before {
  border: 1px solid var(--color-scale-black-contrast);
}
/* ── Panel de escalas ─────────────────────────────────────────────────────── */
.panel-scales {
  flex-direction: column;
  gap: 8px;
  max-height: 160px;
}
.scales-panel__roots {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.scales-panel__root-btn {
  font-size: 0.73rem;
  padding: 4px 6px;
  min-width: 30px;
  text-align: center;
  font-family: var(--font-mono);
}
.scales-panel__type-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.scales-panel__select {
  flex: 1;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: 0.8rem;
  padding: 5px 7px;
  cursor: pointer;
  outline: none;
}
.scales-panel__select:focus {
  border-color: var(--color-accent);
}
.scales-panel__clear {
  font-size: 0.75rem;
  padding: 5px 10px;
  white-space: nowrap;
}

/* ── Hint de edición ───────────────────────────────────────────────────────── */
#piano-edit-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: rgba(0,0,0,.8);
  color: var(--color-text);
  font-size: 0.8rem;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-mid), transform var(--transition-mid);
  white-space: nowrap;
  z-index: 20;
}
#piano-edit-hint.piano-edit-hint--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Barras de control ────────────────────────────────────────────────────── */

/* Barra de acorde: compacta, sobre el piano en móvil */
#chord-overlay {
  flex: 0 0 auto;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 0px;
}

/* Nombre del acorde integrado en la misma línea que el input */
#chord-overlay .chord-display {
  font-size: 1.1rem;
  margin-bottom: 0;
  min-height: auto;
  min-width: 5.5rem;
  text-align: center;
  flex-shrink: 0;
}

/* Fila de input ocupa el espacio restante */
#chord-overlay .chord-input-row {
  flex: 1;
  min-width: 0;
}

/* Selector desplegable de acordes predefinidos */
.chord-select {
  flex-shrink: 0;
  background: var(--color-surface-2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 5px 2px 5px 6px;
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}
.chord-select:focus {
  outline: none;
  border-color: var(--color-accent);
}


/* Barra de controles de transformación: debajo del piano */
#transform-overlay {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 8px 12px;
  pointer-events: auto;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}
#transform-overlay::-webkit-scrollbar { height: 4px; }
#transform-overlay::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 2px; }
/* Separador-expander en la barra de funciones */
.toolbar-sep {
  flex: 1 1 0;
  min-width: 0;
  align-self: stretch;
}

/* Siempre visible en la barra de acorde (ej: botón info) */
.chord-actions-always {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
}

/* ── Panel de favoritos ──────────────────────────────────────────────────── */
#favorites-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-bg);
}

/* Barra superior del modo favoritos */
#favorites-topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

#favorites-topbar-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-accent);
  letter-spacing: .03em;
}

.favorites-topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

/* Grid con scroll propio */
.favorites-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-auto-rows: 130px;
  gap: 8px;
  padding: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  align-content: start;
}

.favorite-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px 8px 8px;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  touch-action: manipulation;
  width: 100%;
  text-align: center;
}
.favorite-card:hover  { background: var(--color-surface-2); }
.favorite-card:active { background: #2e2e2e; }

.favorite-card__name {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-accent);
  pointer-events: none;
  word-break: break-word;
  line-height: 1.2;
}

.favorite-card__notes {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--color-text-muted);
  pointer-events: none;
  word-break: break-word;
  line-height: 1.3;
  text-align: center;
}

.favorite-card__heart {
  position: absolute;
  top: 4px;
  right: 4px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 3px 5px;
  color: var(--color-text-muted);
  transition: color var(--transition-fast), transform 100ms ease;
  border-radius: var(--radius-sm);
}
.favorite-card__heart.btn--favorite-active { color: #f59e0b; }
.favorite-card__heart:active { transform: scale(1.3); }

/* ── Drag-and-drop ───────────────────────────────────────────────────────── */
/* touch-action:none MUST be in CSS (not inline) so iOS sees it before pointerdown */
.favorite-card[data-fav-id] { cursor: grab; touch-action: none; }

/* Placeholder: marca el punto de inserción en el grid */
.favorite-card--placeholder {
  border: 2px dashed var(--color-accent);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-accent) 12%, transparent);
  animation: dnd-pulse 0.6s ease-in-out infinite alternate;
}
@keyframes dnd-pulse {
  from { opacity: 0.35; }
  to   { opacity: 1;    box-shadow: 0 0 12px var(--color-accent); }
}

/* Ghost: copia flotante de la tarjeta que sigue al cursor */
.dnd-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px 8px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0,0,0,0.6), 0 0 0 2px var(--color-accent);
  transform: scale(1.06);
  opacity: 0.92;
  text-align: center;
  font-family: inherit;
  color: inherit;
  overflow: hidden;
}
.dnd-ghost .favorite-card__heart { display: none; }

.btn--danger-hover:hover { color: var(--color-danger, #ef4444); border-color: var(--color-danger, #ef4444); }

.favorites-empty {
  grid-column: 1 / -1;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 24px 0;
}

/* Botón modo favoritos activo → acento ámbar */
#btn-favorites-mode[aria-pressed="true"],
#btn-favorites-mode.btn--active {
  color: var(--color-accent);
  border-color: var(--color-accent);
  background: rgba(245,158,11,.12);
}

/* Siempre visible en la barra de acorde (ej: botón info) */
.chord-actions-always {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
}

/* Botón favorito */
#btn-favorite {
  color: var(--color-text-muted);
  transition: color var(--transition-fast), transform 120ms ease;
}
#btn-favorite.btn--favorite-active {
  color: #f59e0b;
}
#btn-favorite[aria-pressed="true"] {
  color: #f59e0b;
}
#btn-favorite:not(:disabled):active {
  transform: scale(1.25);
}

/* ── Controles de zoom del piano ──────────────────────────────────────────── */
.piano-zoom-level {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  min-width: 2.8rem;
  text-align: center;
  font-family: var(--font-mono);
  pointer-events: none;
  flex-shrink: 0;
  line-height: 1;
}

#btn-scroll-lock {
  flex-shrink: 0;
  opacity: 0.45;
  transition: opacity 0.15s, color 0.15s;
}
#btn-scroll-lock[aria-pressed="true"],
#btn-scroll-lock.btn--active {
  opacity: 1;
  /* color: var(--color-accent); */
}

/* Piano bloqueado: impide scroll táctil/ratón pero permite scroll programático */
#piano-container.piano-container--locked {
  overflow-x: hidden;
}

/* ── Nombre del acorde ─────────────────────────────────────────────────────── */
.chord-display {
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: .04em;
  line-height: 1;
  margin-bottom: 8px;
  min-height: 1.8rem;
  font-family: var(--font-mono);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.chord-display--empty    { color: var(--color-text-muted); font-size: 1rem; }
.chord-display--recognized { color: var(--color-accent); }
.chord-display--custom   { color: var(--color-text-muted); font-size: 1.1rem; }

.chord-display__name { line-height: 1; }

/* Etiqueta de función armónica (pequeña, bajo el nombre del acorde) */
.chord-display__function {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  line-height: 1;
  opacity: 0.85;
}
.chord-display__function--tonic       { color: #4ade80; }  /* verde — reposo   */
.chord-display__function--subdominant { color: #60a5fa; }  /* azul — transición */
.chord-display__function--dominant    { color: #f87171; }  /* rojo — tensión   */
.chord-display__function--leading     { color: #c084fc; }  /* violeta — sensible */
.chord-display__function--suspended   { color: var(--color-text-muted); }

/* ── Fila de input ─────────────────────────────────────────────────────────── */
.chord-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.chord-input-row .chord-select, .chord-input-row .chord-input {
  flex-shrink: 0;
}

.chord-input {
  flex: 1;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: 0.9rem;
  padding: 7px 10px;
  outline: none;
  transition: border-color var(--transition-mid);
  font-family: var(--font-mono);
}
.chord-input:focus  { border-color: var(--color-accent); }
.chord-input--error { border-color: var(--color-danger) !important; }

/* ── Botones genéricos ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: 0.82rem;
  padding: 7px 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition-fast), border-color var(--transition-fast),
              color var(--transition-fast), opacity var(--transition-fast);
  touch-action: manipulation;
  font-family: var(--font-sans);
}

.btn:hover  { background: #2e2e2e; }
.btn:active { background: #3a3a3a; }

.btn--accent {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #000;
  font-weight: 600;
}
.btn--accent:hover  { background: var(--color-accent-light); }

.btn--active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #000;
  font-weight: 700;
}

.btn--icon {
  padding: 7px;
  font-size: 1rem;
  min-width: 36px;
}

.btn--disabled,
.btn:disabled {
  opacity: .38;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Fila de controles rápidos ─────────────────────────────────────────────── */
.controls-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Controles de transformación ───────────────────────────────────────────── */
.transform-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
/* Etiquetas: visibles solo en escritorio */
.transform-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  min-width: 64px;
  text-align: right;
  flex-shrink: 0;
  display: none;
}
.transform-disabled-msg {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-align: center;
  padding: 4px 0;
}

/* En dispositivos táctiles: eliminar efectos costosos de las teclas */
@media (hover: none) {
  #piano-container {
    contain: strict;          /* aislar repaint del resto del DOM */
  }
  .piano-keys-wrapper {
    will-change: transform;   /* elevar a capa composita para scroll suave */
  }
  /* Sin transiciones en teclas: evita repaints durante scroll y pulsación */
  .piano-key--white,
  .piano-key--black {
    transition: none;
  }
  /* Sin perspectiva 3D al pulsar: muy costosa en GPU móvil */
  .piano-key--white:active,
  .piano-key--white.piano-key--pressed {
    transform: none;
    box-shadow: inset 0 4px 10px rgba(0,0,0,.25);
  }
  .piano-key--black:active,
  .piano-key--black.piano-key--pressed {
    transform: none;
    box-shadow: 0 2px 6px rgba(0,0,0,.9);
  }
  /* Box-shadow simplificada en teclas blancas: de 4 capas a 1 */
  .piano-key--white {
    box-shadow: 2px 4px 8px rgba(0,0,0,.45);
  }
  /* Box-shadow simplificada en teclas negras: de 5 capas a 2 */
  .piano-key--black {
    box-shadow:
      0 6px 12px rgba(0,0,0,.9),
      inset 0 1px 0 rgba(255,255,255,.06);
  }
}

@media (max-width: 767px), (hover: none) {
  .transform-group {
    gap: 4px;
  }
}

/* ── Paneles desplegables (variaciones / relacionados) ─────────────────────── */
.panel-popup {
  position: fixed;
  bottom: 60px;   /* fallback; JS lo sobreescribe al abrir */
  left: 12px;
  right: 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 10px;
  max-height: 200px;
  overflow-y: auto;
  display: none;
  z-index: 50;
  box-shadow: var(--shadow-lg);
  flex-wrap: wrap;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}
.panel-popup.panel--open {
  display: flex;
}
.panel-empty {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  width: 100%;
  text-align: center;
  padding: 8px 0;
}

/* ── Botones de acorde (grids) ─────────────────────────────────────────────── */
.chord-btn {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: 0.78rem;
  padding: 5px 8px;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font-mono);
  transition: background var(--transition-fast), border-color var(--transition-fast);
  touch-action: manipulation;
}
.chord-btn:hover  { background: #2e2e2e; }
.chord-btn:active { background: #3a3a3a; }
.chord-btn--active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #000;
  font-weight: 700;
}

/* ── Sección de acordes predefinidos (escritorio) ──────────────────────────── */
#chords-section {
  display: none;   /* Oculto en móvil; visible en escritorio */
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  overflow-y: auto;
  max-height: 280px;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.chords-section__title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 4px;
}

.chords-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

/* ── Mensaje deshabilitado ──────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Separador de secciones ────────────────────────────────────────────────── */
.section-divider {
  width: 100%;
  height: 1px;
  background: var(--color-border);
  margin: 4px 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ESCRITORIO (≥ 768px)  —  layout CSS Grid
   ┌──────────────────────────────────────┐
   │           top-bar (2 cols)           │
   ├──────────────────────────────────────┤
   │         piano-area (2 cols)          │
   ├──────────────────────────────────────┤
   │        chord-overlay (2 cols)        │
   ├─────────────────┬─────────────────────┤
   │ transform-overlay │  chords-section  │
   └─────────────────┴─────────────────────┘
   ═══════════════════════════════════════════════════════════════════════════ */
@media (min-width: 768px) and (hover: hover) {
  :root {
    --key-white-w-base: 48px;
    --key-black-w-base: 30px;
    --key-white-h-base: 220px;
  }

  #top-bar { display: flex; }

  #main-content {
    /* padding: 20px 0; */
    padding: 0;
  }

  #chord-overlay { padding: 12px; }

  #transform-overlay { padding: 12px; }

  #app-footer {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: 8px 16px;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    min-height: 36px;
  }

  #btn-edit-mode { display: inline-flex; }
  .chord-display { font-size: 2rem; }
  .transform-label { display: block; }

  .panel-popup {
    top: auto;
  }

  /* Escritorio: tarjetas más anchas en auto-fill, rectangulares y grandes */
  .favorites-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    grid-auto-rows: 110px;
    gap: 12px;
  }

  .favorite-card__name { font-size: 1.15rem; }
}

@media (min-width: 1200px) and (hover: hover) {
  :root {
    --key-white-w-base: 56px;
    --key-black-w-base: 34px;
    --key-white-h-base: 250px;
  }

  /* #piano-area toma height de calc(var(--key-white-h) + 8px) automáticamente */

  .piano-key__label { font-size: 11px; }
}

/* ── Tablets táctiles (iPad y similares) ──────────────────────────────────── */
/* min-height: 500px excluye teléfonos en landscape (height ≤ 430px);        */
/* los iPads en landscape tienen al menos 744px de altura.                   */
@media (min-width: 600px) and (min-height: 500px) and (hover: none) {
  /* Grid de favoritos: más columnas en tablet, tarjetas más grandes */
  .favorites-grid {
    grid-template-columns: repeat(8, 1fr);
    grid-auto-rows: 120px;
    gap: 10px;
  }
  :root {
    --key-white-w-base: 46px;
    --key-black-w-base: 29px;
    /* clamp: iPad mini(744px)→312px  Air(820px)→344px  Pro(1024px)→350px */
    --key-white-h-base: 220px;
  }
}

/* ── Scrollbar estilizada (escritorio) ─────────────────────────────────────── */
@media (min-width: 768px) and (hover: hover) {
  ::-webkit-scrollbar { width: 6px; height: 6px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }
  ::-webkit-scrollbar-thumb:hover { background: #555; }
}

/* ── Overlay de rotación (portrait + táctil) ─────────────────────────── */
#rotate-overlay {
  display: none; /* oculto por defecto */
}

@media (orientation: portrait) and (hover: none) {
  #rotate-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--color-bg);
    color: var(--color-text);
  }
  #rotate-overlay svg {
    color: var(--color-accent);
    animation: rotate-hint 2s ease-in-out infinite;
  }
  #rotate-overlay p {
    font-size: 1rem;
    color: var(--color-text-muted);
    text-align: center;
    padding: 0 24px;
  }
  /* Ocultar la app cuando el overlay está visible */
  #app {
    visibility: hidden;
  }
}

@keyframes rotate-hint {
  0%   { transform: rotate(-90deg);   }
  35%  { transform: rotate(0deg); }
  65%  { transform: rotate(0deg); }
  100% { transform: rotate(-90deg);   }
}

/* ── Diálogo de información ─────────────────────────────────────────── */
.info-dialog {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 32px 24px 24px;
  max-width: 360px;
  width: calc(100% - 40px);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow-lg);
}
.info-dialog::backdrop {
  background: rgba(0, 0, 0, .78);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.info-dialog__close {
  position: absolute;
  top: 10px;
  right: 10px;
}
.info-dialog__logo img {
  width: 64px;
  height: 64px;
}
.info-dialog__title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: .03em;
  color: var(--color-accent);
  margin-bottom: 6px;
}
.info-dialog__tagline {
  font-size: 0.82rem;
  color: var(--color-text-muted);
}
.info-dialog__version {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin: 2px 0 6px;
  letter-spacing: 0.02em;
}
.info-dialog__divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 16px 0;
}
.info-dialog__copyright {
  font-size: 0.82rem;
  color: var(--color-text-muted);
}
.info-dialog__web {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--color-accent);
  text-decoration: none;
  letter-spacing: .01em;
}
.info-dialog__web:hover { text-decoration: underline; }
.info-dialog__section-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--color-text-muted);
  margin-bottom: 10px;
}
.info-dialog__list {
  list-style: none;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.info-dialog__list li {
  font-size: 0.82rem;
  line-height: 1.5;
}
.info-dialog__list strong {
  color: var(--color-text);
}
.info-dialog__attr {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* ── Diálogo de compartir acorde ────────────────────────────────────── */
.share-dialog {
  max-width: 480px;
  text-align: left;
}
.share-dialog__icon {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--color-accent);
  opacity: 0.85;
}
.share-dialog__desc {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 4px 0 0;
}
.share-url-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 16px;
}
.share-url-input {
  flex: 1;
  min-width: 0;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  color: var(--color-text);
  font-size: 0.82rem;
  font-family: monospace;
  outline: none;
}
.share-copy-confirm {
  font-size: 0.82rem;
  color: var(--color-accent);
  margin: 10px 0 0;
}

/* ── Diálogo de guitarra ──────────────────────────────────────────── */
.guitar-dialog {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 32px 28px 24px;
  max-width: 420px;
  width: calc(100% - 40px);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow-lg);
}
.guitar-dialog::backdrop {
  background: rgba(0, 0, 0, .78);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.guitar-dialog__close {
  position: absolute;
  top: 10px;
  right: 10px;
}
.guitar-dialog__title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-accent);
  margin-bottom: 4px;
  letter-spacing: .02em;
}
.guitar-dialog__subtitle {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 20px;
}
.guitar-dialog__body {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
}
.guitar-diagram {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.guitar-diagram svg {
  width: 180px;
  height: auto;
}
.guitar-dialog__pos-label {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
}
.guitar-dialog__none {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  padding: 12px 0 4px;
}

/* ── Di\u00e1logo de escucha activa ─────────────────────────────────────────────── */

.mic-listening-dialog {
  max-width: 360px;
  text-align: center;
  padding: 28px 24px 24px;
}

.mic-listening__header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.mic-listening__title {
  font-size: 1rem;
  font-weight: 700;
}

/* Punto rojo pulsante */
@keyframes dot-pulse {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%       { opacity: .4; transform: scale(.7); }
}

.mic-listening__dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  animation: dot-pulse 1.1s ease-in-out infinite;
  flex-shrink: 0;
}

/* Canvas de onda */
.mic-waveform {
  display: block;
  width: 100%;
  height: 80px;
  border-radius: var(--radius-md);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  margin-bottom: 16px;
}

.mic-listening__hint {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  margin-bottom: 20px;
  line-height: 1.45;
}

.mic-listening-dialog .btn--primary {
  width: 100%;
}

/* ── Micr\u00f3fono: bot\u00f3n de escucha ──────────────────────────────────────────── */

/* Anillo de pulso animado que aparece alrededor del icono mientras escucha */
@keyframes mic-pulse {
  0%   { transform: scale(1);   opacity: .7; }
  70%  { transform: scale(2.2); opacity: 0; }
  100% { transform: scale(2.2); opacity: 0; }
}

#btn-mic {
  position: relative;
  overflow: visible;  /* necesario para que el anillo desborde el botón */
}

#btn-mic.btn--listening {
  color: var(--color-accent);
}

#btn-mic.btn--listening::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--color-accent);
  animation: mic-pulse 1.4s ease-out infinite;
  pointer-events: none;
}

/* ── Disclaimer y candidatos: di\u00e1logos del micr\u00f3fono ───────────────────────── */

.mic-disclaimer {
  max-width: 340px;
  text-align: center;
}

.mic-disclaimer__icon {
  font-size: 2.4rem;
  margin-bottom: 8px;
  line-height: 1;
}

.mic-disclaimer__body {
  font-size: 0.86rem;
  color: var(--color-text-muted);
  line-height: 1.5;
  margin-bottom: 16px;
}

.mic-disclaimer__badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-accent) 35%, transparent);
  border-radius: 99px;
  padding: 2px 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 18px;
}

.mic-disclaimer__check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--color-text-muted);
  cursor: pointer;
  margin-bottom: 20px;
  justify-content: center;
}

.mic-disclaimer__check-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-accent);
  cursor: pointer;
}

.mic-disclaimer__actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.mic-disclaimer__actions .btn {
  flex: 1;
  max-width: 140px;
}

/* Botón primario reutilizable */
.btn--primary {
  background: var(--color-accent);
  color: #000;
  font-weight: 700;
  border-color: var(--color-accent);
}
.btn--primary:hover {
  opacity: .88;
}

/* Candidatos */
.mic-candidates {
  max-width: 320px;
  text-align: center;
}

.mic-candidates__subtitle {
  font-size: 0.83rem;
  color: var(--color-text-muted);
  margin-bottom: 16px;
  line-height: 1.45;
}

.mic-candidates__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.mic-candidate-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  cursor: pointer;
  font-size: 0.92rem;
  transition: border-color .15s, background .15s;
}

.mic-candidate-btn:hover {
  border-color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 8%, var(--color-bg));
}

.mic-candidate-btn__name {
  font-weight: 700;
  font-size: 1rem;
}

.mic-candidate-btn__score {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.mic-experimental-note {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-accent);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-top: 4px;
}

/* ── Toast de aviso del micr\u00f3fono ────────────────────────────────────────── */

.mic-toast {
  position: fixed;
  z-index: 9999;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 0.82rem;
  box-shadow: var(--shadow-lg);
  max-width: min(90vw, 320px);
  pointer-events: none;
  animation: toast-in .2s ease, toast-out .4s ease 3.1s forwards;
}
.app-toast--error {
  background: color-mix(in srgb, var(--color-surface) 85%, #b33 15%);
  border-color: #c44;
  color: #fcc;
}
.app-update-toast {
  animation: toast-in .2s ease;
  pointer-events: auto;
  display: flex;
  align-items: center;
  max-width: min(90vw, 420px);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(-4px); }
}

/* ── Panel de configuración (estilo explorador) ────────────────────────────── */
.settings-panel {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  animation: settings-slide-in .16s ease;
}
@keyframes settings-slide-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* Cabecera a ancho completo */
.settings-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 20px;
  height: 50px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  flex-shrink: 0;
}
.settings-panel__header-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: .02em;
}
/* Cuerpo: sidebar + contenido */
.settings-panel__body {
  display: flex;
  flex: 1;
  overflow: hidden;
}
/* Sidebar */
.settings-panel__sidebar {
  width: 190px;
  flex-shrink: 0;
  border-right: 1px solid var(--color-border);
  background: var(--color-surface);
  overflow-y: auto;
  padding: 8px 0;
}
.settings-panel__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px;
}
.settings-panel__nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  width: 100%;
  border: none;
  border-radius: var(--radius-md);
  background: none;
  color: var(--color-text);
  font-size: 0.88rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}
.settings-panel__nav-item:hover  { background: var(--color-surface-2); }
.settings-panel__nav-item--active {
  background: color-mix(in srgb, var(--color-accent) 15%, transparent);
  color: var(--color-accent);
  font-weight: 600;
}
.settings-panel__nav-item svg { flex-shrink: 0; opacity: .7; }
.settings-panel__nav-item--active svg { opacity: 1; }
/* Área de contenido */
.settings-panel__content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}
.settings-panel__section         { display: block; }
.settings-panel__section--hidden  { display: none; }
.settings-panel__section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 16px;
}
/* About: centrado con max-width */
.settings-section-about {
  max-width: 340px;
  margin: 0 auto;
  text-align: center;
}

/* ── Sección de opciones ──────────────────────────────────────────────────── */
.settings-options {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 520px;
}
.settings-options__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
}
.settings-options__item:last-child { border-bottom: none; }
.settings-options__texts {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.settings-options__name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
}
.settings-options__desc {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}
/* Toggle switch */
.settings-toggle {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 40px;
  height: 22px;
  background: var(--color-border);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}
.settings-toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.2s;
}
.settings-toggle:checked { background: var(--color-accent); }
.settings-toggle:checked::after { left: 21px; background: #000; }
/* Select de preferencias (selector de instrumento) */
.settings-select {
  background: var(--color-surface-2, #2a2a2a);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 8px);
  padding: 5px 8px;
  font-size: 0.88rem;
  cursor: pointer;
  max-width: 160px;
  outline: none;
  transition: border-color 0.15s;
}
.settings-select:focus { border-color: var(--color-accent); }

/* ========================================
   METRONOMO
   ======================================== */

/* Panel contenedor */
.metro-popup {
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 0;
}
.metro-popup.panel--open {
  display: flex;
  flex-direction: column;
}

/* Layout de dos columnas: principal + lateral */
.metro-panel {
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 14px;
  align-items: start;
}
.metro-col-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  margin: auto 0;
}
.metro-col-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 80px;
}
/* En la columna lateral, los botones van en columna */
.metro-col-side .metro-ts-btns,
.metro-col-side .metro-sound-btns {
  flex-direction: column;
  gap: 4px;
}
.metro-col-side .metro-ts-btn,
.metro-col-side .metro-sound-btn {
  width: 100%;
  text-align: center;
}

/* Indicador visual de pulsos */
.metro-beats {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 22px;
}
.metro-beat-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--color-border);
  transition: background 0.04s, transform 0.04s;
  flex-shrink: 0;
}
.metro-beat-dot--accent {
  width: 14px;
  height: 14px;
}
.metro-beat-dot--active {
  background: var(--color-accent);
  transform: scale(1.25);
}

/* Display de BPM */
.metro-bpm-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}
.metro-bpm-value {
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
  min-width: 4ch;
  text-align: right;
  transition: color 0.1s;
}
@keyframes metro-bpm-pulse {
  0%   { color: var(--color-accent); }
  100% { color: var(--color-text); }
}
.metro-bpm-value--pulse {
  animation: metro-bpm-pulse 0.35s ease-out forwards;
}
.metro-bpm-unit {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  align-self: flex-end;
  padding-bottom: 4px;
}

/* Controles BPM + TAP */
.metro-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
  flex-wrap: nowrap;
}
.metro-btn {
  padding: 5px 7px;
  font-size: 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 8px);
  background: var(--color-surface-2, #2a2a2a);
  color: var(--color-text);
  cursor: pointer;
  min-width: 34px;
  transition: background 0.1s, color 0.1s;
}
.metro-btn:hover { background: var(--color-accent); color: #000; }
.metro-tap {
  padding: 5px 11px;
  font-size: 0.88rem;
  font-weight: 600;
  border: 2px solid var(--color-accent);
  border-radius: var(--radius-md, 8px);
  background: transparent;
  color: var(--color-accent);
  cursor: pointer;
  transition: background 0.08s, color 0.08s;
}
.metro-tap:active { background: var(--color-accent); color: #000; }

/* Secciones del panel */
.metro-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.metro-section__label {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Botones de compás y sonido */
.metro-ts-btns,
.metro-sound-btns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.metro-ts-btn,
.metro-sound-btn {
  padding: 4px 8px;
  font-size: 0.78rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 8px);
  background: var(--color-surface-2, #2a2a2a);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.metro-ts-btn--active,
.metro-sound-btn--active {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 10%, transparent);
}
.metro-ts-btn:hover:not(.metro-ts-btn--active),
.metro-sound-btn:hover:not(.metro-sound-btn--active) {
  border-color: var(--color-text-muted);
  color: var(--color-text);
}

/* Botón de inicio/parada dentro del panel */
.metro-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 9px 0;
  font-size: 0.95rem;
  font-weight: 600;
  border: 2px solid var(--color-accent);
  border-radius: var(--radius-md, 8px);
  background: color-mix(in srgb, var(--color-accent) 12%, transparent);
  color: var(--color-accent);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.metro-toggle:hover {
  background: color-mix(in srgb, var(--color-accent) 22%, transparent);
}
.metro-toggle--running {
  background: var(--color-accent);
  color: #000;
}
.metro-toggle--running:hover {
  background: color-mix(in srgb, var(--color-accent) 85%, #000);
}
.metro-toggle__icon { font-size: 1rem; line-height: 1; }

/* Slider de volumen */
.metro-volume-row {
  display: flex;
  align-items: center;
  gap: 7px;
}
.metro-vol-icon { color: var(--color-text-muted); flex-shrink: 0; }
.metro-volume {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--color-border);
  outline: none;
  cursor: pointer;
  accent-color: var(--color-accent);
}
.metro-volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.metro-volume::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-accent);
  border: none;
  cursor: pointer;
}
/* Responsive: pantallas móviles/táctiles */
@media (max-width: 767px), (hover: none) {
  .settings-panel__sidebar  { width: 140px; }
  .settings-panel__nav-item { font-size: 0.82rem; padding: 9px 10px; gap: 8px; }
  .settings-panel__content  { padding: 16px 14px; }
}
@media (max-width: 400px) {
  .settings-panel__sidebar  { width: 48px; }
  .settings-panel__nav-item span { display: none; }
  .settings-panel__nav-item { justify-content: center; padding: 12px 0; gap: 0; }
}

/* ── Panel: Barra de funciones ──────────────────────────────────────────────── */
.settings-toolbar__desc {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  margin-bottom: 16px;
  text-align: left;
  line-height: 1.5;
}
.settings-toolbar__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 10px;
}
.settings-toolbar__footer {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--color-border);
  padding-top: 12px;
}
.settings-toolbar__footer .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}
.settings-toolbar__footer .btn:hover {
  color: var(--color-accent);
}
.toolbar-item-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 10px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-align: center;
  position: relative;
  user-select: none;
}
/* Asa de arrastrar */
.toolbar-item-card__handle {
  width: 20px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  cursor: grab;
  touch-action: none;
  opacity: 0.3;
  transition: opacity 0.15s;
}
.toolbar-item-card:hover .toolbar-item-card__handle,
.toolbar-item-card--active .toolbar-item-card__handle { opacity: 0.7; }
.toolbar-item-card__handle:active { cursor: grabbing; }
/* Placeholder en el grid de configuración */
.toolbar-item-card--placeholder {
  border: 2px dashed var(--color-accent);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-accent) 12%, transparent);
  animation: dnd-pulse 0.6s ease-in-out infinite alternate;
}
/* Ocultar handle y checkbox dentro del ghost */
.dnd-ghost .toolbar-item-card__handle { display: none; }
.dnd-ghost .toolbar-item-card__toggle { display: none; }
/* Tarjeta de separador ya posicionado en el grid */
.toolbar-item-card--sep {
  border-style: dashed;
  opacity: 0.8;
}
/* Tarjeta fuente del separador (siempre al final, se clona al arrastrar) */
.toolbar-item-card--sep-source {
  border-style: dashed;
  border-color: var(--color-accent);
  opacity: 0.6;
}
/* Ghost fuera del grid: indica que al soltar se eliminará */
.dnd-ghost--will-delete {
  border-color: var(--color-danger, #ef4444) !important;
  opacity: 0.4;
  transform: scale(0.96);
}
.toolbar-item-card:hover { background: var(--color-surface-2); }
.toolbar-item-card--active {
  border-color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 10%, transparent);
}
.toolbar-item-card__icon {
  font-size: 1.25rem;
  line-height: 1;
  color: var(--color-accent);
  margin-bottom: 2px;
}
.toolbar-item-card__name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-text);
}
.toolbar-item-card__help {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  line-height: 1.4;
  margin-top: 2px;
}
.toolbar-item-card__toggle {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 15px;
  height: 15px;
  accent-color: var(--color-accent);
  cursor: pointer;
}

/* ── Grupo de zoom (wrapper para data-toolbar-item) ────────────────────────── */
.toolbar-group--zoom {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* ── Sección de instalación PWA ─────────────────────────────────────────────── */
.install-section {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  max-width: 420px;
}
.install-section__icon {
  font-size: 2.4rem;
  line-height: 1;
}
.install-section__desc {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  line-height: 1.55;
  margin: 0;
}
.install-section__status {
  font-size: 0.85rem;
  color: var(--color-accent);
  padding: 6px 10px;
  border: 1px solid var(--color-accent);
  border-radius: 6px;
}
.install-section__btn {
  min-width: 120px;
}

/* ── Banner de instalación PWA ──────────────────────────────────────────────── */
.install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 300;
  background: var(--color-surface, #1a1a1a);
  border-top: 1px solid var(--color-border);
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  box-shadow: 0 -4px 16px rgba(0,0,0,.5);
}
.install-banner[hidden] { display: none; }
.install-banner__body {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.install-banner__icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}
.install-banner__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.install-banner__title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--color-text);
}
.install-banner__desc {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}
.install-banner__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.install-banner__dismiss {
}
.install-banner__dismiss:hover {
}
.btn--sm {
  font-size: 0.78rem;
  padding: 5px 12px;
  height: auto;
}

/* ── Howto en sección de instalación ─────────────────────────────────────── */
.install-section__howto {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  line-height: 1.5;
  padding: 10px 14px;
  border-left: 3px solid var(--color-accent);
  background: rgba(255,255,255,.04);
  border-radius: 0 6px 6px 0;
  margin: 0;
}
