/* Laboratorio de polirritmos, compases de amalgama y reloj interno */
:root,
[data-theme="dark"] {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --bg-page: #0b0f17;
  --bg-surface: #131b2e;
  --bg-surface-2: #192338;
  --bg-input: #0f1626;
  --border-color: #26334d;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0284c7;
  --accent-soft: rgba(56, 189, 248, 0.14);
  --voice-b: #f59e0b;
  --voice-b-soft: rgba(245, 158, 11, 0.16);
  --ok: #10b981;
  --ok-soft: rgba(16, 185, 129, 0.15);
  --danger: #ef4444;
  --canvas-bg: #080d16;
  --shadow-card: 0 12px 32px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg-page: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-2: #f8fafc;
  --bg-input: #ffffff;
  --border-color: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #475569;
  --accent: #0284c7;
  --accent-strong: #0369a1;
  --accent-soft: rgba(2, 132, 199, 0.1);
  --voice-b: #d97706;
  --voice-b-soft: rgba(217, 119, 6, 0.12);
  --ok: #059669;
  --ok-soft: rgba(5, 150, 105, 0.12);
  --danger: #dc2626;
  --canvas-bg: #0f172a;
  --shadow-card: 0 8px 24px rgba(15, 23, 42, 0.08);
  color-scheme: light;
}

[data-theme="dark"] .app-header { background: #131b2e !important; border-bottom: 1px solid #1e293b !important; }
[data-theme="dark"] .brand-title { color: #f8fafc !important; }
[data-theme="light"] .app-header { background: #ffffff !important; border-bottom: 1px solid #cbd5e1 !important; }
[data-theme="light"] .brand-title { color: #0f172a !important; }

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

body {
  font-family: var(--font-main);
  background: var(--bg-page);
  color: var(--text-main);
  margin: 0;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6, .brand-title, .section-title, .hero-title { font-family: var(--font-heading); }
.mono, code { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.tool-layout { max-width: 1200px; width: 100%; margin: 1.5rem auto 3rem; padding: 0 1rem; flex: 1 0 auto; }
.tool-with-sidebar { display: flex; gap: 2rem; align-items: flex-start; width: 100%; }
.tool-main-content { flex: 1 1 0%; min-width: 0; width: 100%; }

.card-main {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.35rem;
  box-shadow: var(--shadow-card);
  margin-bottom: 1.25rem;
}

.studio-top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}
.badge-pill {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
  margin-bottom: 0.5rem;
}
.hero-title { margin: 0 0 0.35rem; font-size: 1.26rem; line-height: 1.25; }
.hero-desc { margin: 0; font-size: 0.89rem; color: var(--text-muted); line-height: 1.55; max-width: 68ch; }
.section-title { margin: 0 0 0.35rem; font-size: 1.04rem; font-weight: 700; }

.mode-tabs {
  display: inline-flex;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.25rem;
  gap: 0.25rem;
}
.tab-btn {
  min-height: 40px;
  padding: 0.45rem 0.9rem;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.tab-btn.active { background: var(--accent-strong); color: #ffffff; }

.master-transport {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.bpm-box { display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap; flex: 1 1 auto; }

.btn-play-hero {
  min-height: 46px;
  padding: 0.6rem 1.35rem;
  border-radius: 12px;
  border: none;
  background: var(--ok);
  color: #ffffff;
  font-family: var(--font-heading);
  font-size: 0.96rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-play-hero.is-running { background: var(--danger); }

.bpm-readout-wrap { display: flex; flex-direction: column; gap: 0.25rem; min-width: 210px; flex: 1 1 210px; max-width: 300px; }
.bpm-num-row { display: flex; align-items: center; gap: 0.5rem; }
.bpm-value { font-size: 1.45rem; font-weight: 800; line-height: 1; }
.bpm-unit { font-size: 0.78rem; color: var(--text-muted); font-weight: 700; }
.bpm-readout-wrap input[type="range"] { width: 100%; accent-color: var(--accent); cursor: pointer; }

.btn-step,
.btn-secondary {
  min-height: 40px;
  padding: 0.4rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface-2);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-step { min-height: 32px; padding: 0.2rem 0.55rem; font-size: 0.78rem; }
.btn-secondary:hover,
.btn-step:hover { border-color: var(--accent); }

.cycle-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  font-size: 0.82rem;
}
.cycle-status-pill.is-muted-bar { border-color: var(--voice-b); background: var(--voice-b-soft); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-muted); }
.cycle-status-pill.is-playing .status-dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.cycle-status-pill.is-muted-bar .status-dot { background: var(--voice-b); box-shadow: 0 0 8px var(--voice-b); }

.studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 1.25rem;
  align-items: stretch;
}
.wheel-card { display: flex; flex-direction: column; justify-content: space-between; }
.wheel-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; flex-wrap: wrap; }
.wheel-sub { margin: 0; font-size: 0.81rem; color: var(--text-muted); }
.wheel-legend { display: flex; gap: 0.45rem; font-size: 0.75rem; font-weight: 700; }
.leg-a { padding: 0.2rem 0.55rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent); }
.leg-b { padding: 0.2rem 0.55rem; border-radius: 999px; background: var(--voice-b-soft); color: var(--voice-b); border: 1px solid var(--voice-b); }

.wheel-stage { display: flex; justify-content: center; margin: 0.9rem 0; }
#cvs-wheel {
  width: 100%;
  max-width: 380px;
  aspect-ratio: 1 / 1;
  height: auto;
  background: var(--canvas-bg);
  border-radius: 16px;
  border: 1px solid var(--border-color);
}

.step-ribbon-wrap { margin-top: 0.35rem; }
.step-ribbon-title { font-size: 0.74rem; color: var(--text-muted); margin-bottom: 0.4rem; }
.step-ribbon { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.step-cell {
  min-width: 34px;
  min-height: 38px;
  padding: 0.25rem 0.45rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-main);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  cursor: pointer;
  user-select: none;
}
.step-cell.is-active { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.step-cell.lvl-3 { border-color: var(--accent); font-weight: 800; }
.step-cell.lvl-2 { border-color: var(--voice-b); }
.step-cell.lvl-0 { opacity: 0.42; }

.preset-chips { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0.6rem 0 1rem; }
.chip-btn {
  min-height: 36px;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface-2);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.chip-btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.voices-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85rem; }
.voice-box {
  background: var(--bg-surface-2);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.85rem;
}
.voice-a { border-top: 3px solid var(--accent); }
.voice-b { border-top: 3px solid var(--voice-b); }
.voice-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-bottom: 0.65rem; font-size: 0.86rem; }
.voice-controls { display: flex; flex-direction: column; gap: 0.55rem; }
.vol-row { margin-top: 0.55rem; display: flex; align-items: center; gap: 0.5rem; }
.vol-row input { flex: 1 1 0%; width: 0; min-width: 0; accent-color: var(--accent); }

.amalgam-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; margin-bottom: 0.6rem; }
.helper-note { margin: 0 0 0.85rem; font-size: 0.82rem; color: var(--text-muted); line-height: 1.45; }

.form-group { min-width: 0; }
.form-label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.25rem; }
.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0.5rem 40px 0.5rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-input);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.85rem;
  appearance: none;
  -webkit-appearance: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.form-select option { background-color: var(--bg-surface); color: var(--text-main); }

.trainer-modules { display: flex; flex-direction: column; gap: 0.85rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border-color); }
.trainer-block {
  background: var(--bg-surface-2);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.85rem;
}
.trainer-head { margin-bottom: 0.6rem; }
.toggle-label,
.mini-check { display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.83rem; cursor: pointer; }
.trainer-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; margin-bottom: 0.55rem; }
.trainer-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.65rem; }

.faq-list { display: flex; flex-direction: column; gap: 0.55rem; margin-top: 0.65rem; }
.faq-item {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-surface-2);
  padding: 0.75rem 0.95rem;
}
.faq-question { font-weight: 600; font-size: 0.9rem; cursor: pointer; }
.faq-answer { margin: 0.55rem 0 0; font-size: 0.86rem; color: var(--text-muted); line-height: 1.55; }

@media (max-width: 960px) {
  .studio-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .voices-grid,
  .amalgam-options,
  .trainer-grid,
  .trainer-grid-3 { grid-template-columns: 1fr; }
  .btn-play-hero,
  #btn-tap-tempo { width: 100%; }
}
