/* Polirritmos */
.poly-stage { --voice-a: var(--color-accent); --voice-b: var(--color-warn); gap: 16px; padding-top: var(--space-3); padding-bottom: var(--space-3); }
.poly-voice--a { --voice: var(--color-accent); }
.poly-voice--b { --voice: var(--color-warn); }

/* La proporción es el control principal */
.poly-ratio { display: flex; align-items: center; justify-content: center; gap: 14px; }
.poly-num { display: flex; align-items: center; gap: 8px; }
.poly-num__val {
  min-width: 1.3em;
  text-align: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(2.6rem, 9vw, 3.4rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.poly-num--a .poly-num__val { color: var(--voice-a); }
.poly-num--b .poly-num__val { color: var(--voice-b); }
.poly-num__val.is-bump { animation: poly-bump .3s var(--ease); }
@keyframes poly-bump { 40% { transform: scale(1.18); } }
.poly-num .icon-btn[disabled] { opacity: .3; pointer-events: none; }
.poly-ratio__sep { font-size: .7rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--color-gray); }

.poly-presets { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; width: 100%; max-width: 480px; }
.poly-presets .chip { min-width: 52px; font-variant-numeric: tabular-nums; }

/* Rueda: también es un botón para empezar y parar */
.poly-wheel {
  width: 100%;
  max-width: 290px;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .15s ease;
}
.poly-wheel:active { transform: scale(.98); }
.poly-wheel svg { width: 100%; height: 100%; overflow: visible; }
.poly-ring { fill: none; stroke: var(--color-hairline); stroke-width: 2; }
.poly-ring--a { stroke: rgba(0, 205, 156, .28); }
.poly-ring--b { stroke: rgba(242, 181, 68, .28); }
.poly-dot { transition: r .25s var(--ease), fill .25s ease, opacity .25s ease; }
.poly-dot--a { fill: #1f3a32; stroke: var(--voice-a); stroke-width: 2; }
.poly-dot--b { fill: #3b3020; stroke: var(--voice-b); stroke-width: 2; }
.poly-dot.is-first { stroke-width: 3.5; }
.poly-dot.is-hit { transition: none; }
.poly-dot--a.is-hit { fill: var(--voice-a); filter: drop-shadow(0 0 8px var(--color-accent-glow)); }
.poly-dot--b.is-hit { fill: var(--voice-b); filter: drop-shadow(0 0 8px rgba(242, 181, 68, .45)); }
.poly-needle { stroke: var(--color-ink); stroke-width: 2.5; stroke-linecap: round; opacity: .5; transform-origin: 160px 160px; transition: opacity .2s ease; }
.is-playing .poly-needle { opacity: .9; }
.poly-hub { fill: var(--color-ink); transform-origin: 160px 160px; }
.poly-hub.is-pulse { animation: poly-hub .4s ease-out; }
@keyframes poly-hub { 0% { transform: scale(2.2); fill: var(--color-accent); } 100% { transform: scale(1); } }
.is-muted-a .poly-dot--a, .is-muted-a .poly-ring--a { opacity: .3; }
.is-muted-b .poly-dot--b, .is-muted-b .poly-ring--b { opacity: .3; }

/* Línea de tiempo: rejilla común a las dos voces */
.poly-timeline { width: 100%; max-width: 520px; display: grid; gap: 5px; }
.poly-tl-row { display: grid; gap: 3px; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); }
.poly-tl-cell {
  height: 18px;
  border-radius: 4px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-hairline);
  transition: background .2s ease, box-shadow .2s ease;
}
.poly-tl-row--a .is-on { background: rgba(0, 205, 156, .35); border-color: var(--voice-a); }
.poly-tl-row--b .is-on { background: rgba(242, 181, 68, .32); border-color: var(--voice-b); }
.poly-tl-cell.is-now { box-shadow: 0 0 0 2px var(--color-ink); transition: none; }
.poly-tl-row--a .is-on.is-now { background: var(--voice-a); }
.poly-tl-row--b .is-on.is-now { background: var(--voice-b); }
.poly-tl-nums { display: grid; gap: 3px; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); font-size: .66rem; font-weight: 700; color: var(--color-gray); text-align: center; font-variant-numeric: tabular-nums; }
.poly-tl-nums .is-both { color: var(--color-ink); }
.poly-timeline--dense .poly-tl-cell { height: 14px; border-radius: 2px; }
.poly-timeline--dense .poly-tl-nums span:not(.is-both) { visibility: hidden; }
.poly-count { margin: -4px 0 0; font-size: .82rem; color: var(--color-ink-soft); text-align: center; max-width: 520px; min-height: 1.3em; }
.poly-count strong { color: var(--color-ink); }

.poly-actions { display: flex; align-items: center; justify-content: center; gap: var(--space-4); flex-wrap: wrap; }
.poly-bpm { display: grid; grid-template-columns: auto auto auto; align-items: center; gap: 10px; }
.poly-bpm__read { text-align: center; min-width: 84px; }
.poly-bpm__input {
  width: 3.2ch;
  min-width: 100%;
  background: transparent;
  border: 0;
  padding: 0;
  text-align: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 2.4rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  border-radius: var(--radius);
}
.poly-bpm__input:focus { outline: none; background: var(--color-surface-2); }
.poly-bpm .readout__unit { margin-top: 4px; }

/* Panel de voces: dos bloques compactos en un solo panel */
.poly-voice { display: grid; gap: 10px; padding: 12px 0; }
.poly-voice + .poly-voice { border-top: 1px solid var(--color-hairline); }
.poly-voice:first-of-type { padding-top: 0; }
.poly-voice__head { display: flex; align-items: center; justify-content: space-between; }
.poly-voice__name { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.poly-voice__name small { font-weight: 400; color: var(--color-gray); font-size: .82rem; }
.poly-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--voice); box-shadow: 0 0 8px var(--voice); }
.poly-vol { display: grid; grid-template-columns: 20px minmax(0, 1fr) 42px; align-items: center; gap: 10px; color: var(--color-gray); }
.poly-vol svg { width: 18px; height: 18px; }
.poly-vol .field__value { text-align: right; font-size: .85rem; }
.poly-voice .seg button[aria-pressed="true"] { background: var(--voice); border-color: var(--voice); }
.poly-voice input[type="range"]::-webkit-slider-runnable-track { background: linear-gradient(90deg, var(--voice) var(--fill), var(--color-surface-3) var(--fill)); }
.poly-voice input[type="range"]::-webkit-slider-thumb { border-color: var(--voice); }
.poly-voice input[type="range"]::-moz-range-progress { background: var(--voice); }
.poly-voice .switch input:checked + .switch__track { background: var(--voice); border-color: var(--voice); }
.poly-voice.is-muted > :not(.poly-voice__head) { opacity: .45; }
.poly-voice.is-muted .poly-swatch { box-shadow: none; opacity: .5; }

@media (min-width: 960px) {
  .poly-wheel { max-width: 228px; }
  .poly-stage { gap: 14px; }
}
@media (max-width: 600px) {
  .poly-stage { gap: 12px; padding-top: 14px; padding-bottom: 16px; }
  .poly-wheel { max-width: min(232px, 60vw); }
  .poly-ratio { gap: 8px; }
  .poly-num { gap: 4px; }
  .poly-presets { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; scrollbar-width: none; padding: 2px; }
  .poly-presets::-webkit-scrollbar { display: none; }
  .poly-presets .chip { flex: 0 0 auto; min-width: 48px; }
  .poly-actions { gap: var(--space-3); }
  .poly-bpm__input { font-size: 2.1rem; }
  .poly-tl-cell { height: 14px; }
}
@media (max-height: 700px) and (max-width: 600px) {
  .poly-wheel { max-width: 180px; }
}
