:root {
  --bg: #0f1512; --card: #18201c; --card2: #1f2924; --line: #2b3832; --text: #eef3ef; --mut: #93a39a;
  --acc: #4fd18b; --acc2: #2fa86a; --p: #5aa9ff; --c: #f2b84b; --f: #ef6f6c; --fib: #b18cff; --warn: #f2b84b; --bad: #ef6f6c;
  --r: 16px; --nav: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: 'Tajawal', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 16px; }
body { padding-bottom: calc(var(--nav) + env(safe-area-inset-bottom)); }
button, input, select { font: inherit; color: inherit; }
input, select { background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--acc2); border-color: transparent; }
label { display: block; color: var(--mut); font-size: 13px; margin: 10px 0 4px; }
.boot { display: grid; place-items: center; height: 80vh; font-size: 28px; font-weight: 800; color: var(--acc); }
.wrap { max-width: 640px; margin: 0 auto; padding: 12px 14px 24px; }
.top { position: sticky; top: 0; z-index: 5; background: linear-gradient(var(--bg) 75%, transparent); padding: calc(10px + env(safe-area-inset-top)) 14px 8px; }
.top .row { max-width: 640px; margin: 0 auto; }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.grow { flex: 1; }
.wrap-row { flex-wrap: wrap; }
h1 { font-size: 22px; margin: 0; font-weight: 800; }
h2 { font-size: 18px; margin: 0 0 10px; font-weight: 800; }
h3 { font-size: 16px; margin: 0; font-weight: 700; }
.mut { color: var(--mut); font-size: 13px; }
.small { font-size: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin: 10px 0; }
.btn { background: var(--acc); color: #04200f; border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 800; cursor: pointer; white-space: nowrap; }
.btn.sec { background: var(--card2); color: var(--text); border: 1px solid var(--line); font-weight: 600; }
.btn.ghost { background: transparent; color: var(--mut); border: 1px dashed var(--line); font-weight: 600; }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid #5a2b2a; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.icon { background: var(--card2); border: 1px solid var(--line); border-radius: 10px; width: 38px; height: 38px; display: grid; place-items: center; cursor: pointer; font-size: 17px; flex: none; }
.chip { display: inline-block; padding: 6px 12px; border-radius: 99px; background: var(--card2); border: 1px solid var(--line); font-size: 13px; cursor: pointer; margin: 3px; }
.chip.on { background: var(--acc); color: #04200f; border-color: var(--acc); font-weight: 700; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 99px; background: var(--card2); font-size: 11px; color: var(--mut); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stat { background: var(--card2); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; color: var(--mut); }

/* شريط التنقل */
.nav { position: fixed; bottom: 0; inset-inline: 0; z-index: 10; background: #121a16ee; backdrop-filter: blur(10px); border-top: 1px solid var(--line); display: flex; padding-bottom: env(safe-area-inset-bottom); }
.nav button { flex: 1; height: var(--nav); background: none; border: 0; color: var(--mut); font-size: 11px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; }
.nav button i { font-style: normal; font-size: 21px; }
.nav button.on { color: var(--acc); font-weight: 700; }

/* حلقة السعرات */
.ring { position: relative; width: 132px; height: 132px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .in { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .in b { font-size: 26px; display: block; line-height: 1; }
.bar { height: 8px; background: var(--card2); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; border-radius: 99px; }
.macro { margin: 8px 0; }
.macro .row { font-size: 13px; margin-bottom: 4px; }

/* الأكل */
.meal { padding: 0; overflow: hidden; }
.meal .head { padding: 12px 14px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.item { padding: 10px 14px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #222c27; cursor: pointer; }
.item:last-child { border-bottom: 0; }
.item .nm { flex: 1; min-width: 0; }
.item .nm div:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kc { font-weight: 800; text-align: left; min-width: 60px; }
.list { max-height: 52vh; overflow: auto; margin: 0 -14px; }
.res { padding: 10px 14px; border-bottom: 1px solid #222c27; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.res:hover, .item:hover { background: #1c2621; }

/* التمارين */
.ex { padding: 12px; }
.ex img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; background: #fff; flex: none; }
.target { background: #12301f; border: 1px solid #1f5a3a; color: #b9f3d1; padding: 8px 10px; border-radius: 10px; font-size: 13px; margin-top: 8px; line-height: 1.6; }
.target.down { background: #3a1d1c; border-color: #6b2e2c; color: #ffd2d0; }
.target.up { background: #11351f; border-color: #2fa86a; }
.setrow { display: grid; grid-template-columns: 28px 1fr 1fr 70px 44px; gap: 6px; align-items: center; margin-top: 6px; }
.setrow input, .setrow select { padding: 9px 6px; text-align: center; }
.done { display: grid; grid-template-columns: 28px 1fr 34px; gap: 6px; align-items: center; margin-top: 4px; font-size: 14px; color: var(--acc); }
.num { width: 26px; height: 26px; border-radius: 50%; background: var(--card2); display: grid; place-items: center; font-size: 12px; color: var(--mut); }
.today-day { border-color: var(--acc2); }

/* التقرير */
.rep { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rep:last-child { border-bottom: 0; }
.rep .ic { font-size: 20px; flex: none; width: 28px; text-align: center; }
.rep p { margin: 2px 0 0; color: #cfd9d3; font-size: 14px; line-height: 1.6; }

/* نافذة منبثقة */
.modal { position: fixed; inset: 0; background: #000a; z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.modal.hidden { display: none; }
.sheet { background: var(--card); width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 16px 14px calc(18px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.timer { position: fixed; bottom: calc(var(--nav) + 10px + env(safe-area-inset-bottom)); inset-inline: 12px; max-width: 616px; margin: 0 auto; z-index: 20; background: #12301f; border: 1px solid var(--acc2); border-radius: 14px; padding: 10px 14px; display: flex; align-items: center; gap: 10px; box-shadow: 0 8px 30px #0008; }
.timer.hidden { display: none; }
.timer b { font-size: 24px; font-variant-numeric: tabular-nums; flex: 1; }
.toast { position: fixed; top: calc(14px + env(safe-area-inset-top)); inset-inline: 0; margin: 0 auto; width: fit-content; max-width: 90%; background: #263129; border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; z-index: 40; font-size: 14px; }
.toast.hidden { display: none; }
.toast.err { border-color: var(--bad); color: #ffd2d0; }
svg text { font-family: inherit; }
.chart { width: 100%; height: auto; display: block; }
.auth { max-width: 420px; margin: 8vh auto; padding: 20px; }
.logo { font-size: 40px; font-weight: 800; color: var(--acc); text-align: center; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
td, th { padding: 7px 4px; border-bottom: 1px solid var(--line); text-align: right; }
th { color: var(--mut); font-weight: 500; font-size: 12px; }
video { width: 100%; border-radius: 12px; background: #000; }
details summary { cursor: pointer; color: var(--mut); font-size: 13px; }
.hr { height: 1px; background: var(--line); margin: 12px 0; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }
td:first-child { width: 38%; color: var(--mut); }
