:root {
  --bg: #0f0d0c;
  --body: #26221f;
  --panel: #2f2a26;
  --edge: #14110f;
  --cream: #e9dfc8;
  --dim: #9b907c;
  --orange: #e8541e;
  --amber: #ffb02e;
  --led-off: #3a2420;
  --wood1: #7a4a2a;
  --wood2: #54301a;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--cream); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
body { min-height: 100vh; display: flex; justify-content: center; padding: 20px 0; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, .knob:focus-visible, select:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

.unit { display: flex; width: min(1080px, 100%); border-radius: 10px; box-shadow: 0 30px 80px #000a; }
.cheek { width: 28px; flex: none; background:
  repeating-linear-gradient(90deg, #0000 0 3px, #0002 3px 4px),
  linear-gradient(180deg, var(--wood1), var(--wood2)); }
.cheek:first-child { border-radius: 10px 0 0 10px; }
.cheek:last-child { border-radius: 0 10px 10px 0; }
.body { flex: 1; min-width: 0; padding: 18px; background: linear-gradient(180deg, #2c2824, var(--body)); display: grid; gap: 14px; }

.top { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.brand h1 { margin: 0; font-size: 34px; letter-spacing: 3px; font-weight: 300; line-height: 1; }
.brand h1 b { font-weight: 800; color: var(--orange); }
.brand p { margin: 2px 0 0; color: var(--dim); letter-spacing: 6px; font-size: 11px; text-transform: uppercase; }
.lcd { margin-left: auto; background: #1b0d09; border: 2px solid var(--edge); border-radius: 6px; padding: 6px 14px; min-width: 220px;
  font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--orange); text-shadow: 0 0 8px #e8541e88; box-shadow: inset 0 0 14px #000; }
.lcd #bpm { font-size: 32px; font-weight: 700; }
.lcd small { margin-left: 6px; font-size: 11px; opacity: .8; }
.lcd #patname { font-size: 13px; letter-spacing: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leds { display: flex; align-items: center; gap: 12px; }
.led, #beatLeds i { display: block; width: 12px; height: 12px; border-radius: 50%; background: var(--led-off); border: 1px solid #000; }
.led.on { background: #5dff7a; box-shadow: 0 0 10px #5dff7a; }
#beatLeds { display: flex; gap: 8px; }
#beatLeds i.on { background: var(--orange); box-shadow: 0 0 10px var(--orange); }

.panel { background: var(--panel); border: 1px solid var(--edge); border-radius: 8px; padding: 12px 14px; box-shadow: inset 0 1px 0 #ffffff10; }
.panel h2 { margin: 0 0 10px; font-size: 11px; letter-spacing: 3px; text-transform: uppercase; color: var(--dim); font-weight: 600; }

.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.pbtn { display: flex; flex-direction: column; align-items: flex-start; text-align: left; background: #3b352f; border: 1px solid var(--edge); border-bottom-width: 3px; border-radius: 5px; padding: 5px 8px; transition: background .1s; }
.pbtn small { color: var(--dim); font: 10px ui-monospace, Menlo, monospace; }
.pbtn span { font-size: 12.5px; }
.pbtn:hover { background: #4a423a; }
.pbtn.user span { color: var(--amber); }
.pbtn.sel { background: var(--orange); color: #fff; border-bottom-color: #8e2d0a; }
.pbtn.sel small { color: #ffe1d3; }
.pbtn:active { transform: translateY(1px); }

.controls { display: flex; gap: 20px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.knobrow { display: flex; gap: 22px; align-items: flex-end; flex-wrap: wrap; }
.btnrow { display: flex; gap: 10px; }
.big { min-width: 96px; height: 52px; background: #ddd2b8; color: #1b1612; border: 1px solid #000; border-bottom-width: 4px; border-radius: 6px; font-weight: 700; letter-spacing: 2px; position: relative; }
.big::after { content: ""; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--led-off); }
.big.on::after { background: var(--orange); box-shadow: 0 0 8px var(--orange); }
#startBtn.on { background: #ff8a5c; }
.big.alt { background: #b8ad95; }
.big:active { border-bottom-width: 2px; transform: translateY(2px); }

/* Perillas */
.knob { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 64px; touch-action: none; user-select: none; cursor: ns-resize; }
.knob b { font-size: 10px; letter-spacing: 1.5px; color: var(--dim); font-weight: 600; }
.knob output { font: 11px ui-monospace, Menlo, monospace; color: var(--cream); }
.dial { width: 46px; height: 46px; border-radius: 50%; position: relative; background: radial-gradient(circle at 35% 30%, #5a5148, #17130f 75%); border: 2px solid #000; box-shadow: 0 3px 6px #0008; }
.dial i { position: absolute; inset: 0; }
.dial i::after { content: ""; position: absolute; left: 50%; top: 4px; width: 3px; height: 14px; margin-left: -1.5px; border-radius: 2px; background: var(--cream); }
.knob.lg .dial { width: 62px; height: 62px; }
.knob.lg { width: 80px; }
.knob.lg .dial i::after { height: 18px; background: var(--orange); }
.knob.small { width: 52px; }
.knob.small .dial { width: 34px; height: 34px; }
.knob.small .dial i::after { height: 10px; width: 2px; top: 3px; }
.knob.drag .dial { border-color: var(--amber); }

/* Secuenciador */
.seqhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.seqhead h2 { margin: 0; }
.tools { display: flex; gap: 6px; flex-wrap: wrap; }
select, .mini { background: #3b352f; color: var(--cream); border: 1px solid var(--edge); border-radius: 5px; padding: 5px 9px; font-size: 12px; }
.mini:hover, select:hover { background: #4a423a; }

.grid { display: grid; grid-template-columns: 34px repeat(var(--steps), minmax(0, 1fr)); gap: 3px; }
.rowlabel { background: none; border: 0; text-align: left; font: 11px ui-monospace, Menlo, monospace; color: var(--dim); padding: 0; }
.rowlabel:hover { color: var(--amber); }
.cell { aspect-ratio: 1 / 1; min-height: 18px; border: 1px solid var(--edge); border-radius: 3px; background: #231f1c; padding: 0; transition: background .06s; }
.cell.beat { background: #2e2824; }
.cell.vx { background: #c9622f; }
.cell.vX { background: var(--amber); box-shadow: 0 0 8px #ffb02e66; }
.cell.vg { background: #5c4637; }
.cell.head { outline: 2px solid #fff8; outline-offset: -2px; filter: brightness(1.5); }
.hint { margin: 8px 0 0; font-size: 11.5px; color: var(--dim); }

.mixer { display: flex; flex-wrap: wrap; gap: 8px 4px; }

footer { color: var(--dim); font-size: 11.5px; }
footer p { margin: 3px 0; }
kbd { background: #3b352f; border: 1px solid var(--edge); border-radius: 3px; padding: 0 5px; font: 11px ui-monospace, Menlo, monospace; color: var(--cream); }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); background: var(--cream); color: #1b1612; padding: 8px 16px; border-radius: 20px; opacity: 0; pointer-events: none; transition: .2s; font-weight: 600; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  body { padding: 0; }
  .cheek { width: 8px; }
  .body { padding: 12px; }
  .unit { border-radius: 0; }
  .lcd { margin-left: 0; width: 100%; }
  .knobrow { gap: 12px; justify-content: space-between; width: 100%; }
  .btnrow { width: 100%; }
  .big { flex: 1; min-width: 0; }
  .grid { grid-template-columns: 28px repeat(var(--steps), minmax(0, 1fr)); gap: 2px; }
  .cell { min-height: 16px; }
}

/* ---- Colaboración, muro, ranking, diálogos (portado de XTN Tuner) ---- */
:root { --ink: #e9dfc8; --metal-hi: #3b352f; --metal-lo: #2a2521; --lcd: #ff7a45; --lcd-dim: #b0603f; --lcd-bg: #1b0d09; }
[hidden] { display: none !important; }
.collab, .feature, .board, .credit { width: 100%; max-width: 420px; margin: 0 auto; }
.collab { padding: 12px; border-radius: 12px; text-align: center; background: linear-gradient(var(--metal-hi), var(--metal-lo)); border: 2px solid #000; }
.collab p { margin: 0 0 8px; font-size: 12px; opacity: .85; }
.donate { width: 100%; min-height: 44px; border: 0; border-radius: 999px; background: var(--ink); color: #1b1b1b; font-weight: 800; font-size: 15px; box-shadow: 0 3px 0 #0009; }
.feature { padding: 14px; border-radius: 12px; text-align: center; border: 2px solid #000; background: radial-gradient(ellipse at 50% -20%, #5a2a6b 0%, #25122e 70%); }
.eyebrow { font-size: 10px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; color: #ffd36b; }
.feature h2 { margin: 4px 0; font-size: 20px; line-height: 1.15; letter-spacing: 0; text-transform: none; color: var(--cream); }
.feature p { margin: 0 0 10px; font-size: 12px; opacity: .8; }
.feature-btns { display: flex; gap: 8px; }
.feature-btns a { flex: 1; text-decoration: none; padding: 10px 6px; border-radius: 999px; font-weight: 800; font-size: 13px; }
.feature-btns .play { background: #ffd36b; color: #2a1500; box-shadow: 0 3px 0 #0009; }
.feature-btns .sub { border: 2px solid var(--ink); color: var(--ink); padding: 8px 6px; }
.join { margin-top: 8px; width: 100%; padding: 8px 10px; border-radius: 10px; border: 2px dashed #ffd36b; background: transparent; color: #ffd36b; font-weight: 700; font-size: 12px; }
.join small { font-weight: 600; opacity: .85; }
.tracks:empty { display: none; }
.tracks { margin: 0 0 10px; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.track { background: rgba(0,0,0,.35); border-radius: 10px; padding: 8px 10px; }
.track small { display: block; opacity: .7; font-size: 11px; margin-bottom: 4px; }
.track audio { width: 100%; height: 36px; }
.soon { font-size: 12px; opacity: .75; }
.tlinks { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tlinks a { font-size: 12px; font-weight: 700; color: var(--ink); text-decoration: none; border: 1px solid var(--ink); border-radius: 999px; padding: 4px 10px; }
.wall { text-align: left; margin: 0 0 10px; padding: 8px 10px; border-radius: 10px; background: var(--lcd-bg); border: 2px solid #000; box-shadow: inset 0 0 10px #000; }
.wall-title { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--lcd-dim); margin-bottom: 4px; font-weight: 800; }
.wall ul { list-style: none; margin: 0; padding: 0; font-size: 13px; color: var(--lcd); }
.wall li { padding: 2px 0; } .wall li.empty { opacity: .75; }
.board { padding: 12px; border-radius: 12px; border: 2px solid #000; background: var(--lcd-bg); box-shadow: inset 0 0 14px #000; color: var(--lcd); }
.board .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.board ol { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.board li { padding: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .board li.empty { opacity: .6; white-space: normal; }
.board li i { font-style: normal; opacity: .6; margin-left: 4px; }
.rank-opt { display: block; margin-top: 10px; font-size: 12px; cursor: pointer; }
.rank-opt span { opacity: .6; font-size: 11px; }
.rank-row { display: flex; gap: 6px; margin-top: 6px; }
.rank-row input { flex: 1; min-width: 0; min-height: 38px; padding: 0 10px; border-radius: 8px; border: 2px solid #000; background: #0a0605; color: var(--lcd); font-size: 14px; }
.rank-row button { min-height: 38px; padding: 0 14px; border-radius: 8px; border: 2px solid #000; background: var(--ink); color: #1b1b1b; font-weight: 800; font-size: 13px; }
.credit { text-align: center; font-size: 12px; display: flex; flex-direction: column; gap: 6px; align-items: center; max-width: none; }
.credit a { color: var(--ink); }
.credit .ver { font-size: 11px; opacity: .75; }
.credit .hablemos { text-decoration: none; font-weight: 700; border: 1px solid var(--ink); border-radius: 999px; padding: 6px 14px; }
.credit p { margin: 2px 0; color: var(--dim); }
dialog { border: 2px solid #000; border-radius: 16px; color: var(--ink); padding: 18px; width: calc(100% - 32px); max-width: 340px; background: linear-gradient(var(--metal-hi), var(--metal-lo)); box-shadow: 0 20px 50px #000; }
dialog::backdrop { background: rgba(0,0,0,.7); }
dialog h3 { margin: 0 0 4px; font-size: 18px; } dialog p { margin: 0 0 12px; opacity: .8; font-size: 13px; }
.fl { display: block; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; opacity: .85; margin-bottom: 10px; }
.fl input { display: block; width: 100%; margin-top: 4px; min-height: 42px; padding: 0 12px; border-radius: 10px; border: 2px solid #000; font-size: 16px; background: var(--lcd-bg); color: var(--lcd); }
.seg { display: flex; gap: 6px; margin-bottom: 10px; }
.seg button { flex: 1; min-height: 36px; border-radius: 10px; border: 2px solid #000; font-weight: 800; font-size: 13px; background: linear-gradient(var(--metal-hi), var(--metal-lo)); }
.seg button.on { background: var(--ink); color: #1b1b1b; }
.qty { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 12px; }
.qty button { width: 40px; height: 40px; border-radius: 10px; border: 2px solid #000; font-size: 20px; font-weight: 800; background: linear-gradient(var(--metal-hi), var(--metal-lo)); }
.qty b { font-size: 20px; }
#payOpts, #payLegacy { display: flex; flex-direction: column; gap: 8px; }
.pay { display: block; text-align: left; text-decoration: none; color: var(--ink); border: 2px solid var(--ink); border-radius: 12px; padding: 10px 14px; background: transparent; }
.pay b { display: block; font-size: 16px; } .pay span { font-size: 12px; opacity: .8; }
.pay.first { background: var(--ink); color: #1b1b1b; }
button.pay:disabled { opacity: .5; cursor: default; }
.pay-msg { min-height: 18px; margin-top: 8px; font-size: 12px; text-align: center; }
.close { margin-top: 12px; width: 100%; min-height: 40px; border-radius: 10px; border: 2px solid #000; font-weight: 700; font-size: 14px; background: linear-gradient(var(--metal-hi), var(--metal-lo)); }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); width: calc(100% - 32px); max-width: 340px; padding: 12px 14px; background: var(--ink); color: #1b1b1b; border-radius: 12px; font-weight: 700; text-align: center; box-shadow: 0 10px 30px #000; z-index: 20; }

.brand h1 .vtag { font-size: 11px; font-weight: 800; letter-spacing: .08em; color: var(--dim); vertical-align: middle; margin-left: 6px; }
.howto ol { margin: 0 0 8px; padding-left: 20px; }
.howto li { margin: 4px 0; font-size: 13px; color: #ddd3bd; }
.howto .keys { margin: 4px 0; font-size: 12px; color: var(--dim); }
.howto a { color: #9ec8ff; }

/* ---- v1.3: fills, fade, originales, muestras ---- */
.btnrow { flex-wrap: wrap; }
.fadegrp { display: flex; flex-direction: column; gap: 3px; }
.fadegrp .big { height: 36px; min-width: 96px; }
.fadegrp select { padding: 2px 6px; font-size: 11px; }
.big.on::after { background: var(--orange); box-shadow: 0 0 8px var(--orange); }
.subrow { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12px; color: var(--dim); }
.subrow #origInfo { margin-right: auto; }
.chg { color: var(--amber); font-weight: 700; }
.pbtn.mod::after { content: "●"; position: absolute; top: 4px; right: 6px; font-size: 9px; color: var(--amber); }
.pbtn { position: relative; }
.pbtn.sel.mod::after { color: #fff; }
.samples { display: flex; flex-direction: column; gap: 8px; }
.smp { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.smp b { font: 700 12px ui-monospace, Menlo, monospace; color: var(--amber); width: 24px; }
.smp-st { font-size: 12px; color: var(--dim); min-width: 150px; }
.smp-rec.on { background: #b3261e; color: #fff; }
.mini:disabled { opacity: .4; cursor: default; }
.filebtn { cursor: pointer; display: inline-block; }
.howto details { margin: 6px 0; }
.howto summary { cursor: pointer; font-size: 13px; color: var(--amber); }
.howto dl { margin: 8px 0 0; font-size: 12.5px; }
.howto dt { font-weight: 700; color: var(--cream); margin-top: 6px; }
.howto dd { margin: 0 0 0 12px; color: #ddd3bd; }

/* ---- v1.3.2: móvil, botones iguales, desplegable, marcas de original ---- */
html, body { overflow-x: hidden; }
.body { grid-template-columns: minmax(0, 1fr); }
.panel, .feature, .collab, .board { min-width: 0; }
.controls { flex-direction: column; align-items: stretch; }
.knobrow { justify-content: space-between; }
.btnrow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; width: 100%; }
.btnrow .big { min-width: 0; width: 100%; height: 52px; flex: none; }
.big-sel { height: 52px; width: 100%; min-width: 0; font-weight: 700; letter-spacing: .5px; text-align: center; }
.fadegrp { display: contents; }
@media (min-width: 900px) { .btnrow { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.howto summary { cursor: pointer; font: 700 14px system-ui, sans-serif; color: var(--cream); padding: 10px 14px; border: 1px solid var(--edge); border-radius: 6px; background: #3b352f; list-style: none; text-align: center; }
.howto summary::-webkit-details-marker { display: none; }
.howto details[open] summary { background: var(--orange); color: #fff; }
.howto details > :not(summary) { margin-top: 10px; }
.howto h3 { margin: 12px 0 0; font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--dim); }
.cell.chg { outline: 2px dashed var(--amber); outline-offset: -3px; }
.cell.head.chg { outline-style: solid; }
b.chg { color: var(--amber); }
.knob .note { min-height: 12px; font: 10px ui-monospace, Menlo, monospace; color: var(--amber); }
.dial .mk { position: absolute; inset: 0; pointer-events: none; }
.dial .mk::after { content: ""; position: absolute; left: 50%; top: -7px; width: 7px; height: 7px; margin-left: -3.5px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.dial .mk[hidden] { display: none; }
@media (max-width: 640px) {
  .knobrow { gap: 6px; }
  .knob.lg { width: 70px; } .knob { width: 56px; }
  .btnrow { gap: 8px; }
  .tools { width: 100%; }
  .tools select, .tools .mini { flex: 1 1 auto; }
  .smp-st { min-width: 0; flex: 1 1 100%; }
  .smp b { width: auto; }
}
.subrow { flex-basis: auto; width: 100%; }
.big-sel { font-size: 12px; letter-spacing: 0; padding: 0 4px; }

/* ---- v1.3.3: evita glitches de pintado y selección con doble clic ---- */
button, .knob, .pbtn, .cell, summary { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.knob { touch-action: none; }
.cell.head { filter: none; box-shadow: inset 0 0 0 100px rgba(255, 255, 255, .28); }
.big:active { transform: none; border-bottom-width: 2px; }
.big:active { padding-top: 2px; }
.btnrow { isolation: isolate; }

/* ---- v1.3.4: cabecera estable (no se mueve al cambiar de ritmo) ---- */
.top { min-height: 78px; }
.lcd { width: 260px; flex: none; }
.lcd #bpm { display: inline-block; min-width: 3ch; text-align: right; font-variant-numeric: tabular-nums; }
.lcd #patname { max-width: 100%; }
.leds { flex: none; width: 128px; justify-content: flex-end; }
#beatLeds { min-width: 76px; justify-content: flex-end; }
@media (max-width: 640px) { .lcd { width: 100%; } .leds { width: 100%; justify-content: flex-start; } #beatLeds { justify-content: flex-start; } }

/* ---- v1.3.5: botones sin trucos de borde, arrastre de perillas aislado, BPM editable ---- */
.big { -webkit-appearance: none; appearance: none; border: 1px solid #000; border-bottom-width: 1px; box-shadow: 0 4px 0 #000, inset 0 1px 0 rgba(255,255,255,.4); position: relative; top: 0; margin-bottom: 4px; background-clip: padding-box; }
.big:active { border-bottom-width: 1px; padding-top: 0; transform: none; top: 3px; box-shadow: 0 1px 0 #000, inset 0 1px 0 rgba(255,255,255,.4); }
.btnrow { isolation: auto; }
body.dragging, body.dragging * { cursor: ns-resize !important; -webkit-user-select: none; user-select: none; }
body.dragging *:not(.knob.drag):not(.knob.drag *) { pointer-events: none; }
.lcd input#bpm { width: 3.4ch; background: transparent; border: 0; border-bottom: 1px dashed transparent; padding: 0; margin: 0; color: inherit; font: inherit; font-size: 32px; font-weight: 700; text-shadow: inherit; text-align: right; outline: none; -moz-appearance: textfield; }
.lcd input#bpm:hover, .lcd input#bpm:focus { border-bottom-color: var(--orange); }
.lcd input#bpm::-webkit-outer-spin-button, .lcd input#bpm::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---- v1.3.8: el cuerpo apila en columna para que "Más apps" quede debajo de la app ---- */
body { flex-direction: column; align-items: center; }
#xtnApps { width: 100%; }
