:root {
  --bg: #f6f5f2; --surface: #ffffff; --surface2: #efede8; --text: #1c1b19; --muted: #6b6860; --hint: #9c978d;
  --line: rgba(0,0,0,.08); --accent: #2563eb; --accent-soft: #dbeafe; --accent-ink: #1e40af;
  --ok: #16a34a; --ok-soft: #dcfce7; --warn: #d97706; --warn-soft: #fef3c7; --bad: #dc2626; --bad-soft: #fee2e2;
  --fx-line: #c9c5bc; --fx-eq: #a8a29e; --fx-eq2: #d6d3d1; --fx-mat: #bbf7d0; --fx-body: #273142; --fx-body2: #a3acb9; --fx-db: var(--accent);
  --r: 16px; --r-sm: 10px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 18px rgba(0,0,0,.05);
  --nav-h: 64px; --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #181b21; --surface2: #22262e; --text: #eceae6; --muted: #a09c94; --hint: #77736c;
    --line: rgba(255,255,255,.08); --accent-soft: #1e293b; --accent-ink: #93c5fd;
    --ok-soft: #12301d; --warn-soft: #33260b; --bad-soft: #3a1414;
    --fx-line: #3a3f48; --fx-eq: #6b6760; --fx-eq2: #4a4741; --fx-mat: #1f4d32; --fx-body: #e5e7eb; --fx-body2: #6b7280;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #181b21; --surface2: #22262e; --text: #eceae6; --muted: #a09c94; --hint: #77736c;
  --line: rgba(255,255,255,.08); --accent-soft: #1e293b; --accent-ink: #93c5fd;
  --ok-soft: #12301d; --warn-soft: #33260b; --bad-soft: #3a1414;
  --fx-line: #3a3f48; --fx-eq: #6b6760; --fx-eq2: #4a4741; --fx-mat: #1f4d32; --fx-body: #e5e7eb; --fx-body2: #6b7280;
  --shadow: none; color-scheme: dark;
}
body.p-alejandrina { --accent: #db2777; --accent-soft: #fce7f3; --accent-ink: #9d174d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body.p-alejandrina { --accent-soft: #3b1a2a; --accent-ink: #f9a8d4; } }

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.45; font-size: 15px; min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
input, select, textarea { background: var(--surface2); border: 1px solid transparent; border-radius: var(--r-sm); padding: 10px 12px; width: 100%; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px calc(var(--nav-h) + var(--safe-b) + 24px); }

.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.top-in { max-width: 640px; margin: 0 auto; padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px; display: flex; align-items: center; gap: 10px; }
.brand { font-weight: 800; font-size: 19px; letter-spacing: -.4px; flex: 1; }
.brand span { color: var(--accent); }
.who { display: flex; background: var(--surface2); border-radius: 999px; padding: 3px; }
.who button { padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); }
.who button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.icon-btn:active { background: var(--surface2); }

.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.nav-in { max-width: 640px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); height: var(--nav-h); }
.nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--hint); }
.nav button svg { width: 24px; height: 24px; }
.nav button.on { color: var(--accent); }

h2 { font-size: 22px; letter-spacing: -.4px; font-weight: 800; line-height: 1.2; }
h3 { font-size: 16px; font-weight: 700; }
.sec-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--hint); font-weight: 700; margin: 22px 2px 8px; }
.muted { color: var(--muted); }
.hint { color: var(--hint); font-size: 13px; }
.card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px; }
.stack > * + * { margin-top: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; background: var(--surface2); font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.chip.acc { background: var(--accent-soft); color: var(--accent-ink); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: 12px; font-weight: 700; background: var(--surface2); }
.btn.pri { background: var(--accent); color: #fff; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; }
.btn:active { transform: scale(.98); }

.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 12px 0 4px; }
.days button { padding: 8px 0 6px; border-radius: 12px; background: var(--surface); font-weight: 700; font-size: 13px; display: flex; flex-direction: column; align-items: center; gap: 2px; box-shadow: var(--shadow); }
.days button small { font-size: 10px; font-weight: 600; color: var(--hint); }
.days button.today small { color: var(--accent); }
.days button.on { background: var(--accent); color: #fff; }
.days button.on small { color: rgba(255,255,255,.8); }

.hero { display: flex; gap: 12px; align-items: flex-end; margin-top: 16px; }
.prog { height: 8px; background: var(--surface2); border-radius: 99px; overflow: hidden; }
.prog > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }
.prog.ok > i { background: var(--ok); }
.prog.over > i { background: var(--warn); }

.ex { display: flex; gap: 12px; align-items: center; padding: 10px; }
.ex .fig { width: 92px; flex: none; background: var(--surface2); border-radius: 12px; padding: 2px; }
.ex .fig.ph { height: 80px; display: grid; place-items: center; font-size: 26px; }
.ex h4 { font-size: 15px; font-weight: 700; line-height: 1.25; }
.ex .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.ex .note { font-size: 12px; color: var(--hint); margin-top: 2px; }
.sets { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.set { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); font-size: 12px; font-weight: 700; color: var(--muted); display: grid; place-items: center; }
.set.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.ex.done { opacity: .62; }
.block-label { font-size: 13px; font-weight: 700; color: var(--muted); margin: 16px 2px 6px; }
.kg { width: 78px; padding: 6px 8px; font-size: 13px; text-align: center; }

.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; animation: fade .15s; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; background: var(--surface); border-radius: 22px 22px 0 0; max-height: 92dvh; overflow: auto; padding: 8px 16px calc(20px + var(--safe-b)); animation: up .2s ease-out; max-width: 640px; margin: 0 auto; }
.sheet .grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 4px auto 12px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.list-item { display: flex; align-items: center; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.x { width: 30px; height: 30px; border-radius: 50%; color: var(--hint); display: grid; place-items: center; flex: none; }
.x:active { background: var(--bad-soft); color: var(--bad); }

.macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.macros b { font-size: 13px; display: block; }
.macros small { font-size: 12px; color: var(--muted); }
.big-num { font-size: 34px; font-weight: 800; letter-spacing: -1px; line-height: 1; }
.meal-h { display: flex; align-items: center; justify-content: space-between; margin: 18px 2px 6px; }
.meal-h h3 { font-size: 15px; }
.meal-h .k { font-size: 13px; color: var(--muted); font-weight: 600; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin: 0 0 4px 2px; }
.stat { background: var(--surface); border-radius: var(--r); padding: 12px 14px; box-shadow: var(--shadow); }
.stat small { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.stat b { font-size: 22px; letter-spacing: -.5px; }
.stat i { font-style: normal; font-size: 12px; color: var(--muted); }

.chat { display: flex; flex-direction: column; gap: 10px; padding-top: 12px; }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 16px; white-space: normal; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.msg.assistant { align-self: flex-start; background: var(--surface); box-shadow: var(--shadow); border-bottom-left-radius: 5px; }
.msg p + p, .msg ul + p, .msg p + ul { margin-top: 6px; }
.msg ul { padding-left: 18px; }
.prop { margin-top: 8px; border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: var(--surface2); }
.prop .row { margin-top: 8px; }
.composer { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b)); background: var(--bg); padding: 8px 16px; z-index: 25; }
.composer-in { max-width: 640px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { resize: none; max-height: 120px; min-height: 44px; border-radius: 22px; padding: 11px 16px; background: var(--surface); box-shadow: var(--shadow); }
.send { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff; flex: none; display: grid; place-items: center; }
.suggest { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.suggest button { flex: none; padding: 7px 12px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow); font-size: 13px; }
.typing span { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--hint); margin: 0 2px; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: .2; } }

.guided { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: flex; flex-direction: column; padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px calc(16px + var(--safe-b)); overflow: auto; }
.guided .gtop { display: flex; align-items: center; gap: 10px; }
.guided .gfig { background: var(--surface); border-radius: 20px; margin: 12px 0; padding: 6px; box-shadow: var(--shadow); max-width: 460px; width: 100%; align-self: center; }
.guided h2 { text-align: center; }
.guided .target { text-align: center; font-size: 40px; font-weight: 800; letter-spacing: -1px; margin: 4px 0; }
.guided .sub { text-align: center; color: var(--muted); }
.guided .gfoot { margin-top: auto; padding-top: 14px; display: grid; gap: 10px; }
.ring { width: 210px; height: 210px; margin: 10px auto; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .num { position: absolute; inset: 0; display: grid; place-items: center; font-size: 54px; font-weight: 800; letter-spacing: -2px; }
.cues { padding-left: 20px; color: var(--muted); font-size: 14px; }
.cues li + li { margin-top: 4px; }

.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login .card { width: 100%; max-width: 380px; padding: 24px; }
.login h1 { font-size: 28px; letter-spacing: -.8px; margin-bottom: 4px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + var(--safe-b) + 14px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 80; font-size: 14px; font-weight: 600; max-width: calc(100% - 32px); animation: up .2s; }
.chart { width: 100%; height: auto; display: block; }
.chart text { font-size: 10px; fill: var(--hint); }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-top: 14px; scrollbar-width: none; }
.tabs button { flex: none; padding: 8px 14px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow); font-weight: 600; font-size: 13px; color: var(--muted); }
.tabs button.on { background: var(--text); color: var(--bg); }
.supp h4 { font-size: 15px; }
details summary { cursor: pointer; font-weight: 600; }
.attach { width: 44px; height: 44px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow); display: grid; place-items: center; color: var(--muted); flex: none; cursor: pointer; }
.thumbs { display: flex; gap: 8px; padding: 2px 0 8px; }
.thumb { position: relative; width: 64px; height: 64px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }
.thumb button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; background: var(--text); color: var(--bg); font-weight: 700; line-height: 1; }
.chat-img { display: block; max-width: 100%; max-height: 260px; border-radius: 12px; margin-bottom: 6px; }
.glasses { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.glass { width: 34px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--hint); background: var(--surface2); }
.glass.on { color: #fff; background: #0ea5e9; }
