@font-face { font-family: "Hershey"; src: url("fonts/AVHersheySimplexLight.otf") format("opentype"); font-weight: 100 400; font-display: swap; }
@font-face { font-family: "Hershey"; src: url("fonts/AVHersheySimplexMedium.otf") format("opentype"); font-weight: 401 900; font-display: swap; }
:root {
  color-scheme: dark;
  --bg: #040608;
  --panel: #0d1217;
  --panel-top: #121a21;
  --well: #06090c;
  --field: #141b22;
  --field-hi: #1b242d;
  --step-on: #16212a;
  --line: #1c2731;
  --struct: #4f6b7d;
  --struct-rgb: 79, 107, 125;
  --ink: #c3d1db;
  --dim: #93a8b4;
  --label: #aabfc8;
  --title: #b4cbd8;
  --off: #62788a;
  --beam: #8fd8ff;
  --beam-rgb: 143, 216, 255;
  --beam-line: #2f6f8f;
  --sound: #ff9d3c;
  --sound-rgb: 255, 157, 60;
  --lips: #ff6f91;
  --lips-rgb: 255, 111, 145;
  --led-off: #1d1710;
  --warn: #ff4b2b;
  --glow: 0 0 6px rgba(var(--beam-rgb), 0.45);
  --raise: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 1px 3px rgba(0, 0, 0, 0.5);
  --press: inset 0 1px 4px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(255, 255, 255, 0.015);
  --fh: 24px;
  font: 12px 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }

body { margin: 0; background: var(--bg); color: var(--ink); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-user-select: none; user-select: none; }
input[type=text], input:not([type]), .popover p { -webkit-user-select: text; user-select: text; }
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 9;
  background: repeating-linear-gradient(0deg, transparent 0 3px, #00000014 3px 4px);
}
button, input, select, output { font: inherit; color: inherit; }
h1, h2, label, button { font-family: "Hershey", sans-serif; letter-spacing: 1px; }
a { color: var(--beam); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

/* buttons and fields */
button {
  height: var(--fh); padding: 0 9px; border: 0; border-radius: 3px; cursor: pointer; white-space: nowrap;
  background: var(--field); color: var(--ink); box-shadow: var(--raise); font-size: 11px;
}
button:hover { background: var(--field-hi); }
button[aria-pressed=true], button[aria-expanded=true], button.primary { color: var(--beam); text-shadow: var(--glow); box-shadow: var(--raise), inset 0 0 0 1px rgba(var(--beam-rgb), 0.18); }
button.square { width: var(--fh); padding: 0; }
.github-link { display: inline-grid; place-items: center; flex: none; width: var(--fh); height: var(--fh); border-radius: 3px; background: var(--field); box-shadow: var(--raise); color: var(--ink); }
.github-link:hover { background: var(--field-hi); color: var(--beam); }
.github-link svg { width: 14px; height: 14px; fill: currentColor; }
button.tiny { height: 16px; padding: 0 5px; font-size: 9px; vertical-align: 1px; margin-left: 6px; }
.field {
  height: var(--fh); width: 64px; padding: 0 4px; border: 0; border-radius: 3px; background: var(--well); box-shadow: var(--press);
  color: var(--ink); text-align: center; text-align-last: center; font-size: 11px; font-family: 'SFMono-Regular', Consolas, monospace;
  display: inline-grid; place-items: center; appearance: none; -moz-appearance: textfield;
}
.field::-webkit-inner-spin-button, .field::-webkit-outer-spin-button { appearance: none; margin: 0; }
select.field { cursor: pointer; color: var(--beam); }
.field.drag { cursor: ns-resize; user-select: none; touch-action: none; }
.field.on { color: var(--beam); text-shadow: var(--glow); }
:focus, :focus-visible { outline: none; }
/* focus */
[data-nav=keys] :is(button, .field, a, input, select):focus { outline: 1px solid rgba(var(--beam-rgb), 0.35); outline-offset: 0; }
.labeled { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--label); }
.seg { display: inline-flex; gap: 2px; }

.instrument {
  height: 100vh; height: 100dvh; max-width: 1440px; margin: 0 auto; padding: 6px;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; grid-template-columns: minmax(0, 1fr); gap: 6px; position: relative;
}
.panel { background: linear-gradient(180deg, var(--panel-top) 0, var(--panel) 46px); border-radius: 5px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 2px 8px rgba(0, 0, 0, 0.6); }
.bar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: linear-gradient(180deg, var(--panel-top), var(--panel)); border-radius: 5px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 2px 8px rgba(0, 0, 0, 0.6); }
h1 { margin: 0 8px 0 2px; color: var(--beam); font-size: 21px; font-weight: 500; letter-spacing: 6px; text-shadow: 0 0 8px rgba(var(--beam-rgb), 0.6); }
/* bar */
.bar > :not(#status) { flex-shrink: 0; }
@media (max-width: 1180px) { .bar { gap: 6px; } .bar .tlabel { display: none; } .bar button:not(.square) { padding: 0 6px; } }
@media (max-width: 1100px) { .bar { gap: 4px; } .bar button:not(.square) { padding: 0 4px; } h1 { margin-right: 4px; letter-spacing: 3px; } }
#status { flex: 1; min-width: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim); font-size: 10px; transition: opacity 0.6s; }
#status.fade { opacity: 0; }
.keys { display: inline-flex; align-items: center; gap: 2px; }
#notename { width: 40px; color: var(--beam); }
#rootoct { width: 22px; color: var(--beam); }
/* pitch */
.keys.tracking #notename, .keys.tracking #rootoct { color: var(--dim); }
#pitchfrom { width: 52px; }

.views { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 6px; min-height: 0; }
.mouth-panel, .motion-panel { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; }
.panel-title > div { display: flex; gap: 8px; }
h2 { font-size: 12px; font-weight: 500; margin: 0; white-space: nowrap; color: var(--title); letter-spacing: 3px; text-shadow: 0 0 7px rgba(var(--beam-rgb), 0.35); display: flex; align-items: center; }
/* section titles */
.panel-title h2::before, .stage h2::before {
  content: ''; width: 3px; height: 11px; margin-right: 8px; border-radius: 2px; background: var(--beam); box-shadow: 0 0 6px var(--beam), 0 0 12px rgba(var(--beam-rgb), 0.4);
}
.fold, .fold:hover, .fold[aria-expanded] { height: auto; padding: 0; background: none; box-shadow: none; color: inherit; text-shadow: inherit; font: inherit; letter-spacing: inherit; }
.fold { cursor: default; pointer-events: none; }
.well { position: relative; flex: 1; min-height: 110px; margin: 0 8px 8px; background: var(--well); border-radius: 4px; box-shadow: inset 0 2px 14px rgba(0, 0, 0, 0.7), inset 0 0 0 1px rgba(255, 255, 255, 0.015); overflow: hidden; }
.well canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#mouth { touch-action: none; cursor: crosshair; }
.horn-bar { position: absolute; z-index: 1; left: 8px; bottom: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 5px 8px; background: rgba(13, 18, 23, 0.85); border-radius: 4px; box-shadow: var(--raise); }
button.icon svg { display: block; margin: auto; }
.overlay { position: absolute; z-index: 2; inset: 8px 8px auto; padding: 8px; display: grid; gap: 6px; background: var(--panel); border: 1px solid rgba(var(--beam-rgb), 0.28); border-radius: 4px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6), var(--raise); }
.overlay form { display: flex; gap: 2px; }
#text { flex: 1; width: auto; text-align: left; padding: 0 8px; }
#singtext { width: 72px; }
.tgroup { display: inline-flex; align-items: center; gap: 6px; }
/* text */
.text-panel { gap: 0; }
.text-panel form { margin-bottom: 6px; }
.text-row { display: grid; grid-template-columns: 52px 1fr; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid rgba(255, 255, 255, 0.04); }
.trow-title { color: var(--beam); font-size: 10px; letter-spacing: 1.5px; opacity: 0.8; }
.trow-body { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; }
.trow-body .tgroup { white-space: nowrap; }
.text-panel .tlabel { min-width: 0; }
#textreset { min-width: 36px; text-align: center; }
.tlabel { font-family: "Hershey", sans-serif; letter-spacing: 1px; font-size: 11px; color: var(--label); }

/* Motion */
.motion-head, .motion-row { display: grid; grid-template-columns: 70px minmax(60px, 1fr) 64px 90px 64px 56px; gap: 8px; align-items: center; padding: 0 10px; }
.motion-row .smooth { width: 56px; }
.motion-row .smooth.idle { color: var(--off); }
.motion-head { font-family: "Hershey", sans-serif; letter-spacing: 1px; font-size: 10px; color: var(--title); }
.motion-head span:nth-child(n+3) { text-align: center; }
.motion { flex: 1; display: grid; align-content: space-evenly; min-height: 0; padding: 2px 0 8px; }
.motion-row > .name { font-family: "Hershey", sans-serif; font-weight: 500; letter-spacing: 1px; font-size: 12px; color: var(--label); white-space: nowrap; }
.motion-row.active > .name { color: var(--beam); text-shadow: var(--glow); }
.base { position: relative; height: var(--fh); }
.base input { appearance: none; width: 100%; height: var(--fh); margin: 0; background: transparent; cursor: pointer; }
.base input::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; box-shadow: var(--press); background: linear-gradient(to right, var(--well) var(--lo), var(--beam-line) var(--lo), var(--beam-line) var(--hi), var(--well) var(--hi)); }
.base input::-moz-range-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--well) var(--lo), var(--beam-line) var(--lo), var(--beam-line) var(--hi), var(--well) var(--hi)); }
.base input::-webkit-slider-thumb { appearance: none; width: 4px; height: 14px; margin-top: -5px; border-radius: 1px; background: var(--ink); }
.base input::-moz-range-thumb { border: 0; border-radius: 1px; width: 4px; height: 14px; background: var(--ink); }
.base i { position: absolute; top: 6px; width: 2px; height: 12px; margin-left: -1px; background: var(--beam); box-shadow: 0 0 6px var(--beam); pointer-events: none; }
.base output { position: absolute; right: 0; top: -8px; font-size: 9px; color: var(--dim); pointer-events: none; }
.rate { display: flex; gap: 2px; }
.rate .field { width: 64px; }
.rate button { width: var(--fh); padding: 0; font-family: inherit; letter-spacing: 0; }
.motion-row.env .rate { visibility: hidden; }

/* sequencer */
.sequencer { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; padding: 8px 10px; }
.seq-controls { display: grid; grid-template-columns: repeat(4, 66px); gap: 6px; align-content: start; }
#play { width: 100%; height: 100%; }
.cell { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: 9px; letter-spacing: 0.5px; color: var(--label); }
.cell.wide { grid-column: span 2; }
.cell .field { width: 100%; box-sizing: border-box; text-align: center; }
.steps { display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 3px; }
.step { display: grid; grid-template-rows: auto auto 8px; gap: 2px; min-width: 0; user-select: none; justify-items: stretch; }
.step:nth-child(4n + 1) .note { box-shadow: var(--raise), inset 2px 0 0 rgba(var(--struct-rgb), 0.45); }
.step .note { position: relative; height: 38px; border-radius: 3px; background: var(--field); box-shadow: var(--raise); display: grid; place-items: center; padding-bottom: 6px; cursor: ns-resize; touch-action: none; color: var(--dim); font-size: 11px; }
.step.on .note { color: var(--beam); text-shadow: var(--glow); background: var(--step-on); }
.step .len { position: absolute; left: 4px; right: 4px; bottom: 4px; height: 4px; border-radius: 2px; background: var(--well); cursor: ew-resize; }
.step .len b { display: block; height: 100%; width: calc(var(--glen, var(--len)) * 100%); border-radius: 2px; background: var(--beam-line); }
.step.on .len b { background: var(--beam); box-shadow: 0 0 4px var(--beam); }
.step.tie .len { right: -5px; }
.step .acc { position: absolute; top: 2px; right: 3px; font-size: 9px; line-height: 1; color: var(--off); cursor: pointer; padding: 1px; }
.step.accent .acc { color: var(--sound); text-shadow: 0 0 5px var(--sound); }
.step.off-len { opacity: 0.28; }
.step .vowel { height: 38px; border-radius: 3px; background: var(--well); box-shadow: var(--press); display: grid; place-items: center; font-size: 17px; color: var(--off); cursor: pointer; }
.step .vowel.set { color: var(--ink); }

.step .led { justify-self: center; align-self: end; width: 5px; height: 5px; border-radius: 50%; background: var(--led-off); box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.6); }
.step.now .led { background: var(--sound); box-shadow: 0 0 4px var(--sound), 0 0 10px rgba(var(--sound-rgb), 0.55); }

/* knobs */

.stages { display: flex; flex-direction: column; gap: 6px; }
.stage-row { display: flex; gap: 6px; }

.stage { flex: var(--n) 1 0; min-width: calc(var(--n) * 40px + 8px); padding: 4px 4px 6px; background: linear-gradient(180deg, var(--panel-top) 0, var(--panel) 30px); border-radius: 5px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 2px 8px rgba(0, 0, 0, 0.6); }
.stage h2 { padding: 2px 4px 0; display: flex; align-items: center; min-height: 16px; }
.stage h2 > :first-of-type { margin-left: auto; }
#peak { font-size: 10px; color: var(--dim); font-family: 'SFMono-Regular', Consolas, monospace; letter-spacing: 0; }
.knobs { display: flex; padding: 2px 0 0; gap: 2px; }
.knob { flex: 1; min-width: 0; text-align: center; display: grid; grid-template-rows: 14px 42px 12px; justify-items: center; align-items: center; position: relative; }
.knob label { display: block; font-size: 10px; letter-spacing: 0.5px; color: var(--label); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.knob input[type=range] {
  appearance: none; width: min(36px, 100%); height: auto; aspect-ratio: 1; margin: 0; flex-shrink: 0; border: 0;
  border-radius: 50%; cursor: ns-resize; touch-action: none;
  background: radial-gradient(circle, var(--panel) 59%, transparent 62%), conic-gradient(from 225deg, var(--beam) var(--turn, 0deg), var(--well) var(--turn, 0deg) 270deg, transparent 270deg);
  filter: drop-shadow(0 0 2px rgba(var(--beam-rgb), 0.15));
}
.knob input[type=range]::-webkit-slider-thumb { appearance: none; width: 0; height: 0; }
.knob input[type=range]::-moz-range-thumb { width: 0; height: 0; border: 0; }
.knob input[type=range]::-moz-range-track { background: transparent; }
.knob output { font-size: 10px; letter-spacing: 0; cursor: pointer; white-space: nowrap; max-width: 100%; overflow: hidden; }
.knob.beyond output { color: var(--sound); }

.knob { --sync: 15px; }
.knob .sync { position: absolute; z-index: 2; top: 14px; right: 0; width: var(--sync); height: var(--sync); padding: 0; font-size: 9px; font-family: inherit; letter-spacing: 0; touch-action: manipulation; }
.knob .sync::before { content: ''; position: absolute; inset: -2px -2px -1px -2px; }
.knob .dir { top: calc(16px + var(--sync)); }
.knob .syncbox { justify-self: start; width: calc(100% - var(--sync) - 3px); height: 36px; margin: 0; padding: 0; font-size: 10px; }
@media (pointer: coarse) { .knob { --sync: 20px; } .knob .sync { font-size: 11px; } }

/* help */
.popover {
  position: absolute; z-index: 20; top: 46px; right: 12px; width: min(440px, calc(100% - 24px)); max-height: calc(100% - 60px); overflow: auto;
  padding: 12px 14px; background: var(--panel); border: 1px solid rgba(var(--beam-rgb), 0.28); border-radius: 5px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7), var(--raise);
}
.popover h2 { margin: 8px 0 4px; color: var(--beam); }
.popover h2 .sub { margin-left: 6px; color: var(--dim); font-size: 9px; letter-spacing: 0.5px; }

.pitch-pop { right: auto; width: 312px; }
.pulse-pop { right: auto; width: 228px; }
#seqvowel, #seqgate { display: flex; align-items: center; justify-content: center; }
.preset-pop { right: auto; width: auto; }
.preset-pop .pitch-row:last-child { margin-bottom: 0; }
#preset-slot { color: var(--beam); }
.mpe-name { width: 64px; color: var(--label); font-size: 10px; letter-spacing: 0.5px; }
#mpe-panel select.field { width: 84px; }
#mpe-panel .field.drag { width: 52px; }
.pitch-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 6px; }
#scale-notes { display: grid; grid-template-columns: repeat(12, 1fr); gap: 2px; }
#scale-notes button { padding: 0; min-width: 0; font-size: 10px; letter-spacing: 0; }
#jump { min-width: 44px; text-align: center; }
.popover h2:first-child { margin-top: 0; }
.popover p { margin: 0 0 6px; color: var(--ink); font-size: 11px; line-height: 1.5; }
.popover b { color: var(--beam); font-weight: normal; }

@media (max-width: 900px) {
  .instrument { height: auto; min-height: 100dvh; display: grid; grid-template-rows: none; }
  .bar { flex-wrap: wrap; }
  .views { grid-template-columns: 1fr; }
  .well { height: 280px; flex: none; }
  .sequencer { grid-template-columns: 1fr; }
  .seq-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: start; }
  .steps { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .stage-row { flex-wrap: wrap; }
  .stage { flex-basis: 30%; }
  .fold { pointer-events: auto; cursor: pointer; }
  .fold::after { content: ''; display: inline-block; width: 5px; height: 5px; margin-left: 9px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); vertical-align: 2px; }
  .fold[aria-expanded=true]::after { transform: rotate(45deg); vertical-align: 3px; }
  .motion-panel.folded .motion-head, .motion-panel.folded .motion { display: none; }
  .motion-head, .motion-row { grid-template-columns: 50px minmax(30px, 1fr) 44px 80px 44px 40px; gap: 4px; padding: 0 6px; }
  .motion-row .smooth { width: 40px; }
}
@media (prefers-reduced-motion: reduce) { body::before { display: none; } }

/* tooltips */
.tip { position: fixed; z-index: 40; max-width: 280px; padding: 7px 9px; border-radius: 4px; pointer-events: none; background: var(--panel); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.7), var(--raise); color: var(--ink); font-size: 11px; line-height: 1.45; }
.tip b { display: block; margin-bottom: 2px; color: var(--beam); font-family: "Hershey", sans-serif; font-weight: 500; letter-spacing: 1px; }

/* plug-in */
.in-plugin .web-only { display: none !important; }
body:not(.in-plugin) .plugin-only { display: none !important; }
.in-plugin #bpm { color: var(--dim); }
.plugin-grip {
  position: fixed; right: 0; bottom: 0; width: 14px; height: 14px; z-index: 100; cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, var(--dim) 50%, var(--dim) 58%, transparent 58%, transparent 72%, var(--dim) 72%, var(--dim) 80%, transparent 80%);
}

/* icons */
.glyph { width: 9px; height: 9px; margin-right: 6px; vertical-align: -1px; flex: none; }
