/* AbleGo! - dark, flat UI, built for thumbs. */
:root {
  --bg: #1b1b1b;
  --bg-2: #232323;
  --panel: #2b2b2b;
  --panel-2: #333;
  --line: #3d3d3d;
  --line-2: #4a4a4a;
  --text: #dcdcdc;
  --text-dim: #8e8e8e;
  --accent: #ff9f1c;
  --accent-ink: #1b1b1b;
  --play: #6fe26f;
  --rec: #ff4b3e;
  --sel: #ffd166;
  --radius: 6px;
  --tap: 40px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 14px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg { fill: currentColor; }

#app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 3px minmax(88px, 34%) 1fr;
  grid-template-columns: minmax(0, 1fr);
  padding-top: var(--safe-top);
  max-width: 1100px;
  margin: 0 auto;
}

/* ---------- Transport ---------- */
.transport {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: var(--bg-2);
  border-bottom: 1px solid #111;
  min-width: 0;
}
.logo { font-weight: 800; font-size: 17px; letter-spacing: -0.5px; margin-right: auto; white-space: nowrap; }
.logo-a { color: var(--text); }
.logo-b { color: var(--accent); }
.tbtn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 0;
  flex: none;
}
.tbtn svg { width: 20px; height: 20px; }
.tbtn:active { background: var(--panel-2); }
.tbtn.play .i-stop { display: none; }
.tbtn.play.on { background: var(--play); color: #102010; border-color: var(--play); }
.tbtn.play.on .i-play { display: none; }
.tbtn.play.on .i-stop { display: block; }
.tbtn.rec { color: var(--rec); }
.tbtn.rec.on { background: var(--rec); color: #fff; border-color: var(--rec); }
.tbtn.toggle.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tbtn:disabled { opacity: .35; }

.tbtn.sketch {
  width: auto; padding: 0 10px 0 8px; display: flex; align-items: center; gap: 5px;
  color: var(--rec); border-color: color-mix(in srgb, var(--rec) 55%, var(--line));
}
.tbtn.sketch span { font-size: 13px; font-weight: 700; color: var(--text); }
.tbtn.sketch.on { background: var(--rec); color: #fff; border-color: var(--rec); animation: pulse 1.2s infinite; }
.tbtn.sketch.on span { color: #fff; }

.meter-strip { background: #111; }
.meter-strip canvas { display: block; width: 100%; height: 3px; }

@media (max-width: 440px) {
  .logo { font-size: 16px; }
}
@media (max-width: 380px) {
  .logo { font-size: 14.5px; letter-spacing: -0.6px; }
}
@media (max-width: 380px) {
  .tbtn { width: 32px; }
  .tbtn.sketch { padding: 0 7px; }
  .transport { gap: 3px; padding: 6px; }
}
@media (max-width: 330px) {
  .tbtn.sketch span { display: none; }
}

/* ---------- Tracks ---------- */
.tracks {
  overflow-y: auto;
  background: var(--bg);
  padding: 6px 8px;
  display: flex; flex-direction: column; gap: 4px;
  border-bottom: 1px solid #111;
}
.track {
  display: grid;
  grid-template-columns: 6px minmax(70px, 34%) 1fr auto;
  align-items: stretch;
  min-height: 44px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  flex: none;
}
.track.selected { border-color: var(--sel); box-shadow: 0 0 0 1px var(--sel) inset; }
.track .color { background: var(--c); }
.track .info {
  display: flex; flex-direction: column; justify-content: center;
  padding: 2px 8px; min-width: 0; border: 0; background: none; text-align: left;
}
.track .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track .type { font-size: 11px; color: var(--text-dim); }
.track .clip {
  position: relative;
  margin: 5px 0;
  background: color-mix(in srgb, var(--c) 18%, #1f1f1f);
  border-radius: 4px;
  overflow: hidden;
}
.track .clip canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.track .btns { display: flex; align-items: center; gap: 4px; padding: 0 6px; }
.track .meter { width: 5px; height: 30px; margin-right: 2px; background: #151515; }
.ms {
  width: 30px; height: 30px; border-radius: 4px;
  border: 1px solid var(--line-2); background: var(--panel-2);
  font-size: 12px; font-weight: 700; padding: 0;
}
.ms.mute.on { background: #e8c547; color: #222; border-color: #e8c547; }
.ms.solo.on { background: #4aa3ff; color: #081523; border-color: #4aa3ff; }
.track.muted .clip, .track.muted .info { opacity: .45; }

.add-track {
  flex: none;
  min-height: 40px;
  border: 1px dashed var(--line-2);
  background: transparent;
  color: var(--text-dim);
  border-radius: var(--radius);
  font-weight: 600;
}
.add-track:active { background: var(--panel); }

/* ---------- Projects ---------- */
.proj-bar { flex: none; display: flex; align-items: center; gap: 6px; min-height: 34px; }
.proj-bar-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  min-height: 34px; padding: 0 10px; border: 0; border-radius: var(--radius);
  background: transparent; text-align: left;
}
.proj-bar-main:active { background: var(--panel); }
.proj-bar .chip { padding: 6px 10px; }
.proj-bar .song-sum { font-variant-numeric: tabular-nums; color: var(--text-dim); }
.proj-bar-name { font-weight: 700; font-size: 15px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-bar-switch { font-size: 12px; font-weight: 600; color: var(--accent); flex: none; }

.proj-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.proj {
  display: flex; align-items: center; gap: 6px; padding: 6px;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px;
}
.proj.current { border-color: var(--sel); }
.proj .chip { padding: 9px 11px; }
.proj-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  background: none; border: 0; padding: 4px; text-align: left;
}
.proj-colors { display: grid; grid-template-columns: repeat(3, 10px); gap: 2px; flex: none; }
.proj-colors i { width: 10px; height: 10px; border-radius: 2px; }
.proj-text { min-width: 0; }
.proj-text b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-text small { color: var(--text-dim); }
.proj.current .proj-text small { color: var(--sel); }

/* ---------- Editor ---------- */
.editor {
  display: flex; flex-direction: column;
  min-height: 0;
  background: var(--bg-2);
  padding-bottom: var(--safe-bottom);
}
.tabs {
  display: flex; gap: 2px; padding: 6px 8px 0;
  border-bottom: 1px solid var(--line);
  align-items: flex-end;
}
.tabs button {
  border: 1px solid transparent; border-bottom: 0;
  background: transparent; color: var(--text-dim);
  padding: 8px 14px; border-radius: var(--radius) var(--radius) 0 0;
  font-weight: 600;
}
.tabs button.active { background: var(--panel); color: var(--text); border-color: var(--line); margin-bottom: -1px; }
.tab-track {
  margin-left: auto; align-self: center; font-size: 12px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%;
  display: flex; align-items: center; gap: 6px;
}
.tab-track::before { content: ""; width: 10px; height: 10px; border-radius: 2px; background: var(--c, #888); flex: none; }

.panel { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--panel); }
.panel.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }

.toolbar {
  display: flex; align-items: center; gap: 4px; padding: 6px 8px;
  border-bottom: 1px solid var(--line); flex-wrap: nowrap; overflow-x: auto;
  scrollbar-width: none;
}
.toolbar::-webkit-scrollbar { display: none; }
.spacer { flex: 1; }
.tool-label { font-size: 10px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; flex: none; }
.seg { display: flex; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; flex: none; }
.seg button {
  border: 0; background: var(--panel-2); padding: 6px 8px; font-size: 12px; font-weight: 600;
  border-right: 1px solid var(--line-2); min-width: 32px; padding: 6px 7px;
}
.seg button:last-child { border-right: 0; }
.seg button.active { background: var(--accent); color: var(--accent-ink); }
.chip {
  border: 1px solid var(--line-2); background: var(--panel-2); border-radius: var(--radius);
  padding: 6px 9px; font-size: 12px; font-weight: 600; flex: none; min-width: 32px;
}
.chip:active { background: var(--line); }
.chip.on, .chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip.danger { color: #ff8a80; }
.chip.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip:disabled { opacity: .4; }

.roll-wrap { position: relative; flex: 1; min-height: 120px; }
.roll-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }

/* ---------- Performance keys / pads ---------- */
.keys {
  height: 124px; flex: none; position: relative;
  border-top: 1px solid #111; background: #151515;
  display: flex; touch-action: none;
}
.keys .oct {
  width: 34px; display: flex; flex-direction: column; flex: none;
  border-right: 1px solid #111;
}
.keys .oct button { flex: 1; border: 0; background: var(--panel-2); font-weight: 700; font-size: 16px; border-bottom: 1px solid #111; }
.keys .oct span { font-size: 10px; text-align: center; color: var(--text-dim); padding: 2px 0; }
.piano { position: relative; flex: 1; display: flex; }
.piano .w {
  flex: 1; background: #e9e9e9; border-right: 1px solid #999; border-radius: 0 0 4px 4px;
  position: relative; color: #777; font-size: 10px; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 4px;
}
.piano .b {
  position: absolute; top: 0; height: 60%; background: #1d1d1d; border: 1px solid #000;
  border-radius: 0 0 3px 3px; z-index: 2;
}
.piano .w.down { background: var(--accent); }
.piano .b.down { background: var(--accent); }
.pads { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; }
.pad {
  border: 1px solid var(--line-2); border-radius: 5px; background: var(--panel-2);
  font-size: 11px; font-weight: 600; color: var(--text-dim);
  display: flex; align-items: flex-end; padding: 5px; touch-action: none;
}
.pad.down { background: var(--c, var(--accent)); color: #111; }

/* ---------- Form rows (Sound / Sample panels) ---------- */
.section { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.section h3 {
  margin: 0 0 8px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim);
  display: flex; align-items: center; gap: 8px;
}
.row { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.row + .row { margin-top: 4px; }
.row > label { width: 76px; flex: none; color: var(--text-dim); font-size: 13px; }
.row .val { width: 44px; text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; color: var(--text-dim); flex: none; }
.row .grow { flex: 1; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 32px; background: transparent; margin: 0;
  --pct: 50%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(to right, var(--accent) var(--pct), #444 var(--pct));
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: #444; }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: #eee; border: 2px solid #222; margin-top: -8px;
}
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #eee; border: 2px solid #222; }

.text-input {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--radius);
  padding: 8px 10px; outline: none; -webkit-user-select: text; user-select: text;
}
.text-input:focus { border-color: var(--accent); }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; background: var(--c); padding: 0; }
.swatch.on { border-color: #fff; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-row .chip { padding: 9px 12px; }

/* ---------- Sample panel ---------- */
.rec-zone { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 12px; text-align: center; }
.rec-big {
  width: 92px; height: 92px; border-radius: 50%;
  border: 4px solid #444; background: #2a2a2a; display: grid; place-items: center;
}
.rec-big::after { content: ""; width: 40px; height: 40px; border-radius: 50%; background: var(--rec); transition: all .15s; }
.rec-big.on { border-color: var(--rec); animation: pulse 1.2s infinite; }
.rec-big.on::after { border-radius: 6px; width: 32px; height: 32px; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(255,75,62,.18); } }
.rec-time { font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 700; }
.rec-level { width: 70%; max-width: 280px; height: 6px; background: #111; border-radius: 3px; overflow: hidden; }
.rec-level div { height: 100%; width: 0; background: var(--play); transition: width .05s; }
.muted-text { color: var(--text-dim); font-size: 12px; }

.sample-view { position: relative; height: 210px; margin: 0 12px; background: #161616; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.sample-view canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.now-note {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 10px 12px 6px;
}
.now-note .big { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 90px; color: var(--accent); }
.now-note .big.idle { color: #555; }
.now-note .meta { text-align: right; font-size: 12px; color: var(--text-dim); }

/* ---------- Sheet / toast / splash ---------- */
/* The backdrop stops below the transport bar, so play/stop/record stay usable with a sheet open. */
.sheet-backdrop { position: fixed; inset: 0; top: calc(var(--safe-top) + 49px); background: rgba(0,0,0,.55); z-index: 20; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-width: 560px; margin: 0 auto; max-height: 86vh; overflow-y: auto;
  background: var(--panel); border-radius: 14px 14px 0 0; border: 1px solid var(--line);
  padding: 8px 14px calc(16px + var(--safe-bottom));
  animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: #555; margin: 2px auto 10px; }
.sheet h2 { margin: 4px 0 12px; font-size: 17px; }
.sheet-top h2 { flex: 1; min-width: 0; margin: 10px 8px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-top {
  position: sticky; top: -8px; z-index: 5; height: 50px; margin: -8px -14px 4px; padding: 0 14px;
  background: var(--panel); display: flex; align-items: center; justify-content: flex-end;
  box-shadow: 0 6px 8px -6px rgba(0,0,0,.5);
  border-bottom: 1px solid transparent;
}
.sheet-top .grab { position: absolute; left: 50%; top: 8px; margin: 0; transform: translateX(-50%); }
.sheet-close {
  width: 40px; height: 40px; border-radius: 50%; flex: none; margin-top: 8px;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text);
  font-size: 18px; font-weight: 700; line-height: 1; display: grid; place-items: center; padding: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
.sheet-close:active { background: var(--line); }
.sheet .choice {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px; margin-bottom: 8px; text-align: left;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px;
}
.sheet .choice .ic { width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center; font-size: 20px; background: var(--c); color: #111; flex: none; }
.sheet .choice b { display: block; }
.sheet .choice small { color: var(--text-dim); }
.sheet .help { color: var(--text-dim); font-size: 13px; }
.sheet .help li { margin-bottom: 6px; }
.sheet .help b { color: var(--text); }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%);
  background: #eee; color: #111; padding: 9px 14px; border-radius: 20px; font-weight: 600; z-index: 40;
  max-width: 90vw; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.4);
}

.splash {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 30%, #2d2d2d, #121212 70%);
  text-align: center; padding: 24px;
}
.splash-mark { width: 112px; height: 112px; display: block; margin: 0 auto 6px; filter: drop-shadow(0 10px 30px rgba(157,0,255,.35)); }
.splash-logo { font-size: 54px; font-weight: 900; letter-spacing: -2px; }
.splash p { color: var(--text-dim); }
.splash .hint { font-size: 12px; margin-top: 18px; }
.big-btn {
  margin-top: 14px; padding: 14px 34px; border-radius: 30px; border: 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 17px;
}

@media (min-width: 900px) {
  #app { grid-template-rows: auto 3px minmax(120px, 38%) 1fr; }
}

/* Keep the whole notes toolbar on screen on small phones */
@media (max-width: 440px) {
  .toolbar { gap: 3px; padding: 6px; }
  .seg button { min-width: 30px; padding: 6px 5px; }
  .toolbar .chip { min-width: 28px; padding: 6px 7px; }
}
@media (max-width: 400px) {
  .tool-label { display: none; }
}

/* ---------- Sound library ---------- */
.cat-chips { margin-bottom: 10px; }
.cat-chips .chip { padding: 8px 10px; }
.sound-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.sound {
  display: flex; align-items: center; gap: 6px; padding: 5px;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px;
}
.sound.on { border-color: var(--accent); }
.sound-play {
  width: 40px; height: 40px; flex: none; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--accent-ink); font-size: 14px;
}
.sound-play:active { transform: scale(.94); }
.sound-pick { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 4px; }
.sound-pick b, .preset-name b { display: block; }
.sound-pick small, .preset-name small { color: var(--text-dim); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preset-row { display: flex; align-items: center; gap: 6px; }
.preset-row .chip { padding: 10px 12px; }
.preset-name {
  flex: 1; min-width: 0; text-align: left; padding: 6px 10px;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--radius);
}

.live-bar {
  position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.live-bar .chip { padding: 9px 12px; flex: none; }
.live-bar .muted-text { line-height: 1.25; }

.bars-stepper { display: flex; align-items: center; gap: 8px; }
.bars-stepper .chip { min-width: 48px; padding: 10px; font-size: 18px; }
.bars-input { width: 96px; flex: none; text-align: center; font-size: 20px; font-weight: 700; }

/* ---------- Knob-only sliders ---------- */
.sl { display: flex; align-items: center; height: 40px; padding: 0 13px; }
.sl-track { position: relative; width: 100%; height: 6px; border-radius: 3px; background: #444; }
.sl-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--accent); }
.sl-knob {
  position: absolute; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px;
  border-radius: 50%; background: #eee; border: 2px solid #222; box-shadow: 0 1px 4px rgba(0,0,0,.5);
  touch-action: pan-y; cursor: grab; transition: transform .08s;
}
.sl-knob::before { content: ""; position: absolute; inset: -10px; border-radius: 50%; } /* bigger touch target */
.sl-knob.active { transform: scale(1.2); background: var(--accent); cursor: grabbing; }
.sl-knob:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.sound-search { margin-bottom: 10px; }

/* ---------- Note editor ---------- */
.edit-bar { display: flex; align-items: center; gap: 6px; padding: 0 12px 8px; flex-wrap: wrap; }
.sample-view.editing { height: 280px; }
#edit-selection { min-height: 64px; }
.sel-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.keys.tall { height: 220px; }
.keys.tall .pads { grid-auto-rows: 1fr; }

/* ---------- Keys header / scale keys ---------- */
.keys.withbar { flex-direction: column; height: 158px; }
.keys-bar { display: flex; gap: 4px; padding: 4px 6px; border-bottom: 1px solid #111; flex: none; overflow-x: auto; }
.keys-bar .chip { padding: 5px 9px; }
.keys-row { display: flex; flex: 1; min-height: 0; }
.piano .sk {
  flex: 1; background: #e9e9e9; border-right: 1px solid #999; border-radius: 0 0 4px 4px; color: #555;
  font-size: 11px; font-weight: 700; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 6px;
}
.piano .sk.root { background: #ffe2b8; }
.piano .sk.down { background: var(--accent); }

/* ---------- Mixer ---------- */
.mx-row { border: 1px solid var(--line-2); border-left: 5px solid var(--c, #888); border-radius: 10px; padding: 6px 10px; margin-bottom: 8px; background: var(--panel-2); }
.mx-row.master { border-left-color: var(--accent); }
.mx-head { display: flex; align-items: center; gap: 6px; }
.mx-name { flex: 1; min-width: 0; }
.mx-name b, .mx-name small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mx-name small { color: var(--text-dim); }
.mx-meter { width: 6px; height: 34px; border-radius: 2px; }
.mx-row .row { min-height: 30px; }
.mx-row .sl { height: 34px; }

/* ---------- Tap tempo / tools / update ---------- */
.tap-bpm { font-size: 56px; font-weight: 900; text-align: center; color: var(--accent); font-variant-numeric: tabular-nums; }
.tap-pad {
  display: block; width: 100%; height: 150px; border-radius: 16px; border: 2px solid var(--line-2);
  background: var(--panel-2); font-size: 28px; font-weight: 900; letter-spacing: .1em; touch-action: manipulation;
}
.tap-pad.hit { background: var(--accent); color: var(--accent-ink); }
.section.tools .row > label { width: 72px; }
.update-banner {
  position: fixed; left: 50%; bottom: calc(78px + var(--safe-bottom)); transform: translateX(-50%); z-index: 60;
  display: flex; align-items: stretch; width: max-content; max-width: 94vw; border-radius: 22px; overflow: hidden;
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 20px rgba(0,0,0,.45);
}
.update-banner button { border: 0; background: none; color: inherit; font-weight: 800; }
.update-banner .update-go { padding: 10px 14px 10px 16px; text-align: left; }
.update-banner .update-x { padding: 0 14px; border-left: 1px solid rgba(0,0,0,.18); font-size: 15px; }
.version-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.version-row .muted-text { flex: 1 1 100%; }

/* ---------- Menu / quick record / folding sections ---------- */
.sheet .menu-sec { padding: 10px 0; }
.sheet .menu-sec:last-child { border-bottom: 0; }
.stepper { align-items: center; }
.stepper .chip { min-width: 40px; padding: 8px 10px; font-size: 15px; }
.num-input { width: 70px; flex: none; text-align: center; font-weight: 700; font-size: 16px; -moz-appearance: textfield; appearance: textfield; }
.num-input::-webkit-inner-spin-button, .num-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.btn-row.center { justify-content: center; }
.sheet .sample-view.sketch-view { margin: 0; height: 190px; }
.sheet .now-note { padding: 4px 0 8px; }
.sheet-sub { margin: 14px 0 8px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); }

.section.fold { padding: 0 12px; }
.fold-head {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px;
  background: none; border: 0; padding: 0; text-align: left;
}
.fold-title { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); font-weight: 700; flex: none; }
.fold-sum { flex: 1; min-width: 0; font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fold-arrow { color: var(--text-dim); flex: none; width: 16px; text-align: center; }
.fold-dot { width: 7px; height: 7px; border-radius: 50%; background: #444; flex: none; }
.fold-dot.on { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.fold-body { padding-bottom: 10px; }
.preset-name.wide { width: 100%; }
.narrow-label { display: none; }
@media (max-width: 380px) {
  .wide-label { display: none; }
  .narrow-label { display: inline; }
}
@media (max-width: 380px) {
  .toolbar .seg button { min-width: 27px; padding: 6px 4px; }
  .toolbar .chip { min-width: 26px; padding: 6px 6px; }
}

/* ---------- Note editor (full screen) ---------- */
.ne {
  position: fixed; inset: 0; z-index: 35; background: var(--bg-2);
  display: flex; flex-direction: column;
  padding: var(--safe-top) 0 var(--safe-bottom);
}
.ne-top { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.ne-top .sheet-close { margin-top: 0; box-shadow: none; }
.ne-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 16px; }
.ne-badge { font-size: 10px; font-weight: 700; color: var(--accent); border: 1px solid var(--accent); border-radius: 10px; padding: 2px 7px; white-space: nowrap; }
.ne-progress { display: flex; align-items: center; gap: 10px; padding: 10px 12px; font-size: 12px; font-weight: 600; }
.ne-progress-track { flex: 1; height: 6px; background: #111; border-radius: 3px; overflow: hidden; }
.ne-progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .1s; }
.ne-stage { position: relative; flex: 1; min-height: 160px; }
.ne-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
.ne-bar { display: flex; gap: 5px; padding: 8px 10px 4px; flex-wrap: wrap; border-top: 1px solid var(--line); }
.ne-bar .chip { padding: 8px 10px; }
.ne-info { padding: 4px 12px; min-height: 34px; color: var(--text); }
.ne-stats { padding: 0 12px 8px; font-size: 11px; }
.chip.ne-open { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; margin-top: 8px; padding: 9px 12px; text-align: left; }
.chip.ne-open small { font-weight: 500; color: var(--text-dim); }

/* ---------- Control info ("what does this do?") ---------- */
.row > .info-label {
  width: 76px; flex: none; display: flex; align-items: center; gap: 4px; padding: 6px 0; min-height: 34px;
  background: none; border: 0; color: var(--text-dim); font-size: 13px; text-align: left;
}
.info-label .info-i {
  width: 14px; height: 14px; border-radius: 50%; border: 1px solid #666; flex: none;
  font: italic 700 9px/12px Georgia, serif; text-align: center; color: #999;
}
.info-label:active, .info-label:hover { color: var(--text); }
.info-label:active .info-i { border-color: var(--accent); color: var(--accent); }
.info-text { font-size: 14px; color: var(--text); margin: 0 0 12px; line-height: 1.45; }
.sound-pick small.wrap { white-space: normal; }
.sheet .sound > .sound-pick:only-of-type { cursor: default; }
.big-btn.rec { background: var(--rec); color: #fff; box-shadow: 0 8px 24px rgba(255,75,62,.3); }

/* Start-up problem report (see the watchdog in index.html) */
.boot-error {
  position: fixed; left: 12px; right: 12px; bottom: calc(16px + var(--safe-bottom)); z-index: 70; max-width: 520px; margin: 0 auto;
  background: #2b2b2b; border: 1px solid var(--rec); border-radius: 12px; padding: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.6);
}
.boot-error b { color: #fff; font-size: 16px; }
.boot-error p { color: var(--text-dim); margin: 6px 0 8px; font-size: 13px; }
.boot-error pre { white-space: pre-wrap; word-break: break-word; font-size: 11px; color: #ff8a80; background: #1b1b1b; border-radius: 6px; padding: 8px; max-height: 140px; overflow: auto; margin: 0 0 10px; -webkit-user-select: text; user-select: text; }
.boot-error button { width: 100%; padding: 12px; border: 0; border-radius: 22px; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 15px; }
.install-link {
  display: block; margin: 16px auto 0; padding: 10px 16px; border-radius: 22px;
  border: 1px solid var(--line-2); background: rgba(255,255,255,.04); color: var(--text); font-weight: 700; font-size: 14px;
}
.install-link:active { background: var(--panel); }
/* The update banner steps aside while a menu is open (it would cover the menu's buttons). */
#sheet:not([hidden]) ~ .update-banner { display: none; }

/* Quick record: Record again (glowing red) and Delete */
.sketch-actions { margin-top: 10px; }
.sketch-actions .chip { flex: 1; padding: 12px 10px; font-size: 14px; }
.chip.rec-again {
  background: #2a1614; color: #fff; border: 1px solid var(--rec);
  box-shadow: 0 0 0 1px var(--rec), 0 0 14px rgba(255,75,62,.55);
  animation: rec-glow 2.2s ease-in-out infinite;
}
.chip.rec-again:active { background: var(--rec); }
@keyframes rec-glow { 50% { box-shadow: 0 0 0 1px var(--rec), 0 0 24px rgba(255,75,62,.85); } }
.chip.del-take { flex: 0 0 auto; min-width: 104px; }
