:root {
  --bg: #110F17; --surface: #1B1824; --surface2: #23202E; --line: #2E2940; --line2: #3A3450;
  --text: #F3EFFA; --dim: #B5AEC6; --mute: #8C85A0;
  --R: #FF8A2B; --L: #3EB8F0; --xp: #FFD23F; --streak: #FF4F9A; --streak-t: #FF7AB4;
  --ok: #5BE38A; --bad: #FF6B6B;
  --lv: #5BE38A; /* cor do nível atual, trocada via JS */
  --font: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Archivo Black', 'Archivo', system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { background: var(--bg); color: var(--text); font-family: var(--font); }
body { min-height: 100vh; padding-top: env(safe-area-inset-top, 0px); padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); overflow-x: hidden; }
button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 2px solid var(--lv); outline-offset: 2px; }
input, select { font-family: inherit; font-size: 16px; color: var(--text); background: var(--surface2); border: 1px solid var(--line2); border-radius: 10px; padding: 9px 10px; width: 100%; }
svg { display: block; }
.muted { color: var(--dim); }
.small { font-size: 13px; line-height: 1.4; }
[hidden] { display: none !important; }

/* ---------- topo ---------- */
.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px 6px; max-width: 560px; margin: 0 auto; }
.logo { display: flex; align-items: center; gap: 10px; }
.logo svg { width: 36px; height: 36px; }
.wordmark { font-family: var(--display); font-size: 15px; line-height: .95; letter-spacing: .02em; }
.wordmark span { color: var(--R); }
.streak-chip { display: flex; align-items: center; gap: 6px; background: rgba(255,79,154,.14); border: 1px solid rgba(255,79,154,.45); padding: 7px 12px; border-radius: 999px; min-height: 36px; }
.streak-chip svg { width: 16px; height: 16px; fill: none; stroke: var(--streak); stroke-width: 2.2; stroke-linejoin: round; }
.streak-chip span { font-weight: 800; font-size: 14px; color: var(--streak-t); }
.streak-chip.off { background: var(--surface); border-color: var(--line); }
.streak-chip.off svg { stroke: var(--mute); } .streak-chip.off span { color: var(--mute); }

main { max-width: 560px; margin: 0 auto; padding: 0 20px; }
.view { display: none; padding-top: 10px; }
.view.on { display: block; }

/* ---------- blocos genéricos ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; margin-top: 12px; }
.kicker { font-size: 11px; font-weight: 800; letter-spacing: .16em; color: var(--dim); }
.h1 { font-family: var(--display); font-size: 28px; line-height: 1.08; }
.h2 { font-family: var(--display); font-size: 22px; line-height: 1.12; }
.big-num { font-family: var(--display); font-size: 40px; line-height: 1; color: var(--lv); }
.btn-primary { display: block; width: 100%; min-height: 54px; border-radius: 14px; background: var(--lv); color: #110F17; font-family: var(--display); font-size: 16px; letter-spacing: .04em; padding: 0 16px; }
.btn-primary.stop { background: var(--bad); }
.btn-ghost { display: block; width: 100%; min-height: 48px; border-radius: 14px; border: 1px solid var(--line2); font-weight: 700; font-size: 15px; padding: 0 16px; }
.btn-mini { margin-top: 8px; width: 100%; padding: 8px; border-radius: 9px; background: var(--surface2); border: 1px solid var(--line2); font-weight: 700; font-size: 13px; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.stack { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.chip-lv { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .12em; color: #110F17; background: var(--lv); padding: 5px 10px; border-radius: 999px; }

/* ---------- hoje ---------- */
.xpbar { height: 10px; background: #2A2537; border-radius: 999px; margin-top: 14px; overflow: hidden; }
.xpbar > div { height: 100%; background: var(--xp); border-radius: 999px; transition: width .4s ease; }
.lv-row { display: flex; align-items: center; justify-content: space-between; }
.workout { border: 2px solid var(--lv); border-radius: 22px; }
.workout .head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.blk { display: flex; align-items: center; gap: 12px; background: var(--surface2); border-radius: 12px; padding: 10px 12px; border: 1px solid transparent; }
.blk.next { border-color: var(--line2); }
.blk .ix { width: 30px; height: 30px; flex: none; border-radius: 9px; background: var(--line); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; }
.blk.done .ix { background: var(--lv); }
.blk.done .ix svg { width: 16px; height: 16px; fill: none; stroke: #110F17; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.blk .t { flex: 1; min-width: 0; }
.blk .t b { display: block; font-size: 14px; }
.blk .t span { font-size: 12px; color: var(--dim); }
.blk .sc { font-size: 13px; font-weight: 800; }
.diag { display: flex; gap: 12px; align-items: flex-start; background: rgba(62,184,240,.10); border: 1px solid rgba(62,184,240,.35); }
.diag svg { width: 22px; height: 22px; flex: none; fill: none; stroke: var(--L); stroke-width: 2; stroke-linecap: round; }
.diag b { font-size: 14px; }
.clean-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.clean { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 10px; }
.clean .n { font-size: 11.5px; color: var(--dim); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clean .v { font-family: var(--display); font-size: 26px; line-height: 1.1; }
.clean svg { width: 100%; height: 26px; }
.clean .d { font-size: 12px; font-weight: 800; color: var(--ok); }
.clean .d.zero { color: var(--mute); font-weight: 600; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; margin-top: 22px; }
.onboard { border: 2px solid var(--lv); }

/* ---------- trilha ---------- */
.trail-tabs { display: flex; gap: 6px; margin-top: 4px; }
.trail-tabs button { flex: 1; min-height: 40px; border-radius: 999px; border: 1px solid var(--line2); font-size: 13px; font-weight: 700; color: var(--dim); display: flex; align-items: center; justify-content: center; gap: 5px; }
.trail-tabs button.on { color: #110F17; border-color: transparent; }
.trail-tabs svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.4; }
.stages { position: relative; margin-top: 18px; }
.stages::before { content: ""; position: absolute; left: 23px; top: 24px; bottom: 24px; width: 3px; background: var(--line); border-radius: 2px; }
.stage-row { position: relative; display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 4px 0; border-radius: 16px; border: 1px solid transparent; margin-bottom: 10px; }
.stage-row.cur { background: color-mix(in srgb, var(--lv) 10%, transparent); border-color: color-mix(in srgb, var(--lv) 50%, transparent); padding: 12px 12px 12px 0; }
.stage-row.lock { opacity: .7; }
.node { width: 48px; height: 48px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--surface); border: 2px solid var(--line); font-family: var(--display); color: var(--text); }
.stage-row.done .node, .stage-row.cur .node { color: #110F17; }
.stage-row:disabled { opacity: .7; }
.stage-row.done .node { background: var(--lv); border: none; }
.stage-row.cur .node { background: var(--lv); border: 4px solid var(--bg); box-shadow: 0 0 0 3px var(--lv); }
.node svg { width: 20px; height: 20px; fill: none; stroke: #110F17; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.stage-row.lock .node svg { stroke: #6E6783; stroke-width: 2.2; width: 18px; height: 18px; }
.stage-row .t { flex: 1; min-width: 0; }
.stage-row .t b { display: block; font-size: 15px; }
.stage-row.lock .t b { color: #9C95AD; }
.stars { display: flex; gap: 2px; }
.stars svg { width: 16px; height: 16px; fill: #3A3450; }
.stars svg.on { fill: var(--xp); }
.stars.big svg { width: 26px; height: 26px; }
.free-note { border-style: dashed; border-color: var(--line2); }

/* ---------- rudimentos ---------- */
.cat { font-size: 11px; font-weight: 800; letter-spacing: .14em; color: var(--dim); margin: 22px 2px 8px; }
.rud-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; min-height: 52px; }
.rud-item b { font-size: 15px; display: block; }
.rud-item span { font-size: 12px; color: var(--dim); }
.tag { font-size: 11px; font-weight: 700; color: var(--mute); border: 1px solid var(--line2); border-radius: 999px; padding: 3px 8px; white-space: nowrap; }
.tag.rec { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.back { color: var(--lv); font-weight: 700; font-size: 15px; min-height: 44px; }

/* ---------- partitura e palco ---------- */
.stage { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; margin-top: 12px; padding-top: 4px; }
.stage svg { width: 100%; height: 140px; }
.stick { transition: transform .05s ease-out; }
.stick.L { transform-origin: 70px 28px; transform: rotate(-16deg); }
.stick.L.hit { transform: rotate(5deg); } .stick.L.hit.acc { transform: rotate(11deg); }
.stick.R { transform-origin: 230px 28px; transform: rotate(16deg); }
.stick.R.hit { transform: rotate(-5deg); } .stick.R.hit.acc { transform: rotate(-11deg); }
.flash { opacity: 0; transition: opacity .05s; } .flash.on { opacity: .85; }
.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px 8px 8px; margin-top: 10px; }
.cells { display: flex; flex-wrap: wrap; gap: 14px 10px; justify-content: center; }
.bgroup { display: flex; gap: 4px; position: relative; padding-bottom: 16px; }
.bnum { position: absolute; bottom: 0; left: 2px; font-size: 11px; font-weight: 700; color: var(--dim); }
.cell { width: 34px; text-align: center; border-radius: 8px; padding: 6px 0 4px; background: var(--surface2); border: 1px solid var(--line); display: flex; flex-direction: column; }
.cell .hand { font-family: var(--display); font-size: 17px; }
.cell.R .hand { color: var(--R); } .cell.L .hand { color: var(--L); }
.cell .acc { font-size: 12px; font-weight: 800; height: 13px; }
.cell .grace { font-size: 10px; color: var(--dim); height: 11px; }
.cell.rest { opacity: .3; }
.cell.accented.R { background: rgba(255,138,43,.18); border-color: var(--R); }
.cell.accented.L { background: rgba(62,184,240,.18); border-color: var(--L); }
.cell.now { box-shadow: 0 0 0 2px var(--text); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; margin-top: 8px; font-size: 11.5px; color: var(--dim); }
.legend b.r { color: var(--R); } .legend b.l { color: var(--L); }
.bpm-ctl { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.bpm-ctl .v { font-family: var(--display); font-size: 30px; min-width: 92px; text-align: center; }
.bpm-ctl .v small { font-family: var(--font); font-size: 12px; color: var(--dim); display: block; font-weight: 600; }
.bpm-ctl button { min-width: 48px; min-height: 44px; border-radius: 10px; background: var(--surface2); border: 1px solid var(--line2); font-weight: 700; }

/* ---------- treino (overlay) ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow-y: auto; padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px); }
.s-top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; max-width: 560px; margin: 0 auto; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: var(--text); stroke-width: 2.2; stroke-linecap: round; }
.s-dots { flex: 1; display: flex; gap: 6px; }
.s-dots i { flex: 1; height: 6px; border-radius: 999px; background: var(--line); }
.s-dots i.done { background: var(--lv); }
.s-dots i.cur { background: color-mix(in srgb, var(--lv) 45%, var(--line)); }
.s-body { max-width: 560px; margin: 0 auto; padding: 4px 20px 28px; }
.status { min-height: 52px; display: flex; align-items: center; justify-content: center; text-align: center; font-weight: 700; font-size: 15px; margin-top: 12px; }
.status.count { font-family: var(--display); font-size: 40px; color: var(--lv); }
.status.mutedbar { color: var(--streak-t); }
.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.result .scorebox { display: flex; align-items: center; justify-content: space-between; }
.result .score { font-family: var(--display); font-size: 52px; line-height: 1; }
.chart-legend { display: flex; justify-content: space-between; font-size: 11px; margin-top: 14px; color: var(--dim); }
.chart-legend .late { color: var(--R); font-weight: 700; } .chart-legend .early { color: var(--L); font-weight: 700; }
canvas.dev { width: 100%; height: 110px; display: block; background: var(--surface2); border-radius: 10px; margin-top: 4px; }
.stats3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; text-align: center; }
.stats3 .v { font-family: var(--display); font-size: 18px; }
.stats3 .k { font-size: 10.5px; letter-spacing: .08em; color: var(--dim); font-weight: 700; }
.reward-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.reward { border-radius: 16px; padding: 14px; }
.reward .v { font-family: var(--display); font-size: 24px; }
.reward.xp { background: rgba(255,210,63,.10); border: 1px solid rgba(255,210,63,.45); } .reward.xp .v { color: var(--xp); }
.reward.st { background: rgba(255,79,154,.10); border: 1px solid rgba(255,79,154,.45); } .reward.st .v { color: var(--streak-t); }
.note-ok { background: rgba(91,227,138,.10); border: 1px solid rgba(91,227,138,.45); }
.done-hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 18px; }
.done-hero .check { width: 64px; height: 64px; border-radius: 50%; background: var(--lv); display: flex; align-items: center; justify-content: center; }
.done-hero .check svg { width: 32px; height: 32px; fill: none; stroke: #110F17; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- metrônomo ---------- */
.bpm-box { text-align: center; }
.bpm-num { font-family: var(--display); font-size: 84px; line-height: 1; font-variant-numeric: tabular-nums; user-select: none; touch-action: none; cursor: ew-resize; }
.bpm-adjust { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }
.bpm-adjust button { min-width: 56px; min-height: 44px; background: var(--surface2); border: 1px solid var(--line2); border-radius: 10px; font-weight: 700; font-size: 16px; }
.pads { display: flex; gap: 6px; margin-top: 16px; justify-content: center; flex-wrap: wrap; }
.pad { width: 32px; height: 44px; border-radius: 8px; background: var(--surface2); border: 1px solid var(--line); }
.pad.beat { height: 54px; }
.pad.hit { background: var(--L); } .pad.hit.one { background: var(--R); }
.ctrl-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.ctrl { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; font-size: 12px; font-weight: 700; color: var(--dim); }
.ctrl.wide { grid-column: 1 / -1; }
.check { display: flex !important; flex-direction: row !important; align-items: center; gap: 10px; font-size: 14px; color: var(--text); font-weight: 600; }
.check input { width: 20px; height: 20px; accent-color: var(--lv); }
input[type=range] { accent-color: var(--lv); padding: 0; border: none; background: none; }
.panel summary { list-style: none; cursor: pointer; font-weight: 800; font-size: 15px; display: flex; justify-content: space-between; min-height: 24px; }
.panel summary::after { content: "+"; color: var(--lv); font-size: 20px; line-height: 1; }
.panel[open] summary::after { content: "−"; }
.panel-body { display: grid; gap: 10px; margin-top: 12px; }
.panel-body label { font-size: 12px; font-weight: 700; color: var(--dim); display: flex; flex-direction: column; gap: 4px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.file-btn { display: block; text-align: center; padding: 14px; background: var(--surface2); border: 1px dashed var(--line2); border-radius: 12px; font-weight: 700; font-size: 14px !important; color: var(--text) !important; cursor: pointer; }
.live { color: var(--ok); font-size: 13px; font-weight: 700; }

/* ---------- perfil ---------- */
.kv { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: none; }
.kv b { font-weight: 800; }
.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }

/* ---------- navegação ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: #17141F; border-top: 1px solid var(--line); padding: 6px 4px calc(8px + env(safe-area-inset-bottom, 0px)); }
.tabbar button { display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 52px; justify-content: center; font-size: 10.5px; font-weight: 700; color: var(--mute); }
.tabbar button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button.on { color: var(--lv); font-weight: 800; }

.toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%) translateY(20px); background: var(--surface2); border: 1px solid var(--line2); color: var(--text); padding: 12px 16px; border-radius: 14px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; max-width: calc(100% - 40px); text-align: center; }
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }


/* ---------- apresentação ---------- */
body.intro-mode { padding-bottom: env(safe-area-inset-bottom, 0px); }
body.intro-mode .tabbar, body.intro-mode .streak-chip { display: none; }
.hero { padding-top: 8px; }
.hero .kicker { color: var(--lv); }
.hero h1 { font-family: var(--display); font-size: 34px; line-height: 1.05; margin-top: 8px; }
.hero p { color: var(--dim); font-size: 16px; line-height: 1.5; margin-top: 12px; }
.sec-title { font-family: var(--display); font-size: 22px; line-height: 1.1; margin-top: 36px; }
.steps { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.step { display: flex; gap: 14px; align-items: flex-start; }
.step .n { width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--lv); color: #110F17; font-family: var(--display); display: flex; align-items: center; justify-content: center; }
.step b { display: block; font-size: 15px; } .step p { font-size: 13.5px; color: var(--dim); line-height: 1.45; margin-top: 2px; }
.feat { display: flex; gap: 14px; align-items: flex-start; }
.feat .ic { width: 42px; height: 42px; flex: none; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.feat .ic svg { width: 22px; height: 22px; fill: none; stroke: #110F17; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.feat b { display: block; font-size: 15px; } .feat p { font-size: 13.5px; color: var(--dim); line-height: 1.45; margin-top: 2px; }
.feat-chart { width: 100%; height: 64px; margin-top: 10px; border-radius: 10px; background: var(--surface2); }
.install ol { margin: 10px 0 0 20px; display: grid; gap: 6px; font-size: 14px; line-height: 1.45; }
.install .ok { color: var(--ok); font-weight: 700; }
.banner { display: flex; gap: 12px; align-items: center; background: rgba(255,210,63,.10); border: 1px solid rgba(255,210,63,.45); }
.banner b { font-size: 14px; } .banner p { font-size: 12.5px; color: var(--dim); margin-top: 2px; }
.banner button { flex: none; color: var(--xp); font-weight: 800; font-size: 14px; min-height: 44px; padding: 0 4px; }
.link-btn { color: var(--lv); font-weight: 700; font-size: 14px; min-height: 44px; }
textarea { font-family: inherit; font-size: 16px; color: var(--text); background: var(--surface2); border: 1px solid var(--line2); border-radius: 10px; padding: 10px; width: 100%; resize: vertical; min-height: 130px; }
.form { display: grid; gap: 14px; margin-top: 16px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 700; color: var(--dim); }
.form .check { font-size: 14px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

@media (max-width: 370px) { .bpm-num { font-size: 66px; } .cell { width: 29px; } .clean .v { font-size: 22px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
