/* Editor de pedaleira no navegador.
   Cabine de estúdio: metal escovado, brilho de válvula, LED de footswitch.
   Usa os tokens do app.css; tudo que é "equipamento" é desenhado aqui. */

.pe-page {
  --pe-amber: #ff9f45;
  --pe-amber-rgb: 255, 159, 69;
  --pe-led: #4ade80;
  --pe-led-rgb: 74, 222, 128;
  --pe-red: #ff5c7a;
  --pe-panel: linear-gradient(168deg, rgba(22, 32, 54, 0.92), rgba(8, 14, 26, 0.96));
  --pe-metal: linear-gradient(170deg, rgba(238, 246, 255, 0.1), rgba(5, 8, 15, 0.55));
  --pe-line: rgba(238, 246, 255, 0.12);
}
.pe-page .stage {
  width: min(1340px, calc(100% - 2rem));
}

/* Textura de metal escovado, por cima de tudo que é equipamento */
.pe-rack::after,
.pe-chain-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: repeating-linear-gradient(118deg, rgba(255, 255, 255, 0.016) 0 1px, transparent 1px 6px);
  pointer-events: none;
}

/* ---------------- Barra de conexão ---------------- */
.pe-top {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  padding: 14px 18px;
  border: 1px solid var(--pe-line);
  border-radius: 18px;
  background: rgba(8, 14, 26, 0.86);
  backdrop-filter: blur(14px);
}
.pe-badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px 8px 11px;
  border: 1px solid var(--pe-line);
  border-radius: 999px;
  background: rgba(238, 246, 255, 0.04);
  font-size: 0.84rem;
  font-weight: 600;
}
.pe-badge i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #64748b;
  box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.18);
  transition: background 0.25s ease, box-shadow 0.25s ease;
}
.pe-badge.is-on i {
  background: var(--pe-led);
  box-shadow: 0 0 0 3px rgba(var(--pe-led-rgb), 0.22), 0 0 14px var(--pe-led);
  animation: pe-pulse 2.2s ease-in-out infinite;
}
.pe-badge.is-busy i {
  background: var(--pe-amber);
  box-shadow: 0 0 0 3px rgba(var(--pe-amber-rgb), 0.22);
  animation: pe-pulse 0.8s ease-in-out infinite;
}
.pe-badge.is-err i { background: var(--pe-red); box-shadow: 0 0 0 3px rgba(255, 92, 122, 0.2); }
.pe-dev-name {
  min-width: 0;
  color: var(--muted);
  font-size: 0.84rem;
}
.pe-dev-name b { color: var(--ink); }
.pe-top-sp { flex: 1 1 auto; }

.pe-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.pe-btn svg { width: 17px; height: 17px; }
.pe-btn-primary {
  background: linear-gradient(120deg, var(--pe-amber), #ff7a45);
  color: #150800;
  box-shadow: 0 12px 30px rgba(var(--pe-amber-rgb), 0.3);
}
.pe-btn-primary:hover { transform: translateY(-2px); box-shadow: 0 18px 40px rgba(var(--pe-amber-rgb), 0.42); }
.pe-btn-ghost {
  border-color: var(--pe-line);
  background: rgba(238, 246, 255, 0.04);
  color: var(--ink);
}
.pe-btn-ghost:hover { transform: translateY(-2px); border-color: rgba(var(--pe-amber-rgb), 0.45); }
.pe-btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---------------- Grade principal ---------------- */
.pe-grid {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr) 272px;
  gap: 18px;
  align-items: start;
}

.pe-rack {
  position: relative;
  padding: 18px;
  border: 1px solid var(--pe-line);
  border-radius: 20px;
  background: var(--pe-panel);
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.45);
}
.pe-rack-title {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ---------------- Bancos e presets ---------------- */
.pe-banks {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 14px;
}
.pe-bank {
  width: 30px;
  height: 30px;
  border: 1px solid var(--pe-line);
  border-radius: 8px;
  background: var(--pe-metal);
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.16s ease;
}
.pe-bank:hover { color: var(--ink); border-color: rgba(var(--pe-amber-rgb), 0.4); }
.pe-bank.is-on {
  border-color: rgba(var(--pe-amber-rgb), 0.7);
  background: rgba(var(--pe-amber-rgb), 0.16);
  color: var(--pe-amber);
  box-shadow: 0 0 14px rgba(var(--pe-amber-rgb), 0.28);
}

.pe-presets { display: grid; gap: 8px; }
.pe-preset {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid var(--pe-line);
  border-radius: 12px;
  background: var(--pe-metal);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}
.pe-preset::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--p);
  opacity: 0;
  transition: opacity 0.18s ease;
}
.pe-preset:hover { transform: translateX(3px); border-color: rgba(var(--p-rgb), 0.5); }
.pe-preset.is-on {
  border-color: rgba(var(--p-rgb), 0.65);
  background: linear-gradient(100deg, rgba(var(--p-rgb), 0.16), rgba(238, 246, 255, 0.03));
}
.pe-preset.is-on::before { opacity: 1; }
.pe-preset-n {
  display: grid;
  place-items: center;
  height: 26px;
  border-radius: 7px;
  background: rgba(var(--p-rgb), 0.18);
  color: var(--p);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.pe-preset-nm {
  min-width: 0;
  font-size: 0.87rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------- Cadeia de pedais ---------------- */
.pe-chain-wrap {
  position: relative;
  padding: 20px 18px 18px;
  border: 1px solid var(--pe-line);
  border-radius: 20px;
  background: var(--pe-panel);
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.45);
}
.pe-chain-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.pe-chain-head h2 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}
.pe-chain-head p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}
.pe-chain {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0;
}
.pe-slot {
  position: relative;
  /* base 0 para os nove blocos caberem numa fileira só; a largura vem do flex */
  flex: 1 1 0;
  min-width: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 12px 6px 10px;
  border: 1px solid var(--pe-line);
  border-radius: 14px;
  background: var(--pe-metal);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(.22,1,.36,1), border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.pe-slot:hover { transform: translateY(-3px); }
.pe-slot.is-sel {
  border-color: rgba(var(--b-rgb), 0.8);
  background: linear-gradient(170deg, rgba(var(--b-rgb), 0.18), rgba(5, 8, 15, 0.6));
  box-shadow: 0 0 0 1px rgba(var(--b-rgb), 0.35), 0 16px 34px rgba(var(--b-rgb), 0.26);
  transform: translateY(-4px);
}
.pe-slot.is-off { opacity: 0.44; }
.pe-slot-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(238, 246, 255, 0.18);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.pe-slot.is-on .pe-slot-led {
  background: var(--b);
  box-shadow: 0 0 10px var(--b), 0 0 22px rgba(var(--b-rgb), 0.55);
}
.pe-slot svg { width: 24px; height: 24px; color: var(--muted); transition: color 0.2s ease; }
.pe-slot.is-on svg { color: var(--b); }
.pe-slot b { font-size: 0.76rem; font-weight: 700; }
.pe-slot em {
  color: var(--muted);
  font-size: 0.64rem;
  font-style: normal;
  text-align: center;
  line-height: 1.25;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pe-wire {
  flex: 0 0 14px;
  align-self: center;
  position: relative;
  height: 2px;
  background: rgba(238, 246, 255, 0.14);
}
.pe-wire span {
  position: absolute;
  top: 50%;
  left: 0;
  width: 9px;
  height: 4px;
  margin-top: -2px;
  border-radius: 4px;
  background: var(--pe-amber);
  box-shadow: 0 0 9px var(--pe-amber);
  animation: pe-flow 2.6s linear infinite;
  animation-delay: calc(var(--d, 0) * 0.26s);
}
.pe-chain-wrap.is-idle .pe-wire span { animation-play-state: paused; opacity: 0.25; }

/* ---------------- Painel de botões ---------------- */
.pe-panel {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(var(--b-rgb), 0.3);
  border-radius: 18px;
  background: linear-gradient(150deg, rgba(var(--b-rgb), 0.09), rgba(5, 8, 15, 0.5));
  transition: border-color 0.25s ease, background 0.25s ease;
}
.pe-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.pe-panel-ico {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(var(--b-rgb), 0.16);
  color: var(--b);
}
.pe-panel-ico svg { width: 22px; height: 22px; }
.pe-panel-tt { min-width: 0; flex: 1 1 auto; }
.pe-panel-tt h3 { margin: 0; font-size: 1.05rem; }
.pe-panel-tt p { margin: 1px 0 0; color: var(--muted); font-size: 0.78rem; }

.pe-model {
  padding: 9px 14px;
  border: 1px solid rgba(var(--b-rgb), 0.4);
  border-radius: 999px;
  background: rgba(5, 8, 15, 0.6);
  color: var(--b);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 650;
  cursor: pointer;
}
.pe-model:focus-visible { outline: 2px solid var(--b); outline-offset: 2px; }

.pe-switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 14px 7px 9px;
  border: 1px solid var(--pe-line);
  border-radius: 999px;
  background: rgba(5, 8, 15, 0.5);
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 650;
  cursor: pointer;
  transition: all 0.18s ease;
}
.pe-switch i {
  position: relative;
  width: 34px;
  height: 18px;
  border-radius: 999px;
  background: rgba(238, 246, 255, 0.14);
  transition: background 0.2s ease;
}
.pe-switch i::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #94a3b8;
  transition: transform 0.22s cubic-bezier(.22,1,.36,1), background 0.2s ease;
}
.pe-switch.is-on { color: var(--b); border-color: rgba(var(--b-rgb), 0.5); }
.pe-switch.is-on i { background: rgba(var(--b-rgb), 0.3); }
.pe-switch.is-on i::after { transform: translateX(16px); background: var(--b); }

/* Botões giratórios */
.pe-knobs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 14px;
}
.pe-knob {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 12px 6px 10px;
  border: 1px solid var(--pe-line);
  border-radius: 14px;
  background: rgba(5, 8, 15, 0.42);
  touch-action: none;
  user-select: none;
  cursor: ns-resize;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.pe-knob:hover,
.pe-knob.is-drag { border-color: rgba(var(--b-rgb), 0.55); background: rgba(var(--b-rgb), 0.07); }
.pe-knob svg { width: 68px; height: 68px; overflow: visible; }
.pe-knob-track { stroke: rgba(238, 246, 255, 0.14); }
.pe-knob-fill {
  stroke: var(--b);
  filter: drop-shadow(0 0 5px rgba(var(--b-rgb), 0.7));
  transition: stroke-dashoffset 0.12s linear;
}
.pe-knob-body { fill: url(#peKnobFace); stroke: rgba(238, 246, 255, 0.16); }
.pe-knob-ptr { stroke: var(--b); stroke-width: 2.4; stroke-linecap: round; }
.pe-knob-lbl {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pe-knob-val {
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.pe-knob-val span { color: var(--muted); font-size: 0.72rem; font-weight: 500; }

/* ---------------- Coluna direita ---------------- */
/* ---------- Gabinete de saída ----------
   Moldura, tela de pano trançado, parafusos nos cantos e um alto-falante
   com cesto, cone, suspensão e calota. O cone bombeia com o sinal. */
.pe-cab {
  position: relative;
  height: 186px;
  margin-bottom: 14px;
  border-radius: 14px;
  border: 1px solid rgba(238, 246, 255, 0.14);
  background:
    linear-gradient(175deg, #2a2118, #1a1510 55%, #120e0a);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -10px 24px rgba(0, 0, 0, 0.6),
    0 14px 30px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
/* tela de pano: dois tramados cruzados */
.pe-cab-cloth {
  position: absolute;
  inset: 11px;
  border-radius: 8px;
  background-color: #15110d;
  background-image:
    repeating-linear-gradient(45deg, rgba(255, 228, 196, 0.07) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.55) 0 1px, transparent 1px 4px);
  box-shadow: inset 0 0 26px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.pe-speaker {
  position: absolute;
  left: 50%;
  top: 44%;
  width: 108px;
  height: 108px;
  transform: translate(-50%, -50%);
}
.pe-spk-basket,
.pe-spk-cone,
.pe-spk-surround,
.pe-spk-cap {
  position: absolute;
  border-radius: 50%;
}
/* cesto de metal com a borda chanfrada */
.pe-spk-basket {
  inset: 0;
  background: conic-gradient(from 210deg, #3a3f49, #22262e 18%, #4a515d 38%, #1d2027 62%, #40464f 82%, #23272f);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}
/* suspensão: o anel macio em volta do cone */
.pe-spk-surround {
  inset: 11px;
  background: radial-gradient(circle at 42% 34%, #4b4036, #2a241e 60%, #171310);
  box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.75), inset 0 -2px 5px rgba(255, 255, 255, 0.05);
}
/* o cone, com as nervuras radiais */
.pe-spk-cone {
  inset: 18px;
  background:
    repeating-conic-gradient(from 0deg, rgba(255, 255, 255, 0.028) 0deg 3deg, transparent 3deg 6deg),
    radial-gradient(circle at 40% 32%, #46505f, #222a36 52%, #10151e 88%);
  box-shadow: inset 0 6px 18px rgba(0, 0, 0, 0.65);
}
/* calota central, onde bate a luz */
.pe-spk-cap {
  inset: 35px;
  background: radial-gradient(circle at 38% 30%, #ffc07a, #e2762a 45%, #8c3d0f 78%, #4a1f07);
  box-shadow:
    0 0 20px rgba(255, 159, 69, 0.45),
    inset 0 -3px 8px rgba(0, 0, 0, 0.45),
    inset 0 3px 6px rgba(255, 255, 255, 0.28);
}
.pe-speaker { animation: pe-cone 1.7s ease-in-out infinite; }
.pe-rack.is-idle .pe-speaker { animation-play-state: paused; }

.pe-screw {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #9aa3ae, #4a515b 60%, #272c33);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.7), inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.pe-screw::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 1.4px;
  background: rgba(0, 0, 0, 0.6);
  transform: translate(-50%, -50%) rotate(28deg);
}
.pe-screw.is-tl { left: 7px; top: 7px; }
.pe-screw.is-tr { right: 7px; top: 7px; }
.pe-screw.is-bl { left: 7px; bottom: 7px; }
.pe-screw.is-br { right: 7px; bottom: 7px; }

.pe-cab-badge {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  padding: 3px 11px;
  border-radius: 4px;
  border: 1px solid rgba(255, 228, 196, 0.22);
  background: rgba(12, 9, 6, 0.75);
  color: rgba(255, 228, 196, 0.72);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  max-width: 86%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Medidor de saída ---------- */
.pe-meter {
  margin-bottom: 14px;
  padding: 10px 11px 7px;
  border: 1px solid var(--pe-line);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(5, 8, 15, 0.8), rgba(12, 18, 30, 0.6));
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
}
.pe-meter-leds {
  display: flex;
  align-items: stretch;
  gap: 3px;
  height: 30px;
}
/* cada led mora num soquete escuro; o brilho é o ::after que sobe */
.pe-meter-leds i {
  position: relative;
  flex: 1;
  border-radius: 2px;
  background: rgba(238, 246, 255, 0.05);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.pe-meter-leds i::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, #86efac, #22c55e);
  box-shadow: 0 0 7px rgba(74, 222, 128, 0.7);
  transform-origin: bottom;
  transform: scaleY(0.18);
  animation: pe-meter 1.45s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.055s);
}
.pe-meter-leds i:nth-child(n + 13)::after {
  background: linear-gradient(180deg, #fde68a, #f59e0b);
  box-shadow: 0 0 7px rgba(251, 191, 36, 0.7);
}
.pe-meter-leds i:nth-child(n + 17)::after {
  background: linear-gradient(180deg, #fda4af, #e11d48);
  box-shadow: 0 0 8px rgba(255, 92, 122, 0.8);
}
.pe-rack.is-idle .pe-meter-leds i::after { animation-play-state: paused; }
.pe-meter-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.56rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}
.pe-meter-scale em { font-style: normal; }

.pe-info { display: grid; gap: 8px; margin: 0; padding: 0; }
.pe-info div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  background: rgba(238, 246, 255, 0.04);
  font-size: 0.8rem;
}
.pe-info dt { color: var(--muted); margin: 0; }
.pe-info dd { margin: 0; color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }

.pe-actions { display: grid; gap: 8px; margin-top: 14px; }
.pe-actions .pe-btn { justify-content: center; width: 100%; }

/* ---------------- Console de conexão ---------------- */
.pe-log {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--pe-line);
  border-radius: 14px;
  background: rgba(5, 8, 15, 0.55);
  font-size: 0.78rem;
  line-height: 1.6;
}
.pe-log h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.pe-log ol {
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  color: var(--muted);
}
.pe-log li { padding: 2px 0; }
.pe-log li b { color: var(--pe-led); font-weight: 600; }
.pe-log li.is-warn b { color: var(--pe-amber); }
.pe-log li.is-err b { color: var(--pe-red); }

.pe-demo-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border: 1px dashed rgba(var(--pe-amber-rgb), 0.5);
  border-radius: 999px;
  color: var(--pe-amber);
  font-size: 0.72rem;
  font-weight: 650;
}

/* ---------------- Animações ---------------- */
@keyframes pe-flow {
  0% { left: -14%; opacity: 0; }
  14% { opacity: 1; }
  86% { opacity: 1; }
  100% { left: 104%; opacity: 0; }
}
@keyframes pe-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
/* O translate precisa vir junto: transform substitui, não acumula — sem isso
   o alto-falante salta para fora do centro assim que a animação começa. */
@keyframes pe-cone {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.04); }
}
@keyframes pe-meter {
  0%, 100% { transform: scaleY(0.2); }
  50% { transform: scaleY(1); }
}

@media (prefers-reduced-motion: reduce) {
  .pe-wire span, .pe-cone, .pe-meter i, .pe-badge i { animation: none; }
}

@media (max-width: 1100px) {
  .pe-grid { grid-template-columns: 200px minmax(0, 1fr); }
  .pe-side { grid-column: 1 / -1; }
  .pe-side .pe-cab { height: 120px; }
}
@media (max-width: 760px) {
  .pe-grid { grid-template-columns: minmax(0, 1fr); }
  .pe-top { position: static; }
  .pe-slot { flex: 1 1 74px; min-width: 70px; }
  .pe-wire { flex-basis: 8px; }
}

/* ---------- Acabamento ---------- */

/* Serigrafia em volta do botão */
.pe-knob-tick {
  stroke: rgba(238, 246, 255, 0.22);
  stroke-width: 1.2;
  stroke-linecap: round;
}
.pe-knob-tick.is-long {
  stroke: rgba(238, 246, 255, 0.4);
  stroke-width: 1.6;
}
.pe-knob.is-drag .pe-knob-tick { stroke: rgba(var(--b-rgb), 0.45); }
.pe-knob.is-drag .pe-knob-tick.is-long { stroke: rgba(var(--b-rgb), 0.8); }

/* Relevo no corpo do botão: luz em cima, sombra embaixo */
.pe-knob svg { filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.45)); }
.pe-knob.is-drag .pe-knob-val { color: var(--b); }

/* Pisada no bloco: afunda e a luz responde, como um footswitch */
.pe-slot:active {
  transform: translateY(1px) scale(0.985);
  transition-duration: 0.06s;
}
.pe-slot.is-on:active .pe-slot-led {
  box-shadow: 0 0 16px var(--b), 0 0 34px rgba(var(--b-rgb), 0.8);
}
.pe-slot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(60% 50% at 50% 0%, rgba(var(--b-rgb), 0.22), transparent 70%);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.pe-slot.is-on::after { opacity: 0.7; }
.pe-slot.is-sel::after { opacity: 1; }

/* Depois de um bloco desligado o sinal passa, mas sem brilho: o cabo conta
   a história da cadeia em vez de piscar sempre igual. */
.pe-slot.is-off + .pe-wire span {
  opacity: 0.22;
  box-shadow: none;
  background: rgba(238, 246, 255, 0.5);
}

/* Brilho de válvula atrás do painel quando o bloco é o amplificador */
.pe-panel { position: relative; overflow: hidden; }
.pe-panel::before {
  content: "";
  position: absolute;
  right: -8%;
  top: -40%;
  width: 46%;
  height: 180%;
  background: radial-gradient(50% 40% at 50% 50%, rgba(var(--b-rgb), 0.22), transparent 70%);
  filter: blur(14px);
  pointer-events: none;
  animation: pe-glow 4.2s ease-in-out infinite;
}
@keyframes pe-glow {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .pe-panel::before { animation: none; }
}

/* ---------- Timbres salvos na conta ---------- */
.pe-mine {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--pe-line);
}
.pe-mine-list { display: grid; gap: 6px; margin-bottom: 10px; }
.pe-mine-empty {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}
.pe-mine-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  gap: 4px;
  align-items: stretch;
}
.pe-mine-open {
  display: grid;
  gap: 1px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--pe-line);
  border-radius: 10px;
  background: var(--pe-metal);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.16s ease, transform 0.16s ease;
}
.pe-mine-open:hover {
  border-color: rgba(var(--pe-amber-rgb), 0.5);
  transform: translateX(2px);
}
.pe-mine-open b {
  font-size: 0.82rem;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pe-mine-open em {
  color: var(--muted);
  font-size: 0.68rem;
  font-style: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pe-mine-del {
  border: 1px solid var(--pe-line);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.16s ease;
}
.pe-mine-del:hover {
  border-color: rgba(255, 92, 122, 0.5);
  background: rgba(255, 92, 122, 0.12);
  color: var(--pe-red);
}
.pe-mine-save { justify-content: center; width: 100%; }

/* ---------- Folha da biblioteca ---------- */
.pe-sheet {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(3, 6, 12, 0.72);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.22s ease;
}
.pe-sheet.is-in { opacity: 1; }
.pe-sheet-box {
  width: min(980px, 100%);
  max-height: 86vh;
  overflow: auto;
  padding: 22px 24px 26px;
  border: 1px solid var(--pe-line);
  border-radius: 20px;
  background: linear-gradient(170deg, rgba(22, 32, 54, 0.98), rgba(8, 14, 26, 0.99));
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.7);
  transform: translateY(14px) scale(0.985);
  transition: transform 0.26s cubic-bezier(.22, 1, .36, 1);
}
.pe-sheet.is-in .pe-sheet-box { transform: none; }
.pe-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.pe-sheet-head h3 { margin: 0; font-size: 1.2rem; letter-spacing: -0.01em; }
.pe-sheet-x {
  width: 34px;
  height: 34px;
  border: 1px solid var(--pe-line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.16s ease;
}
.pe-sheet-x:hover { color: var(--ink); border-color: rgba(var(--pe-amber-rgb), 0.5); }
.pe-sheet-sub {
  margin: 6px 0 18px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}
.pe-sheet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(226px, 1fr));
  gap: 12px;
}
.pe-lib-card {
  display: grid;
  gap: 7px;
  padding: 15px 16px 14px;
  border: 1px solid var(--pe-line);
  border-radius: 14px;
  background: linear-gradient(165deg, rgba(var(--t-rgb), 0.1), rgba(5, 8, 15, 0.7));
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.pe-lib-card:hover {
  transform: translateY(-4px);
  border-color: rgba(var(--t-rgb), 0.6);
  box-shadow: 0 18px 38px rgba(var(--t-rgb), 0.2);
}
.pe-lib-tag {
  justify-self: start;
  padding: 3px 9px;
  border: 1px solid rgba(var(--t-rgb), 0.45);
  border-radius: 999px;
  color: var(--t);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.pe-lib-card b { font-size: 1rem; font-weight: 650; }
.pe-lib-card em {
  color: var(--muted);
  font-size: 0.8rem;
  font-style: normal;
  line-height: 1.45;
}
.pe-lib-chain { display: flex; flex-wrap: wrap; gap: 4px; }
.pe-lib-chain i {
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(238, 246, 255, 0.07);
  color: var(--muted);
  font-size: 0.66rem;
  font-style: normal;
}
@media (prefers-reduced-motion: reduce) {
  .pe-sheet, .pe-sheet-box { transition: none; }
}

/* ====================================================================
   Ferramentas de criação
   ====================================================================
   Desfazer, comparar A/B, ajuste rápido e variações. Tudo desenhado como
   equipamento — placa de metal, serigrafia, LED — para não parecer um
   formulário colado em cima da pedaleira.
   ==================================================================== */

/* ---------- Barra de ferramentas da cadeia ---------- */
.pe-tools {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}
.pe-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border: 1px solid var(--pe-line);
  border-radius: 999px;
  background: rgba(238, 246, 255, 0.04);
  color: var(--muted);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 620;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}
.pe-tool svg { width: 15px; height: 15px; }
.pe-tool:hover:not([disabled]) {
  border-color: rgba(var(--pe-amber-rgb), 0.5);
  background: rgba(var(--pe-amber-rgb), 0.1);
  color: var(--ink);
}
.pe-tool[disabled] { opacity: 0.38; cursor: not-allowed; }

/* O A/B é um chaveador: duas pastilhas, a acesa é a que está soando. */
.pe-ab {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--pe-line);
  border-radius: 999px;
  background: linear-gradient(170deg, rgba(5, 8, 15, 0.6), rgba(238, 246, 255, 0.05));
  cursor: pointer;
  transition: border-color 0.16s ease;
}
.pe-ab i {
  display: grid;
  place-items: center;
  width: 26px;
  height: 22px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 750;
  letter-spacing: 0.04em;
  transition: all 0.18s ease;
}
.pe-ab.is-armed { border-color: rgba(var(--pe-led-rgb), 0.45); }
.pe-ab.is-armed i.is-live {
  background: rgba(var(--pe-led-rgb), 0.9);
  color: #04120a;
  box-shadow: 0 0 12px rgba(var(--pe-led-rgb), 0.5);
}
.pe-ab:hover { border-color: rgba(var(--pe-amber-rgb), 0.5); }

/* ---------- Ajuste rápido ---------- */
.pe-macros {
  margin-top: 14px;
  padding: 16px 16px 14px;
  border: 1px solid var(--pe-line);
  border-radius: 16px;
  background: linear-gradient(168deg, rgba(238, 246, 255, 0.045), rgba(5, 8, 15, 0.42));
}
.pe-macros-head { margin-bottom: 12px; }
.pe-macros-head h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
}
.pe-macros-head h3 svg {
  width: 17px;
  height: 17px;
  color: var(--pe-amber);
}
.pe-macros-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.5;
}
.pe-macro-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(188px, 1fr));
  gap: 8px;
}
.pe-macro {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 8px 9px;
  border: 1px solid var(--pe-line);
  border-radius: 12px;
  background: var(--pe-metal);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.pe-macro:hover {
  border-color: rgba(var(--m-rgb), 0.45);
  box-shadow: inset 0 0 0 1px rgba(var(--m-rgb), 0.12);
}
.pe-macro-ico {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: rgba(var(--m-rgb), 0.14);
  color: var(--m);
}
.pe-macro-ico svg { width: 17px; height: 17px; }
.pe-macro-tt { display: grid; gap: 1px; min-width: 0; }
.pe-macro-tt b {
  font-size: 0.8rem;
  font-weight: 650;
}
.pe-macro-tt em {
  color: var(--muted);
  font-size: 0.66rem;
  font-style: normal;
  line-height: 1.35;
}
.pe-macro-pm {
  display: flex;
  gap: 4px;
}
.pe-macro-pm button {
  width: 27px;
  height: 27px;
  border: 1px solid var(--pe-line);
  border-radius: 8px;
  background: rgba(5, 8, 15, 0.45);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: all 0.14s ease;
}
.pe-macro-pm button:hover {
  border-color: rgba(var(--m-rgb), 0.6);
  background: rgba(var(--m-rgb), 0.18);
  color: var(--m);
}
.pe-macro-pm button:active { transform: scale(0.9); }

/* Um lampejo na cor da macro ao aplicar: confirma que algo mudou mesmo quando
   o movimento acontece num botão que está fora da vista. */
.pe-macro.is-pulse { animation: pe-macro-pulse 0.5s ease-out; }
@keyframes pe-macro-pulse {
  0% { box-shadow: inset 0 0 0 1px rgba(var(--m-rgb), 0.9), 0 0 0 0 rgba(var(--m-rgb), 0.45); }
  100% { box-shadow: inset 0 0 0 1px rgba(var(--m-rgb), 0), 0 0 0 14px rgba(var(--m-rgb), 0); }
}

/* ---------- Variações ---------- */
.pe-vars {
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px dashed var(--pe-line);
}
.pe-vars-lbl {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.pe-vars-lbl svg {
  width: 14px;
  height: 14px;
  color: var(--pe-led);
}
.pe-vars-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
  gap: 7px;
}
.pe-var {
  display: grid;
  gap: 1px;
  align-content: start;
  padding: 8px 12px;
  border: 1px solid var(--pe-line);
  border-radius: 11px;
  background: rgba(238, 246, 255, 0.035);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}
.pe-var b { font-size: 0.78rem; font-weight: 650; }
.pe-var em {
  color: var(--muted);
  font-size: 0.65rem;
  font-style: normal;
  line-height: 1.35;
}
.pe-var:hover {
  transform: translateY(-2px);
  border-color: rgba(var(--pe-led-rgb), 0.45);
  background: rgba(var(--pe-led-rgb), 0.08);
}
.pe-var:active { transform: translateY(0); }

/* Mesma linha repetida vira um contador, em vez de rolar o log inteiro. */
.pe-log-n {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(238, 246, 255, 0.1);
  color: var(--muted);
  font-size: 0.62rem;
  font-style: normal;
  font-weight: 700;
}

/* ---------- Operações do timbre salvo ---------- */
.pe-mine-item { grid-template-columns: minmax(0, 1fr) auto; }
.pe-mine-item.is-open .pe-mine-open {
  border-color: rgba(var(--pe-amber-rgb), 0.55);
  background: linear-gradient(170deg, rgba(var(--pe-amber-rgb), 0.14), rgba(5, 8, 15, 0.5));
}
.pe-mine-ops { display: flex; gap: 3px; }
.pe-mine-ops button {
  display: grid;
  place-items: center;
  width: 26px;
  border: 1px solid var(--pe-line);
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.16s ease;
}
.pe-mine-ops button svg { width: 14px; height: 14px; }
.pe-mine-ops button:hover {
  border-color: rgba(var(--pe-amber-rgb), 0.5);
  background: rgba(var(--pe-amber-rgb), 0.1);
  color: var(--ink);
}
.pe-mine-ops .pe-mine-del:hover {
  border-color: rgba(255, 92, 122, 0.5);
  background: rgba(255, 92, 122, 0.12);
  color: var(--pe-red);
}

@media (max-width: 760px) {
  .pe-chain-head { flex-wrap: wrap; }
  .pe-tools { width: 100%; justify-content: flex-start; }
  .pe-tool span { display: none; }
  .pe-tool { padding: 7px 9px; }
  .pe-macro-row, .pe-vars-row { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .pe-macro.is-pulse { animation: none; }
  .pe-var:hover, .pe-macro-pm button:active { transform: none; }
}
