:root {
  color-scheme: dark;
  --ink: #070909;
  --canvas: #0c0f10;
  --panel: #111516;
  --panel-high: #1b2022;
  --pad: #202627;
  --line: #343b3d;
  --line-soft: #252b2d;
  --paper: #f1f3ec;
  --muted: #89918f;
  --acid: #c8ff3d;
  --acid-soft: #9fc82f;
  --danger: #ff675f;
  --warning: #ffbf48;
  --mono: "SFMono-Regular", "Roboto Mono", "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--ink);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--paper);
  background:
    linear-gradient(90deg, rgb(255 255 255 / 1.4%) 1px, transparent 1px) 0 0 / 48px 48px,
    #080a0b;
  font-family: var(--sans);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

button,
input { font: inherit; }

button,
input[type="range"],
.file-action,
.secondary-action { touch-action: manipulation; }

button { color: inherit; }

a { color: inherit; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
label:has(input:focus-visible) {
  outline: 3px solid var(--acid);
  outline-offset: 3px;
}

h1,
h2,
p { margin-top: 0; }

.sampler {
  width: min(1540px, calc(100% - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
  overflow: hidden;
  border: 1px solid #454d4f;
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgb(255 255 255 / 2.5%), transparent 24%),
    var(--canvas);
  box-shadow: 0 26px 80px rgb(0 0 0 / 45%), inset 0 1px rgb(255 255 255 / 8%);
}

.sampler-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 104px;
  padding: 19px 27px;
  border-bottom: 1px solid var(--line);
  background: #0d1011;
}

.brand-block { display: grid; gap: 4px; }

.tool-switcher {
  display: flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
}

.tool-switcher a {
  width: fit-content;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--muted);
  font: 750 0.59rem/1 var(--mono);
  letter-spacing: 0.12em;
  text-decoration: none;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}

.tool-switcher a:hover { color: var(--paper); border-color: var(--line); }
.tool-switcher a[aria-current="page"] { color: #101408; border-color: var(--acid); background: var(--acid); }

h1 {
  margin: 0;
  font-size: clamp(2.05rem, 4vw, 3.85rem);
  font-weight: 850;
  line-height: 0.9;
  letter-spacing: -0.075em;
}

h1 span { color: var(--acid); font-weight: 350; }

.brand-block > p {
  margin: 1px 0 0;
  color: var(--muted);
  font: 650 0.55rem/1 var(--mono);
  letter-spacing: 0.14em;
}

.header-utility { display: flex; align-items: center; gap: 16px; }

.engine-status {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 212px;
  padding: 10px 13px;
  border-left: 1px solid var(--line);
}

.engine-status small {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font: 650 0.56rem/1 var(--mono);
  letter-spacing: 0.12em;
}

.engine-status strong {
  display: block;
  max-width: 210px;
  overflow: hidden;
  font: 750 0.66rem/1.15 var(--mono);
  letter-spacing: 0.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-led {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #626a69;
  box-shadow: 0 0 0 5px rgb(255 255 255 / 3%);
}

.engine-status.is-ready .status-led {
  background: var(--acid);
  box-shadow: 0 0 14px rgb(200 255 61 / 70%), 0 0 0 5px rgb(200 255 61 / 8%);
}

.engine-status.is-warning .status-led { background: var(--warning); }
.engine-status.is-error .status-led { background: var(--danger); box-shadow: 0 0 12px rgb(255 103 95 / 45%); }

.stop-all-button,
.file-action,
.secondary-action,
.mode-button,
.interaction-button,
.toolbar-action,
.trim-preview-button,
.trim-apply-button,
.clear-kit-button,
.confirm-clear-button {
  border: 1px solid #4a5452;
  border-radius: 5px;
  background: #1a1f20;
  box-shadow: inset 0 1px rgb(255 255 255 / 6%), 0 3px 0 #060808;
  font: 800 0.66rem/1 var(--mono);
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: color 100ms ease, background 100ms ease, border-color 100ms ease, transform 100ms ease;
}

.stop-all-button:hover,
.file-action:hover,
.secondary-action:hover,
.mode-button:hover,
.interaction-button:hover,
.toolbar-action:hover,
.trim-preview-button:hover,
.trim-apply-button:hover,
.clear-kit-button:hover { border-color: #78817f; background: #22292a; }

.stop-all-button:active,
.file-action:active,
.secondary-action:active,
.mode-button:active,
.interaction-button:active,
.toolbar-action:active,
.trim-preview-button:active,
.trim-apply-button:active,
.clear-kit-button:active,
.confirm-clear-button:active {
  transform: translateY(2px);
  box-shadow: inset 0 1px rgb(255 255 255 / 5%), 0 1px 0 #060808;
}

.stop-all-button {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 13px;
  border-color: #68726f;
}

.stop-all-button > span {
  width: 9px;
  height: 9px;
  background: currentColor;
}

.stop-all-button kbd {
  padding: 4px 5px;
  border: 1px solid #525b59;
  border-radius: 3px;
  color: var(--muted);
  font: 650 0.52rem/1 var(--mono);
}

.section-label {
  margin: 0;
  color: var(--muted);
  font: 750 0.61rem/1 var(--mono);
  letter-spacing: 0.17em;
}

.drop-zone {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(240px, 1fr) auto auto;
  align-items: center;
  gap: 20px;
  min-height: 114px;
  padding: 17px 27px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgb(200 255 61 / 4%), transparent 38%),
    #111516;
  transition: background 130ms ease, box-shadow 130ms ease;
}

.drop-zone::after {
  position: absolute;
  inset: 7px;
  border: 1px dashed #38403f;
  border-radius: 7px;
  content: "";
  pointer-events: none;
  transition: border-color 130ms ease;
}

.drop-zone.is-dragging {
  background: linear-gradient(90deg, rgb(200 255 61 / 16%), rgb(200 255 61 / 5%)), #111516;
  box-shadow: inset 0 0 34px rgb(200 255 61 / 8%);
}

.drop-zone.is-dragging::after { border-color: var(--acid); }

.drop-signal {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 90px;
  height: 52px;
  padding: 0 4px;
}

.drop-signal i {
  width: 5px;
  height: calc(10px + var(--bar, 1) * 5px);
  border-radius: 1px;
  background: var(--acid);
  box-shadow: 0 0 8px rgb(200 255 61 / 18%);
}

.drop-signal i:nth-child(1),
.drop-signal i:nth-child(9) { --bar: 1; }
.drop-signal i:nth-child(2),
.drop-signal i:nth-child(8) { --bar: 3; }
.drop-signal i:nth-child(3),
.drop-signal i:nth-child(7) { --bar: 5; }
.drop-signal i:nth-child(4),
.drop-signal i:nth-child(6) { --bar: 7; }
.drop-signal i:nth-child(5) { --bar: 9; }

.drop-copy { min-width: 0; }

.drop-copy h2 {
  margin: 7px 0 3px;
  font-size: clamp(1.03rem, 2vw, 1.45rem);
  letter-spacing: -0.025em;
}

.drop-copy > p:last-child {
  margin: 0;
  color: var(--muted);
  font: 600 0.67rem/1.45 var(--mono);
}

.file-action {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 46px;
  padding: 0 18px;
  color: #101408;
  border-color: var(--acid);
  background: var(--acid);
}

.file-action:hover { color: var(--paper); border-color: var(--acid); background: #202820; }

.kit-count {
  display: grid;
  min-width: 82px;
  padding-left: 18px;
  border-left: 1px solid var(--line);
}

.kit-count strong {
  color: var(--acid);
  font: 800 1.65rem/1 var(--mono);
  letter-spacing: -0.07em;
}

.kit-count span { margin-top: 4px; color: var(--muted); font: 650 0.52rem/1 var(--mono); letter-spacing: 0.08em; }

.performance-workspace {
  display: grid;
  grid-template-columns: minmax(600px, 1fr) minmax(320px, 0.42fr);
  min-height: 615px;
}

.pad-stage,
.pad-inspector { min-width: 0; padding: 24px 27px; }

.pad-stage { border-right: 1px solid var(--line); background: #101415; }
.pad-inspector { background: #0d1011; }

.stage-heading,
.inspector-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  min-height: 45px;
  margin-bottom: 17px;
}

.stage-heading h2,
.inspector-heading h2 {
  margin: 5px 0 0;
  font-size: clamp(1.12rem, 2vw, 1.48rem);
  letter-spacing: -0.03em;
}

.stage-heading > p {
  max-width: 300px;
  margin: 0;
  color: var(--muted);
  font: 600 0.61rem/1.4 var(--mono);
  text-align: right;
}

.pad-workflow-toolbar {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  margin: -3px 0 15px;
  padding: 6px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: #0c1011;
}

.interaction-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }

.interaction-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 11px;
  border-color: transparent;
  box-shadow: none;
}

.interaction-button.is-active {
  color: #101408;
  border-color: var(--acid);
  background: var(--acid);
  box-shadow: inset 0 1px rgb(255 255 255 / 20%);
}

.interaction-button.is-active:hover { color: #101408; background: var(--acid); }

#interactionHelp {
  margin: 0;
  color: var(--muted);
  font: 600 0.55rem/1.35 var(--mono);
  letter-spacing: 0.025em;
}

.toolbar-action {
  min-height: 34px;
  padding: 0 11px;
  border-color: var(--line);
  box-shadow: none;
}

.sampler-pad-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(88px, 1fr));
  gap: 10px;
}

.sample-pad {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  aspect-ratio: 1 / 0.76;
  min-height: 94px;
  overflow: hidden;
  padding: 11px 12px 12px;
  border: 1px solid #505957;
  border-radius: 8px;
  color: #b7bebb;
  background: var(--pad);
  box-shadow: inset 0 0 0 3px #171b1c, inset 0 -18px 22px rgb(0 0 0 / 28%), 0 5px 0 #060808;
  cursor: pointer;
  text-align: left;
  transform: translateY(0);
  transition: color 85ms ease, background 85ms ease, border-color 85ms ease, box-shadow 85ms ease, transform 85ms ease;
}

.sample-pad::after {
  position: absolute;
  inset: 5px;
  border: 1px solid rgb(255 255 255 / 5%);
  border-radius: 4px;
  content: "";
  pointer-events: none;
}

.sample-pad:hover { color: var(--paper); border-color: #77817f; }

.sample-pad.is-selected {
  border-color: var(--acid-soft);
  box-shadow: inset 0 0 0 3px #171b1c, inset 0 -18px 22px rgb(0 0 0 / 25%), 0 5px 0 #060808, 0 0 0 1px var(--acid-soft);
}

.sample-pad[data-status="empty"] { color: #7f8785; background: #1a1f20; }
.sample-pad[data-status="empty"] .pad-name { color: #949c99; }
.sample-pad[data-status="loading"] { border-color: var(--acid-soft); }
.sample-pad[data-status="loading"] .pad-name { color: var(--acid); }
.sample-pad[data-status="ready"] .pad-meta::before { color: var(--acid); content: "●  "; }
.sample-pad[data-status="error"] { border-color: var(--danger); color: #ff9b96; }
.sample-pad[data-status="error"] .pad-name { color: var(--danger); }

.sample-pad.is-drop-target {
  border-color: var(--acid);
  background: #28331e;
  box-shadow: inset 0 0 0 3px #171b1c, 0 5px 0 #060808, 0 0 22px rgb(200 255 61 / 21%);
}

.sampler[data-interaction-mode="arrange"] .sample-pad[data-status="ready"] { cursor: grab; }
.sampler[data-interaction-mode="arrange"] .sample-pad[data-status="ready"]:active { cursor: grabbing; }

.sample-pad.is-arrange-target {
  border-color: var(--acid);
  background: #26311e;
  box-shadow: inset 0 0 0 3px #171b1c, 0 5px 0 #060808, 0 0 25px rgb(200 255 61 / 24%);
}

.sample-pad.is-drag-source,
.sample-pad.is-move-source {
  color: var(--acid);
  border-style: dashed;
  opacity: 0.62;
}

.sampler[data-interaction-mode="arrange"] .sample-pad.is-playing {
  color: #b7bebb;
  background: var(--pad);
  transform: none;
}

.sample-pad.is-playing {
  color: #101408;
  border-color: var(--acid);
  background: var(--acid);
  box-shadow: inset 0 0 20px rgb(255 255 255 / 24%), 0 1px 0 #060808, 0 0 25px rgb(200 255 61 / 28%);
  transform: translateY(4px) scale(0.986);
}

.sample-pad.is-playing .pad-name,
.sample-pad.is-playing .pad-meta,
.sample-pad.is-playing .pad-meta::before { color: #101408; }

.pad-identity { display: flex; align-items: start; justify-content: space-between; gap: 8px; }
.pad-number { opacity: 0.58; font: 650 0.57rem/1 var(--mono); letter-spacing: 0.08em; }

.pad-key,
.keyboard-map kbd {
  min-width: 24px;
  padding: 4px 5px;
  border: 1px solid currentColor;
  border-radius: 3px;
  background: transparent;
  font: 700 0.59rem/1 var(--mono);
  text-align: center;
}

.pad-name {
  align-self: end;
  display: block;
  width: 100%;
  overflow: hidden;
  margin-top: 10px;
  font: 800 clamp(0.7rem, 1.2vw, 0.96rem)/1 var(--mono);
  letter-spacing: -0.035em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pad-meta {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  color: var(--muted);
  font: 650 0.49rem/1 var(--mono);
  letter-spacing: 0.07em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pad-progress {
  position: absolute;
  right: 8px;
  bottom: 5px;
  left: 8px;
  height: 2px;
  overflow: hidden;
  background: transparent;
}

.sample-pad[data-status="loading"] .pad-progress { background: #343e2f; }

.sample-pad[data-status="loading"] .pad-progress i {
  display: block;
  width: 35%;
  height: 100%;
  background: var(--acid);
  animation: loading-scan 850ms ease-in-out infinite;
}

.keyboard-map {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 17px;
  color: var(--muted);
  font: 650 0.57rem/1 var(--mono);
}

.keyboard-map span { display: flex; align-items: center; gap: 4px; }
.keyboard-map kbd { color: var(--paper); border-color: var(--line); background: #171b1c; }

.inspector-heading h2 {
  display: flex;
  gap: 7px;
  max-width: 265px;
  overflow: hidden;
  font-family: var(--mono);
  font-size: 0.95rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#selectedPadNumber { color: var(--acid); }
#selectedSampleName { overflow: hidden; text-overflow: ellipsis; }

.state-chip {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font: 750 0.5rem/1 var(--mono);
  letter-spacing: 0.09em;
}

.state-chip[data-state="ready"] { color: var(--acid); border-color: var(--acid-soft); }
.state-chip[data-state="loading"] { color: var(--warning); border-color: var(--warning); }
.state-chip[data-state="error"] { color: var(--danger); border-color: var(--danger); }

.sample-readout {
  min-height: 100px;
  margin-bottom: 19px;
  padding: 15px 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

.sample-wave {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 43px;
  overflow: hidden;
  opacity: 0.44;
}

.sample-wave i {
  flex: 1 1 0;
  min-width: 2px;
  height: calc(8px + var(--wave, 1) * 4px);
  border-radius: 1px;
  background: #6a7471;
  transition: height 180ms ease, background 180ms ease;
}

.sample-wave i:nth-child(2n) { --wave: 3; }
.sample-wave i:nth-child(3n) { --wave: 6; }
.sample-wave i:nth-child(5n) { --wave: 8; }
.pad-inspector.has-sample .sample-wave { opacity: 1; }
.pad-inspector.has-sample .sample-wave i { background: var(--acid-soft); }

.sample-readout p {
  margin: 9px 0 0;
  color: var(--muted);
  font: 600 0.61rem/1.45 var(--mono);
  overflow-wrap: anywhere;
}

fieldset { min-width: 0; padding: 0; border: 0; }
fieldset:disabled { opacity: 0.44; }

.mode-fieldset { margin: 0 0 20px; }

.mode-fieldset legend {
  margin-bottom: 9px;
  color: var(--muted);
  font: 750 0.58rem/1 var(--mono);
  letter-spacing: 0.14em;
}

.mode-switch { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }

.mode-button {
  min-height: 55px;
  padding: 8px 4px;
  line-height: 1.1;
}

.mode-button small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.46rem;
  font-weight: 600;
  letter-spacing: 0;
}

.mode-button.is-active {
  color: #101408;
  border-color: var(--acid);
  background: var(--acid);
}

.mode-button.is-active small { color: #354116; }

.tone-controls { display: grid; gap: 17px; }

.range-control { display: grid; gap: 9px; }

.range-control > span { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.range-control b { font: 750 0.59rem/1 var(--mono); letter-spacing: 0.12em; }
.range-control output { color: var(--acid); font: 750 0.64rem/1 var(--mono); }

input[type="range"] {
  width: 100%;
  height: 22px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--acid-soft), #3b4342);
}

input[type="range"]::-moz-range-track { height: 3px; border-radius: 2px; background: #4a5352; }

input[type="range"]::-webkit-slider-thumb {
  width: 17px;
  height: 17px;
  margin-top: -7px;
  appearance: none;
  border: 2px solid #0d1011;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 0 0 1px #66706e;
}

input[type="range"]::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border: 2px solid #0d1011;
  border-radius: 50%;
  background: var(--paper);
}

.pad-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 22px; }

.secondary-action {
  display: grid;
  place-items: center;
  min-height: 41px;
  padding: 0 12px;
}

.secondary-action.danger { color: #ff9892; }

.secondary-action.is-disabled,
button:disabled {
  color: #656d6b;
  border-color: #313837;
  background: #15191a;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.62;
}

.clear-kit-button {
  width: 100%;
  min-height: 39px;
  margin-top: 11px;
  color: #ff9892;
  background: transparent;
}

.studio-cta {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 12px;
  margin-top: 13px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--paper);
  background: #131819;
  text-decoration: none;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.studio-cta:hover { border-color: var(--acid-soft); background: #192017; transform: translateY(-1px); }
.studio-cta > span { grid-column: 1 / -1; color: var(--muted); font: 750 0.49rem/1 var(--mono); letter-spacing: 0.13em; }
.studio-cta strong { font: 800 0.72rem/1.15 var(--mono); letter-spacing: 0.035em; }
.studio-cta strong b { color: var(--acid); font-size: 1rem; }
.studio-cta small { align-self: center; color: var(--muted); font: 650 0.47rem/1 var(--mono); letter-spacing: 0.04em; }
.studio-cta.is-ready { border-color: var(--acid-soft); box-shadow: inset 3px 0 var(--acid); }
.studio-cta.is-ready > span,
.studio-cta.is-ready output { color: var(--acid); }

.sampler-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 50px;
  padding: 11px 27px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #090b0c;
  font: 600 0.57rem/1.4 var(--mono);
  letter-spacing: 0.04em;
}

.sampler-footer p { margin: 0; }
.sampler-footer span { color: var(--acid); }
#messageLine { max-width: 48%; color: #aeb5b2; text-align: right; }

.confirm-dialog {
  width: min(460px, calc(100% - 32px));
  padding: 0;
  border: 1px solid #59615f;
  border-radius: 10px;
  color: var(--paper);
  background: #111516;
  box-shadow: 0 30px 90px rgb(0 0 0 / 70%);
}

.confirm-dialog::backdrop { background: rgb(2 4 4 / 76%); backdrop-filter: blur(5px); }
.confirm-dialog form { padding: 25px; }
.confirm-dialog h2 { margin: 10px 0; font-size: 1.25rem; letter-spacing: -0.025em; }
.confirm-dialog form > p:not(.section-label) { margin-bottom: 22px; color: var(--muted); font-size: 0.78rem; line-height: 1.65; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.confirm-clear-button { min-height: 42px; color: #170403; border-color: var(--danger); background: var(--danger); }

.trim-dialog {
  width: min(920px, calc(100% - 28px));
  max-height: min(90vh, 760px);
  padding: 0;
  overflow: auto;
  border: 1px solid #596360;
  border-radius: 12px;
  color: var(--paper);
  background: #0c0f10;
  box-shadow: 0 35px 110px rgb(0 0 0 / 78%);
}

.trim-dialog::backdrop { background: rgb(2 4 4 / 84%); backdrop-filter: blur(7px); }
.trim-dialog-shell { padding: clamp(18px, 3vw, 30px); }

.trim-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 19px;
}

.trim-heading h2 { margin: 7px 0 5px; font-size: clamp(1.25rem, 3vw, 2rem); letter-spacing: -0.045em; }
.trim-heading > div > p:last-child { margin: 0; color: var(--muted); font: 700 0.67rem/1.3 var(--mono); }

.non-destructive-badge {
  flex: 0 0 auto;
  padding: 7px 9px;
  border: 1px solid var(--acid-soft);
  border-radius: 999px;
  color: var(--acid);
  font: 750 0.51rem/1 var(--mono);
  letter-spacing: 0.08em;
}

.waveform-editor {
  position: relative;
  height: clamp(190px, 31vh, 280px);
  overflow: hidden;
  border: 1px solid #46504e;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgb(255 255 255 / 4%) 1px, transparent 1px) 0 0 / 12.5% 100%,
    #111617;
  touch-action: none;
  user-select: none;
}

#trimWaveform { display: block; width: 100%; height: 100%; }

.trim-selection {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  border-top: 2px solid var(--acid);
  border-bottom: 2px solid var(--acid);
  background: rgb(200 255 61 / 7%);
  box-shadow: 0 0 0 200vmax rgb(1 3 3 / 62%);
  cursor: grab;
}

.trim-selection:active { cursor: grabbing; }

.trim-handle {
  position: absolute;
  z-index: 2;
  top: 0;
  bottom: 0;
  width: 22px;
  color: #0c1007;
  background: var(--acid);
  cursor: ew-resize;
  touch-action: none;
}

.trim-handle::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 3px;
  height: 36px;
  border-right: 1px solid rgb(9 13 4 / 50%);
  border-left: 1px solid rgb(9 13 4 / 50%);
  content: "";
  transform: translate(-50%, -50%);
}

.trim-handle span {
  position: absolute;
  top: 8px;
  padding: 5px 7px;
  color: var(--acid);
  border: 1px solid var(--acid-soft);
  border-radius: 3px;
  background: #0b0f0c;
  font: 800 0.48rem/1 var(--mono);
  letter-spacing: 0.07em;
  pointer-events: none;
}

.trim-handle-start { left: 0; transform: translateX(-2px); }
.trim-handle-end { left: 100%; transform: translateX(-20px); }
.trim-handle-start span { left: 24px; }
.trim-handle-end span { right: 24px; }

.trim-selection:focus-visible,
.trim-handle:focus-visible { outline: 3px solid var(--paper); outline-offset: -5px; }

.trim-readouts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  border-left: 1px solid var(--line-soft);
}

.trim-readouts > span {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
  padding: 11px 13px;
  border-right: 1px solid var(--line-soft);
}

.trim-readouts > span:last-child { border-right: 0; }
.trim-readouts small { color: var(--muted); font: 700 0.49rem/1 var(--mono); letter-spacing: 0.1em; }
.trim-readouts strong { overflow: hidden; color: var(--acid); font: 800 clamp(0.78rem, 2vw, 1.1rem)/1 var(--mono); text-overflow: ellipsis; }
.trim-readouts i { color: var(--muted); font: normal 650 0.46rem/1 var(--mono); }

.trim-help { margin: 13px 0 20px; color: var(--muted); font: 600 0.62rem/1.55 var(--mono); }

.trim-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.trim-actions > div { display: flex; align-items: center; gap: 8px; }
.trim-actions button { min-height: 43px; padding: 0 15px; }
.trim-preview-button { display: flex; align-items: center; gap: 8px; border-color: #77817f; }
.trim-preview-button.is-playing { color: #101408; border-color: var(--acid); background: var(--acid); }
.trim-apply-button { color: #101408; border-color: var(--acid); background: var(--acid); }
.trim-apply-button:hover { color: var(--paper); border-color: var(--acid); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes loading-scan {
  from { transform: translateX(-110%); }
  to { transform: translateX(310%); }
}

@media (max-width: 1080px) {
  .performance-workspace { grid-template-columns: minmax(520px, 1fr) minmax(292px, 0.46fr); }
  .drop-signal { display: none; }
  .drop-zone { grid-template-columns: minmax(240px, 1fr) auto auto; }
  .sampler-pad-grid { gap: 8px; }
  .sample-pad { min-height: 84px; }
}

@media (min-width: 821px) and (max-height: 800px) {
  .sampler { min-height: calc(100vh - 16px); margin-top: 8px; margin-bottom: 8px; }
  .sampler-header { min-height: 79px; padding-top: 12px; padding-bottom: 12px; }
  h1 { font-size: clamp(2rem, 3.3vw, 2.85rem); }
  .drop-zone { min-height: 82px; padding-top: 10px; padding-bottom: 10px; }
  .drop-signal { height: 42px; }
  .performance-workspace { min-height: 0; }
  .pad-stage,
  .pad-inspector { padding-top: 14px; padding-bottom: 12px; }
  .stage-heading,
  .inspector-heading { min-height: 37px; margin-bottom: 10px; }
  .sample-pad { aspect-ratio: auto; min-height: 82px; height: 82px; }
  .keyboard-map { margin-top: 10px; }
  .sample-readout { min-height: 74px; margin-bottom: 13px; padding-top: 9px; padding-bottom: 9px; }
  .sample-wave { height: 29px; }
  .mode-fieldset { margin-bottom: 13px; }
  .mode-button { min-height: 48px; }
  .tone-controls { gap: 10px; }
  .range-control { gap: 5px; }
  .pad-actions { margin-top: 12px; }
  .clear-kit-button { margin-top: 8px; }
  .sampler-footer { min-height: 43px; }
}

@media (max-width: 820px) {
  .sampler { width: min(100% - 16px, 720px); min-height: calc(100vh - 16px); margin: 8px auto; border-radius: 12px; }
  .sampler-header { min-height: 91px; padding: 16px 19px; }
  .brand-block > p { display: none; }
  .engine-status { display: none; }
  .drop-zone { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; min-height: 102px; padding: 14px 19px; }
  .kit-count { position: absolute; right: 22px; bottom: 11px; display: flex; align-items: baseline; gap: 6px; min-width: 0; padding: 0; border: 0; }
  .kit-count strong { font-size: 1rem; }
  .drop-copy > p:last-child { max-width: 430px; padding-right: 74px; font-size: 0.58rem; }
  .performance-workspace { grid-template-columns: 1fr; }
  .pad-stage { border-right: 0; border-bottom: 1px solid var(--line); }
  .pad-stage,
  .pad-inspector { padding: 21px 19px; }
  .pad-workflow-toolbar { grid-template-columns: auto 1fr auto; }
  .sampler-footer { align-items: flex-start; padding: 12px 19px; }
  .sampler-footer > p:first-child { display: none; }
  #messageLine { max-width: none; text-align: left; }
}

@media (max-width: 540px) {
  .sampler { width: 100%; min-height: 100vh; margin: 0; border-right: 0; border-left: 0; border-radius: 0; }
  .sampler-header { min-height: 76px; padding: 12px 14px; }
  .tool-switcher { gap: 2px; }
  .tool-switcher a { padding: 3px 4px; font-size: 0.44rem; }
  h1 { font-size: clamp(1.62rem, 8.5vw, 2.18rem); }
  .stop-all-button { min-height: 42px; padding: 0 10px; font-size: 0.56rem; }
  .stop-all-button kbd { display: none; }
  .drop-zone { min-height: 91px; padding: 11px 14px; }
  .drop-zone::after { inset: 5px; }
  .drop-copy h2 { margin-top: 5px; font-size: 0.92rem; }
  .drop-copy > p:last-child { max-width: 235px; padding-right: 0; font-size: 0.5rem; line-height: 1.35; }
  .file-action { min-height: 40px; padding: 0 10px; font-size: 0.54rem; }
  .kit-count { right: 16px; bottom: 6px; }
  .kit-count span { font-size: 0.43rem; }
  .pad-stage,
  .pad-inspector { padding: 16px 13px; }
  .stage-heading { align-items: end; min-height: 37px; margin-bottom: 11px; }
  .stage-heading > p { max-width: 130px; font-size: 0.47rem; line-height: 1.3; }
  .stage-heading h2 { margin-top: 4px; font-size: 1.02rem; }
  .section-label { font-size: 0.5rem; }
  .pad-workflow-toolbar {
    grid-template-columns: 1fr auto;
    gap: 7px;
    margin-bottom: 11px;
    padding: 5px;
  }
  .interaction-switch { min-width: 0; }
  .interaction-button { min-height: 32px; padding: 0 8px; font-size: 0.5rem; }
  #interactionHelp { grid-column: 1 / -1; grid-row: 2; padding: 2px 3px; font-size: 0.46rem; }
  .toolbar-action { min-height: 32px; padding: 0 8px; font-size: 0.48rem; }
  .sampler-pad-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .sample-pad { aspect-ratio: 1 / 0.88; min-height: 65px; padding: 8px 8px 9px; border-radius: 6px; }
  .pad-number { font-size: 0.44rem; }
  .pad-key { min-width: 20px; padding: 3px; font-size: 0.5rem; }
  .pad-name { margin-top: 4px; font-size: clamp(0.52rem, 2.45vw, 0.67rem); }
  .pad-meta { margin-top: 3px; font-size: 0.38rem; letter-spacing: 0.02em; }
  .keyboard-map { gap: 7px 11px; margin-top: 11px; font-size: 0.47rem; }
  .keyboard-map kbd { min-width: 19px; padding: 3px; font-size: 0.46rem; }
  .pad-inspector { padding-top: 20px; }
  .inspector-heading { min-height: 37px; margin-bottom: 13px; }
  .inspector-heading h2 { max-width: 235px; font-size: 0.82rem; }
  .sample-readout { min-height: 83px; margin-bottom: 16px; padding: 11px 0; }
  .sample-wave { height: 32px; }
  .sample-readout p { margin-top: 6px; font-size: 0.54rem; }
  .mode-button { min-height: 51px; font-size: 0.53rem; }
  .mode-button small { font-size: 0.39rem; }
  .sampler-footer { min-height: 45px; padding: 10px 13px; font-size: 0.52rem; }
  .studio-cta { padding: 12px; }

  .trim-dialog { width: 100%; max-width: none; max-height: 96vh; margin: auto 0 0; border-radius: 12px 12px 0 0; }
  .trim-dialog-shell { padding: 17px 13px max(17px, env(safe-area-inset-bottom)); }
  .trim-heading { gap: 10px; margin-bottom: 13px; }
  .trim-heading h2 { font-size: 1.18rem; }
  .non-destructive-badge { padding: 6px; font-size: 0.4rem; }
  .waveform-editor { height: 210px; }
  .trim-handle { width: 18px; }
  .trim-handle-end { transform: translateX(-16px); }
  .trim-handle-start span { left: 20px; }
  .trim-handle-end span { right: 20px; }
  .trim-readouts > span { grid-template-columns: 1fr; gap: 3px; padding: 9px 8px; }
  .trim-readouts i { display: none; }
  .trim-help { margin: 10px 0 14px; font-size: 0.52rem; }
  .trim-actions { align-items: stretch; flex-direction: column; }
  .trim-actions > div { display: grid; grid-template-columns: 1fr 1fr; }
  .trim-actions > div,
  .trim-actions button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .sample-pad.is-playing { transform: translateY(2px); }
}
