:root {
  --bg: #0d1117;
  --bg2: #151b24;
  --card: #1b232f;
  --line: #2a3442;
  --text: #e8edf3;
  --muted: #8b97a8;
  --primary: #22c55e;
  --primary-d: #16a34a;
  --accent: #f97316;
  --blue: #38bdf8;
  --red: #ef4444;
  --amber: #f59e0b;
  --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 70px; }
body {
  font-family: "Cairo", system-ui, Tahoma, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.7;
}
a { color: inherit; text-decoration: none; }
.container { width: min(1180px, 92%); margin-inline: auto; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }

/* ===== Nav ===== */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 60; background: var(--bg); }
.nav { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 50; background: rgba(13,17,23,.88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.logo { font-size: 1.5rem; font-weight: 900; }
.logo span { color: var(--primary); }
.nav nav { display: flex; gap: 6px; }
.nav nav a { padding: 6px 12px; border-radius: 10px; font-weight: 600; color: var(--muted); transition: .2s; }
.nav nav a:hover, .nav nav a.active { color: var(--text); background: var(--card); }
.menu-btn { display: none; background: none; border: 0; color: var(--text); font-size: 1.6rem; cursor: pointer; }

/* ===== Buttons ===== */
.btn { display: inline-block; border: 0; cursor: pointer; font-family: inherit; font-weight: 700; font-size: 1rem; padding: 10px 22px; border-radius: 12px; transition: .2s; }
.btn.primary { background: var(--primary); color: #04130a; }
.btn.primary:hover { background: var(--primary-d); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn.small { padding: 6px 14px; font-size: .9rem; }
.btn.full { width: 100%; }

/* ===== Hero ===== */
.hero { padding: 90px 0 70px; background:
  radial-gradient(circle at 15% 20%, rgba(34,197,94,.18), transparent 45%),
  radial-gradient(circle at 85% 80%, rgba(249,115,22,.15), transparent 45%); }
.hero-inner { display: grid; grid-template-columns: 1.4fr 1fr; gap: 40px; align-items: center; }
.hero h1 { font-size: clamp(2rem, 4.5vw, 3.3rem); line-height: 1.3; font-weight: 900; }
.accent { color: var(--primary); }
.hero p { color: var(--muted); font-size: 1.1rem; margin: 18px 0 28px; }
.hero-btns { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; text-align: center; }
.stat b { display: block; font-size: 2.2rem; color: var(--primary); font-weight: 900; }
.stat span { color: var(--muted); }

/* ===== Sections ===== */
.section { padding: 80px 0; }
.section.alt { background: var(--bg2); }
.title { font-size: 2rem; font-weight: 900; }
.title::after { content: ""; display: block; width: 60px; height: 4px; background: var(--primary); border-radius: 4px; margin-top: 6px; }
.subtitle { color: var(--muted); margin: 10px 0 30px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.card h3 { margin-bottom: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }

/* ===== Filters ===== */
.filters { margin-bottom: 24px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { background: var(--card); border: 1px solid var(--line); color: var(--muted); padding: 6px 16px; border-radius: 999px; cursor: pointer; font-family: inherit; font-weight: 600; font-size: .95rem; }
.chip.active { background: var(--primary); color: #04130a; border-color: var(--primary); }
.filter-row { display: flex; gap: 10px; flex-wrap: wrap; }
input, select { font-family: inherit; font-size: 1rem; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; outline: none; }
input:focus, select:focus { border-color: var(--primary); }
.filter-row input { flex: 1; min-width: 200px; }

/* ===== Exercise cards ===== */
.ex-card { cursor: pointer; transition: .2s; position: relative; overflow: hidden; }
.ex-card:hover { transform: translateY(-4px); border-color: var(--primary); }
.ex-card .icon { font-size: 2rem; }
.ex-card { padding-top: 14px; }

/* ===== رسومات التمارين ===== */
.fig-wrap { position: relative; background: radial-gradient(circle at 50% 40%, rgba(34,197,94,.12), var(--bg) 70%); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; display: flex; align-items: center; justify-content: center; aspect-ratio: 5 / 4; overflow: hidden; }
.fig-wrap.big { margin-bottom: 14px; }
.fig { width: 100%; height: 100%; direction: ltr; }
.fig line, .fig path { stroke-linecap: round; stroke-linejoin: round; fill: none; }
.fig .limb line, .fig .torso { stroke: var(--text); stroke-width: 6; }
.fig .limb.back line { stroke: var(--muted); opacity: .55; }
.fig .head { fill: var(--text); }
.fig .floor { stroke: var(--line); stroke-width: 3; }
.fig .eq { stroke: #5b6b80; stroke-width: 4; fill: #3a4656; }
.fig .eq polyline { fill: none; }
.fig .plate { fill: none; stroke: var(--primary); stroke-width: 5; }
.fig .db { fill: var(--primary); }
.fig .cable { stroke: var(--amber); stroke-width: 2; fill: none; }
.cat-badge { position: absolute; top: 8px; inset-inline-start: 8px; font-size: 1.1rem; background: var(--card); border-radius: 8px; padding: 0 6px; }.ex-card h4 { font-size: 1.1rem; margin: 6px 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { font-size: .78rem; padding: 2px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.tag.lv-مبتدئ { color: var(--primary); border-color: rgba(34,197,94,.4); }
.tag.lv-متوسط { color: var(--amber); border-color: rgba(245,158,11,.4); }
.tag.lv-متقدم { color: var(--red); border-color: rgba(239,68,68,.4); }
.ex-sets { margin-top: 10px; font-weight: 700; color: var(--blue); }
.empty { grid-column: 1/-1; text-align: center; color: var(--muted); padding: 30px; }

/* ===== Plans ===== */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.plan h3 { margin-bottom: 4px; }
.plan .meta { color: var(--muted); font-size: .9rem; margin-bottom: 14px; }
.plan-day { border-top: 1px dashed var(--line); padding: 10px 0; }
.plan-day b { color: var(--primary); }
.plan-day ul { padding-inline-start: 20px; color: var(--muted); }

/* ===== Calculator ===== */
.calc { display: grid; grid-template-columns: 1fr 1.2fr; gap: 20px; align-items: start; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; margin-bottom: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.res-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.res-box { background: var(--bg); border-radius: 12px; padding: 14px; text-align: center; }
.res-box b { display: block; font-size: 1.6rem; font-weight: 900; }
.res-box span { color: var(--muted); font-size: .85rem; }
.res-box.hl b { color: var(--primary); }
.macro-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.macro { border-radius: 12px; padding: 14px; text-align: center; border: 1px solid var(--line); }
.macro b { font-size: 1.4rem; display: block; }
.macro.p b { color: var(--blue); } .macro.c b { color: var(--amber); } .macro.f b { color: var(--accent); }
.results .note { margin-top: 14px; color: var(--muted); font-size: .9rem; }

/* ===== Tracker ===== */
.tracker { display: grid; grid-template-columns: 1fr 1.4fr; gap: 20px; align-items: start; }
.tracker-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.progress-block { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; justify-content: center; }
.ring-wrap { position: relative; width: 150px; height: 150px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 12; }
.ring-bg { stroke: var(--bg); }
.ring-fg { stroke: var(--primary); stroke-linecap: round; stroke-dasharray: 326.7; stroke-dashoffset: 326.7; transition: stroke-dashoffset .5s, stroke .3s; }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-text b { font-size: 1.8rem; font-weight: 900; line-height: 1; }
.ring-text span { color: var(--muted); font-size: .85rem; }
.macro-bars { flex: 1; min-width: 180px; }
.mbar { margin-bottom: 10px; }
.mbar-top { display: flex; justify-content: space-between; font-size: .9rem; }
.mbar-track { height: 8px; background: var(--bg); border-radius: 8px; overflow: hidden; margin-top: 4px; }
.mbar-fill { height: 100%; border-radius: 8px; transition: width .5s; }
.water { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); flex-wrap: wrap; gap: 10px; }
.water-btns { display: flex; gap: 6px; }
.add-food { display: flex; gap: 8px; flex-wrap: wrap; }
.add-food #foodInput { flex: 1; min-width: 160px; }
.add-food #qtyInput { width: 80px; }
.add-food.custom input { flex: 1; min-width: 80px; }
.custom-food { margin: 10px 0 16px; }
.custom-food summary { cursor: pointer; color: var(--blue); margin-bottom: 10px; }
.meal { margin-top: 14px; }
.meal h4 { display: flex; justify-content: space-between; color: var(--primary); border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.meal-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); gap: 8px; }
.meal-item .info small { color: var(--muted); display: block; }
.del { background: none; border: 0; color: var(--red); cursor: pointer; font-size: 1.1rem; }

/* ===== Weight ===== */
.weight { display: grid; grid-template-columns: 1fr 1.6fr; gap: 20px; align-items: start; }
#wValue { flex: 1; min-width: 100px; }
.goal-row { display: flex; flex-direction: column; gap: 4px; font-weight: 600; margin: 16px 0; }
.w-stats .res-grid { margin-bottom: 8px; }
.w-stats .res-box b { font-size: 1.15rem; }
.w-goal { margin-top: 14px; }
.chart-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.chart-head h3 { margin: 0; }
.chips.small { margin: 0; }
.chips.small .chip { padding: 3px 12px; font-size: .85rem; }
.chart { position: relative; direction: ltr; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 12px; font-family: inherit; }
.chart .wline { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .wdot { fill: var(--primary); stroke: var(--card); stroke-width: 2; }
.chart .wdot.hover { stroke-width: 3; }
.chart .goal { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 5; }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart-empty { height: 280px; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); direction: rtl; border: 1px dashed var(--line); border-radius: 12px; padding: 20px; }
.tooltip { position: absolute; pointer-events: none; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; direction: rtl; display: flex; flex-direction: column; font-size: .85rem; white-space: nowrap; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.tooltip b { font-size: 1rem; }
.w-table { margin-top: 20px; }
.w-table summary { cursor: pointer; font-weight: 700; }
.tbl { width: 100%; border-collapse: collapse; margin-top: 12px; }
.tbl th, .tbl td { text-align: start; padding: 8px; border-bottom: 1px solid var(--line); }
.tbl th { color: var(--muted); font-weight: 600; font-size: .9rem; }

/* ===== Supplements ===== */
.legend { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 20px; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-inline-end: 4px; }
.dot.green { background: var(--primary); } .dot.amber { background: var(--amber); } .dot.red { background: var(--red); }
.sup { border-top: 4px solid var(--line); }
.sup.green { border-top-color: var(--primary); } .sup.amber { border-top-color: var(--amber); } .sup.red { border-top-color: var(--red); }
.sup h4 { font-size: 1.15rem; }
.sup .ev { font-size: .8rem; color: var(--muted); }
.sup p { margin-top: 8px; font-size: .93rem; }
.sup p b { color: var(--text); }
.sup .warn { color: var(--amber); }

/* ===== Health ===== */
.tips .tip .ic { font-size: 2rem; }
.tips .tip p { color: var(--muted); }
.bmi { margin-top: 24px; }
.bmi-out { margin-top: 14px; font-size: 1.1rem; font-weight: 700; }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; max-width: 520px; width: 100%; position: relative; max-height: 90vh; overflow-y: auto; }
.close { position: absolute; top: 14px; left: 14px; background: var(--bg); border: 0; color: var(--text); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; }
.modal-box ol { padding-inline-start: 22px; margin: 12px 0; }
.modal-box li { margin-bottom: 6px; }
.tipbox { background: rgba(34,197,94,.1); border-inline-start: 4px solid var(--primary); padding: 10px 14px; border-radius: 8px; }

.footer { padding: 30px 0; text-align: center; color: var(--muted); border-top: 1px solid var(--line); }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .hero-inner, .calc, .tracker, .weight { grid-template-columns: 1fr; }
  .menu-btn { display: block; }
  .nav nav { position: absolute; top: 64px; inset-inline: 0; background: var(--bg2); flex-direction: column; padding: 12px; display: none; border-bottom: 1px solid var(--line); }
  .nav nav.open { display: flex; }
}
@media (max-width: 520px) {
  .res-grid, .macro-row { grid-template-columns: 1fr 1fr; }
  .hero { padding: 50px 0; }
}
