:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --danger: #e34948;
  --status-good: #0ca30c;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-ink: #ffffff;
    --danger: #e66767;

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
  --accent-ink: #ffffff;
  --danger: #e66767;

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation; /* no double-tap zoom */
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* The page itself never scrolls — #app-shell fills the viewport and <main>
   does the scrolling. This also kills the rubber-band overscroll that made the
   bar drift away from the screen edge. */
html, body {
  height: 100%;
  overflow: hidden;
}

/* App shell: a column filling the viewport. Anchored with `position: fixed;
   inset: 0` rather than 100dvh — viewport units are resolved from a height iOS
   reports wrongly on the first paint in standalone mode, which left a strip
   under the nav until a scroll forced a re-layout. `inset: 0` is measured by
   the browser itself and stays correct. */
#app-shell {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  flex: 0 0 auto;
  z-index: 20;
  background: var(--page);
  border-bottom: 1px solid var(--border);
  padding: max(10px, env(safe-area-inset-top)) 12px 10px;
}

.topbar-inner {
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

h1 {
  font-size: 17px;
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

main {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 12px 12px 20px;
}

/* Bottom navigation — thumb reach on mobile */
.bottom-nav {
  flex: 0 0 auto;
  z-index: 30;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  /* --safe-bottom is measured and frozen by JS: iOS 15+ reports
     env(safe-area-inset-bottom) inconsistently and changes it on scroll,
     which is what made the bar drift from the screen edge until you scrolled.
     env() stays as the pre-JS fallback. */
  padding-bottom: var(--safe-bottom, env(safe-area-inset-bottom));
}

.nav-btn {
  appearance: none;
  flex: 1;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px 10px;
  min-height: 58px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
}

.nav-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-btn.active { color: var(--accent); }
.nav-btn:active { opacity: 0.7; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}

.card h3 {
  margin: 0 0 12px;
  font-size: 15px;
}

label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin: 10px 0 4px;
}

input, select, textarea {
  width: 100%;
  padding: 11px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-primary);
  font-size: 16px;
  font-family: inherit;
  min-height: 44px;
}

textarea { resize: vertical; min-height: unset; }

.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-row > div { flex: 1; min-width: 100px; }

.btn-primary, .btn-secondary {
  appearance: none;
  border: none;
  border-radius: 8px;
  padding: 11px 16px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 10px;
  min-height: 48px;
  font-family: inherit;
}

.btn-block {
  display: block;
  width: 100%;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-secondary:active, .btn-primary:active { opacity: 0.85; }

.btn-danger-link {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 13px;
  padding: 10px 4px;
  min-height: 44px;
}

.btn-edit-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  padding: 10px 4px;
  min-height: 44px;
}

.item-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.msg {
  font-size: 13px;
  color: var(--text-secondary);
  min-height: 16px;
  margin: 8px 0 0;
}

.msg.error { color: var(--danger); }

.build-stamp {
  margin: 12px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}


.exercise-select {
  margin-top: 4px;
}

.exercise-select:disabled {
  color: var(--text-muted);
}

.exercise-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 14px;
}

.exercise-list.empty {
  color: var(--text-muted);
  font-size: 13px;
}

.exercise-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--gridline);
}

.exercise-list li:last-child { border-bottom: none; }

.exercise-list .ex-name { font-weight: 500; }
.exercise-list .ex-meta { color: var(--text-secondary); font-size: 12px; }

.serie-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.serie-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
  background: var(--page);
}

.serie-row-header {
  flex: 0 0 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.serie-row-label-group {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.serie-row-label {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
}

.serie-row-record {
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.serie-row .btn-remove {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  width: 36px;
  height: 32px;
  cursor: pointer;
  padding: 0;
}

.field {
  flex: 1 1 0;
  min-width: 0;
}

.field-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin: 0 0 3px 2px;
}

.stepper {
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.stepper input {
  flex: 1;
  min-width: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 10px 2px;
  min-height: 48px;
  -moz-appearance: textfield;
}

.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.step-btn {
  appearance: none;
  flex: 0 0 40px;
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 20px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  min-height: 48px;
  font-family: inherit;
}

.step-btn:active { background: var(--page); }

.serie-row .btn-save {
  flex: 0 0 100%;
  min-height: 48px;
  margin-top: 2px;
}

@media (min-width: 560px) {
  .serie-row .btn-save {
    flex: 0 0 auto;
    min-width: 120px;
    align-self: flex-end;
  }
}

.when-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

/* min-width:0 is what actually lets these shrink — a flex item defaults to
   min-width:auto, and date/time inputs have a wide intrinsic size, so without
   it they push past the card instead of fitting it. */
.when-row .field {
  flex: 1 1 0;
  min-width: 0;
}

.when-row input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  font-size: 15px;
  min-height: 44px;
  -webkit-appearance: none;
  appearance: none;
}

.pr-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.pr-item {
  flex: 1;
  min-width: 140px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--page);
  border: 1px solid var(--border);
}

.pr-item .pr-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.pr-item .pr-value {
  display: block;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.pr-item .pr-date {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-secondary);
}

.serie-row button.btn-saved {
  background: var(--status-good);
  color: #ffffff;
}

/* Rest timer — lives in the top bar */
.rest-timer {
  margin-left: auto;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 4px 4px 4px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: background 0.2s, border-color 0.2s;
}

.rest-timer.pulse {
  background: var(--status-good);
  border-color: var(--status-good);
}

.rest-timer.pulse .rest-timer-label,
.rest-timer.pulse .rest-timer-clock,
.rest-timer.pulse .rest-timer-stop {
  color: #ffffff;
}

.rest-timer-label {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rest-timer-clock {
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.rest-timer-stop {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  width: 36px;
  height: 36px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.serie-row input:disabled {
  opacity: 0.6;
}

#chart-container { margin-top: 14px; }
#table-toggle-wrap { margin-top: 6px; }
.hidden { display: none !important; }

/* Boot screen: shown until /api/session resolves, then replaced by the login
   or the app. Also where a fatal startup error surfaces — on a phone there is
   no console to read, so the message has to land on screen. */
.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--page);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.boot-box {
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.boot-spinner {
  width: 28px;
  height: 28px;
  margin: 0 auto 14px;
  border: 3px solid var(--border);
  border-top-color: var(--accent, #2a78d6);
  border-radius: 50%;
  animation: boot-spin 0.8s linear infinite;
}

@keyframes boot-spin { to { transform: rotate(360deg); } }

.boot-msg {
  margin: 0;
  font-size: 15px;
  color: var(--text-primary);
}

.boot-detail {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-muted);
  word-break: break-word;
}

.boot-screen .btn-primary { margin-top: 16px; }

/* Progression block inside Registrar: collapsed by default, so it needs a
   little air between the toggle and the chart when opened. */
#prog-body {
  margin-top: 12px;
}

/* Login */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--page);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-box {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
}

.login-box h2 {
  margin: 0 0 16px;
  font-size: 18px;
  text-align: center;
}

.chart-frame {
  position: relative;
}

.chart-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Fixed reps scale — sits above the scrolling plot, opaque so gridlines
   pass underneath it instead of colliding with the numbers. */
.chart-yaxis {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  background: var(--surface);
}

.period-selector {
  display: flex;
  gap: 6px;
  margin-top: 14px;
}

.period-btn {
  appearance: none;
  flex: 1;
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 4px;
  min-height: 40px;
  cursor: pointer;
}

.period-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Chart */
.viz-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.viz-legend .swatch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.viz-legend .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.legend-btn {
  appearance: none;
  background: transparent;
  border: none;
  padding: 4px 2px;
  margin: 0;
  font: inherit;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  min-height: 32px;
}

.legend-off { opacity: 0.35; }


.demo-banner {
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--series-4);
  color: #1a1a19;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}

#demo-wrap { margin-top: 6px; }

.btn-demo-on {
  border-color: var(--accent);
  color: var(--accent);
}

.chart-caption {
  color: var(--text-muted);
  font-size: 12px;
  margin: 10px 0 0;
}

.viz-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 12px;
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.1s;
}

.viz-tooltip.show { opacity: 1; }
.viz-tooltip .tt-secondary { color: var(--text-secondary); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 10px;
}

.data-table th, .data-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--gridline);
  font-variant-numeric: tabular-nums;
}

.data-table th {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 12px;
}

/* ---------- IA ---------- */

.ia-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.ia-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 2px;
  background: var(--page);
  border-radius: 8px;
}

.ia-stat-valor {
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.ia-stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.2;
}

.ia-ex {
  padding: 10px 0;
  border-top: 1px solid var(--gridline);
}

.ia-ex-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.ia-ex-nombre { font-size: 14px; font-weight: 600; }
.ia-ex-mod { font-size: 12px; color: var(--text-muted); }

.ia-ex-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.ia-chips { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }

.ia-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  font-variant-numeric: tabular-nums;
  background: var(--page);
  color: var(--text-secondary);
}

.ia-chip.up { background: rgba(12, 163, 12, 0.14); color: var(--status-good); }
.ia-chip.down { background: rgba(227, 73, 72, 0.14); color: var(--danger); }
.ia-chip.warn { background: rgba(237, 161, 0, 0.18); color: var(--series-4); }

.ia-resumen {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
}

.ia-punto {
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: var(--page);
  border-left: 3px solid var(--text-muted);
}

.ia-punto.progreso { border-left-color: var(--status-good); }
.ia-punto.aviso { border-left-color: var(--danger); }
.ia-punto.sugerencia { border-left-color: var(--accent); }

.ia-punto-tipo {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.ia-punto.progreso .ia-punto-tipo { color: var(--status-good); }
.ia-punto.aviso .ia-punto-tipo { color: var(--danger); }
.ia-punto.sugerencia .ia-punto-tipo { color: var(--accent); }

.ia-punto-titulo {
  margin: 3px 0 4px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

.ia-punto-detalle {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.ia-proxima {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
}

.ia-proxima-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
}

.ia-proxima p {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.45;
}

.ia-fecha {
  margin: 12px 0 0;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

#ia-objetivos { width: 100%; }

/* ---------- nota de sesión ---------- */

.nota-wrap { margin-top: 14px; }

.nota-wrap label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

#reg-nota {
  width: 100%;
  resize: vertical;
}

.nota-estado {
  display: block;
  min-height: 14px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--danger);
}

.nota-estado.ok { color: var(--status-good); }

/* ---------- peso corporal ---------- */

.peso-historial {
  margin-top: 14px;
}

.peso-hist-row {
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--gridline);
}

.peso-hist-row:first-child { border-top: none; }

.peso-hist-info {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  appearance: none;
  background: transparent;
  border: none;
  padding: 9px 2px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  min-height: 44px;
}

.peso-hist-fecha {
  font-size: 13px;
  color: var(--text-secondary);
}

.peso-hist-valor {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.peso-hist-del {
  appearance: none;
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--danger);
  font-size: 20px;
  line-height: 1;
  padding: 10px;
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
}

/* ---------- preguntas específicas (chat) ---------- */

.ia-chat-card {
  display: flex;
  flex-direction: column;
}

.ia-chat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 46vh;
  min-height: 220px;
  max-height: 420px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 2px;
  margin-bottom: 8px;
}

.ia-chat-empty {
  margin: auto;
  max-width: 85%;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.ia-bubble {
  max-width: 85%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
}

.ia-bubble p { margin: 0; white-space: pre-wrap; }

.ia-bubble-user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-ink);
  border-bottom-right-radius: 4px;
}

.ia-bubble-ia {
  align-self: flex-start;
  background: var(--page);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.ia-bubble-error {
  color: var(--danger);
  border-color: var(--danger);
}

.ia-bubble-pensando {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
}

.ia-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: ia-dot-bounce 1.1s infinite ease-in-out;
}

.ia-dot:nth-child(2) { animation-delay: 0.15s; }
.ia-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes ia-dot-bounce {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.ia-chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.ia-chat-input-row textarea {
  flex: 1;
  resize: none;
  max-height: 110px;
  min-height: 44px;
}

.ia-chat-send {
  appearance: none;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ia-chat-send svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ia-chat-send:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: default;
}

/* ---------- navegación de periodo (bajo la gráfica) ---------- */

.period-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 4px 0 14px;
}

.period-nav-btn {
  appearance: none;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-primary);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.period-nav-btn:disabled {
  color: var(--text-muted);
  cursor: default;
  opacity: 0.5;
}

.period-nav-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* ---------- tabla editable de series ---------- */

.data-table-editable th,
.data-table-editable td {
  padding: 4px;
}

.data-table-editable input {
  width: 100%;
  min-width: 0;
  padding: 6px 5px;
  font-size: 13px;
  min-height: 34px;
  border-radius: 6px;
}

.data-table-editable .celda-fecha { min-width: 118px; }
.data-table-editable .celda-serie { width: 44px; }
.data-table-editable .celda-kg,
.data-table-editable .celda-reps { width: 56px; }
.data-table-editable .celda-comentario { min-width: 140px; }

.celda-serie-auto {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 34px;
  color: var(--text-muted);
  font-size: 13px;
}

.tabla-del {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--danger);
  font-size: 18px;
  line-height: 1;
  padding: 6px;
  min-width: 34px;
  min-height: 34px;
  cursor: pointer;
}

/* Marks the first row of a new date, so consecutive same-day sets read as
   one group at a glance. */
.data-table-editable tr.fila-dia-nuevo td {
  border-top: 2px solid var(--baseline);
}

.fila-nueva td {
  background: rgba(42, 120, 214, 0.06);
}

#table-msg { text-align: center; margin: 8px 0; }

/* ---------- recomendación IA en Registrar ---------- */

.reg-recomendacion {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border-left: 3px solid var(--accent);
  background: var(--page);
}

.reg-recomendacion p {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-primary);
}

.reg-recomendacion-fecha {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.pr-chip-extra {
  display: inline-block;
  margin-top: 4px;
}

/* ---------- selector de modalidad ---------- */

.modalidad-select {
  margin-bottom: 4px;
}
