:root {
  --bg: #07080a;
  --panel: #0d0f12;
  --fg: #e6ebf0;
  --dim: rgba(230, 235, 240, 0.55);
  --faint: rgba(230, 235, 240, 0.14);
  --accent: #c8f560;
  --gutter: clamp(16px, 2.4vw, 32px);
  --sans: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--fg); font-family: var(--sans); font-weight: 300;
  -webkit-font-smoothing: antialiased; padding-bottom: 60px;
}
:where(button, label.btn) { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent); color: var(--bg); }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }
.mono { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }
.grain {
  position: fixed; inset: -50%; z-index: 5; pointer-events: none; opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- chrome ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 18px;
  padding: 14px var(--gutter); background: rgba(7, 8, 10, 0.86);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--faint);
}
.brand { display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: 18px; letter-spacing: 0.04em; }
.brand__glyph { width: 24px; height: 11px; fill: var(--fg); }
.brand__glyph path { fill: var(--accent); }
.title { color: var(--accent); }
.topbar__right { margin-left: auto; display: flex; gap: 20px; align-items: center; }
.link { position: relative; padding: 3px 0; color: var(--dim); transition: color 0.3s; }
.link:hover { color: var(--fg); }

main { max-width: 1240px; margin: 0 auto; padding: 0 var(--gutter); }
.intro { padding: clamp(40px, 7vw, 90px) 0 30px; }
.intro h1 { font-weight: 400; font-size: clamp(38px, 6vw, 82px); line-height: 0.98; letter-spacing: -0.035em; }
.intro h1 em { font-style: normal; color: var(--accent); }
.lede { max-width: 620px; margin-top: 18px; color: var(--dim); line-height: 1.7; font-size: 15px; }

/* ---------- transport ---------- */
.bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 16px; border: 1px solid var(--faint); border-radius: 14px;
  background: var(--panel); position: sticky; top: 56px; z-index: 9;
}
.bar__right { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px;
  border: 1px solid var(--faint); font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.06em; text-transform: uppercase; background: rgba(255, 255, 255, 0.03);
  transition: border-color 0.25s, background 0.25s, color 0.25s, transform 0.25s var(--ease);
}
.btn:hover { border-color: var(--dim); transform: translateY(-1px); }
.btn--primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.play-ico { width: 0; height: 0; border-left: 9px solid currentColor; border-top: 6px solid transparent; border-bottom: 6px solid transparent; }
[aria-pressed="true"] .play-ico { border: 0; width: 9px; height: 10px; background: currentColor; }
.field { display: inline-flex; align-items: center; gap: 8px; color: var(--dim); }
.field input[type="number"], .field select {
  background: #14181d; color: var(--fg); border: 1px solid var(--faint);
  border-radius: 8px; padding: 7px 9px; font-family: var(--mono); font-size: 12px;
}
.field input[type="range"] { width: 92px; accent-color: var(--accent); }
.unit { color: var(--dim); }

/* ---------- sequencer ---------- */
.seq { margin-top: 22px; }
.seq__head, .lane { display: grid; grid-template-columns: 150px repeat(16, 1fr); gap: 6px; }
.seq__head { color: var(--dim); padding: 0 0 6px 0; }
.seq__head span { text-align: center; font-size: 9px; }
.seq__head .beat { color: var(--accent); }
.lane { margin-bottom: 6px; align-items: stretch; }
.lane.is-sel .pad { border-color: var(--accent); }
.pad {
  display: flex; align-items: center; gap: 9px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--faint); background: var(--panel); text-align: left;
  transition: border-color 0.25s, background 0.25s;
}
.pad:hover { background: #12161b; }
.pad__n { color: var(--dim); }
.pad__name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pad.is-sel { background: #151a20; }
.pad.is-hit { animation: padhit 0.35s var(--ease); }
@keyframes padhit {
  0% { background: var(--accent); color: var(--bg); }
  100% { background: #151a20; color: var(--fg); }
}
.cell {
  height: 44px; border-radius: 8px; border: 1px solid var(--faint);
  background: #0b0d10; transition: background 0.12s, border-color 0.12s, transform 0.12s;
}
.cell.beat { border-color: rgba(230, 235, 240, 0.24); }
.cell:hover { border-color: var(--dim); }
.cell.on { background: #4d6b1c; border-color: #6d9628; }
.cell.accent { background: var(--accent); border-color: var(--accent); }
.cell.is-now { transform: scaleY(1.08); box-shadow: 0 0 0 1px var(--accent) inset; }
.note { color: var(--dim); margin-top: 10px; text-transform: none; letter-spacing: 0.02em; line-height: 1.7; }

/* ---------- editor ---------- */
.editor { margin-top: 34px; border: 1px solid var(--faint); border-radius: 16px; background: var(--panel); overflow: hidden; }
.editor__head { display: flex; gap: 20px; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--faint); flex-wrap: wrap; }
.kicker { color: var(--accent); }
.voice-name {
  background: none; border: 0; border-bottom: 1px solid var(--faint); color: var(--fg);
  font-family: var(--sans); font-size: 30px; font-weight: 400; letter-spacing: -0.02em;
  padding: 2px 0; width: 240px;
}
.voice-name:focus { outline: none; border-color: var(--accent); }
#scope { flex: 1; min-width: 280px; height: 96px; background: #0b0d10; border: 1px solid var(--faint); border-radius: 10px; }
.editor__actions { display: flex; align-items: center; gap: 10px; }
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.panel { padding: 18px; border-right: 1px solid var(--faint); }
.panel:last-child { border-right: 0; }
.panel h3 { color: var(--dim); font-weight: 400; margin-bottom: 14px; }
.panel__row { display: flex; flex-wrap: wrap; gap: 16px 14px; align-items: flex-start; }

.knob { width: 62px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.knob__dial { width: 48px; height: 48px; cursor: ns-resize; touch-action: none; border-radius: 50%; }
.knob__dial svg { width: 100%; height: 100%; display: block; }
.k-track { fill: none; stroke: rgba(230, 235, 240, 0.12); stroke-width: 3; stroke-dasharray: 89.5 119.4; transform: rotate(135deg); transform-origin: 50% 50%; }
.k-fill { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; }
.k-hand { stroke: var(--fg); stroke-width: 2; stroke-linecap: round; }
.knob__dial.is-drag .k-hand, .knob__dial:hover .k-hand { stroke: var(--accent); }
.knob__label { color: var(--dim); font-size: 9px; text-align: center; }
.knob__val { font-size: 9.5px; color: var(--fg); }
.sel { display: flex; flex-direction: column; gap: 6px; }
.sel span { color: var(--dim); font-size: 9px; }
.sel select { background: #14181d; color: var(--fg); border: 1px solid var(--faint); border-radius: 8px; padding: 8px; font-family: var(--mono); font-size: 11px; }

/* ---------- export + help ---------- */
.export, .help { margin-top: 34px; padding: 22px; border: 1px solid var(--faint); border-radius: 16px; background: var(--panel); }
.export h2, .help h2 { font-weight: 400; font-size: 26px; letter-spacing: -0.02em; margin-bottom: 8px; }
.export__row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.help__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 22px; margin-top: 16px; }
.help h3 { font-weight: 400; font-size: 19px; margin-bottom: 6px; color: var(--accent); }
.help p { color: rgba(230, 235, 240, 0.78); line-height: 1.7; font-size: 14px; }
.help b { font-weight: 500; color: var(--fg); }

.foot { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; max-width: 1240px; margin: 40px auto 0; padding: 20px var(--gutter); color: var(--dim); text-transform: none; letter-spacing: 0.02em; border-top: 1px solid var(--faint); }
.toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 20; transform: translate(-50%, 16px);
  padding: 10px 16px; border-radius: 999px; background: var(--fg); color: var(--bg);
  opacity: 0; pointer-events: none; transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  /* Keep all 16 steps; the grid scrolls sideways with the name column pinned. */
  .seq { overflow-x: auto; padding-bottom: 6px; }
  .seq__head, .lane { grid-template-columns: 116px repeat(16, 42px); width: max-content; }
  .pad { position: sticky; left: 0; z-index: 2; }
  .cell { height: 38px; }
  .panel { border-right: 0; border-bottom: 1px solid var(--faint); }
}
@media (max-width: 640px) {
  .bar { position: static; }
  .voice-name { width: 100%; font-size: 24px; }
  .topbar__right a { display: none; }
}

/* PO-32 page: A/B endpoint switch */
.ab { display: inline-flex; gap: 6px; }
.ab .btn.is-on { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.editor__head .note { margin-top: 4px; max-width: 420px; }

/* PO-32: the 16 device sounds */
.slots-wrap { margin-top: 22px; }
.slots { display: grid; gap: 8px; }
.slot { position: relative; }
.slot__btn {
  width: 100%; display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  padding: 12px 12px 12px 30px; border: 1px solid var(--faint); border-radius: 10px;
  background: var(--panel); text-align: left; transition: border-color .2s, background .2s;
}
.slot__btn:hover { background: #12161b; }
.slot.is-sel .slot__btn { border-color: var(--accent); background: #151a20; }
.slot.is-edited .slot__n::after { content: "•"; color: var(--accent); margin-left: 4px; }
.slot__n { color: var(--dim); font-size: 9px; }
.slot__name { font-size: 13px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.slot__tick { position: absolute; left: 10px; top: 14px; accent-color: var(--accent); width: 14px; height: 14px; }
.bar__group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dim { color: var(--dim); }
.editor__id { display: flex; flex-direction: column; gap: 8px; }
.pad-note { padding: 0 18px 10px; }
.btn[disabled] { opacity: .4; pointer-events: none; }

/* Drag-and-drop overlay (hidden until files are dragged over the page) */
.drop {
  position: fixed; inset: 12px; z-index: 60; border: 1px dashed var(--accent);
  border-radius: 18px; display: grid; place-items: center;
  background: rgba(7, 8, 10, 0.72); backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none; transition: opacity .25s;
  font-size: clamp(32px, 6vw, 80px); font-weight: 300; letter-spacing: -0.03em;
}
.drop em { color: var(--accent); font-style: normal; }
.drop.is-on { opacity: 1; }

/* ---------- kit header + transfer steps ---------- */
.kit-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.kit-head h2 { font-weight: 400; font-size: clamp(20px, 2.4vw, 28px); letter-spacing: -0.02em; }
.kit-head h2 span { font-size: 11px; }
#kitStatus { color: var(--accent); }
.kit-head .btn { margin-left: auto; }
.steps-list { color: var(--dim); display: grid; gap: 6px; margin: 10px 0 16px; padding-left: 18px;
  text-transform: none; letter-spacing: 0.02em; line-height: 1.6; }
.steps-list li::marker { color: var(--accent); }
.btn--big { padding: 14px 22px; font-size: 12.5px; }

/* ---------- zoom / small-screen robustness ---------- */
/* Nothing sticky once the viewport gets short or narrow: with two sticky bars
   a zoomed-in phone ends up with almost no room left to work in. */
@media (max-width: 900px), (max-height: 620px) {
  .topbar, .bar { position: static; }
}
main, .seq, .editor, .export, .help, .slots-wrap { max-width: 100%; }
.panels { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.slots { grid-template-columns: repeat(auto-fill, minmax(min(116px, 100%), 1fr)); }
#scope { max-width: 100%; }
.editor__head { align-items: flex-start; }
@media (max-width: 900px) {
  .editor__head { flex-direction: column; gap: 14px; }
  .editor__actions { flex-wrap: wrap; }
  #scope { width: 100%; height: 80px; }
  .voice-name { width: 100%; }
  .bar { gap: 10px; }
  .bar__right { margin-left: 0; width: 100%; }
  .kit-head .btn { margin-left: 0; }
}
@media (max-width: 560px) {
  .knob { width: 56px; }
  .knob__dial { width: 44px; height: 44px; }
  .panel { padding: 14px; }
  .btn { padding: 9px 13px; font-size: 10.5px; }
  .export__row { gap: 8px; }
}
