/* JPV PAD — console de operação. Grafite, alto contraste, sem enfeite. */
:root {
  --bg: #16181b; --panel: #202328; --panel-2: #2a2e34; --line: #3a3f47;
  --ink: #eceae4; --muted: #959aa3; --signal: #ffb020; --stop: #d9352b; --pad-empty: #1d2024;
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif; --radius: 6px;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--bg); color: var(--ink); font: 15px/1.4 var(--font); display: flex; flex-direction: column; -webkit-user-select: none; user-select: none; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

.console { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { margin: 0; font-size: 1.6rem; font-weight: 900; letter-spacing: .12em; line-height: 1.05; color: var(--signal); }
.brand .version { margin-left: 8px; font-size: .68rem; font-weight: 600; letter-spacing: .04em; color: var(--muted, #9aa0a6); vertical-align: middle; }
.brand-block { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 12px; row-gap: 1px; }
.brand-mark { grid-row: 1 / span 2; width: 42px; height: 42px; }
.byline { margin: 0; font-size: .75rem; letter-spacing: .04em; color: var(--muted); }
.byline .author { display: inline-block; padding: 2px 0; color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.byline .author:hover { color: var(--signal); }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; }
.control-group { display: flex; align-items: center; gap: 14px; }
.control-actions { gap: 10px; }
.master { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.master input { width: 120px; accent-color: var(--signal); }

.btn { padding: 8px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); font-weight: 600; cursor: pointer; transition: background .12s, border-color .12s; }
.btn:hover:not(:disabled) { background: #343942; border-color: #50565f; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-stop { background: var(--stop); border-color: var(--stop); font-weight: 800; letter-spacing: .06em; min-width: 108px; }
.btn-stop:hover:not(:disabled) { background: #ee4439; border-color: #ee4439; }
.btn-primary { background: var(--signal); border-color: var(--signal); color: #1a1405; }
.btn-primary:hover:not(:disabled) { background: #ffc24d; border-color: #ffc24d; }
.btn-danger { background: var(--stop); border-color: var(--stop); }
.btn-danger:hover:not(:disabled) { background: #ee4439; border-color: #ee4439; }

.tabbar { display: flex; align-items: flex-end; gap: 6px; padding: 10px 20px 0; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; min-width: 0; overflow-x: auto; }
.tab { padding: 9px 18px; border: 1px solid var(--line); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; background: var(--panel); color: var(--muted); font-weight: 600; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab.is-active { background: var(--bg); color: var(--ink); box-shadow: inset 0 3px 0 var(--signal); margin-bottom: -1px; padding-bottom: 10px; }
.tab-add { width: 36px; height: 36px; margin-bottom: 4px; border: 1px dashed var(--line); border-radius: var(--radius); background: transparent; color: var(--muted); font-size: 1.3rem; line-height: 1; cursor: pointer; }
.tab-add { flex: none; }
.tab-add:hover:not(:disabled) { color: var(--ink); border-color: var(--muted); }
.tab-add:disabled { opacity: .35; cursor: not-allowed; }

.pad-grid { flex: 1; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(84px, 1fr); gap: 10px; padding: 16px 20px 20px; min-height: 0; }
.pad { --pad: var(--panel-2); --pad-ink: var(--ink); position: relative; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; padding: 10px 12px; border: 1px solid rgba(255,255,255,.08); border-radius: 8px; text-align: left; cursor: pointer; background: var(--pad); color: var(--pad-ink); overflow: hidden; box-shadow: inset 0 -4px 0 rgba(0,0,0,.28); transition: transform .06s, filter .12s; }
.pad.has-audio { --pad: #3a404a; border-color: rgba(255,255,255,.16); }
.pad:hover { filter: brightness(1.12); }
.pad:active { transform: translateY(1px); }
.pad.is-empty { background: var(--pad-empty); border: 1px dashed var(--line); box-shadow: none; color: var(--muted); }
.pad-num { position: absolute; top: 8px; left: 12px; font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums; opacity: .75; }
.pad-name { max-width: 100%; font-weight: 700; line-height: 1.2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.pad.is-empty .pad-num, .pad.has-audio .pad-num { opacity: 1; }
.pad.is-empty .pad-name { font-weight: 500; font-size: .85rem; }
.pad-loop { position: absolute; top: 7px; right: 10px; padding: 1px 6px; border: 1px solid currentColor; border-radius: 3px; font-size: .62rem; font-weight: 800; letter-spacing: .08em; }
.pad-loop[hidden] { display: none; }
.pad-led { position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--signal); opacity: 0; transition: opacity .1s; }
.pad.is-playing .pad-led { opacity: 1; }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(8,9,10,.7); }
.modal { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 24px 60px rgba(0,0,0,.55); }
.modal-title { margin: 0; padding: 16px 20px; font-size: 1.05rem; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px 20px; }
.modal-body p { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }
.field { display: grid; gap: 6px; color: var(--muted); font-size: .88rem; }
.field input { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--ink); -webkit-user-select: text; user-select: text; }
.field-error { margin-top: 8px !important; color: #ff7b72; font-size: .88rem; }
.field-error[hidden] { display: none; }

.ctx-menu { position: fixed; z-index: 60; min-width: 190px; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 12px 32px rgba(0,0,0,.5); }
.ctx-item { display: block; width: 100%; padding: 9px 12px; border: 0; border-radius: 5px; background: transparent; text-align: left; font-weight: 600; cursor: pointer; }
.ctx-item:hover, .ctx-item:focus-visible { background: var(--panel-2); }
.ctx-item:disabled { opacity: .45; cursor: not-allowed; background: transparent; }
.ctx-item.is-danger { color: #ff7b72; }

.toast-stack { position: fixed; z-index: 45; pointer-events: none; right: 20px; bottom: 20px; display: grid; gap: 8px; }
.toast { padding: 10px 16px; border-radius: var(--radius); background: var(--panel-2); border-left: 4px solid var(--muted); box-shadow: 0 8px 24px rgba(0,0,0,.45); max-width: 340px; }
.toast-success { border-left-color: #3fb950; }
.toast-error { border-left-color: var(--stop); }

@media (max-width: 1000px) { .pad-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (max-width: 680px) {
  .pad-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 12px; }
  .console, .tabbar { padding-left: 12px; padding-right: 12px; }
}
@media (max-width: 380px) { .pad-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Fase 2: cadeado da aba SFX, popup de configuração do pad, erro de armazenamento */
.pad, .tab { -webkit-touch-callout: none; }
.tab-lock { width: 12px; height: 12px; margin-left: 7px; vertical-align: -1px; fill: currentColor; }
.modal-wide { width: min(500px, 100%); }
.modal-body { max-height: calc(100vh - 170px); max-height: calc(100dvh - 170px); overflow-y: auto; }
.pad-section { display: grid; gap: 8px; margin-bottom: 18px; }
.pad-section:last-child { margin-bottom: 0; }
.pad-section.is-disabled { opacity: .45; }
.section-label { color: var(--muted); font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.title-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.title-input { flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--ink); -webkit-user-select: text; user-select: text; }
.title-input[aria-invalid="true"] { border-color: #ff7b72; }
.title-input:disabled { cursor: not-allowed; }
.title-count { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.file-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--signal); }
.modal-actions .btn-delete-audio { margin-right: auto; }
.modal-actions .btn-delete-audio[hidden] { display: none; }
.fatal { grid-column: 1 / -1; align-self: start; justify-self: center; max-width: 520px; padding: 24px; border: 1px solid var(--stop); border-radius: 10px; background: var(--panel); }
.fatal h2 { margin: 0 0 8px; font-size: 1.1rem; }
.fatal p { margin: 0 0 16px; color: var(--muted); }
@media (max-width: 680px) {
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn-delete-audio { margin-right: 0; flex-basis: 100%; }
}

/* Fase 3: motor de áudio — células, estados, progresso, volume e forma de onda */
.pad-cell { position: relative; display: flex; min-width: 0; min-height: 0; }
.pad-cell > .pad { flex: 1; min-width: 0; }
/* Comandos em coluna na borda direita: nunca cobrem o centro do pad (alvo do clique e do botão direito) */
.pad-actions { position: absolute; top: 6px; right: 6px; z-index: 2; display: flex; flex-direction: column; gap: 6px; }
.pad-actions[hidden] { display: none; }
.pad-action { width: 32px; height: 32px; border: 1px solid rgba(255,255,255,.4); border-radius: 6px; background: rgba(8,10,12,.82); color: #fff; font-size: 1rem; font-weight: 800; line-height: 1; cursor: pointer; }
.pad-action:hover:not(:disabled) { background: #000; border-color: #fff; }
.pad-action:disabled { opacity: .45; cursor: default; }
.pad-state { position: absolute; top: 7px; left: 36px; font-size: .8rem; font-weight: 800; line-height: 1.3; }
.pad-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--signal); transform: scaleX(0); transform-origin: left; pointer-events: none; }
.pad.is-playing .pad-progress, .pad.is-looping .pad-progress, .pad.is-fading .pad-progress { animation: pad-progress var(--dur, 1s) linear var(--delay, 0s) 1 forwards; }
.pad.is-looping .pad-progress { animation-iteration-count: infinite; }
.pad.is-fading .pad-progress { background: var(--stop); }
.pad.is-playing .pad-led, .pad.is-looping .pad-led, .pad.is-fading .pad-led { opacity: 1; }
.pad.is-loading .pad-led { animation: pad-pulse .8s ease-in-out infinite alternate; }
.pad.is-fading .pad-led { background: var(--stop); }
.pad.is-fading .pad-name { animation: pad-fade var(--fade, 2s) linear var(--fade-delay, 0s) forwards; }
.pad.is-error { border: 2px solid var(--stop); box-shadow: inset 0 0 0 1px var(--stop); }
.pad.is-error .pad-led { background: var(--stop); opacity: 1; }
.pad.is-nudge { animation: pad-nudge .6s ease-out; }
/* Pad ocupado: o glifo de estado (↻ ▶ ↘ …) substitui o selo LOOP e libera o canto para os comandos */
.pad.is-playing .pad-loop, .pad.is-looping .pad-loop, .pad.is-fading .pad-loop, .pad.is-loading .pad-loop { display: none; }
.pad.is-playing .pad-name, .pad.is-looping .pad-name, .pad.is-fading .pad-name, .pad.is-loading .pad-name { max-width: calc(100% - 44px); }
/* Versão 1.2: onda, tempo percorrido e volume dentro do botão (só abas locais; a SFX não tem nada disso) */
.pad-wave, .pad-time { display: none; pointer-events: none; }
.pad.is-playing .pad-wave, .pad.is-looping .pad-wave, .pad.is-fading .pad-wave { display: block; }
.pad.is-playing .pad-time, .pad.is-looping .pad-time, .pad.is-fading .pad-time { display: block; }
.pad.has-wave .pad-progress { display: none; } /* a onda é o indicador de progresso */
.pad-wave { position: absolute; left: 10px; right: 10px; bottom: 8px; height: 24px; } /* faixa própria no pé do botão: o texto fica acima dela */
.pad-wave-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.pad-wave-played { position: absolute; inset: 0; clip-path: inset(0 100% 0 0); }
.pad-wave-dot { position: absolute; left: 0; bottom: 2px; width: 9px; height: 9px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.45); transform: translate(-50%, 50%); }
.pad.is-playing .pad-wave-played, .pad.is-looping .pad-wave-played, .pad.is-fading .pad-wave-played { animation: pad-wave-reveal var(--dur, 1s) linear var(--delay, 0s) 1 forwards; }
.pad.is-playing .pad-wave-dot, .pad.is-looping .pad-wave-dot, .pad.is-fading .pad-wave-dot { animation: pad-wave-dot var(--dur, 1s) linear var(--delay, 0s) 1 forwards; }
.pad.is-looping .pad-wave-played, .pad.is-looping .pad-wave-dot { animation-iteration-count: infinite; }
.pad-name, .pad-time { position: relative; z-index: 1; }
.pad-time { font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.25; opacity: .92; }
/* Pad com áudio: altura mínima para caber nome + tempo + onda sem encostar na linha do número */
.pad.has-wave { min-height: 108px; }
.pad.has-wave.is-playing, .pad.has-wave.is-looping, .pad.has-wave.is-fading { padding-bottom: 36px; }
.pad-vol { position: absolute; top: 2px; left: 54px; z-index: 2; width: 28px; height: 28px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--pad-ink, var(--ink)); opacity: .7; cursor: pointer; }
.pad-vol:hover, .pad-vol[aria-expanded="true"] { opacity: 1; background: rgba(0,0,0,.28); }
.pad-vol-icon { width: 15px; height: 15px; overflow: visible; }
.pad-vol-icon .vol-body { fill: currentColor; }
.pad-vol-icon .vol-waves, .pad-vol-icon .vol-mute { fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; }
.pad-vol-icon .vol-mute { display: none; }
.pad-vol.is-muted .vol-waves { display: none; }
.pad-vol.is-muted .vol-mute { display: inline; }
.pad-vol-pop { position: absolute; left: 6px; right: 6px; top: 34px; z-index: 6; display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid rgba(255,255,255,.4); border-radius: 8px; background: rgba(8,10,12,.94); color: #fff; box-shadow: 0 8px 20px rgba(0,0,0,.45); }
.pad-vol-pop[hidden] { display: none; }
.pad-vol-range { flex: 1; min-width: 0; height: 24px; margin: 0; accent-color: var(--signal); cursor: pointer; }
.pad-vol-out { flex: 0 0 auto; min-width: 3ch; font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
@keyframes pad-wave-reveal { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes pad-wave-dot { from { left: 0; } to { left: 100%; } }
/* Versão 1.4: barra de status do backup (sempre visível no rodapé; a cor sobe com a idade do último backup) */
.backup-bar { position: sticky; bottom: 0; z-index: 20; display: flex; align-items: center; padding: 4px 14px; border-top: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: .75rem; line-height: 1.3; }
.backup-bar-text { display: flex; align-items: center; gap: 8px; min-width: 0; }
.backup-dot { flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.backup-bar[data-level="ok"] { background: #143323; border-top-color: #2e7d4f; color: #c8f2d6; }
.backup-bar[data-level="warn"] { background: #4b3608; border-top-color: #e0a21b; color: #ffe2a0; font-weight: 600; }
.backup-bar[data-level="danger"] { background: #a8150e; border-top-color: #ff7a70; color: #fff; font-weight: 700; }
.backup-bar.is-blinking { animation: backup-blink 1.2s ease-in-out infinite; } /* ~0,8 piscadas por segundo: bem visível e abaixo do limite seguro */
@keyframes backup-blink { 0%, 100% { background: #a8150e; } 50% { background: #4d0a07; } }
@media (prefers-reduced-motion: reduce) { .backup-bar.is-blinking { animation: none; } }
@media (max-width: 680px) { .backup-bar { padding-left: 12px; padding-right: 12px; } .backup-bar-note { display: none; } }
.backup-bar { justify-content: space-between; gap: 12px; }
.backup-bar-note { margin-left: auto; padding-left: 12px; font-size: .72rem; font-weight: 500; opacity: .75; white-space: nowrap; }
.menu-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); color: var(--ink); cursor: pointer; }
.menu-btn:hover, .menu-btn[aria-expanded="true"] { background: #343942; border-color: #50565f; }
.menu-btn svg { width: 18px; height: 18px; }
/* Versão 1.6: arrastar botões para reorganizar (imagem fantasma, origem esmaecida e destino destacado) */
.pad-grid.is-dragging, .pad-grid.is-dragging * { cursor: grabbing; }
.pad-grid.is-dragging { -webkit-user-select: none; user-select: none; }
.pad-cell.is-drag-source { opacity: .35; }
.pad-cell.is-lifted .pad { transform: scale(1.04); box-shadow: 0 10px 22px rgba(0,0,0,.5); }
.pad-ghost { position: fixed; top: 0; left: 0; z-index: 90; margin: 0; opacity: .74; pointer-events: none; box-shadow: 0 16px 34px rgba(0,0,0,.6); transition: none; will-change: transform; }
.pad-cell[data-drop] { position: relative; }
.pad-cell[data-drop]::after { content: attr(data-drop-label); position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; border-radius: 8px; font-size: .9rem; font-weight: 800; letter-spacing: .14em; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.9), 0 0 8px rgba(0,0,0,.6); pointer-events: none; }
.pad-cell[data-drop="move"]::after { outline: 3px dashed #4cc2ff; outline-offset: -3px; background: rgba(76,194,255,.4); }
.pad-cell[data-drop="swap"]::after { outline: 3px solid var(--signal); outline-offset: -3px; background: rgba(245,166,35,.45); }
.pad-cell[data-drop="blocked"]::after { outline: 3px solid #ff5a50; outline-offset: -3px; background: rgba(255,90,80,.5); }
/* Versão 1.8: teclas de atalho — etiqueta no botão e campo "Tecla de atalho" no editor */
.pad-key { position: absolute; right: 8px; bottom: 7px; z-index: 2; min-width: 18px; padding: 1px 5px; border: 1px solid currentColor; border-radius: 4px; font-size: .68rem; font-weight: 800; line-height: 1.25; text-align: center; opacity: .72; pointer-events: none; }
.pad.has-wave .pad-key { color: var(--pad-ink); }
.pad.has-key { padding-right: 32px; } /* só quem tem etiqueta de tecla reserva o espaço dela */
.pad.has-wave.is-playing .pad-key, .pad.has-wave.is-looping .pad-key, .pad.has-wave.is-fading .pad-key { display: none; } /* tocando: o foco é a onda, o tempo e o STOP/FADE */
@media (max-width: 680px), (pointer: coarse) { .pad-key { display: none; } .pad.has-key { padding-right: 12px; } } /* tela de toque: sem teclado, sem etiqueta */
.shortcut-row { display: flex; align-items: center; gap: 10px; }
.shortcut-capture { min-width: 150px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); font: inherit; font-weight: 800; letter-spacing: .04em; text-align: left; cursor: pointer; }
.shortcut-capture:hover:not(:disabled) { border-color: #50565f; }
.shortcut-capture.is-capturing { border-color: var(--signal); box-shadow: 0 0 0 2px rgba(245,166,35,.35); color: var(--signal); }
.shortcut-capture:disabled { cursor: not-allowed; }
.shortcut-reset { padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); color: var(--ink); font: inherit; font-size: .82rem; cursor: pointer; }
.shortcut-reset[hidden] { display: none; }
.shortcut-status { margin: 6px 0 0; font-size: .86rem; font-weight: 600; }
.shortcut-status.is-ok { color: #7fe3a1; }
.shortcut-status.is-bad { color: #ff8a80; }
.shortcut-status.is-neutral { color: var(--muted); font-weight: 500; }
.shortcut-capture.is-empty { color: var(--muted); font-weight: 600; }
.shortcut-icon { display: inline-block; min-width: 1.1em; font-weight: 800; }
/* Versão 2.0: escolha de cor — uma linha (quadradinho + código hexadecimal + botão) e o popup com o quadro de cores */
.color-row { display: flex; align-items: center; gap: 10px; }
.color-chip { flex: 0 0 auto; width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--chip, transparent); cursor: pointer; }
.color-chip.is-none, .cp-chip.is-none { background: repeating-linear-gradient(135deg, var(--panel-2) 0 6px, var(--bg) 6px 12px); }
.color-chip:hover:not(:disabled), .color-open:hover:not(:disabled) { border-color: #50565f; }
.color-chip:disabled, .color-open:disabled { cursor: not-allowed; }
.color-input, .cp-hex { width: 150px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); font: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .04em; text-transform: uppercase; -webkit-user-select: text; user-select: text; }
.color-input[aria-invalid="true"], .cp-hex[aria-invalid="true"] { border-color: #ff7b72; }
.color-input::placeholder, .cp-hex::placeholder { text-transform: none; letter-spacing: 0; color: var(--muted); }
.color-open { flex: 0 0 auto; display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); color: var(--ink); cursor: pointer; }
.color-open-icon { width: 20px; height: 20px; }
.color-hint, .cp-hint { margin: 6px 0 0; font-size: .84rem; color: var(--muted); }
.color-hint.is-bad, .cp-hint.is-bad { color: #ff8a80; font-weight: 600; }
.color-hint[hidden], .cp-hint[hidden] { display: none; }
.color-popup { display: grid; gap: 12px; min-width: 0; }
.cp-sv { position: relative; height: 170px; border-radius: 8px; border: 1px solid var(--line); cursor: crosshair; touch-action: none; -webkit-user-select: none; user-select: none;
  background: linear-gradient(to top, #000, rgba(0,0,0,0)), linear-gradient(to right, #fff, hsl(var(--hue, 40) 100% 50%)); }
.cp-sv:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.cp-marker { position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 1px 4px rgba(0,0,0,.6); transform: translate(-50%, -50%); pointer-events: none; }
.cp-marker[hidden] { display: none; }
.cp-hue { width: 100%; height: 14px; margin: 0; appearance: none; -webkit-appearance: none; border-radius: 7px; cursor: pointer;
  background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%); }
.cp-hue::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; border: 2px solid #fff; background: transparent; box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 1px 4px rgba(0,0,0,.6); }
.cp-hue::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; background: transparent; box-shadow: 0 0 0 1px rgba(0,0,0,.6); }
.cp-hex-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cp-chips { display: flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--muted); }
.cp-chip { display: inline-block; width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 6px; background: var(--chip, transparent); }
.cp-sample { padding: 14px 12px; border: 1px solid var(--line); border-radius: 8px; font-weight: 700; text-align: left; }
.cp-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.cp-preset { width: 22px; height: 22px; padding: 0; border: 2px solid transparent; border-radius: 50%; background: var(--swatch); cursor: pointer; }
.cp-preset[aria-checked="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--bg) inset; }
@media (pointer: coarse) { .cp-preset { width: 30px; height: 30px; } .cp-presets { gap: 8px; } }
@keyframes pad-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes pad-pulse { from { opacity: .25; } to { opacity: 1; } }
@keyframes pad-fade { from { opacity: 1; } to { opacity: .45; } }
@keyframes pad-nudge { 0%, 100% { box-shadow: none; } 30% { box-shadow: inset 0 0 0 2px var(--signal); } }
.fade-select { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.fade-select select { padding: 7px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); color: var(--ink); }
#master-volume-value { min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.volume-row { display: flex; align-items: center; gap: 12px; }
.volume-row input { flex: 1; accent-color: var(--signal); }
.volume-out { min-width: 3.4em; text-align: right; font-variant-numeric: tabular-nums; }
.wave-box { display: grid; gap: 4px; }
.wave-box[hidden] { display: none; }
.wave-row { display: flex; align-items: stretch; gap: 10px; min-width: 0; }
.wave-controls { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; width: 86px; }
.preview-btn { flex: 1; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); font-weight: 700; font-size: .78rem; letter-spacing: .04em; white-space: nowrap; cursor: pointer; transition: background .12s, border-color .12s; }
.preview-btn:hover:not(:disabled) { background: #343942; border-color: #50565f; }
.preview-btn:disabled { opacity: .4; cursor: not-allowed; }
.preview-play[aria-pressed="true"] { background: var(--signal); border-color: var(--signal); color: #1a1405; }
.wave-row .waveform { flex: 1; width: auto; min-width: 0; }
.waveform { display: block; width: 100%; height: 56px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.wave-status { min-height: 1.2em; margin: 0; color: var(--muted); font-size: .8rem; }
@media (prefers-reduced-motion: reduce) { .pad-led, .pad.is-fading .pad-name, .pad.is-nudge { animation: none !important; } }
/* Toque: STOP/FADE com 40 px (controle crítico ao vivo). Linhas mais altas no celular para a coluna de comandos caber. */
@media (max-width: 680px), (pointer: coarse) { .pad-action { width: 40px; height: 40px; } }
@media (max-width: 680px) { .pad-vol { left: 46px; } }
@media (pointer: coarse) { .pad-vol { width: 36px; height: 36px; } .pad-vol-pop { top: 40px; } .pad-vol-range { height: 32px; } }
@media (max-width: 680px) { .pad-grid { grid-auto-rows: minmax(98px, 1fr); } }
/* Fase 4: janela de progresso (exportação) */
.progress-text { margin: 0; }
.progress { display: block; width: 100%; height: 10px; margin-top: 12px; accent-color: var(--signal); }

/* v1.7: modo AO VIVO (trava as edições; tocar continua normal) */
.live-btn { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); font: inherit; font-size: .76rem; font-weight: 800; letter-spacing: .12em; cursor: pointer; }
.live-btn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .55; }
.live-btn:hover { color: var(--ink); border-color: var(--muted); }
.live-btn[aria-pressed="true"] { border-color: var(--stop); background: var(--stop); color: #fff; }
.live-btn[aria-pressed="true"]::before { background: #fff; opacity: 1; }
.live-btn.is-pulse { box-shadow: 0 0 0 4px rgba(217, 53, 43, .5); animation: live-pulse .7s ease-out; }
@keyframes live-pulse { 0% { box-shadow: 0 0 0 0 rgba(217, 53, 43, .85); } 100% { box-shadow: 0 0 0 10px rgba(217, 53, 43, 0); } }
@media (prefers-reduced-motion: reduce) { .live-btn.is-pulse { animation: none; } } /* sem movimento: o anel fica parado pelo mesmo tempo */
body.is-live .console { box-shadow: inset 0 -3px 0 var(--stop); }
body.is-live .tab-add { opacity: .35; cursor: not-allowed; }

/* Cabeçalho do celular (fica no fim do arquivo para vencer as regras-base declaradas acima) */
@media (max-width: 680px) {
  /* Cabeçalho do celular em duas linhas: nome + menu; volume + fade + AO VIVO + STOP ALL */
  .console { display: grid; grid-template-columns: 1fr auto auto auto; grid-template-areas: "brand brand brand menu" "master fade live stop"; align-items: center; gap: 10px 8px; padding-top: 10px; padding-bottom: 10px; }
  .controls, .control-group, .control-actions { display: contents; }
  .brand-block { grid-area: brand; min-width: 0; column-gap: 9px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand { font-size: 1.3rem; white-space: nowrap; }
  .brand .version { margin-left: 6px; }
  .byline { white-space: nowrap; font-size: .8rem; }
  .live-btn { grid-area: live; height: 34px; padding: 0 10px; gap: 6px; font-size: .66rem; letter-spacing: .06em; }
  .menu-btn { grid-area: menu; }
  .master { grid-area: master; min-width: 0; gap: 6px; }
  .master label, .master output, .fade-select span { display: none; } /* o controle continua com nome acessível (aria-label) */
  .master input { flex: 1; width: auto; min-width: 0; }
  .fade-select { grid-area: fade; }
  .btn-stop { grid-area: stop; min-width: 0; padding: 8px 12px; }
  /* o rótulo LOOP vira só o ícone ↻ para não encostar no ícone de volume */
  .pad-loop { font-size: 0; padding: 1px 5px; letter-spacing: 0; }
  .pad-loop::before { content: "↻"; font-size: .85rem; }
}
