/* رحلة ١٢٦ — design system */
:root {
  --bg: #0c0e0d;
  --surface: #151815;
  --surface-2: #1d211e;
  --surface-3: #252a26;
  --line: #2a2f2b;
  --ink: #edefe9;
  --muted: #8a938b;
  --dim: #5f6861;
  --accent: #c9f24d;
  --accent-ink: #101408;
  --warn: #ffb454;
  --danger: #ff6b5a;
  --radius: 20px;
  --shadow: 0 18px 40px rgba(0,0,0,.45);
  --font: -apple-system, "SF Arabic", "SF Pro Text", "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f1ea;
    --surface: #ffffff;
    --surface-2: #ece9e0;
    --surface-3: #e2ded1;
    --line: #ded9cb;
    --ink: #14170f;
    --muted: #6b7268;
    --dim: #9aa094;
    --shadow: 0 14px 34px rgba(30,30,20,.10);
  }
}

html[data-theme="light"] {
  --bg: #f3f1ea; --surface: #ffffff; --surface-2: #ece9e0; --surface-3: #e2ded1;
  --line: #ded9cb; --ink: #14170f; --muted: #6b7268; --dim: #9aa094;
  --shadow: 0 14px 34px rgba(30,30,20,.10);
}
html[data-theme="dark"] {
  --bg: #0c0e0d; --surface: #151815; --surface-2: #1d211e; --surface-3: #252a26;
  --line: #2a2f2b; --ink: #edefe9; --muted: #8a938b; --dim: #5f6861;
  --shadow: 0 18px 40px rgba(0,0,0,.45);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html { background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
h1, h2, h3, h4, p { margin: 0; }
b, strong, .num { font-variant-numeric: tabular-nums; }

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

/* ---------- top bar ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 18px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  width: 12px; height: 12px; border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent);
}
.brand-text { font-size: 15px; font-weight: 600; letter-spacing: -.2px; }
.brand-text b { color: var(--accent); font-weight: 700; }
.top-date { font-size: 12px; color: var(--muted); }

/* ---------- layout ---------- */
.view { padding: 4px 16px 24px; }
.view > * + * { margin-top: 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card.tight { padding: 13px 14px; }
.card.flush { padding: 0; overflow: hidden; }

.sec-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 20px 4px 2px;
}
.sec-head h2 { font-size: 13px; font-weight: 600; letter-spacing: .3px; color: var(--muted); }
.sec-head .link { font-size: 12px; color: var(--accent); font-weight: 600; }

.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.num { font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row.sb { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; min-width: 0; }

/* ---------- hero / weight ---------- */
.hero {
  display: flex; align-items: center; gap: 16px;
  background:
    radial-gradient(120% 120% at 100% 0%, color-mix(in srgb, var(--accent) 9%, transparent) 0%, transparent 55%),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.hero-num { display: flex; align-items: baseline; gap: 6px; }
.hero-num b { font-size: 40px; font-weight: 650; letter-spacing: -1.5px; line-height: 1; }
.hero-num span { font-size: 14px; color: var(--muted); }
.hero-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }
.delta { font-weight: 600; }
.delta.down { color: var(--accent); }
.delta.up { color: var(--warn); }

.dial { position: relative; width: 96px; height: 96px; flex: none; }
.dial svg { transform: rotate(-90deg); }
.dial .val {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 17px; font-weight: 650; letter-spacing: -.4px;
}
.dial .val small { display: block; font-size: 9px; color: var(--muted); font-weight: 500; text-align: center; letter-spacing: 0; }

/* ---------- macros ---------- */
.macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.macro .m-top { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-bottom: 5px; }
.macro .m-top b { color: var(--ink); font-weight: 600; }
.bar { height: 5px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width .4s ease; }
.bar.carb > i { background: #64b6f7; }
.bar.fat > i { background: var(--warn); }

/* ---------- quick actions ---------- */
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.q {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 12px 10px; text-align: center;
  transition: transform .12s ease, border-color .12s ease;
}
.q:active { transform: scale(.97); }
.q .qv { font-size: 18px; font-weight: 650; letter-spacing: -.5px; }
.q .ql { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.q .qv small { font-size: 10px; color: var(--muted); font-weight: 500; }

/* ---------- meals ---------- */
.meal { border-bottom: 1px solid var(--line); }
.meal:last-child { border-bottom: 0; }
.meal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 14px; width: 100%; text-align: right;
  cursor: pointer;
}
.meal-head .mname { font-weight: 600; font-size: 14px; }
.meal-head .mtime { font-size: 11px; color: var(--muted); }
.meal-head .mkcal { margin-inline-start: auto; font-size: 12px; color: var(--muted); }
.dotbtn { padding: 4px; margin: -4px; display: grid; place-items: center; }
.chev { color: var(--dim); font-size: 12px; transition: transform .2s ease; }
.chev.open { transform: rotate(180deg); }
.meal-head .ringdot {
  width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--line); flex: none;
}
.meal-head .ringdot.on { background: var(--accent); border-color: var(--accent); }
.meal-note { padding: 0 14px 10px; font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.meal-note.warn { color: var(--warn); }
.meal-body { padding: 0 14px 10px; }

.food-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-top: 1px dashed color-mix(in srgb, var(--line) 70%, transparent);
}
.food-row:first-child { border-top: 0; }
.food-row .fname { font-size: 13.5px; }
.food-row .fg { font-size: 11px; color: var(--muted); }
.food-row .fkcal { margin-inline-start: auto; font-size: 12px; color: var(--muted); }

.check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--line); flex: none;
  display: grid; place-items: center;
  transition: background .15s, border-color .15s;
}
.check.on { background: var(--accent); border-color: var(--accent); }
.check.on svg { opacity: 1; }
.check svg { width: 12px; height: 12px; opacity: 0; stroke: var(--accent-ink); }

.add-line {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 10px; margin-top: 4px;
  font-size: 12.5px; color: var(--accent); font-weight: 600;
  border: 1px dashed color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 12px;
}

/* ---------- inputs ---------- */
.inp, .sel, .ta {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 16px;
  outline: none;
  transition: border-color .15s;
}
.inp:focus, .ta:focus, .sel:focus { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.ta { resize: none; min-height: 72px; line-height: 1.5; }
.inp.sm { padding: 8px 10px; font-size: 15px; border-radius: 10px; }
.lbl { font-size: 11.5px; color: var(--muted); margin-bottom: 6px; display: block; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 650; font-size: 14px;
  padding: 12px 16px; border-radius: 13px;
  transition: transform .12s ease, opacity .12s;
}
.btn:active { transform: scale(.97); }
.btn.ghost { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.btn.block { width: 100%; }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); }

.chips { display: flex; gap: 8px; }
.chip {
  flex: 1; padding: 9px 4px; border-radius: 11px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--muted);
  transition: all .15s;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- training ---------- */
.daystrip { display: flex; gap: 7px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.daystrip::-webkit-scrollbar { display: none; }
.daypill {
  flex: none; padding: 7px 13px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 600; color: var(--muted);
}
.daypill.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.daypill.rest { opacity: .6; }

.ex {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0; border-top: 1px solid var(--line);
  width: 100%; text-align: right;
}
.ex:first-child { border-top: 0; }
.ex-name { font-size: 14px; font-weight: 550; }
.ex-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.ex-last { font-size: 10.5px; color: var(--accent); margin-top: 3px; font-variant-numeric: tabular-nums; }
.ex-go { color: var(--dim); font-size: 18px; }

.setrow { display: grid; grid-template-columns: 26px 1fr 1fr 44px; gap: 8px; align-items: center; margin-bottom: 8px; }
.setrow .sn { font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- charts ---------- */
.chart { width: 100%; height: 132px; display: block; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.chart .area { fill: color-mix(in srgb, var(--accent) 12%, transparent); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--accent); }
.chart .lab { fill: var(--muted); font-size: 9px; }

.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 13px 14px; }
.stat .sv { font-size: 22px; font-weight: 650; letter-spacing: -.6px; }
.stat .sl { font-size: 11px; color: var(--muted); margin-top: 2px; }

.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.heat i {
  aspect-ratio: 1; border-radius: 5px; background: var(--surface-3);
}
.heat i.l1 { background: color-mix(in srgb, var(--accent) 28%, var(--surface-3)); }
.heat i.l2 { background: color-mix(in srgb, var(--accent) 55%, var(--surface-3)); }
.heat i.l3 { background: var(--accent); }

/* ---------- list ---------- */
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 0; border-top: 1px solid var(--line);
  width: 100%; text-align: right;
}
.list-row:first-child { border-top: 0; }
.list-row .lr-name { font-size: 14px; }
.list-row .lr-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.list-row .lr-val { margin-inline-start: auto; font-size: 12px; color: var(--muted); }

/* ---------- tabbar ---------- */
.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  max-width: 560px; margin: 0 auto;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 2px; border-radius: 12px;
  color: var(--dim); font-size: 10px; font-weight: 550;
  transition: color .15s;
}
.tab svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tab.on { color: var(--accent); }

/* ---------- sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(2px); animation: fade .2s ease; }
.sheet {
  position: relative; width: 100%; max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--line); border-bottom: 0;
  border-radius: 24px 24px 0 0;
  padding: 8px 18px calc(20px + env(safe-area-inset-bottom));
  max-height: 90dvh; overflow-y: auto;
  box-shadow: var(--shadow);
  animation: up .26s cubic-bezier(.22,1,.36,1);
  direction: rtl;
}
.sheet-grab { width: 38px; height: 4px; border-radius: 99px; background: var(--surface-3); margin: 6px auto 14px; }
.sheet h3 { font-size: 17px; font-weight: 650; letter-spacing: -.3px; margin-bottom: 4px; }
.sheet .sub { font-size: 12px; color: var(--muted); margin-bottom: 14px; }

@keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet, .sheet-bg { animation: none; } }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  font-size: 13px; font-weight: 600;
  padding: 11px 18px; border-radius: 99px;
  z-index: 90; animation: fade .18s ease;
  max-width: 90vw; text-align: center;
}

/* ---------- misc ---------- */
.search { position: relative; }
.search svg { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; stroke: var(--dim); fill: none; stroke-width: 2; }
.search .inp { padding-inline-start: 38px; }

.empty { text-align: center; padding: 26px 10px; color: var(--dim); font-size: 13px; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 600; padding: 4px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.pill.on { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }

hr.sep { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

.seg { display: grid; grid-template-columns: repeat(3,1fr); gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 12px; }
.seg button { padding: 8px; font-size: 12px; font-weight: 600; border-radius: 9px; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.15); }

.range { display: flex; gap: 6px; }
