/* FitSV Coach — diseño */
:root {
  --bg: #f3f6f5; --surface: #ffffff; --surface-2: #f7faf9; --ink: #0f1f1c; --muted: #5f716d; --line: #e3eae8;
  --brand: #0d9488; --brand-2: #10b981; --brand-ink: #ffffff; --brand-soft: #e0f5f1;
  --grad: linear-gradient(135deg, #0d9488 0%, #10b981 55%, #84cc16 130%);
  --warn: #c2410c; --warn-soft: #ffedd5; --bad: #dc2626; --bad-soft: #fee2e2; --ok: #15803d; --ok-soft: #dcfce7;
  --gold: #f59e0b; --protein: #3b82f6; --carb: #f59e0b; --fat: #a855f7; --water: #0ea5e9;
  --r: 20px; --r-sm: 12px;
  --shadow: 0 1px 2px rgba(15, 31, 28, .04), 0 8px 24px rgba(15, 31, 28, .06);
  --shadow-lg: 0 20px 50px rgba(15, 31, 28, .18);
  --side: 248px;
  color-scheme: light;
}
/* Instalación con la marca de un coach (BRAND=jc en el servidor): JC Training System — azules y verdes oscuros (el naranja queda solo en el logo) */
:root[data-brand="jc"] {
  --brand: #1d4ed8; --brand-2: #047857; --brand-ink: #ffffff; --brand-soft: #e3ebfd;
  --grad: linear-gradient(150deg, #222728 0%, #0f2a4a 55%, #065f46 120%);
}
:root[data-theme="dark"] {
  --bg: #0b1210; --surface: #121c1a; --surface-2: #17231f; --ink: #e8f1ef; --muted: #8fa5a0; --line: #22312d;
  --brand: #2dd4bf; --brand-2: #34d399; --brand-ink: #032420; --brand-soft: #0f2f2a;
  --warn: #fb923c; --warn-soft: #3a210d; --bad: #f87171; --bad-soft: #3a1414; --ok: #4ade80; --ok-soft: #0f2e1a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 20px 50px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
:root[data-theme="dark"][data-brand="jc"] { --brand: #60a5fa; --brand-2: #34d399; --brand-ink: #071226; --brand-soft: #102a4c; }
.logo b.brandimg { background: #222728; padding: 0; overflow: hidden; box-shadow: none; }
.logo b.brandimg img { width: 100%; height: 100%; object-fit: cover; }
.auth .art .brand-logo { width: min(440px, 100%); margin: 0 0 1.6rem; display: block; filter: drop-shadow(0 6px 18px rgba(0, 0, 0, .35)); } /* logo sin fondo: se funde con el degradado */
:root[data-brand] .auth .art::after { content: none; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 800; } h2 { font-size: 1.1rem; font-weight: 700; } h3 { font-size: .98rem; font-weight: 700; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .tiny { font-size: .75rem; }
.hidden { display: none !important; }
.ico { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Layout */
.app { min-height: 100vh; }
.side { position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 1.2rem .9rem; z-index: 30; }
.logo { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.15rem; padding: .2rem .5rem 1.2rem; }
.logo b { width: 36px; height: 36px; border-radius: 11px; background: var(--grad); display: grid; place-items: center; font-size: 1.2rem; box-shadow: 0 6px 16px rgba(13, 148, 136, .35); }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a { display: flex; align-items: center; gap: .75rem; padding: .65rem .8rem; border-radius: 12px; color: var(--muted); font-weight: 600; position: relative; transition: background .15s, color .15s; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.nav .count { margin-left: auto; background: var(--bad); color: #fff; font-size: .7rem; font-weight: 800; border-radius: 999px; padding: .05rem .45rem; min-width: 20px; text-align: center; }
.me { display: flex; align-items: center; gap: .65rem; padding: .6rem; border-radius: 14px; background: var(--surface-2); cursor: pointer; }
.me div { min-width: 0; } .me strong, .me small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; flex: none; font-size: .9rem; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.2rem; }
.content { margin-left: var(--side); padding: 1.6rem 2rem 6rem; max-width: calc(1180px + var(--side)); }
.mobile-top { display: none; }

/* ---------- Grids */
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.auto { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.span2 { grid-column: span 2; } .full { grid-column: 1 / -1; }
.row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: .8rem; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.head p { margin-top: .25rem; }
.mt { margin-top: 1rem; }

/* ---------- Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .9rem; }
.card-h h2 { display: flex; align-items: center; gap: .5rem; }
.card.tap { cursor: pointer; transition: transform .15s, box-shadow .15s; }
.card.tap:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.hero { background: var(--grad); color: #fff; border: 0; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; width: 260px; height: 260px; border-radius: 50%; background: rgba(255, 255, 255, .1); right: -70px; top: -110px; }
.hero .muted { color: rgba(255, 255, 255, .85); }
.hero .quote { font-size: .95rem; margin-top: .5rem; max-width: 60ch; position: relative; z-index: 1; }
.pill { display: inline-flex; align-items: center; gap: .35rem; background: rgba(255, 255, 255, .18); padding: .3rem .7rem; border-radius: 999px; font-weight: 700; font-size: .85rem; backdrop-filter: blur(4px); }
.kpi { display: flex; flex-direction: column; gap: .2rem; }
.kpi .v { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.kpi .ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); margin-bottom: .4rem; }

/* ---------- Forms */
label { display: block; font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: .3rem; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--surface-2); border: 1.5px solid var(--line); border-radius: var(--r-sm); padding: .6rem .8rem; min-height: 44px; transition: border-color .15s, box-shadow .15s; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; accent-color: var(--brand); }
.fg { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.fg .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: .55rem; font-weight: 600; color: var(--ink); font-size: .92rem; margin: 0; cursor: pointer; }
.search { position: relative; } .search .ico { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 2.5rem; }

/* ---------- Buttons */
.btn { font: inherit; font-weight: 700; font-size: .92rem; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); border-radius: var(--r-sm); padding: .55rem 1rem; min-height: 44px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; transition: transform .1s, background .15s, border-color .15s; white-space: nowrap; }
.btn:hover { border-color: var(--brand); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); box-shadow: 0 6px 16px rgba(13, 148, 136, .25); }
.btn.grad { background: var(--grad); border: 0; color: #fff; box-shadow: 0 8px 20px rgba(13, 148, 136, .3); }
.btn.soft { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 34px; padding: .3rem .7rem; font-size: .82rem; border-radius: 10px; }
.btn.icon { padding: 0; width: 40px; min-width: 40px; }
.btn.sm.icon { width: 34px; min-width: 34px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .6; cursor: wait; }
.fab { position: fixed; right: 1.6rem; bottom: 1.6rem; width: 60px; height: 60px; border-radius: 20px; border: 0; background: var(--grad); color: #fff; box-shadow: 0 12px 30px rgba(13, 148, 136, .45); cursor: pointer; display: grid; place-items: center; z-index: 25; transition: transform .15s; }
.fab:hover { transform: scale(1.06) rotate(90deg); }
.fab .ico { width: 28px; height: 28px; stroke-width: 2.5; }

/* ---------- Chips / segmented */
.chip { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; font-weight: 700; padding: .18rem .6rem; border-radius: 999px; background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.chip.warn { background: var(--warn-soft); color: var(--warn); } .chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.ok { background: var(--ok-soft); color: var(--ok); } .chip.gray { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.chip.gold { background: #fef3c7; color: #b45309; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.seg button { font: inherit; font-weight: 700; font-size: .85rem; border: 0; background: transparent; color: var(--muted); padding: .45rem .85rem; border-radius: 10px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }
.seg.full { display: flex; } .seg.full button { flex: 1; }

/* ---------- Progreso */
.ring { position: relative; display: grid; place-items: center; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .track { stroke: var(--line); }
.ring .val { transition: stroke-dashoffset .8s cubic-bezier(.2, .8, .2, 1); }
.ring .lbl { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .lbl b { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--brand); transition: width .6s; }
.bar.lg { height: 12px; }
.bar.over > i { background: var(--bad) !important; }
.macro { margin: .55rem 0; } .macro .row { justify-content: space-between; font-size: .85rem; margin-bottom: .25rem; }
.cal { display: flex; align-items: center; gap: 1.4rem; }
.cal .side-stats { flex: 1; min-width: 0; }
.weekbars { display: flex; align-items: flex-end; gap: 8px; height: 110px; }
.weekbars > div { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; font-size: .72rem; color: var(--muted); }
.weekbars i { width: 100%; max-width: 34px; border-radius: 8px 8px 4px 4px; background: var(--grad); min-height: 4px; transition: height .6s; }
.weekbars i.none { background: var(--line); } .weekbars i.over { background: var(--bad); }
.weekbars .today { color: var(--brand); font-weight: 800; }

/* Misiones */
.mission { display: flex; align-items: center; gap: .75rem; padding: .55rem .2rem; border-bottom: 1px dashed var(--line); }
.mission:last-child { border-bottom: 0; }
.mission .tick { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex: none; transition: .3s; }
.mission.done .tick { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.mission.done .txt { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--brand-2); }
.mission .txt { flex: 1; font-weight: 600; font-size: .92rem; }
.mission .pts { font-size: .75rem; font-weight: 800; color: var(--gold); }

/* Agua */
.water { display: flex; flex-wrap: wrap; gap: .4rem; }
.glass { width: 38px; height: 46px; border: 2px solid var(--water); border-radius: 6px 6px 12px 12px; background: transparent; cursor: pointer; position: relative; overflow: hidden; padding: 0; transition: transform .1s; }
.glass:active { transform: scale(.92); }
.glass::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--water); opacity: .8; transition: height .35s; }
.glass.full::after { height: 85%; }

/* Comidas */
.meal-block { border: 1px solid var(--line); border-radius: 16px; padding: .8rem .9rem; background: var(--surface-2); }
.meal-block + .meal-block { margin-top: .7rem; }
.meal-block .mh { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.meal-block .mh h3 { display: flex; align-items: center; gap: .45rem; }
.item { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; border-top: 1px solid var(--line); }
.item:first-of-type { margin-top: .5rem; }
.item .grow { flex: 1; min-width: 0; }
.item .name { font-weight: 600; font-size: .92rem; }
.suggest { margin-top: .6rem; padding: .55rem .7rem; border-radius: 12px; background: var(--brand-soft); color: var(--brand); font-size: .85rem; display: flex; align-items: center; gap: .5rem; justify-content: space-between; }

/* Listas */
.list { list-style: none; padding: 0; margin: 0; }
.list > li { display: flex; align-items: center; gap: .7rem; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.pick { display: flex; align-items: center; gap: .7rem; padding: .7rem .8rem; border-radius: 14px; cursor: pointer; border: 1px solid transparent; }
.pick:hover { background: var(--surface-2); border-color: var(--line); }
.pick .grow { flex: 1; min-width: 0; }
.emoji { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); font-size: 1.25rem; flex: none; }
.option { border: 1px solid var(--line); border-radius: 16px; padding: .9rem 1rem; background: var(--surface); }
.option + .option { margin-top: .7rem; }
.tags { display: flex; gap: .35rem; flex-wrap: wrap; margin: .45rem 0; }
ul.tips { margin: .3rem 0 0; padding-left: 1.15rem; } ul.tips li { margin: .3rem 0; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }
.empty { text-align: center; color: var(--muted); padding: 1.8rem .5rem; }
.empty .big { font-size: 2.4rem; display: block; margin-bottom: .3rem; }
.banner { padding: .7rem 1rem; border-radius: 14px; background: var(--warn-soft); color: var(--warn); font-size: .88rem; display: flex; gap: .5rem; align-items: center; }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }

/* Logros */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .7rem; }
.badge { text-align: center; padding: .9rem .5rem; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); }
.badge .e { font-size: 2rem; display: block; line-height: 1.2; }
.badge b { display: block; font-size: .82rem; margin-top: .25rem; }
.badge small { color: var(--muted); font-size: .7rem; line-height: 1.25; display: block; margin-top: .15rem; }
.badge.lock { opacity: .55; } .badge.lock .e { filter: grayscale(1); }
.badge.won { background: linear-gradient(180deg, #fffbeb, var(--surface)); border-color: #fcd34d; }
:root[data-theme="dark"] .badge.won { background: linear-gradient(180deg, #2a2210, var(--surface)); border-color: #a16207; }

/* Chat */
.chat { display: flex; flex-direction: column; height: calc(100vh - 220px); min-height: 420px; }
.chat .msgs { flex: 1; overflow-y: auto; padding: .5rem .2rem; display: flex; flex-direction: column; gap: .45rem; }
.bubble { max-width: 78%; padding: .6rem .85rem; border-radius: 18px; font-size: .93rem; position: relative; word-wrap: break-word; }
.bubble.them { background: var(--surface-2); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 6px; }
.bubble.me { background: var(--brand); color: var(--brand-ink); align-self: flex-end; border-bottom-right-radius: 6px; }
.bubble.auto { border-style: dashed; }
.bubble .meta { display: block; font-size: .68rem; opacity: .7; margin-top: .2rem; }
.bubble .react { position: absolute; bottom: -10px; right: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; font-size: .8rem; padding: 0 .3rem; }
.reacts { display: flex; gap: .2rem; margin-top: .3rem; }
.reacts button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; cursor: pointer; font-size: .85rem; padding: .05rem .45rem; }
.composer { display: flex; gap: .5rem; padding-top: .7rem; border-top: 1px solid var(--line); align-items: flex-end; }
.composer textarea { min-height: 44px; height: 44px; max-height: 140px; }
.quick { display: flex; gap: .4rem; overflow-x: auto; padding: .5rem 0 .2rem; scrollbar-width: none; }
.quick button { flex: none; }
.threads .pick.on { background: var(--brand-soft); }
.daysep { align-self: center; font-size: .72rem; color: var(--muted); background: var(--surface-2); padding: .1rem .6rem; border-radius: 999px; margin: .4rem 0; }

/* Peso */
.chart { width: 100%; height: 180px; display: block; }
.chart .line { fill: none; stroke: var(--brand); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart .area { fill: url(#gArea); }
.chart .goal { stroke: var(--gold); stroke-dasharray: 6 6; stroke-width: 2; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart circle { fill: var(--surface); stroke: var(--brand); stroke-width: 2.5; }

/* Sheet / diálogo */
dialog.sheet { border: 0; padding: 0; background: var(--surface); color: var(--ink); width: min(560px, 100vw); max-height: 88vh; border-radius: 24px; box-shadow: var(--shadow-lg); overflow: hidden; }
dialog.sheet::backdrop { background: rgba(5, 15, 13, .5); backdrop-filter: blur(3px); }
dialog.sheet[open] { animation: pop .22s cubic-bezier(.2, .8, .2, 1); }
.sheet-in { display: flex; flex-direction: column; max-height: 88vh; }
.sheet-h { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.2rem .6rem; gap: .6rem; }
.sheet-b { padding: .4rem 1.2rem 1.3rem; overflow-y: auto; }
.grabber { display: none; width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: .55rem auto 0; }
@keyframes pop { from { transform: translateY(20px) scale(.98); opacity: 0; } }
.stepper { display: flex; align-items: center; gap: .7rem; justify-content: center; margin: .8rem 0; }
.stepper b { font-size: 2rem; min-width: 80px; text-align: center; }
.stepper .btn { width: 52px; height: 52px; border-radius: 16px; font-size: 1.4rem; }
.actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; }
.action { display: flex; flex-direction: column; align-items: flex-start; gap: .5rem; padding: 1rem; border-radius: 18px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; font: inherit; color: inherit; text-align: left; }
.action:hover { border-color: var(--brand); }
.action .emoji { background: var(--surface); }

/* Login */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth .art { background: var(--grad); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.auth .art h1 { font-size: 2.6rem; line-height: 1.1; max-width: 14ch; }
.auth .art ul { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; gap: .8rem; font-weight: 600; }
.auth .art li { display: flex; gap: .7rem; align-items: center; }
.auth .art li span { width: 38px; height: 38px; border-radius: 12px; background: rgba(255, 255, 255, .18); display: grid; place-items: center; }
.auth .art::after { content: "🥑"; position: absolute; font-size: 16rem; right: -3rem; bottom: -4rem; opacity: .12; }
.auth .panel { display: grid; place-items: center; padding: 2rem 1.2rem; }
.auth form { width: min(380px, 100%); }

/* Toast + confeti */
#toast { position: fixed; left: 50%; bottom: 2rem; transform: translate(-50%, 30px); background: var(--ink); color: var(--bg); padding: .7rem 1.1rem; border-radius: 14px; opacity: 0; pointer-events: none; transition: .3s; z-index: 100; font-weight: 600; max-width: 90vw; box-shadow: var(--shadow-lg); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 99; }
.spinner { display: inline-block; width: 1em; height: 1em; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { height: 120px; border-radius: var(--r); background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border: 1px solid var(--line); }
@keyframes sk { to { background-position: -200% 0; } }
.fade-in { animation: fade .35s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Responsive */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: minmax(0, 1fr); } .g3 > .span2 { grid-column: auto; } }
@media (max-width: 860px) {
  .side { inset: auto 0 0 0; width: auto; height: auto; flex-direction: row; padding: .35rem .3rem calc(.35rem + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); }
  .side .logo, .side .me { display: none; }
  .nav { flex-direction: row; justify-content: space-around; overflow-x: auto; scrollbar-width: none; }
  .nav a { flex-direction: column; gap: .15rem; font-size: .68rem; padding: .4rem .5rem; min-width: 62px; text-align: center; }
  .nav a .ico { width: 22px; height: 22px; }
  .nav .count { position: absolute; top: 2px; right: 8px; margin: 0; }
  .mobile-top { display: flex; align-items: center; justify-content: space-between; padding: .7rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  .content { margin-left: 0; padding: 1rem 1rem 7rem; }
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .g4.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span2 { grid-column: auto; }
  .fab { bottom: calc(5.4rem + env(safe-area-inset-bottom)); right: 1rem; }
  h1 { font-size: 1.35rem; }
  dialog.sheet { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 24px 24px 0 0; }
  dialog.sheet[open] { animation: up .25s cubic-bezier(.2, .8, .2, 1); }
  .grabber { display: block; }
  .auth { grid-template-columns: 1fr; } .auth .art { padding: 2rem 1.4rem; } .auth .art h1 { font-size: 1.8rem; } .auth .art ul { display: none; }
  .chat { height: calc(100vh - 250px); }
  #toast { bottom: calc(6rem + env(safe-area-inset-bottom)); }
}
@keyframes up { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Estado de conexión */
#netbar { position: fixed; top: calc(.6rem + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 60; padding: .35rem .9rem; border-radius: 999px; font-size: .8rem; font-weight: 700; box-shadow: var(--shadow-lg); display: none; white-space: nowrap; max-width: 94vw; overflow: hidden; text-overflow: ellipsis; }
#netbar.off { display: block; background: #1f2937; color: #fff; }
#netbar.sync { display: block; background: var(--brand); color: var(--brand-ink); }
@media (max-width: 860px) { #netbar { top: calc(4.4rem + env(safe-area-inset-top)); } }

/* Fotos de comidas y registro de "Comer fuera" */
.mthumb { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; flex: none; cursor: zoom-in; border: 1px solid var(--line); }
.photo-prev { width: 100%; max-height: 240px; object-fit: cover; border-radius: 14px; margin-bottom: .6rem; }
.part { display: flex; align-items: center; gap: .6rem; padding: .55rem 0; border-top: 1px solid var(--line); }
.part .grow { flex: 1; min-width: 0; }
.part.off .name { opacity: .45; text-decoration: line-through; }
.stepper { display: inline-flex; align-items: center; gap: .25rem; }
.stepper b { min-width: 2.2rem; text-align: center; font-size: 1.05rem; }
.stepper .btn { width: 36px; height: 36px; padding: 0; justify-content: center; }
.total-box { position: sticky; bottom: -1.3rem; background: var(--surface); padding: .7rem 0 1.3rem; margin: .4rem 0 -1.3rem; border-top: 1px solid var(--line); z-index: 1; }
.total-box .kcal { font-size: 1.6rem; font-weight: 800; }

/* Barras tocables y catálogo de menú */
.weekbars [data-day] { cursor: pointer; border-radius: 10px; transition: background .15s; }
.weekbars [data-day]:hover, .weekbars [data-day]:focus-visible { background: var(--brand-soft); outline: none; }
.cat-sec { margin: .9rem 0 .2rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
/* Tono del coach elegido */
#tones .pick { border: 2px solid transparent; }
#tones .pick.on { border-color: var(--brand); background: var(--brand-soft); }
#tones .pick.on strong::after { content: '  ✓ Elegido'; color: var(--brand); font-size: .8rem; }

/* Misiones tocables */
button.mission { width: 100%; background: none; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; border-radius: 12px; }
button.mission:hover, button.mission:focus-visible { background: var(--brand-soft); outline: none; }

/* Ficha de anamnesis */
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .3rem .8rem; }
.check { display: flex; align-items: center; gap: .45rem; font-weight: 500; font-size: .92rem; margin: 0; cursor: pointer; }
.check input { width: auto; }

/* Hoy por pestañas */
.today-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px; padding: 4px; }
.today-tabs button { font: inherit; font-weight: 600; font-size: .85rem; border: 0; background: transparent; color: var(--muted); padding: .45rem .2rem; border-radius: 12px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.today-tabs button span { font-size: 1.25rem; }
.today-tabs button.on { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); font-weight: 800; }
.cmp { margin-bottom: .7rem; } .cmp.big { margin-bottom: 1rem; } .cmp.big .cmp-v { font-size: 1.5rem; } .cmp-v { font-size: 1.05rem; }
.bad-t { color: var(--bad); } .ok-t { color: var(--ok); }
table.bymeal { width: 100%; border-collapse: collapse; } table.bymeal td, table.bymeal th { padding: .5rem .3rem; border-top: 1px solid var(--line); }
table.bymeal th { border-top: 0; font-size: .75rem; color: var(--muted); font-weight: 600; } table.bymeal tr[data-goto] { cursor: pointer; }
table.bymeal tr[data-goto]:hover { background: var(--brand-soft); }

/* Gasto energético */
.energy-res .kpi { background: var(--surface-2); border-radius: 14px; padding: .7rem .8rem; }
/* Plan semanal: un día desplegable por fila */
.day-plan { border: 1px solid var(--line); border-radius: 16px; padding: .7rem 1rem; margin-top: .7rem; background: var(--surface); }
.day-plan > summary { cursor: pointer; list-style: none; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.day-plan > summary::-webkit-details-marker { display: none; }
.day-plan > summary::before { content: '▸'; color: var(--muted); transition: transform .15s; }
.day-plan[open] > summary::before { transform: rotate(90deg); }
.meal-block .option { padding: .6rem .7rem; }

/* Avisos emergentes de alertas del coach */
#alert-pops { position: fixed; top: 1rem; right: 1rem; z-index: 60; display: grid; gap: .6rem; width: min(360px, calc(100vw - 2rem)); }
.alert-pop { display: flex; gap: .7rem; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--warn); border-radius: var(--r); padding: .8rem .9rem; box-shadow: var(--shadow-lg); animation: popin .25s ease-out; transition: opacity .25s, transform .25s; }
.alert-pop.out { opacity: 0; transform: translateX(20px); }
.alert-pop .ai { font-size: 1.5rem; line-height: 1; }
.alert-pop p { margin: .2rem 0 .5rem; font-size: .9rem; }
.alert-pop .x { background: none; border: 0; color: var(--muted); cursor: pointer; padding: .1rem; }
@keyframes popin { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@media (max-width: 860px) { #alert-pops { top: auto; bottom: 5.5rem; right: 1rem; left: 1rem; width: auto; } }

/* Botón de ojo para ver la contraseña */
.pw-wrap { position: relative; display: block; flex: 1; }
.pw-wrap input { padding-right: 2.8rem; }
.pw-eye { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); cursor: pointer; padding: .35rem; border-radius: 8px; display: grid; place-items: center; }
.pw-eye:hover { color: var(--ink); background: var(--surface); }

/* Continuar con Google / Microsoft */
.or { display: flex; align-items: center; gap: .7rem; color: var(--muted); font-size: .8rem; margin: .2rem 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.btn.oauth { border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); display: flex; align-items: center; justify-content: center; gap: .6rem; margin-top: .5rem; text-decoration: none; }
