:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1a1c1e;
  --muted: #5c6169;
  --line: #e2e5ea;
  --brand: #b3261e;
  --brand-ink: #ffffff;
  --ok: #1e7d47;
  --warn: #b8860b;
  --danger: #b3261e;
  --accent: #2b5fb3;
  --radius: 14px;
  --tap: 46px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181c; --card: #1f2228; --ink: #eceef1; --muted: #a2a8b3;
    --line: #30343c; --brand: #e2564d; --accent: #6ea0ff; --ok: #4bbd77; --warn: #e0b64a;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.4;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--brand); color: var(--brand-ink);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.topbar-title { font-weight: 700; font-size: 18px; }
.topbar-sub { font-size: 12.5px; opacity: .9; margin-top: 2px; }
.app { max-width: 720px; margin: 0 auto; padding: 14px 12px 24px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; text-align: center; text-decoration: none; color: var(--muted);
  font-size: 11px; padding: 7px 2px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tabbar a span { font-size: 20px; line-height: 1; }
.tabbar a.active { color: var(--brand); font-weight: 600; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}
.card h2 { margin: 0 0 8px; font-size: 16px; }
.card h3 { margin: 12px 0 6px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.spec { color: var(--muted); font-size: 13px; margin: 2px 0 8px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 8px; }

label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 3px; }
input, select, textarea, button {
  font: inherit; color: var(--ink);
}
input[type=number], input[type=text], input[type=date], input[type=password], select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); min-height: var(--tap);
}
textarea { min-height: 70px; resize: vertical; }
.field { margin-bottom: 10px; }
.field-inline { display: flex; gap: 8px; align-items: flex-end; }
.field-inline .field { margin-bottom: 0; }
.col { display: flex; flex-direction: column; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

button, .btn {
  cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 10px; padding: 11px 14px; min-height: var(--tap); font-weight: 600;
}
a.btn { display: inline-block; text-align: center; text-decoration: none; box-sizing: border-box; }
a.btn.block { display: block; }
.checkrow { display: flex; gap: 8px; align-items: flex-start; color: var(--ink); font-size: 15px; }
.checkrow input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
.checkrow span { flex: 1; }
button.primary, .btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
button.accent { background: var(--accent); color: #fff; border-color: var(--accent); }
button.ghost { background: transparent; }
button.sm { min-height: 38px; padding: 7px 10px; font-size: 13px; font-weight: 600; }
button.block { width: 100%; }
button:disabled { opacity: .5; }

.badge { display: inline-block; font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--line); color: var(--ink); font-weight: 600; }
.badge.brand { background: var(--brand); color: #fff; }
.badge.warn { background: var(--warn); color: #fff; }
.badge.ok { background: var(--ok); color: #fff; }
.badge.deload { background: #6d28d9; color: #fff; }

.alert { border-radius: 10px; padding: 10px 12px; margin: 6px 0; font-size: 14px; font-weight: 500; }
.alert.ok { background: rgba(30,125,71,.14); color: var(--ok); }
.alert.warning { background: rgba(184,134,11,.16); color: var(--warn); }
.alert.danger { background: rgba(179,38,30,.14); color: var(--danger); }

.checkline { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.checkline:last-child { border-bottom: none; }
.checkbtn { width: 34px; height: 34px; min-height: 34px; border-radius: 8px; padding: 0; font-size: 16px; flex: none; }
.checkbtn.on { background: var(--ok); color: #fff; border-color: var(--ok); }

.setrow { display: grid; grid-template-columns: auto 1fr 1fr auto; gap: 6px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.setrow .idx { font-weight: 700; min-width: 26px; color: var(--muted); font-size: 13px; }
.setrow input { min-height: 44px; padding: 8px; }
.setrow .checkbtn, .warmrow .checkbtn { width: 46px; height: 46px; min-height: 46px; border-radius: 12px; font-size: 19px; }
.warmrow { display: grid; grid-template-columns: auto 1fr auto auto; gap: 6px; align-items: center; padding: 5px 0; }
.warmrow .w { font-weight: 700; }

/* Escala 0-10 de un toque (monitoreo) */
.scale { display: flex; gap: 3px; }
.scale button { flex: 1; min-width: 0; min-height: 40px; padding: 0; border-radius: 8px; font-size: 14px; font-weight: 600; }
.scale button.sel { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Acordeon de ejercicios */
.excard .exhead { cursor: pointer; user-select: none; }
.excard.collapsed .exbody { display: none; }
.exsum { font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.exsum.done { color: var(--ok); }
.chev { display: inline-block; transition: transform .15s; color: var(--muted); font-size: 12px; }
.excard.collapsed .chev { transform: rotate(-90deg); }

/* Barra de progreso de sesion */
.progressbar { height: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.progressbar > div { height: 100%; background: var(--ok); transition: width .3s; }

/* Sugerencia de progresion */
.hintline { font-size: 12.5px; color: var(--accent); margin-top: 4px; }

.timerbar {
  position: sticky; bottom: 64px; z-index: 15; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 8px 10px; display: flex; align-items: center; gap: 8px; margin: 10px 0;
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
}
.timerbar .time { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 22px; min-width: 74px; text-align: center; }

.fixedcta { position: sticky; bottom: calc(64px + 6px); z-index: 16; margin-top: 14px; }

.pill-toggle { display: flex; gap: 6px; }
.pill-toggle button { flex: 1; min-height: 40px; }
.pill-toggle button.sel { background: var(--brand); color: #fff; border-color: var(--brand); }
.pill-toggle.up button.sel.up { background: var(--ok); border-color: var(--ok); }
.pill-toggle.down button.sel.down { background: var(--danger); border-color: var(--danger); }

.list-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 4px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.list-item:last-child { border-bottom: none; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .h { font-size: 11px; text-align: center; color: var(--muted); }
.cal .d { aspect-ratio: 1/1; border-radius: 7px; background: var(--bg); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 10px; position: relative; }
.cal .d.done { background: var(--ok); color: #fff; border-color: var(--ok); }
.cal .d.planned { background: rgba(43,95,179,.14); }
.cal .d.deload { background: #6d28d9; color: #fff; border-color: #6d28d9; }

.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; margin: 6px 0; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: middle; }
.chartwrap { width: 100%; overflow-x: auto; }
svg.chart { width: 100%; height: auto; display: block; }
.metricbig { font-size: 26px; font-weight: 800; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 78px; z-index: 50;
  background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
.toast.err { background: var(--danger); }

.hint { background: rgba(43,95,179,.1); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.warnbox { background: rgba(179,38,30,.1); border: 1px solid rgba(179,38,30,.3); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
hr.sep { border: none; border-top: 1px solid var(--line); margin: 12px 0; }
.center { text-align: center; }
