.by-app {
  --by-back: #130b1c;
  --by-panel: #21142e;
  --by-border: #543961;
  --by-muted: #c9b6d2;
  --by-gold: #ffce59;
  --by-light: #fff3dc;
  --by-step: #3a2550;
  --by-step-beat: #4b3165;
  --by-house: #b38cff;
  --by-boom: #ffd075;
  --by-broken: #f392b9;
  --by-trap: #88d7cd;
  min-height: 100vh;
  padding: clamp(24px, 5vw, 72px) clamp(12px, 4vw, 52px);
  background-color: var(--by-back);
  background-image: radial-gradient(ellipse at 18% 6%, #342049 0, transparent 50%), radial-gradient(ellipse at 95% 75%, #251737 0, transparent 56%);
  color: var(--by-light);
  font-family: 'LM Charte Sans', system-ui, sans-serif;
  color-scheme: dark;
}
body:has(> .by-app) { margin: 0; }
.by-app *, .by-app *::before, .by-app *::after { box-sizing: border-box; }
.by-wrap { max-width: 1120px; margin: auto; }
.by-app button, .by-app input { font: inherit; }
.by-app button { cursor: pointer; }
.by-app button:disabled { cursor: progress; }
.by-app :focus-visible { outline: 2px solid #fff1b5; outline-offset: 3px; }
.by-app [hidden] { display: none; }

.by-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px 32px;
  margin: 0 0 clamp(24px,4vw,42px);
  padding: 0 clamp(2px,1.4vw,16px);
}
.by-signature {
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: .75rem;
  font-weight: 750;
  letter-spacing: .23em;
}
.by-signature::before { content: ""; display: block; width: 26px; height: 2px; background: var(--by-gold); }
.by-brand h1 {
  margin: 0;
  color: var(--by-gold);
  font-size: clamp(2.65rem, 7vw, 6.25rem);
  font-weight: 950;
  line-height: .9;
  letter-spacing: -.052em; word-spacing: .08em;
  text-wrap: nowrap;
}
.by-description { color: var(--by-muted); margin: 15px 0 0; font-size: clamp(.85rem,1.8vw,1rem); }
.by-transport { display: flex; align-items: stretch; gap: 8px; flex-shrink: 0; }
.by-play, .by-tempo {
  display: inline-flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 8px;
  font-weight: 800;
}
.by-play {
  min-width: 106px;
  padding: 0 13px;
  color: #1d1027;
  background: var(--by-gold);
  border: 1px solid #ffe28a;
  box-shadow: 0 3px 0 #9e662d;
}
.by-play:hover { background: #ffdf85; }
.by-play[aria-pressed="true"] { background: var(--by-light); box-shadow: 0 3px 0 #8b6a75; }
.by-play:disabled { opacity: .72; }
.by-transport-icon { width: 0; height: 0; border-left: 10px solid currentColor; border-top: 6px solid transparent; border-bottom: 6px solid transparent; }
.by-play[aria-pressed="true"] .by-transport-icon { width: 10px; height: 10px; border: 0; background: currentColor; }
.by-tempo { gap: 3px; color: var(--by-muted); background: #21142e; border: 1px solid var(--by-border); padding: 0 10px; }
.by-tempo span { font-weight: 750; font-size: .68rem; letter-spacing: .05em; }
.by-tempo input { appearance: textfield; width: 2.7em; min-width: 0; border: 0; padding: 4px; background: none; color: var(--by-light); text-align: center; font-weight: 800; border-radius: 3px; font-variant-numeric: tabular-nums; }
.by-tempo input::-webkit-outer-spin-button, .by-tempo input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.by-machine {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(12px, 2vw, 18px);
  padding: clamp(6px, 1.2vw, 12px);
  background-color: #2c1d3e;
  background-image: linear-gradient(143deg,#3d2854,#241634 65%);
  border: 1px solid #60446d;
  border-radius: 18px;
  box-shadow: 0 18px 70px #05030680, 0 3px 0 #100916;
}
.by-panel {
  min-width: 0;
  border: 1px solid #4c355f;
  border-radius: 12px;
  padding: clamp(11px, 2.1vw, 24px);
  background: var(--by-panel);
}
.by-panel-header { min-height: 27px; display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 14px; }
.by-panel-header h2 {
  margin: 0;
  font-size: .92rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .17em;
}
.by-quiet-button { background: transparent; color: var(--by-muted); border: 1px solid transparent; border-radius: 6px; padding: 6px 8px; font-size: .77rem !important; font-weight: 700 !important; white-space: nowrap; }
.by-quiet-button:hover { color: var(--by-light); border-color: var(--by-border); }
.by-quiet-button:disabled { cursor: default; opacity: .44; }

.by-bars { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(10px, 1.8vw, 24px); }
.by-bar { min-width: 0; }
.by-bar h3 { margin: 0 0 8px; color: var(--by-muted); font-size: .73rem; text-transform: uppercase; font-weight: 800; letter-spacing: .12em; }
.by-steps {
  display: grid;
  grid-template-columns: var(--by-track-size, 55px) repeat(16, minmax(0, 1fr));
  gap: var(--by-gutter, 3px);
  align-items: center;
}
.by-counter { font-size: .59rem; color: var(--by-muted); text-align: center; font-weight: 750; font-variant-numeric: tabular-nums; }
.by-counter.is-current { color: var(--by-gold); }
.by-mute { border: 1px solid #59406f; border-radius: 4px; background: #342344; color: var(--by-light); min-width: 0; min-height: 29px; padding: 2px 3px; text-align: left; font-weight: 800 !important; font-size: .61rem !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.by-mute[aria-pressed="true"] { background: #22162e; color: #ac99b8; }
.by-step {
  border: 1px solid transparent;
  border-radius: 4px;
  height: clamp(23px,2.7vw,37px);
  padding: 0;
  min-width: 0;
  background: var(--by-step);
  box-shadow: 0 2px 0 #1a1025;
}
.by-step[data-downbeat] { background: var(--by-step-beat); }
.by-step[data-active] { background: #dbaf52; background-image: linear-gradient(160deg, #ffd77a, #af7830); border-color: #f6c66d; }
.by-step[data-active][data-muted] { background: #7c6334; border-color: #967147; }
.by-step.is-current { border-color: #b991ea; background-color: #655078; }
.by-step[data-active].is-current { border-color: #fff3b3; box-shadow: 0 0 10px #ffd56b4d; }
.by-step:hover, .by-mute:hover { border-color: var(--by-light); }
.by-step:focus-visible { outline-offset: 0; }
.by-hint, .by-status { color: var(--by-muted); font-size: .78rem; line-height: 1.5; }
.by-hint { margin: 14px 0 0; }
.by-status { min-height: 1.6em; margin: 10px 8px 0; }

.by-morph-section .by-panel-header h2 { color: var(--by-gold); }
.by-morph-content { display: grid; grid-template-columns: minmax(170px, 272px) auto; gap: clamp(15px,3vw,35px); align-items: center; }
.by-pad {
  --point-x: 6%;
  --point-y: 16%;
  position: relative;
  aspect-ratio: 1 / 1;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid #76568e;
  border-radius: 9px;
  background: radial-gradient(ellipse at 0% 0%,#64439a 0, transparent 69%), radial-gradient(ellipse at 100% 0%,#76562c 0, transparent 69%), radial-gradient(ellipse at 0% 100%,#73355d 0, transparent 69%),radial-gradient(ellipse at 100% 100%,#315b58 0,transparent 69%),#362540;
  cursor: crosshair;
  touch-action: none;
}
.by-pad::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(#f8e8ff1d 1px, transparent 1px), linear-gradient(90deg,#f8e8ff1d 1px, transparent 1px);
  background-size: 12.5% 12.5%;
  pointer-events: none;
}
.by-puck, .by-cross-x, .by-cross-y, .by-pad-percent { position: absolute; pointer-events: none; }
.by-puck {
  z-index: 2;
  left: var(--point-x);
  top: var(--point-y);
  transform: translate(-50%,-50%);
  width: 17px;
  height: 17px;
  border-radius: 100%;
  background: #ffd577;
  border: 2px solid #21142e;
  box-shadow: 0 0 0 9px #ffca6030, 0 0 20px #efbe6873;
}
.by-cross-x { left: var(--point-x); top: 1px; bottom: 1px; border-left: 1px solid #fff4cf6b; }
.by-cross-y { left: 1px; right: 1px; top: var(--point-y); border-top: 1px solid #fff4cf6b; }
.by-pad-percent { color: var(--by-light); opacity: .9; width: 4ch; font-weight: 750; font-size: clamp(.63rem,1.25vw,.82rem); font-variant-numeric: tabular-nums; }
.by-nw { left: 9px; top: 8px; }
.by-ne { right: 9px; top: 8px; text-align: right; }
.by-sw { left: 9px; bottom: 8px; }
.by-se { right: 9px; bottom: 8px; text-align: right; }
.by-morph-options { max-width: 400px; }
.by-morph-options p { margin: 0 0 14px; font-size: .87rem; line-height: 1.55; color: var(--by-muted); }
.by-corners { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.by-corner {
  --color: var(--by-house);
  min-width: 0;
  text-align: left;
  display: flex;
  gap: 7px;
  align-items: center;
  padding: 8px;
  min-height: 41px;
  border: 1px solid #5d4574;
  border-radius: 7px;
  background: #30213e;
  color: var(--by-light);
  font-weight: 750 !important;
  font-size: .78rem !important;
}
.by-corner:nth-child(2) { --color: var(--by-boom); }
.by-corner:nth-child(3) { --color: var(--by-broken); }
.by-corner:nth-child(4) { --color: var(--by-trap); }
.by-color { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; background: var(--color); }
.by-corner:hover, .by-corner.is-dominant { border-color: var(--color); }

@media (max-width: 805px) {
  .by-bars { grid-template-columns: 1fr; gap: 15px; }
  .by-steps { --by-gutter: 2px; --by-track-size: 45px; }
  .by-step { height: clamp(23px, 5vw, 36px); }
  .by-mute { min-height: clamp(23px, 5vw, 36px); }
}
@media (max-width: 530px) {
  .by-app { padding-inline: 9px; }
  .by-heading { align-items: start; flex-direction: column; }
  .by-morph-content { grid-template-columns: minmax(0,1fr); gap: 12px; }
  .by-pad { width: min(100%, 270px); }
  .by-morph-options p { font-size: .8rem; }
}
@media (prefers-reduced-motion: reduce) {
  .by-app *, .by-app *::before, .by-app *::after { scroll-behavior: auto; }
}

.by-nav { display: flex; justify-content: space-between; gap: 12px; margin: 0 0 clamp(18px, 4vw, 38px); padding: 0 clamp(2px,1.4vw,16px) 12px; border-bottom: 1px solid #87609945; }
.by-nav a { color: var(--by-muted); text-underline-offset: .28em; font-size: .83rem; font-weight: 750; }
.by-nav a:hover { color: var(--by-light); }
.by-sequence-controls { display: flex; gap: 6px; align-items: center; }
.by-app .by-preset { min-width: 0; max-width: 100%; padding: 6px 7px; border: 1px solid var(--by-border); border-radius: 6px; background: #2d1d3c; color: var(--by-light); font: 750 .76rem/1.2 'LM Charte Sans', system-ui, sans-serif; }
.by-step { color: #2a1835; font-size: clamp(.45rem, .83vw, .62rem) !important; font-weight: 800 !important; font-variant-numeric: tabular-nums; }
.by-step[data-muted] { opacity: .62; }
.by-energy { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin-top: 14px; color: var(--by-light); font-size: .8rem; font-weight: 750; }
.by-energy output { justify-self: end; color: var(--by-gold); font-variant-numeric: tabular-nums; }
.by-energy input { grid-column: 1 / -1; width: 100%; margin: 0; min-height: 24px; accent-color: var(--by-gold); cursor: pointer; }
@media (max-width: 530px) {
  .by-app:lang(en) .by-panel-header h2, .by-app:lang(fr) .by-panel-header h2 { font-size: .78rem; letter-spacing: .1em; }
  .by-sequence .by-panel-header { flex-wrap: wrap; row-gap: 7px; }
  .by-app .by-preset { font-size: .72rem; }
}
