/* MultiHard DJ — layout: barra fina no topo, telas dos decks, controladora ocupando o resto */
:root {
  --bg: #08080a;
  --panel: #121215;
  --panel-2: #1b1b20;
  --line: #2d2d35;
  --text: #ececf1;
  --muted: #9494a0;
  --red: #ff2a3c;
  --red-deep: #8a1320;
  --green: #5be36e;
  --font-ui: "Helvetica Neue", Helvetica, Arial, "Liberation Sans", sans-serif;
  --font-num: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text); font: 13px/1.35 var(--font-ui);
  overflow: hidden; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
[hidden] { display: none !important; }

#app { height: 100%; display: flex; flex-direction: column; background: radial-gradient(120% 80% at 50% 0%, #17171b 0%, var(--bg) 60%); }

/* ---------- barra superior ---------- */
#topbar { display: flex; align-items: center; gap: 10px; padding: 5px 10px; min-height: 38px; border-bottom: 1px solid var(--line); background: linear-gradient(#17171b, #0e0e11); flex: none; }
.tb-left, .tb-right { display: flex; align-items: center; gap: 8px; flex: 1 1 0; min-width: 0; }
.tb-right { justify-content: flex-end; }
.brand { font-weight: 800; font-style: italic; font-size: 16px; letter-spacing: .01em; white-space: nowrap; }
.chip { border: 1px solid var(--red-deep); background: rgba(255, 42, 60, .08); color: #ffd9dc; border-radius: 4px; padding: 3px 8px; font: 700 11px/1.2 var(--font-num); letter-spacing: .04em; white-space: nowrap; }
.chip.warn { background: var(--red); color: #fff; border-color: var(--red); }
.tb-views { display: flex; gap: 2px; background: #050506; border: 1px solid var(--line); border-radius: 5px; padding: 2px; flex: none; }
.tb-views button { border: 0; background: transparent; color: var(--muted); font-weight: 700; font-size: 11px; letter-spacing: .05em; padding: 4px 9px; border-radius: 3px; }
.tb-views button.on { background: var(--red); color: #fff; box-shadow: 0 0 10px rgba(255, 42, 60, .55); }
.tb-btn { border: 1px solid #4a4a55; background: linear-gradient(#26262c, #141418); border-radius: 4px; padding: 4px 10px; font-weight: 700; font-size: 11px; letter-spacing: .06em; white-space: nowrap; }
.tb-btn:hover { border-color: #8a8a96; }
.tb-btn.on { border-color: var(--red); color: #fff; box-shadow: 0 0 10px rgba(255, 42, 60, .5), inset 0 0 8px rgba(255, 42, 60, .35); }
.tb-master { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 10px; letter-spacing: .08em; color: var(--muted); }
.tb-master input { width: 92px; }
input[type=range] { accent-color: var(--red); height: 18px; }

/* ---------- telas dos decks ---------- */
#screens { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 6px 8px 4px; flex: none; }
.scr { min-width: 0; background: linear-gradient(#131317, #0a0a0c); border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px 6px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04), inset 0 0 22px rgba(0, 0, 0, .7); }
.scr.loaded { border-color: #4b2227; }
.scr-top { display: flex; align-items: center; gap: 8px; min-width: 0; height: 22px; }
.scr-num { flex: none; width: 20px; height: 20px; border-radius: 3px; background: var(--red); color: #fff; font-weight: 800; font-size: 13px; display: grid; place-items: center; box-shadow: 0 0 8px rgba(255, 42, 60, .6); }
.scr-title { flex: 1 1 auto; min-width: 0; font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scr:not(.loaded) .scr-title { color: var(--muted); font-weight: 400; }
.scr-data { flex: none; display: flex; align-items: baseline; gap: 9px; font-family: var(--font-num); font-variant-numeric: tabular-nums; white-space: nowrap; }
.scr-bpm { color: var(--red); font-weight: 700; font-size: 15px; text-shadow: 0 0 8px rgba(255, 42, 60, .6); }
.scr-bpm small { font-size: 9px; color: var(--muted); margin-left: 3px; text-shadow: none; letter-spacing: .06em; }
.scr-pitch { font-size: 11px; color: #d7d7de; min-width: 6.2ch; text-align: right; }
.scr-time { font-size: 12px; }
.scr-time i { font-style: normal; color: var(--muted); }
.scr-tag { flex: none; border: 1px solid #44444e; background: transparent; border-radius: 3px; padding: 0 5px; height: 18px; font: 700 10px/16px var(--font-num); color: var(--muted); }
button.scr-tag.on { border-color: var(--red); color: #fff; background: rgba(255, 42, 60, .22); }
.scr-mode { color: #ffd9dc; border-color: var(--red-deep); }
.scr-body { display: flex; gap: 5px; margin-top: 4px; }
.scr-waves { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.scr canvas { display: block; width: 100%; background: #050507; border-radius: 3px; touch-action: none; }
.scr-wave { height: 54px; cursor: grab; }
.scr-wave:active { cursor: grabbing; }
.scr-over { height: 16px; cursor: pointer; }
.scr-lvl { flex: none; width: 6px; border-radius: 2px; background: #050507; position: relative; overflow: hidden; }
.scr-lvl i { position: absolute; inset: 0; transform-origin: 50% 100%; transform: scaleY(0); background: linear-gradient(to top, var(--green) 0 70%, #ffd23a 70% 86%, var(--red) 86%); }

/* ---------- palco / controladora ---------- */
#stage { flex: 1 1 auto; min-height: 0; position: relative; overflow: hidden; touch-action: none; }
#ctl { position: absolute; left: 0; top: 0; width: 1860px; height: 846px; transform-origin: 0 0; background: url(../img/deck_off.webp) 0 0 / 1860px 846px no-repeat; will-change: transform; }
#ctl > * { position: absolute; }
.lit { position: absolute; inset: 0; background: url(../img/deck_on.webp) no-repeat; background-size: 1860px 846px; opacity: 0; transition: opacity .05s linear; pointer-events: none; }
.on > .lit { opacity: 1; }
.round, .round > .lit { border-radius: 50%; }
.btn { cursor: pointer; border-radius: 6px; }
.btn.down > .lit { opacity: 1; }

.pad { cursor: pointer; border-radius: 6px; }
.pad .fill { position: absolute; inset: 9px; border-radius: 4px; background: radial-gradient(ellipse at 50% 45%, rgba(255, 120, 120, .95), rgba(255, 30, 50, .75) 55%, rgba(255, 30, 50, .25)); box-shadow: 0 0 16px 4px rgba(255, 42, 60, .7); opacity: 0; transition: opacity .12s ease-out; pointer-events: none; }
.pad.down .fill { opacity: 1; transition: none; }
.pad.on .fill { opacity: .22; }
.pad.on.down .fill { opacity: 1; }
.pad span { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center; font: 800 13px/1 var(--font-ui); letter-spacing: .03em; color: rgba(255, 255, 255, .55); pointer-events: none; text-shadow: 0 1px 2px #000; }
.pad.on span, .pad.down span { color: #fff; }

.knob { cursor: ns-resize; border-radius: 50%; }
.knob-cap { position: absolute; border-radius: 50%; background: url(../img/deck_off.webp) no-repeat; background-size: 1860px 846px; will-change: transform; pointer-events: none; }

.fader-hit { cursor: pointer; }
.cap { pointer-events: none; will-change: transform; filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .75)); -webkit-user-drag: none; }

.jog { border-radius: 50%; cursor: grab; }
.jog:active { cursor: grabbing; }
.jog .jog-ring { inset: auto; }
.jog-disc { position: absolute; border-radius: 50%; overflow: hidden; will-change: transform; pointer-events: none; }
.jog-disc i { position: absolute; inset: 0; background-repeat: no-repeat; background-size: 1860px 846px; }
.jog-disc .d-off { background-image: url(../img/deck_off.webp); }
.jog-disc .d-on { background-image: url(../img/deck_on.webp); opacity: 0; transition: opacity .25s; }
.jog.on .d-on { opacity: 1; }

.led { pointer-events: none; }
.led > .lit { transition: none; }

/* ---------- biblioteca ---------- */
#library { position: fixed; left: 0; right: 0; bottom: 0; height: min(64%, 600px); z-index: 30; display: flex; flex-direction: column; background: linear-gradient(#17171b, #0b0b0d); border-top: 2px solid var(--red); box-shadow: 0 -12px 40px rgba(0, 0, 0, .8), 0 -2px 18px rgba(255, 42, 60, .35); transform: translateY(104%); transition: transform .2s ease-out; visibility: hidden; -webkit-user-select: text; user-select: text; }
#library.open { transform: none; visibility: visible; }
.lib-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.lib-title { font-size: 13px; letter-spacing: .08em; }
.lib-folder { color: var(--muted); font-size: 12px; max-width: 26ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-target { display: flex; align-items: center; gap: 4px; margin-left: auto; font-size: 11px; color: var(--muted); }
.lib-target button { border: 1px solid #4a4a55; background: #141418; border-radius: 4px; padding: 4px 9px; font-weight: 700; font-size: 11px; letter-spacing: .05em; color: var(--muted); }
.lib-target button.on { border-color: var(--red); background: var(--red); color: #fff; }
#lib-search { flex: 1 1 140px; min-width: 110px; max-width: 280px; background: #050507; border: 1px solid #3a3a44; border-radius: 4px; padding: 5px 8px; font-size: 14px; }
.act { border: 1px solid #5a5a66; background: linear-gradient(#2a2a31, #17171b); border-radius: 4px; padding: 5px 10px; font-weight: 700; font-size: 12px; white-space: nowrap; }
.act:hover { border-color: #a0a0ac; }
.x { border: 0; background: transparent; color: var(--muted); font-size: 16px; padding: 4px 8px; }
.x:hover { color: #fff; }
.lib-note { padding: 0 10px; font-size: 12px; color: var(--muted); }
.lib-note:not(:empty) { padding: 7px 10px; border-bottom: 1px solid var(--line); }
.lib-note button { margin-left: 6px; }
.lib-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; outline: none; }
.lib-group { padding: 6px 10px 3px; font-size: 10px; font-weight: 700; letter-spacing: .1em; color: var(--muted); position: sticky; top: 0; background: #101013; z-index: 1; }
.lib-row { display: flex; align-items: center; gap: 8px; padding: 0 6px 0 10px; height: 34px; border-bottom: 1px solid rgba(255, 255, 255, .04); cursor: default; }
.lib-row:hover { background: rgba(255, 255, 255, .04); }
.lib-row.sel { background: linear-gradient(90deg, rgba(255, 42, 60, .38), rgba(255, 42, 60, .1)); box-shadow: inset 3px 0 0 var(--red); }
.lib-row .nm { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.lib-row .nm small { color: var(--muted); margin-left: 8px; font-size: 11px; }
.lib-row .sz { flex: none; color: var(--muted); font: 11px var(--font-num); }
.lib-row .ld { flex: none; width: 30px; height: 24px; border: 1px solid #4a4a55; background: #141418; border-radius: 4px; font-weight: 800; font-size: 12px; }
.lib-row .ld:hover { border-color: var(--red); background: var(--red); color: #fff; }
.lib-row.on1 .ld[data-d="0"], .lib-row.on2 .ld[data-d="1"] { border-color: var(--red); color: #ff8b95; }
.lib-empty { padding: 18px 14px; color: var(--muted); font-size: 13px; max-width: 70ch; }
.lib-foot { padding: 6px 10px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); }

/* ---------- modais ---------- */
.modal, #power { position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, .72); -webkit-user-select: text; user-select: text; }
.modal.open, #power.open { display: flex; }
.card, .power-card { position: relative; width: min(560px, 100%); max-height: 100%; overflow-y: auto; background: linear-gradient(#1a1a1f, #0e0e11); border: 1px solid #3a3a44; border-top: 2px solid var(--red); border-radius: 8px; padding: 18px 20px 16px; box-shadow: 0 20px 60px #000, 0 0 30px rgba(255, 42, 60, .18); }
.card.wide { width: min(820px, 100%); }
.card h2 { margin: 0 28px 12px 0; font-size: 17px; font-style: italic; font-weight: 800; text-wrap: balance; }
.card h3 { margin: 12px 0 3px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: #ff8b95; }
.card p { margin: 0 0 8px; }
.card .x { position: absolute; right: 8px; top: 8px; }
.lead { color: #d7d7de; }
.field { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.field > label:not(.opt), .field legend, .field.two label { display: block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; padding: 0; }
.field select, .field input[type=text], .field input[type=email], #pro-key { width: 100%; background: #050507; border: 1px solid #3a3a44; border-radius: 4px; padding: 7px 8px; font-size: 14px; min-width: 0; }
.field input[type=range] { width: 100%; }
.field.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row { display: flex; gap: 8px; align-items: center; }
.row select, .row input { flex: 1 1 auto; }
.opt { display: flex; gap: 8px; align-items: flex-start; padding: 5px 0; font-size: 13px; cursor: pointer; }
.opt input { margin-top: 2px; accent-color: var(--red); }
.opt.off { opacity: .45; }
.hint { font-size: 12px; color: var(--muted); margin: 5px 0 0; }
.status { min-height: 1.3em; font-size: 12px; color: #ffb3ba; margin: 4px 0 0; }
.status.ok { color: var(--green); }
.caps { list-style: none; margin: 0; padding: 0; font-size: 12px; }
.caps li::before { content: "✓ "; color: var(--green); font-weight: 700; }
.caps li.no { color: var(--muted); }
.caps li.no::before { content: "✕ "; color: var(--muted); }
.primary { border: 1px solid var(--red); background: linear-gradient(#ff4253, #c9162a); color: #fff; font-weight: 800; letter-spacing: .06em; border-radius: 5px; padding: 9px 16px; box-shadow: 0 0 16px rgba(255, 42, 60, .45); }
.primary.big { font-size: 18px; padding: 13px 40px; }
.link { border: 0; background: transparent; color: var(--muted); text-decoration: underline; padding: 6px 0; }
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 14px; }
.plan { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; background: #0c0c0f; }
.plan h3 { margin: 0 0 4px; color: var(--text); }
.plan h3 small { color: var(--muted); letter-spacing: .04em; text-transform: none; font-weight: 400; }
.plan p, .plan ul { margin: 0; padding: 0; list-style: none; font-size: 12px; color: var(--muted); }
.plan.cur { border-color: var(--red); box-shadow: inset 0 0 14px rgba(255, 42, 60, .18); }
.plan.cur h3 { color: #ff8b95; }
.who { font-size: 14px; }
.who span { color: var(--muted); font-size: 12px; }
.help { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 26px; font-size: 13px; }
.help p { color: #d7d7de; max-width: 62ch; }
kbd { font: 700 11px var(--font-num); border: 1px solid #55555f; border-bottom-width: 2px; border-radius: 3px; padding: 0 5px; background: #1d1d22; }

#power { z-index: 60; background: rgba(0, 0, 0, .78); }
.power-card { text-align: center; width: min(430px, 100%); padding: 26px 24px 20px; }
.power-card h1 { margin: 0 0 8px; font-size: 30px; font-style: italic; font-weight: 800; }
.power-card p { margin: 0 0 16px; color: #c9c9d2; }
.power-card .hint { margin-top: 14px; }

#toast { position: fixed; left: 50%; top: 52px; transform: translate(-50%, -8px); z-index: 70; max-width: min(92vw, 560px); background: #17171b; border: 1px solid var(--red); border-radius: 6px; padding: 8px 14px; font-size: 13px; box-shadow: 0 8px 30px #000, 0 0 16px rgba(255, 42, 60, .3); opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#drop-hint { position: fixed; inset: 0; z-index: 65; display: none; align-items: center; justify-content: center; background: rgba(255, 42, 60, .16); border: 3px dashed var(--red); font-size: 18px; font-weight: 800; pointer-events: none; text-align: center; padding: 20px; }
#drop-hint.show { display: flex; }

/* ---------- telas menores ---------- */
@media (max-width: 900px) {
  .brand { display: none; }
  .tb-master span { display: none; }
  .tb-master input { width: 64px; }
  .scr-pitch, .scr-mode { display: none; }
}
@media (max-width: 640px) {
  #topbar { gap: 6px; padding: 4px 6px; flex-wrap: wrap; }
  .tb-left { flex: 0 0 auto; }
  .tb-right { flex: 1 1 auto; gap: 5px; }
  .tb-views { order: 3; flex: 1 1 100%; }
  .tb-views button { flex: 1; padding: 6px 4px; }
  .tb-btn { padding: 5px 8px; }
  #screens { grid-template-columns: 1fr; gap: 4px; padding: 4px 6px 2px; }
  .scr-wave { height: 40px; }
  .scr-over { height: 12px; }
  .scr-data { gap: 6px; }
  .field.two, .help { grid-template-columns: 1fr; }
  .plans { grid-template-columns: 1fr; }
  #library { height: 78%; }
  .lib-target { margin-left: 0; }
  .lib-foot { display: none; }
}
@media (max-height: 480px) {
  #topbar { min-height: 30px; padding: 2px 8px; }
  #screens { padding: 3px 6px 2px; }
  .scr { padding: 3px 6px 4px; }
  .scr-wave { height: 30px; }
  .scr-over { height: 9px; }
  #library { height: 88%; }
}
@media (prefers-reduced-motion: reduce) {
  #library, #toast, .lit, .pad .fill, .jog-disc .d-on { transition: none; }
}
