:root {
  /* One dark world: a studio at night. */
  color-scheme: dark;
  --bg: #15131f;
  --panel: #1e1b2c;
  --panel-2: #29253b;
  --roll: #191626;
  --line: #373249;
  --text: #eeeaf8;
  --muted: #9d97b8;
  --note: #ffb04f;
  --note-ink: #3b2304;
  --select: #ff5c93;
  --trace: #58d6c5;
  --rec: #ff4d5e;
  --font-display: "Syne", "Trebuchet MS", system-ui, sans-serif;
  --font-body: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "DM Mono", ui-monospace, "SF Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* components set display themselves; hidden must still win */
html, body { margin: 0; }
html { scroll-padding-top: 120px; } /* keep focused controls clear of the sticky transport */
@media (max-width: 640px) { html { scroll-padding-top: 0; } }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--font-body);
  padding: 24px 20px 48px;
}
.wrap { max-width: 1280px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; }
h1 { font: 800 30px/1.1 var(--font-display); letter-spacing: -0.01em; margin: 0; }
h1 span { color: var(--note); }
header p { margin: 0; color: var(--muted); max-width: 60ch; }
header { align-items: center; }
.hactions { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
#scale { max-width: 170px; }
h2 { font: 700 13px/1 var(--font-display); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.spacer { flex: 1; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--trace); outline-offset: 2px; }

.btn {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 13px; font-weight: 500; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--note); border-color: var(--note); color: var(--note-ink); font-weight: 700; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); border-color: var(--note); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.play { display: inline-flex; align-items: center; gap: 8px; min-width: 92px; justify-content: center; }
.btn.play.on { background: var(--trace); border-color: var(--trace); color: #062521; font-weight: 700; }
.btn.play .ico { font-size: 12px; }

.tog {
  width: 26px; height: 26px; padding: 0; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--muted); font: 500 12px/1 var(--font-mono); flex: none;
}
.tog:hover { border-color: var(--muted); }
.tog.on { background: var(--rec); border-color: var(--rec); color: #fff; }
.tog.solo.on { background: var(--trace); border-color: var(--trace); color: #062521; }

select, input[type="number"] {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; min-width: 0;
}
input[type="number"] { width: 70px; font-family: var(--font-mono); }
input[type="range"] { accent-color: var(--note); min-width: 70px; }
input[type="range"].vol { width: 84px; }
.check { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.check input { accent-color: var(--note); width: 16px; height: 16px; margin: 0; }
.lab { color: var(--muted); font-size: 13px; white-space: nowrap; }
.lab2 { color: var(--muted); font-size: 13px; }
.hiddenfile { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* transport */
.transport {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px;
  background: color-mix(in srgb, var(--panel) 94%, transparent); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px;
}
.tgroup { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pos { font: 500 15px/1 var(--font-mono); min-width: 5.5ch; color: var(--trace); font-variant-numeric: tabular-nums; }

/* capture */
.capture { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.caprow, .takerow { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.takerow { border-top: 1px solid var(--line); padding-top: 10px; gap: 8px 14px; }
.takerow.off > :not(.lab) { opacity: 0.4; pointer-events: none; }
.takerow.drums { display: none; } /* those settings are about humming */
.seg.capmode button { padding: 7px 11px; }
.rangebox { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
#recBtn {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--rec); border: 0; border-radius: 999px; color: #fff;
  font: 700 16px/1 var(--font-body); padding: 13px 22px 13px 18px;
}
#recBtn:hover { filter: brightness(1.1); }
#recBtn .dot { width: 14px; height: 14px; border-radius: 50%; background: #fff; }
#recBtn.on .dot { border-radius: 3px; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { #recBtn.on .dot { animation: none; } }
.live { display: flex; align-items: center; gap: 14px; min-width: 200px; }
#liveNote { font: 500 28px/1 var(--font-mono); min-width: 3.2ch; color: var(--trace); }
#liveNote.idle { color: var(--line); }
.meterbox { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 110px; }
.meter { height: 8px; border-radius: 4px; background: var(--panel-2); overflow: hidden; }
#level { height: 100%; width: 0; background: var(--trace); border-radius: 4px; }
#recTime { font: 400 13px/1 var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.loader { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
#status { margin: -4px 2px 0; min-height: 1.5em; color: var(--muted); }
#status.warn { color: var(--note); }

/* panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.phead, .ptools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 14px; }
.phead { border-bottom: 1px solid var(--line); }
.ptools { border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 70%, var(--bg)); gap: 8px 10px; }
.ptools .hint { margin-left: auto; color: var(--muted); font-size: 12px; }
.summary { font-weight: 500; font-variant-numeric: tabular-nums; font-size: 14px; }
.chip {
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--trace); border: 1px solid var(--trace); border-radius: 999px; padding: 1px 9px;
}
.chip.edited { color: var(--note); border-color: var(--note); }
#rollWrap { position: relative; background: var(--roll); }
#roll { display: block; height: 440px; width: 100%; touch-action: none; }

/* drum rack */
.rack { overflow-x: auto; padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 5px; }
.drow { display: grid; grid-template-columns: 236px 1fr; gap: 10px; align-items: center; min-width: calc(246px + var(--steps, 16) * 24px); border-radius: 8px; }
.drow.drop { outline: 2px dashed var(--trace); outline-offset: 2px; }
.drow.silent .steps { opacity: 0.4; }
.dhead { display: flex; align-items: center; gap: 5px; }
.dname {
  flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 4px 6px; border-radius: 6px;
  font-weight: 500; display: flex; flex-direction: column; line-height: 1.15;
}
.dname:hover { background: var(--panel-2); }
.dname i { font-style: normal; font: 400 11px/1.2 var(--font-mono); color: var(--trace); }
.dname .miss { font: 700 10px/1.2 var(--font-body); color: var(--note); text-transform: uppercase; letter-spacing: 0.04em; }
.dvol { width: 62px !important; min-width: 0 !important; }
.tog.small { font-size: 13px; }
.steps { display: grid; grid-template-columns: repeat(var(--steps, 16), minmax(20px, 1fr)); gap: 3px; touch-action: pan-y; }
.step {
  height: 30px; border-radius: 5px; border: 1px solid transparent; background: var(--panel-2); padding: 0;
}
.step.alt { background: #231f33; }
.step:hover { border-color: var(--muted); }
.step.on { background: var(--note); }
.step.on.acc { background: #ffd08f; box-shadow: inset 0 0 0 2px #fff6; }
.step.on.ghost { background: color-mix(in srgb, var(--note) 50%, var(--panel-2)); }
.step.now { border-color: var(--trace); }
.step.now:not(.on) { background: color-mix(in srgb, var(--trace) 22%, var(--panel-2)); }
.step.on.now { filter: brightness(1.2); }

/* mode switch */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { background: var(--panel-2); border: 0; padding: 7px 12px; font-weight: 500; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--text); color: var(--bg); font-weight: 700; }

/* playlist */
.plgrid { display: grid; grid-template-columns: 290px 1fr; }
.plheads { border-right: 1px solid var(--line); background: var(--panel); }
.plcorner { height: 38px; border-bottom: 1px solid var(--line); padding: 0 12px; display: flex; align-items: center; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.plhead {
  height: 52px; display: flex; align-items: center; gap: 5px; padding: 0 8px 0 0;
  border-bottom: 1px solid rgba(255,255,255,0.06); cursor: pointer;
}
.plhead.on { background: rgba(255,255,255,0.045); }
.plhead .swatch { align-self: stretch; width: 5px; height: auto; border-radius: 0; background: var(--tc); flex: none; margin-right: 5px; }
.plhead.on .swatch { width: 7px; }
.plname { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.plname input {
  width: 100%; background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 1px 5px;
  font-weight: 500; font-size: 14px;
}
.plname input:hover { border-color: var(--line); }
.plname input:focus { background: var(--panel-2); border-color: var(--muted); outline: none; }
.pltype { font-size: 11px; color: var(--muted); padding-left: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plhead.muted .plname { opacity: 0.5; }
.plvol { width: 54px !important; min-width: 0 !important; }
.plauto {
  height: 60px; display: flex; align-items: center; gap: 6px; padding: 0 8px 0 0;
  border-bottom: 1px solid rgba(255,255,255,0.06); background: rgba(0,0,0,0.18);
}
.plauto .swatch { align-self: stretch; width: 5px; height: auto; border-radius: 0; background: var(--tc); opacity: 0.45; flex: none; margin-right: 12px; }
.plauto .autosel { flex: 1; min-width: 0; font-size: 13px; padding: 4px 6px; }
.tog.auto { font-size: 11px; }
.tog.auto.has:not(.on) { color: var(--tc); border-color: var(--tc); }
.tog.auto.on { background: var(--tc); border-color: var(--tc); color: #15131f; }
.autod > span::after, .fwrap.autod::after { content: ' A'; color: var(--note); font-weight: 700; }
.fwrap.autod { position: relative; }
.fwrap.autod::after { position: absolute; top: -4px; right: -10px; font-size: 10px; }
.knob.filter input { accent-color: var(--trace); }
.knob.reverb input { accent-color: #5fb4ff; }
.knob.pump input { accent-color: var(--select); }
.knob.loud input { accent-color: var(--rec); }
.tog.x { font-size: 15px; }
.tog:disabled { opacity: 0.3; cursor: default; }
.pllanes { position: relative; min-width: 0; background: var(--roll); }
#plCanvas { display: block; width: 100%; touch-action: pan-y; }

/* editor */
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: none; }
.editor { border-top: 3px solid var(--tc, var(--line)); }
.editor h2 { color: var(--text); }
.ctl { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.small { font-size: 12px; }
.edhint { margin: 0; padding: 8px 14px; font-size: 13px; color: var(--note); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--note) 7%, var(--panel)); }
.linkbtn { background: none; border: 0; padding: 0; color: var(--text); text-decoration: underline; font-size: inherit; }

/* mixer */
.mixer { display: flex; gap: 8px; overflow-x: auto; padding: 12px 14px 14px; }
.strip {
  flex: none; width: 104px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--line); border-top: 3px solid var(--tc, var(--line));
  border-radius: 10px; padding: 8px 6px 10px;
}
.strip.on { border-color: var(--tc); box-shadow: inset 0 0 0 1px var(--tc); }
.strip.silent .fwrap, .strip.silent .knob { opacity: 0.45; }
.strip.master { --tc: var(--text); width: 120px; background: color-mix(in srgb, var(--panel-2) 80%, var(--bg)); }
.sname {
  width: 100%; background: none; border: 0; padding: 2px 4px; border-radius: 6px; font-weight: 600; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center;
}
button.sname:hover { background: rgba(255,255,255,0.06); }
.fwrap { display: flex; align-items: stretch; gap: 8px; height: 150px; }
.meter { width: 8px; border-radius: 3px; background: #15131f; overflow: hidden; position: relative; height: 100%; }
.mfill {
  position: absolute; inset: 0; transform-origin: bottom; transform: scaleY(0);
  background: linear-gradient(to top, #58d6c5 0%, #58d6c5 62%, #ffe066 82%, #ff4d5e 100%);
  background-size: 100% 150px; background-position: bottom;
}
.mfill.hot { box-shadow: inset 0 3px 0 #ff4d5e; }
.fader {
  writing-mode: vertical-lr; direction: rtl; width: 26px !important; min-width: 0 !important; height: 100%; margin: 0;
  accent-color: var(--tc);
}
.strip.master .fader { accent-color: var(--note); }
.db { font: 11px/1 var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.knob { width: 100%; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 0 4px; font-size: 11px; color: var(--muted); }
.knob input { grid-column: 1 / -1; width: 100%; min-width: 0; accent-color: var(--tc); margin: 2px 0 0; }
.knob output { text-align: right; font-family: var(--font-mono); }
.knob.drive input { accent-color: var(--rec); }
.ms { display: flex; gap: 6px; }
.mnote { margin: auto 0 0; font-size: 11px; color: var(--muted); text-align: center; line-height: 1.3; }

.arpbox { display: inline-flex; align-items: center; gap: 4px; }
.arpbox select { padding: 4px 6px; font-size: 13px; }

/* live keys */
.keysbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 85%, var(--bg)); }
.keysbar .hint { margin-left: auto; color: var(--muted); font-size: 12px; }
.readout { font-family: var(--font-mono); min-width: 2.6ch; text-align: center; }
.btn.tgl.on { background: var(--trace); border-color: var(--trace); color: #062521; font-weight: 700; }
.btn.tgl.rec.on { background: var(--rec); border-color: var(--rec); color: #fff; animation: pulse 1.2s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .btn.tgl.rec.on { animation: none; } }
.dname.hit { animation: hit 0.25s ease-out; }
@keyframes hit { from { background: var(--note); color: var(--note-ink); } }

/* sound shape */
.shapebar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.shapebar .hint { margin-left: auto; color: var(--muted); font-size: 12px; }
.shp { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.shp input { width: 110px; min-width: 0; accent-color: var(--tc, var(--note)); }
.shp output { font: 12px var(--font-mono); color: var(--text); min-width: 7.5ch; }

/* example picker */
.exwrap { position: relative; }
.btn.exbtn { border-color: var(--trace); color: var(--trace); }
.expanel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: min(420px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 8px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.45); display: flex; flex-direction: column; gap: 4px;
}
.exitem {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; text-align: left; width: 100%;
  background: none; border: 1px solid transparent; border-radius: 10px; padding: 10px 12px;
}
.exitem:hover, .exitem:focus-visible { background: var(--panel-2); border-color: var(--line); }
.exitem .t { font: 700 15px/1.2 var(--font-body); }
.exitem .m { font: 12px var(--font-mono); color: var(--muted); text-align: right; white-space: nowrap; }
.exitem .b { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
.exitem .s { color: var(--trace); font-weight: 500; }
.exnote { margin: 4px 12px 2px; font-size: 12px; color: var(--muted); }

/* my songs */
.songspanel { max-height: min(70vh, 560px); overflow-y: auto; }
.songrow { display: flex; align-items: center; gap: 4px; border-radius: 10px; }
.songrow .exitem { flex: 1; min-width: 0; }
.songrow .exitem .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.songrow.cur { background: color-mix(in srgb, var(--trace) 8%, transparent); }
.songrow .tog { flex: none; }
.songrow .tog.x.sure { width: auto; padding: 0 8px; background: var(--rec); border-color: var(--rec); color: #fff; font: 600 12px var(--font-body); }
.nowtag { font: 600 11px var(--font-body); color: var(--trace); border: 1px solid var(--trace); border-radius: 999px; padding: 0 6px; margin-left: 4px; vertical-align: 2px; }

/* share */
.sharepanel { padding: 14px; gap: 10px; }
.sharehead { margin: 0; font-size: 14px; }
.sharerow { display: flex; gap: 8px; }
.sharerow input {
  flex: 1; min-width: 0; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 8px; font: 12px var(--font-mono); color: var(--muted);
}

/* welcome */
.welcome {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; position: relative;
  background: linear-gradient(120deg, color-mix(in srgb, var(--note) 14%, var(--panel)), var(--panel) 60%);
  border: 1px solid color-mix(in srgb, var(--note) 45%, var(--line)); border-radius: 14px; padding: 16px 52px 16px 20px;
}
.welcome h2 { font: 700 18px/1.3 var(--font-body); color: var(--text); text-transform: none; letter-spacing: 0; margin: 0 0 6px; }
.welcome ol { margin: 0; padding-left: 20px; color: var(--muted); font-size: 14px; }
.welcome li { margin: 2px 0; }
.welcome b { color: var(--text); font-weight: 600; }
.wtext { flex: 1 1 380px; }
.wact { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.wclose { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; padding: 0; font-size: 18px; }

/* help */
.help { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 16px; }
.help summary { cursor: pointer; color: var(--muted); font-weight: 500; }
.helpgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 4px 24px; }
.help h3 { font: 700 12px/1 var(--font-display); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 14px 0 6px; }
.help ul { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--muted); }
.help li { margin: 3px 0; }
.help b { color: var(--text); font-weight: 500; }
footer { color: var(--muted); font-size: 13px; max-width: 80ch; }
body.dropping .capture { outline: 2px dashed var(--trace); outline-offset: 3px; }

@media (max-width: 640px) {
  body { padding: 14px 16px 36px; }
  h1 { font-size: 25px; }
  #roll { height: 360px; }
  .loader { margin-left: 0; }
  .ptools .hint { margin-left: 0; }
  .transport { position: static; }
  .drow { grid-template-columns: 150px 1fr; min-width: calc(160px + var(--steps, 16) * 24px); }
  .expanel { left: 0; right: auto; } /* the header wraps, so the button sits on the left here */
  .sharepanel, .songspanel { position: fixed; top: 12px; left: 16px; right: 16px; width: auto; } /* mid-row buttons: pin to the screen instead */
  .welcome { padding: 14px 44px 14px 16px; }
  .plgrid { grid-template-columns: 132px 1fr; }
  .plvol, .tog.x { display: none; }
  .plhead .tog { width: 22px; height: 22px; }
  .dvol { display: none; }
}
