/* n0gym - styles.css
 * Móvil primero. Fondo casi negro, acento verde lima. Sin fuentes ni recursos externos. */

:root {
  --bg: #0a0b09;
  --surface: #141612;
  --surface-2: #1d201a;
  --line: #2a2e25;
  --text: #eef1e8;
  --muted: #a0a796;
  --accent: #c6f432;
  --accent-ink: #101500;
  --danger: #ff7d70;
  --radius: 14px;
  --nav-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  font-variant-numeric: tabular-nums;
}

#main {
  max-width: 640px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 28px);
  outline: none;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.6rem; line-height: 1.2; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1.05rem; }
p + p { margin-top: 8px; }
a { color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- navegación inferior ---------- */

.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.nav-inner { display: flex; max-width: 640px; margin: 0 auto; }
.nav a {
  flex: 1;
  min-height: var(--nav-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
}
.nav a[aria-current="page"] { color: var(--accent); }
.nav svg { width: 24px; height: 24px; }

/* ---------- cabecera y secciones ---------- */

.top { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.top h1 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.brand { font-size: 1.8rem; font-weight: 800; letter-spacing: 0.02em; color: var(--accent); }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 24px 0 12px; }
.link { color: var(--accent); text-decoration: none; font-weight: 600; padding: 8px 0; }
.day { margin: 24px 0 10px; font-size: 1rem; color: var(--muted); font-weight: 600; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; margin-top: 24px; }
.danger-text { color: var(--danger); }
.note { color: var(--muted); font-size: 0.92rem; margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- tarjetas ---------- */

.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  text-decoration: none;
}
.card h3 { overflow-wrap: anywhere; }
.card h3 + p { margin-top: 4px; }
.card .btn.block, .card .row { margin-top: 12px; }
.card-link:active { background: var(--surface-2); }

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  text-decoration: none;
}

.empty {
  padding: 24px 16px;
  margin-bottom: 12px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty p { color: var(--muted); margin: 6px 0 16px; }
.empty .btn { margin-top: 4px; }

/* ---------- filas y rejillas ---------- */

.row { display: flex; gap: 8px; align-items: center; }
.row.mt { margin-top: 8px; }
.row-between { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.row-tight { display: flex; gap: 4px; flex-shrink: 0; }
.grow { flex: 1; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }

.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.seg a {
  flex: 1;
  padding: 10px;
  text-align: center;
  border-radius: 9px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}
.seg a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 0.9rem;
  white-space: nowrap;
}

/* ---------- botones ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.btn:active { filter: brightness(0.9); }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 0.92rem; }
.btn-ghost { background: var(--surface-2); color: var(--text); font-weight: 600; border: 1px solid var(--line); }
.btn-danger { background: var(--danger); color: #2b0600; }
.btn-quiet { background: transparent; color: var(--muted); font-weight: 600; }
.btn-ghost.danger-text { color: var(--danger); }
.block { display: flex; width: 100%; }
.block + .block, .card + .block, .btn.block + .btn.block { margin-top: 8px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1.2rem;
  text-decoration: none;
  cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn:disabled { color: var(--line); cursor: default; }
.icon-btn.small { width: 36px; height: 44px; color: var(--muted); }

/* ---------- formularios ---------- */

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; margin-bottom: 6px; font-size: 0.9rem; color: var(--muted); }

input, textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit; /* 16px evita el zoom automático en iOS */
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #6f765f; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(198, 244, 50, 0.3); }
.grid3 .field { margin-bottom: 0; }

.form-error { color: var(--danger); font-size: 0.92rem; }

.sticky-actions {
  position: sticky;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding: 10px 0;
  background: var(--bg);
}

/* ---------- entrenamiento activo ---------- */

.ex .row-between { align-items: center; }
.ex h2 { overflow-wrap: anywhere; }
.prev { margin: 4px 0 12px; color: var(--muted); font-size: 0.88rem; }

.set {
  display: grid;
  grid-template-columns: 28px 1fr 1fr 52px 36px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.set-head { margin-bottom: 4px; font-size: 0.8rem; color: var(--muted); }
.set-n { text-align: center; color: var(--muted); font-weight: 600; }
.set input { text-align: center; font-size: 1.1rem; font-weight: 600; padding: 10px 4px; }

.check {
  width: 52px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font: inherit;
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
}
.set.done .check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.set.done input { color: var(--accent); border-color: rgba(198, 244, 50, 0.4); }
.ex .btn.block { margin-top: 4px; }

/* ---------- fotos ---------- */

.ex-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ex-row .grow { min-width: 0; }

.thumb {
  position: relative;
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  padding: 0;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb-count {
  position: absolute;
  right: 4px;
  bottom: 4px;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 20px;
}
.photo-strip { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; }
.photo-strip .thumb { width: 72px; height: 72px; }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.photo-grid:empty { display: none; }
.photo { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo-rm {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font: inherit;
  cursor: pointer;
}
#ex-add-photo { margin-top: 0; }
#ex-add-photo:disabled { opacity: 0.5; }
.field > .muted.small { margin-top: 6px; }

.gallery { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; }
.gallery img {
  flex: 0 0 100%;
  width: 100%;
  max-height: 60vh;
  object-fit: contain;
  background: #000;
  border-radius: 10px;
  scroll-snap-align: center;
}

/* ---------- historial ---------- */

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0; }
.stats div { padding: 12px 8px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.stats strong { display: block; font-size: 1.2rem; }
.stats span { font-size: 0.8rem; color: var(--muted); }

.sets { margin: 8px 0 0; padding-left: 24px; }
.sets li { padding: 2px 0; }
.sets li::marker { color: var(--muted); }

.kv { margin: 12px 0 0; display: grid; gap: 8px; }
.kv div { display: flex; justify-content: space-between; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 700; }

/* ---------- diálogos y avisos ---------- */

dialog.dlg {
  width: min(92vw, 460px);
  max-height: 88vh;
  overflow-y: auto;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 18px;
}
dialog.dlg::backdrop { background: rgba(0, 0, 0, 0.72); }
.dlg-body { display: flex; flex-direction: column; gap: 12px; padding: 20px; }
.dlg-body .field { margin-bottom: 0; }
.dlg-body p { color: var(--muted); }
.dlg-actions { display: flex; gap: 8px; margin-top: 4px; }
.dlg-actions .btn { flex: 1; }

.pick-list { display: flex; flex-direction: column; gap: 6px; max-height: 40vh; overflow-y: auto; }
.pick {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 52px;
  padding: 10px 14px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.pick small { color: var(--muted); }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 76px);
  z-index: 40;
  max-width: min(90vw, 440px);
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity 0.15s;
}
#toast.show { opacity: 1; }
#toast.error { border-color: var(--danger); }

/* ---------- temporizador de descanso ---------- */

.rt {
  position: fixed;
  z-index: 30;
  left: max(12px, env(safe-area-inset-left), calc(50% - 308px));
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px);
}
/* en el entrenamiento, por encima de la barra Cancelar / Finalizar */
body.on-workout .rt { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 80px); }

.rt-bar {
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  align-items: center;
  padding: 4px 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
.rt-time {
  min-width: 72px;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
}
.rt-bar .icon-btn { font-size: 1.1rem; }
.rt-grip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: grab;
  touch-action: none; /* el arrastre no hace scroll en la página */
}
.rt-dragging .rt-grip { cursor: grabbing; color: var(--accent); }
.rt-dragging .rt-bar { border-color: var(--accent); }
.rt[data-state="done"] .rt-grip { color: var(--accent-ink); }
.rt[data-state="running"] .rt-bar { border-color: var(--accent); }
.rt[data-state="running"] .rt-time { color: var(--accent); }
.rt[data-state="paused"] .rt-time { color: var(--muted); }
.rt[data-state="done"] .rt-bar { background: var(--accent); border-color: var(--accent); animation: rt-pulse 0.6s ease-in-out 4; }
.rt[data-state="done"] .rt-time,
.rt[data-state="done"] .icon-btn { color: var(--accent-ink); }
@keyframes rt-pulse { 50% { transform: scale(1.08); } }

.rt-panel {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(320px, calc(100vw - 24px));
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
.rt.rt-below .rt-panel { bottom: auto; top: calc(100% + 8px); }
.rt.rt-right .rt-panel { left: auto; right: 0; }
.rt-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.rt-presets button {
  min-height: 44px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.rt-presets button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.rt-custom { display: flex; gap: 6px; }
.rt-custom input { flex: 1; min-width: 0; }
.rt-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- calculadora de discos ---------- */

.field.mt { margin-top: 12px; }
.plates-cfg summary { min-height: 44px; display: flex; align-items: center; font-weight: 700; font-size: 1.05rem; cursor: pointer; }
.plates-cfg[open] summary { margin-bottom: 4px; }
.plates-cfg .muted.small { margin-bottom: 12px; }

.plate-row {
  display: grid;
  grid-template-columns: 52px 1fr 1fr 36px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.plate-row.head { margin-bottom: 4px; font-size: 0.8rem; color: var(--muted); }
.plate-row input { text-align: center; font-weight: 600; padding: 10px 4px; }

.plate-row.on .check { background: var(--pc, var(--accent)); border-color: var(--pe, var(--accent)); color: var(--pf, var(--accent-ink)); }

/* colores IPF */
.plate-chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; padding: 0; }
.plate-chips.legend { margin: 0 0 12px; }
.plate-chip {
  min-width: 44px;
  padding: 6px 12px;
  border: 2px solid var(--pe);
  border-radius: 999px;
  background: var(--pc);
  color: var(--pf);
  font-weight: 700;
  text-align: center;
}

/* barra con discos de un lado */
.plate-vis {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 14px;
  padding: 6px 0;
  overflow-x: auto;
}
.bar-shaft { flex: 0 0 34px; height: 10px; border-radius: 5px 0 0 5px; background: linear-gradient(#e5e7eb, #6b7280); }
.bar-collar { flex: 0 0 8px; height: 40px; border-radius: 3px; background: linear-gradient(90deg, #d1d5db, #6b7280); }
.bar-tip { flex: 0 0 22px; height: 18px; border-radius: 0 6px 6px 0; background: linear-gradient(#e5e7eb, #6b7280); }
.plate {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid;
  border-radius: 6px;
  box-sizing: border-box;
  overflow: hidden;
}
.plate span { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 0.68rem; font-weight: 700; line-height: 1; }

/* selector de idioma, soporte y donaciones */
select {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
}
select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(198, 244, 50, 0.3); }
.wallet { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.8rem; text-overflow: ellipsis; }
.copy-btn { min-width: 96px; transition: background-color 0.15s, color 0.15s; }
.copy-btn.copied { background: #22c55e; border-color: #22c55e; color: #052e16; }
.copy-btn.copy-failed { background: var(--danger); border-color: var(--danger); color: #2b0600; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; animation: none !important; }
}
