:root {
  color-scheme: dark;
  --background: #000;
  --card: #101010;
  --ink: #ededed;
  --quiet: #aaa;
  --line: #303030;
  --orange: #ffc06a;
  --screen: #080808;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-family: system-ui, sans-serif;
  color: var(--ink);
  background: var(--background);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; }
button { cursor: pointer; color: inherit; }
button:disabled { cursor: wait; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 3px;
}

.frame { width: min(1120px, calc(100% - 72px)); margin-inline: auto; }
.site-header { border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; min-height: 48px; }
.home { color: var(--quiet); text-decoration: none; font-size: .9rem; font-weight: 650; letter-spacing: -.025em; }
.home:hover { text-decoration: underline; }
.intro { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 26px 0 22px; }
h1 { margin: 0; font-size: clamp(1.75rem, 3.5vw, 2.5rem); line-height: 1; font-weight: 720; letter-spacing: -.06em; }
.transport { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.repeat { position: relative; display: inline-flex; align-items: center; gap: 8px; font-size: .875rem; white-space: nowrap; cursor: pointer; }
.repeat input, .waveform-options input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch { position: relative; width: 34px; height: 20px; flex: none; border: 1px solid #666; border-radius: 20px; background: #242424; }
.switch::after { content: ""; position: absolute; left: 3px; top: 3px; height: 12px; width: 12px; border-radius: 50%; background: #aaa; transition: transform .15s; }
.repeat input:checked + .switch, .mode-switch[aria-checked="true"] .switch { background: var(--orange); border-color: var(--orange); }
.repeat input:checked + .switch::after, .mode-switch[aria-checked="true"] .switch::after { transform: translateX(14px); background: #1a1209; }
.repeat input:focus-visible + .switch, .waveform-options input:focus-visible + span { outline: 2px solid var(--orange); outline-offset: 2px; }
.tempo { display: inline-flex; align-items: center; gap: 6px; color: var(--quiet); font: .875rem / 1 var(--mono); }
.tempo input { width: 65px; min-height: 40px; padding: 6px 5px 6px 9px; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.play { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 105px; min-height: 40px; padding: 0 12px; border: 0; border-radius: 6px; background: var(--orange); color: #1a1209; font-size: .92rem; font-weight: 750; white-space: nowrap; }
.play:hover { background: #ffcc88; }
.download { min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); font-size: .875rem; white-space: nowrap; }
.download:hover:not(:disabled) { border-color: #777; }
.download:disabled { color: var(--quiet); opacity: .65; cursor: default; }
.play-icon { border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-left: 9px solid currentColor; }
.play[data-stoppable] .play-icon { width: 10px; height: 10px; border: 0; background: currentColor; }
kbd { padding: 4px 5px; border: 1px solid #cd9350; border-radius: 4px; font: .67rem / 1 var(--mono); }

.workspace { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(320px, 1fr); gap: 16px; }
.monitor, .parameters { min-width: 0; border: 1px solid var(--line); border-radius: 9px; }
.monitor { display: flex; flex-direction: column; padding: 18px; background: var(--screen); }
.monitor-header, .parameters-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
h2 { margin: 0; font-size: 1.05rem; font-weight: 650; line-height: 1.3; }
.view-controls { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 6px; }
.view-controls button { padding: 5px 9px; min-height: 30px; border: 0; border-radius: 4px; background: transparent; color: var(--quiet); font-size: .875rem; }
.view-controls button:hover { color: #fff; }
.view-controls button[aria-pressed="true"] { color: var(--ink); background: #2b2b2b; }
#plot { display: block; width: 100%; height: 265px; flex: 1 1 265px; margin: 15px 0 12px; }
.readouts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding-top: 13px; border-top: 1px solid var(--line); }
.readouts > div { min-width: 0; padding-inline: 15px; }
.readouts > div:first-child { padding-left: 0; }
.readouts > div + div { border-left: 1px solid var(--line); }
.readouts span { display: block; margin-bottom: 5px; color: var(--quiet); font-size: .84rem; }
.readouts output { font: 700 1.4rem / 1.2 var(--mono); white-space: nowrap; }
.readouts small { color: var(--quiet); font-size: .8rem; }
#status { display: inline-flex; gap: 7px; align-items: center; font-family: inherit; font-size: .84rem; min-height: 26px; }
#status i { width: 6px; height: 6px; border-radius: 50%; background: #888; }
#status[data-state="active"] i { background: var(--orange); }
#audio-error { margin: 14px 0 0; color: #ffd09c; font-size: .875rem; }

.parameters { padding: 18px; background: var(--card); }
.parameter-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 6px; }
.reset, #randomize { padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--quiet); font-size: .875rem; }
.reset:hover { border-color: #666; color: var(--ink); }
.mode-switch { display: flex; align-items: center; gap: 6px; padding: 4px; border: 0; border-radius: 4px; background: transparent; font-size: .875rem; white-space: nowrap; }
.randomize-controls { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-top: 12px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; color: var(--quiet); font-size: .875rem; }
.randomize-controls[hidden] { display: none; }
.roll-actions { display: flex; gap: 6px; margin-left: auto; }
.scale-controls { display: flex; flex: 1 0 100%; flex-wrap: wrap; align-items: center; gap: 7px 14px; padding-top: 8px; border-top: 1px solid var(--line); }
.scale-controls select:disabled { color: var(--quiet); opacity: .65; }
#randomize { background: var(--orange); border-color: var(--orange); color: #1a1209; font-weight: 700; }
#randomize:hover { background: #ffcc88; }
#randomize:disabled { opacity: .55; cursor: default; }
.random-lock { display: none; position: relative; place-items: center; flex: none; width: 28px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: var(--screen); color: var(--quiet); }
[data-randomize-mode] .random-lock { display: grid; }
.random-lock:hover { border-color: #777; }
.random-lock[aria-pressed="true"] { border-color: #8c623b; background: #2d2014; color: var(--orange); }
.lock-icon { position: relative; width: 10px; height: 8px; margin-top: 5px; border: 1px solid currentColor; border-radius: 2px; }
.lock-icon::before { content: ""; position: absolute; left: 1px; top: -6px; width: 6px; height: 6px; border: 1px solid currentColor; border-bottom: 0; border-radius: 4px 4px 0 0; }
.random-lock[aria-pressed="false"] .lock-icon::before { transform: translate(3px, -1px) rotate(20deg); }
.waveforms { min-width: 0; margin: 19px 0 17px; }
.waveform-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 7px; }
.waveform-heading, .slider label { font-size: .875rem; font-weight: 650; }
.waveform-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 6px; }
.waveform-options label { display: grid; position: relative; min-width: 0; }
.waveform-options span { display: grid; place-items: center; padding: 5px 2px; min-height: 31px; border-radius: 4px; text-align: center; font-size: .875rem; cursor: pointer; line-height: 1.15; }
.waveform-options label:hover span { background: #242424; }
.waveform-options input:checked + span { background: #343434; color: var(--ink); }
.sliders { display: grid; gap: 9px; }
.slider { display: grid; grid-template-columns: 1fr auto; align-items: center; row-gap: 2px; }
[data-randomize-mode] .slider:has(.random-lock) { grid-template-columns: 1fr auto auto; column-gap: 7px; }
.slider output { font: 650 .875rem / 1.2 var(--mono); color: var(--orange); white-space: nowrap; }
#repeat-duration { grid-column: 1 / -1; margin: 0; color: var(--quiet); font-size: .8rem; }
.slider input {
  grid-column: 1 / -1;
  appearance: none;
  width: 100%;
  height: 18px;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.slider input::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: linear-gradient(to right, #967044 var(--fill), #383838 var(--fill)); }
.slider input::-moz-range-track { height: 3px; border-radius: 3px; background: linear-gradient(to right, #967044 var(--fill), #383838 var(--fill)); }
.slider input::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; margin-top: -4.5px; border-radius: 50%; background: var(--orange); }
.slider input::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--orange); }

.disclosure { position: relative; border: 1px solid var(--line); border-radius: 9px; background: var(--card); }
.effects { margin-top: 16px; }
.rhythm { margin-bottom: 16px; }
.disclosure summary { display: flex; align-items: center; gap: 10px; min-height: 46px; list-style: none; padding: 12px 80px 12px 18px; font-size: .95rem; font-weight: 650; cursor: pointer; }
.disclosure summary::-webkit-details-marker { display: none; }
.disclosure summary::after { content: ""; width: 12px; height: 12px; background: linear-gradient(var(--quiet), var(--quiet)) center / 100% 1px no-repeat, linear-gradient(var(--quiet), var(--quiet)) center / 1px 100% no-repeat; }
.disclosure details[open] summary::after { background-size: 100% 1px, 0 0; }
.disclosure-reset { position: absolute; top: 7px; right: 18px; }
.rhythm details:not([open]) + .disclosure-reset { display: none; }
.effect-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 0 18px 15px; }
.effect-grid fieldset { min-width: 0; margin: 0; padding: 7px 10px 9px; border: 1px solid var(--line); border-radius: 6px; }
.effect-grid legend { padding: 0 4px; color: var(--quiet); font-size: .875rem; font-weight: 650; }
.effect-grid .slider + .slider, .effect-select + .slider { margin-top: 7px; }
.slider + .effect-select { margin-top: 7px; }
.effect-select { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: .875rem; font-weight: 650; }
.effect-select label { margin-right: auto; }
.effect-select select { min-width: 0; padding: 3px 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--screen); color: var(--ink); font-weight: 500; }
.effects [hidden] { display: none; }
.synced-delay, .rhythm-guide { margin: 5px 0 7px; color: var(--quiet); font-size: .8rem; }
.effect-check { display: flex; width: fit-content; align-items: center; gap: 6px; margin-top: 6px; font-size: .875rem; cursor: pointer; }
.effect-check input { margin: 0; accent-color: var(--orange); }
.rhythm-controls { padding: 0 18px 15px; }
.rhythm-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; margin-bottom: 8px; }
.rhythm-heading .rhythm-guide { margin: 0; }
#rhythm-steps { display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 4px; }
.rhythm-step { min-height: 30px; padding: 2px 0; border: 1px solid var(--line); border-radius: 4px; background: var(--screen); color: var(--quiet); font: .8rem / 1 var(--mono); }
.rhythm-step:hover { border-color: #777; }
.rhythm-step[aria-pressed="true"] { background: #2d2014; border-color: #8c623b; color: var(--orange); }
.rhythm-step[data-playing] { background: var(--orange); border-color: var(--orange); color: #1a1209; }
.rhythm-step[aria-disabled="true"] { cursor: default; }

.presets { padding: 23px 0 32px; }
.presets h2 { margin-bottom: 10px; }
.preset-list { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 9px; }
.preset { display: grid; gap: 5px; justify-items: start; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); text-align: left; }
.preset:hover { border-color: #777; }
.preset[aria-pressed="true"] { border-color: #aa7f4d; background: #1b1610; }
.preset strong { font-size: .9rem; }
.preset small { color: var(--quiet); font: .76rem / 1.2 var(--mono); }

/* Short visible labels for the compact Effects rows; the full label stays the accessible name. */
.label-short { display: none; }

/* Narrow layout, taken from the 9:16 video version: the monitor spans the width,
   with Parameters and Effects side by side below it (one column on phones). */
@media (max-width: 830px) {
  .frame { width: calc(100% - 40px); }
  #ping { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: stretch; }
  #ping > .intro, #ping > .rhythm, .monitor, #ping > .presets { grid-column: 1 / -1; }
  .workspace { display: contents; }
  .rhythm, .effects { margin: 0; }
  .effects:has(details:not([open])) { align-self: start; }
  .monitor, .parameters { padding-inline: 16px; }
  #plot { height: 216px; flex: none; }
  .randomize-controls > span { flex: 1 0 100%; }
  .scale-controls { flex-wrap: nowrap; column-gap: 10px; min-width: 0; }
  .scale-controls .effect-select { min-width: 0; }
  .effect-grid { grid-template-columns: minmax(0, 1fr); padding: 0 14px 14px; }
  .effect-grid .label-full { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .effect-grid .label-short { display: inline; }
  /* One row per slider: label | track | value | lock */
  #ping .effect-grid .slider { grid-template-columns: 6rem minmax(0, 1fr) auto auto; column-gap: 6px; }
  .effect-grid .slider label { grid-area: 1 / 1; font-size: .8125rem; }
  .effect-grid .slider input { grid-area: 1 / 2; }
  .effect-grid .slider output { grid-area: 1 / 3; min-width: 9ch; text-align: right; font-size: .8125rem; }
  .effect-grid .slider .random-lock { grid-area: 1 / 4; width: 24px; height: 24px; }
  .effect-grid .slider + .slider, .effect-select + .slider, .slider + .effect-select { margin-top: 4px; }
  .effect-grid .effect-select { font-size: .8125rem; }
  .effect-grid .effect-select .random-lock { width: 24px; height: 24px; }
  .effect-grid .synced-delay { margin: 4px 0; }
  .preset-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .frame { width: calc(100% - 28px); }
  .header-inner { min-height: 49px; }
  .intro { flex-direction: column; align-items: stretch; gap: 18px; padding: 24px 0 16px; }
  .transport { gap: 10px; }
  .play { margin-left: auto; min-width: 72px; }
  kbd { display: none; }
  .monitor, .parameters { padding: 16px; }
  #plot { height: 218px; }
  .readouts > div { padding-inline: 9px; }
  .readouts output { font-size: 1.2rem; }
  .slider input { height: 26px; }
  .disclosure summary { padding-left: 14px; }
  .disclosure-reset { right: 14px; }
  .rhythm-controls { padding-inline: 14px; }
  #rhythm-steps { gap: 3px; }
  .rhythm-step { min-height: 34px; font-size: .7rem; }
  .preset { padding-inline: 8px; }
}

/* Below this, Parameters and Effects no longer fit side by side. */
@media (max-width: 699px) { #ping { grid-template-columns: minmax(0, 1fr); } }
@media (pointer: coarse) { kbd { display: none; } }
@media (prefers-reduced-motion: reduce) { .switch::after { transition: none; } }
