:root {
  --bg: #0f1115; --card: #181b22; --card2: #20242d; --line: #2a2f3a; --text: #e8eaf0; --dim: #8b93a5;
  --p: #f472b6; --c: #60a5fa; --f: #fbbf24; --fi: #4ade80; --kcal: #a78bfa; --bad: #f87171; --ok: #4ade80;
  --radius: 16px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Hebrew", sans-serif; }
body { min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
.hidden { display: none !important; }

/* layout */
.shell { max-width: 640px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-t)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); }
.top h1 { font-size: 20px; margin: 0; flex: 1; }
.top .who { color: var(--dim); font-size: 13px; }
main { flex: 1; padding: 4px 14px calc(90px + var(--safe-b)); }
nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; justify-content: center;
  background: color-mix(in srgb, var(--card) 94%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b); }
nav.tabs .in { display: flex; width: 100%; max-width: 640px; }
nav.tabs button { flex: 1; padding: 10px 0 12px; color: var(--dim); font-size: 12px; display: flex; flex-direction: column; align-items: center; gap: 3px; }
nav.tabs button svg { width: 24px; height: 24px; }
nav.tabs button.on { color: var(--text); }

.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin: 10px 0; }
.card h2 { font-size: 15px; margin: 0 0 10px; color: var(--dim); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card h2 .sp { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; }
.dim { color: var(--dim); }
.small { font-size: 13px; }
.big { font-size: 34px; font-weight: 700; letter-spacing: -0.5px; }
.err { color: var(--bad); }

.btn { background: var(--card2); border-radius: 12px; padding: 10px 14px; font-weight: 600; }
.btn.primary { background: #3b82f6; color: white; }
.btn.danger { background: #7f1d1d; color: #fecaca; }
.btn.ghost { background: transparent; color: var(--dim); }
.btn:disabled { opacity: .5; cursor: default; }
.chip { background: var(--card2); border-radius: 999px; padding: 7px 12px; font-size: 13px; white-space: nowrap; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
input.field, textarea.field { width: 100%; background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; outline: none; }
input.field:focus, textarea.field:focus { border-color: #3b82f6; }

/* login */
.login { max-width: 380px; margin: 0 auto; padding: calc(60px + var(--safe-t)) 22px 40px; }
.login h1 { font-size: 28px; margin: 18px 0 4px; }
.login label { display: block; margin: 16px 0 6px; color: var(--dim); font-size: 13px; }
.login .btn { width: 100%; margin-top: 22px; padding: 13px; }
.login img { width: 72px; height: 72px; }

/* today */
.hero { display: flex; align-items: center; gap: 16px; }
.hero svg { flex: none; }
.hero .nums { flex: 1; }
.bar { margin: 9px 0; }
.bar .lbl { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.bar .track { position: relative; height: 8px; background: var(--card2); border-radius: 99px; overflow: visible; }
.bar .fill { height: 100%; border-radius: 99px; }
.bar .tick { position: absolute; top: -3px; width: 2px; height: 14px; background: var(--text); opacity: .55; border-radius: 1px; }
.slots { display: grid; grid-template-columns: repeat(var(--n, 4), 1fr); gap: 6px; }
.slot { background: var(--card2); border-radius: 12px; padding: 8px; text-align: center; font-size: 12px; }
.slot b { display: block; font-size: 15px; }
.slot.now { outline: 2px solid #3b82f6; }
.slot.over b { color: var(--bad); }
.entry { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.entry:first-child { border-top: 0; }
.entry .name { flex: 1; min-width: 0; }
.entry .name div:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry .kc { font-weight: 600; }
.x { color: var(--dim); padding: 4px 8px; font-size: 18px; line-height: 1; }
.slotlabel { font-size: 12px; color: var(--dim); margin: 12px 0 2px; text-transform: uppercase; letter-spacing: .5px; }
.fab { position: fixed; right: max(16px, calc(50vw - 304px)); bottom: calc(76px + var(--safe-b)); z-index: 7; width: 56px; height: 56px;
  border-radius: 18px; background: #3b82f6; color: white; font-size: 30px; line-height: 1; box-shadow: 0 6px 20px #0008; }

/* sheet */
.scrim { position: fixed; inset: 0; background: #0009; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 640px; max-height: 88dvh; border-radius: 20px 20px 0 0; padding: 14px 16px calc(16px + var(--safe-b));
  display: flex; flex-direction: column; gap: 10px; animation: up .18s ease-out; }
.sheet h3 { margin: 0; font-size: 17px; }
.sheet .list { overflow-y: auto; flex: 1; min-height: 120px; }
.food { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-top: 1px solid var(--line); width: 100%; text-align: start; }
.food .name { flex: 1; min-width: 0; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
.dialog { background: var(--card); border-radius: 18px; padding: 18px; margin: auto 16px; max-width: 360px; width: 100%; align-self: center; }
.dialog .row { justify-content: flex-end; margin-top: 16px; }
.amount { display: flex; gap: 8px; align-items: center; }
.amount input { text-align: center; font-size: 22px; font-weight: 700; }
.macros4 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; text-align: center; font-size: 12px; }
.macros4 b { display: block; font-size: 16px; }

/* gym */
.ex { background: var(--card); border-radius: var(--radius); padding: 12px 14px; margin: 8px 0; }
.ex .head { display: flex; align-items: baseline; gap: 8px; }
.ex .head .n { flex: 1; font-weight: 600; }
.ex .last { font-size: 12px; color: var(--dim); margin-top: 2px; }
.steppers { display: flex; gap: 8px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.step { display: flex; align-items: center; background: var(--card2); border-radius: 12px; }
.step button { width: 34px; height: 38px; font-size: 18px; color: var(--dim); }
.step span { min-width: 44px; text-align: center; font-weight: 700; }
.step small { color: var(--dim); font-size: 11px; margin-inline-end: 6px; }
.done-badge { color: var(--ok); font-size: 13px; font-weight: 600; }
.bodypart { margin: 18px 4px 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--dim); }

/* weight */
.chart { width: 100%; height: 180px; display: block; }
.chart text { fill: var(--dim); font-size: 10px; }

/* coach */
.chat { display: flex; flex-direction: column; gap: 10px; padding-bottom: 130px; }
.msg { max-width: 92%; padding: 10px 12px; border-radius: 16px; background: var(--card); overflow-x: auto; unicode-bidi: plaintext; }
.msg.me { align-self: flex-end; background: #1e3a8a; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.err { background: #3f1d1d; }
.msg p { margin: 4px 0; }
.msg ul { margin: 4px 0; padding-inline-start: 20px; }
.msg table { border-collapse: collapse; margin: 6px 0; font-size: 13px; }
.msg th, .msg td { border-bottom: 1px solid var(--line); padding: 4px 7px; text-align: start; white-space: nowrap; }
.msg th { color: var(--dim); font-weight: 600; }
.composer { position: fixed; left: 0; right: 0; bottom: calc(62px + var(--safe-b)); z-index: 6; display: flex; justify-content: center; pointer-events: none; }
.composer .in { width: 100%; max-width: 640px; padding: 8px 12px; background: linear-gradient(transparent, var(--bg) 30%); pointer-events: auto; }
.composer .row { align-items: flex-end; }
.composer textarea { resize: none; max-height: 140px; min-height: 44px; unicode-bidi: plaintext; }
.typing { color: var(--dim); font-size: 13px; padding: 4px 6px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(150px + var(--safe-b)); z-index: 30; background: #111827; border: 1px solid var(--line);
  padding: 10px 14px; border-radius: 12px; display: flex; gap: 12px; align-items: center; box-shadow: 0 6px 20px #0008; }
.toast button { color: #93c5fd; font-weight: 600; }
.bristol { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.bristol button { background: var(--card2); border-radius: 10px; padding: 9px 0; font-weight: 700; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--text); border-radius: 50%; animation: spin 1s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { color: var(--dim); text-align: center; padding: 16px 0; font-size: 14px; }

/* progress */
.chip.on { background: #3b82f6; color: white; }
.stats2 { display: flex; gap: 8px; margin-bottom: 10px; }
.stats2 > div { flex: 1; background: var(--card2); border-radius: 14px; padding: 9px 12px; }
.stats2 b { display: block; font-size: 18px; }
.stats2 span { color: var(--dim); font-size: 12px; font-weight: 600; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal .dow { color: var(--dim); font-size: 11px; padding: 2px 0; }
.cal .day { aspect-ratio: 1; border-radius: 50%; font-size: 13px; color: var(--dim); }
.cal .day.on { background: #3b82f6; color: white; font-weight: 700; }
.cal .day.today { outline: 2px solid var(--text); }
.card h2 .chips { padding: 0; }
nav.tabs button { font-size: 11px; }
