:root {
  --bg0: #070b17;
  --bg1: #0d1428;
  --bg2: #151d38;
  --line: rgba(255, 255, 255, 0.08);
  --text: #e9edff;
  --dim: #8f9bc4;
  --accent: #7b6cff;
  --accent2: #2fc7ff;
  --danger: #ff5e7e;
  --radius: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: 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(--bg0); color: var(--text); font: 15px/1.35 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif; overscroll-behavior: none; }
body {
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(123, 108, 255, 0.22), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, rgba(47, 199, 255, 0.14), transparent 55%),
    radial-gradient(700px 600px at 50% 120%, rgba(255, 94, 126, 0.12), transparent 60%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
  background-attachment: fixed;
}
#root { min-height: 100%; }
body { overflow-x: hidden; }
button, input, select { font: inherit; color: inherit; touch-action: manipulation; }
button { cursor: pointer; }

.app { display: flex; flex-direction: column; gap: 8px; min-height: 100vh; min-height: 100dvh; max-width: 1280px; margin: 0 auto; padding: calc(10px + var(--safe-t)) 12px calc(10px + var(--safe-b)); }

/* ---------- topo ---------- */
.topbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 6px; margin-right: auto; letter-spacing: 0.14em; }
.brand b { font-size: 15px; } .brand small { color: var(--dim); font-size: 11px; letter-spacing: 0.3em; }
@media (max-width: 480px) { .brand small { display: none; } .brand { letter-spacing: 0.1em; } }
.logo { width: 22px; height: 22px; border-radius: 50%; align-self: center; background: conic-gradient(from 200deg, #7b6cff, #2fc7ff, #ff5e7e, #ffb347, #7b6cff); box-shadow: 0 0 14px rgba(123, 108, 255, 0.7); position: relative; }
.logo::after { content: ''; position: absolute; inset: 5px; border-radius: 50%; background: var(--bg1); }
.logo.big { width: 84px; height: 84px; margin: 0 auto 14px; animation: spin 14s linear infinite; }
.logo.big::after { inset: 20px; }
@keyframes spin { to { transform: rotate(360deg); } }

.scene-nav { display: flex; align-items: center; gap: 4px; order: 3; flex: 1 1 100%; justify-content: center; }
.scene-name { flex: 0 1 340px; min-width: 0; padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line); background: linear-gradient(180deg, #1c2546, #121a33); font-weight: 600; letter-spacing: 0.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 4px 14px rgba(0, 0, 0, 0.4); }
.dirty { display: inline-block; width: 7px; height: 7px; margin-left: 8px; border-radius: 50%; background: #ffb347; box-shadow: 0 0 8px #ffb347; vertical-align: middle; }
.nav { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: #131b36; font-size: 22px; line-height: 1; }
.top-actions { display: flex; gap: 8px; }
.gear { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: #131b36; font-size: 18px; }
.rec { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: #131b36; font-weight: 700; letter-spacing: 0.08em; font-size: 12px; }
.rec i { width: 11px; height: 11px; border-radius: 50%; background: #5a2234; box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6); }
.rec time { font-variant-numeric: tabular-nums; color: var(--dim); font-weight: 500; min-width: 30px; }
.rec.on { border-color: rgba(255, 94, 126, 0.7); background: #2a1220; }
.rec.on i { background: var(--danger); box-shadow: 0 0 12px var(--danger); animation: blink 1s infinite; }
.rec.on time { color: #fff; }
@keyframes blink { 50% { opacity: 0.35; } }

/* ---------- faixa de status ---------- */
.strip { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); color: var(--text); font-size: 13px; font-variant-numeric: tabular-nums; }
.chip.chord { color: #cfd6ff; border-color: rgba(123, 108, 255, 0.5); background: rgba(123, 108, 255, 0.12); min-width: 74px; text-align: center; font-weight: 600; }
.beats { display: flex; gap: 6px; margin: 0 4px; }
.beats i { width: 9px; height: 9px; border-radius: 50%; background: #1d2644; box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.6); transition: background 0.08s, box-shadow 0.08s; }
.beats i.on { background: var(--accent2); box-shadow: 0 0 10px var(--accent2); }
.meter { flex: 1 1 90px; height: 8px; border-radius: 6px; background: #0a1022; box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.7); overflow: hidden; min-width: 80px; }
.meter i { display: block; height: 100%; transform-origin: left; transform: scaleX(0); background: linear-gradient(90deg, #3ddc97, #ffd35e 70%, #ff5e7e); }

/* ---------- palco ---------- */
.stage { flex: 1 1 auto; min-height: 0; display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; }
.pads { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(82px, 1fr); gap: 10px; min-height: 0; }
.pad {
  --c1: #7b6cff; --c2: #2fc7ff;
  position: relative; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px;
  padding: 10px 12px 8px; min-height: 82px; border-radius: var(--radius); cursor: pointer; user-select: none; outline: none;
  background: linear-gradient(145deg, color-mix(in srgb, var(--c1) 22%, #121a33), color-mix(in srgb, var(--c2) 14%, #0e152c));
  border: 1px solid color-mix(in srgb, var(--c1) 28%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), inset 0 -10px 24px rgba(0, 0, 0, 0.35), 0 8px 18px rgba(0, 0, 0, 0.45);
  transition: transform 0.12s, box-shadow 0.25s, background 0.25s, border-color 0.25s, filter 0.25s;
  filter: saturate(0.7);
}
.pad:active { transform: translateY(2px) scale(0.985); }
.pad:focus-visible { box-shadow: 0 0 0 2px #fff; }
.pad.on {
  filter: none;
  background: linear-gradient(145deg, var(--c1), var(--c2));
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), inset 0 -12px 26px rgba(0, 0, 0, 0.28), 0 0 26px color-mix(in srgb, var(--c1) 60%, transparent), 0 10px 22px rgba(0, 0, 0, 0.45);
}
.pad.entering { filter: none; animation: enter 1s ease-in-out infinite; }
@keyframes enter { 50% { box-shadow: 0 0 30px color-mix(in srgb, var(--c2) 80%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.3); } }
.pad-name { font-weight: 700; font-size: 17px; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45); }
.pad-cat { font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; opacity: 0.7; }
.led { position: absolute; top: 12px; left: 14px; width: 11px; height: 11px; border-radius: 50%; background: #11172d; box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.08); }
.pad.on .led { background: #fff; box-shadow: 0 0 10px #fff, 0 0 20px var(--c2); animation: led 2.4s ease-in-out infinite; }
@keyframes led { 50% { opacity: 0.7; } }
.pad-cfg { position: absolute; top: 4px; right: 6px; width: 38px; height: 34px; border: 0; background: transparent; font-size: 22px; opacity: 0.7; border-radius: 10px; }
.pad-cfg:hover { background: rgba(255, 255, 255, 0.12); opacity: 1; }
.pad-vol { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; margin: 2px 0 0; background: transparent; cursor: pointer; }
.pad-vol::-webkit-slider-runnable-track { height: 5px; border-radius: 4px; background: rgba(0, 0, 0, 0.4); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6); }
.pad-vol::-moz-range-track { height: 5px; border-radius: 4px; background: rgba(0, 0, 0, 0.4); }
.pad-vol::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #c9cfee); box-shadow: 0 2px 5px rgba(0, 0, 0, 0.6); }
.pad-vol::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: #e8ebff; }

/* ---------- console ---------- */
.console { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding: 8px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: linear-gradient(180deg, #141c38, #0e152b); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 8px 22px rgba(0, 0, 0, 0.4); }
.master { flex: 1 1 100%; min-width: 120px; display: flex; flex-direction: column; gap: 6px; }
.master label { font-size: 11px; letter-spacing: 0.22em; color: var(--dim); }
.fader { -webkit-appearance: none; appearance: none; width: 100%; height: 34px; background: transparent; cursor: pointer; }
.fader::-webkit-slider-runnable-track { height: 8px; border-radius: 6px; background: linear-gradient(90deg, #7b6cff, #2fc7ff); box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5); }
.fader::-moz-range-track { height: 8px; border-radius: 6px; background: linear-gradient(90deg, #7b6cff, #2fc7ff); }
.fader::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 34px; margin-top: -13px; border-radius: 8px; background: linear-gradient(180deg, #fafbff, #aab2d6 55%, #e5e8f7); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.6), inset 0 -2px 0 rgba(0, 0, 0, 0.2); border-top: 3px solid #5a6395; }
.fader::-moz-range-thumb { width: 26px; height: 34px; border-radius: 8px; border: 0; background: linear-gradient(180deg, #fafbff, #aab2d6); }
.knobs { display: flex; gap: 12px; flex: 1 1 100%; justify-content: space-around; }

.knob { width: 74px; text-align: center; outline: none; touch-action: none; user-select: none; cursor: ns-resize; }
.knob-dial { --v: 0.5; position: relative; width: 62px; height: 62px; margin: 0 auto 4px; border-radius: 50%; background: conic-gradient(from -135deg, var(--accent) calc(var(--v) * 270deg), rgba(255, 255, 255, 0.08) 0 270deg, transparent 0); filter: drop-shadow(0 0 5px color-mix(in srgb, var(--accent) 55%, transparent)); }
.knob-dial::before { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: radial-gradient(circle at 32% 26%, #424c78, #151c35 72%); box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.14), 0 6px 12px rgba(0, 0, 0, 0.55); }
.knob-dial::after { content: ''; position: absolute; left: 50%; top: 11px; width: 3px; height: 13px; margin-left: -1.5px; border-radius: 2px; background: #fff; box-shadow: 0 0 6px var(--accent); transform-origin: 50% 20px; transform: rotate(calc(var(--v) * 270deg - 135deg)); }
.knob:focus-visible .knob-dial, .knob.grab .knob-dial { filter: drop-shadow(0 0 9px var(--accent)); }
.knob-label { font-size: 10px; letter-spacing: 0.2em; color: var(--dim); }
.knob-val { font-size: 11px; color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- Build Up ---------- */
.buildup h3 { margin: 0 0 6px; font-size: 11px; letter-spacing: 0.3em; color: var(--dim); font-weight: 600; }
.bu-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.bu { --bc: #7b6cff; position: relative; overflow: hidden; height: 58px; border-radius: 14px; border: 1px solid color-mix(in srgb, var(--bc) 55%, transparent); background: linear-gradient(180deg, #1a2342, #0f1630); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 5px 12px rgba(0, 0, 0, 0.4); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; transition: box-shadow 0.25s; }
.bu-fill { position: absolute; inset: 0; transform-origin: left; transform: scaleX(0); background: linear-gradient(90deg, color-mix(in srgb, var(--bc) 25%, transparent), color-mix(in srgb, var(--bc) 75%, transparent)); }
.bu-label { position: relative; font-weight: 700; letter-spacing: 0.05em; }
.bu-sub { position: relative; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.6; }
.bu:active { transform: translateY(2px); }
.bu[data-state='queued'] { animation: blink 0.6s infinite; }
.bu[data-state='building'] { box-shadow: 0 0 18px color-mix(in srgb, var(--bc) 55%, transparent); }
.bu[data-state='peak'] { box-shadow: 0 0 28px var(--bc); border-color: #fff; }
.bu[data-state='releasing'] { box-shadow: 0 0 12px color-mix(in srgb, var(--bc) 40%, transparent); }

/* ---------- cenas ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip-scene { flex: 0 0 auto; padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); color: var(--dim); white-space: nowrap; }
.chip-scene.on { color: #fff; border-color: rgba(123, 108, 255, 0.8); background: linear-gradient(180deg, rgba(123, 108, 255, 0.4), rgba(47, 199, 255, 0.2)); box-shadow: 0 0 14px rgba(123, 108, 255, 0.4); }
.chip-scene.add { width: 38px; padding: 8px 0; font-size: 18px; line-height: 1; }

/* ---------- overlay / toast ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(5, 8, 18, 0.88); backdrop-filter: blur(10px); transition: opacity 0.4s; }
.overlay.hide { opacity: 0; pointer-events: none; }
.start-card { text-align: center; padding: 24px; }
.start-card h1 { margin: 0; letter-spacing: 0.2em; font-size: 22px; }
.start-card p { color: var(--dim); margin: 6px 0 26px; }
.start-card small { display: block; margin-top: 14px; color: var(--dim); }
.play { padding: 16px 44px; font-size: 18px; font-weight: 700; letter-spacing: 0.08em; border: 0; border-radius: 999px; color: #fff; background: linear-gradient(135deg, #7b6cff, #2fc7ff); box-shadow: 0 0 30px rgba(123, 108, 255, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.5); }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translate(-50%, 30px); opacity: 0; pointer-events: none; z-index: 70; max-width: 90vw; padding: 11px 18px; border-radius: 14px; background: #1b2548; border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6); transition: 0.3s; font-size: 14px; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- configurações ---------- */
dialog.sheet { margin: auto; width: min(680px, 100vw); max-height: min(88vh, 900px); padding: 0; color: var(--text); border: 1px solid var(--line); border-radius: 22px; background: linear-gradient(180deg, #172044, #0d1428); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7); overflow: hidden; }
dialog.sheet[open] { display: flex; flex-direction: column; }
dialog.sheet::backdrop { background: rgba(3, 6, 14, 0.72); backdrop-filter: blur(4px); }
dialog.sheet.small { width: min(460px, 100vw); }
.sheet-head, .tabs { flex: 0 0 auto; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.x { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05); }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 10px 14px; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs button { flex: 0 0 auto; padding: 7px 14px; border-radius: 999px; border: 1px solid transparent; background: transparent; color: var(--dim); }
.tabs button.on { color: #fff; background: rgba(123, 108, 255, 0.28); border-color: rgba(123, 108, 255, 0.6); }
.sheet-body { overflow-y: auto; padding: 14px 18px 22px; }
.form { display: flex; flex-direction: column; gap: 12px; }
.row { display: grid; grid-template-columns: minmax(110px, 38%) 1fr auto; align-items: center; gap: 10px; }
.row > span { color: var(--dim); font-size: 14px; }
.row output { min-width: 56px; text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }
.row select { grid-column: 2 / 4; }
select, input[type='text'] { width: 100%; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line); background: #0e1530; }
input[type='range'] { accent-color: var(--accent); width: 100%; }
.hint { color: var(--dim); font-size: 13px; }
.label { margin-top: 6px; font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--dim); }
.chords { display: flex; flex-wrap: wrap; gap: 8px; }
.chord-chip { padding: 6px 12px; border-radius: 10px; background: rgba(123, 108, 255, 0.16); border: 1px solid rgba(123, 108, 255, 0.4); font-weight: 600; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row button, .scene-row button, .bu-head button { padding: 9px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); }
button.primary { background: linear-gradient(135deg, #5b4cf0, #1f9fd6) !important; border-color: transparent !important; font-weight: 600; }
button.danger { color: #ff9db0; }
button:disabled { opacity: 0.5; }
.scene-row { display: flex; gap: 6px; align-items: center; padding: 6px; border-radius: 14px; border: 1px solid var(--line); }
.scene-row.on { border-color: rgba(123, 108, 255, 0.7); background: rgba(123, 108, 255, 0.1); }
.scene-row input { flex: 1; min-width: 0; }
.scene-row .grow { flex: 1; padding-left: 6px; }
.check { display: flex; align-items: center; gap: 4px; font-size: 14px; }
.check.disabled { opacity: 0.5; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 10px; }
.bu-card { --bc: #7b6cff; display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 16px; border: 1px solid color-mix(in srgb, var(--bc) 50%, transparent); background: color-mix(in srgb, var(--bc) 7%, transparent); }
.bu-head { display: flex; justify-content: space-between; align-items: center; color: var(--bc); }
progress { width: 100%; accent-color: var(--accent); }

/* ---------- responsivo ---------- */
@media (min-width: 640px) {
  .scene-nav { order: 0; flex: 0 1 auto; margin: 0 auto; }
  .brand { margin-right: 0; }
  .topbar { flex-wrap: nowrap; }
  .top-actions { margin-left: 0; }
  .pads { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .master { flex: 1 1 auto; }
  .knobs { flex: 0 0 auto; }
}
@media (min-width: 960px) {
  .stage { grid-template-columns: minmax(0, 1fr) 250px; grid-template-rows: 1fr; }
  .console { flex-direction: column; flex-wrap: nowrap; align-items: stretch; justify-content: center; gap: 22px; }
  .knobs { justify-content: space-between; flex: 0 0 auto; }
  .knob { width: 68px; }
  .master { flex: 0 0 auto; }
  .pad-name { font-size: 19px; }
}
@media (max-height: 560px) and (orientation: landscape) {
  .app { gap: 6px; }
  .pad { min-height: 60px; padding: 8px 10px; }
  .pad-vol { margin-top: 2px; }
  .bu { height: 46px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
