/* FisioGuía — sistema visual: calma, claridad y botones grandes. */
:root {
  --bg: #f3f7f6;
  --surface: #ffffff;
  --surface-2: #eaf3f1;
  --text: #15302b;
  --muted: #5a6f6a;
  --border: #dbe6e3;
  --primary: #0d8577;
  --primary-strong: #096b60;
  --primary-soft: #d5efea;
  --on-primary: #ffffff;
  --accent: #ff7a50;
  --warn-bg: #fff4e3;
  --warn-ink: #7a4300;
  --warn-line: #f5c27a;
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --info-bg: #e7f3fb;
  --info-ink: #11507a;
  --shadow-1: 0 1px 2px rgba(16, 48, 43, .06), 0 4px 14px rgba(16, 48, 43, .06);
  --shadow-2: 0 10px 30px rgba(16, 48, 43, .14);
  --radius: 20px;
  /* Personaje */
  --stage-a: #e4f4f1;
  --stage-b: #f7fbfa;
  --skin: #f2c4a0;
  --skin-far: #d9a37c;
  --shirt: #14a594;
  --shirt-far: #0c7a6e;
  --pants: #2e4a6e;
  --pants-far: #1f3452;
  --shoe: #1c2836;
  --hair: #3d2b20;
  --face: #2a1f1a;
  --floor: #d8e9e5;
  --ground: #b9d3cd;
  --rig-shadow: rgba(20, 60, 55, .14);
  --wood: #b08d68;
  --wood-light: #c9a882;
  --mat: #8fd3c8;
  --region-cuello: #7c5cff;
  --region-hombro: #0a84ff;
  --region-codo: #00a6a6;
  --region-espalda: #e67e22;
  --region-cadera: #d63384;
  --region-rodilla: #2f9e44;
  --region-tobillo: #c48a00;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1715; --surface: #16231f; --surface-2: #1c2d29; --text: #e6f2ef; --muted: #9db3ad; --border: #29403a;
    --primary: #2bc0ac; --primary-strong: #5fd6c5; --primary-soft: #173b35; --on-primary: #062420;
    --warn-bg: #33270f; --warn-ink: #ffd391; --warn-line: #6b4f1d; --danger: #ff7b6b; --danger-bg: #3a1a17; --info-bg: #13283a; --info-ink: #9fd0f5;
    --shadow-1: 0 1px 2px rgba(0,0,0,.3); --shadow-2: 0 10px 30px rgba(0,0,0,.45);
    --stage-a: #18302b; --stage-b: #132420; --floor: #1d3530; --ground: #2a4a43; --rig-shadow: rgba(0,0,0,.35);
    --mat: #2b6f66; --wood: #8a6b4c; --wood-light: #a5825f; --face: #2a1f1a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html { font-size: 17px; -webkit-text-size-adjust: 100%; }
html.large-text { font-size: 20px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45; -webkit-font-smoothing: antialiased; min-height: 100dvh;
}
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1:focus { outline: none; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.icon { flex: none; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.icon .fill { fill: currentColor; stroke: none; }

.app { max-width: 620px; margin: 0 auto; }
.boot { display: grid; place-items: center; min-height: 100dvh; color: var(--muted); }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--primary-soft); border-top-color: var(--primary); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Página ---- */
.page { min-height: 100dvh; }
.page.has-nav { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 12px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
}
.topbar-text { flex: 1; min-width: 0; }
.topbar h1 { font-size: 1.45rem; font-weight: 750; letter-spacing: -.01em; }
.subtitle { color: var(--muted); font-size: .92rem; margin-top: 2px; }
.subtitle::first-letter { text-transform: uppercase; }
.content { padding: 4px 16px 28px; display: flex; flex-direction: column; gap: 16px; }
.section-title { font-size: 1.1rem; font-weight: 700; margin-top: 8px; }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.row-between h2 { font-size: 1.1rem; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.icon-btn { width: 46px; height: 46px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; flex: none; }

/* ---- Navegación inferior ---- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, 1fr);
  max-width: 620px; margin: 0 auto; padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 94%, transparent); border-top: 1px solid var(--border);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; border: 0; background: none; color: var(--muted); font-size: .76rem; font-weight: 600; border-radius: 14px; min-height: 56px; justify-content: center; }
.nav-item.active { color: var(--primary); }
.nav-item.active .icon { background: var(--primary-soft); border-radius: 12px; padding: 3px 14px; width: 54px; height: 30px; }

/* ---- Botones ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 12px 20px;
  border-radius: 16px; border: 1.5px solid transparent; font-weight: 700; font-size: 1rem; text-align: center;
  transition: transform .12s ease, background-color .2s ease, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.big { min-height: 60px; font-size: 1.08rem; width: 100%; }
.btn.primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 30%, transparent); }
.btn.primary:hover:not(:disabled) { background: var(--primary-strong); }
.btn.secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn.light { background: rgba(255,255,255,.95); color: #0b5e55; min-height: 46px; padding: 10px 16px; align-self: flex-start; }
.btn.ghost { background: transparent; color: var(--muted); min-height: 46px; }
.btn.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }
.btn.danger { background: var(--danger); color: #fff; }
.danger-text { color: var(--danger) !important; }
.link { background: none; border: 0; color: var(--primary); font-weight: 650; padding: 12px; text-decoration: underline; text-underline-offset: 3px; }

/* ---- Tarjetas ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-1); display: flex; flex-direction: column; gap: 10px; }
.card-title { font-size: 1.02rem; font-weight: 700; }
.hero-card {
  display: flex; align-items: center; gap: 16px; padding: 18px; border-radius: 24px; color: #fff;
  background: radial-gradient(120% 140% at 0% 0%, #22c1ad 0%, #0d8577 55%, #0a6a73 100%); box-shadow: var(--shadow-2);
}
.hero-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.hero-text strong { font-size: 1.15rem; }
.hero-text span { opacity: .92; font-size: .95rem; }
.ring { width: 86px; height: 86px; flex: none; }
.ring-bg { fill: none; stroke: rgba(255,255,255,.25); stroke-width: 8; }
.ring-fg { fill: none; stroke: #fff; stroke-width: 8; stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.ring-text { fill: #fff; font-size: 17px; font-weight: 800; }
.note-card { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--info-bg); color: var(--info-ink); }
.note-card p { margin-top: 2px; white-space: pre-line; }

.list { display: flex; flex-direction: column; gap: 10px; }
.ex-card {
  display: grid; grid-template-columns: 84px 1fr auto; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 10px 14px 10px 10px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-1); transition: transform .12s ease, box-shadow .2s;
}
.ex-card:active { transform: scale(.99); }
.ex-card:hover { box-shadow: var(--shadow-2); }
.ex-card.done { background: color-mix(in srgb, var(--primary-soft) 55%, var(--surface)); }
.ex-card-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; align-items: flex-start; }
.ex-title { font-size: 1rem; line-height: 1.25; }
.chev { color: var(--muted); }
.badge-done { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; }
.thumb { width: 84px; height: 84px; border-radius: 16px; overflow: hidden; background: linear-gradient(180deg, var(--stage-b), var(--stage-a)); display: grid; place-items: center; }
.thumb .rig { width: 100%; height: 100%; }
.thumb .rig-focus { display: none; }

.chip { display: inline-block; font-size: .72rem; font-weight: 750; letter-spacing: .02em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px;
  color: var(--rc, var(--primary)); background: color-mix(in srgb, var(--rc, var(--primary)) 13%, transparent); }
[data-region="cuello"] { --rc: var(--region-cuello); }
[data-region="hombro"] { --rc: var(--region-hombro); }
[data-region="codo"] { --rc: var(--region-codo); }
[data-region="espalda"] { --rc: var(--region-espalda); }
[data-region="cadera"] { --rc: var(--region-cadera); }
[data-region="rodilla"] { --rc: var(--region-rodilla); }
[data-region="tobillo"] { --rc: var(--region-tobillo); }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 12px 8px; }
.empty .stack { width: 100%; }
.empty-icon { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.footnote { display: flex; gap: 8px; align-items: flex-start; color: var(--muted); font-size: .85rem; }
.footnote.center { justify-content: center; }

/* ---- Alertas ---- */
.alert { border-radius: 18px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; border: 1px solid transparent; }
.alert-title { display: flex; align-items: center; gap: 8px; font-weight: 750; }
.alert ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.alert.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }
.alert.danger { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.alert.info { background: var(--info-bg); color: var(--info-ink); }
.alert p { white-space: pre-line; }

/* ---- Escenario del personaje ---- */
.stage {
  position: relative; border-radius: 26px; overflow: hidden; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 12px 14px;
  background: radial-gradient(90% 80% at 50% 30%, var(--stage-b) 0%, var(--stage-a) 100%);
  border: 1px solid var(--border);
}
.stage .rig { display: block; width: 100%; height: auto; max-height: 46vh; order: 1; }
.stage.live { box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 45%, transparent); }
.stage.mascot { background: transparent; border: 0; width: min(260px, 70vw); margin: 0 auto; padding: 0; }
.stage.mascot.small { width: min(180px, 50vw); }
.cue {
  order: 2; max-width: 100%; min-height: 42px; display: flex; align-items: center; justify-content: center;
  background: var(--surface); color: var(--text); padding: 8px 16px; border-radius: 999px;
  font-weight: 700; font-size: 1rem; box-shadow: var(--shadow-1); text-align: center;
}
.cue:empty { visibility: hidden; }
.cue.pop { animation: pop .35s ease; }
@keyframes pop { from { transform: scale(.92); opacity: .4; } to { transform: scale(1); opacity: 1; } }
.focus-label {
  order: 0; align-self: flex-start; display: flex; gap: 6px; align-items: center; font-size: .8rem; font-weight: 700;
  background: color-mix(in srgb, var(--surface) 90%, transparent); padding: 5px 10px; border-radius: 999px; max-width: 100%;
}
.focus-swatch { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); flex: none; }
.player { display: flex; flex-direction: column; gap: 10px; }
.controls { display: flex; justify-content: center; gap: 10px; }
.ctrl { min-width: 54px; height: 54px; border-radius: 18px; border: 1px solid var(--border); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 700; box-shadow: var(--shadow-1); }
.ctrl.wide { padding: 0 16px; }
.ctrl[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-strong); }

/* Dibujo del personaje */
.rig .seg { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.rig .shirt { stroke: var(--shirt); stroke-width: 13; }
.rig .shirt.far { stroke: var(--shirt-far); }
.rig .skin { stroke: var(--skin); stroke-width: 10.5; }
.rig .skin.far { stroke: var(--skin-far); }
.rig .pants { stroke: var(--pants); stroke-width: 15; }
.rig .pants.far { stroke: var(--pants-far); }
.rig .shoe { stroke: var(--shoe); stroke-width: 9; }
.rig .torso { stroke: var(--shirt); stroke-width: 30; }
.rig.front .torso { stroke-width: 36; }
.rig .neck { stroke: var(--skin); stroke-width: 10; }
.rig .skinfill { fill: var(--skin); }
.rig .skinfill.far { fill: var(--skin-far); }
.rig .head { fill: var(--skin); }
.rig .ear { fill: var(--skin-far); }
.rig .hair { fill: var(--hair); }
.rig .eye { fill: var(--face); }
.rig .mouth { fill: none; stroke: var(--face); stroke-width: 2; stroke-linecap: round; }
.rig .cheek { fill: #ff8a7a; opacity: .35; }
.rig .rig-floor { fill: var(--floor); }
.rig .rig-ground { stroke: var(--ground); stroke-width: 2; }
.rig .rig-shadow { fill: var(--rig-shadow); }
.rig .prop-mat { fill: var(--mat); }
.rig .prop-wood { fill: var(--wood); }
.rig .prop-seat { fill: var(--wood-light); }
.rig .focus-dot { fill: var(--accent); stroke: #fff; stroke-width: 2; }
.rig .focus-pulse { fill: var(--accent); opacity: .35; transform-box: fill-box; transform-origin: center; animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { 0% { transform: scale(.6); opacity: .55; } 100% { transform: scale(1.6); opacity: 0; } }

/* ---- Panel de sesión ---- */
.panel { display: flex; flex-direction: column; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: 16px; box-shadow: var(--shadow-1); }
.panel-title { font-size: 1.12rem; text-align: center; }
.dose { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.dose > div { background: var(--surface-2); border-radius: 16px; padding: 10px 6px; display: flex; flex-direction: column; align-items: center; }
.dose-num { font-size: 1.6rem; font-weight: 800; color: var(--primary-strong); }
.dose-label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.counter { text-align: center; }
.counter-main { display: flex; align-items: baseline; justify-content: center; gap: 6px; }
.big-num { font-size: 3.4rem; font-weight: 850; line-height: 1; color: var(--primary-strong); font-variant-numeric: tabular-nums; }
.counter-of { font-size: 1.5rem; font-weight: 700; color: var(--muted); }
.counter-sub { color: var(--muted); display: flex; gap: 8px; justify-content: center; align-items: center; margin-top: 4px; font-weight: 600; }
.set-pill, .pill { background: var(--primary-soft); color: var(--primary-strong); padding: 3px 10px; border-radius: 999px; font-size: .82rem; font-weight: 750; }
.bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-fill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), #3fd3bf); border-radius: inherit; transition: width .4s ease; }
.countdown { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0; font-weight: 650; }
.countdown-num { font-size: 4rem; font-weight: 850; line-height: 1.05; color: var(--primary-strong); font-variant-numeric: tabular-nums; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: var(--surface-2); padding: 5px; border-radius: 16px; }
.segmented button { min-height: 48px; border: 0; border-radius: 12px; background: transparent; font-weight: 700; color: var(--muted); }
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--primary-strong); box-shadow: var(--shadow-1); }
.celebrate { text-align: center; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.confetti { display: block; font-size: 3.2rem; line-height: 1.1; animation: bounce .8s ease; }
@keyframes bounce { 0% { transform: scale(.3) rotate(-20deg); } 60% { transform: scale(1.15) rotate(6deg); } 100% { transform: scale(1); } }

/* Escala de dolor */
.pain { display: flex; flex-direction: column; gap: 10px; }
.pain-display { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; }
.pain-face { font-size: 2.2rem; line-height: 1; }
.pain-label { font-weight: 750; font-size: 1.05rem; }
.pain-row { display: grid; grid-template-columns: repeat(11, 1fr); gap: 4px; }
.pain-btn {
  aspect-ratio: 1 / 1.25; min-height: 40px; border-radius: 10px; border: 2px solid transparent; font-weight: 800; font-size: .95rem; padding: 0;
  background: hsl(var(--h) 70% 88%); color: hsl(var(--h) 60% 22%); transition: transform .12s;
}
.pain-btn[aria-checked="true"] { transform: scale(1.12); border-color: hsl(var(--h) 60% 30%); background: hsl(var(--h) 65% 55%); color: #fff; }
.pain-ends { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); }

/* ---- Información del ejercicio ---- */
.info { display: flex; flex-direction: column; gap: 12px; }
.meta-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.meta { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; font-size: .92rem; }
.goal { font-size: 1.02rem; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: 10px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: start; }
.steps li::before { content: counter(s); width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-strong); display: grid; place-items: center; font-weight: 800; }
.tips { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }

/* ---- Mapa corporal ---- */
.library-top { display: flex; flex-direction: column; gap: 12px; }
.bodymap { position: relative; width: min(300px, 86%); margin: 0 auto; background: radial-gradient(60% 60% at 50% 45%, var(--stage-a), transparent 70%); border-radius: 28px; }
.bodymap .rig { display: block; width: 100%; height: auto; }
.bodymap .rig-floor, .bodymap .rig-ground { display: none; }
.spot { position: absolute; transform: translate(-50%, -50%); width: 46px; height: 46px; border: 0; background: none; padding: 0; display: grid; place-items: center; }
.spot-dot { width: 17px; height: 17px; border-radius: 50%; background: var(--rc); border: 3px solid #fff; box-shadow: 0 0 0 0 color-mix(in srgb, var(--rc) 50%, transparent); animation: ring 2.2s ease-out infinite; }
.spot.active .spot-dot { width: 22px; height: 22px; animation: none; box-shadow: 0 0 0 6px color-mix(in srgb, var(--rc) 30%, transparent); }
@keyframes ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--rc) 55%, transparent); } 100% { box-shadow: 0 0 0 14px transparent; } }
.spot-label { position: absolute; top: 50%; transform: translateY(-50%); white-space: nowrap; font-size: .78rem; font-weight: 750; padding: 4px 9px; border-radius: 999px;
  background: var(--surface); color: var(--rc); box-shadow: var(--shadow-1); border: 1px solid color-mix(in srgb, var(--rc) 30%, transparent); }
.spot.r .spot-label { left: 40px; }
.spot.l .spot-label { right: 40px; }
.spot.active .spot-label { background: var(--rc); color: #fff; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip-btn { flex: none; min-height: 42px; padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--border); background: var(--surface); font-weight: 700; font-size: .9rem; }
.chip-btn.active { background: var(--rc, var(--primary)); border-color: var(--rc, var(--primary)); color: #fff; }
.region-block { display: flex; flex-direction: column; gap: 10px; }

/* ---- Progreso ---- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 12px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow-1); color: var(--primary); }
.stat strong { font-size: 1.7rem; color: var(--text); font-weight: 850; }
.stat span { font-size: .78rem; color: var(--muted); font-weight: 600; line-height: 1.25; }
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; }
.wday { display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 700; font-size: .85rem; color: var(--muted); }
.wdot { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; }
.wday.on .wdot { background: var(--primary); color: var(--on-primary); }
.wday.today span:first-child { color: var(--primary); }
.wday.today .wdot { outline: 2px solid var(--primary); outline-offset: 2px; }
.chart { width: 100%; height: auto; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .line { fill: none; stroke: var(--primary); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart .pt { fill: var(--surface); stroke: var(--primary); stroke-width: 2.5; }
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.hist { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 12px 14px; }
.hist > div { display: flex; flex-direction: column; min-width: 0; }
.pain-chip { flex: none; font-weight: 800; font-variant-numeric: tabular-nums; background: var(--surface-2); padding: 4px 10px; border-radius: 999px; font-size: .88rem; }

/* ---- Ajustes ---- */
.settings { padding: 6px; gap: 0; }
.setting, .list-btn { display: flex; align-items: center; gap: 12px; padding: 12px 10px; min-height: 64px; width: 100%; text-align: left; background: none; border: 0; border-radius: 14px; }
.setting + .setting, .list-btn + .list-btn, .setting + .list-btn { border-top: 1px solid var(--border); border-radius: 0; }
.list-btn:hover { background: var(--surface-2); }
.list-btn.danger { color: var(--danger); }
.list-btn .icon:last-child { color: var(--muted); }
.setting-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; flex: none; color: var(--primary); }
.list-btn.danger .setting-icon { color: var(--danger); background: var(--danger-bg); }
.setting-text { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.switch { width: 56px; height: 34px; border-radius: 999px; border: 0; background: var(--border); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch[aria-checked="true"] { background: var(--primary); }
.switch[aria-checked="true"]::after { transform: translateX(22px); }

/* ---- Formularios ---- */
.input { width: 100%; min-height: 52px; padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--border); background: var(--surface); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.input.big { font-size: 1.2rem; min-height: 60px; }
.input.invalid { border-color: var(--danger); box-shadow: 0 0 0 4px var(--danger-bg); }
.select { width: auto; min-width: 100px; }
textarea.input { resize: vertical; }
.code-input { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .85rem; word-break: break-all; }
.field-label { font-weight: 700; font-size: .92rem; }
.field-error { color: var(--danger); font-weight: 650; min-height: 1.2em; }
.check { display: flex; gap: 12px; align-items: center; padding: 14px; background: var(--surface-2); border-radius: 16px; font-weight: 650; cursor: pointer; }
.check input { width: 26px; height: 26px; accent-color: var(--primary); flex: none; }
.code { white-space: pre-wrap; font-size: .85rem; background: var(--surface-2); padding: 12px; border-radius: 12px; }
.mini-list { margin: 0; padding-left: 20px; }

/* ---- Bienvenida y PIN ---- */
.onboarding { min-height: 100dvh; display: grid; place-items: center; padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); }
.ob-card { width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 16px; }
.ob-head { display: flex; align-items: center; gap: 12px; }
.ob-progress { flex: 1; display: flex; gap: 6px; }
.ob-progress span { flex: 1; height: 6px; border-radius: 999px; background: var(--border); }
.ob-progress span.on { background: var(--primary); }
.hero-title { font-size: 2rem; text-align: center; font-weight: 800; letter-spacing: -.02em; }
.ob-card h1 { font-size: 1.6rem; }
.lead { text-align: center; color: var(--muted); font-size: 1.05rem; }
.features { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.features li { display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 12px 14px; }
.features .icon { color: var(--primary); }
.safety-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.safety-list li { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 12px 14px; }
.safety-list li .icon { color: var(--primary); margin-top: 1px; }
.safety-list li.danger { background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.safety-list li.danger .icon { color: var(--danger); }
.card .safety-list li { border: 0; background: var(--surface-2); }
.pinpad { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.pinpad.busy .pin-keys { opacity: .5; pointer-events: none; }
.pin-title { font-size: 1.4rem; text-align: center; }
.pin-dots { display: flex; gap: 14px; padding: 8px 0; }
.pin-dots .dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--primary); transition: background .15s, transform .15s; }
.pin-dots .dot.on { background: var(--primary); transform: scale(1.1); }
.pin-msg { min-height: 1.4em; font-weight: 650; color: var(--muted); text-align: center; }
.pin-msg.err { color: var(--danger); }
.pin-keys { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px 22px; }
.pin-key { width: 76px; height: 76px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); font-size: 1.7rem; font-weight: 650; box-shadow: var(--shadow-1); transition: transform .08s, background .15s; }
.pin-key:active { transform: scale(.94); background: var(--primary-soft); }
.pin-key.del { background: transparent; box-shadow: none; border-color: transparent; font-size: 1.5rem; }
.shake { animation: shake .4s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ---- Modo profesional ---- */
.pro-region { display: flex; flex-direction: column; gap: 8px; }
.pro-region h3 { font-size: .95rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 6px; }
.pro-row { background: var(--surface); border: 1.5px solid var(--border); border-radius: 18px; overflow: hidden; }
.pro-row.on { border-color: var(--primary); }
.pro-head { display: grid; grid-template-columns: 28px 64px 1fr; gap: 12px; align-items: center; padding: 10px 12px; cursor: pointer; }
.pro-head input { width: 26px; height: 26px; accent-color: var(--primary); }
.pro-head .thumb { width: 64px; height: 64px; border-radius: 12px; }
.pro-config:not(:empty) { padding: 4px 12px 14px; display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--border); padding-top: 12px; }
.steppers { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stepper { background: var(--surface-2); border-radius: 14px; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.step-label { font-size: .78rem; font-weight: 700; color: var(--muted); }
.step-ctrl { display: flex; align-items: center; justify-content: space-between; }
.step-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; }
.step-val { font-weight: 800; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.sticky-actions { position: sticky; bottom: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--bg) 30%); }

/* ---- Diálogos y avisos ---- */
.dialog { border: 0; border-radius: 24px; padding: 20px; width: min(440px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-2); display: flex; flex-direction: column; gap: 12px; }
.dialog:not([open]) { display: none; }
.dialog::backdrop { background: rgba(8, 25, 22, .5); backdrop-filter: blur(3px); }
.dialog h2 { font-size: 1.25rem; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; }
.dialog-actions .btn { flex: 1; }
.toast { position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50; background: var(--text); color: var(--bg);
  padding: 12px 18px; border-radius: 14px; font-weight: 650; box-shadow: var(--shadow-2); max-width: calc(100vw - 32px); animation: toastIn .25s ease; transition: opacity .4s, transform .4s; }
.toast.error { background: var(--danger); color: #fff; }
.toast.out { opacity: 0; transform: translate(-50%, 10px); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } }

@media (max-width: 380px) {
  .pin-keys { grid-template-columns: repeat(3, 68px); gap: 12px 18px; }
  .pin-key { width: 68px; height: 68px; }
  .meta-row { grid-template-columns: 1fr 1fr; }
  .stat { padding: 10px; }
  .stat strong { font-size: 1.35rem; }
  .ex-card { grid-template-columns: 70px 1fr auto; }
  .thumb { width: 70px; height: 70px; }
  .pain-btn { font-size: .82rem; }
}
@media (prefers-reduced-motion: reduce) {
  .cue.pop, .confetti, .shake, .spot-dot, .toast { animation: none !important; }
  .btn, .ex-card, .switch::after { transition: none; }
}
