:root {
  --bg: #0c0e11; --panel: #15181d; --panel2: #1c2027; --line: #2a2f38;
  --text: #eef1f5; --muted: #8b93a1;
  --fat: #f2a33a; --muscle: #e5484d; --endu: #3aa8f2; --xp: #7ddc4e; --gold: #ffd35a; --health: #ff6fa0;
  --font: "Bahnschrift", "Avenir Next Condensed", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; }
body { min-height: 100dvh; padding-bottom: calc(72px + var(--safe-b)); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h2 { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 22px 0 10px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* HUD */
#hud { position: sticky; top: 0; z-index: 5; background: linear-gradient(var(--bg) 80%, transparent); padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 10px; }
.hud-row { display: flex; align-items: center; gap: 12px; max-width: 640px; margin: 0 auto; }
.lvl { width: 48px; height: 48px; border: 2px solid var(--xp); display: grid; place-items: center; font-size: 22px; font-weight: 700; transform: skew(-6deg); }
.hud-mid { flex: 1; min-width: 0; }
.rank { font-size: 15px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.xpbar { height: 6px; background: var(--panel2); margin-top: 6px; overflow: hidden; }
.xpbar i { display: block; height: 100%; background: var(--xp); transition: width .6s; }
.xptext { font-size: 11px; color: var(--muted); margin-top: 3px; }
.streak { text-align: right; line-height: 1.1; }
.streak b { font-size: 24px; color: var(--gold); }
.streak small { display: block; font-size: 11px; color: var(--muted); }
.sync-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); margin-left: 6px; vertical-align: middle; }
.sync-dot.on { background: var(--xp); } .sync-dot.err { background: var(--muscle); }

main { max-width: 640px; margin: 0 auto; padding: 0 16px 24px; }

.coach { background: var(--panel); border-left: 3px solid var(--xp); padding: 12px 14px; font-size: 15px; line-height: 1.4; }

/* Barras de estadísticas */
.stat { margin: 12px 0; }
.stat-head { display: flex; justify-content: space-between; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; font-weight: 600; }
.stat-head .delta { letter-spacing: 0; text-transform: none; font-weight: 400; }
.up { color: var(--xp); } .down { color: var(--muscle); }
.bar { position: relative; height: 16px; background: var(--panel2); margin-top: 5px; transform: skew(-12deg); overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; transition: width .8s cubic-bezier(.2,.8,.2,1); }
.bar::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 2px), var(--bg) calc(10% - 2px) 10%); }
.bar .goal { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #fff; z-index: 2; }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.card { background: var(--panel); padding: 12px; }
.card .big { font-size: 24px; font-weight: 700; }
.card .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.meter { height: 5px; background: var(--panel2); margin-top: 8px; }
.meter i { display: block; height: 100%; }

.missions { display: grid; gap: 6px; }
.mission { display: flex; align-items: center; gap: 12px; background: var(--panel); padding: 12px; border: 0; width: 100%; text-align: left; }
.mission .box { width: 22px; height: 22px; border: 2px solid var(--line); flex: none; display: grid; place-items: center; font-size: 14px; }
.mission.done .box { background: var(--xp); border-color: var(--xp); color: #000; }
.mission.done .mt { color: var(--muted); text-decoration: line-through; }
.mission .mt { flex: 1; }
.mission .mxp { font-size: 13px; color: var(--xp); font-weight: 700; }
.mission.auto { cursor: default; }
.minimum { margin-top: 8px; font-size: 13px; padding: 8px 12px; background: var(--panel); }
.minimum.ok { color: var(--xp); }

.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.btn { background: var(--panel2); border: 1px solid var(--line); padding: 12px; font-weight: 600; letter-spacing: .04em; }
.btn.primary { background: var(--xp); color: #071; border-color: var(--xp); color: #0a1a05; }
.btn.danger { color: var(--muscle); }
.btn:active { transform: translateY(1px); }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip { background: var(--panel); border: 1px solid var(--line); padding: 8px 12px; white-space: nowrap; font-size: 14px; }
.chip.on { border-color: var(--xp); color: var(--xp); }

input[type=text], input[type=number], input[type=search], select {
  width: 100%; background: var(--panel); border: 1px solid var(--line); padding: 12px; border-radius: 0; font-size: 16px;
}
label.f { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 10px 0 4px; }

.list { display: grid; gap: 2px; }
.item { display: flex; align-items: center; gap: 10px; background: var(--panel); padding: 11px 12px; border: 0; width: 100%; text-align: left; }
.item .n { flex: 1; min-width: 0; }
.item .n small { display: block; color: var(--muted); font-size: 12px; }
.item .k { font-weight: 700; white-space: nowrap; }
.item .x { background: none; border: 0; color: var(--muted); font-size: 18px; padding: 0 4px; }
.tag { font-size: 10px; padding: 2px 6px; border: 1px solid var(--endu); color: var(--endu); text-transform: uppercase; margin-left: 6px; }

/* Pulso en vivo */
.live { background: var(--panel); padding: 16px; text-align: center; }
.live .bpm { font-size: 64px; font-weight: 700; line-height: 1; }
.live .zone { display: inline-block; padding: 3px 10px; margin-top: 6px; font-size: 13px; font-weight: 700; text-transform: uppercase; }

/* Progreso */
svg.chart { width: 100%; height: 180px; display: block; background: var(--panel); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal div { aspect-ratio: 1; background: var(--panel); display: grid; place-items: center; font-size: 11px; color: var(--muted); }
.cal .ok { background: #2d5a1d; color: #dfffd0; } .cal .escudo { background: #5a4a14; color: #fff4c8; }
.cal .perdido { background: #3a1719; } .cal .pendiente { outline: 1px solid var(--xp); }
.ach { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.ach div { background: var(--panel); padding: 10px; opacity: .4; }
.ach div.on { opacity: 1; border-left: 3px solid var(--gold); }
.ach b { display: block; font-size: 14px; } .ach small { color: var(--muted); font-size: 12px; }

.code { background: var(--panel); padding: 10px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; word-break: break-all; user-select: all; }
ol.steps { padding-left: 20px; line-height: 1.5; font-size: 14px; }
ol.steps li { margin-bottom: 8px; }

/* Navegación */
#tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: #0f1215; border-top: 1px solid var(--line); padding-bottom: var(--safe-b); z-index: 6; }
#tabs button { flex: 1; background: none; border: 0; padding: 9px 0 10px; font-size: 11px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
#tabs button span { display: block; font-size: 18px; margin-bottom: 2px; }
#tabs button.on { color: var(--xp); }

/* Hoja modal */
dialog#sheet { border: 0; padding: 0; background: var(--panel); color: var(--text); width: min(520px, 100vw); max-width: 100vw; margin: auto auto 0; }
dialog#sheet::backdrop { background: rgba(0,0,0,.6); }
#sheet-body { padding: 18px 16px calc(18px + var(--safe-b)); }
#sheet-body h3 { margin: 0 0 12px; font-size: 18px; }
@media (min-width: 600px) { dialog#sheet { margin: auto; } }

/* Avisos */
#toasts { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 70px); left: 0; right: 0; display: grid; justify-items: center; gap: 6px; pointer-events: none; z-index: 20; }
.toast { background: #0f1215; border: 1px solid var(--xp); color: var(--xp); padding: 10px 16px; font-weight: 700; letter-spacing: .04em; animation: pop 2.8s forwards; }
.toast.gold { border-color: var(--gold); color: var(--gold); font-size: 20px; padding: 14px 22px; }
@keyframes pop { 0% { opacity: 0; transform: translateY(-10px) scale(.95); } 8%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* Sesión en curso */
.session { padding-top: 6px; }
.sess-title { font-size: 26px; font-weight: 700; letter-spacing: .03em; transform: skew(-6deg); }
.clock { font-size: 72px; font-weight: 700; line-height: 1; margin: 8px 0; font-variant-numeric: tabular-nums; }
.meter.big { height: 10px; margin: 6px 0; }
.live-stat .bar i { transition: width 1s linear; }
.bar i.gain { filter: brightness(1.6); animation: glow 1.2s ease-in-out infinite alternate; z-index: 1; }
@keyframes glow { from { opacity: .55; } to { opacity: 1; } }
.live-stat .sv { font-variant-numeric: tabular-nums; }
.linkbtn { background: none; border: 0; color: var(--endu); padding: 0; text-decoration: underline; }
.item.block .box { width: 22px; height: 22px; border: 2px solid var(--line); flex: none; display: grid; place-items: center; }
.item.block.done .box { background: var(--xp); border-color: var(--xp); color: #000; }
.item.block.done .n { color: var(--muted); }
.item.today { border-left: 3px solid var(--xp); }
.session-card.done { border-left: 3px solid var(--xp); }
.card b { font-weight: 700; }
#tabs button { font-size: 10px; }

.onb { padding-top: 20px; }
.onb h1 { font-size: 38px; margin: 0; letter-spacing: .04em; transform: skew(-6deg); }
