/* ---------- Temas ---------- */
:root, [data-theme="medianoche"] {
  --bg1: #070b1f; --bg2: #121f4d; --glow1: rgba(82, 124, 255, .38); --glow2: rgba(130, 96, 255, .22);
  --text: #eef2ff; --muted: rgba(226, 232, 255, .62);
  --surface: rgba(255, 255, 255, .07); --surface2: rgba(255, 255, 255, .13); --border: rgba(255, 255, 255, .11);
  --accent: #6a94ff; --accent2: #3f6ae8; --on-accent: #fff;
  --cell-off: rgba(255, 255, 255, .08); --cell-on: #5b86f0; --beat: #cfdcff;
  --sheet: #111a3b; --track: rgba(255, 255, 255, .12); --tick: rgba(255, 255, 255, .2);
  --ring-a: #39436e; --ring-b: #252d52; --face-a: #3a4572; --face-b: #1c2347;
  --scrim: transparent; --show-dark: block; --show-light: none; --shadow: rgba(0, 0, 0, .4);
}
[data-theme="claro"] {
  --bg1: #f2f5fc; --bg2: #dbe5f8; --glow1: rgba(80, 120, 230, .22); --glow2: rgba(150, 170, 230, .25);
  --text: #0f1733; --muted: rgba(15, 23, 51, .6);
  --surface: rgba(255, 255, 255, .78); --surface2: rgba(255, 255, 255, .95); --border: rgba(15, 23, 51, .1);
  --accent: #2f5bd6; --accent2: #4a78f0; --on-accent: #fff;
  --cell-off: rgba(15, 23, 51, .08); --cell-on: #3a66e0; --beat: #0f2a8a;
  --sheet: #ffffff; --track: rgba(15, 23, 51, .12); --tick: rgba(15, 23, 51, .22);
  --ring-a: #c6d1ea; --ring-b: #aab8da; --face-a: #ffffff; --face-b: #dfe7f8;
  --scrim: #0f1733; --show-dark: none; --show-light: block; --shadow: rgba(30, 50, 110, .22);
}
[data-theme="grafito"] {
  --bg1: #0e0f12; --bg2: #1d1f26; --glow1: rgba(190, 196, 210, .16); --glow2: rgba(120, 128, 146, .14);
  --text: #f1f2f5; --muted: rgba(235, 237, 242, .58);
  --surface: rgba(255, 255, 255, .06); --surface2: rgba(255, 255, 255, .12); --border: rgba(255, 255, 255, .1);
  --accent: #d5d9e2; --accent2: #959cab; --on-accent: #14161b;
  --cell-off: rgba(255, 255, 255, .07); --cell-on: #aab0bd; --beat: #ffffff;
  --sheet: #1a1c22; --track: rgba(255, 255, 255, .12); --tick: rgba(255, 255, 255, .18);
  --ring-a: #3a3d46; --ring-b: #26282f; --face-a: #3d4049; --face-b: #1f2127;
  --scrim: transparent; --show-dark: block; --show-light: none; --shadow: rgba(0, 0, 0, .5);
}
[data-theme="aurora"] {
  --bg1: #06161a; --bg2: #14123a; --glow1: rgba(30, 220, 190, .3); --glow2: rgba(130, 100, 255, .28);
  --text: #eafffb; --muted: rgba(220, 250, 245, .62);
  --surface: rgba(255, 255, 255, .07); --surface2: rgba(255, 255, 255, .13); --border: rgba(255, 255, 255, .11);
  --accent: #35e6c4; --accent2: #7b6cff; --on-accent: #04201b;
  --cell-off: rgba(255, 255, 255, .08); --cell-on: #2fd6b8; --beat: #c8fff3;
  --sheet: #0e1d2b; --track: rgba(255, 255, 255, .12); --tick: rgba(255, 255, 255, .2);
  --ring-a: #2a4358; --ring-b: #1b2740; --face-a: #2e4a5e; --face-b: #162135;
  --scrim: transparent; --show-dark: block; --show-light: none; --shadow: rgba(0, 0, 0, .45);
}
[data-theme="ambar"] {
  --bg1: #140c05; --bg2: #2c1707; --glow1: rgba(255, 160, 40, .3); --glow2: rgba(255, 90, 40, .2);
  --text: #fff4e6; --muted: rgba(255, 238, 215, .62);
  --surface: rgba(255, 255, 255, .07); --surface2: rgba(255, 255, 255, .13); --border: rgba(255, 220, 170, .13);
  --accent: #ffb02e; --accent2: #ff7a2e; --on-accent: #2a1400;
  --cell-off: rgba(255, 255, 255, .08); --cell-on: #f59a1c; --beat: #ffe2b0;
  --sheet: #24150a; --track: rgba(255, 255, 255, .12); --tick: rgba(255, 230, 190, .2);
  --ring-a: #5a3d22; --ring-b: #3a2412; --face-a: #5e4026; --face-b: #2e1c0e;
  --scrim: transparent; --show-dark: block; --show-light: none; --shadow: rgba(0, 0, 0, .5);
}
[data-theme="carmesi"] {
  --bg1: #170610; --bg2: #35102a; --glow1: rgba(255, 70, 130, .3); --glow2: rgba(190, 60, 255, .22);
  --text: #fff0f5; --muted: rgba(255, 228, 238, .62);
  --surface: rgba(255, 255, 255, .07); --surface2: rgba(255, 255, 255, .13); --border: rgba(255, 255, 255, .11);
  --accent: #ff5c8a; --accent2: #c23dff; --on-accent: #fff;
  --cell-off: rgba(255, 255, 255, .08); --cell-on: #f0487c; --beat: #ffd0df;
  --sheet: #26101f; --track: rgba(255, 255, 255, .12); --tick: rgba(255, 255, 255, .2);
  --ring-a: #5a2b48; --ring-b: #3a1a31; --face-a: #5e2e4c; --face-b: #2c1426;
  --scrim: transparent; --show-dark: block; --show-light: none; --shadow: rgba(0, 0, 0, .5);
}

/* ---------- Base ---------- */
:root { --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg1); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  overscroll-behavior: none; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
body {
  background:
    radial-gradient(90% 40% at 12% 0%, var(--glow1), transparent 70%),
    radial-gradient(80% 45% at 100% 55%, var(--glow2), transparent 70%),
    linear-gradient(180deg, var(--bg1), var(--bg2));
  background-attachment: fixed;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
[hidden] { display: none !important; }
.scrim { position: fixed; top: 0; left: 0; right: 0; height: var(--safe-t); background: var(--scrim); z-index: 30; }

.app { height: 100dvh; display: flex; flex-direction: column; max-width: 480px; margin: 0 auto; padding: calc(var(--safe-t) + 6px) 16px 0; }
.view { display: none; flex: 1; min-height: 0; flex-direction: column; }
.view.active { display: flex; }

/* Encabezado con marca */
.topbar { display: flex; align-items: center; justify-content: space-between; height: 46px; }
.logo { height: 34px; width: auto; }
.logo-dark { display: var(--show-dark); } .logo-light { display: var(--show-light); }
.icon-btn { width: 42px; height: 42px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); font-size: 17px; display: grid; place-items: center; }

/* Tarjeta principal */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 26px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 10px 30px var(--shadow); }
.hero { padding: 14px 16px 16px; margin-top: 4px; }
.hero-top { display: flex; align-items: flex-end; justify-content: space-between; }
.bpm { display: flex; align-items: baseline; gap: 8px; text-align: left; }
.bpm span { font-size: clamp(60px, 10dvh, 84px); font-weight: 700; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.bpm small { font-size: 14px; font-weight: 600; color: var(--muted); letter-spacing: .1em; }
.tname { font-size: 17px; font-weight: 600; color: var(--accent); padding-bottom: 8px; }
.chips-row { display: flex; gap: 8px; margin: 10px 0 12px; flex-wrap: wrap; }
.chip { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 19px; background: var(--surface2); border: 1px solid var(--border); font-size: 14px; font-weight: 600; }
.chip i { color: var(--accent); }

/* Visual de patrón rítmico */
.pv { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 5px; gap: 2px; align-items: end; height: 16px; }
.pv i { display: block; height: 100%; border-radius: 2px; border: 1.5px solid var(--muted); opacity: .6; }
.pv i.h { background: var(--accent); border-color: var(--accent); opacity: 1; }

/* Pads de acento */
.pads { display: grid; gap: 6px; grid-auto-flow: column; grid-auto-columns: 1fr; height: clamp(88px, 14dvh, 128px); }
.col { display: grid; grid-template-rows: repeat(3, 1fr); gap: 4px; }
.cell { background: var(--cell-off); border-radius: 9px; transition: background .08s, box-shadow .08s; }
.cell.on { background: var(--cell-on); }
.col.beat .cell.on { background: var(--beat); box-shadow: 0 0 16px var(--accent); }
.poly-dots { display: flex; justify-content: space-between; margin-top: 10px; padding: 0 4px; }
.poly-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--cell-off); transition: background .08s, transform .08s; }
.poly-dots i.on { background: var(--accent2); transform: scale(1.5); box-shadow: 0 0 10px var(--accent2); }
.status { text-align: center; font-size: 13px; color: var(--muted); min-height: 22px; margin-top: 6px; font-weight: 500; }

/* Dial */
.dial-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; container-type: size; }
.dial { position: relative; width: min(100cqw, 100cqh, 330px); aspect-ratio: 1; touch-action: none; }
.prog { position: absolute; inset: 0; width: 100%; height: 100%; }
.prog circle { fill: none; stroke-width: 2.8; stroke-linecap: round; transform: rotate(135deg); transform-origin: 50% 50%; }
.prog .track { stroke: var(--track); stroke-dasharray: 75 100; }
.prog .val { stroke: var(--accent); stroke-dasharray: 0 100; filter: drop-shadow(0 0 3px var(--accent)); }
.knob { position: absolute; inset: 7%; border-radius: 50%; box-shadow: 0 14px 30px var(--shadow); }
.ring { position: absolute; inset: 0; border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, var(--tick) 0 2deg, transparent 2deg 6deg), radial-gradient(circle, var(--ring-a), var(--ring-b)); }
.ring::after { content: ""; position: absolute; left: 50%; top: 2.5%; width: 9px; height: 9px; margin-left: -4.5px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.face { position: absolute; inset: 11%; border-radius: 50%; background: radial-gradient(circle at 35% 25%, var(--face-a), var(--face-b));
  box-shadow: inset 0 1px 1px rgba(255,255,255,.18), 0 0 0 1px var(--border); }
.play { position: absolute; left: 50%; top: 50%; width: 34%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%;
  background: linear-gradient(145deg, var(--accent), var(--accent2)); color: var(--on-accent); font-size: clamp(26px, 8vw, 38px);
  display: grid; place-items: center; box-shadow: 0 8px 22px var(--shadow), 0 0 22px color-mix(in srgb, var(--accent) 45%, transparent); }
.play i { transform: translateX(2px); } .play.running i { transform: none; }
.play:active { transform: translate(-50%, -50%) scale(.96); }
.arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 13%; aspect-ratio: 1; font-size: 22px; color: var(--muted); }
.arrow.left { left: 13%; } .arrow.right { right: 13%; }
.arrow:active { color: var(--text); }

/* Fila inferior */
.bottom-row { display: flex; gap: 10px; align-items: center; padding: 8px 0 12px; }
.tap { flex: 1; height: 56px; border-radius: 18px; background: linear-gradient(145deg, var(--accent), var(--accent2)); color: var(--on-accent); font-size: 20px; font-weight: 800; letter-spacing: .12em; box-shadow: 0 6px 18px var(--shadow); }
.tap:active { filter: brightness(1.15); transform: scale(.98); }
.tools { display: flex; gap: 8px; }
.tools button { width: 52px; height: 56px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); font-size: 19px; color: var(--muted); display: grid; place-items: center; }
.tools button.active { color: var(--accent); border-color: var(--accent); }
.tools button .tlabel { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tools button:has(.tlabel) { width: auto; min-width: 64px; padding: 0 8px; }

/* Barra de pestañas */
.tabbar { display: flex; gap: 6px; padding: 6px; margin: 0 0 calc(var(--safe-b) + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: 24px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0; border-radius: 18px; font-size: 11px; font-weight: 600; color: var(--muted); }
.tab i { font-size: 18px; }
.tab.active { background: var(--surface2); color: var(--accent); }

/* Listas */
.page-title { font-size: 28px; font-weight: 800; letter-spacing: -.02em; margin: 6px 2px 10px; }
.head-row { display: flex; align-items: center; justify-content: space-between; }
.btn-wide { width: 100%; height: 52px; border-radius: 16px; background: var(--surface2); border: 1px solid var(--border); font-weight: 700; font-size: 16px; color: var(--accent); }
.songs { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.songs li { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; }
.songs .info { flex: 1; text-align: left; padding: 14px 16px; }
.songs .nm { font-size: 17px; font-weight: 700; }
.songs .meta { color: var(--muted); font-size: 13px; margin-top: 3px; }
.songs .del { padding: 16px 18px; color: var(--muted); }
.empty { color: var(--muted); text-align: center; margin-top: 30px; }
.plist { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; overflow-y: auto; padding-bottom: 8px; }
.pcard { background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 16px 16px 8px; }
.ptop { display: flex; gap: 14px; justify-content: space-between; }
.pinfo { flex: 1; min-width: 0; }
.pname { font-size: 18px; font-weight: 700; line-height: 1.2; }
.pmeta { color: var(--muted); font-size: 14px; margin-top: 10px; }
.bars { display: flex; gap: 4px; height: 70px; width: 44%; max-width: 160px; }
.bar { flex: 1; background: var(--cell-off); border-radius: 5px; display: flex; align-items: flex-end; overflow: hidden; }
.bar span { display: block; width: 100%; background: linear-gradient(180deg, var(--accent), var(--accent2)); border-radius: 5px; }
.pfoot { display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--border); margin-top: 12px; padding-top: 2px; }
.plast { flex: 1; color: var(--muted); font-size: 14px; }
.pmore, .pplay { width: 48px; height: 44px; font-size: 18px; } .pplay { color: var(--accent); font-size: 20px; }

/* Hojas de diálogo */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); display: flex; align-items: flex-end; justify-content: center; z-index: 40; }
.sheet { width: 100%; max-width: 480px; max-height: 92dvh; overflow-y: auto; background: var(--sheet); color: var(--text); border-radius: 26px 26px 0 0; border: 1px solid var(--border);
  padding: 20px 18px calc(var(--safe-b) + 18px); animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet h2 { margin: 0 0 14px; font-size: 19px; font-weight: 800; }
.sheet h3 { margin: 16px 0 8px; font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet-actions button { flex: 1; height: 50px; border-radius: 15px; background: var(--surface2); font-weight: 700; font-size: 16px; }
.sheet-actions button.primary { background: linear-gradient(145deg, var(--accent), var(--accent2)); color: var(--on-accent); }
.sheet-actions button.danger { background: #d8445c; color: #fff; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0; }
.row label { flex: 1; color: var(--muted); font-size: 14px; }
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper button { width: 44px; height: 44px; border-radius: 13px; background: var(--surface2); font-size: 16px; }
.stepper output { min-width: 52px; text-align: center; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { padding: 10px 14px; border-radius: 12px; background: var(--surface2); font-size: 15px; font-weight: 600; }
.chips button.sel { background: var(--accent); color: var(--on-accent); }
.sheet input[type=text], .sheet input[type=tel] { width: 100%; height: 50px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 18px; padding: 0 14px; -webkit-user-select: text; user-select: text; }
.sheet input[type=range] { width: 100%; accent-color: var(--accent); }
.sheet p.note { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.switch { position: relative; flex: none; width: 54px; height: 32px; border-radius: 16px; background: var(--surface2); transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch.on { background: var(--accent); } .switch.on::after { transform: translateX(22px); }

/* Temporizador */
.timer-lcd { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; text-align: center; font-size: 50px; font-weight: 700; color: var(--accent);
  font-variant-numeric: tabular-nums; letter-spacing: .03em; padding: 14px 0; margin-bottom: 14px; }
.ctl-row { display: flex; justify-content: center; gap: 12px; margin-bottom: 8px; }
.pill { height: 52px; min-width: 130px; padding: 0 22px; border-radius: 26px; font-size: 17px; font-weight: 700; color: #fff; }
.pill.go { background: linear-gradient(145deg, var(--accent), var(--accent2)); color: var(--on-accent); } .pill.stop { background: #e5484d; }

/* Patrones rítmicos */
.pgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pcell { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 6px 10px; border-radius: 16px; background: var(--surface2); border: 2px solid transparent; font-size: 12px; font-weight: 600; text-align: center; line-height: 1.2; }
.pcell .pv { height: 26px; grid-auto-columns: 7px; gap: 3px; }
.pcell.sel { border-color: var(--accent); }

/* Temas */
.swgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.swatch { height: 92px; border-radius: 18px; border: 2px solid var(--border); position: relative; overflow: hidden; display: flex; align-items: flex-end; padding: 8px 10px;
  background: radial-gradient(90% 70% at 10% 0%, var(--glow1), transparent 70%), linear-gradient(160deg, var(--bg1), var(--bg2)); color: var(--text); font-size: 13px; font-weight: 700; text-align: left; }
.swatch::before { content: ""; position: absolute; top: 12px; right: 12px; width: 22px; height: 22px; border-radius: 50%; background: linear-gradient(145deg, var(--accent), var(--accent2)); }
.swatch.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.swatch.auto { background: linear-gradient(115deg, #070b1f 50%, #f2f5fc 50%); }
.swatch.auto span { color: #fff; mix-blend-mode: difference; }
.credit { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 18px; color: var(--muted); font-size: 12px; }
.credit img { height: 28px; width: auto; }

@media (max-height: 720px) {
  .hero { padding: 10px 14px 12px; }
  .tap, .tools button { height: 48px; }
}

/* ---------- Controles centrales ---------- */
.ctl { display: none; position: relative; }
[data-ctl="disco"] .ctl-disco, [data-ctl="orbe"] .ctl-orb { display: flex; }
[data-ctl="pend"] .ctl-pend { display: block; }
[data-ctl="regla"] .ctl-ruler { display: flex; }
.ctl-disco { width: 100%; height: 100%; align-items: center; justify-content: center; }
.hint { position: absolute; left: 0; right: 0; text-align: center; font-size: 12px; color: var(--muted); margin: 0; pointer-events: none; }

/* Péndulo */
.ctl-pend { width: min(100cqw, 78cqh); height: 100cqh; touch-action: none; }
.pend-body { position: absolute; left: 4%; right: 4%; bottom: 0; height: 76%; clip-path: polygon(27% 0, 73% 0, 100% 100%, 0 100%);
  background: linear-gradient(90deg, rgba(255,255,255,.07), transparent 30%, transparent 70%, rgba(0,0,0,.18)), linear-gradient(160deg, var(--face-a), var(--face-b)); }
.rod { position: absolute; left: 50%; bottom: 32%; width: 6px; height: 64%; margin-left: -3px; border-radius: 3px; transform-origin: 50% 100%;
  background: linear-gradient(var(--accent), var(--accent2)); box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 50%, transparent); }
.weight { position: absolute; left: 50%; width: 36px; height: 26px; margin-left: -18px; bottom: 50%; border-radius: 8px;
  background: linear-gradient(var(--face-a), var(--face-b)); border: 2px solid var(--accent); box-shadow: 0 4px 10px var(--shadow); }
.pend-pivot { position: absolute; left: 50%; bottom: 32%; width: 20px; height: 20px; margin: 0 0 -10px -10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.pend-ctl { position: absolute; left: 14%; right: 14%; bottom: 3%; display: flex; align-items: center; justify-content: space-between; }
.mini { width: 44px; height: 44px; border-radius: 50%; background: var(--surface2); border: 1px solid var(--border); font-size: 15px; display: grid; place-items: center; }
.mini.main { width: 58px; height: 58px; background: linear-gradient(145deg, var(--accent), var(--accent2)); color: var(--on-accent); font-size: 21px; border: 0; }
.ctl-pend .hint { top: 0; text-align: left; }

/* Orbe */
.ctl-orb { width: min(100cqw, 100cqh); height: min(100cqw, 100cqh); align-self: center; touch-action: none; }
.orb-dots i { position: absolute; left: 50%; top: 50%; width: 12px; height: 12px; margin: -6px; border-radius: 50%; background: var(--cell-off); border: 1px solid var(--border);
  transform: rotate(var(--a)) translateY(-43cqmin) scale(var(--s)); transition: background .08s, box-shadow .08s; }
.orb-dots i.on { background: var(--accent); box-shadow: 0 0 14px var(--accent); }
.orb-core { position: absolute; left: 50%; top: 50%; width: 62%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--on-accent);
  background: radial-gradient(circle at 35% 25%, color-mix(in srgb, var(--accent) 65%, #fff), var(--accent2));
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--accent) 16%, transparent), 0 0 60px color-mix(in srgb, var(--accent) 45%, transparent); transition: scale .1s; }
.orb-core.pulse { scale: 1.07; }
.orb-bpm { font-size: clamp(44px, 18cqmin, 70px); font-weight: 800; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.orb-core small { font-size: 12px; font-weight: 700; letter-spacing: .12em; opacity: .8; }
.orb-core i { margin-top: 8px; font-size: 18px; opacity: .9; }
.ctl-orb .hint { bottom: -2px; }

/* Regla */
.ctl-ruler { width: 100%; height: 100%; flex-direction: column; justify-content: center; align-items: center; gap: 18px; }
.ruler-view { position: relative; width: 100%; height: min(44cqh, 130px); border-radius: 22px; background: var(--surface); border: 1px solid var(--border); overflow: hidden; touch-action: none; }
#rulerCv { position: absolute; inset: 0; width: 100%; height: 100%; }
.needle { position: absolute; left: 50%; top: 0; bottom: 0; width: 3px; margin-left: -1.5px; background: var(--accent); box-shadow: 0 0 12px var(--accent); border-radius: 2px; }
.ruler-ctl { display: flex; gap: 22px; align-items: center; }
.round { width: 56px; height: 56px; border-radius: 50%; background: var(--surface2); border: 1px solid var(--border); font-size: 18px; display: grid; place-items: center; }
.round.big { width: 84px; height: 84px; background: linear-gradient(145deg, var(--accent), var(--accent2)); color: var(--on-accent); font-size: 30px; border: 0; box-shadow: 0 8px 22px var(--shadow); }
.ctl-ruler .hint { position: static; }

/* Temas: etiqueta del control */
.swatch { flex-direction: column; justify-content: flex-end; align-items: flex-start; }
.swatch small { display: block; font-weight: 500; opacity: .75; font-size: 11px; margin-top: 1px; }

/* Orbe: botones de ajuste fino */
.orb-btn { position: absolute; bottom: 14px; width: 56px; height: 56px; font-size: 18px; z-index: 2; }
.orb-btn.left { left: 0; } .orb-btn.right { right: 0; }

/* ---------- Botones: estado inactivo visible ---------- */
:root { --btn: rgba(255, 255, 255, .1); --btn-border: rgba(255, 255, 255, .22); --btn-press: rgba(255, 255, 255, .2); }
[data-theme="claro"] { --btn: rgba(15, 23, 51, .06); --btn-border: rgba(15, 23, 51, .22); --btn-press: rgba(15, 23, 51, .14); }

.chips button, .stepper button, .sheet-actions button, .pcell, .mini, .round, .chip, .icon-btn, .tools button, .btn-wide {
  background: var(--btn); border: 1px solid var(--btn-border); box-shadow: 0 1px 0 rgba(255, 255, 255, .06);
}
.chips button:active, .stepper button:active, .sheet-actions button:active, .pcell:active, .mini:active, .round:active, .chip:active,
.icon-btn:active, .tools button:active, .btn-wide:active { background: var(--btn-press); }
.pcell { border: 2px solid var(--btn-border); }
.pcell.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--btn)); }
.chips button { padding: 10px 16px; }
.chips button.sel { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.sheet-actions button.primary, .sheet-actions button.danger { border-color: transparent; }
.tools button.active { border-color: var(--accent); }
.mini.main, .round.big { border: 0; }
.switch { background: var(--btn-border); border: 0; }
.switch.on { background: var(--accent); }

/* Tema automático: rótulos legibles sobre el fondo partido */
.swatch.auto span, .swatch.auto small { background: rgba(10, 15, 40, .85); color: #fff; padding: 2px 8px; border-radius: 8px; mix-blend-mode: normal; opacity: 1; }
.swatch.auto small { margin-top: 3px; }
.swatch { border-color: var(--btn-border); }
.swatch.sel { border-color: var(--accent); }
.swatch.auto span, .swatch.auto small { white-space: nowrap; width: fit-content; }
.swatch.auto small { font-size: 10px; }

/* ---------- Gráfico de curva y editor de intervalos ---------- */
.g { width: 100%; height: auto; display: block; overflow: visible; }
.g text { font: 600 10px -apple-system, sans-serif; fill: var(--muted); }
.g text.lbl { fill: var(--text); font-size: 11px; }
.g .grid { stroke: var(--track); stroke-width: 1; }
.g .pin { fill: var(--accent); stroke: var(--bg1); stroke-width: 1.5; }
.g .gcur { stroke: var(--text); stroke-width: 1.5; stroke-dasharray: 3 3; }
.pg { width: 46%; max-width: 170px; align-self: center; }
.run-graph { margin: 4px 2px 0; padding: 6px 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }
.pgraph-edit { margin: 12px 0 4px; padding: 10px 10px 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }
.pgraph-edit .note { text-align: center; margin: 2px 0 6px; }

.iv { margin: 10px 0; padding: 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); }
.iv-top { display: flex; align-items: center; gap: 10px; }
.iv-n { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 800; background: var(--accent); color: var(--on-accent); }
.iv-f { flex: 1; min-width: 0; }
.iv-f label { display: block; font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; margin-bottom: 4px; }
.mst { display: flex; align-items: center; gap: 4px; }
.mst button { flex: none; width: 34px; height: 38px; border-radius: 11px; background: var(--btn); border: 1px solid var(--btn-border); font-size: 13px; }
.mst button:active { background: var(--btn-press); }
.mst output, .mst .iv-in { flex: 1; min-width: 0; text-align: center; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sheet .iv-in { width: 100%; height: 38px; padding: 0 2px; font-size: 18px; border-radius: 10px; }
.iv-bot { display: flex; gap: 6px; margin-top: 10px; }
.iv-bot button { flex: 1; height: 38px; border-radius: 11px; background: var(--btn); border: 1px solid var(--btn-border); font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 6px; }
.iv-bot button:active { background: var(--btn-press); }
.iv-bot button.on { background: var(--accent); color: var(--on-accent); border-color: transparent; }
button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Opciones, canciones, historial, afinador ---------- */
.flash { position: fixed; inset: 0; z-index: 25; pointer-events: none; background: var(--accent); opacity: 0; }
.flash.go { animation: fl .22s ease-out; }
@keyframes fl { from { opacity: var(--fo, .4); } to { opacity: 0; } }

.songbar { display: flex; align-items: center; gap: 6px; margin: 4px 0 0; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }
.songbar button { width: 40px; height: 38px; border-radius: 11px; background: var(--btn); border: 1px solid var(--btn-border); font-size: 14px; }
.songbar .sb-mid { flex: 1; min-width: 0; text-align: center; display: flex; flex-direction: column; }
.songbar .sb-mid span { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.songbar .sb-mid small { color: var(--muted); font-size: 11px; }

.menu { display: flex; flex-direction: column; gap: 8px; }
.menu-btn { display: flex; align-items: center; gap: 14px; height: 50px; padding: 0 16px; border-radius: 14px; background: var(--btn); border: 1px solid var(--btn-border); font-size: 16px; font-weight: 600; text-align: left; }
.menu-btn i { width: 20px; text-align: center; color: var(--accent); }
.menu-btn.danger i, .menu-btn.danger { color: #e5484d; }
.menu-btn:active { background: var(--btn-press); }
.songs .splay { padding: 16px 14px; color: var(--accent); font-size: 16px; }

.sec-name { width: 100%; height: 40px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 16px; font-weight: 600; padding: 0 12px; -webkit-user-select: text; user-select: text; }
.sec-mid { margin-top: 10px; }
.dd { width: 100%; height: 40px; border-radius: 11px; border: 1px solid var(--btn-border); background: var(--btn); color: var(--text); font-size: 14px; font-weight: 600; padding: 0 8px; }

.backup { margin-top: 22px; padding-bottom: 12px; }
.backup h3, .logbox h3 { margin: 0 0 8px; }
.two { display: flex; gap: 10px; }
.two button { flex: 1; height: 50px; border-radius: 14px; background: var(--btn); border: 1px solid var(--btn-border); font-weight: 700; font-size: 15px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.two button:active { background: var(--btn-press); }

.logbox { margin-top: 20px; padding-bottom: 16px; }
.stats { display: flex; gap: 8px; margin-bottom: 10px; }
.stats div { flex: 1; padding: 12px 8px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); text-align: center; display: flex; flex-direction: column; gap: 2px; }
.stats b { font-size: 18px; } .stats span { font-size: 11px; color: var(--muted); }
.logl { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.logl li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); font-size: 14px; }
.logl .ln { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logl .lm { color: var(--muted); flex: none; }

.tuner { padding: 18px 16px; text-align: center; margin-bottom: 14px; }
.tn-note { font-size: 84px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.tn-note sub { font-size: 28px; font-weight: 700; color: var(--muted); }
.tn-freq { color: var(--muted); font-weight: 600; margin: 4px 0 18px; }
.tn-meter { position: relative; height: 54px; border-radius: 27px; background: var(--cell-off); margin: 0 6px 8px; transition: box-shadow .15s; }
.tn-zone { position: absolute; left: 47%; right: 47%; top: 6px; bottom: 6px; border-radius: 6px; background: color-mix(in srgb, var(--accent) 35%, transparent); }
.tn-needle { position: absolute; left: 50%; top: 4px; bottom: 4px; width: 6px; margin-left: -3px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 10px var(--accent); transition: left .08s linear, background .15s; }
.tn-meter.idle .tn-needle { opacity: .35; }
.tn-meter.ok { box-shadow: 0 0 0 3px #2fd27a; }
.tn-meter.ok .tn-needle { background: #2fd27a; box-shadow: 0 0 12px #2fd27a; }
.tn-l, .tn-r { position: absolute; top: 100%; margin-top: 4px; font-size: 11px; color: var(--muted); }
.tn-l { left: 6px; } .tn-r { right: 6px; }
.tn-cents { min-height: 22px; font-weight: 700; margin: 18px 0 12px; font-variant-numeric: tabular-nums; }
.drone { padding: 16px; margin-bottom: 16px; }
.drone h2 { margin: 0 0 4px; font-size: 19px; font-weight: 800; }
#drBtn { margin-top: 14px; color: var(--accent); }
#drBtn.on { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.tab { padding: 7px 0; }

/* Vistas largas con desplazamiento propio */
#viewSongs, #viewPractice, #viewTuner { overflow-y: auto; padding-bottom: 10px; -webkit-overflow-scrolling: touch; }
p.note { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

/* ---------- Indicador de tendencia y controles de práctica ---------- */
.hero.runmode .tname { display: none; }
.trend { display: flex; align-items: center; gap: 9px; padding: 7px 13px; border-radius: 16px; --tc: var(--muted);
  color: var(--tc); background: color-mix(in srgb, var(--tc) 16%, transparent); border: 1px solid color-mix(in srgb, var(--tc) 38%, transparent); margin-bottom: 6px; }
.trend.up { --tc: var(--accent); } .trend.down { --tc: #ff9f43; } .trend.hold { --tc: var(--muted); }
.trend i { font-size: 18px; }
.trend b { display: block; font-size: 14px; font-weight: 800; line-height: 1.1; }
.trend small { display: block; font-size: 11px; font-weight: 600; opacity: .85; }
.trend.up i { animation: nudgeUp 1.1s ease-in-out infinite; }
.trend.down i { animation: nudgeDown 1.1s ease-in-out infinite; }
@keyframes nudgeUp { 0%, 100% { transform: translateY(2px); opacity: .55; } 50% { transform: translateY(-3px); opacity: 1; } }
@keyframes nudgeDown { 0%, 100% { transform: translateY(-2px); opacity: .55; } 50% { transform: translateY(3px); opacity: 1; } }
.bpm span { transition: color .35s; }
.bpm.up span { color: var(--accent); } .bpm.down span { color: #ff9f43; }

.run-ctl { display: flex; gap: 6px; margin-top: 6px; }
.run-ctl button { flex: 1; height: 38px; border-radius: 12px; background: var(--btn); border: 1px solid var(--btn-border); font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 7px; }
.run-ctl button:active { background: var(--btn-press); }
.run-ctl button.end { color: #e5484d; }
.lastrun { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 14px; border-radius: 15px; background: var(--btn); border: 1px solid var(--btn-border); color: var(--accent); font-size: 13px; font-weight: 700; max-width: 100%; }
.lastrun span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { display: flex; align-items: center; justify-content: center; }

.iv-mode { margin-top: 10px; }
.iv-mode label, .iv-trans label { display: block; font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; margin-bottom: 5px; }
.seg2 { display: flex; gap: 6px; }
.seg2 button { flex: 1; height: 40px; border-radius: 12px; background: var(--btn); border: 1px solid var(--btn-border); font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 7px; }
.seg2 button.on { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.iv-trans { margin-top: 10px; }
.iv-mode .note { margin: 6px 0 0; }
#bpmNum.up { color: var(--accent); } #bpmNum.down { color: #ff9f43; }
.hero.compact .bpm span { font-size: clamp(52px, 8dvh, 68px); }
.trend small { white-space: nowrap; }
.run-graph { margin-bottom: 8px; }

/* ---------- Cuenta regresiva ---------- */
.run-count { display: flex; gap: 8px; margin-bottom: 6px; }
.rc { flex: 1; min-width: 0; padding: 7px 10px; border-radius: 14px; background: var(--btn); border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; transition: background .2s, border-color .2s; }
.rc small { font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); line-height: 1.2; }
.rc b { font-size: 17px; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; color: var(--muted); }
.rc-int { flex: 1.5; }
.rc-int.soon { background: color-mix(in srgb, var(--accent) 16%, transparent); border-color: var(--accent); }
.rc-int.soon small { color: var(--accent); }
.rc-int.soon b { font-size: 38px; color: var(--accent); line-height: 1; }
.rc-int.urgent { background: color-mix(in srgb, #ff9f43 20%, transparent); border-color: #ff9f43; }
.rc-int.urgent small, .rc-int.urgent b { color: #ff9f43; }
.rc b.tick { animation: cdPulse .45s ease-out; }
@keyframes cdPulse { from { transform: scale(1.35); } to { transform: scale(1); } }
.rc-tot b { font-size: 20px; color: var(--text); }
.rc-bar { height: 4px; border-radius: 2px; background: var(--track); margin-bottom: 6px; overflow: hidden; }
.rc-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent2), var(--accent)); transition: width .15s linear; }
.tpill .fa-stopwatch { font-size: 18px; }
.tpill b { font-size: 18px; font-variant-numeric: tabular-nums; }
.hero.runmode .tpill { display: none; }

/* Durante una práctica, la tarjeta principal se compacta para dar espacio al panel */
.hero.compact { padding-bottom: 12px; }
.hero.compact .pads { height: clamp(52px, 7.5dvh, 72px); }
.hero.compact .chips-row { margin: 6px 0 8px; }
.hero.compact .chip { height: 32px; font-size: 13px; }
.run-graph { padding: 6px 8px; }
.run-ctl button { height: 34px; }
.rc-int.soon b { font-size: 34px; }

/* Cuenta regresiva informativa: intervalo (principal) y total */
.rc em { font-style: normal; font-size: 10px; font-weight: 600; color: var(--muted); line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc b { font-size: 22px; color: var(--text); }
.rc-int { flex: 1.45; }
.rc-tot b { font-size: 22px; }
.rc-int.soon b { font-size: 34px; color: var(--accent); line-height: 1; }
.rc-int.soon em, .rc-int.soon small { color: var(--accent); }
.rc-int.urgent em, .rc-int.urgent small, .rc-int.urgent b { color: #ff9f43; }
.rc small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* ---------- Ajustes de diseño tras la auditoría de superposiciones ---------- */
#viewMetro { overflow-y: auto; overflow-x: hidden; }
.dial-wrap { min-height: 150px; flex-shrink: 0; flex-basis: auto; }
#viewMetro .dial-wrap { flex: 1 0 150px; }

/* Cabecera de la tarjeta: la píldora nunca desborda y el número se achica si hace falta */
.hero-top { gap: 8px; flex-wrap: nowrap; }
.hero-top .bpm { flex: 0 1 auto; min-width: 0; }
.hero-top .trend { flex: 0 1 auto; min-width: 0; max-width: 52%; }
.trend > div { min-width: 0; }
.trend b, .trend small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.hero.withpill .bpm span { font-size: clamp(50px, 15.5vw, 68px); }
.hero.withpill .bpm small { display: none; }

/* Controles que escalan con el espacio disponible */
.ruler-view { height: clamp(52px, 36cqh, 130px); }
.round { width: clamp(38px, 21cqh, 56px); height: clamp(38px, 21cqh, 56px); }
.round.big { width: clamp(52px, 36cqh, 84px); height: clamp(52px, 36cqh, 84px); font-size: clamp(22px, 14cqh, 30px); }
.ctl-ruler { gap: clamp(8px, 6cqh, 18px); }
.ruler-ctl { gap: clamp(14px, 18cqw, 22px); }
@container (max-height: 215px) { .ctl .hint { display: none; } }

/* Pantallas bajas: se compacta en etapas para que nada se monte */
@media (max-height: 780px) {
  #viewMetro.runpanel .hero .chips-row { display: none; }
  .tabbar { padding: 4px; margin-bottom: calc(var(--safe-b) + 4px); }
  .tab { padding: 5px 0; }
  .tab i { font-size: 17px; }
}
@media (max-height: 720px) {
  #viewMetro.runpanel #rgSvg { display: none; }
  .bpm span { font-size: clamp(52px, 9dvh, 64px); }
  .pads { height: clamp(60px, 10.5dvh, 96px); }
  .hero { padding: 10px 14px 12px; }
  .chips-row { margin: 8px 0 10px; }
  .status { margin-top: 4px; min-height: 20px; }
  .bottom-row { padding: 6px 0 8px; }
}
@media (max-height: 640px) {
  #viewMetro.runpanel .dial-wrap { display: none; }
  .hero.compact .pads { height: 44px; }
}
@media (max-height: 720px) {
  .songbar { padding: 4px 6px; }
  .songbar button { height: 34px; }
  .rc { padding: 4px 8px; }
  .rc b { font-size: 19px; }
  .rc-int.soon b { font-size: 28px; }
  .run-count { margin-bottom: 4px; }
  .run-graph { padding: 5px 7px; margin-bottom: 6px; }
  .run-ctl { margin-top: 4px; }
  .rc-bar { margin-bottom: 4px; }
}
.ctl-pend .hint { display: none; }

/* ---------- Orbe: escenario propio, sin superposiciones ---------- */
.ctl-orb { width: 100cqw; height: 100cqh; align-self: stretch; --os: min(calc(100cqh - 24px), calc(100cqw - 150px)); }
.orb-stage { position: absolute; top: 0; left: 50%; width: var(--os); height: var(--os); margin-left: calc(var(--os) / -2); }
.orb-dots { position: absolute; inset: 0; }
.orb-dots i { position: absolute; inset: 0; width: auto; height: auto; margin: 0; border: 0; background: none; box-shadow: none; transform: rotate(var(--a)); }
.orb-dots i::before { content: ""; position: absolute; left: 50%; top: 1%; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%;
  background: var(--cell-off); border: 1px solid var(--border); transform: scale(var(--s)); transition: background .08s, box-shadow .08s; }
.orb-dots i.on { background: none; box-shadow: none; }
.orb-dots i.on::before { background: var(--accent); box-shadow: 0 0 14px var(--accent); }
.orb-btn { top: 50%; bottom: auto; transform: translateY(-50%); width: clamp(44px, 34cqh, 56px); height: clamp(44px, 34cqh, 56px); }
.ctl-orb .hint { bottom: 0; left: 0; right: 0; }
@container (max-height: 215px) { .ctl-orb { --os: min(100cqh, calc(100cqw - 150px)); } }

.songbar { padding: 5px 6px; }
.songbar button { height: 36px; }
.status { min-height: 18px; margin-top: 4px; font-size: 12.5px; }
.run-graph { margin-bottom: 6px; }

/* Acciones del diálogo siempre al alcance, aunque el contenido se desplace */
.sheet-actions { position: sticky; bottom: calc(-1 * (var(--safe-b) + 18px)); margin: 14px -18px calc(-1 * (var(--safe-b) + 18px));
  padding: 12px 18px calc(var(--safe-b) + 18px); background: var(--sheet); border-top: 1px solid var(--border); z-index: 2; }

/* Rótulos de tema que caben en tres columnas */
.swatch { font-size: 12px; padding: 8px; }
.swatch span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swatch small { font-size: 10px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swatch.auto span, .swatch.auto small { padding: 2px 6px; max-width: 100%; }
