/* ============================================================
   Atlas 💪 — design system
   Apple-clean, mobile-first. One accent (#0A84FF iOS blue).
   Full prefers-color-scheme dark support.
   ============================================================ */

:root {
  /* palette — light first */
  --bg:           #F5F5F7;
  --bg-elev:      #FFFFFF;
  --card:         #FFFFFF;
  --card-2:       #FBFBFD;
  --text:         #1D1D1F;
  --text-2:       #86868B;
  --text-3:       #AEAEB2;
  --hair:         rgba(60, 60, 67, 0.10);
  --hair-strong:  rgba(60, 60, 67, 0.18);
  --accent:       #0A84FF;
  --accent-soft:  rgba(10, 132, 255, 0.12);
  --green:        #30D158;
  --orange:       #FF9F0A;
  --red:          #FF453A;
  --purple:       #BF5AF2;
  --ring-track:   rgba(60, 60, 67, 0.12);

  /* macro accents */
  --prot:  #FF6482;
  --carb:  #FFB340;
  --grasa: #5AC8FA;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.06);
  --shadow:    0 2px 8px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.05);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.16);

  --r-sm: 12px;
  --r:    18px;
  --r-lg: 22px;
  --r-pill: 999px;

  --tabbar-h: 56px;
  --maxw: 480px;

  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --ease: cubic-bezier(.22, .61, .36, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #000000;
    --bg-elev:     #1C1C1E;
    --card:        #1C1C1E;
    --card-2:      #2C2C2E;
    --text:        #F5F5F7;
    --text-2:      #98989F;
    --text-3:      #6E6E73;
    --hair:        rgba(255, 255, 255, 0.10);
    --hair-strong: rgba(255, 255, 255, 0.16);
    --accent-soft: rgba(10, 132, 255, 0.22);
    --ring-track:  rgba(120, 120, 128, 0.24);
    --shadow-sm:   0 1px 2px rgba(0,0,0,.4);
    --shadow:      0 2px 10px rgba(0,0,0,.5);
    --shadow-lg:   0 10px 44px rgba(0,0,0,.6);
  }
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
input, button { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, h4, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-body { background: var(--bg); }
.login-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-top)) 22px calc(24px + var(--safe-bottom));
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 40px 28px 28px;
  text-align: center;
  animation: rise .5s var(--ease) both;
}
.login-mark { line-height: 0; display: flex; justify-content: center; }
.login-mark svg { display: block; }
.login-wordmark {
  font-size: 34px; font-weight: 700; letter-spacing: -.02em;
  margin-top: 10px;
}
.login-tagline { color: var(--text-2); font-size: 15px; margin-top: 4px; margin-bottom: 26px; }
.login-form { text-align: left; display: grid; gap: 16px; }
.login-foot { margin-top: 22px; color: var(--text-3); font-size: 12px; }

.field { display: grid; gap: 7px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); padding-left: 4px; }
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--card-2);
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  padding: 14px 14px;
  font-size: 16px;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--card);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  border-radius: var(--r-sm);
  padding: 14px 18px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .12s var(--ease), opacity .15s var(--ease), filter .15s var(--ease);
}
.btn-primary:active { transform: scale(.975); filter: brightness(.94); }
.btn-primary:disabled { opacity: .6; }
.btn-block { width: 100%; }

/* AI macro-estimate button (add-meal sheet) */
.btn-ai {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; margin-top: 10px;
  padding: 12px 16px; min-height: 44px;
  border-radius: var(--r-sm);
  background: var(--accent-soft); color: var(--accent);
  font-weight: 600; font-size: 15px;
  transition: transform .12s var(--ease), opacity .15s var(--ease), filter .15s var(--ease);
}
.btn-ai svg { width: 18px; height: 18px; }
.btn-ai:active { transform: scale(.98); filter: brightness(.97); }
.btn-ai.loading, .btn-ai:disabled { opacity: .6; }
.ai-note {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px; font-size: 13px; color: var(--accent);
}
.ai-note[hidden] { display: none; }
.ai-note { flex-direction: column; align-items: stretch; }
.ai-note-head { display: flex; align-items: center; gap: 6px; }
.ai-note-head svg, .ai-note svg { width: 15px; height: 15px; flex: none; }
.ai-ings { margin: 8px 0 0; padding: 0; display: grid; gap: 6px; list-style: none; }
.ai-ings li { display: flex; justify-content: space-between; gap: 10px; align-items: baseline;
  font-size: 12.5px; color: var(--text-2); }
.ai-ings li > span:first-child { color: var(--text); min-width: 0; }
.ai-ings em { color: var(--text-3); font-style: normal; }

/* per-meal ingredient expander in the meals list */
.ing-details { margin-top: 7px; }
.ing-details summary {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; color: var(--accent); cursor: pointer;
  list-style: none; user-select: none; padding: 2px 0;
}
.ing-details summary::-webkit-details-marker { display: none; }
.ing-details summary svg { width: 14px; height: 14px; }
.ing-list { margin: 7px 0 2px; padding: 0; display: grid; gap: 6px; list-style: none; }
.ing-list li { display: flex; justify-content: space-between; gap: 10px; align-items: baseline;
  font-size: 12.5px; color: var(--text-2); }
.ing-name { color: var(--text); min-width: 0; }
.ing-name em { color: var(--text-3); font-style: normal; }
.ing-macros { white-space: nowrap; flex: none; }

/* add-meal ingredient builder (preset picker + grams) */
.lbl-hint { font-weight: 400; color: var(--text-3); font-size: 12px; margin-left: 4px; }
.ing-name-inp { width: 100%; background: var(--card-2); border: 1px solid var(--hair);
  border-radius: var(--r-sm); padding: 12px 12px; font-size: 16px; }
.ing-add { display: flex; gap: 8px; align-items: stretch; margin-top: 8px; }
.ing-add .ing-amt-inp { flex: 1 1 auto; min-width: 0; background: var(--card-2);
  border: 1px solid var(--hair); border-radius: var(--r-sm); padding: 12px 12px; font-size: 16px; }
.ing-add .ing-unit { flex: none; width: 104px; background: var(--card-2);
  border: 1px solid var(--hair); border-radius: var(--r-sm); padding: 12px 10px; font-size: 15px;
  -webkit-appearance: none; appearance: none; text-align: center; }
.ing-name-inp:focus, .ing-add .ing-amt-inp:focus, .ing-add .ing-unit:focus {
  outline: none; border-color: var(--accent); background: var(--card); }
.ing-preview { display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  margin-top: 9px; padding: 9px 12px; background: var(--accent-soft); border-radius: var(--r-sm); }
.ing-preview[hidden] { display: none; }
.ing-preview .ing-pv-name { font-size: 13px; font-weight: 600; color: var(--text); min-width: 0; }
.ing-preview .ing-pv-k { font-size: 13px; color: var(--accent); white-space: nowrap; flex: none; }
.ing-add-btn { flex: none; width: 48px; min-height: 44px; border-radius: var(--r-sm);
  background: var(--accent-soft); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; }
.ing-add-btn svg { width: 20px; height: 20px; }
.ing-add-btn:active { transform: scale(.96); }
.ing-hint { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12.5px; color: var(--text-2); }
.ing-hint[hidden] { display: none; }
.ing-hint svg { width: 14px; height: 14px; flex: none; }
.ing-builder { display: grid; gap: 8px; margin-top: 10px; }
.ing-builder:empty { margin-top: 0; }
.ing-chip { display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--card-2); border-radius: var(--r-sm); }
.ing-chip-main { flex: 1 1 auto; min-width: 0; font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ing-chip-main em { font-style: normal; font-weight: 400; color: var(--text-2); }
.ing-chip-k { flex: none; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.ing-chip-x { flex: none; width: 30px; height: 30px; border-radius: 50%; color: var(--text-3);
  display: inline-flex; align-items: center; justify-content: center; }
.ing-chip-x svg { width: 15px; height: 15px; }
.ing-chip-x:active { background: var(--hair); color: var(--red); }

.btn-spinner {
  width: 17px; height: 17px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.45); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.form-error {
  background: rgba(255,69,58,.12); color: var(--red);
  border-radius: var(--r-sm); padding: 11px 13px; font-size: 14px; font-weight: 500;
}

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell { min-height: 100dvh; }

.app-header {
  position: sticky; top: 0; z-index: 30;
  padding-top: var(--safe-top);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s var(--ease);
}
.app-header.scrolled { border-bottom-color: var(--hair); }
.header-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; min-height: 44px;
}
.header-title { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.header-action {
  color: var(--accent); font-weight: 600; font-size: 16px;
  padding: 6px 4px; border-radius: 8px;
  min-width: 44px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
}
.header-action[hidden] { display: none; }
.header-action:active { opacity: .55; }

.view {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 8px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 28px);
  min-height: 60dvh;
}
.view-loading { display: grid; place-items: center; min-height: 50dvh; }

/* ---------- bottom tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: center; gap: 2px;
  padding: 4px 6px calc(4px + var(--safe-bottom));
  background: color-mix(in srgb, var(--bg-elev) 72%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
  border-top: 1px solid var(--hair);
}
.tab {
  flex: 1 1 0;
  max-width: 96px;
  min-height: 48px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-3);
  border-radius: 12px;
  transition: color .15s var(--ease), transform .1s var(--ease);
  padding: 4px 2px;
}
.tab:active { transform: scale(.92); }
.tab-ico { display: grid; place-items: center; height: 24px; opacity: .9; transition: opacity .15s, transform .15s; }
.tab-ico .ic { width: 23px; height: 23px; }
.tab-label { font-size: 10px; font-weight: 600; letter-spacing: .01em; }
.tab.active { color: var(--accent); }
.tab.active .tab-ico { opacity: 1; transform: translateY(-1px); }

/* ---------- inline svg icon defaults ---------- */
.ic { display: inline-block; vertical-align: middle; flex: none; }

/* ============================================================
   CARDS & PRIMITIVES
   ============================================================ */
.card {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  padding: 18px;
}
.card + .card { margin-top: 14px; }
.stack { display: grid; gap: 14px; }
.stack-sm { display: grid; gap: 10px; }

.greeting { padding: 12px 4px 6px; }
.greeting h2 { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.greeting .date { color: var(--text-2); font-size: 15px; margin-top: 2px; text-transform: capitalize; }

.section-title {
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-2); padding: 18px 6px 8px;
}
.card-title { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.card-sub { color: var(--text-2); font-size: 14px; }
.muted { color: var(--text-2); }
.tabnum { font-variant-numeric: tabular-nums; }

.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.spread { flex: 1; }

/* chips */
.chip-row { display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card); border-radius: var(--r-pill);
  padding: 9px 14px; box-shadow: var(--shadow-sm);
  font-size: 14px; font-weight: 600;
}
.chip .chip-ico { display: inline-grid; place-items: center; }
.chip .chip-ico .ic { width: 16px; height: 16px; }
.chip .chip-sub { color: var(--text-2); font-weight: 500; font-size: 13px; }
.chip.flame { color: var(--orange); }
.chip.up { color: var(--green); } .chip.down { color: var(--red); }

/* pill buttons / quick actions */
.quick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.quick {
  background: var(--card); border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  padding: 16px 14px; display: flex; align-items: center; gap: 12px;
  font-weight: 600; font-size: 15px;
  transition: transform .12s var(--ease), background .15s var(--ease);
}
.quick:active { transform: scale(.97); background: var(--card-2); }
.quick .q-ico {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.quick .q-ico .ic { width: 20px; height: 20px; }

.btn-ghost {
  background: var(--accent-soft); color: var(--accent);
  border-radius: var(--r-pill); padding: 9px 16px; font-weight: 600; font-size: 14px;
  transition: filter .15s, transform .1s;
}
.btn-ghost:active { transform: scale(.96); filter: brightness(.95); }
.btn-line {
  border: 1px solid var(--hair-strong); border-radius: var(--r-pill);
  padding: 9px 16px; font-weight: 600; font-size: 14px; color: var(--text);
}
.btn-danger { color: var(--red); }
.btn-text { color: var(--accent); font-weight: 600; }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
}
.badge.pr { background: rgba(255,159,10,.16); color: var(--orange); }
.badge.ok { background: rgba(48,209,88,.16); color: var(--green); }
.badge.rest { background: var(--card-2); color: var(--text-2); }

/* ---------- hero calorie ring card ---------- */
.hero {
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 20px 18px 16px;
  text-align: center;
}
/* ring + macros side by side */
.hero-main { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; }
.hero .ring-wrap { display: grid; place-items: center; margin: 0; }
.hero-foot {
  display: flex; justify-content: center; gap: 22px;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--hair);
}
.hero-foot .kv { text-align: center; }
.hero-foot .kv .v { font-size: 17px; font-weight: 700; }
.hero-foot .kv .k { font-size: 12px; color: var(--text-2); }

/* macro bars */
.macros { display: grid; gap: 13px; margin-top: 4px; text-align: left; min-width: 0; }
.hero .macros { margin-top: 0; }
.macro { display: grid; gap: 6px; min-width: 0; }
.macro-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-size: 13px; }
.macro-top .m-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.macro-top .m-val { color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-track { height: 8px; border-radius: 99px; background: var(--ring-track); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; transition: width .6s var(--ease); }
.bar-fill.over { opacity: .85; }
.macro.prot  .bar-fill { background: var(--prot); }
.macro.carb  .bar-fill { background: var(--carb); }
.macro.grasa .bar-fill { background: var(--grasa); }

/* hollow / "empty" effect: track is just a tinted contour, fill grows inside */
.macros.hollow .bar-track {
  height: 10px; background: transparent;
  border: 1.5px solid var(--hair); box-sizing: border-box;
}
.macros.hollow .macro.prot  .bar-track { border-color: color-mix(in srgb, var(--prot) 50%, transparent); }
.macros.hollow .macro.carb  .bar-track { border-color: color-mix(in srgb, var(--carb) 50%, transparent); }
.macros.hollow .macro.grasa .bar-track { border-color: color-mix(in srgb, var(--grasa) 55%, transparent); }
.macros.hollow .bar-fill { opacity: .92; }

/* list rows */
.list { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow-sm); overflow: hidden; }
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-top: 1px solid var(--hair);
  transition: background .12s var(--ease);
}
.list-row:first-child { border-top: none; }
.list-row.tappable:active { background: var(--card-2); }
.list-row .lr-main { flex: 1; min-width: 0; }
.list-row .lr-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .lr-sub { color: var(--text-2); font-size: 13px; margin-top: 1px; }
.list-row .lr-right { text-align: right; flex: none; }
.list-row .lr-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.list-row .lr-chev { color: var(--text-3); font-size: 18px; flex: none; }
.lr-ico {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  display: grid; place-items: center; background: var(--card-2); color: var(--text-2);
}
.lr-ico .ic { width: 19px; height: 19px; }
.lr-ico.accent { background: var(--accent-soft); color: var(--accent); }

/* meal group header */
.meal-group { margin-top: 6px; }
.meal-group .mg-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 6px 8px;
}
.meal-group .mg-name { font-size: 15px; font-weight: 700; text-transform: capitalize; }
.meal-group .mg-kcal { color: var(--text-2); font-size: 13px; font-weight: 600; }

/* day selector / segmented */
.daybar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0 6px; }
.daybar .day-label { font-weight: 700; font-size: 16px; text-transform: capitalize; }
.stepper { display: flex; gap: 6px; }
.stepper button {
  width: 44px; height: 44px; border-radius: 12px; background: var(--card);
  box-shadow: var(--shadow-sm); display: grid; place-items: center; font-size: 18px; color: var(--accent);
}
.stepper button:active { transform: scale(.92); }
.stepper button:disabled { color: var(--text-3); }

.segmented {
  display: flex; background: var(--ring-track); border-radius: 12px; padding: 3px; gap: 3px;
}
.segmented button {
  flex: 1; padding: 7px 10px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--text-2);
  transition: background .15s var(--ease), color .15s var(--ease);
}
.segmented button.active { background: var(--card); color: var(--text); box-shadow: var(--shadow-sm); }

/* stat grid */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat {
  background: var(--card); border-radius: var(--r); box-shadow: var(--shadow-sm); padding: 16px;
}
.stat .s-val { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .s-key { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.stat .s-delta { font-size: 12px; font-weight: 600; margin-top: 4px; }
.s-delta.up { color: var(--green); } .s-delta.down { color: var(--red); }

/* chart card */
.chart-card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow-sm); padding: 16px 14px; }
.chart-card .cc-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; padding: 0 2px; }
.chart-card .cc-title { font-size: 15px; font-weight: 700; }
.chart-card .cc-meta { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.chart-card svg { display: block; width: 100%; height: auto; }

/* ---------- empty / skeleton ---------- */
.empty { text-align: center; padding: 48px 24px; color: var(--text-2); }
.empty .e-ico { display: inline-grid; place-items: center; width: 64px; height: 64px;
  border-radius: 20px; background: var(--card-2); color: var(--text-3); margin: 0 auto; }
.empty .e-ico .ic { width: 30px; height: 30px; }
.empty .e-title { font-size: 17px; font-weight: 700; color: var(--text); margin-top: 14px; }
.empty .e-sub { font-size: 14px; margin-top: 4px; }
.empty .e-cta { margin-top: 18px; }

.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--ring-track); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
.skel { background: linear-gradient(100deg, var(--card-2) 30%, var(--hair) 50%, var(--card-2) 70%);
        background-size: 200% 100%; animation: shimmer 1.3s linear infinite; border-radius: var(--r); }
.skel-card { height: 110px; }
.skel-line { height: 14px; border-radius: 7px; }
.skel-ring { height: 220px; border-radius: var(--r-lg); }

/* ---------- bottom sheet ---------- */
.sheet-host { position: fixed; inset: 0; z-index: 60; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.4); animation: fade .25s var(--ease); }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-width: var(--maxw); margin: 0 auto;
  background: var(--bg-elev);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-lg);
  padding: 10px 18px calc(22px + var(--safe-bottom));
  max-height: 92dvh; overflow-y: auto;
  animation: sheet-up .32s var(--ease);
}
.sheet-grab { width: 38px; height: 5px; border-radius: 99px; background: var(--hair-strong); margin: 4px auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-title { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.sheet-close { color: var(--accent); font-weight: 600; font-size: 16px; }
.sheet .field + .field { margin-top: 14px; }
.sheet-actions { margin-top: 20px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* segmented pills (sheet type select etc.) */
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  padding: 9px 14px; border-radius: var(--r-pill); font-size: 14px; font-weight: 600;
  background: var(--card-2); color: var(--text-2); border: 1px solid transparent;
  transition: all .15s var(--ease);
}
.pill.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* toast */
.toast-host {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px);
  z-index: 80; display: grid; gap: 8px; justify-items: center; pointer-events: none; padding: 0 16px;
}
.toast {
  background: var(--text); color: var(--bg);
  padding: 11px 18px; border-radius: var(--r-pill); font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-lg); animation: toast-in .3s var(--ease);
  max-width: 90%;
}
.toast.err { background: var(--red); color: #fff; }

/* progress mini ring inline */
.mini-ring { display: inline-grid; place-items: center; }

/* divider */
.hr { height: 1px; background: var(--hair); margin: 14px 0; border: none; }

/* recipe cards */
.recipe-card {
  background: var(--card); border-radius: var(--r); box-shadow: var(--shadow-sm);
  padding: 16px; transition: transform .12s var(--ease); }
.recipe-card:active { transform: scale(.985); }
.recipe-card .rc-title { font-weight: 700; font-size: 16px; }
.recipe-card .rc-desc { color: var(--text-2); font-size: 13px; margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.recipe-card .rc-macros { display: flex; gap: 14px; margin-top: 12px; }
.recipe-card .rc-macros .rm { font-size: 13px; }
.recipe-card .rc-macros .rm b { font-weight: 700; }
.recipe-card .rc-macros .rm span { color: var(--text-2); font-size: 11px; display: block; }

/* sets table */
.sets-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.sets-table th { text-align: left; font-size: 12px; color: var(--text-2); font-weight: 600; padding: 6px 8px; }
.sets-table td { padding: 9px 8px; border-top: 1px solid var(--hair); font-size: 14px; }
.sets-table tr.pr td { color: var(--orange); font-weight: 600; }
.ex-block { margin-top: 12px; }
.ex-block .ex-name { font-weight: 700; font-size: 15px; padding: 0 2px 2px; }

/* delete swipe affordance (simple delete btn) */
.del-btn {
  color: var(--red); font-weight: 600; font-size: 14px;
  min-height: 44px; padding: 6px 10px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* targets readout */
.targets-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.targets-grid .tg { background: var(--card-2); border-radius: var(--r-sm); padding: 13px; }
.targets-grid .tg .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.targets-grid .tg .k { font-size: 12px; color: var(--text-2); }

/* legend */
.legend { display: flex; gap: 14px; flex-wrap: wrap; padding: 8px 2px 0; }
.legend .lg { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.legend .dot { width: 9px; height: 9px; border-radius: 3px; }

/* ============================================================
   animations
   ============================================================ */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.view > * { animation: pop .32s var(--ease) both; }
.view-enter { animation: pop .3s var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ============================================================
   LIVE GUIDED WORKOUT  (#/entrenar)
   ============================================================ */
.train-wrap { padding-top: 4px; }
.train-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 2px 6px; }
.train-top .tt-name { font-size: 15px; font-weight: 700; }
.train-top .tt-meta { color: var(--text-2); font-size: 13px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.train-top .t-clock { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.train-top .t-clock .ic { width: 14px; height: 14px; }
.train-cancel { color: var(--text-2); font-weight: 600; font-size: 14px; padding: 8px; min-height: 44px; display: inline-flex; align-items: center; }

.train-progress { display: flex; gap: 5px; margin: 4px 2px 16px; }
.tp-seg { flex: 1; height: 5px; border-radius: 99px; background: var(--ring-track); overflow: hidden; }
.tp-seg.done { background: var(--green); }
.tp-seg.current { background: var(--accent); }

/* current exercise hero */
.ex-hero {
  background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: 22px 20px; text-align: center; position: relative;
}
.ex-hero .eh-step { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); }
.ex-hero .eh-name { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 6px; line-height: 1.1; }
.ex-hero .eh-scheme { color: var(--text-2); font-size: 15px; margin-top: 8px; font-variant-numeric: tabular-nums; }
.ex-hero .eh-note { color: var(--text-3); font-size: 13px; margin-top: 6px; }
.ex-hero .eh-target { display: inline-flex; align-items: center; gap: 7px; margin-top: 14px;
  background: var(--accent-soft); color: var(--accent); border-radius: var(--r-pill);
  padding: 8px 14px; font-size: 13px; font-weight: 600; }
.ex-hero .eh-target .ic { width: 15px; height: 15px; }

/* set dots for current exercise */
.set-dots { display: flex; justify-content: center; gap: 9px; margin: 16px 0 4px; flex-wrap: wrap; }
.set-dot {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
  border: 2px solid var(--hair-strong); color: var(--text-3); background: var(--card);
  transition: all .2s var(--ease);
}
.set-dot.done { background: var(--green); border-color: var(--green); color: #fff; }
.set-dot.current { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.set-dot .ic { width: 16px; height: 16px; }

/* big numeric input row for logging a set */
.logset { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.logset .ls-field { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow-sm); padding: 12px 10px; text-align: center; min-width: 0; }
.logset .ls-field label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--text-2); margin-bottom: 6px; }
.stepper-num { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.stepper-num button {
  width: 36px; height: 36px; border-radius: 50%; background: var(--card-2);
  display: grid; place-items: center; color: var(--accent); flex: none;
  box-shadow: var(--shadow-sm); transition: transform .1s var(--ease);
  font-size: 21px; font-weight: 700; line-height: 1;
}
.stepper-num button:active { transform: scale(.9); }
.stepper-num button .ic { width: 18px; height: 18px; }
.stepper-num input {
  width: 100%; min-width: 0; flex: 1; text-align: center; background: transparent; border: none;
  font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; padding: 0;
  letter-spacing: -.02em; color: var(--text);
  -moz-appearance: textfield;
}
.stepper-num input::-webkit-outer-spin-button,
.stepper-num input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper-num input:focus { outline: none; }
.logset .ls-unit { font-size: 13px; color: var(--text-3); font-weight: 600; }

.train-actions { margin-top: 16px; display: grid; gap: 10px; }
.btn-primary.btn-lg { padding: 16px; font-size: 17px; border-radius: var(--r); }
.btn-primary .ic { width: 19px; height: 19px; }

/* rest timer overlay */
.rest-overlay {
  position: fixed; inset: 0; z-index: 70;
  display: grid; place-items: center; padding: 24px;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  -webkit-backdrop-filter: blur(24px) saturate(160%); backdrop-filter: blur(24px) saturate(160%);
  animation: fade .25s var(--ease);
}
.rest-card { text-align: center; width: 100%; max-width: 360px; }
.rest-label { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); }
.rest-ring-wrap { position: relative; display: inline-grid; place-items: center; margin: 14px 0 6px; }
.rest-time { position: absolute; font-size: 52px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.rest-next { color: var(--text-2); font-size: 15px; margin-top: 6px; }
.rest-next b { color: var(--text); font-weight: 700; }
.rest-btns { display: flex; gap: 10px; justify-content: center; margin-top: 22px; }
.rest-btns button {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 12px 20px; border-radius: var(--r-pill); font-weight: 700; font-size: 15px;
  background: var(--card); box-shadow: var(--shadow-sm); color: var(--text);
}
.rest-btns button.primary { background: var(--accent); color: #fff; }
.rest-btns button .ic { width: 17px; height: 17px; }
.rest-adjust { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }
.rest-adjust button { font-size: 13px; font-weight: 600; color: var(--accent); padding: 8px 12px; border-radius: 10px; background: var(--accent-soft); }

/* finish summary */
.finish-hero { text-align: center; padding: 20px 0 6px; }
.finish-hero .fh-ico { width: 76px; height: 76px; border-radius: 24px; margin: 0 auto 14px;
  display: grid; place-items: center; background: rgba(48,209,88,.16); color: var(--green); }
.finish-hero .fh-ico .ic { width: 38px; height: 38px; }
.finish-hero h2 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.finish-hero .fh-sub { color: var(--text-2); margin-top: 4px; }

/* coach line (the "te faltan X series / siguiente ejercicio" message) */
.coach {
  display: flex; align-items: flex-start; gap: 11px;
  background: var(--accent-soft); border-radius: var(--r); padding: 14px 15px; margin-top: 16px;
}
.coach .c-ico { width: 30px; height: 30px; border-radius: 9px; flex: none; display: grid; place-items: center;
  background: var(--accent); color: #fff; }
.coach .c-ico .ic { width: 18px; height: 18px; }
.coach .c-text { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.4; }
.coach .c-text b { color: var(--accent); }

/* ============================================================
   MONTHLY PROGRESS  (calendar heatmap + month stats)
   ============================================================ */
.month-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 2px 8px; }
.month-head .mh-label { font-size: 19px; font-weight: 800; letter-spacing: -.01em; text-transform: capitalize; }
.cal {
  background: var(--card); border-radius: var(--r); box-shadow: var(--shadow-sm); padding: 16px 14px;
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; padding-bottom: 4px; }
.cal-cell {
  aspect-ratio: 1; border-radius: 9px; display: grid; place-items: center; position: relative;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  background: var(--card-2); color: var(--text-3);
}
.cal-cell.lv1 { background: color-mix(in srgb, var(--accent) 22%, var(--card-2)); color: var(--text); }
.cal-cell.lv2 { background: color-mix(in srgb, var(--accent) 48%, var(--card-2)); color: var(--text); }
.cal-cell.lv3 { background: var(--accent); color: #fff; }
.cal-cell.today { box-shadow: 0 0 0 2px var(--accent); }
.cal-cell.empty { background: transparent; }
.cal-legend { display: flex; align-items: center; gap: 7px; justify-content: flex-end; margin-top: 12px; font-size: 11px; color: var(--text-3); }
.cal-legend .cl-box { width: 13px; height: 13px; border-radius: 4px; }

/* muscle-group volume bars (horizontal) */
.mg-bars { display: grid; gap: 11px; }
.mg-bar .mgb-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.mg-bar .mgb-name { font-weight: 600; text-transform: capitalize; }
.mg-bar .mgb-val { color: var(--text-2); font-variant-numeric: tabular-nums; }
.mg-bar .mgb-track { height: 9px; border-radius: 99px; background: var(--ring-track); overflow: hidden; }
.mg-bar .mgb-fill { height: 100%; border-radius: 99px; background: var(--accent); transition: width .6s var(--ease); }

/* segmented sub-tabs (Semanal / Mensual on Progreso) */
.subtabs { display: flex; background: var(--ring-track); border-radius: 12px; padding: 3px; gap: 3px; margin: 2px 0 4px; }
.subtabs button { flex: 1; padding: 9px 10px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--text-2); transition: all .15s var(--ease); }
.subtabs button.active { background: var(--card); color: var(--text); box-shadow: var(--shadow-sm); }

/* routine day cards */
.rd-card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 14px; }
.rd-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 15px 16px; border-bottom: 1px solid var(--hair); }
.rd-head .rd-name { font-weight: 700; font-size: 16px; }
.rd-head .rd-day { font-size: 12px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 4px 10px; border-radius: var(--r-pill); }
.rd-ex { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--hair); }
.rd-ex:first-of-type { border-top: none; }
.rd-ex .rdx-idx { width: 24px; height: 24px; border-radius: 7px; background: var(--card-2); color: var(--text-2);
  display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.rd-ex .rdx-main { flex: 1; min-width: 0; }
.rd-ex .rdx-name { font-weight: 600; font-size: 15px; }
.rd-ex .rdx-scheme { color: var(--text-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.rd-ex .rdx-tag { font-size: 11px; font-weight: 700; color: var(--text-3); flex: none; text-transform: capitalize; }

/* hero gradient accent for the "start workout" CTA card */
.start-card {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, var(--purple)));
  color: #fff; border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.start-card .sc-eyebrow { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; opacity: .85; }
.start-card .sc-title { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; }
.start-card .sc-sub { font-size: 14px; opacity: .9; margin-top: 4px; }
.start-card .sc-btn {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 16px;
  background: #fff; color: var(--accent); font-weight: 700; font-size: 15px;
  padding: 12px 20px; border-radius: var(--r-pill);
}
.start-card .sc-btn .ic { width: 18px; height: 18px; }
.start-card .sc-glow { position: absolute; right: -30px; top: -30px; width: 140px; height: 140px;
  border-radius: 50%; background: rgba(255,255,255,.14); }

/* card title icon */
.ct-row { display: flex; align-items: center; gap: 9px; }
.ct-row .ic { width: 18px; height: 18px; color: var(--accent); }

/* ============================================================
   RESPONSIVE  — phone → tablet → desktop
   Mobile keeps the clean centered column. ≥900px becomes a real
   desktop layout: left sidebar nav + wider multi-column content.
   ============================================================ */

/* tablet: slightly wider column, 2-up quick grid stays */
@media (min-width: 600px) and (max-width: 899px) {
  :root { --maxw: 600px; }
  .quick-grid { grid-template-columns: repeat(4, 1fr); }
  .tabbar { left: 50%; right: auto; transform: translateX(-50%); width: 100%; max-width: var(--maxw);
    border-left: 1px solid var(--hair); border-right: 1px solid var(--hair); }
}

/* DESKTOP ≥900px — sidebar app layout */
@media (min-width: 900px) {
  :root { --sidebar-w: 240px; --content-maxw: 940px; }

  body { background: var(--bg); }

  /* turn the bottom tabbar into a left sidebar */
  .tabbar {
    position: fixed; top: 0; bottom: 0; left: 0; right: auto;
    width: var(--sidebar-w);
    flex-direction: column; justify-content: flex-start; align-items: stretch;
    gap: 4px; padding: 22px 14px;
    background: var(--bg-elev);
    border-top: none; border-right: 1px solid var(--hair);
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .tabbar::before {
    content: "Atlas"; display: block;
    font-size: 22px; font-weight: 800; letter-spacing: -.02em; color: var(--text);
    padding: 4px 12px 18px;
  }
  .tab {
    flex: none; max-width: none; flex-direction: row; justify-content: flex-start; gap: 13px;
    min-height: 46px; padding: 11px 13px; border-radius: 12px;
  }
  .tab-ico { height: auto; }
  .tab-ico .ic { width: 21px; height: 21px; }
  .tab-label { font-size: 15px; font-weight: 600; }
  .tab:hover { background: var(--card-2); }
  .tab.active { background: var(--accent-soft); color: var(--accent); }
  .tab:active { transform: none; }

  /* content shifts right of the sidebar, header spans content area */
  .app-header {
    position: sticky; top: 0;
    padding-left: var(--sidebar-w);
  }
  .header-inner { max-width: var(--content-maxw); padding: 16px 32px; }
  .header-title { font-size: 26px; }

  .view {
    max-width: var(--content-maxw);
    margin-left: var(--sidebar-w);
    margin-right: auto;
    padding: 18px 32px 60px;
    min-height: 100dvh;
  }

  /* center the content nicely within the available space */
  .app-header .header-inner, .view { margin-left: max(var(--sidebar-w), 0px); }
  @media (min-width: 1300px) {
    .view { margin-left: var(--sidebar-w); margin-right: auto;
      padding-left: max(32px, calc((100vw - var(--sidebar-w) - var(--content-maxw)) / 2)); }
    .app-header { padding-left: var(--sidebar-w); }
    .app-header .header-inner { margin: 0 auto; }
  }

  /* desktop multi-column dashboards (only top-level grids, not inside 2-col) */
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .targets-grid { grid-template-columns: repeat(4, 1fr); }

  /* Hoy becomes a 2-column layout via a wrapper the view sets */
  .desk-2col { display: grid; grid-template-columns: 1.1fr .9fr; gap: 24px; align-items: start; }
  .desk-2col > * { min-width: 0; }
  .desk-2col .section-title:first-child { padding-top: 4px; }
  /* inside the narrower right column, keep quick + stats 2-up */
  .desk-2col .quick-grid { grid-template-columns: repeat(2, 1fr); }
  .desk-2col .stat-grid { grid-template-columns: repeat(2, 1fr); }

  /* progreso charts 2-up */
  .chart-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

  /* sheets become centered modals on desktop */
  .sheet {
    left: 50%; right: auto; bottom: auto; top: 50%;
    transform: translate(-50%, -50%);
    max-width: 460px; width: calc(100% - 48px);
    border-radius: var(--r-lg);
    max-height: 86dvh;
    animation: rise .3s var(--ease);
  }
  .rest-card { max-width: 400px; }

  /* the live workout reads centered & roomy on desktop */
  .train-wrap, .finish-hero { max-width: 560px; margin-left: auto; margin-right: auto; }
  .toast-host { bottom: 28px; }

  /* hover affordances */
  .quick:hover, .recipe-card:hover, .list-row.tappable:hover, .rd-ex:hover { background: var(--card-2); }
  .stat:hover, .chart-card:hover { box-shadow: var(--shadow); }
  .header-action:hover { background: var(--card-2); }
}

/* extra-wide: cap content + breathing room */
@media (min-width: 1500px) {
  :root { --content-maxw: 1040px; }
}

/* ============================================================
   LIVE WORKOUT SESSION (#/entrenar, server-backed)
   ============================================================ */
.live-head { margin-bottom: 14px; }
.live-title { font-size: 22px; font-weight: 700; letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.live-meta { display: flex; align-items: center; gap: 12px; margin-top: 6px; color: var(--text-2); font-size: 14px; }
.live-meta b { color: var(--text); font-variant-numeric: tabular-nums; }
.lm-clock { display: inline-flex; align-items: center; gap: 5px; }
.live-dot { color: var(--green); font-size: 10px; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

.rest-bar { position: sticky; top: calc(var(--safe-top) + 54px); z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--accent); color: #fff; border-radius: var(--r-sm); padding: 10px 14px;
  margin-bottom: 12px; box-shadow: var(--shadow); }
.rest-bar[hidden] { display: none; }
.rest-bar-l { display: inline-flex; align-items: center; gap: 7px; font-size: 15px; }
.rest-bar-l b { font-variant-numeric: tabular-nums; font-size: 16px; }
.rest-skip { background: rgba(255,255,255,.22); color: #fff; border-radius: 99px;
  padding: 6px 14px; font-weight: 600; font-size: 13px; }

.live-list { display: grid; gap: 10px; }
.ex-card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow-sm);
  padding: 14px 16px; transition: box-shadow .2s var(--ease); }
.ex-card.current { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.ex-card.done { opacity: .66; }
.ex-top { display: flex; align-items: center; gap: 12px; }
.ex-num, .ex-now, .ex-check { flex: none; width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
.ex-num { background: var(--card-2); color: var(--text-2); }
.ex-now { background: var(--accent-soft); color: var(--accent); }
.ex-check { background: rgba(48,209,88,.16); color: var(--green); }
.ex-main { min-width: 0; flex: 1; }
.ex-name { font-weight: 600; font-size: 16px; }
.ex-target { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.set-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.set-chip { background: var(--card-2); border-radius: 8px; padding: 4px 9px; font-size: 12px;
  color: var(--text-2); font-variant-numeric: tabular-nums; }
.log-row { display: flex; gap: 8px; margin-top: 12px; }
.log-row .log-reps, .log-row .log-kg { flex: 1 1 0; min-width: 0; background: var(--card-2);
  border: 1px solid var(--hair); border-radius: var(--r-sm); padding: 12px; font-size: 16px; text-align: center; }
.log-row .log-reps:focus, .log-row .log-kg:focus { outline: none; border-color: var(--accent); background: var(--card); }
.log-btn { flex: none; width: 52px; border-radius: var(--r-sm); background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; }
.log-btn:active { transform: scale(.97); }

.live-actions { display: grid; gap: 10px; margin-top: 20px; }
.btn-ghost-danger { width: 100%; padding: 13px; border-radius: var(--r-sm); background: rgba(255,69,58,.10);
  color: var(--red); font-weight: 600; font-size: 15px; min-height: 44px; }
.btn-ghost-danger:active { background: rgba(255,69,58,.18); }
.btn-text { width: 100%; padding: 10px; color: var(--text-3); font-size: 14px; }

.finish-card { text-align: center; max-width: 360px; margin: 24px auto; background: var(--card);
  border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 32px 22px; }
.finish-ico { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%;
  background: rgba(48,209,88,.16); color: var(--green); display: flex; align-items: center; justify-content: center; }
.finish-sub { color: var(--text-2); margin-top: 6px; }
.finish-pr { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; color: var(--orange); font-weight: 600; font-size: 14px; }
.finish-card .btn-primary { margin-top: 20px; }

/* Hoy "entrenamiento en curso" banner */
.live-banner { display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
  background: linear-gradient(135deg, var(--accent), #4aa3ff); color: #fff;
  border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); cursor: pointer; }
.live-banner:active { transform: scale(.99); }
.live-banner .lb-ico { flex: none; width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,.22); display: flex; align-items: center; justify-content: center; }
.live-banner .lb-main { flex: 1; min-width: 0; }
.live-banner .lb-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 7px; }
.live-banner .lb-sub { font-size: 13px; opacity: .9; margin-top: 1px; }
.live-banner .lb-dot { width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: pulse 1.6s ease-in-out infinite; }

/* editable set rows (workout detail) */
.set-edit-row { cursor: pointer; transition: background .12s var(--ease); }
.set-edit-row:active { background: var(--card-2); }
.set-edit-hint { color: var(--text-3); display: inline-flex; }

/* ===========================================================
   §6A — Onboarding wizard (first-login full-screen flow)
   Owned by onboarding-agent. Append-only block.
   =========================================================== */
.ob-root {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  padding: calc(var(--safe-top) + 8px) 0 0;
}
.ob-top { flex: none; padding: 8px 20px 4px; min-height: 22px; }
.ob-dots { display: flex; gap: 7px; justify-content: center; }
.ob-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--hair-strong);
  transition: background .25s var(--ease), transform .25s var(--ease); }
.ob-dot.done { background: var(--accent); opacity: .45; }
.ob-dot.active { background: var(--accent); transform: scale(1.35); }

.ob-scroll { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.ob-step { max-width: var(--maxw, 480px); margin: 0 auto; width: 100%;
  padding: 18px 22px 24px; animation: obIn .32s var(--ease) both; }
@keyframes obIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.ob-hero { text-align: center; padding: 32px 0 26px; }
.ob-mark { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-bottom: 22px; }
.ob-mark-emo { font-weight: 400; }
.ob-head { padding: 8px 0 18px; }
.ob-title { font-size: 27px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.ob-hero .ob-title { font-size: 28px; }
.ob-sub { color: var(--text-2); font-size: 15px; margin-top: 8px; line-height: 1.4; }
.ob-hint { color: var(--text-3); font-size: 13px; text-align: center; margin-top: 14px; }
.ob-field { margin-top: 6px; }
.ob-field + .grid-2, .ob-field + .field { margin-top: 16px; }
.grid-2 + .field { margin-top: 16px; }

/* segmented (sexo) */
.ob-seg { display: flex; gap: 0; background: var(--card-2); border: 1px solid var(--hair);
  border-radius: var(--r-sm); padding: 4px; }
.ob-seg button { flex: 1 1 0; padding: 11px; border-radius: 9px; font-size: 15px; font-weight: 600;
  color: var(--text-2); min-height: 44px; transition: all .15s var(--ease); }
.ob-seg button.active { background: var(--card); color: var(--text); box-shadow: var(--shadow-sm); }

/* selectable cards (objetivo / actividad / disciplinas) */
.ob-cards { display: grid; gap: 12px; }
.ob-card { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--card); border: 1.5px solid var(--hair); border-radius: var(--r);
  padding: 16px; min-height: 64px; transition: border-color .15s var(--ease), background .15s var(--ease), transform .1s var(--ease); }
.ob-card:active { transform: scale(.985); }
.ob-card.sel { border-color: var(--accent); background: var(--accent-soft); }
.ob-card-ico { flex: none; width: 42px; height: 42px; border-radius: 12px; display: flex;
  align-items: center; justify-content: center; background: var(--card-2); color: var(--text-2); }
.ob-card.sel .ob-card-ico { background: var(--accent); color: #fff; }
.ob-card-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ob-card-title { font-weight: 600; font-size: 16px; }
.ob-card-sub { color: var(--text-2); font-size: 13px; }
.ob-card-check { flex: none; width: 24px; height: 24px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; color: #fff; background: var(--accent);
  opacity: 0; transform: scale(.6); transition: all .15s var(--ease); }
.ob-card.sel .ob-card-check { opacity: 1; transform: scale(1); }

/* días/semana picker */
.ob-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.ob-days button { padding: 0; height: 46px; border-radius: var(--r-sm); font-size: 16px; font-weight: 600;
  color: var(--text-2); background: var(--card-2); border: 1px solid var(--hair); transition: all .15s var(--ease); }
.ob-days button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* summary list reuse */
.ob-summary { margin-top: 4px; }

/* nav footer */
.ob-nav { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: var(--maxw, 480px); margin: 0 auto; width: 100%;
  padding: 12px 22px calc(var(--safe-bottom) + 16px); border-top: 1px solid var(--hair);
  background: var(--bg); }
.ob-nav.single { justify-content: stretch; }
.ob-back { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2);
  font-size: 15px; font-weight: 500; padding: 12px 6px; min-height: 44px; }
.ob-back:active { opacity: .6; }
.ob-cta { flex: 1 1 auto; max-width: 280px; margin-left: auto; }
.ob-nav.single .ob-cta { max-width: none; }

/* result screen */
.ob-done { text-align: center; padding-top: 26px; }
.ob-done-ico { width: 72px; height: 72px; margin: 0 auto 18px; border-radius: 50%;
  background: rgba(48,209,88,.16); color: var(--green); display: flex; align-items: center; justify-content: center;
  animation: obPop .4s var(--ease) both; }
@keyframes obPop { 0% { transform: scale(.5); opacity: 0; } 60% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }
.ob-kcal { margin: 26px auto 8px; }
.ob-kcal-val { font-size: 52px; font-weight: 700; letter-spacing: -.03em; line-height: 1; color: var(--accent); }
.ob-kcal-key { color: var(--text-2); font-size: 14px; margin-top: 6px; }
.ob-macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 24px; }
.ob-macro { background: var(--card); border: 1px solid var(--hair); border-radius: var(--r); padding: 16px 10px; }
.ob-macro-val { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.ob-macro-val span { font-size: 14px; font-weight: 500; color: var(--text-2); margin-left: 2px; }
.ob-macro-key { color: var(--text-2); font-size: 12px; margin-top: 4px; }
.ob-meta { color: var(--text-3); font-size: 13px; margin-top: 18px; }

/* ============================================================
   §6B — Disciplinas (Running + Hyrox)  [disciplines-agent]
   Append-only. Reuses base tokens (.segmented, .chip, .stat, etc.).
   ============================================================ */

/* discipline segmented selector (top of Entrenos) */
.disc-seg { margin: 6px 0 14px; }

/* discipline summary stat grid spacing */
.disc-sum { margin-bottom: 4px; }

/* selectable chips (run type / disciplines) — toggle .active */
.disc-chip {
  cursor: pointer; border: 1px solid var(--hair); background: var(--card-2);
  color: var(--text-2); box-shadow: none; transition: all .15s var(--ease);
}
.disc-chip:active { transform: scale(.96); }
.disc-chip.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}

/* hyrox segment list (log sheet) */
.hx-seg-line {
  display: flex; align-items: center; gap: 12px;
  background: var(--card-2); border: 1px solid var(--hair);
  border-radius: var(--r-sm); padding: 10px 12px;
}
.hx-seg-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.hx-seg-name { font-size: 14px; font-weight: 600; color: var(--text); }
.hx-seg-name.run { color: var(--accent); }
.hx-seg-extra { font-size: 12px; color: var(--text-2); }
.hx-seg-input {
  flex: none; width: 84px; text-align: center; font-variant-numeric: tabular-nums;
  background: var(--card); border: 1px solid var(--hair); border-radius: 10px; padding: 10px;
  color: var(--text); font-size: 15px;
}
.hx-seg-input:focus { outline: none; border-color: var(--accent); }

/* running total row in hyrox sheet */
.hx-total-row {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-top: 12px; padding: 12px 4px 0; border-top: 1px solid var(--hair);
  font-weight: 700; font-size: 16px;
}
.hx-total-row span:last-child { font-size: 22px; letter-spacing: -.02em; }

/* hyrox detail segments table */
.hx-table .hx-seg-name { font-weight: 600; }
.hx-table .hx-seg-extra { display: block; font-size: 12px; color: var(--text-2); margin-top: 1px; font-weight: 400; }

/* ============================================================
   §6C — Registro de entreno mobile-first (manual log + live RIR)
   Append-only. Touch-first targets (44px+), grouped-by-exercise.
   ============================================================ */

/* "Desde tu rutina" one-tap suggestion chips */
.mlog-sugs { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 4px; }
.mlog-sug {
  border: 1px solid var(--accent); background: var(--accent-soft); color: var(--accent);
  border-radius: 99px; padding: 8px 13px; font-size: 13.5px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 5px; min-height: 38px;
  transition: transform .12s var(--ease), opacity .15s var(--ease);
}
.mlog-sug::before { content: "+"; font-weight: 700; opacity: .8; }
.mlog-sug:active { transform: scale(.95); }
.mlog-sug.used { opacity: .42; }

/* exercise blocks */
.mlog-list { display: grid; gap: 12px; margin-bottom: 12px; }
.mlog-ex {
  background: var(--card); border: 1px solid var(--hair); border-radius: var(--r);
  padding: 12px 12px 14px; box-shadow: var(--shadow-sm);
}
.mlog-ex-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.mlog-ex-head .lw-ex {
  flex: 1; min-width: 0; background: var(--card-2); border: 1px solid var(--hair);
  border-radius: var(--r-sm); padding: 12px; font-size: 16px; font-weight: 600; color: var(--text);
  min-height: 46px;
}
.mlog-ex-head .lw-ex:focus { outline: none; border-color: var(--accent); background: var(--card); }

/* set rows: #  reps  kg  RIR  ✕ */
.mlog-sets { display: grid; gap: 8px; }
.mlog-set {
  display: grid; grid-template-columns: 16px 1fr 1fr 1fr 34px;
  gap: 7px; align-items: center;
}
.mlog-setn { font-size: 12px; font-weight: 700; color: var(--text-3); text-align: center; font-variant-numeric: tabular-nums; }
.mlog-set input {
  width: 100%; min-width: 0; background: var(--card-2); border: 1px solid var(--hair);
  border-radius: var(--r-sm); padding: 12px 6px; font-size: 16px; text-align: center;
  color: var(--text); font-variant-numeric: tabular-nums; min-height: 46px;
}
.mlog-set input:focus { outline: none; border-color: var(--accent); background: var(--card); }

/* small ghost remove buttons (set + exercise) */
.mlog-rm {
  flex: none; width: 34px; height: 34px; border-radius: 9px; color: var(--text-3);
  display: inline-flex; align-items: center; justify-content: center; background: transparent;
}
.mlog-rm:active { background: rgba(255,69,58,.12); color: var(--red); }

/* add-set / add-exercise */
.mlog-addset {
  margin-top: 10px; display: inline-flex; align-items: center; gap: 5px;
  color: var(--accent); font-weight: 600; font-size: 14px; padding: 6px 2px; min-height: 38px;
}
.mlog-addex { width: 100%; display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; min-height: 48px; }

/* sticky save bar — always reachable without scrolling to the bottom */
.mlog-save-bar {
  position: sticky; bottom: 0; z-index: 3;
  margin: 18px -18px 0; padding: 12px 18px calc(8px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg-elev) 62%, transparent);
}

/* live quick-log: RIR input next to reps/kg */
.log-row .log-rir {
  flex: 1 1 0; min-width: 0; background: var(--card-2); border: 1px solid var(--hair);
  border-radius: var(--r-sm); padding: 12px; font-size: 16px; text-align: center;
  color: var(--text); font-variant-numeric: tabular-nums;
}
.log-row .log-rir:focus { outline: none; border-color: var(--accent); background: var(--card); }

/* ============================================================
   §6D — Hyrox LIVE race (cronómetro guiado). Reuses .live-head,
   .live-meta, .live-actions, .start-card, .finish-card from gym.
   ============================================================ */

/* current segment hero card with split stopwatch */
.hl-current {
  background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: 20px 18px; text-align: center; margin-bottom: 16px;
  border: 1px solid var(--hair);
}
.hl-current.run { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.hl-current.station { box-shadow: 0 0 0 2px var(--orange), var(--shadow); }
.hl-cur-eyebrow {
  font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-3);
}
.hl-current.run .hl-cur-eyebrow { color: var(--accent); }
.hl-current.station .hl-cur-eyebrow { color: var(--orange); }
.hl-cur-name { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; }
.hl-cur-meta { color: var(--text-2); font-size: 14px; margin-top: 3px; }
.hl-cur-split {
  font-size: 52px; font-weight: 800; letter-spacing: -.03em; margin: 12px 0 16px;
  font-variant-numeric: tabular-nums; line-height: 1;
}
.hl-lap { font-size: 17px; padding: 16px; }
.hl-current .btn-text { margin-top: 8px; }

/* segment progression list */
.hl-list { display: grid; gap: 8px; }
.hl-row {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border-radius: var(--r-sm); padding: 11px 14px; box-shadow: var(--shadow-sm);
  transition: opacity .2s var(--ease);
}
.hl-row.todo { opacity: .5; }
.hl-row.current { box-shadow: 0 0 0 2px var(--accent), var(--shadow-sm); opacity: 1; }
.hl-ico {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
.hl-ico.run { background: var(--accent-soft); color: var(--accent); }
.hl-ico.station { background: rgba(255,159,10,.16); color: var(--orange); }
.hl-row-main { flex: 1; min-width: 0; }
.hl-row-name { font-weight: 600; font-size: 15px; }
.hl-row-meta { color: var(--text-2); font-size: 12px; margin-top: 1px; }
.hl-row-t { font-variant-numeric: tabular-nums; font-size: 15px; color: var(--text-3); }
.hl-row-t.done { color: var(--green); font-weight: 700; }
.hl-row.current .hl-row-t { color: var(--accent); font-weight: 600; }
