/* ───────── Design tokens ───────── */
/* الألوان متاخدة من اللوجو (Concept 1 — Vital Balance): أخضر غامق جدًا + نعناعي.
   في الفاتح، النعناعي الفاتح للوجو بس؛ العناصر التفاعلية بدرجة أغمق عشان التباين (WCAG AA). */
:root {
  /* الأسطح رمادي فحمي شبه محايد، والنعناعي للعناصر المهمة بس */
  --bg: #0B0E0D; --surface: #131716; --surface-2: #1A1F1E; --surface-3: #101413;
  --ink: #ECF1EF; --muted: #9AA6A2; --line: #222826; --track: #232A28;
  --primary: #2EE3B4; --on-primary: #06201A; --primary-soft: #12241F; --primary-line: #1E4A3E; --primary-text: #B4D3C9;
  --accent: #FF8F70; --glucose: #6BA3FF; --sleep: #9B8DF5; --sleep-dim: #3A3470;
  --warn: #F2B84B; --danger: #F06A6A; --good: #2EE3B4;
  --glow: rgba(46, 227, 180, .07);
  --radius: 24px; --radius-sm: 14px;
  --font: 'Readex Pro', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  /* اللوجو (partials/logo.njk) */
  --logo-ring-1: #63F5CB; --logo-ring-2: #20EBBD; --logo-ring-3: #0CB892;
  --logo-wave-1: #7AF7D3; --logo-wave-2: #22E3B3;
  --logo-leaf-1: #12A585; --logo-leaf-2: #3FE3B6;
  --logo-track: #176C56; --logo-vein: #0B6A55;
  color-scheme: dark;
}
:root[data-theme='light'] {
  --bg: #F6F4F0; --surface: #FFFFFF; --surface-2: #EDF4F1; --surface-3: #F1F5F2;
  --ink: #0C221D; --muted: #56706A; --line: #E3E1D9; --track: #E2ECE8;
  --primary: #0A7D63; --on-primary: #FFFFFF; --primary-soft: #E1F4EE; --primary-line: #B5E0D3; --primary-text: #24584C;
  --accent: #D9573A; --glucose: #2F6FE0; --sleep: #6A58E0; --sleep-dim: #CFC8F6;
  --warn: #B97A06; --danger: #D64545; --good: #0A7D63;
  --glow: rgba(34, 195, 152, .12);
  --logo-ring-1: #3AD3A6; --logo-ring-2: #17AE88; --logo-ring-3: #0A7D63;
  --logo-wave-1: #2CC79C; --logo-wave-2: #0B8468;
  --logo-leaf-1: #0B7F66; --logo-leaf-2: #22B48E;
  --logo-track: #8CC4B5; --logo-vein: #E8F3EE;
  color-scheme: light;
}

/* ───────── Base ───────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.6; min-height: 100dvh; }
h1, h2, h3, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: 8px; }

.lbl { font-size: 12px; color: var(--muted); }
.unit { font-size: 12px; color: var(--muted); font-weight: 400; }
.num { font-size: 28px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.strong { color: var(--ink); font-size: 15px; font-weight: 600; }
.h1 { font-size: 22px; font-weight: 600; line-height: 1.4; }
.h2 { font-size: 16px; font-weight: 600; }
.h3 { font-size: 15px; font-weight: 600; line-height: 1.5; }
.empty { font-size: 13px; color: var(--muted); margin-top: 8px; }
.only-desktop { display: none; }
.spacer { flex: 1; }

/* ───────── Shell ───────── */
.shell { display: flex; min-height: 100dvh; position: relative; }
.main {
  position: relative; flex: 1; min-width: 0; isolation: isolate;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(112px + env(safe-area-inset-bottom, 0px));
}
.main::before { /* وهج خلفي هادي */
  content: ''; position: absolute; z-index: -1; inset-inline: 0; top: -120px; height: 520px;
  background: radial-gradient(60% 60% at 50% 30%, var(--glow), transparent 70%); pointer-events: none;
}
.sidebar { display: none; }

/* ───────── Buttons & chips ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border: 0; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer; transition: transform .12s ease, filter .12s ease;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--primary); color: var(--on-primary); }
.btn--primary:not([disabled]):hover { filter: brightness(1.06); }
.btn--soft { background: var(--surface-2); color: var(--primary); border: 1px solid var(--line); padding: 0 16px; }
.btn--block { width: 100%; }

/* ───────── Loading ───────── */
/* الزرار بيحتفظ بمقاسه، والكلام بيستخبّى ومكانه سبينر بلون الزرار */
.btn { --spin: var(--ink); position: relative; }
.btn--primary { --spin: var(--on-primary); }
.btn--soft { --spin: var(--primary); }
.btn--danger { --spin: #fff; }
.btn.is-loading, .btn.is-loading[disabled] { color: transparent !important; opacity: 1; cursor: progress; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
  content: ''; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid color-mix(in srgb, var(--spin) 28%, transparent); border-top-color: var(--spin);
  animation: spin .7s linear infinite;
}
/* زراير الإرسال التانية في نفس الفورم: معطّلة من غير سبينر */
.btn[data-busy]:not(.is-loading) { opacity: .45; cursor: progress; }
/* مهمة اليوم: الدايرة نفسها بتلف */
.task.is-loading { cursor: progress; }
.task.is-loading .checkbox { border-color: var(--primary); border-top-color: transparent; background: transparent; animation: spin .7s linear infinite; }
.task.is-loading .checkbox svg { display: none; }
/* أي عنصر تاني (زي تسجيل الخروج) */
[aria-busy='true']:not(.btn):not(.task):not(form) { opacity: .6; cursor: progress; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn--desktop { display: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); cursor: pointer;
}
.icon-btn:hover { color: var(--ink); }
.chip { font-size: 13px; border-radius: 999px; padding: 6px 12px; background: var(--surface-2); color: var(--ink); }
.chip--up { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); font-weight: 600; }
.chip--down { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); font-weight: 600; }
.chip--muted { color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ───────── Top bar ───────── */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 4px 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.streak {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line);
  color: var(--accent); font-size: 14px; font-weight: 600;
}
.streak-long { display: none; }

/* ───────── Bento grid (موبايل: عمودين) ───────── */
.bento { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card--hero { grid-column: span 2; order: 1; background: transparent; border: 0; padding: 4px 0 0; }
.card--coach { grid-column: span 2; order: 2; background: var(--primary-soft); border-color: var(--primary-line); }
.card--glucose { order: 3; } .card--sleep { order: 4; }
.card--meals { grid-column: span 2; order: 5; }
.card--meds { grid-column: span 2; order: 6; }
.card--tasks { grid-column: span 2; order: 7; padding: 6px 16px; }
.big { margin-top: 10px; }
.delta { display: none; font-size: 13px; font-weight: 600; margin-inline-start: 10px; color: var(--muted); }
.delta.is-good { color: var(--good); } .delta.is-bad { color: var(--warn); }

/* Hero + الحلقة الأيضية */
.hero { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.ring { position: relative; width: 236px; height: 236px; }
.ring svg { width: 100%; height: 100%; display: block; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.ring-num { font-size: 64px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.ring-outer { animation: ring-outer 1.2s cubic-bezier(.2, .8, .2, 1) both; }
.ring-inner { animation: ring-inner 1.2s .15s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes ring-outer { from { stroke-dasharray: 0 var(--oc); } }
@keyframes ring-inner { from { stroke-dasharray: 0 var(--ic); } }
.hero-side { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.axes { width: 100%; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding: 0 6px; }
.axis { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; }
.axis .track { order: -1; width: 100%; max-width: 56px; height: 4px; }
.axis-val { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.track { display: block; height: 6px; border-radius: 6px; background: var(--track); overflow: hidden; }
.fill { display: block; height: 100%; border-radius: 6px; }

/* السكر والنوم */
.chart { display: block; width: 100%; height: 44px; margin-top: 10px; }
.chart .band { display: none; }
.bars { display: block; width: 100%; height: 44px; margin-top: 10px; }
.card--glucose .lbl:last-child, .card--sleep .lbl:last-child { margin-top: 6px; display: block; }

/* الأكل */
.meter { height: 10px; border-radius: 10px; background: var(--track); margin-top: 12px; overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 10px; background: linear-gradient(90deg, var(--primary), var(--glucose)); transition: width .6s ease; }
.macros { display: flex; justify-content: space-between; gap: 8px; margin-top: 14px; }
.macro { font-size: 15px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* الدوا */
.med { display: flex; align-items: center; gap: 12px; }
.med-icon { flex: none; width: 40px; height: 40px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--warn); display: grid; place-items: center; }
.med-icon--ok { color: var(--good); }
.med-info { flex: 1; min-width: 0; }
.med-name { font-size: 15px; font-weight: 600; }

/* المدرب */
.coach { display: flex; gap: 12px; align-items: flex-start; }
.coach-icon { flex: none; width: 40px; height: 40px; border-radius: var(--radius-sm); background: var(--primary); color: var(--on-primary); display: grid; place-items: center; }
.coach-body { font-size: 13px; line-height: 1.7; color: var(--primary-text); margin-top: 4px; }
.coach-note { font-size: 11px; color: var(--muted); margin-top: 8px; }

/* المهام */
.card--tasks .card-head { display: none; }
.tasklist li + li { border-top: 1px solid var(--line); }
.task {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 0;
  background: none; border: 0; cursor: pointer; text-align: start; font-size: 14px;
}
.checkbox { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted); display: grid; place-items: center; transition: background .2s, border-color .2s; color: var(--on-primary); }
.task.is-done .checkbox { background: var(--primary); border-color: var(--primary); }
.task.is-done .task-title { color: var(--muted); text-decoration: line-through; }
.htmx-request.task { opacity: .6; }

/* ───────── Bottom nav (موبايل) ───────── */
.bottomnav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 20; height: calc(84px + env(safe-area-inset-bottom, 0px));
  padding: 10px 8px env(safe-area-inset-bottom, 0px);
  display: flex; align-items: flex-start; justify-content: space-around;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.bn { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 60px; font-size: 11px; color: var(--muted); }
.bn.is-active { color: var(--primary); font-weight: 600; }
.bn-fab {
  width: 56px; height: 56px; margin-top: -14px; border-radius: 20px; display: grid; place-items: center;
  background: var(--primary); color: var(--on-primary); box-shadow: 0 8px 24px color-mix(in srgb, var(--primary) 35%, transparent);
}

/* ───────── Auth / misc pages ───────── */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(100%, 400px); display: flex; flex-direction: column; align-items: center; gap: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 24px; }
.field { width: 100%; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field input, .time-input, .field textarea { width: 100%; min-width: 0; min-height: 50px; padding: 0 14px; font: inherit; font-size: 16px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.field input:focus, .time-input:focus, .field textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
/* ───────── Toasts ───────── */
.toasts {
  position: fixed; z-index: 100; inset-inline: 16px; top: max(16px, calc(env(safe-area-inset-top) + 8px));
  max-width: 420px; margin-inline: auto;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
/* كارت هادي بلون محايد، واللون بتاع النوع في الأيقونة والشريط بس */
:root { --toast-bg: #1C2220; --toast-line: rgba(255, 255, 255, .07); --toast-shadow: 0 24px 50px -22px rgba(0, 0, 0, .8), 0 4px 14px rgba(0, 0, 0, .28); }
:root[data-theme='light'] { --toast-bg: #FFFFFF; --toast-line: #E7E3DA; --toast-shadow: 0 22px 44px -22px rgba(18, 32, 28, .32), 0 3px 10px rgba(18, 32, 28, .06); }
.toast {
  --tone: var(--primary); --glyph: var(--on-primary);
  position: relative; overflow: hidden; pointer-events: auto; touch-action: pan-y;
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  padding: 12px 12px 15px 14px; border-radius: 16px;
  background: var(--toast-bg); border: 1px solid var(--toast-line); box-shadow: var(--toast-shadow);
  animation: toast-in .5s cubic-bezier(.2, 1.15, .4, 1) both;
}
.toast--success { --tone: var(--good); --glyph: var(--on-primary); }
.toast--error { --tone: var(--danger); --glyph: #fff; }
.toast--warn { --tone: var(--warn); --glyph: #2A1D00; }
:root[data-theme='light'] .toast--warn { --glyph: #fff; }
.toast--info { --tone: var(--glucose); --glyph: #fff; }
.toast-icon {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; align-self: start;
  background: var(--tone); color: var(--glyph);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--tone) 14%, transparent);
}
.toast--success .toast-icon svg path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: toast-check .4s .2s ease-out forwards; }
.toast-body { min-width: 0; }
.toast-title { font-size: 14px; font-weight: 600; line-height: 1.5; color: var(--ink); }
.toast-text { font-size: 13px; line-height: 1.65; color: var(--muted); }
.toast-title + .toast-text { margin-top: 1px; }
.toast-close {
  width: 28px; height: 28px; border: 0; border-radius: 8px; display: grid; place-items: center; align-self: start;
  background: transparent; color: var(--muted); cursor: pointer; transition: background .15s, color .15s;
}
.toast-close:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }
.toast-close:focus-visible { outline: 2px solid var(--tone); outline-offset: 1px; }
.toast-bar {
  position: absolute; inset-inline: 0; bottom: 0; height: 3px; transform-origin: right;
  background: var(--tone); opacity: .9;
  animation: toast-life var(--life, 4s) linear forwards;
}
[dir='ltr'] .toast-bar { transform-origin: left; }
/* العدّاد بيقف لما المستخدم يقرا أو يسحب */
.toast:hover .toast-bar, .toast:focus-within .toast-bar, .toast.is-dragging .toast-bar { animation-play-state: paused; }
.toast.is-dragging { transition: none; cursor: grabbing; }
.toast.is-leaving { animation: toast-out .3s cubic-bezier(.4, 0, 1, 1) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-18px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-12px) scale(.94); } }
@keyframes toast-life { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes toast-check { to { stroke-dashoffset: 0; } }
@media (min-width: 1024px) { .toasts { top: 24px; } }

/* من غير JS: الإشعار بيفضل مكانه كتنبيه عادي */
.toast-seed {
  width: 100%; padding: 12px 14px; border-radius: 14px; font-size: 13.5px; line-height: 1.7; color: var(--ink);
  background: color-mix(in srgb, var(--primary) 10%, var(--surface)); border: 1px solid var(--primary-line);
}
.toast-seed--error { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.js .toast-seed { display: none; }

/* ───────── Password eye ───────── */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; }
/* المساحة محجوزة من الأول عشان مفيش نطّة لما الزرار يتضاف */
.js .field input[type='password'], .pw-wrap input { padding-inline-end: 52px; }
.pw-eye {
  position: absolute; inset-block: 0; inset-inline-end: 4px; margin-block: auto; width: 44px; height: 44px;
  display: grid; place-items: center; border: 0; border-radius: 11px; background: transparent; color: var(--muted); cursor: pointer;
  transition: color .15s, background-color .15s;
}
.pw-eye:hover { color: var(--ink); }
.pw-eye:focus-visible { outline: 2px solid var(--primary); outline-offset: -4px; }
.pw-eye[aria-pressed='true'] { color: var(--primary); }

/* ───────── Select (Tom Select) بألوان الهوية ───────── */
.ts-wrapper { width: 100%; position: relative; }
.ts-wrapper .ts-control, .ts-wrapper.single .ts-control, .ts-wrapper.single.input-active .ts-control {
  display: flex; align-items: center; min-height: 50px; padding-block: 0; padding-inline: 14px 40px; cursor: pointer;
  font: inherit; font-size: 16px; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: none;
  transition: border-color .18s, background-color .18s, box-shadow .18s;
}
.ts-wrapper .ts-control > input { color: var(--ink); font: inherit; font-size: 16px; }
.ts-wrapper .ts-control .item { color: var(--ink); }
/* سهم القايمة في نهاية السطر (شمال في RTL، يمين في LTR) */
.ts-wrapper.single .ts-control::after {
  content: ''; position: absolute; top: 50%; left: auto; right: auto; inset-inline-end: 18px; width: 8px; height: 8px; margin-top: -6px;
  border: solid var(--muted); border-width: 0 0 2px 2px; transform: rotate(-45deg); transition: transform .2s ease;
}
.ts-wrapper.single.dropdown-active .ts-control::after { transform: rotate(135deg); margin-top: -2px; }
.ts-wrapper.focus .ts-control { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
.ts-dropdown {
  margin-top: 6px; padding: 6px; z-index: 60; color: var(--ink); background: var(--toast-bg);
  border: 1px solid var(--toast-line); border-radius: 16px; box-shadow: var(--toast-shadow);
  animation: pop-in .16s ease-out;
}
.ts-dropdown .ts-dropdown-content { max-height: 280px; }
.ts-dropdown .option {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 46px; padding: 0 12px; border-radius: 10px; font-size: 15px; cursor: pointer;
}
.ts-dropdown .active { background: var(--surface-2); color: var(--ink); }
.ts-dropdown .option.selected { color: var(--primary); font-weight: 600; }
.ts-dropdown .option.selected::after {
  content: ''; width: 10px; height: 5px; margin-top: -3px; border: solid var(--primary); border-width: 0 0 2px 2px; transform: rotate(-45deg);
}
.ts-dropdown .no-results { padding: 12px; color: var(--muted); font-size: 14px; }
.is-invalid .ts-control { border-color: var(--danger) !important; background: color-mix(in srgb, var(--danger) 5%, var(--bg)) !important; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ───────── التقويم (Air Datepicker) بألوان الهوية ───────── */
.date-input { cursor: pointer; caret-color: transparent; }
.field:has(.date-input) { position: relative; }
.air-datepicker {
  --adp-font-family: var(--font);
  --adp-font-size: 14px;
  --adp-width: 300px;
  --adp-padding: 8px;
  --adp-z-index: 120;
  --adp-background-color: var(--toast-bg);
  --adp-background-color-hover: var(--surface-2);
  --adp-background-color-active: var(--primary-soft);
  --adp-color: var(--ink);
  --adp-color-secondary: var(--muted);
  --adp-accent-color: var(--primary);
  --adp-color-current-date: var(--primary);
  --adp-color-other-month: color-mix(in srgb, var(--muted) 40%, transparent);
  --adp-color-other-month-hover: var(--muted);
  --adp-color-disabled: color-mix(in srgb, var(--muted) 35%, transparent);
  --adp-border-color: var(--toast-line);
  --adp-border-color-inner: var(--line);
  --adp-border-radius: 20px;
  --adp-cell-border-radius: 12px;
  --adp-cell-background-color-hover: var(--surface-2);
  --adp-cell-background-color-selected: var(--primary);
  --adp-cell-background-color-selected-hover: var(--primary);
  --adp-day-name-color: var(--muted);
  --adp-nav-arrow-color: var(--ink);
  --adp-nav-color-secondary: var(--muted);
  --adp-nav-height: 40px;
  --adp-nav-action-size: 40px;
  --adp-day-cell-height: 38px;
  --adp-month-cell-height: 50px;
  --adp-year-cell-height: 54px;
  --adp-btn-color: var(--primary);
  --adp-mobile-font-size: 16px;
  --adp-mobile-nav-height: 48px;
  --adp-mobile-day-cell-height: 44px;
  --adp-mobile-month-cell-height: 58px;
  --adp-mobile-year-cell-height: 62px;
  box-shadow: var(--toast-shadow);
}
.air-datepicker-nav { border-bottom: 0; }
.air-datepicker-nav--title { font-size: 15px; font-weight: 600; border-radius: 10px; padding: 0 12px; }
.air-datepicker-nav--title i { color: var(--muted); margin-left: 0; margin-inline-start: .35em; }
.air-datepicker-nav--action { border-radius: 12px; color: var(--ink); }
.air-datepicker-nav--action path { stroke: currentColor; }
.air-datepicker-body--day-name { font-size: 12px; font-weight: 600; text-transform: none; }
.air-datepicker-cell { font-variant-numeric: tabular-nums; transition: background-color .12s, color .12s; }
.air-datepicker-cell.-current-:not(.-selected-) { font-weight: 700; box-shadow: inset 0 0 0 1.5px var(--primary-line); }
.air-datepicker-cell.-selected-, .air-datepicker-cell.-selected-.-current-, .air-datepicker-cell.-selected-.-focus- {
  color: var(--on-primary); font-weight: 700; background: var(--primary);
}
/* السهم الصغير ناحية الحقل: لونه ثابت أبيض في المكتبة */
.air-datepicker--pointer::after { background: var(--adp-background-color); border-color: var(--adp-border-color); }
.air-datepicker-overlay { --adp-overlay-background-color: rgba(3, 8, 6, .55); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }

/* الموبايل: التقويم بيطلع من تحت زي تطبيقات الموبايل (bottom sheet) */
.air-datepicker.-is-mobile- {
  top: auto !important; bottom: 0 !important; left: 0 !important; right: 0 !important;
  width: auto; max-width: 520px; margin-inline: auto; box-sizing: border-box;
  padding: 22px 8px calc(12px + env(safe-area-inset-bottom, 0px));
  border-radius: 26px 26px 0 0; border: 0;
  /* مقبض السحب الصغير فوق */
  --handle: color-mix(in srgb, var(--muted) 45%, transparent);
  background-image: linear-gradient(var(--handle), var(--handle)); background-size: 40px 4px; background-position: center 9px; background-repeat: no-repeat;
}
.air-datepicker.-is-mobile-:not(.-custom-position-) { transform: translateY(100%); transition: transform .34s cubic-bezier(.2, .9, .3, 1), opacity .2s; }
.air-datepicker.-is-mobile-.-active-:not(.-custom-position-) { transform: none; }

/* ───────── Validation ───────── */
.field-msg { display: flex; align-items: center; gap: 6px; font-size: 12.5px; line-height: 1.5; color: var(--danger); animation: msg-in .22s ease-out; }
.field-msg[hidden] { display: none; }
.field-msg svg { flex: none; }
.group > .field-msg { margin-top: 8px; }
.check + .field-msg { margin-top: -8px; padding-inline-start: 4px; }
.field input, .field select, .opt span, .check { transition: border-color .18s, background-color .18s, box-shadow .18s; }
.is-invalid input:not([type='radio']):not([type='checkbox']), .is-invalid select {
  border-color: var(--danger); background: color-mix(in srgb, var(--danger) 5%, var(--bg));
}
.is-invalid input:focus, .is-invalid select:focus { outline-color: var(--danger); box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 16%, transparent); }
.group.is-invalid legend { color: var(--danger); }
.group.is-invalid .opt span { border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }
.check.is-invalid { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 6%, var(--bg)); }
.shake { animation: shake .38s cubic-bezier(.36, .07, .19, .97); }
@keyframes msg-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
@media (prefers-reduced-motion: reduce) {
  .field-msg, .shake, .toast, .toast.is-leaving, .toast--success .toast-icon svg path { animation: none; }
  .toast--success .toast-icon svg path { stroke-dashoffset: 0; }
}
.auth-grow { display: none; }
.auth { position: relative; }
.auth-top { position: absolute; z-index: 2; top: calc(env(safe-area-inset-top, 0px) + 14px); inset-inline-end: 16px; }
.flow-head-end { display: flex; align-items: center; gap: 10px; }
.auth-top .lang-switch button, .flow-head .lang-switch button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 12px; border-radius: 999px;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); cursor: pointer;
  transition: border-color .15s, color .15s;
}
.auth-top .lang-switch button:hover, .flow-head .lang-switch button:hover { border-color: var(--primary-line); color: var(--primary); }
.auth-top .lang-switch svg, .flow-head .lang-switch svg { width: 16px; height: 16px; }
.auth-sub { margin-top: 6px; font-size: 14px; line-height: 1.7; color: var(--muted); }
.auth-head { text-align: center; }
.alt { font-size: 13px; color: var(--muted); } .alt a { color: var(--primary); font-weight: 600; }
.center-msg { min-height: 60dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; }

/* ───────── Desktop ≥ 1024 ───────── */
@media (min-width: 1024px) {
  .only-desktop { display: inline; }
  .btn--desktop { display: inline-flex; }
  .bottomnav { display: none; }
  .main { padding: 28px 36px 40px; }
  .h1 { font-size: 28px; }
  .streak-long { display: inline; } .streak-short { display: none; }
  .streak { padding: 0 16px; min-height: 44px; }

  .sidebar {
    display: flex; flex-direction: column; gap: 6px; flex: none; width: 248px; padding: 28px 18px;
    position: sticky; top: 0; height: 100dvh; background: var(--surface-3); border-inline-end: 1px solid var(--line);
  }
  .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; font-size: 19px; font-weight: 700; }
  .sidenav { display: flex; flex-direction: column; gap: 4px; }
  .nav-link {
    display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 14px; border-radius: var(--radius-sm);
    color: var(--muted); font-size: 15px; background: none; border: 0; cursor: pointer; width: 100%; text-align: start;
  }
  .nav-link:hover { background: var(--surface-2); color: var(--ink); }
  .nav-link.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
  .card--note { padding: 16px; background: var(--primary-soft); border-color: var(--primary-line); display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
  .note-text { font-size: 13px; color: var(--primary-text); line-height: 1.7; }
  /* القايمة أطول مع الصفحات الجديدة: تتقلّص على الشاشات القصيرة وتتسكرول لو لسه مش كفاية */
  .sidebar { overflow-y: auto; scrollbar-width: thin; }
  @media (max-height: 900px) {
    .sidebar { padding-block: 18px; gap: 4px; }
    .brand { padding-bottom: 12px; }
    .nav-link { min-height: 40px; }
    .card--note .note-text { display: none; }
  }
  @media (max-height: 800px) { .nav-link { min-height: 38px; } .sidebar .spacer, .sidebar .card--note { display: none; } }

  .bento { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 18px; margin-top: 24px; }
  .card { padding: 22px; }
  .card--hero, .card--coach, .card--glucose, .card--sleep, .card--meals, .card--meds, .card--tasks { order: 0; }
  .card--hero { grid-column: span 5; background: var(--surface); border: 1px solid var(--line); padding: 22px; }
  .card--glucose { grid-column: span 7; }
  .card--sleep { grid-column: span 3; }
  .card--meals { grid-column: span 5; }
  .card--meds { grid-column: span 4; }
  .card--coach { grid-column: span 6; }
  .card--tasks { grid-column: span 6; padding: 12px 22px; }
  .card--tasks .card-head { display: flex; padding: 8px 0; }
  .num { font-size: 34px; }

  .hero { flex-direction: row; gap: 24px; align-items: center; }
  .ring { width: 200px; height: 200px; flex: none; }
  .ring-num { font-size: 54px; }
  .hero-side { align-items: stretch; gap: 14px; flex: 1; min-width: 0; }
  .chips { justify-content: flex-start; }
  .axes { grid-template-columns: 1fr; gap: 10px; padding: 0; }
  .axis { flex-direction: row; gap: 10px; text-align: start; }
  .axis .track { order: 0; flex: 1; max-width: none; }
  .axis-label { width: 40px; } .axis-val { width: 22px; font-size: 13px; }

  .delta { display: inline; }
  .chart { height: 170px; margin-top: 14px; }
  .chart .band { display: block; }
  .bars { height: 64px; margin-top: 14px; }
  .macro { font-size: 18px; }
  .med { flex-wrap: wrap; }
  .coach-body { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  /* السبينر معلومة مهمة (فيه حاجة شغالة)، فبيلف بس أبطأ */
  .btn.is-loading::after, .task.is-loading .checkbox { animation: spin 1.4s linear infinite !important; }
}

/* ───────── Onboarding flow ───────── */
.flow { min-height: 100dvh; max-width: 640px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top, 0px)) 16px 40px; }
.flow-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 4px 14px; }
.brand--flow { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.progress { height: 6px; border-radius: 6px; background: var(--track); overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--primary), var(--glucose)); transition: width .5s ease; }
.flow-card { margin-top: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 20px; animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.sub { margin: 4px 0 18px; font-size: 14px; line-height: 1.7; }
.flow-form { display: flex; flex-direction: column; gap: 16px; }
.flow-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.flow-actions .btn--primary { flex: 1; }
.btn--ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn--danger { background: var(--danger); color: #fff; }
.hint { font-size: 13px; color: var(--muted); line-height: 1.7; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.group { border: 0; padding: 0; margin: 0; min-width: 0; }
.group legend { font-size: 13px; color: var(--muted); padding: 0; margin-bottom: 8px; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opts--nums .opt span { min-width: 44px; justify-content: center; }
.opt { position: relative; }
.opt input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.opt span { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 14px; transition: background .15s, border-color .15s, color .15s; }
.opt:hover span { border-color: var(--primary-line); }
.opt input:checked + span { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.opt input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.rowfields { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 10px; }
.field select { width: 100%; min-width: 0; min-height: 50px; padding: 0 12px; font: inherit; font-size: 16px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.rowfields:has(select) { grid-template-columns: 120px minmax(0, 1fr); }
.field input[type='date'] { text-align: start; }

.points { display: flex; flex-direction: column; gap: 10px; padding-inline-start: 18px; list-style: disc; font-size: 14px; line-height: 1.8; color: var(--primary-text); }
.points b { color: var(--ink); }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; line-height: 1.7; cursor: pointer; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); }
.check input { flex: none; width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--primary); }
.check--optional { border-style: dashed; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 8px; background: var(--surface-2); border-radius: var(--radius-sm); text-align: center; }
.stat b { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.flags { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.flag { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.flag--attention { background: color-mix(in srgb, var(--warn) 12%, transparent); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.flag-icon { flex: none; color: var(--primary); margin-top: 2px; } .flag--attention .flag-icon { color: var(--warn); }
.flag-title { font-size: 14px; font-weight: 600; } .flag-text { font-size: 13px; color: var(--muted); line-height: 1.7; margin-top: 2px; }
.disclaimer { font-size: 12px; color: var(--muted); line-height: 1.7; }


/* ───────── Profile ───────── */
.profile-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 16px; }
.pcard { display: flex; flex-direction: column; gap: 12px; }
.edit { font-size: 13px; color: var(--primary); font-weight: 600; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 500; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { padding: 6px 12px; border-radius: 999px; background: var(--surface-2); font-size: 13px; }
.plain { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.inline-form { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; }
/* صفوف قابلة للفتح زي إعدادات التطبيقات: سهم بيلف بدل علامة المتصفح */
.fold { border-top: 1px solid var(--line); }
.fold summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 54px;
  cursor: pointer; list-style: none; font-size: 15px; font-weight: 600; -webkit-user-select: none; user-select: none;
}
.fold summary::-webkit-details-marker { display: none; }
.fold summary::after {
  content: ''; flex: none; width: 9px; height: 9px; margin-inline-end: 4px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); transition: transform .2s ease;
}
.fold[open] summary::after { transform: rotate(225deg); }
.fold[open] { padding-bottom: 8px; }
.fold--danger summary { color: var(--danger); }
.fold--danger summary::after { border-color: var(--danger); }
.btn--logout { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); min-height: 52px; }
.btn--logout { --spin: var(--danger); }
.fold .stack { margin-top: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; max-width: 420px; }

/* ───────── إحساس تطبيق الموبايل ───────── */
html { background: var(--bg); -webkit-tap-highlight-color: transparent; }
a, button, summary, label, input, select { touch-action: manipulation; }
.btn, .bn, .bn-fab, .icon-btn, .task, .opt span, .nav-link, .streak { -webkit-user-select: none; user-select: none; }
/* ضغطة محسوسة زي التطبيقات */
.bn, .bn-fab, .icon-btn, .task, .opt span, .pw-eye, .toast-close { transition: transform .12s ease, background-color .15s, color .15s, border-color .15s; }
.bn:active, .icon-btn:active, .pw-eye:active, .toast-close:active { transform: scale(.92); }
.bn-fab:active { transform: scale(.94); }
.task:active { transform: scale(.985); }
.opt:active span { transform: scale(.96); }
/* الـ hover بيعلّق على اللمس، فبنلغيه هناك */
@media (hover: none) {
  .opt:hover span { border-color: var(--line); }
  .opt input:checked + span { border-color: var(--primary); }
  .icon-btn:hover, .pw-eye:hover { color: var(--muted); }
}
/* ───────── أزرار وشرايح صغيرة ───────── */
.btn--sm { min-height: 38px; padding: 0 14px; font-size: 13px; margin-top: 10px; }
.icon-btn--sm { width: 36px; height: 36px; }
.icon-btn--danger:hover, .icon-btn--danger.is-armed { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.is-armed { color: var(--danger) !important; }
a.chip { display: inline-flex; align-items: center; min-height: 34px; }
.chip.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 600; box-shadow: inset 0 0 0 1px var(--primary-line); }
.chip--xs { font-size: 11px; padding: 3px 9px; }
button.chip { border: 0; font: inherit; font-size: 13px; cursor: pointer; min-height: 36px; padding: 0 14px; }
button.chip:active { transform: scale(.95); }

/* ───────── شيت التسجيل (<dialog>) ───────── */
.sheet { padding: 0; border: 0; background: transparent; color: var(--ink); max-width: none; max-height: none; overflow: visible; }
.sheet::backdrop { background: rgba(3, 6, 5, .62); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.sheet-panel {
  position: relative; width: min(480px, calc(100vw - 32px)); max-height: min(86dvh, 760px); overflow-y: auto; overscroll-behavior: contain;
  padding: 22px 20px 20px; border-radius: 24px; background: var(--toast-bg); border: 1px solid var(--toast-line); box-shadow: var(--toast-shadow);
}
.sheet[open] .sheet-panel { animation: sheet-in .28s cubic-bezier(.2, .9, .3, 1); }
.sheet-handle { display: none; }
.sheet-close {
  position: absolute; top: 14px; inset-inline-end: 14px; width: 36px; height: 36px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: var(--surface-2); color: var(--muted); cursor: pointer; z-index: 2;
}
.sheet-close:hover { color: var(--ink); }
.sheet-head { display: flex; align-items: center; gap: 12px; padding-inline-end: 44px; margin-bottom: 18px; }
.sheet-head .lbl { margin-top: 2px; }
.sheet-back { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); color: var(--ink); flex: none; }
[dir='ltr'] .sheet-back svg { transform: scaleX(-1); }
.sheet-loading { height: 180px; display: grid; place-items: center; }
.sheet-loading::after { content: ''; width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--track); border-top-color: var(--primary); animation: spin .7s linear infinite; }
.sheet-page { max-width: 520px; margin: 8px auto 0; }
.sheet-panel--page { width: 100%; max-height: none; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(14px) scale(.98); } }

/* الأنواع */
.log-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.log-tile {
  --tone: var(--primary);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 108px; padding: 14px 8px;
  border-radius: 18px; background: var(--surface-2); border: 1px solid var(--line); text-align: center; font-size: 14px; font-weight: 600;
  transition: transform .12s ease, border-color .15s;
}
.log-tile:hover { border-color: color-mix(in srgb, var(--tone) 45%, var(--line)); }
.log-tile:active { transform: scale(.96); }
.log-tile-icon {
  --tone: var(--primary);
  width: 46px; height: 46px; flex: none; border-radius: 15px; display: grid; place-items: center; color: var(--tone);
  background: color-mix(in srgb, var(--tone) 15%, transparent);
}
.log-tile .log-tile-icon { --tone: inherit; }

/* فورم القياس */
.log-form { display: flex; flex-direction: column; gap: 16px; }
.log-big .log-big-row { display: flex; align-items: center; gap: 10px; }
.log-big input { min-height: 72px; font-size: 34px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; letter-spacing: .5px; }
.log-big input::placeholder { color: color-mix(in srgb, var(--muted) 45%, transparent); }
.log-unit { flex: none; min-width: 64px; font-size: 15px; font-weight: 600; color: var(--muted); }
.log-bp { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; gap: 8px; }
.log-bp-sep { font-size: 34px; font-weight: 300; color: var(--muted); padding-bottom: 12px; }
.log-unit-hint { text-align: center; margin-top: -8px; }
.opts--seg { display: grid; grid-template-columns: 1fr 1fr; }
.opts--seg .opt span { width: 100%; justify-content: center; }
.opts--stack { display: grid; grid-template-columns: 1fr; }
.opts--stack .opt span { width: 100%; border-radius: var(--radius-sm); }
.quick-fill { display: flex; flex-wrap: wrap; gap: 8px; margin-top: -6px; }

/* بعد الحفظ */
.log-done { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding-top: 6px; }
.log-done-check {
  width: 68px; height: 68px; border-radius: 50%; display: grid; place-items: center; color: var(--on-primary); background: var(--primary);
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--primary) 16%, transparent); margin-bottom: 6px;
}
.log-done-check svg path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: toast-check .45s .1s ease-out forwards; }
.log-done-actions { width: 100%; display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.log-alert {
  --tone: var(--warn);
  width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 20px 16px; border-radius: 20px;
  background: color-mix(in srgb, var(--tone) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--tone) 40%, transparent);
}
.log-alert--urgent { --tone: var(--danger); }
.log-alert-icon { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; color: var(--tone); background: color-mix(in srgb, var(--tone) 16%, transparent); }
.log-alert-text { font-size: 14px; line-height: 1.8; color: var(--ink); }
.log-alert .btn--danger { min-height: 52px; font-size: 16px; }

/* ───────── صفحة صحتي ───────── */
.metric-tabs { display: flex; gap: 8px; overflow-x: auto; margin: 16px -16px 0; padding: 0 16px 4px; scrollbar-width: none; scroll-snap-type: x proximity; }
.metric-tabs::-webkit-scrollbar { display: none; }
.metric-tab {
  --tone: var(--primary);
  flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 14px; border-radius: 999px; scroll-snap-align: start;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap;
}
.metric-tab svg { color: var(--tone); }
.metric-tab.is-active { color: var(--ink); background: color-mix(in srgb, var(--tone) 14%, var(--surface)); border-color: color-mix(in srgb, var(--tone) 45%, var(--line)); }
.health-card { --tone: var(--primary); margin-top: 12px; display: flex; flex-direction: column; gap: 14px; }
.health-card .card-head { flex-wrap: wrap; }
.range-chips { display: flex; gap: 6px; }
.health-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.health-num { font-size: 28px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.health-chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart-legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.chart-legend .dot:not(:first-child) { margin-inline-start: 10px; }
.health-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 28px 0 12px; text-align: center; }
.health-empty .log-tile-icon { --tone: inherit; }
.entry-list { margin-top: 6px; }
.entry { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; }
.entry + .entry { border-top: 1px solid var(--line); }
.entry-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; min-width: 0; }
.entry-value { font-size: 18px; font-variant-numeric: tabular-nums; }
.entry-when { width: 100%; }
.entry-actions { display: flex; gap: 8px; flex: none; }
.htmx-swapping.entry { opacity: 0; transition: opacity .2s; }

/* الشيت على الموبايل: بيطلع من تحت */
@media (max-width: 1023px) {
  .sheet { margin: auto 0 0; width: 100%; }
  .sheet-panel {
    width: 100%; max-height: 92dvh; border-radius: 26px 26px 0 0; border-bottom: 0;
    padding: 26px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  }
  .sheet[open] .sheet-panel { animation: sheet-up .32s cubic-bezier(.2, .9, .3, 1); }
  .sheet-handle { display: block; position: absolute; top: 9px; inset-inline: 0; margin: auto; width: 40px; height: 4px; border-radius: 4px; background: color-mix(in srgb, var(--muted) 45%, transparent); }
  .sheet-page { margin-top: 0; }
  .sheet-panel--page { border-radius: 24px; border-bottom: 1px solid var(--toast-line); }
  .log-grid { gap: 8px; }
  .log-tile { min-height: 100px; }
}
@keyframes sheet-up { from { transform: translateY(100%); } }

@media (min-width: 1024px) {
  .health-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .metric-tabs { margin-inline: 0; padding-inline: 0; flex-wrap: wrap; }
}

.only-mobile { display: block; }

@media (max-width: 1023px) {
  /* الدخول والتسجيل: شاشة كاملة، المحتوى فوق والزرار تحت قريب من الإبهام */
  .auth { place-items: stretch; padding: calc(env(safe-area-inset-top, 0px) + 32px) 20px calc(env(safe-area-inset-bottom, 0px) + 20px); }
  .auth-card { width: 100%; max-width: 440px; margin-inline: auto; background: transparent; border: 0; border-radius: 0; padding: 0; align-items: stretch; gap: 18px; }
  .auth-card > svg { align-self: flex-start; width: 48px; height: 48px; }
  .auth-card .h1 { font-size: 28px; }
  .auth-head { text-align: start; }
  .auth-grow { display: block; flex: 1; min-height: 12px; }
  .alt { text-align: center; padding-top: 2px; }

  /* الـ Onboarding: هيدر ثابت فوق، وزراير التنقّل ثابتة تحت */
  /* الصفحة بطول الشاشة، فلو المحتوى قصير الزراير برضه بتنزل لتحت */
  .flow { padding: 0 16px; display: flex; flex-direction: column; }
  .flow-card { flex: 1; display: flex; flex-direction: column; }
  .flow-form { flex: 1; }
  .flow-actions { margin-top: auto !important; }
  .flow-top {
    position: sticky; top: 0; z-index: 10; margin-inline: -16px; padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
    background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  }
  .flow-head { padding: 0 0 12px; }
  .flow-card { margin-top: 4px; background: transparent; border: 0; border-radius: 0; padding: 12px 0 0; }
  .flow-card .h1 { font-size: 26px; }
  .flow-actions {
    position: sticky; bottom: 0; z-index: 10; margin: 12px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--bg) 90%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
  }

  /* أهداف لمس أكبر */
  .btn--block, .flow-actions .btn { min-height: 54px; font-size: 16px; border-radius: 16px; }
  .opt span { min-height: 46px; }
  .check { padding: 14px; }
  .profile-grid > .only-mobile { margin-top: 4px; }
}

@media (min-width: 1024px) {
  .only-mobile { display: none; }
  .flow { padding-top: 40px; }
  .flow-card { padding: 32px 36px; }
  .profile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 24px; }
  .pcard--wide { grid-column: span 2; }
}

/* ───── التنقّل زي التطبيق: شريط تقدّم فوق أثناء تحميل الصفحة (hx-boost) ───── */
.nav-progress {
  position: fixed; inset-block-start: 0; inset-inline: 0; z-index: 1000;
  height: 3px; pointer-events: none; opacity: 0;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  background-size: 40% 100%; background-repeat: no-repeat;
  transition: opacity .2s ease;
}
.is-navigating .nav-progress { opacity: 1; animation: nav-progress 1s ease-in-out infinite; }
.is-navigating .main { opacity: .6; transition: opacity .2s ease .15s; }
@keyframes nav-progress { from { background-position: -40% 0; } to { background-position: 140% 0; } }
@media (prefers-reduced-motion: reduce) {
  .is-navigating .nav-progress { animation: none; background-size: 100% 100%; }
}

/* ───── كارت الإشعارات (ملفي): الحالة من push.js في data-state ───── */
.push-head { display: flex; gap: 14px; align-items: flex-start; }
.push-head .hint { margin-top: 4px; }
.push-ico {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px;
  background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary);
}
.push-status { margin-block: 14px 4px; font-weight: 600; }
.push-card[data-state="on"] .push-status { color: var(--primary); }
.push-card[data-state="denied"] .push-status, .push-card[data-state="ios"] .push-status { font-weight: 500; color: var(--muted); }
.push-devices { margin-block: 10px 14px; }
.push-card .actions-row { flex-wrap: wrap; }
.push-card [data-when] { display: none; }
.push-card[data-state="on"] [data-when="on"],
.push-card[data-state="off"] [data-when="off"],
.push-card[data-state="denied"] [data-when="denied"],
.push-card[data-state="unsupported"] [data-when="unsupported"],
.push-card[data-state="ios"] [data-when="ios"] { display: revert; }
.push-card[data-state="on"] .btn[data-when="on"],
.push-card[data-state="off"] .btn[data-when="off"] { display: inline-flex; }
.push-card[data-state="loading"] .push-status { min-height: 1.4em; }

/* ───────── الأدوية ───────── */
.meds-layout { display: grid; gap: 12px; margin-top: 16px; }
.meds-today { display: grid; gap: 12px; }
@media (min-width: 900px) {
  .meds-layout { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: start; }
  .meds-today { grid-row: span 2; }
}
.btn--sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.chip--xs { font-size: 12px; padding: 3px 9px; }

.dose-list, .med-list, .adh-rows, .med-alerts ul { list-style: none; margin: 0; padding: 0; }
.dose { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; align-items: center; padding: 12px 0; border-block-end: 1px solid var(--line); }
.dose:last-child { border-block-end: 0; }
.dose-time { font-weight: 700; font-size: 15px; min-inline-size: 64px; }
.dose-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dose-actions { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.meds-today .card { container-type: inline-size; }
@container (min-width: 520px) {
  .dose { grid-template-columns: auto minmax(0, 1fr) auto; }
  .dose-actions { grid-column: auto; }
}
.dose--taken .dose-info b, .dose--skipped .dose-info b { color: var(--muted); }
.dose--due .dose-time { color: var(--warn); }

.adh-overall { display: flex; align-items: baseline; gap: 10px; margin-block: 10px 6px; }
.adh-pct { font-size: 40px; line-height: 1; font-weight: 700; color: var(--primary); }
.adh-pct small { font-size: 18px; margin-inline-start: 2px; }
.adh-rows li { display: grid; grid-template-columns: minmax(0, 1fr) 2fr auto; gap: 10px; align-items: center; padding-block: 6px; }
.adh-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.adh-bar { block-size: 8px; border-radius: 999px; background: var(--track); overflow: hidden; }
.adh-bar i { display: block; block-size: 100%; border-radius: inherit; background: var(--primary); }

.med-item { padding-block: 14px; border-block-end: 1px solid var(--line); }
.med-item:last-child { border-block-end: 0; }
.med-item-head { display: flex; align-items: center; gap: 12px; }
.med-item-title { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.med-sched { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-block: 10px 0; font-size: 14px; }
.med-tip { display: flex; gap: 6px; align-items: flex-start; margin-block: 8px 0; font-size: 13px; color: var(--muted); }
.med-tip svg { flex: none; margin-top: 2px; color: var(--primary); }
.med-doctor { margin-top: 12px; }
.med-icon--lg { width: 56px; height: 56px; }
.meds-empty { display: grid; justify-items: center; gap: 14px; text-align: center; padding: 32px 20px; margin-top: 16px; }

.med-alerts { margin-top: 16px; border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); background: color-mix(in srgb, var(--warn) 7%, var(--surface)); }
.med-alerts-head { display: flex; align-items: center; gap: 10px; }
.med-alerts-ico { color: var(--warn); display: inline-flex; }
.med-alerts ul { display: grid; gap: 10px; margin-block: 12px; }
.med-alerts li { padding-inline-start: 14px; border-inline-start: 3px solid var(--warn); line-height: 1.6; }

.med-form-card { margin-top: 16px; }
.med-form { max-width: none; }
.adh-pct { font-variant-numeric: tabular-nums; }
/* لابتوب وأكبر: الفورم عمودين، والحقول الطويلة بعرض الكارت */
@media (min-width: 1024px) {
  .med-form-card { max-width: 920px; padding: 24px 28px; }
  .med-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 24px; align-items: start; }
  .med-form > .mf-full { grid-column: 1 / -1; }
  .med-custom { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .mf-submit { grid-column: 1 / -1; justify-self: start; width: auto; min-width: 260px; }
}
.med-custom { display: grid; gap: 12px; padding: 12px; border: 1px dashed var(--line); border-radius: 14px; }
.time-rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.time-input.is-hidden { display: none; }
.add-time { justify-self: start; margin-top: 8px; }
.med-stop { margin-top: 14px; }
.field textarea { padding: 12px 14px; min-height: 76px; resize: vertical; }
.time-input { color-scheme: light dark; }
.med-more { display: inline-block; color: var(--muted); text-decoration: none; }
.med-more:hover { color: var(--primary); }

/* منتقي الوقت: الساعة قبل الدقايق دايمًا (من غير ما الاتجاه يقلبهم) */
.air-datepicker-time--current { direction: ltr; unicode-bidi: isolate; }
.field textarea { resize: none; }

/* كارت الدوا في الرئيسية: لما يضيق (لابتوب) الزرار ينزل سطر لوحده بدل ما يزنق الاسم */
.card--meds { container-type: inline-size; }
.med-info { min-width: 0; flex: 1; }
@container (max-width: 400px) {
  .card--meds .med { flex-wrap: wrap; }
  .card--meds .med > .btn { flex: 1 0 100%; }
}

/* صحتي: القياسات عمودين على الشاشات الواسعة بدل صف طويل بعرض الصفحة */
@media (min-width: 1100px) {
  .entry-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }
  .entry-list > .entry { border-top: 1px solid var(--line); }
  .entry-list > .entry:nth-child(-n+2) { border-top: 0; }
}

/* ───────── لابتوب: الملف الطبي أقصر وأكتر تنظيمًا ───────── */
.priv-grid, .priv-col { display: contents; }
@media (min-width: 1024px) {
  /* الإعدادات: الحقول جنب بعض وزرار الحفظ تحتها */
  .settings-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px 16px; align-items: end; }
  .settings-form .btn { grid-column: 1 / -1; justify-self: start; min-width: 200px; }

  /* الإشعارات: الحالة والأزرار على جنب، والتفضيلات على الجنب التاني */
  .push-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: 'head head' 'status prefs' 'actions prefs' 'devices prefs'; column-gap: 28px; row-gap: 8px; align-content: start; }
  .push-card .push-head { grid-area: head; }
  .push-card .push-status { grid-area: status; margin-block: 8px 0; }
  .push-card .actions-row { grid-area: actions; align-self: start; }
  .push-card .push-devices { grid-area: devices; margin-block: 4px 0; }
  .push-card .push-prefs { grid-area: prefs; align-self: center; padding-inline-start: 28px; border-inline-start: 1px solid var(--line); }

  /* الخصوصية: اختيار الأبحاث والتصدير على جنب، وتغيير كلمة السر والحذف على الجنب التاني */
  .priv-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 28px; align-items: start; }
  .priv-col { display: flex; flex-direction: column; gap: 12px; }
  .priv-col .fold:first-child { border-top: 0; }
  .priv-grid .stack { max-width: none; }
}
/* شاشات أعرض من 1200: كروت الملف الطبي التلاتة جنب بعض بدل اتنين، فالصفحة أقصر */
@media (min-width: 1200px) {
  .profile-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pcard--wide { grid-column: span 3; }
}

/* ───────── التحاليل ───────── */
.lab-disclaimer { margin: 12px 4px 0; }
.lab-group { margin-top: 22px; }
.lab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 10px; }
.lab-card { display: flex; flex-direction: column; gap: 4px; color: inherit; text-decoration: none; transition: border-color .15s ease, transform .15s ease; }
.lab-card:hover { border-color: var(--primary-line); }
.lab-card:active { transform: scale(.99); }
.lab-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.lab-name { font-size: 15px; }
.lab-value { margin: 6px 0 0; font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.lab-value .unit { font-size: 13px; font-weight: 500; color: var(--muted); }
.lab-value--none { font-size: 16px; font-weight: 500; color: var(--muted); }
.lab-range { margin-top: 6px; }
.lab-flag { white-space: nowrap; }
.lab-flag--normal { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); font-weight: 600; }
.lab-flag--high, .lab-flag--low { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); font-weight: 600; }
.lab-card--high, .lab-card--low { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.lab-due { color: var(--warn); font-weight: 600; }
.lab-detail { margin-top: 16px; }
.lab-stats { display: flex; flex-wrap: wrap; gap: 20px 40px; margin-bottom: 8px; }
.lab-chart { margin-top: 10px; }

/* ───────── التغذية ───────── */
.day-nav { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }
.day-label { min-width: 160px; text-align: center; }
[dir='rtl'] .day-next svg, [dir='ltr'] .day-nav > a:first-child svg { transform: scaleX(-1); }
.day-next.is-off { opacity: .3; pointer-events: none; }
.food-layout { display: grid; gap: 12px; margin-top: 14px; }
.food-meals { display: grid; gap: 12px; align-content: start; }
.food-kcal { margin: 8px 0 6px; font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.food-kcal .unit { font-size: 14px; font-weight: 500; }
.food-totals .macros { margin-top: 14px; }
.meter--over > span { background: var(--warn); }
.meter--thin { height: 5px; margin-top: 6px; }
.food-name { font-size: 15px; }
.food-add { align-self: flex-start; margin-top: 8px; }
.food-meal { display: flex; flex-direction: column; }
.food-empty { text-align: center; padding: 6px 0; }
.swap { margin-top: 12px; }
.swap-for { margin: 0 0 6px; font-weight: 600; }
.swap-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.swap-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.food-disclaimer { margin: 12px 4px 0; }
@media (min-width: 1024px) {
  .food-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); align-items: start; gap: 18px; margin-top: 18px; }
  .food-totals { position: sticky; top: 16px; }
  .food-swaps { grid-column: 1; }
  .food-meals { grid-column: 2; grid-row: 1 / span 2; }
  .food-empty { grid-column: 1 / -1; }
}

/* ───────── البرنامج والمدرب والنوم ───────── */
.program-layout, .coach-layout, .sleep-layout { display: grid; gap: 12px; margin-top: 16px; }
.program-main { display: grid; gap: 12px; align-content: start; }
.program-intro { display: grid; justify-items: start; gap: 12px; margin-top: 16px; max-width: 640px; }
.program-points { margin: 0; padding-inline-start: 20px; display: grid; gap: 6px; }
.program-title { margin: 4px 0 8px; font-size: 24px; }
.program-lesson { line-height: 1.8; margin: 0 0 8px; }
.program-win { margin: 12px 0 0; color: var(--good); font-weight: 600; }
.task-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.task { width: 100%; display: flex; align-items: center; gap: 12px; text-align: start; padding: 12px 14px; font: inherit; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; transition: border-color .15s, background .15s; }
.task:active { transform: scale(.99); }
.task-box { flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line); color: transparent; transition: all .15s; }
.task.is-done { border-color: var(--primary-line); background: var(--primary-soft); }
.task.is-done .task-box { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.task.is-done .task-text { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.weeks { list-style: none; margin: 10px 0 14px; padding: 0; display: grid; gap: 6px; }
.wk { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; color: var(--muted); }
.wk-n { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); font-size: 13px; font-weight: 700; }
.wk--current { background: var(--primary-soft); color: var(--ink); }
.wk--current .wk-n { background: var(--primary); color: var(--on-primary); }
.wk--past .wk-n { background: color-mix(in srgb, var(--good) 22%, transparent); color: var(--good); }
.wk-pct { font-size: 12px; font-variant-numeric: tabular-nums; }

.insights { list-style: none; margin: 10px 0 8px; padding: 0; display: grid; gap: 10px; }
.insight { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.insight p { margin: 0; line-height: 1.75; }
.insight-ico { flex: none; display: inline-flex; margin-top: 3px; color: var(--muted); }
.insight--good .insight-ico { color: var(--good); }
.insight--attention { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); background: color-mix(in srgb, var(--warn) 7%, var(--surface-2)); }
.insight--attention .insight-ico { color: var(--warn); }
.coach-side { display: grid; gap: 12px; align-content: start; }
.coach-link { display: flex; align-items: center; gap: 14px; color: inherit; text-decoration: none; }
.coach-link:hover { border-color: var(--primary-line); }
.coach-link > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.coach-link-ico { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); }

.story-range { margin: 8px 4px 0; }
.stories { margin-top: 12px; display: grid; gap: 12px; }
.story { padding: 28px 24px; border-radius: 24px; background: linear-gradient(160deg, var(--primary-soft), var(--surface) 70%); border: 1px solid var(--primary-line); min-height: 280px; display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.story-kicker { margin: 0; font-size: 14px; font-weight: 600; color: var(--primary); }
.story-big { margin: 0; font-size: 56px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.story-big small { font-size: 18px; font-weight: 500; color: var(--muted); }
.story-big--2 { font-size: 40px; }
.story-text { margin: 0; font-size: 17px; line-height: 1.7; }
.story-bars, .story-nav { display: none; }
.stories.is-live { max-width: 520px; margin-inline: auto; position: relative; }
.stories.is-live .story-bars { display: flex; gap: 6px; }
.stories.is-live .story-bars i { flex: 1; height: 4px; border-radius: 4px; background: var(--track); }
.stories.is-live .story-bars i.is-done, .stories.is-live .story-bars i.is-now { background: var(--primary); }
.stories.is-live .story-bars i.is-now { opacity: .65; }
.stories.is-live .story { min-height: 380px; cursor: pointer; user-select: none; animation: story-in .3s ease; }
.stories.is-live .story-nav { display: flex; justify-content: space-between; }
.stories.is-live .story-nav[hidden] { display: none; }
[dir='rtl'] .story-nav [data-story-next] svg, [dir='ltr'] .story-nav [data-story-prev] svg { transform: scaleX(-1); }
@keyframes story-in { from { opacity: 0; transform: scale(.98); } }
.story-note { margin: 12px 4px 0; }

.routine { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 12px; }
.routine li { display: flex; gap: 12px; align-items: flex-start; }
.routine p { margin: 0; display: flex; flex-direction: column; gap: 2px; }
.routine-n { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 13px; }
.breath { display: grid; gap: 14px; justify-items: center; text-align: center; }
.breath .hint { max-width: 420px; }
.breath-modes { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip--btn { border: 1px solid var(--line); cursor: pointer; font: inherit; font-size: 13px; color: var(--ink); background: var(--surface-2); min-height: 36px; padding: 0 14px; border-radius: 999px; }
.chip--btn.is-active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.chip--btn:disabled { opacity: .6; cursor: default; }
.breath-stage { position: relative; width: 220px; height: 220px; display: grid; place-items: center; }
.breath-circle { position: absolute; inset: 0; margin: auto; width: 120px; height: 120px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--primary) 55%, transparent), color-mix(in srgb, var(--primary) 18%, transparent)); box-shadow: 0 0 40px color-mix(in srgb, var(--primary) 30%, transparent); transition: transform 4s ease-in-out; }
.breath-circle.is-big { transform: scale(1.8); }
.breath-phase { position: relative; margin: 0; font-size: 20px; font-weight: 700; }
.breath-count { position: absolute; inset-block-end: 14px; margin: 0; font-size: 16px; }
@media (prefers-reduced-motion: reduce) { .breath-circle { transition: none !important; } }
@media (min-width: 1024px) {
  .program-layout { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; gap: 18px; }
  .program-main { grid-column: 1; }
  .program-timeline { grid-column: 2; }
  .coach-layout { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; gap: 18px; }
  .sleep-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
  .sleep-summary { grid-column: 1 / -1; }
}
.story[hidden] { display: none; }

/* ───────── بوابة المختص وفريقي الطبي ───────── */
.pro-grid, .care-grid { display: grid; gap: 12px; margin-top: 14px; }
.pro-note { margin: 8px 4px 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pro-alerts ul { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.pro-link { margin-top: 14px; }
.pro-link-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin: 8px 0; }
.pro-link-form .field { flex: 1 1 220px; }
.code-input { letter-spacing: .18em; text-transform: uppercase; font-weight: 700; }
.patient-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.patient { display: flex; flex-direction: column; gap: 6px; color: inherit; text-decoration: none; }
.patient:hover { border-color: var(--primary-line); }
.patient--high { border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); }
.patient-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.patient-name { font-size: 16px; }
.patient-reasons { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.prio--high { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); font-weight: 700; }
.prio--medium { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); font-weight: 600; }
.prio--low { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); font-weight: 600; }
.alert-review { padding: 12px 0; border-top: 1px solid var(--line); }
.alert-review p { margin: 0 0 6px; line-height: 1.7; }
.alert-review.is-reviewed { opacity: .85; }
.review-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.review-form select, .review-form input[type=text] { min-height: 40px; padding: 0 10px; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.review-form input[type=text] { flex: 1 1 200px; }
.plan-form { margin-top: 12px; display: grid; gap: 10px; }
.plan-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.plan-badge { display: inline-flex; align-items: center; gap: 6px; color: var(--good); font-weight: 600; margin: 8px 0 0; }
.note-form { display: grid; gap: 10px; }
.notes { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.notes li { padding: 10px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.notes p { margin: 0 0 4px; line-height: 1.7; white-space: pre-wrap; }
.lab-value-inline { font-weight: 600; font-variant-numeric: tabular-nums; }
.care-code { border-color: var(--primary-line); background: var(--primary-soft); }
.care-code-value { margin: 10px 0; font-size: 32px; font-weight: 800; letter-spacing: .14em; text-align: center; font-variant-numeric: tabular-nums; user-select: all; }
.care-links { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 12px; }
.care-links li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.care-links li:last-child { border-bottom: 0; padding-bottom: 0; }
.btn--danger-text { color: var(--danger); }
.bn-form { display: contents; }
.bn-form .bn { background: none; border: 0; font: inherit; cursor: pointer; }
@media (min-width: 1024px) {
  .pro-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
  .pro-head, #readings, #notes { grid-column: 1 / -1; }
  .care-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
}

/* ───────── العيلة ورمضان ───────── */
.ram-grid, .fam-grid { display: grid; gap: 12px; margin-top: 14px; }
.ram-risk { margin-top: 14px; }
.ram-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 10px 0; }
.ram-time { margin: 2px 0 0; font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.ram-countdown { margin: 4px 0 10px; font-size: 18px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; min-height: 1.4em; }
.ram-meds { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 10px; }
.ram-meds p { margin: 2px 0 0; }
.fam-notices ul { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 14px; }
.fam-checks { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; }
.fam-join-title { margin-top: 18px; }
.fam-invite { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; margin-top: 10px; border-radius: 14px; background: var(--primary-soft); border: 1px solid var(--primary-line); }
.fam-invite p { margin: 0; }
.challenge { margin-top: 14px; padding: 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface-2); display: grid; gap: 8px; }
.challenge.is-finished { opacity: .75; }
.fam-streak { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--accent); font-weight: 700; }
.board { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.board li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; background: var(--surface); }
.board li.is-me { outline: 1px solid var(--primary-line); background: var(--primary-soft); }
.board-rank { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); font-size: 12px; font-weight: 700; }
.board-val small { font-weight: 500; color: var(--muted); }
.fam-new { margin-top: 18px; display: grid; gap: 10px; }
@media (min-width: 1024px) {
  .ram-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
  .fam-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
  .fam-challenges { grid-column: 1 / -1; }
}

/* ───────── الأجهزة ───────── */
.dev-grid { display: grid; gap: 12px; margin-top: 14px; }
.cgm-tir { display: flex; block-size: 14px; border-radius: 999px; overflow: hidden; background: var(--track); margin: 12px 0; }
.tir--low { background: var(--danger, #e5484d); }
.tir--in { background: var(--primary); }
.tir--high { background: var(--warn); }
.token-value { margin: 8px 0; padding: 10px 12px; border-radius: 10px; background: var(--bg); border: 1px dashed var(--primary-line); font-family: ui-monospace, Consolas, monospace; font-size: 13px; word-break: break-all; user-select: all; }
.api-example { margin: 10px 0 0; padding: 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); font-size: 12px; line-height: 1.6; overflow-x: auto; white-space: pre; }
.import-result { margin-top: 12px; }
.import-box { padding: 12px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); display: grid; gap: 8px; }
.import-box.is-error { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.import-counts { margin: 0; padding-inline-start: 18px; display: grid; gap: 2px; }
.import-table { width: 100%; font-size: 12px; border-collapse: collapse; }
.import-table td { padding: 4px 8px; border-top: 1px solid var(--line); }
.dev-import input[type=file] { padding: 12px; min-height: 0; }
@media (min-width: 1024px) {
  .dev-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
  .dev-cgm, .dev-batches { grid-column: 1 / -1; }
}
/* حقل الملف بنفس هوية باقي الحقول (بدل الزرار الأصلي للمتصفح) */
input[type=file] { color: var(--muted); font: inherit; font-size: 14px; }
input[type=file]::file-selector-button { margin-inline-end: 12px; padding: 8px 14px; border: 1px solid var(--primary-line); border-radius: 999px; background: var(--primary-soft); color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; }
input[type=file]::file-selector-button:hover { border-color: var(--primary); }

/* ───── Sprint 12: الأمان والصفحات القانونية ───── */
.auth--wide .auth-card { max-inline-size: 560px; }
.sec .stack { display: grid; gap: 12px; }
.sec-qr { display: grid; place-items: center; padding: 12px; background: #fff; border-radius: var(--radius, 16px); inline-size: fit-content; margin-inline: auto; }
.sec-qr svg { inline-size: 192px; block-size: 192px; }
.sec-secret { text-align: center; word-break: break-all; }
.rec-codes { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.rec-codes code { display: block; padding: 8px 10px; border-radius: 10px; background: var(--surface-2, rgba(127,127,127,.12)); text-align: center; letter-spacing: .08em; }
.legal section { margin-block: 14px; }
.legal-draft { padding: 10px 12px; border-radius: 12px; background: rgba(245, 158, 11, .14); font-size: .9rem; }

/* ───────── لابتوب: صفحات أقصر وأنظم (بدل كروت طويلة تحت بعض) ───────── */
@media (min-width: 1024px) {
  /* التحاليل: المجموعات في عمودين، والكروت أصغر */
  .lab-groups { column-count: 2; column-gap: 28px; }
  .lab-group { break-inside: avoid; margin-top: 18px; }
  .lab-group:first-child { margin-top: 12px; }
  .lab-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
  .lab-card { padding: 14px 16px; gap: 2px; }
  .lab-value { margin-top: 2px; font-size: 24px; }
  .lab-range { margin-top: 2px; }

  /* رمضان والعيلة وملف المريض عند المختص: عمودين من غير فراغات بين الكروت */
  .ram-grid, .fam-grid, .pro-grid { display: block; column-count: 2; column-gap: 18px; }
  .ram-grid > .card, .fam-grid > .card, .pro-grid > .card { break-inside: avoid; margin-bottom: 18px; }
  .ram-grid > .card:last-child, .fam-grid > .card:last-child, .pro-grid > .card:last-child { margin-bottom: 0; }
}
/* صحتي: الرسم على جنب والقياسات في قايمة جنبه بتتسكرول جوّاها، فالصفحة متطولش */
@media (min-width: 1200px) {
  .health-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; align-items: start; }
  .health-layout .health-card { position: sticky; top: 16px; }
  .health-list { max-height: calc(100dvh - 190px); overflow-y: auto; scrollbar-width: thin; }
  .health-list .entry-list { display: block; }
  .health-list .entry-list > .entry { border-top: 1px solid var(--line); }
  .health-list .entry-list > .entry:first-child { border-top: 0; }
}
/* الوجبات: قايمة واحدة جوه كل وجبة (العمود ضيّق) */
@media (min-width: 1100px) {
  .food-meal .entry-list { display: block; }
  .food-meal .entry-list > .entry { border-top: 1px solid var(--line); }
  .food-meal .entry-list > .entry:first-child { border-top: 0; }
}
@media (min-width: 1024px) { .lab-value--none { font-size: 14px; } }

/* ───────── الملف الطبي: تبويبات على اللابتوب (بدون JS) ───────── */
.ptab-radio, .ptabs { display: none; }
@media (min-width: 1024px) {
  .ptab-radio { display: block; position: absolute; opacity: 0; pointer-events: none; }
  .ptabs { display: flex; gap: 6px; margin-top: 18px; padding: 4px; width: fit-content; background: var(--surface-2); border-radius: 999px; }
  .ptabs label { padding: 8px 18px; border-radius: 999px; cursor: pointer; color: var(--muted); font-size: 14px; font-weight: 600; }
  .ptabs label:hover { color: var(--ink); }
  #pt-health:checked ~ .ptabs label[for="pt-health"],
  #pt-settings:checked ~ .ptabs label[for="pt-settings"],
  #pt-privacy:checked ~ .ptabs label[for="pt-privacy"] { background: var(--primary-soft); color: var(--primary); }
  #pt-health:focus-visible ~ .ptabs label[for="pt-health"],
  #pt-settings:focus-visible ~ .ptabs label[for="pt-settings"],
  #pt-privacy:focus-visible ~ .ptabs label[for="pt-privacy"] { outline: 2px solid var(--primary); outline-offset: 2px; }
  #pt-health:checked ~ .profile-grid [data-tab]:not([data-tab="health"]),
  #pt-settings:checked ~ .profile-grid [data-tab]:not([data-tab="settings"]),
  #pt-privacy:checked ~ .profile-grid [data-tab]:not([data-tab="privacy"]) { display: none; }
  .ptabs ~ .profile-grid { margin-top: 14px; }
}

/* ───────── صندوق الإشعارات + الجرس ───────── */
.appbar { display: flex; justify-content: flex-end; align-items: center; min-height: 40px; }
.bell { position: relative; display: grid; place-items: center; inline-size: 40px; block-size: 40px; border-radius: 50%; color: var(--muted); background: var(--surface-2); }
.bell:hover, .bell[aria-current] { color: var(--primary); }
.bell-badge { position: absolute; inset-block-start: -2px; inset-inline-end: -2px; min-inline-size: 18px; block-size: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger, #ef4444); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; }
.notif-filters { margin-top: 14px; }
.notif-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.notif { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; }
.notif.is-unread { border-color: var(--primary-line); background: color-mix(in srgb, var(--primary) 6%, var(--surface)); }
.notif-ico { flex: none; display: grid; place-items: center; inline-size: 38px; block-size: 38px; border-radius: 50%; background: var(--surface-2); color: var(--muted); }
.notif-ico--alert { color: var(--danger, #ef4444); }
.notif-main { flex: 1; min-inline-size: 0; }
.notif-open { all: unset; display: grid; gap: 2px; inline-size: 100%; cursor: pointer; }
.notif-open:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; border-radius: 8px; }
.notif-title { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.notif-dot { flex: none; inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--primary); }
.notif-body { color: var(--muted); font-size: 14px; line-height: 1.6; }
.notif-actions { flex: none; display: flex; gap: 4px; }
.notif-clear { margin-top: 12px; text-align: center; }
@media (min-width: 1024px) { .notif-list { max-inline-size: 760px; } }

/* ───────── تقرير الدكتور ───────── */
.report { max-inline-size: 860px; margin-inline: auto; padding: 20px 16px 48px; }
.report-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.report-bar-actions { display: flex; align-items: center; gap: 10px; }
.report-head { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.report-kv { margin-top: 10px; }
.report-note { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(245, 158, 11, .12); font-size: .9rem; }
.report-sec { margin-top: 22px; break-inside: avoid; }
.report-table { inline-size: 100%; border-collapse: collapse; font-size: 14px; }
.report-table th, .report-table td { padding: 8px 10px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: top; }
.report-table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.share-new { margin: 12px 0; padding: 12px; border: 1px dashed var(--primary-line); border-radius: 12px; display: grid; gap: 6px; }
.share-link { inline-size: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font: inherit; }
.share-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
@media print {
  :root, :root[data-theme="dark"], :root[data-theme="light"] { --ink: #111; --muted: #444; --surface: #fff; --surface-2: #f3f3f3; --line: #ccc; --primary: #0a7a5a; --accent: #0a7a5a; }
  html, body { background: #fff !important; color: #111 !important; }
  .no-print, .toast, .nav-progress { display: none !important; }
  .report { padding: 0; max-inline-size: none; }
}

/* PWA: عناصر الحالة بتتخفي بـ hidden حتى لو عليها display */
.pwa-card [hidden] { display: none !important; }

/* ───────── الخطوة الجاية + ابدأ هنا ───────── */
.guide { display: grid; gap: 12px; margin-top: 16px; }
.guide-next { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-color: var(--primary-line); background: color-mix(in srgb, var(--primary) 7%, var(--surface)); }
.guide-ico { flex: none; display: grid; place-items: center; inline-size: 44px; block-size: 44px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); }
.guide-body { flex: 1; min-inline-size: 0; }
.guide-steps { list-style: none; margin: 12px 0 4px; padding: 0; display: grid; gap: 6px; }
.guide-step a { display: flex; align-items: center; gap: 10px; padding: 6px 2px; color: inherit; text-decoration: none; }
.guide-step.is-done a { color: var(--muted); text-decoration: line-through; }
.guide-tick { flex: none; display: grid; place-items: center; inline-size: 20px; block-size: 20px; border-radius: 50%; border: 1.5px solid var(--line); color: var(--primary); }
.guide-step.is-done .guide-tick { background: var(--primary-soft); border-color: var(--primary-line); }
@media (max-width: 640px) { .guide-next { flex-wrap: wrap; } .guide-next .btn { inline-size: 100%; } }
@media (min-width: 1100px) { .guide { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; } .guide-next:only-child { grid-column: 1 / -1; } }

/* ───────── المساعد / افهم أرقامك / المراجع / الربط ───────── */
.nav-group { margin: 10px 14px 2px; font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--muted); opacity: .8; }
@media (max-height: 900px) { .nav-group { margin-block: 6px 0; } }
.assistant, .assistant-privacy { margin-top: 14px; }
.assistant-form { display: grid; gap: 10px; margin-top: 10px; }
.assistant-form textarea { min-block-size: 84px; }
.assistant-examples { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.assistant-answer { margin-top: 14px; }
.ans-q { font-weight: 600; margin: 0 0 8px; }
.ans-box { padding: 12px 14px; border-radius: 14px; background: var(--surface-2); line-height: 1.8; }
.ans-box--urgent { background: color-mix(in srgb, var(--danger, #ef4444) 14%, var(--surface)); border: 1px solid var(--danger, #ef4444); }
.ans-box--warn { background: rgba(245, 158, 11, .12); }
.ans-refs { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 10px; }
.ans-ref { padding: 12px 14px; }
.ans-disclaimer { margin-top: 10px; }
.learn-how { margin-top: 14px; }
.how-steps { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 10px; }
.how-steps li { display: grid; gap: 2px; }
.how-steps span { color: var(--muted); }
.learn-grid { display: grid; gap: 8px; }
.learn-group { margin-top: 16px; }
.learn-card { margin-top: 10px; line-height: 1.8; }
.learn-disclaimer { margin-top: 18px; }
.ref-rules, .ref-sources { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 14px; }
.ref-rules p, .ref-sources li { line-height: 1.7; }
.connect-intro { margin: 12px 4px 0; }
.connect-group { margin-top: 18px; }
.connect-grid { display: grid; gap: 12px; margin-top: 10px; }
.connect-card { display: grid; gap: 8px; align-content: start; }
.connect-card--planned { opacity: .85; }
@media (min-width: 1024px) {
  .learn-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; align-items: start; }
  .connect-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .how-steps { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1280px) { .connect-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
