:root {
  --page: #aaa89e;
  --page-deep: #8f8e86;
  --case: #d6d3c6;
  --case-light: #e6e3d7;
  --panel: #c9c6b9;
  --panel-dark: #b8b5aa;
  --ink: #1c1d1b;
  --muted: #62625d;
  --line: rgba(30, 31, 29, 0.22);
  --screen: #11140f;
  --phosphor: #e9efc2;
  --phosphor-soft: #a9be93;
  --orange: #ec5b2a;
  --orange-dark: #9e3217;
  --yellow: #e6b43c;
  --blue: #526e78;
  --green: #77966b;
  --red: #ad4434;
  --shadow: rgba(34, 34, 31, 0.32);
  --inset: rgba(255, 255, 255, 0.64);
  --font-ui: "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SFMono-Regular", "Roboto Mono", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--page-deep);
}

body {
  min-height: 100vh;
  margin: 0;
  padding: clamp(18px, 4vw, 58px) clamp(12px, 3vw, 42px) clamp(32px, 6vw, 80px);
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -10%, rgba(255, 255, 255, 0.5), transparent 45%),
    linear-gradient(125deg, rgba(255, 255, 255, 0.06), transparent 40%),
    var(--page);
  font-family: var(--font-ui);
  letter-spacing: 0.02em;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 3px;
}

.room-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    repeating-linear-gradient(90deg, transparent 0 79px, rgba(20, 20, 18, 0.025) 80px),
    repeating-linear-gradient(0deg, transparent 0 79px, rgba(255, 255, 255, 0.025) 80px);
}

.instrument {
  position: relative;
  width: min(1480px, 100%);
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid rgba(57, 57, 52, 0.65);
  border-radius: 22px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.14), transparent 8%, transparent 92%, rgba(0, 0, 0, 0.07)),
    linear-gradient(180deg, var(--case-light), var(--case) 16%, #cecbbe 88%, #bbb8ad);
  box-shadow:
    0 32px 70px rgba(39, 39, 36, 0.35),
    0 7px 15px rgba(34, 34, 30, 0.32),
    inset 0 1px 1px rgba(255, 255, 255, 0.88),
    inset 0 -2px 1px rgba(61, 61, 56, 0.2);
}

.instrument::before {
  position: absolute;
  inset: 0;
  z-index: 20;
  border-radius: inherit;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='92' height='92' viewBox='0 0 92 92'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.83' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.14'/%3E%3C/svg%3E");
  content: "";
  opacity: 0.11;
  pointer-events: none;
  mix-blend-mode: multiply;
}

.case-screw {
  position: absolute;
  z-index: 25;
  width: 13px;
  height: 13px;
  border: 1px solid #74736c;
  border-radius: 50%;
  background:
    linear-gradient(45deg, transparent 43%, #55554f 44% 55%, transparent 56%),
    radial-gradient(circle at 35% 30%, #f2f0e7, #aaa89f 60%, #6f6e68);
  box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7), inset 0 0 1px rgba(0, 0, 0, 0.7);
}

.screw-nw { top: 14px; left: 14px; transform: rotate(17deg); }
.screw-ne { top: 14px; right: 14px; transform: rotate(71deg); }
.screw-sw { bottom: 14px; left: 14px; transform: rotate(108deg); }
.screw-se { right: 14px; bottom: 14px; transform: rotate(145deg); }

.instrument-header {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto auto auto;
  gap: 14px;
  align-items: center;
  min-height: 102px;
  padding: 24px clamp(28px, 4vw, 64px);
  border-bottom: 1px solid rgba(41, 42, 39, 0.35);
  background: rgba(238, 235, 224, 0.38);
  box-shadow: inset 0 -1px rgba(255, 255, 255, 0.55);
}

.identity-block h1,
.identity-block p,
.module-heading h2,
.sequence-title-block h2,
.ratio-label-block h2,
.performance-copy h2,
.method-drawer h2 {
  margin: 0;
}

.brand-line {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.brand-line h1 {
  font-size: clamp(24px, 2.7vw, 38px);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1;
}

.brand-mark {
  display: flex;
  align-items: end;
  gap: 3px;
  width: 22px;
  height: 24px;
}

.brand-mark i {
  display: block;
  width: 5px;
  border-radius: 1px 1px 0 0;
  background: var(--ink);
}

.brand-mark i:nth-child(1) { height: 10px; }
.brand-mark i:nth-child(2) { height: 23px; background: var(--orange); }
.brand-mark i:nth-child(3) { height: 16px; }

.model-number {
  padding: 3px 5px 2px;
  border: 1px solid var(--ink);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  vertical-align: middle;
}

.identity-block p {
  margin-top: 8px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.13em;
}

.header-readout {
  display: grid;
  grid-template-columns: auto auto;
  min-width: 180px;
  margin-right: 2px;
  padding: 8px 11px;
  border: 1px solid rgba(33, 34, 31, 0.36);
  border-radius: 3px;
  color: var(--phosphor);
  background: #252923;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.7), 0 1px rgba(255, 255, 255, 0.6);
  font-family: var(--font-mono);
  font-size: 9px;
}

.header-tools {
  display: flex;
  gap: 5px;
  align-items: stretch;
}

.utility-button {
  display: grid;
  align-content: center;
  min-width: 58px;
  min-height: 42px;
  padding: 5px 8px;
  border: 1px solid #77766f;
  border-radius: 3px;
  color: #4e4f4a;
  cursor: pointer;
  background: linear-gradient(#dfddd4, #b9b7ae);
  box-shadow: 0 2px 2px rgba(40, 40, 36, 0.18), inset 0 1px rgba(255, 255, 255, 0.65);
  font-family: var(--font-mono);
  font-size: 7px;
  font-weight: 700;
  line-height: 1.15;
  text-align: left;
  text-decoration: none;
}

.utility-button small {
  max-width: 82px;
  overflow: hidden;
  margin-top: 3px;
  color: #817f78;
  font-size: 5px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.utility-button:hover { filter: brightness(1.04); }

.utility-button[aria-pressed="true"] {
  color: #f2eee3;
  background: #3c4039;
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.45);
}

.utility-button[aria-pressed="true"] small { color: #bdc5ae; }
.library-button { border-bottom-color: var(--orange); }

.header-readout .readout-label {
  color: #828b77;
  letter-spacing: 0.1em;
}

.header-readout strong {
  grid-column: 1;
  margin-top: 4px;
  color: #d1d9b4;
  font-size: 10px;
  letter-spacing: 0.08em;
}

.header-readout > span:last-child {
  grid-row: 1 / 3;
  grid-column: 2;
  align-self: center;
  color: var(--orange);
  font-size: 13px;
  text-align: right;
}

.power-cluster {
  display: flex;
  align-items: center;
  gap: 11px;
}

.power-copy {
  display: grid;
  color: #4d4d49;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-align: right;
}

.power-copy small {
  font-size: 8px;
  font-weight: 500;
}

.power-button {
  position: relative;
  width: 54px;
  height: 54px;
  padding: 0;
  border: 1px solid #6e6c65;
  border-radius: 50%;
  cursor: pointer;
  background: radial-gradient(circle at 38% 32%, #f5f2e8 0 10%, #bcb9ae 50%, #929087 78%, #6c6b65 100%);
  box-shadow:
    0 4px 6px rgba(29, 29, 27, 0.25),
    inset 0 2px 2px rgba(255, 255, 255, 0.8),
    inset 0 -3px 4px rgba(50, 50, 46, 0.28);
}

.power-button:active,
.power-button[aria-pressed="true"] {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(29, 29, 27, 0.35), inset 0 2px 5px rgba(55, 54, 50, 0.25);
}

.power-symbol {
  position: absolute;
  top: 18px;
  left: 17px;
  width: 20px;
  height: 19px;
  border: 2px solid #55554f;
  border-top-color: transparent;
  border-radius: 50%;
}

.power-symbol::before {
  position: absolute;
  top: -5px;
  left: 7px;
  width: 2px;
  height: 12px;
  border-radius: 1px;
  background: #55554f;
  content: "";
}

.power-led {
  position: absolute;
  top: 4px;
  left: 50%;
  z-index: 2;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #6c5c42;
  transform: translateX(-50%);
  transition: background 180ms, box-shadow 180ms;
}

.power-button[aria-pressed="true"] .power-led {
  background: #ff753f;
  box-shadow: 0 0 8px 2px rgba(236, 91, 42, 0.72);
}

.upper-deck {
  display: grid;
  grid-template-columns: minmax(0, 1.42fr) minmax(370px, 0.78fr);
  gap: 18px;
  padding: 18px 20px 0;
}

.module {
  position: relative;
  border: 1px solid rgba(53, 53, 49, 0.42);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 5%),
    var(--panel);
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.68),
    inset 0 -1px rgba(54, 54, 49, 0.18),
    0 2px 3px rgba(47, 47, 43, 0.12);
}

.module-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  min-height: 66px;
  padding: 15px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  display: block;
  margin-bottom: 4px;
  color: #686760;
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.13em;
}

.module-heading h2,
.sequence-title-block h2,
.ratio-label-block h2,
.performance-copy h2 {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.055em;
}

.scope-mode-controls {
  display: flex;
  gap: 4px;
}

.micro-button {
  min-width: 47px;
  height: 26px;
  padding: 0 8px;
  border: 1px solid #77766f;
  border-radius: 2px;
  color: #54544f;
  cursor: pointer;
  background: linear-gradient(#e1dfd5, #b9b7ae);
  box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7), inset 0 1px rgba(255, 255, 255, 0.48);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.micro-button.active,
.micro-button[aria-pressed="true"] {
  color: #f6eadc;
  background: #3b3d38;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.65);
}

.display-bezel {
  margin: 14px;
  padding: 10px;
  border: 1px solid #61625e;
  border-radius: 10px;
  background: linear-gradient(145deg, #5e605b, #252824 45%, #4a4b47);
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.8),
    0 1px 1px rgba(255, 255, 255, 0.6),
    0 5px 8px rgba(38, 38, 35, 0.2);
}

.display-screen {
  position: relative;
  min-height: 410px;
  overflow: hidden;
  border: 1px solid #090a08;
  border-radius: 5px;
  color: var(--phosphor);
  background:
    radial-gradient(ellipse at center, rgba(104, 126, 87, 0.12), transparent 65%),
    var(--screen);
  box-shadow:
    inset 0 0 38px rgba(0, 0, 0, 0.85),
    inset 0 0 4px rgba(170, 197, 139, 0.22);
}

.display-screen::after {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: repeating-linear-gradient(180deg, transparent 0 3px, rgba(0, 0, 0, 0.18) 4px);
  content: "";
  opacity: 0.5;
  pointer-events: none;
}

#scopeCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.scope-grid {
  position: absolute;
  inset: 10% 7%;
  z-index: 1;
  opacity: 0.2;
  background-image:
    linear-gradient(rgba(190, 206, 164, 0.38) 1px, transparent 1px),
    linear-gradient(90deg, rgba(190, 206, 164, 0.38) 1px, transparent 1px);
  background-size: 12.5% 12.5%;
  pointer-events: none;
}

.scope-grid::before,
.scope-grid::after {
  position: absolute;
  background: rgba(224, 235, 194, 0.56);
  content: "";
}

.scope-grid::before { top: 50%; left: 0; width: 100%; height: 1px; }
.scope-grid::after { top: 0; left: 50%; width: 1px; height: 100%; }

.scope-corner {
  position: absolute;
  z-index: 5;
  width: 15px;
  height: 15px;
  border-color: rgba(220, 232, 187, 0.58);
  pointer-events: none;
}

.corner-tl { top: 17px; left: 17px; border-top: 1px solid; border-left: 1px solid; }
.corner-tr { top: 17px; right: 17px; border-top: 1px solid; border-right: 1px solid; }
.corner-bl { bottom: 17px; left: 17px; border-bottom: 1px solid; border-left: 1px solid; }
.corner-br { right: 17px; bottom: 17px; border-right: 1px solid; border-bottom: 1px solid; }

.scope-topline,
.scope-data {
  position: absolute;
  right: 24px;
  left: 24px;
  z-index: 6;
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.08em;
  pointer-events: none;
}

.scope-topline {
  top: 22px;
  color: rgba(214, 227, 182, 0.7);
}

.scope-data {
  bottom: 20px;
  align-items: end;
}

.scope-data > div {
  display: grid;
  gap: 2px;
}

.scope-data > div:last-child { text-align: right; }

.scope-data span {
  color: rgba(186, 200, 159, 0.54);
  font-size: 7px;
}

.scope-data strong {
  font-size: 11px;
  font-weight: 500;
  text-shadow: 0 0 8px rgba(206, 226, 172, 0.4);
}

.scope-data sup { font-size: 7px; }

.ratio-readout {
  max-width: 58%;
  text-align: center;
}

.level-meter {
  position: absolute;
  top: 66px;
  right: 16px;
  bottom: 57px;
  z-index: 5;
  width: 4px;
  overflow: hidden;
  border: 1px solid rgba(178, 198, 153, 0.28);
  background: rgba(0, 0, 0, 0.32);
}

.level-meter span {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3%;
  background: var(--phosphor);
  box-shadow: 0 0 6px rgba(220, 239, 181, 0.9);
  transition: height 60ms linear;
}

.screen-start {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 10;
  display: grid;
  gap: 5px;
  width: 202px;
  min-height: 74px;
  border: 1px solid rgba(225, 237, 197, 0.72);
  border-radius: 2px;
  color: var(--phosphor);
  cursor: pointer;
  background: rgba(20, 23, 18, 0.88);
  box-shadow: 0 0 28px rgba(161, 186, 130, 0.13), inset 0 0 14px rgba(183, 210, 149, 0.06);
  transform: translate(-50%, -50%);
  transition: opacity 250ms, transform 250ms;
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
}

.screen-start span { color: #98a486; font-size: 7px; }
.screen-start strong { font-size: 12px; }
.screen-start:hover { background: rgba(48, 53, 42, 0.9); }
.screen-start.hidden { opacity: 0; pointer-events: none; transform: translate(-50%, -47%); }

.scope-footer {
  display: flex;
  justify-content: space-between;
  padding: 0 18px 14px;
  color: #5a5b55;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.07em;
}

.status-dot,
.led {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 5px;
  border-radius: 50%;
  background: #797b70;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.55);
}

.audio-on .status-dot,
.led-green { background: var(--green); box-shadow: 0 0 5px rgba(119, 150, 107, 0.64); }
.led-orange { background: var(--orange); box-shadow: 0 0 5px rgba(236, 91, 42, 0.55); }

.compact-heading { min-height: 66px; }
.serial { color: #77766f; font-family: var(--font-mono); font-size: 8px; }

.knob-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(90px, 1fr));
  gap: 18px 10px;
  padding: 24px 15px 20px;
}

.knob-unit {
  position: relative;
  display: grid;
  justify-items: center;
  min-width: 0;
  cursor: ew-resize;
  user-select: none;
}

.knob-name {
  margin-bottom: 9px;
  color: #43443f;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.knob-shell {
  position: relative;
  display: block;
  width: 70px;
  height: 70px;
  border: 1px solid #817f77;
  border-radius: 50%;
  background:
    repeating-conic-gradient(from 225deg, #77776f 0 1deg, transparent 1deg 11.1deg) 50% 50% / 58px 58px no-repeat,
    radial-gradient(circle, transparent 0 65%, rgba(255, 255, 255, 0.35) 66% 68%, transparent 69%);
}

.knob-shell::after {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  box-shadow: 0 4px 5px rgba(36, 36, 33, 0.28);
  content: "";
  pointer-events: none;
}

.knob-shell input {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
}

.knob-dial {
  --angle: 0deg;
  position: absolute;
  inset: 10px;
  z-index: 2;
  border: 1px solid #676761;
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 29%, rgba(255, 255, 255, 0.55), transparent 16%),
    radial-gradient(circle, #bebcb3 0 45%, #9f9d95 72%, #74736e 100%);
  box-shadow: inset 0 2px 2px rgba(255, 255, 255, 0.45), inset 0 -3px 4px rgba(42, 42, 39, 0.23);
  transform: rotate(var(--angle));
}

.knob-dial::before {
  position: absolute;
  top: 5px;
  left: calc(50% - 1px);
  width: 2px;
  height: 17px;
  border-radius: 2px;
  background: #333430;
  box-shadow: 1px 0 rgba(255, 255, 255, 0.25);
  content: "";
}

.tempo-knob .knob-dial {
  background:
    radial-gradient(circle at 38% 29%, rgba(255, 255, 255, 0.25), transparent 16%),
    radial-gradient(circle, #e7683a 0 45%, #cb4e25 72%, #7e2b16 100%);
}

.tempo-knob .knob-dial::before { background: #f5e8d7; }

.knob-unit output {
  min-width: 35px;
  margin-top: 7px;
  padding: 2px 4px;
  border: 1px solid rgba(64, 64, 59, 0.4);
  border-radius: 2px;
  color: #d5dbc0;
  background: #343831;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
  font-family: var(--font-mono);
  font-size: 9px;
  text-align: center;
}

.knob-unit small {
  margin-top: 3px;
  color: #74736d;
  font-family: var(--font-mono);
  font-size: 6px;
  letter-spacing: 0.08em;
}

.tuning-panel {
  display: grid;
  grid-template-columns: 1fr 0.8fr 0.85fr;
  gap: 10px;
  padding: 14px 15px 16px;
  border-top: 1px solid var(--line);
  background: rgba(183, 180, 170, 0.38);
}

.switch-group,
.root-selector {
  display: grid;
  gap: 6px;
  align-content: start;
}

.switch-group > span,
.root-selector > span {
  color: #5d5d58;
  font-family: var(--font-mono);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.segment-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid #77766f;
  border-radius: 3px;
  background: #aaa89f;
  box-shadow: inset 0 1px 3px rgba(37, 37, 34, 0.25);
}

.segment-switch.three-way { grid-template-columns: repeat(3, 1fr); }

.segment-switch button {
  min-height: 26px;
  padding: 0 5px;
  border: 0;
  border-radius: 1px;
  color: #595953;
  cursor: pointer;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 7px;
  font-weight: 700;
}

.segment-switch button.active {
  color: #f3ecdf;
  background: #42443e;
  box-shadow: 0 1px 2px rgba(35, 35, 32, 0.38), inset 0 1px rgba(255, 255, 255, 0.08);
}

.root-selector select {
  width: 100%;
  min-height: 34px;
  padding: 0 24px 0 9px;
  border: 1px solid #77766f;
  border-radius: 3px;
  color: #eff0db;
  cursor: pointer;
  background: #3c4038;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.55);
  font-family: var(--font-mono);
  font-size: 9px;
}

.ratio-module {
  display: grid;
  grid-template-columns: 195px minmax(0, 1fr);
  gap: 15px;
  margin: 18px 20px 0;
  padding: 14px 16px;
  border: 1px solid rgba(51, 52, 48, 0.45);
  border-radius: 7px;
  background: #bcb9ae;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.6), inset 0 -1px rgba(48, 48, 44, 0.16);
}

.ratio-label-block {
  align-self: center;
  padding-left: 3px;
}

.ratio-label-block p {
  margin: 6px 0 0;
  color: #696862;
  font-family: var(--font-mono);
  font-size: 7px;
  text-transform: uppercase;
}

.ratio-keybed {
  display: grid;
  grid-template-columns: repeat(12, minmax(48px, 1fr));
  gap: 5px;
  min-width: 0;
}

.ratio-key {
  position: relative;
  min-width: 0;
  height: 78px;
  overflow: hidden;
  padding: 7px 4px 6px;
  border: 1px solid #5e5f59;
  border-radius: 3px;
  color: #292a27;
  cursor: pointer;
  background: linear-gradient(90deg, #d9d7cd, #f0eee4 40%, #c2c0b7);
  box-shadow: 0 3px 2px rgba(45, 45, 42, 0.28), inset 0 1px rgba(255, 255, 255, 0.8);
  transition: transform 60ms, filter 100ms;
}

.ratio-key:nth-child(2),
.ratio-key:nth-child(4),
.ratio-key:nth-child(7),
.ratio-key:nth-child(9),
.ratio-key:nth-child(11) {
  color: #e2e2d6;
  background: linear-gradient(90deg, #2c2f2b, #4b4e48 50%, #242622);
}

.ratio-key:hover { filter: brightness(1.06); }
.ratio-key:active,
.ratio-key.pressed { transform: translateY(2px); box-shadow: 0 1px 1px rgba(45, 45, 42, 0.32), inset 0 2px 2px rgba(0, 0, 0, 0.15); }

.ratio-key .note-name,
.ratio-key .ratio-value,
.ratio-key .cent-value {
  position: relative;
  z-index: 2;
  display: block;
  font-family: var(--font-mono);
  text-align: center;
}

.ratio-key .note-name { font-size: 9px; font-weight: 800; }
.ratio-key .ratio-value { margin-top: 19px; font-size: 8px; }
.ratio-key .cent-value { margin-top: 3px; opacity: 0.62; font-size: 6px; }

.ratio-key .deviation-bar {
  position: absolute;
  right: 5px;
  bottom: 0;
  left: 5px;
  height: var(--deviation-height, 8%);
  opacity: 0.42;
  background: var(--orange);
  pointer-events: none;
}

.sequence-module {
  margin: 18px 20px 0;
  overflow: hidden;
}

.sequence-toolbar {
  display: grid;
  grid-template-columns: minmax(170px, 0.9fr) minmax(450px, 2fr) auto;
  gap: 22px;
  align-items: center;
  padding: 15px 17px;
  border-bottom: 1px solid var(--line);
}

.preset-bank {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}

.preset-button {
  position: relative;
  display: grid;
  grid-template-columns: 17px 1fr;
  grid-template-rows: 1fr 1fr;
  min-width: 0;
  height: 46px;
  padding: 6px 7px;
  border: 1px solid #77766f;
  border-radius: 3px;
  color: #4f504b;
  cursor: pointer;
  background: linear-gradient(#d8d6cc, #b7b5ac);
  box-shadow: 0 2px 2px rgba(45, 45, 42, 0.2), inset 0 1px rgba(255, 255, 255, 0.68);
  text-align: left;
}

.preset-button > span {
  grid-row: 1 / 3;
  align-self: center;
  color: #83817a;
  font-family: var(--font-mono);
  font-size: 7px;
}

.preset-button strong { font-size: 9px; letter-spacing: 0.09em; }
.preset-button small { color: #77766f; font-family: var(--font-mono); font-size: 7px; }

.preset-button.active {
  color: #f2eee2;
  background: #3d403a;
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.45), 0 1px rgba(255, 255, 255, 0.55);
}

.preset-button.active::after {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 5px rgba(236, 91, 42, 0.7);
  content: "";
}

.transport-cluster {
  display: grid;
  grid-template-columns: auto auto;
  gap: 7px;
}

.compose-button,
.transport-button {
  min-height: 52px;
  border: 1px solid #6f6e67;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 3px 3px rgba(42, 42, 39, 0.26), inset 0 1px rgba(255, 255, 255, 0.5);
}

.compose-button {
  display: grid;
  min-width: 82px;
  padding: 8px 12px;
  color: #3e3f3b;
  background: linear-gradient(#dedcd2, #b9b7ae);
  text-align: left;
}

.compose-button span { color: #787770; font-family: var(--font-mono); font-size: 6px; }
.compose-button strong { font-size: 9px; letter-spacing: 0.07em; }

.transport-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 82px;
  padding: 8px 11px;
  color: #f8eee1;
  background: linear-gradient(#f16c3c, #cb481f);
  text-shadow: 0 1px rgba(83, 22, 10, 0.35);
}

.transport-button[aria-pressed="true"] {
  transform: translateY(1px);
  background: #31342f;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.55);
}

.play-icon {
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 9px solid currentColor;
}

.transport-button[aria-pressed="true"] .play-icon {
  width: 8px;
  height: 11px;
  border: 0;
  border-right: 3px solid currentColor;
  border-left: 3px solid currentColor;
}

.transport-button strong { font-size: 10px; letter-spacing: 0.1em; }

.sequence-meta {
  display: flex;
  gap: 28px;
  align-items: center;
  min-height: 37px;
  padding: 8px 17px;
  border-bottom: 1px solid rgba(49, 49, 45, 0.28);
  color: #71716a;
  background: rgba(183, 180, 170, 0.38);
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.07em;
}

.sequence-meta strong { color: #343530; font-weight: 700; }
.keyboard-hint { margin-left: auto; }

.sequence-scroll {
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  padding: 15px 17px 18px;
  scrollbar-color: #696a63 transparent;
  scrollbar-width: thin;
}

.sequencer-grid {
  display: grid;
  grid-template-columns: 70px repeat(16, minmax(43px, 1fr));
  gap: 5px;
  min-width: 850px;
}

.lane-label {
  display: grid;
  align-content: center;
  padding-left: 4px;
  border-bottom: 1px solid rgba(56, 56, 52, 0.2);
  color: #484944;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.lane-label small {
  margin-top: 2px;
  color: #88867f;
  font-family: var(--font-mono);
  font-size: 6px;
  font-weight: 400;
}

.step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 17px;
  color: #797870;
  font-family: var(--font-mono);
  font-size: 6px;
}

.step-number.downbeat { color: #33342f; font-weight: 700; }

.sequence-cell {
  position: relative;
  min-width: 0;
  height: 42px;
  padding: 0;
  border: 1px solid #77766f;
  border-radius: 3px;
  color: #50504b;
  cursor: pointer;
  background: linear-gradient(#d9d7cd, #b4b2aa);
  box-shadow: 0 2px 1px rgba(40, 40, 37, 0.22), inset 0 1px rgba(255, 255, 255, 0.7);
  font-family: var(--font-mono);
  font-size: 8px;
  transition: transform 60ms, filter 100ms;
}

.sequence-cell:hover { filter: brightness(1.06); }
.sequence-cell:active { transform: translateY(1px); }
.sequence-cell.bar-start { margin-left: 4px; }

.sequence-cell.harmony-cell.active {
  color: #f4eee3;
  background: var(--cell-color, var(--blue));
  box-shadow: 0 2px 1px rgba(40, 40, 37, 0.25), inset 0 1px rgba(255, 255, 255, 0.14);
}

.sequence-cell.trigger-cell { height: 27px; }
.sequence-cell.trigger-cell.active { background: #3e423b; }
.sequence-cell.gate-cell.active { background: var(--orange); }
.sequence-cell.kick-cell.active { background: var(--yellow); }
.sequence-cell.air-cell.active { background: var(--blue); }

.sequence-cell.trigger-cell::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #85847d;
  content: "";
  transform: translate(-50%, -50%);
}

.sequence-cell.trigger-cell.active::after {
  background: #f6f0e3;
  box-shadow: 0 0 5px rgba(255, 249, 231, 0.65);
}

.sequencer-grid.current-0 [data-step="0"],
.sequencer-grid.current-1 [data-step="1"],
.sequencer-grid.current-2 [data-step="2"],
.sequencer-grid.current-3 [data-step="3"],
.sequencer-grid.current-4 [data-step="4"],
.sequencer-grid.current-5 [data-step="5"],
.sequencer-grid.current-6 [data-step="6"],
.sequencer-grid.current-7 [data-step="7"],
.sequencer-grid.current-8 [data-step="8"],
.sequencer-grid.current-9 [data-step="9"],
.sequencer-grid.current-10 [data-step="10"],
.sequencer-grid.current-11 [data-step="11"],
.sequencer-grid.current-12 [data-step="12"],
.sequencer-grid.current-13 [data-step="13"],
.sequencer-grid.current-14 [data-step="14"],
.sequencer-grid.current-15 [data-step="15"] {
  outline: 2px solid rgba(239, 93, 45, 0.78);
  outline-offset: 1px;
}

.performance-deck {
  display: grid;
  grid-template-columns: minmax(210px, 0.72fr) minmax(520px, 2fr) minmax(180px, 0.62fr);
  gap: 18px;
  margin: 18px 20px 0;
  padding: 18px;
  border: 1px solid rgba(49, 50, 46, 0.44);
  border-radius: 8px;
  background: #b6b3a8;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.6), inset 0 -1px rgba(52, 52, 48, 0.18);
}

.performance-copy {
  align-self: center;
}

.performance-copy p {
  max-width: 260px;
  margin: 10px 0 12px;
  color: #5e5e58;
  font-family: var(--font-mono);
  font-size: 7px;
  line-height: 1.55;
  text-transform: uppercase;
}

.performance-indicators {
  display: flex;
  flex-wrap: wrap;
  gap: 13px;
  color: #5e5e58;
  font-family: var(--font-mono);
  font-size: 6px;
  letter-spacing: 0.06em;
}

.chord-pads {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.chord-pad {
  position: relative;
  display: grid;
  align-content: space-between;
  min-width: 0;
  min-height: 98px;
  padding: 12px 10px 10px;
  border: 1px solid #5b5c56;
  border-radius: 5px;
  color: #e8e7de;
  cursor: pointer;
  background:
    radial-gradient(circle at 48% 25%, rgba(255, 255, 255, 0.09), transparent 42%),
    #383b36;
  box-shadow:
    0 5px 4px rgba(39, 39, 36, 0.3),
    inset 0 1px rgba(255, 255, 255, 0.11),
    inset 0 -4px 6px rgba(0, 0, 0, 0.22);
  text-align: left;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.chord-pad::after {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #20211e;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.8);
  content: "";
}

.chord-pad:hover { filter: brightness(1.08); }
.chord-pad:active,
.chord-pad.pressed {
  transform: translateY(3px);
  box-shadow: 0 2px 2px rgba(39, 39, 36, 0.35), inset 0 3px 6px rgba(0, 0, 0, 0.25);
}

.chord-pad.pressed::after { background: var(--orange); box-shadow: 0 0 6px rgba(236, 91, 42, 0.8); }
.chord-pad strong { font-size: 20px; font-weight: 500; letter-spacing: -0.04em; }
.chord-pad small { color: #9ea095; font-family: var(--font-mono); font-size: 6px; letter-spacing: 0.06em; }
.chord-pad span { color: #74776d; font-family: var(--font-mono); font-size: 7px; }

.bend-module {
  display: grid;
  align-content: start;
  padding: 12px;
  border: 1px solid #76756e;
  border-radius: 5px;
  background: #cac7bb;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.58);
}

.bend-heading {
  display: flex;
  justify-content: space-between;
  margin-bottom: 15px;
  font-family: var(--font-mono);
  font-size: 6px;
  letter-spacing: 0.06em;
}

.bend-heading strong { font-size: 7px; }

.bend-module label {
  display: grid;
  grid-template-columns: 16px 1fr 16px;
  align-items: center;
  gap: 5px;
  color: #686760;
  font-family: var(--font-mono);
  font-size: 7px;
  text-align: center;
}

#performanceBend {
  width: 100%;
  accent-color: var(--orange);
}

.bend-module output {
  justify-self: center;
  min-width: 54px;
  margin-top: 10px;
  padding: 4px;
  border: 1px solid #343630;
  border-radius: 2px;
  color: #d7dfc2;
  background: #30342d;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
  font-family: var(--font-mono);
  font-size: 8px;
  text-align: center;
}

.latch-button {
  min-height: 29px;
  margin-top: 12px;
  border: 1px solid #77766f;
  border-radius: 2px;
  color: #55554f;
  cursor: pointer;
  background: linear-gradient(#e0ded4, #aaa89f);
  box-shadow: 0 2px 1px rgba(42, 42, 39, 0.23), inset 0 1px rgba(255, 255, 255, 0.7);
  font-family: var(--font-mono);
  font-size: 7px;
  font-weight: 700;
}

.latch-button[aria-pressed="true"] {
  color: #f2eee2;
  background: var(--orange-dark);
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.44);
}

.instrument-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 65px;
  margin-top: 18px;
  padding: 0 clamp(30px, 4vw, 62px);
  border-top: 1px solid rgba(52, 52, 48, 0.3);
  background: rgba(232, 229, 218, 0.28);
}

.instrument-footer p {
  margin: 0;
  color: #6c6b65;
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.08em;
}

.instrument-footer p span { margin: 0 8px; color: var(--orange); }

.info-button {
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid #77766f;
  border-radius: 2px;
  color: #55564f;
  cursor: pointer;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 7px;
  font-weight: 700;
}

.method-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 100;
  width: min(470px, 92vw);
  height: 100dvh;
  overflow-y: auto;
  padding: clamp(55px, 8vw, 95px) clamp(28px, 5vw, 58px);
  border-left: 1px solid #1c1d1a;
  color: #e5e4d9;
  background: #282b26;
  box-shadow: -16px 0 45px rgba(26, 26, 23, 0.35);
  transform: translateX(102%);
  transition: transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.method-drawer.open { transform: translateX(0); }
.method-drawer .eyebrow { color: #909487; }
.method-drawer h2 { margin-top: 10px; font-size: 34px; letter-spacing: -0.035em; }
.method-drawer > p { color: #b9baaf; font-size: 13px; line-height: 1.7; }

.method-drawer dl {
  margin: 32px 0;
  border-top: 1px solid #55584f;
}

.method-drawer dl div {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 20px;
  padding: 14px 0;
  border-bottom: 1px solid #55584f;
}

.method-drawer dt { color: var(--orange); font-family: var(--font-mono); font-size: 10px; }
.method-drawer dd { margin: 0; color: #c1c2b8; font-size: 12px; }
.method-drawer .key-map { color: #8f9288; font-family: var(--font-mono); font-size: 9px; text-transform: uppercase; }
.method-drawer .key-map strong { color: #e5e4d9; }

.drawer-close {
  position: absolute;
  top: 22px;
  right: 25px;
  width: 38px;
  height: 38px;
  border: 1px solid #6f7169;
  border-radius: 50%;
  color: #d9d9cf;
  cursor: pointer;
  background: transparent;
  font-size: 24px;
  font-weight: 200;
}

.drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(25, 25, 22, 0.38);
  backdrop-filter: blur(2px);
}

@media (max-width: 1120px) {
  .upper-deck {
    grid-template-columns: 1fr;
  }

  .display-screen { min-height: 430px; }

  .control-module {
    display: grid;
    grid-template-columns: 170px 1fr;
  }

  .control-module .module-heading {
    align-items: start;
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  .knob-grid { grid-template-columns: repeat(6, 1fr); }
  .tuning-panel { grid-column: 1 / -1; }

  .sequence-toolbar {
    grid-template-columns: minmax(150px, 0.5fr) minmax(430px, 1.7fr) auto;
    gap: 13px;
  }

  .performance-deck {
    grid-template-columns: 190px 1fr;
  }

  .bend-module {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 2fr auto auto;
    align-items: center;
    gap: 14px;
  }

  .bend-heading { margin: 0; }
  .bend-module output { margin: 0; }
  .latch-button { min-width: 80px; margin: 0; }
}

@media (max-width: 880px) {
  body { padding: 12px 8px 34px; }
  .instrument { border-radius: 15px; }

  .instrument-header {
    grid-template-columns: 1fr auto;
    gap: 15px;
    padding: 22px 30px;
  }

  .header-readout { display: none; }
  .identity-block { grid-row: 1; grid-column: 1; }
  .power-cluster { grid-row: 1; grid-column: 2; }
  .header-tools {
    grid-row: 2;
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }
  .utility-button { text-align: center; }
  .identity-block p { max-width: 260px; line-height: 1.4; }

  .control-module { display: block; }
  .control-module .module-heading { border-right: 0; border-bottom: 1px solid var(--line); }
  .knob-grid { grid-template-columns: repeat(3, 1fr); }

  .ratio-module {
    grid-template-columns: 145px minmax(0, 1fr);
    overflow: hidden;
  }

  .ratio-keybed {
    overflow-x: auto;
    padding-bottom: 5px;
  }

  .ratio-key { min-width: 51px; }

  .sequence-toolbar {
    grid-template-columns: 1fr auto;
  }

  .preset-bank {
    grid-row: 2;
    grid-column: 1 / -1;
  }

  .transport-cluster { grid-row: 1; grid-column: 2; }
  .keyboard-hint { display: none; }

  .performance-deck { grid-template-columns: 1fr; }
  .performance-copy p { max-width: none; }
  .chord-pads { grid-template-columns: repeat(4, 1fr); }

  .bend-module {
    grid-column: auto;
    grid-template-columns: 1fr 2fr auto auto;
  }

  .instrument-footer { padding: 0 30px; }
  .instrument-footer p { max-width: 70%; line-height: 1.5; }
}

@media (max-width: 600px) {
  .case-screw { display: none; }

  .instrument-header {
    min-height: 88px;
    padding: 18px 18px;
  }

  .brand-line { gap: 9px; }
  .brand-line h1 { font-size: 24px; }
  .brand-mark { width: 17px; }
  .identity-block p { font-size: 7px; }
  .model-number { display: none; }
  .power-copy { display: none; }
  .power-button { width: 47px; height: 47px; }
  .power-symbol { top: 15px; left: 14px; }

  .upper-deck { gap: 12px; padding: 12px 10px 0; }
  .module-heading { min-height: 58px; padding: 12px; }
  .scope-mode-controls .micro-button { min-width: 39px; padding: 0 5px; }
  .scope-mode-controls .micro-button:nth-child(2) { display: none; }
  .display-bezel { margin: 9px; padding: 7px; }
  .display-screen { min-height: 340px; }
  .scope-data { right: 15px; bottom: 16px; left: 15px; }
  .ratio-readout { display: none !important; }

  .knob-grid { gap: 14px 0; padding: 18px 8px; }
  .knob-shell { width: 65px; height: 65px; }
  .tuning-panel { grid-template-columns: 1fr 1fr; }
  .root-selector { grid-column: 1 / -1; }

  .ratio-module {
    display: block;
    margin: 12px 10px 0;
    padding: 12px;
  }

  .ratio-label-block { display: flex; align-items: baseline; gap: 9px; margin-bottom: 10px; }
  .ratio-label-block .eyebrow,
  .ratio-label-block p { display: none; }
  .ratio-keybed { grid-template-columns: repeat(12, 50px); }
  .ratio-key { height: 70px; }

  .sequence-module { margin: 12px 10px 0; }
  .sequence-toolbar { gap: 10px; padding: 12px; }
  .sequence-title-block .eyebrow { display: none; }
  .sequence-title-block h2 { font-size: 12px; }
  .compose-button { min-width: 68px; }
  .transport-button { min-width: 68px; }
  .preset-bank { gap: 3px; }
  .preset-button { grid-template-columns: 1fr; height: 42px; padding: 6px; text-align: center; }
  .preset-button > span,
  .preset-button small { display: none; }
  .sequence-meta { gap: 14px; padding: 8px 12px; }
  .sequence-meta span:nth-child(2) { display: none; }
  .sequence-scroll { padding: 12px; }

  .performance-deck { gap: 14px; margin: 12px 10px 0; padding: 14px; }
  .chord-pads { grid-template-columns: repeat(2, 1fr); }
  .chord-pad { min-height: 88px; }

  .bend-module {
    grid-template-columns: 1fr;
  }

  .bend-heading { margin-bottom: 3px; }
  .latch-button { min-height: 34px; }

  .instrument-footer {
    min-height: 58px;
    margin-top: 12px;
    padding: 0 20px;
  }

  .instrument-footer p { display: none; }
  .info-button { margin-left: auto; }
}

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

body.atelier-fit-active {
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  padding: 0;
}

body.atelier-fit-active .instrument {
  position: fixed;
  top: 50%;
  left: 50%;
  margin: 0;
  transform: translate(-50%, -50%) scale(var(--atelier-fit-scale, 1));
  transform-origin: center center;
}
