:root {
  /* escala de grises neutros (sin tinte azul) + naranja de acento */
  --bg: #0e0e10;
  --bg-2: #161618;
  --card: #1b1b1e;
  --card-2: #232326;
  --line: #2c2c31;
  --line-2: #3c3c42;
  --txt: #ededf0;
  --muted: #9a9aa4;
  --accent: #f97316;
  --accent-2: #22c55e;
  --blue: #3b82f6;
  --purple: #a855f7;
  --cyan: #06b6d4;
  --red: #ef4444;
  --amber: #f59e0b;
  --radius: 14px;
  --shadow: 0 8px 28px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }

img { max-width: 100%; height: auto; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--txt);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: .4rem 0; }
code { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: .1rem .35rem; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.tiny { font-size: .78rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 1rem;
  padding: .65rem 1.1rem;
  background: rgba(14,14,16,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav { display: flex; gap: .15rem; flex-wrap: wrap; }
.nav a {
  padding: .4rem .7rem; border-radius: 9px; color: var(--muted);
  font-size: .9rem; font-weight: 600;
}
.nav a:hover { background: var(--card); color: var(--txt); text-decoration: none; }
.nav a.on { background: var(--accent); color: #fff; }
.topbar-user { display: flex; align-items: center; gap: .6rem; margin-left: auto; }
.who { font-weight: 700; font-size: .9rem; max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- layout ---------- */
.wrap { max-width: 1280px; margin: 0 auto; padding: 1.4rem 1.1rem 3rem; }
.wrap-auth { max-width: 460px; padding-top: 2.5rem; padding-bottom: 2.5rem; }

/* ---------- auth ---------- */
/* fondo: img/background.jpg oscurecido con un velo; si falta la imagen se ve --bg.
 * Lo usan el login y el selector de sesion del arranque. */
body.auth-page {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(8,8,10,.52), rgba(8,8,10,.78)),
    url("../img/background.jpg") center center / cover no-repeat scroll;
  background-color: var(--bg);
}
.auth { display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; min-height: calc(100vh - 8rem); min-height: calc(100svh - 7rem); }
.auth-card {
  width: 100%;
  background: rgba(27,27,30,.86);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line-2);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius); padding: 1.9rem; box-shadow: var(--shadow);
}
.auth-head { text-align: center; margin-bottom: 1.4rem; }
.auth-head h1 { margin: 0 0 .35rem; font-size: 1.7rem; letter-spacing: -.5px; }
.auth-head p { margin: 0; }

/* ---------- selector de sesion del arranque ---------- */
body.start-screen .topbar { display: none; }
.start-screen-wrap {
  display: grid; place-items: center;
  min-height: calc(100vh - 8rem); min-height: calc(100svh - 7rem);
}
.start-panel { width: min(560px, 100%); }
.start-panel .focus-dialog-actions { justify-content: center; gap: 1.4rem; margin-top: 1.2rem; }
.start-panel .focus-dialog-actions .btn { flex: 0 1 auto; }

/* ---------- forms ---------- */
.form { display: grid; gap: .45rem; }
.form label { font-size: .82rem; color: var(--muted); font-weight: 600; margin-top: .35rem; }
input, select, textarea {
  width: 100%; padding: .6rem .7rem;
  background: var(--bg-2); color: var(--txt);
  border: 1px solid var(--line-2); border-radius: 9px;
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent;
}
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: .8rem; margin: 0; }
legend { padding: 0 .35rem; font-size: .82rem; color: var(--muted); font-weight: 700; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem; }
@media (max-width: 760px) { .grid2, .grid3, .grid4 { grid-template-columns: minmax(0, 1fr); } }

.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .35rem .6rem; border-radius: 999px;
  background: var(--card-2); border: 1px solid var(--line-2);
  font-size: .82rem; cursor: pointer; user-select: none;
}
.chip input { display: none; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .58rem 1rem; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 700; font-size: .9rem; cursor: pointer;
  background: var(--card-2); color: var(--txt);
}
.btn:hover { filter: brightness(1.12); text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line-2); color: var(--muted); }
.btn-ok { background: var(--accent-2); color: #06210f; }
.btn-sm { padding: .34rem .65rem; font-size: .8rem; }
.btn-block { width: 100%; margin-top: .9rem; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem;
}
.card + .card { margin-top: 1rem; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: .7rem; flex-wrap: wrap; margin-bottom: .8rem;
}
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.stack > *, .grid2 > *, .grid3 > *, .grid4 > * { min-width: 0; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr)); gap: .7rem; }
.stat {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 11px; padding: .7rem .8rem;
}
.stat .k { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }
.stat .v { font-size: 1.4rem; font-weight: 800; line-height: 1.15; }
.stat .s { font-size: .78rem; color: var(--muted); }
.delta-up { color: var(--accent-2); }
.delta-dn { color: var(--blue); }
.delta-no { color: var(--muted); }

/* ---------- badges ---------- */
.badge {
  display: inline-block; padding: .12rem .45rem; border-radius: 6px;
  font-size: .72rem; font-weight: 800; letter-spacing: .3px;
  background: var(--card-2); color: var(--muted); border: 1px solid var(--line-2);
}
.badge.compound { background: rgba(59,130,246,.15); color: #93c5fd; border-color: rgba(59,130,246,.35); }
.badge.isolation { background: rgba(168,85,247,.15); color: #d8b4fe; border-color: rgba(168,85,247,.35); }
.badge.beginner { background: rgba(34,197,94,.14); color: #86efac; border-color: rgba(34,197,94,.32); }
.badge.intermediate { background: rgba(245,158,11,.14); color: #fcd34d; border-color: rgba(245,158,11,.32); }
.badge.advanced { background: rgba(239,68,68,.14); color: #fca5a5; border-color: rgba(239,68,68,.32); }
.badge.ok { background: rgba(34,197,94,.16); color: #86efac; border-color: rgba(34,197,94,.34); }
.badge.no { background: rgba(239,68,68,.16); color: #fca5a5; border-color: rgba(239,68,68,.34); }

/* ---------- alerts ---------- */
.alert { padding: .7rem .9rem; border-radius: 10px; margin: .6rem 0; font-size: .88rem; }
.alert-err { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.4); color: #fca5a5; }
.alert-ok { background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.4); color: #86efac; }
.alert-warn { background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.4); color: #fcd34d; }
.alert-info { background: rgba(59,130,246,.12); border: 1px solid rgba(59,130,246,.4); color: #93c5fd; }
.note {
  border-left: 3px solid var(--line-2); padding: .3rem 0 .3rem .7rem;
  color: var(--muted); font-size: .82rem; margin: .4rem 0;
}
.note.evitar { border-color: var(--red); }
.note.aviso { border-color: var(--amber); }
.note.modificacion { border-color: var(--blue); }
.note.alerta { border-color: var(--red); background: rgba(239,68,68,.06); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .55rem .7rem; text-align: left; border-bottom: 1px solid var(--line); }
th { background: var(--bg-2); font-size: .74rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 800; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.02); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- exercise item ---------- */
.ex {
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg-2); padding: .85rem; margin-bottom: .7rem;
}
.ex.done { border-color: rgba(34,197,94,.45); background: rgba(34,197,94,.05); }
.ex-top { display: flex; align-items: flex-start; gap: .6rem; flex-wrap: wrap; }
.ex-order {
  width: 26px; height: 26px; flex: 0 0 26px; display: grid; place-items: center;
  border-radius: 8px; background: var(--card-2); font-weight: 800; font-size: .82rem;
}
.ex-name { font-weight: 700; font-size: .98rem; }
.ex-presc {
  display: flex; gap: .8rem; flex-wrap: wrap; margin: .55rem 0;
  padding: .5rem .6rem; background: var(--card); border-radius: 9px;
  font-variant-numeric: tabular-nums;
}
.ex-presc div { font-size: .82rem; }
.ex-presc b { display: block; font-size: .95rem; }
.ex-presc span { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .3px; }
.ex details { margin-top: .45rem; }
.ex summary { cursor: pointer; font-size: .83rem; color: var(--accent); font-weight: 600; }
.ex details .body { margin-top: .5rem; font-size: .85rem; color: var(--muted); }
.ex ul { margin: .3rem 0; padding-left: 1.1rem; }
.ex li { margin: .15rem 0; }

/* ---------- exercise illustration ---------- */
.ex-thumb {
  position: relative; display: block; flex: 0 0 auto;
  width: clamp(104px, 22vw, 148px); padding: 0;
  border: 1px solid var(--line-2); border-radius: 10px;
  background: #f1f1f3; overflow: hidden; cursor: zoom-in;
  appearance: none; font: inherit;
}
.ex-thumb img {
  display: block; width: 100%; height: auto;
  aspect-ratio: 3 / 2; object-fit: cover;
  transition: transform .18s ease;
}
.ex-thumb:hover img, .ex-thumb:focus-visible img { transform: scale(1.04); }
.ex-thumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ex-thumb-hint {
  position: absolute; right: 5px; bottom: 5px;
  padding: .1rem .4rem; border-radius: 99px;
  background: rgba(0,0,0,.82); color: #fff;
  font-size: .62rem; font-weight: 700; letter-spacing: .3px;
  opacity: 0; transition: opacity .15s ease; pointer-events: none;
}
.ex-thumb:hover .ex-thumb-hint, .ex-thumb:focus-visible .ex-thumb-hint { opacity: 1; }
.ex-thumb-sm { width: 60px; border-radius: 8px; }
.ex-thumb-sm .ex-thumb-hint { display: none; }
h4 .ex-thumb { display: inline-block; vertical-align: middle; margin: 0 .5rem .1rem 0; }
h4 .ex-thumb-sm { width: 58px; }

/* inline figure inside the technique block */
.ex-figure { display: grid; gap: .5rem; margin: .6rem 0; }
.ex-figure img {
  width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover;
  border: 1px solid var(--line-2); border-radius: 10px; background: #f1f1f3;
}
.ex-figure figcaption { font-size: .78rem; color: var(--muted); }

/* ---------- lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 1rem; }
.lightbox[hidden] { display: none; }
.lightbox-backdrop {
  position: absolute; inset: 0; border: 0; padding: 0;
  background: rgba(0,0,0,.82); backdrop-filter: blur(4px); cursor: pointer;
}
.lightbox-panel {
  position: relative; z-index: 1;
  width: min(760px, 96vw); max-height: 92vh; overflow: auto;
  background: var(--card); border: 1px solid var(--line-2);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .9rem;
}
.lightbox-panel > img {
  display: block; width: 100%; height: auto; aspect-ratio: 3 / 2;
  object-fit: cover; background: #f1f1f3;
  border: 1px solid var(--line-2); border-radius: 10px;
}
.lightbox-panel h3 { margin: .7rem 0 .15rem; }
.lightbox-meta { color: var(--muted); font-size: .78rem; margin: 0 0 .5rem; }
.lightbox-panel .lb-desc { font-size: .88rem; color: var(--muted); margin: .4rem 0; }
.lightbox-panel .lb-rom {
  font-size: .82rem; color: var(--muted);
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 9px; padding: .5rem .6rem;
}
.lightbox-panel ul { margin: .5rem 0 0; padding-left: 1.1rem; font-size: .85rem; }
.lightbox-panel li { margin: .18rem 0; }
.lightbox-close {
  position: absolute; top: .55rem; right: .55rem; z-index: 2;
  width: 32px; height: 32px; display: grid; place-items: center;
  border: 1px solid var(--line-2); border-radius: 50%;
  background: rgba(20,20,22,.92); color: #fff;
  font-size: 1rem; line-height: 1; cursor: pointer;
}
.lightbox-close:hover { background: var(--accent); border-color: var(--accent); }
body.lb-open { overflow: hidden; }
.lightbox figcaption { margin-top: .5rem; }

/* ---------- exercise catalogue ---------- */
.filters {
  display: flex; gap: .7rem; flex-wrap: wrap; align-items: flex-end;
  margin-bottom: 1rem;
}
.filters label { display: grid; gap: .25rem; flex: 1 1 180px; min-width: 150px; }
.filters label > span {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .4px;
  color: var(--muted); font-weight: 700;
}
.filters input, .filters select {
  width: 100%; padding: .5rem .6rem; border-radius: 9px;
  border: 1px solid var(--line-2); background: var(--bg-2);
  color: var(--txt); font: inherit;
}
.filters input:focus, .filters select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.filter-actions { display: flex; gap: .5rem; align-items: center; }

.exgrid {
  display: grid; gap: .8rem;
  grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr));
}
.excard {
  display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg-2); cursor: pointer;
  transition: border-color .15s ease, transform .15s ease;
}
.excard:hover { border-color: var(--line-2); transform: translateY(-2px); }
.excard .ex-thumb { width: 100%; border: 0; border-radius: 0; }
.excard .ex-thumb-hint { opacity: 1; }
.excard-noimg {
  display: grid; place-items: center; aspect-ratio: 3 / 2;
  background: var(--card); color: var(--muted);
  font-size: .8rem; border-bottom: 1px solid var(--line);
}
.excard-body { padding: .55rem .7rem .75rem; display: grid; gap: .3rem; }
.excard-body h3 { margin: 0; font-size: .94rem; line-height: 1.3; }
.excard-body p { margin: 0; }
.excard-badges { display: flex; flex-wrap: wrap; gap: .3rem; }

@media (max-width: 720px) {
  .exgrid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .filters { flex-direction: column; align-items: stretch; }
  .ex-thumb { width: 116px; }
}

/* set logger */
.sets { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .5rem; align-items: center; }
.setbox {
  display: flex; align-items: center; gap: .3rem;
  background: var(--card); border: 1px solid var(--line-2);
  border-radius: 9px; padding: .25rem .35rem;
}
.setbox span { font-size: .72rem; color: var(--muted); font-weight: 700; }
.setbox input { width: 58px; padding: .25rem .3rem; font-size: .85rem; }
.setbox input.num { width: 48px; text-align: center; }
.btn-check {
  width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line-2);
  background: var(--card-2); color: var(--muted); cursor: pointer; font-weight: 800;
  display: grid; place-items: center;
}
.btn-check.on { background: var(--accent-2); color: #06210f; border-color: var(--accent-2); }

/* ---------- calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-h { text-align: center; font-size: .72rem; color: var(--muted); font-weight: 800; padding: .35rem 0; }
.cal-d {
  min-height: 74px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg-2); padding: .35rem; font-size: .74rem;
  display: flex; flex-direction: column; gap: .15rem;
}
.cal-d.out { opacity: .32; }
.cal-d.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.cal-d.rest { background: #141416; }
.cal-d .dnum { font-weight: 800; font-size: .8rem; }
.cal-d .tag { font-size: .66rem; padding: .05rem .25rem; border-radius: 4px; font-weight: 700; }
.tag-done { background: rgba(34,197,94,.2); color: #86efac; }
.tag-rest { background: var(--card-2); color: var(--muted); }
.tag-load { background: rgba(59,130,246,.18); color: #93c5fd; }

/* ---------- bars ---------- */
.bar { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar > i.g { background: var(--accent-2); }
.bar > i.b { background: var(--blue); }
.bar > i.p { background: var(--purple); }
.bar-lg { height: 22px; }

.minibars { display: flex; align-items: flex-end; gap: 3px; height: 90px; }
.minibars > div { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.minibars > div.g { background: var(--accent-2); }
.minibars > div.b { background: var(--blue); }
.minibars .lbl { position: absolute; bottom: -18px; left: 0; right: 0; text-align: center; font-size: .62rem; color: var(--muted); }

/* ---------- goal picker ---------- */
.goal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); gap: .7rem; }
.goal-card {
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg-2);
  padding: .9rem; cursor: pointer; position: relative;
}
.goal-card:hover { border-color: var(--line-2); }
.goal-card.on { border-color: var(--accent); background: rgba(249,115,22,.07); }
.goal-card .ic { font-size: 1.5rem; }
.goal-card h4 { margin: .35rem 0 .2rem; }
.goal-card p { font-size: .8rem; color: var(--muted); }

/* ---------- rank bars ---------- */
.rankrow { display: grid; grid-template-columns: minmax(0, 1fr) 80px; gap: .6rem; align-items: center; padding: .35rem 0; }
.rankrow .who2 { display: flex; align-items: center; gap: .4rem; font-size: .86rem; }
.rankrow .val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }
.dot.me { background: var(--accent); }
.dot.other { background: var(--blue); }

/* ---------- day strip ---------- */
.strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.strip a {
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2);
  padding: .45rem .3rem; text-align: center; color: var(--txt); font-size: .76rem;
}
.strip a:hover { border-color: var(--line-2); text-decoration: none; }
.strip a.on { border-color: var(--accent); background: rgba(249,115,22,.12); }
.strip a.done { background: rgba(34,197,94,.14); border-color: rgba(34,197,94,.4); }
.strip a .d { font-weight: 800; font-size: .95rem; }
.strip a .w { color: var(--muted); font-size: .68rem; display: block; }

/* ---------- misc ---------- */
.meter { display: grid; gap: .25rem; }
.meter-top { display: flex; justify-content: space-between; font-size: .8rem; }
details.acc { border: 1px solid var(--line); border-radius: 10px; padding: .6rem .8rem; background: var(--bg-2); }
details.acc summary { cursor: pointer; font-weight: 700; font-size: .88rem; }
details.acc .inner { margin-top: .7rem; }
.hint { font-size: .78rem; color: var(--muted); }
ul.clean { list-style: none; padding: 0; margin: .3rem 0; }
ul.clean li { padding: .18rem 0; border-bottom: 1px dashed var(--line); }
ul.clean li:last-child { border-bottom: none; }
.inline-form { display: flex; gap: .4rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { font-size: .74rem; color: var(--muted); font-weight: 700; }
.inline-form > div { display: grid; gap: .2rem; }
.scroll-x { overflow-x: auto; }

/* ================= dialogo de foco diario ================= */
.focus-dialog { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 1rem; }
.focus-dialog[hidden] { display: none; }
.focus-dialog-backdrop {
  position: absolute; inset: 0; background: rgba(3,7,18,.72);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.focus-dialog-panel {
  position: relative; width: min(520px, 100%);
  background: var(--card); border: 1px solid var(--line-2);
  border-radius: 16px; padding: 1.5rem;
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
}
.focus-dialog-panel h2 { margin: 0 0 .2rem; }
.focus-dialog-close {
  position: absolute; top: .7rem; right: .7rem;
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--bg-2); color: var(--muted);
  font: inherit; font-size: .95rem; cursor: pointer;
}
.focus-dialog-close:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.focus-opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; margin: 1rem 0 .4rem; }
.focus-opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: .15rem;
  padding: .85rem .9rem; border-radius: 12px; text-align: left;
  background: var(--bg-2); border: 1px solid var(--line-2);
  font: inherit; font-weight: 700; font-size: .98rem; color: var(--txt); cursor: pointer;
}
.focus-opt:hover { border-color: var(--accent); }
.focus-opt.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.focus-count { font-size: .72rem; font-weight: 600; opacity: .75; }
.focus-dialog-actions {
  display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; margin-top: .9rem;
}
.focus-warn { margin: .8rem 0 0; }
body.fd-open { overflow: hidden; }

/* ================= responsive ================= */

/* tablet / portatil: menos columnas en rejillas anchas */
@media (max-width: 1040px) {
  .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* movil: barra superior en dos filas y navegacion deslizable */
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: .45rem; padding: .5rem .75rem; }
  .nav {
    order: 3; width: 100%; flex-wrap: nowrap;
    overflow-x: auto; overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
    margin: 0 -.75rem; padding: .4rem .75rem 0;
    border-top: 1px solid var(--line);
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; padding: .45rem .65rem; font-size: .85rem; }

  .wrap { padding: .9rem .8rem 2.4rem; }
  .wrap-auth { padding-top: 1.4rem; padding-bottom: 1.6rem; }

  /* background-attachment: fixed es problemático en iOS */
  body.auth-page { background-attachment: scroll; }
  .auth { min-height: calc(100svh - 6.5rem); }

  .table-wrap { -webkit-overflow-scrolling: touch; }
}

@media (max-width: 760px) {
  /* 16px evita el zoom automatico de iOS al enfocar un campo */
  input, select, textarea { font-size: 16px; }

  h1 { font-size: 1.35rem; }
  h2 { font-size: 1.15rem; }

  .topbar-user .who { font-size: .82rem; }

  .auth-card { padding: 1.4rem; }
  .card { padding: .9rem; }
  .ex { padding: .7rem; }
  .ex-presc { gap: .5rem; padding: .45rem .55rem; }

  table { min-width: 460px; }

  .cal { gap: 3px; }
  .cal-d { min-height: 56px; padding: .25rem; font-size: .68rem; }
  .cal-d .dnum { font-size: .76rem; }
  .strip { gap: 3px; }
  .strip a { padding: .4rem .2rem; font-size: .7rem; }
  .strip a .d { font-size: .86rem; }

  .stat { padding: .6rem .7rem; }
  .stat .v { font-size: 1.2rem; }

  .exgrid, .goal-grid { gap: .6rem; }
}

@media (max-width: 480px) {
  h1 { font-size: 1.25rem; }

  .wrap { padding: .8rem .65rem 2rem; }
  .auth-card { padding: 1.15rem; }
  .auth-head h1 { font-size: 1.45rem; }

  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
  .stat .v { font-size: 1.12rem; }
  .rankrow { grid-template-columns: minmax(0, 1fr) 64px; }

  .ex-thumb { width: clamp(88px, 30vw, 120px); }
  .ex-thumb-sm, .ex-thumb-sm { width: 54px; }

  .setbox input { width: 52px; }
  .btn { padding: .55rem .9rem; }
  .lightbox-panel { padding: .7rem; }

  .focus-dialog { padding: .7rem; }
  .focus-dialog-panel { padding: 1.15rem; }
  .focus-opts { grid-template-columns: minmax(0, 1fr); gap: .45rem; }
  .focus-dialog-actions .btn { flex: 1; }
  .focus-dialog-actions .btn-ghost { order: 2; }
}
