/* Black Box Hub: visual inspirado no próprio pedal.
   Carcaça grafite, teclas de silicone lilás, tela preta com as cores dos módulos e footswitches cromados. */

:root {
  --bg: #1c1e23;
  --case: #23262c;
  --case-2: #2a2d34;
  --case-3: #33373f;
  --edge: #3d424d;
  --silk: #eceef4;
  --silk-dim: #a9afbd;
  --silk-faint: #737a89;
  --key: #c5cae0;
  --key-hi: #d8dcee;
  --key-low: #8e93a9;
  --key-ink: #22252d;
  --screen: #06080c;
  --screen-ink: #f2f5ff;
  --screen-dim: #8f9bb3;
  --fx: #ef6b73;
  --amp: #7ed6a2;
  --mod: #45c4dc;
  --dly: #5b95f5;
  --rev: #b4e38e;
  --cab: #93d9cf;
  --live: #7ed6a2;
  --warn: #f2b35b;
  --danger: #ef6b73;
  --font-display: 'Michroma', 'Segoe UI', system-ui, sans-serif;
  --font-ui: system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --rail-h: 60px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
/* No celular: sem aumento automático de fonte e sem "puxar para atualizar" (recarregar no meio de uma música para a bateria). */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overscroll-behavior-y: none; }
body {
  background: var(--bg);
  color: var(--silk);
  font: 15px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--key); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--silk-dim); }
.small { font-size: 13px; }
.icon { display: inline-flex; width: 20px; height: 20px; flex: none; }
.icon svg { width: 100%; height: 100%; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--key); color: var(--key-ink); padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }

/* ---------- Casca ---------- */

.shell {
  display: grid;
  grid-template-columns: 208px minmax(0, 1fr);
  grid-template-rows: var(--rail-h) minmax(0, 1fr);
  min-height: 100vh;
}
.rail {
  grid-column: 1 / -1;
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  background: var(--case);
  border-bottom: 1px solid var(--edge);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--silk); text-decoration: none; margin-right: 6px; }
.brand-mark {
  width: 26px; height: 22px; border-radius: 6px; background: var(--case-3); border: 1px solid var(--edge); position: relative;
}
.brand-mark::before, .brand-mark::after {
  content: ''; position: absolute; bottom: 4px; width: 6px; height: 6px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #a9adb7);
}
.brand-mark::before { left: 4px; }
.brand-mark::after { right: 4px; }
.brand-name { font-family: var(--font-display); font-size: 12px; letter-spacing: .08em; white-space: nowrap; }

.conn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--edge); background: var(--case-2); cursor: pointer; font-size: 13px; white-space: nowrap;
}
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--silk-faint); }
.conn.ok .conn-dot { background: var(--live); box-shadow: 0 0 8px var(--live); }
.conn.bad .conn-dot { background: var(--danger); }
.conn.idle { border-color: var(--key-low); }
.conn-short { display: none; }

.rail-preset {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  background: var(--screen); border: 1px solid #000; border-radius: 8px; padding: 4px 12px 4px 10px; cursor: pointer;
  box-shadow: inset 3px 0 0 var(--pc, transparent);
}
.rail-p { font-family: var(--font-display); font-size: 15px; color: var(--screen-ink); }
.rail-pname { color: var(--screen-dim); font-size: 13px; max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.transport { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.rail-led { width: 8px; height: 8px; border-radius: 50%; background: #2d3a33; flex: none; }
.rail-led.blink { animation: led 160ms ease-out; }
@keyframes led { from { background: var(--live); box-shadow: 0 0 10px var(--live); } to { background: #2d3a33; box-shadow: none; } }
.rail-bpm { display: flex; align-items: center; gap: 2px; }
.bpm-val { display: inline-flex; align-items: baseline; gap: 4px; min-width: 5.5ch; justify-content: center; }
.bpm-val b { font-family: var(--font-display); font-size: 15px; font-weight: 400; }
.bpm-val small { color: var(--silk-faint); font-size: 11px; }
.now-label { color: var(--silk-dim); font-size: 13px; max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav {
  position: sticky; top: var(--rail-h); align-self: start;
  height: calc(100vh - var(--rail-h));
  display: flex; flex-direction: column; gap: 2px;
  padding: 18px 12px;
  background: var(--case);
  border-right: 1px solid var(--edge);
}
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--silk-dim); text-decoration: none; position: relative;
}
.nav a:hover { color: var(--silk); background: var(--case-2); }
.nav a[aria-current='page'] { color: var(--silk); background: var(--case-3); }
.nav a[aria-current='page']::before {
  content: ''; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--key);
}

.main { padding: 28px clamp(16px, 3vw, 40px) 72px; min-width: 0; outline: none; }
.view { display: grid; gap: 22px; max-width: 1180px; grid-template-columns: minmax(0, 1fr); }

.view-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.view-head h1 { font-family: var(--font-display); font-size: 22px; font-weight: 400; letter-spacing: .02em; }
.lede { color: var(--silk-dim); max-width: 70ch; margin-top: 6px; }
.note {
  border-left: 3px solid var(--key-low); background: var(--case-2); padding: 10px 14px; border-radius: 0 10px 10px 0; color: var(--silk-dim); max-width: 80ch;
  display: grid; gap: 8px; justify-items: start;
}

/* ---------- Blocos e campos ---------- */

.block { background: var(--case-2); border: 1px solid var(--edge); border-radius: 16px; padding: 18px 20px; display: grid; gap: 14px; min-width: 0; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.block-head h2 { font-size: 16px; font-weight: 600; }

.input {
  background: var(--case); border: 1px solid var(--edge); border-radius: 9px; padding: 7px 10px; min-height: 38px; min-width: 0;
}
.input:focus { border-color: var(--key-low); }
select.input { padding-right: 28px; }
textarea.input { resize: vertical; }
.title-input { font-size: 20px; font-weight: 600; background: transparent; border-color: transparent; padding-left: 4px; }
.title-input:hover, .title-input:focus { border-color: var(--edge); background: var(--case); }

.field { display: grid; gap: 6px; }
.field-label { color: var(--silk-dim); font-size: 13px; }
.field-hint { color: var(--silk-faint); font-size: 12px; }
.form { display: grid; gap: 14px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > .field { flex: 1 1 140px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--silk-dim); white-space: nowrap; min-width: 0; }
.check input { width: 18px; height: 18px; accent-color: var(--key); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 7px 14px; border-radius: 10px;
  border: 1px solid var(--edge); background: var(--case-3); color: var(--silk); cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--silk-faint); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn .icon { width: 18px; height: 18px; }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn.big { min-height: 46px; padding: 10px 20px; font-weight: 600; }
.btn.ghost { background: transparent; }
/* Botões principais imitam as teclas lilás do pedal */
.btn.primary {
  background: var(--key); color: var(--key-ink); border-color: transparent; font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), 0 2px 0 var(--key-low);
}
.btn.primary:hover { background: var(--key-hi); }
.btn.primary:active { transform: translateY(1px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), 0 1px 0 var(--key-low); }
.btn.good { background: color-mix(in oklab, var(--amp) 20%, var(--case-3)); border-color: color-mix(in oklab, var(--amp) 60%, var(--edge)); }
.btn.danger { background: var(--danger); color: #2b0d10; border-color: transparent; font-weight: 600; }
.btn.danger-ghost { background: transparent; color: #f3a1a7; border-color: color-mix(in oklab, var(--danger) 45%, var(--edge)); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center; flex: none;
  border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--silk-dim); cursor: pointer; font-size: 18px;
}
.icon-btn:hover:not(:disabled) { background: var(--case-3); color: var(--silk); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.icon-btn .icon { width: 18px; height: 18px; }
.icon-btn.star.on { color: var(--warn); }
.icon-btn.star.on svg { fill: currentColor; }

.stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--edge); border-radius: 10px; background: var(--case); overflow: hidden; }
.stepper-btn { width: 34px; border: 0; background: transparent; color: var(--silk-dim); cursor: pointer; font-size: 18px; }
.stepper-btn:hover { background: var(--case-3); color: var(--silk); }
.stepper-input {
  width: 5ch; text-align: center; border: 0; background: transparent; min-height: 38px;
  font-family: var(--font-display); font-size: 14px; -moz-appearance: textfield;
}
.stepper-input::-webkit-outer-spin-button, .stepper-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper.sm .stepper-input { min-height: 34px; width: 4ch; font-size: 13px; }
.stepper.sm .stepper-btn { width: 28px; }

input[type='range'] { accent-color: var(--key); width: 100%; min-width: 120px; }
.range-out { font-family: var(--font-display); font-size: 13px; color: var(--silk); }
.range-out.big { font-size: 22px; min-width: 3ch; text-align: right; }

.play-key {
  display: inline-grid; place-items: center; flex: none; cursor: pointer;
  border-radius: 14px; border: 0;
  background: var(--key); color: var(--key-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 3px 0 var(--key-low);
}
.play-key.lg { width: 58px; height: 52px; }
.play-key.lg .icon { width: 26px; height: 26px; }
.play-key.sm { width: 40px; height: 34px; border-radius: 10px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 2px 0 var(--key-low); }
.play-key:hover { background: var(--key-hi); }
.play-key:active { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 1px 0 var(--key-low); }
.play-key.is-playing { background: var(--live); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 3px 0 #3f8f63, 0 0 18px -4px var(--live); }

.segmented { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--case); border: 1px solid var(--edge); }
.segmented button { border: 0; background: transparent; color: var(--silk-dim); padding: 5px 14px; border-radius: 7px; cursor: pointer; }
.segmented button.on { background: var(--case-3); color: var(--silk); }

.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--edge); color: var(--silk-dim); }
.tag.found { color: var(--amp); border-color: currentColor; }

/* ---------- Palco: o pedal na tela ---------- */

.pedal {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center;
  gap: clamp(18px, 4vw, 52px);
  padding: clamp(22px, 4vw, 44px);
  border-radius: 24px; border: 1px solid var(--edge);
  background:
    radial-gradient(circle at 16px 16px, #7a7f8b 0 2.5px, #3a3e47 3px 4.5px, transparent 5px),
    radial-gradient(circle at calc(100% - 16px) 16px, #7a7f8b 0 2.5px, #3a3e47 3px 4.5px, transparent 5px),
    radial-gradient(circle at 16px calc(100% - 16px), #7a7f8b 0 2.5px, #3a3e47 3px 4.5px, transparent 5px),
    radial-gradient(circle at calc(100% - 16px) calc(100% - 16px), #7a7f8b 0 2.5px, #3a3e47 3px 4.5px, transparent 5px),
    linear-gradient(180deg, #2e3138 0%, #24272d 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 24px 48px -28px rgba(0, 0, 0, .7);
}
.fs-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.footswitch {
  width: clamp(76px, 9vw, 108px); aspect-ratio: 1; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  display: grid; place-items: center;
  background: radial-gradient(circle, #6f747e 0 50%, #c9ccd3 51% 58%, #8a8f99 59% 68%, #3f434b 69% 100%);
  box-shadow: 0 7px 0 #15171b, 0 12px 22px rgba(0, 0, 0, .5);
  transition: transform 60ms, box-shadow 60ms;
}
.footswitch-cap {
  width: 52%; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #fff, #dfe2e8 38%, #9ea2ac 74%, #6c707a);
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, .35), 0 1px 2px rgba(0, 0, 0, .4);
}
.footswitch:hover .footswitch-cap { background: radial-gradient(circle at 36% 30%, #fff, #eceef2 38%, #aeb2bb 74%, #767a84); }
.footswitch:active { transform: translateY(5px); box-shadow: 0 2px 0 #15171b, 0 4px 10px rgba(0, 0, 0, .5); }
.fs-caption { display: inline-flex; align-items: center; gap: 7px; color: var(--silk-dim); font-size: 13px; }
.fs-caption::before { content: ''; border-left: 5px solid transparent; border-right: 5px solid transparent; }
.fs-caption.down::before { border-top: 7px solid var(--silk-dim); }
.fs-caption.up::before { border-bottom: 7px solid var(--silk-dim); }

.screen {
  background: var(--screen); color: var(--screen-ink);
  border-radius: 16px; border: 2px solid #000;
  box-shadow: inset 0 0 0 1px #1b1f27, inset 0 0 60px rgba(91, 149, 245, .07);
  padding: 16px clamp(16px, 2.5vw, 26px) 20px;
  display: grid; gap: 12px; min-height: 230px; align-content: start;
}
.screen.boot { animation: boot 520ms steps(6, end) both; }
@keyframes boot { from { opacity: .15; filter: brightness(2); } to { opacity: 1; filter: none; } }
.screen-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.screen-modules { display: flex; gap: 6px; flex-wrap: wrap; }
.mod-chip {
  font-family: var(--font-display); font-size: 10px; letter-spacing: .04em;
  padding: 4px 7px; border-radius: 5px; cursor: pointer;
  border: 1px solid color-mix(in oklab, var(--mc) 55%, transparent);
  background: transparent; color: color-mix(in oklab, var(--mc) 70%, #000);
}
.mod-chip.on { background: var(--mc); color: #06080c; border-color: var(--mc); }
.mod-chip.off { color: color-mix(in oklab, var(--mc) 45%, #222); border-style: dashed; }
.mod-chip.unknown { color: var(--mc); }
.mod-chip:disabled { opacity: .3; cursor: default; }
.screen-conn { display: inline-flex; align-items: center; gap: 4px; color: var(--screen-dim); font-size: 12px; white-space: nowrap; }
.screen-conn .icon { width: 15px; height: 15px; }
.screen-conn.ok { color: var(--live); }
.screen-main { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.preset-box {
  display: inline-flex; align-items: baseline; gap: 6px;
  border: 3px solid var(--pc, var(--screen-ink)); border-radius: 20px;
  padding: 8px 20px 6px; font-family: var(--font-display); line-height: 1;
}
.preset-p { font-size: clamp(34px, 5vw, 58px); }
.preset-num { font-size: clamp(52px, 8.5vw, 98px); letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.bpm-ring { position: relative; width: clamp(78px, 8vw, 96px); aspect-ratio: 1; flex: none; }
.bpm-ring svg { width: 100%; height: 100%; }
.ring-track { fill: none; stroke: #232833; stroke-width: 6; }
.ring-arc { fill: none; stroke: var(--screen-ink); stroke-width: 6; stroke-linecap: round; transition: stroke-dashoffset 200ms ease-out; }
.ring-text { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.05; }
.ring-value { font-family: var(--font-display); font-size: clamp(16px, 1.8vw, 20px); }
.ring-unit { font-size: 11px; color: var(--screen-dim); }
.screen-name { font-size: clamp(18px, 2.2vw, 24px); font-weight: 600; }
.screen-notes { color: var(--screen-dim); max-width: 62ch; white-space: pre-line; }

.stage-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 22px; }
.strip-row, .drum-transport { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.strip-field { display: grid; gap: 6px; min-width: 0; }
.strip-field.grow { flex: 1 1 180px; }
.range-field { flex: 1 1 160px; }
.beat-leds { display: inline-flex; gap: 8px; align-items: center; }
.led { width: 12px; height: 12px; border-radius: 50%; background: #2d3237; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .6); }
.led.on { background: var(--live); box-shadow: 0 0 10px var(--live); }
.led.on.accent { background: #e8fff1; box-shadow: 0 0 12px var(--live); }

.fav-row { display: flex; flex-wrap: wrap; gap: 8px; }
.fav {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px 8px 10px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--edge); background: var(--case); box-shadow: inset 3px 0 0 var(--pc, var(--edge));
}
.fav.on { border-color: var(--key); }
.fav-num { font-family: var(--font-display); font-size: 13px; }
.fav-name { color: var(--silk-dim); max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stage-songs { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.stage-song {
  width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--edge); background: var(--case); cursor: pointer; text-align: left;
}
.stage-song:hover { border-color: var(--silk-faint); }
.stage-song .icon { color: var(--key); }
.stage-song-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-song-first { color: var(--silk-faint); font-size: 13px; }
.song-status { font-family: var(--font-display); font-size: 14px; color: var(--silk); }

/* ---------- Linha do tempo das músicas ---------- */

.timeline { position: relative; display: flex; gap: 3px; height: 58px; }
.tl-seg {
  min-width: 0; border-radius: 8px; padding: 7px 10px; display: grid; align-content: center;
  background: color-mix(in oklab, var(--pc, var(--case-3)) 28%, var(--case));
  border: 1px solid color-mix(in oklab, var(--pc, var(--edge)) 50%, var(--edge));
  transition: background 150ms;
}
.tl-seg.now { background: color-mix(in oklab, var(--pc, var(--key)) 55%, var(--case)); border-color: var(--pc, var(--key)); }
.tl-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-meta { font-size: 11px; color: var(--silk-dim); font-family: var(--font-display); }
.tl-cursor { position: absolute; top: -4px; bottom: -4px; left: 0; width: 2px; background: var(--silk); box-shadow: 0 0 8px var(--silk); transition: left 120ms linear; }

/* ---------- Presets ---------- */

.toolbar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.search { flex: 1 1 260px; max-width: 420px; }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.tile {
  position: relative; display: flex; flex-direction: column; min-width: 0;
  background: var(--case-2); border: 1px solid var(--edge); border-radius: 12px; overflow: hidden;
  box-shadow: inset 4px 0 0 var(--pc, transparent);
}
.tile.is-current { border-color: var(--key); background: color-mix(in oklab, var(--key) 9%, var(--case-2)); }
.tile.is-current .tile-num::after { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--live); margin-left: 8px; vertical-align: middle; box-shadow: 0 0 8px var(--live); }
.tile-main { border: 0; background: transparent; text-align: left; cursor: pointer; padding: 12px 12px 4px 16px; display: grid; gap: 2px; align-content: start; min-height: 86px; min-width: 0; }
.tile-main:focus-visible { outline: 2px solid var(--key); outline-offset: -2px; border-radius: 10px; }
.tile-num { font-family: var(--font-display); font-size: 22px; line-height: 1.2; }
.tile-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-name.dim { color: var(--silk-faint); font-weight: 400; }
.tile-notes { font-size: 12px; color: var(--silk-dim); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile-tools { display: flex; justify-content: flex-end; padding: 0 6px 6px; margin-top: auto; }
.tile { scroll-margin-top: calc(var(--rail-h) + env(safe-area-inset-top, 0px) + 112px); }
.tool-more { display: none; }

/* Busca e atalhos por faixa ficam presos no topo enquanto a lista rola. */
.presets .toolbar {
  position: sticky; top: calc(var(--rail-h) + env(safe-area-inset-top, 0px)); z-index: 5;
  background: color-mix(in oklab, var(--bg) 94%, transparent); backdrop-filter: blur(6px);
  margin: -10px calc(-1 * clamp(16px, 3vw, 40px)); padding: 10px clamp(16px, 3vw, 40px);
}
.bank-jump { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1 1 100%; padding-bottom: 2px; }
.bank-jump::-webkit-scrollbar { display: none; }
.bank {
  flex: none; min-width: 46px; padding: 6px 10px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--edge); background: var(--case-2); color: var(--silk-dim);
  font-family: var(--font-display); font-size: 12px;
}
.bank:hover { color: var(--silk); border-color: var(--silk-faint); }
.bank.has-current { border-color: var(--key); color: var(--silk); }

/* Menu de ações de um preset (celular) */
.action-list { display: grid; gap: 8px; }
.action-item {
  display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 2px 12px; align-items: center; text-align: left;
  padding: 12px 14px; min-height: 56px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--edge); background: var(--case); color: var(--silk);
}
.action-item:hover { border-color: var(--silk-faint); }
.action-item .icon { grid-row: 1 / span 2; color: var(--key); }
.action-item strong { font-weight: 600; }
.action-item span:not(.icon) { grid-column: 2; font-size: 13px; color: var(--silk-dim); }
.action-item.primary { border-color: var(--key-low); background: color-mix(in oklab, var(--key) 10%, var(--case)); }

.pack-title { display: grid; gap: 4px; max-width: 70ch; }

.progress { position: relative; height: 30px; border-radius: 8px; background: var(--case); border: 1px solid var(--edge); overflow: hidden; }
.progress-bar { position: absolute; inset: 0 auto 0 0; background: color-mix(in oklab, var(--live) 45%, var(--case)); transition: width 150ms linear; }
.progress-text { position: relative; display: block; padding: 0 12px; line-height: 28px; font-size: 13px; }
.note.error { border-left-color: var(--danger); }
.hex-details { width: 100%; }
.hex { font: 12px/1.5 ui-monospace, Consolas, monospace; background: var(--screen); color: var(--screen-dim); padding: 10px 12px; border-radius: 8px; overflow-x: auto; margin: 8px 0; white-space: pre; max-height: 260px; }

.tile-chain { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; }
.mini {
  font-family: var(--font-display); font-size: 8px; letter-spacing: .02em; padding: 2px 4px; border-radius: 3px;
  color: var(--silk-faint); box-shadow: inset 0 0 0 1px var(--edge);
}
.mini.on { background: var(--mc); color: #06080c; box-shadow: none; }

.detail { display: grid; gap: 14px; }
.detail-blocks { display: grid; gap: 8px; }
.detail-row { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 12px; align-items: start; padding: 10px 12px; background: var(--case); border: 1px solid var(--edge); border-radius: 10px; }
.detail-row .chip { justify-self: start; margin-top: 2px; }
.detail-row.off { opacity: .6; }
.detail-main { display: grid; gap: 6px; }
.knobs { display: flex; flex-wrap: wrap; gap: 6px; }
.knob { display: inline-flex; gap: 6px; align-items: baseline; padding: 3px 8px; border-radius: 6px; background: var(--case-2); font-size: 12px; color: var(--silk-dim); }
.knob b { font-family: var(--font-display); font-weight: 400; color: var(--silk); font-size: 12px; }
.note.warn { border-left-color: var(--warn); }

/* Editor de presets */
.dialog.wide:has(.editor) { width: min(880px, calc(100vw - 32px)); }
.editor { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.editor .ed-block, .editor .ed-knobs, .detail, .detail-blocks, .action-list { grid-template-columns: minmax(0, 1fr); }
.editor .note { max-width: none; }
.ed-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 14px; align-items: center; }
.ed-label { font-size: 13px; color: var(--silk-dim); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ed-chain { display: flex; flex-wrap: wrap; gap: 6px; grid-column: 2 / -1; }
.ed-chain-item { display: inline-flex; align-items: center; gap: 2px; padding: 2px; background: var(--case); border: 1px solid var(--edge); border-radius: 9px; }
.ed-chain-item .chip { font-size: 11px; padding: 3px 7px; }
.icon-btn.sm { width: 26px; height: 28px; font-size: 18px; line-height: 1; }
.ed-blocks { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); }
.ed-block {
  display: grid; gap: 10px; padding: 12px 14px; background: var(--case); border: 1px solid var(--edge); border-radius: 12px;
  box-shadow: inset 3px 0 0 var(--mc);
}
.ed-block.is-off { box-shadow: inset 3px 0 0 var(--edge); }
.ed-block.is-off .ed-knobs { opacity: .5; }
.ed-block-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ed-block-head select { flex: 0 1 200px; }
.ed-block.is-off .ed-block-head .chip { background: transparent; color: var(--silk-faint); box-shadow: inset 0 0 0 1px var(--edge); }
.ed-knobs { display: grid; gap: 4px; }
.ed-knob { display: grid; grid-template-columns: 82px minmax(0, 1fr) 3ch; gap: 10px; align-items: center; }
.ed-knob-name { font-size: 12px; color: var(--silk-dim); }
.ed-knob input[type='range'] { min-width: 0; accent-color: var(--mc); }
.ed-knob .range-out { text-align: right; font-size: 12px; }
.ed-save { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 4px; border-top: 1px solid var(--edge); }
.ed-save select { min-width: 220px; }
.ed-dirty { font-size: 12px; color: var(--warn); }
.ed-undo { display: grid; gap: 8px; justify-items: start; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { width: 36px; height: 20px; border-radius: 999px; background: var(--case-3); border: 1px solid var(--edge); position: relative; transition: background 150ms; flex: none; }
.switch-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--silk-dim); transition: transform 150ms, background 150ms; }
.switch input:checked + .switch-track { background: color-mix(in oklab, var(--mc, var(--live)) 55%, var(--case)); border-color: transparent; }
.switch input:checked + .switch-track::after { transform: translateX(16px); background: var(--silk); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--key); outline-offset: 2px; }

@media (max-width: 760px) {
  .ed-row { grid-template-columns: 1fr auto; }
  .ed-row > .ed-label { grid-column: 1 / -1; }
  .ed-chain { grid-column: 1 / -1; }
  .ed-blocks { grid-template-columns: 1fr; }
  .ed-knob { grid-template-columns: 72px minmax(0, 1fr) 3ch; }
}

details > summary { cursor: pointer; font-weight: 600; padding: 4px 0; color: var(--silk); }
details > summary::marker { color: var(--key); }
.pack-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr)); }
.pack-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: start;
  padding: 12px 14px; background: var(--case); border: 1px solid var(--edge); border-radius: 12px;
  box-shadow: inset 4px 0 0 var(--pc, var(--edge));
}
.pack-num { font-family: var(--font-display); font-size: 17px; border: 0; background: transparent; color: var(--silk); cursor: pointer; padding: 2px 0; }
.pack-num:hover { color: var(--key-hi); }
.pack-body h3 { font-size: 15px; font-weight: 600; }
.pack-body > p { color: var(--silk-dim); font-size: 14px; margin: 2px 0 8px; }
.recipe { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; font-size: 13px; color: var(--silk-dim); }
.recipe li { display: flex; gap: 8px; align-items: baseline; }
.chip {
  font-family: var(--font-display); font-size: 10px; letter-spacing: .03em; padding: 2px 6px; border-radius: 4px; flex: none;
  background: var(--mc, var(--silk-dim)); color: #06080c;
}
.chip.off { background: transparent; color: var(--silk-faint); box-shadow: inset 0 0 0 1px var(--edge); text-decoration: line-through; }
.glossary dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 14px; margin: 12px 0 0; align-items: baseline; }
.glossary dd { margin: 0; color: var(--silk-dim); max-width: 70ch; }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; background: var(--sw); cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .3); }
.swatch.none { background: repeating-linear-gradient(45deg, var(--case-3) 0 4px, var(--case) 4px 8px); }
.swatch.on { border-color: var(--silk); }

/* ---------- Bateria ---------- */

.view.drums { grid-template-columns: 240px minmax(0, 1fr); align-items: start; max-width: 1280px; }
.library {
  position: sticky; top: calc(var(--rail-h) + 20px); max-height: calc(100vh - var(--rail-h) - 40px); overflow: auto;
  background: var(--case-2); border: 1px solid var(--edge); border-radius: 16px; padding: 14px 10px; display: grid; gap: 14px; align-content: start;
}
.library-head { display: flex; justify-content: space-between; align-items: center; padding: 0 6px; }
.library-head h2 { font-size: 16px; }
.lib-group { display: grid; gap: 2px; }
.lib-style { font-size: 12px; font-weight: 600; color: var(--silk-faint); padding: 0 8px 4px; }
.lib-item {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px; min-width: 0;
  border: 0; background: transparent; padding: 7px 8px; border-radius: 8px; cursor: pointer; text-align: left; color: var(--silk-dim);
}
.lib-compact { display: none; gap: 8px; }
.lib-compact select { flex: 1 1 220px; max-width: 360px; }
.lib-item:hover { background: var(--case-3); color: var(--silk); }
.lib-item.on { background: var(--key); color: var(--key-ink); }
.lib-item.on .lib-meta { color: #4a4f60; }
.lib-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-meta { font-size: 11px; color: var(--silk-faint); white-space: nowrap; }
.drums-main { display: grid; gap: 18px; min-width: 0; }
.pattern-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.pattern-title { font-family: var(--font-display); font-size: 22px; font-weight: 400; }
.pattern-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.drum-transport .beat-leds { margin-left: auto; padding-bottom: 12px; }

.legend { display: flex; gap: 12px; font-size: 12px; color: var(--silk-dim); }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.lg::before { content: ''; width: 12px; height: 12px; border-radius: 3px; }
.lg.on::before { background: var(--key); }
.lg.acc::before { background: #fff; box-shadow: inset 0 0 0 2px var(--key-low); }
.lg.ghost::before { background: color-mix(in oklab, var(--key) 32%, var(--case)); }

.seq-wrap { overflow-x: auto; padding: 2px 2px 8px; }
.seq { display: grid; gap: 4px; width: max-content; }
.seq-row { display: grid; grid-template-columns: 136px repeat(var(--steps), 26px); gap: 3px; align-items: center; }
.seq-label {
  border: 0; background: var(--case-2); text-align: left; color: var(--silk-dim); font-size: 13px; padding: 4px 8px; border-radius: 6px; cursor: pointer; white-space: nowrap;
  position: sticky; left: 0; z-index: 1; overflow: hidden; text-overflow: ellipsis; /* nome fica visível ao rolar a grade */
}
.seq-label:hover { color: var(--silk); background: var(--case-3); }
.cell { width: 26px; height: 30px; padding: 0; border-radius: 5px; border: 1px solid #3a3f4a; background: #23262d; cursor: pointer; }
.cell.alt { background: #292c34; }
.cell.beat { border-left-color: #59606e; }
.cell.bar { box-shadow: -3px 0 0 -1px var(--silk-faint); }
.cell.v-on { background: var(--key); border-color: transparent; }
.cell.v-acc { background: #fff; border-color: transparent; box-shadow: inset 0 0 0 2px var(--key-low); }
.cell.v-ghost { background: color-mix(in oklab, var(--key) 32%, #23262d); border-color: transparent; }
.cell.now { outline: 2px solid var(--live); outline-offset: 1px; }
.cell:disabled { cursor: default; }
.cell:not(:disabled):hover { border-color: var(--key); }
.pattern-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Músicas ---------- */

.view.songs { grid-template-columns: 320px minmax(0, 1fr); align-items: start; max-width: 1280px; }
.setlist {
  position: sticky; top: calc(var(--rail-h) + 20px);
  background: var(--case-2); border: 1px solid var(--edge); border-radius: 16px; padding: 14px; display: grid; gap: 12px;
}
.setlist-head { display: flex; gap: 4px; align-items: center; }
.setlist-head select { flex: 1; }
.song-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.song-item { display: flex; align-items: center; border-radius: 10px; border: 1px solid transparent; }
.song-item.on { background: var(--case-3); border-color: var(--edge); }
.song-item.playing { border-color: var(--live); }
.song-pick { flex: 1; min-width: 0; display: grid; grid-template-columns: 22px minmax(0, 1fr); column-gap: 8px; text-align: left; border: 0; background: transparent; padding: 8px 8px; cursor: pointer; }
.song-idx { grid-row: span 2; font-family: var(--font-display); font-size: 12px; color: var(--silk-faint); padding-top: 3px; }
.song-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-meta { font-size: 12px; color: var(--silk-dim); }
.song-tools { display: flex; padding-right: 4px; }
.setlist-foot { display: grid; gap: 8px; }

.song-editor { display: grid; gap: 18px; min-width: 0; }
.song-head { display: flex; justify-content: space-between; gap: 14px; align-items: center; flex-wrap: wrap; }
.song-head .title-input { flex: 1 1 260px; }
.song-fields { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; padding: 16px 18px; background: var(--case-2); border: 1px solid var(--edge); border-radius: 16px; }
.big-num { font-family: var(--font-display); font-size: 18px; line-height: 38px; }
.sec-table { display: grid; gap: 6px; }
.sec-row {
  display: grid; grid-template-columns: 24px minmax(110px, 1fr) auto minmax(140px, 1fr) minmax(140px, 1fr) auto auto;
  gap: 8px; align-items: center; padding: 6px 8px; border-radius: 12px; border: 1px solid transparent;
}
.sec-row:not(.sec-header) { background: var(--case-2); border-color: var(--edge); }
.sec-row.now { border-color: var(--live); box-shadow: 0 0 0 1px var(--live); }
.sec-header { font-size: 12px; color: var(--silk-faint); padding-bottom: 0; }
.sec-idx { font-family: var(--font-display); font-size: 12px; color: var(--silk-faint); text-align: center; }
.row-tools { display: flex; }
.song-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Controles ---------- */

.ctl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.ctl-card {
  background: var(--case-2); border: 1px solid var(--edge); border-radius: 14px; padding: 14px; display: grid; gap: 10px; align-content: start;
  box-shadow: inset 0 3px 0 var(--mc);
}
.ctl-card.unverified { border-style: dashed; }
.ctl-head { display: flex; align-items: center; gap: 8px; }
.ctl-module { font-family: var(--font-display); font-size: 11px; padding: 3px 7px; border-radius: 5px; background: var(--mc); color: #06080c; }
.ctl-cc { font-size: 12px; color: var(--silk-faint); }
.ctl-tools { margin-left: auto; display: flex; }
.ctl-name { font-size: 15px; font-weight: 600; }
.ctl-body { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ctl-body.knob { flex-wrap: nowrap; }
.ctl-quick { display: flex; gap: 6px; }
.led-btn {
  display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--edge); background: var(--case); min-width: 130px;
}
.led-dot { width: 12px; height: 12px; border-radius: 50%; background: #2d3237; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .6); }
.led-btn.on { border-color: var(--mc); }
.led-btn.on .led-dot { background: var(--mc); box-shadow: 0 0 10px var(--mc); }
.ctl-verify { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--silk-dim); border-top: 1px solid var(--edge); padding-top: 10px; }

.scan-body { display: grid; grid-template-columns: minmax(150px, auto) 1fr 1fr; gap: 18px; align-items: end; }
.scan-now { display: grid; gap: 6px; }
.scan-num { font-family: var(--font-display); font-size: 34px; line-height: 1; }
.scan-send, .scan-answer { display: grid; gap: 6px; }
.cc-map { display: grid; grid-template-columns: repeat(20, 1fr); gap: 3px; }
.map-cell { aspect-ratio: 1; border-radius: 3px; border: 1px solid #3a3f4a; background: #23262d; padding: 0; cursor: pointer; min-width: 0; }
.map-cell.none { background: #3a3f4a; }
.map-cell.found { background: var(--amp); border-color: transparent; }
.map-cell.known { box-shadow: inset 0 0 0 2px var(--key); }
.map-cell.cur { outline: 2px solid var(--silk); outline-offset: 1px; }
.map-legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lg-cell { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-left: 8px; }
.lg-cell:first-child { margin-left: 0; }
.lg-cell.found { background: var(--amp); }
.lg-cell.none { background: #3a3f4a; }
.lg-cell.known { background: #23262d; box-shadow: inset 0 0 0 2px var(--key); }
.explorer { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }

/* ---------- Ajustes ---------- */

.settings-row { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.status-dot { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--silk-dim); }
.status-dot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.status-dot.connected::before { background: var(--live); box-shadow: 0 0 8px var(--live); }
.status-dot.idle::before { background: var(--silk-faint); }
.foot-list { display: grid; gap: 6px; }
.foot-row { display: grid; grid-template-columns: minmax(180px, 1.2fr) minmax(140px, 1fr) auto; gap: 12px; align-items: center; padding: 8px 12px; background: var(--case); border: 1px solid var(--edge); border-radius: 10px; }
.foot-sig { font-size: 13px; }
.facts { margin: 0; padding-left: 18px; display: grid; gap: 8px; color: var(--silk-dim); max-width: 85ch; }
.facts b { color: var(--silk); font-weight: 600; }

/* ---------- Diálogos e avisos ---------- */

.dialog {
  padding: 0; border: 1px solid var(--edge); border-radius: 18px; background: var(--case-2); color: var(--silk);
  width: min(520px, calc(100vw - 32px)); box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .7);
  max-height: calc(100dvh - 32px); overflow: hidden;
}
.dialog.wide { width: min(720px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(10, 11, 14, .62); backdrop-filter: blur(2px); }
/* Título e botões ficam sempre à vista; só o conteúdo do meio rola. */
.dialog-inner {
  padding: 22px 22px 18px; display: grid; gap: 18px;
  grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: calc(100dvh - 34px);
}
.dialog-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: -4px -8px; padding: 4px 8px; }
.dialog-title { font-size: 18px; font-weight: 600; }
.dialog-text { color: var(--silk-dim); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 60; max-width: min(420px, calc(100vw - 40px)); }
.toast {
  background: var(--case-3); border: 1px solid var(--edge); border-left: 3px solid var(--key);
  padding: 10px 14px; border-radius: 10px; box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .7);
  transition: opacity 250ms, transform 250ms;
}
.toast.ok { border-left-color: var(--live); }
.toast.warn { border-left-color: var(--warn); }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------- Telas menores ---------- */

@media (max-width: 1100px) {
  .stage-grid { grid-template-columns: minmax(0, 1fr); }
  .scan-body { grid-template-columns: 1fr 1fr; }
  .scan-now { grid-column: 1 / -1; }
  .sec-row:not(.sec-header) { grid-template-columns: 24px minmax(0, 1fr) auto; }
  .sec-row:not(.sec-header) > select { grid-column: 2 / -1; }
  .sec-row:not(.sec-header) > .check { grid-column: 2; }
  .sec-row:not(.sec-header) > .row-tools { grid-column: 3; justify-self: end; }
  .sec-header { display: none; }
}

@media (max-width: 1200px) {
  .view.drums, .view.songs { grid-template-columns: minmax(0, 1fr); }
  .library { display: none; }
  .lib-compact { display: flex; flex-wrap: wrap; }
  .setlist { position: static; }
}

@media (max-width: 960px) {
  .now-label, .rail-pname { display: none; }
}

@media (max-width: 760px) {
  :root { --rail-h: 56px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { gap: 10px; padding: 0 12px; }
  .brand-name, .conn-label, .rail-bpm .icon-btn, .transport .btn { display: none; }
  .nav {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 10;
    flex-direction: row; justify-content: space-around; gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--edge);
  }
  .nav a { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 11px; flex: 1; text-align: center; }
  .nav a[aria-current='page']::before { left: 25%; right: 25%; top: -7px; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  .main { padding: 18px 16px 104px; }
  .pedal { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: 'screen screen' 'left right'; padding: 20px 16px 24px; }
  .screen { padding: 14px; }
  .screen-main { gap: 10px; }
  .preset-box { padding: 6px 14px 4px; border-radius: 16px; min-width: 0; }
  .preset-p { font-size: clamp(24px, 8.5vw, 40px); }
  .preset-num { font-size: clamp(40px, 15vw, 68px); }
  .bpm-ring { width: clamp(62px, 19vw, 84px); }
  .pedal .screen { grid-area: screen; }
  .fs-wrap.left { grid-area: left; }
  .fs-wrap.right { grid-area: right; }
  .scan-body { grid-template-columns: minmax(0, 1fr); }
  .cc-map { grid-template-columns: repeat(12, 1fr); }
  .foot-row { grid-template-columns: minmax(0, 1fr); }
  .stage-song { grid-template-columns: auto minmax(0, 1fr); }
  .stage-song .muted, .stage-song-first { grid-column: 2; }
}

/* ---------- Toque (celular e tablet) ---------- */

button, a, input, select, label { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
/* Arrastar na vertical rola a página; só o gesto na horizontal mexe no controle. */
input[type='range'] { touch-action: pan-y; }
.footswitch, .play-key, .cell, .btn, .icon-btn, .mod-chip, .led-btn, .seq-label, .nav a { -webkit-user-select: none; user-select: none; }
.shell { grid-template-rows: calc(var(--rail-h) + env(safe-area-inset-top, 0px)) minmax(0, 1fr); }
.rail { padding-top: env(safe-area-inset-top, 0px); }

@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn.small { min-height: 38px; padding: 6px 12px; }
  .icon-btn { width: 42px; height: 42px; }
  .input { min-height: 44px; font-size: 16px; } /* 16px evita o zoom automático do celular ao tocar no campo */
  .stepper-btn { width: 44px; font-size: 20px; }
  .stepper-input { min-height: 44px; font-size: 16px; }
  .stepper.sm .stepper-btn { width: 38px; }
  .stepper.sm .stepper-input { min-height: 40px; }
  .seq-row { grid-template-columns: 112px repeat(var(--steps), 34px); gap: 4px; }
  .cell { width: 34px; height: 40px; }
  .seq-label { padding: 8px 6px; }
  .lib-item, .song-pick { padding-top: 11px; padding-bottom: 11px; }
  .map-cell { min-height: 20px; }
  .check input { width: 22px; height: 22px; flex: none; }
  .check { min-height: 40px; }
  input[type='range'] { height: 36px; }
  .mod-chip { min-height: 34px; min-width: 44px; padding: 6px 9px; font-size: 11px; }
  .icon-btn.sm { width: 36px; height: 40px; }
  .bank { min-height: 38px; min-width: 50px; }
  .conn { min-height: 40px; }
  .rail-preset { min-height: 40px; }
  details > summary { padding: 10px 0; }
  .pack-num { padding: 8px 4px; }
  .ed-knob { min-height: 40px; }
  .switch-track { width: 44px; height: 26px; }
  .switch-track::after { width: 20px; height: 20px; }
  .switch input:checked + .switch-track::after { transform: translateX(18px); }
}

@media (max-width: 760px) {
  .footswitch { width: 96px; }
  .view-head h1, .pattern-title { font-size: 19px; }
  .block { padding: 16px; border-radius: 14px; }
  .song-fields { padding: 14px; }
  .toasts { left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); max-width: none; }
  .drum-transport .beat-leds { margin-left: 0; padding-bottom: 0; width: 100%; }
  .check { white-space: normal; }

  /* Barra de cima: sem a marca, e com "Conectar" visível quando o pedal não está conectado. */
  .brand { display: none; }
  .conn { padding: 5px 10px; min-height: 36px; }
  .conn:not(.ok) .conn-short { display: inline; }

  /* Diálogos saem de baixo, como no Android; os largos (editor, detalhes) ocupam a tela toda. */
  .dialog {
    width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 18px 18px 0 0; border-width: 1px 0 0;
    max-height: calc(100dvh - 24px);
  }
  .dialog-inner { padding: 18px 16px calc(14px + env(safe-area-inset-bottom, 0px)); gap: 14px; max-height: calc(100dvh - 25px); }
  .dialog.wide { height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; border: 0; }
  .dialog.wide .dialog-inner { height: 100%; max-height: 100%; padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
  .dialog-title { font-size: 17px; }
  .dialog-actions .btn { flex: 1 1 0; white-space: normal; text-align: center; justify-content: center; line-height: 1.2; }

  /* Presets em lista: número, nome e módulos numa linha; ações no menu ⋯. */
  .presets .toolbar { margin: -8px -16px; padding: 8px 16px; gap: 8px; }
  .presets .toolbar .search { flex: 1 1 0; max-width: none; }
  .preset-grid { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .tile { flex-direction: row; align-items: center; }
  .tile-main {
    flex: 1 1 auto; min-height: 64px; padding: 8px 2px 8px 12px;
    grid-template-columns: 40px minmax(0, 1fr); column-gap: 8px; row-gap: 4px; align-content: center;
  }
  .tile-num { grid-row: 1 / span 2; font-size: 19px; white-space: nowrap; }
  .tile-chain { gap: 2px; flex-wrap: nowrap; }
  .tile-chain .mini { padding: 2px 3px; }
  .tile-tools .icon-btn { width: 40px; }
  .bank-jump { gap: 4px; }
  .bank { flex: 1 1 0; min-width: 0; padding: 6px 2px; }
  .tile.is-current .tile-num::after { display: block; margin: 4px 0 0; }
  .tile-name, .tile-chain { grid-column: 2; }
  .tile-chain { margin-top: 0; }
  .tile-notes { display: none; }
  .tile-tools { margin: 0; padding: 0 6px 0 0; align-items: center; }
  .tool-info, .tool-sound, .tool-edit { display: none; }
  .tool-more { display: inline-grid; }

  /* Editor de presets */
  .ed-row { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; }
  .ed-row > .ed-label { grid-column: 1 / -1; }
  .ed-chain { grid-column: 1 / -1; gap: 6px; }
  .ed-blocks { grid-template-columns: minmax(0, 1fr); }
  .ed-block { padding: 12px; }
  .ed-block-head select { flex: 1 1 0; min-width: 0; }
  .ed-knob { grid-template-columns: 74px minmax(0, 1fr) 3ch; gap: 8px; }
  .ed-save { align-items: stretch; }
  .ed-save .ed-label { flex: 1 1 100%; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; }
  .ed-save select { min-width: 0; }
  .editor .note.small { font-size: 12.5px; padding: 8px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
