/* ===========================================================================
   دوّنلي — هوية "دفتر" (Daftar Design System)
   ورق دافي + حبر + أخضر هادي، وأربع عوالم: الصحة/مرجاني، العادات/كهرماني،
   الأهداف/أزرق، الفلوس/أخضر ورقي. Lemonada للعناوين، Tajawal للنصوص. RTL.
   =========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Lemonada:wght@400;500;600;700&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800&display=swap");

:root {
  /* ---- الورق والأسطح ---- */
  --paper:           #F6F1E4;
  --paper-deep:      #EFE8D6;
  --surface-card:    #FFFCF5;
  --surface-raised:  #FFFFFF;

  /* ---- الحبر ---- */
  --ink:             #34302A;
  --ink-muted:       #6E665A;
  --ink-faint:       #9A9082;
  --hairline:        #DFD7C4;
  --hairline-strong: #C9BFA8;

  /* ---- البراند: أخضر هادي ---- */
  --brand:        #5C8A6B;
  --brand-deep:   #426B52;
  --brand-tint:   #BCD4C2;
  --brand-wash:   #E4EEE6;

  /* ---- العوالم الأربعة ---- */
  --health:        #E0705C;
  --health-deep:   #C4543F;
  --health-tint:   #F6D5CD;
  --health-wash:   #FBEAE5;

  --habits:        #E3A24A;
  --habits-deep:   #C07F25;
  --habits-tint:   #F6E1BE;
  --habits-wash:   #FBF0D9;

  --goals:         #5285A6;
  --goals-deep:    #3A647F;
  --goals-tint:    #C3DAE7;
  --goals-wash:    #E3EEF4;

  --finances:      #6FA84A;
  --finances-deep: #527F35;
  --finances-tint: #CFE3BD;
  --finances-wash: #EAF2E1;
  --coin:          #C9962E;

  --success: #6FA84A;
  --warning: #E3A24A;
  --danger:  #E0705C;
  --danger-deep: #C4543F;

  --bg-app: var(--paper);
  --on-accent: #FFFCF5;

  /* ---- الخطوط ---- */
  --font-display: "Lemonada", "Tajawal", system-ui, sans-serif;
  --font-body:    "Tajawal", "Lemonada", system-ui, sans-serif;
  --text-display: 3.5rem;
  --text-h1: 2.5rem;
  --text-h2: 2rem;
  --text-h3: 1.5rem;
  --text-h4: 1.25rem;
  --text-lg: 1.125rem;
  --text-base: 1rem;
  --text-sm: 0.875rem;
  --text-xs: 0.75rem;
  --type-h1:    700 var(--text-h1)/1.2 var(--font-display);
  --type-h2:    700 var(--text-h2)/1.2 var(--font-display);
  --type-h3:    500 var(--text-h3)/1.4 var(--font-display);
  --type-body:  400 var(--text-base)/1.7 var(--font-body);
  --type-lead:  400 var(--text-lg)/1.7 var(--font-body);
  --type-label: 700 var(--text-sm)/1.4 var(--font-body);

  /* ---- مسافات وأنصاف أقطار وظلال ---- */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px;
  --radius-sm: 14px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --radius-pill: 999px;
  --radius-sketch:   255px 15px 225px 15px / 15px 225px 15px 255px;
  --radius-sketch-2: 15px 225px 15px 255px / 255px 15px 225px 15px;
  --stroke: 2px;
  --shadow-sm: 0 2px 8px rgba(52, 48, 42, 0.06);
  --shadow-md: 0 4px 16px rgba(52, 48, 42, 0.08);
  --shadow-lg: 0 10px 30px rgba(52, 48, 42, 0.12);
  --shadow-press: 0 1px 4px rgba(52, 48, 42, 0.10);
  --ease-pen:    cubic-bezier(0.65, 0, 0.35, 1);
  --ease-soft:   cubic-bezier(0.33, 1, 0.68, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 160ms; --dur-base: 280ms; --dur-slow: 600ms; --dur-draw: 1200ms;

  /* حبيبات الورق */
  --paper-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
}

* , *::before, *::after { box-sizing: border-box; }

html { direction: rtl; text-size-adjust: 100%; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font: var(--type-body);
  color: var(--ink);
  background-color: var(--bg-app);
  background-image: var(--paper-grain);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
  margin: 0;
}

::selection { background: var(--brand-tint); }
a { color: inherit; }

/* ---------- علب السكتش (المرسومة باليد) ---------- */
.sketch-box {
  background: var(--surface-card);
  border: var(--stroke) solid var(--ink);
  border-radius: var(--radius-sketch);
  box-shadow: var(--shadow-md);
}
.sketch-box.alt { border-radius: var(--radius-sketch-2); }

/* ---------- خربشة تحت العنوان ---------- */
.squiggle { position: relative; display: inline-block; }
.squiggle::after {
  content: "";
  position: absolute;
  inset-inline: -2px;
  bottom: -0.3em;
  height: 0.42em;
  background: no-repeat center/100% 100%
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 12' fill='none' stroke='%235C8A6B' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M2 7c14-6 28 4 42-1s28-6 42-1 26 3 32 1'/%3E%3C/svg%3E");
}

/* ===========================================================================
   أزرار
   =========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: var(--text-base);
  line-height: 1;
  padding: 12px 22px;
  border-radius: 18px;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  background: var(--brand);
  color: var(--on-accent);
  border: 2px solid var(--brand-deep);
  box-shadow: var(--shadow-md);
  transition: transform var(--dur-fast) var(--ease-soft), box-shadow var(--dur-fast) var(--ease-soft), background var(--dur-fast) var(--ease-soft);
}
.btn:hover { background: var(--brand-deep); transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.btn:active { transform: scale(0.97); box-shadow: var(--shadow-press); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn.secondary {
  background: var(--surface-card);
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow-sm);
}
.btn.secondary:hover { background: var(--surface-card); box-shadow: var(--shadow-md); }

.btn.ghost {
  background: transparent;
  color: var(--brand-deep);
  border: 2px solid transparent;
  box-shadow: none;
}
.btn.ghost:hover { background: var(--brand-wash); transform: none; box-shadow: none; }

.btn.sm { padding: 8px 16px; font-size: var(--text-sm); border-radius: var(--radius-sm); }
.btn.lg { padding: 16px 30px; font-size: var(--text-lg); border-radius: 22px; }

.btn.health   { background: var(--health);   border-color: var(--health-deep); }
.btn.health:hover { background: var(--health-deep); }
.btn.habits   { background: var(--habits);   border-color: var(--habits-deep); }
.btn.habits:hover { background: var(--habits-deep); }
.btn.goals    { background: var(--goals);    border-color: var(--goals-deep); }
.btn.goals:hover { background: var(--goals-deep); }
.btn.finances { background: var(--finances); border-color: var(--finances-deep); }
.btn.finances:hover { background: var(--finances-deep); }
.btn.danger   { background: var(--danger); border-color: var(--danger-deep); }
.btn.danger:hover { background: var(--danger-deep); }

/* زر أيقونة صغير (حذف وغيره) */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  font-size: 14px;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.icon-btn:hover { background: var(--health-wash); color: var(--health-deep); }

/* ===========================================================================
   Chips & Badges
   =========================================================================== */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--text-sm);
  line-height: 1;
  color: var(--brand-deep);
  background: var(--brand-wash);
  border: 1.5px solid var(--brand);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  white-space: nowrap;
}
.chip.health   { color: var(--health-deep);   background: var(--health-wash);   border-color: var(--health); }
.chip.habits   { color: var(--habits-deep);   background: var(--habits-wash);   border-color: var(--habits); }
.chip.goals    { color: var(--goals-deep);    background: var(--goals-wash);    border-color: var(--goals); }
.chip.finances { color: var(--finances-deep); background: var(--finances-wash); border-color: var(--finances); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: var(--text-xs);
  line-height: 1;
  color: var(--brand-deep);
  background: var(--brand-wash);
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }
.badge.health   { color: var(--health-deep);   background: var(--health-wash); }
.badge.health .dot { background: var(--health); }
.badge.habits   { color: var(--habits-deep);   background: var(--habits-wash); }
.badge.habits .dot { background: var(--habits); }
.badge.goals    { color: var(--goals-deep);    background: var(--goals-wash); }
.badge.goals .dot { background: var(--goals); }
.badge.finances, .badge.success { color: var(--finances-deep); background: var(--finances-wash); }
.badge.finances .dot, .badge.success .dot { background: var(--finances); }
.badge.warning  { color: var(--habits-deep);   background: var(--habits-wash); }
.badge.warning .dot { background: var(--warning); }
.badge.danger   { color: var(--danger-deep);   background: var(--health-wash); }
.badge.danger .dot { background: var(--danger); }

.kicker {
  font: var(--type-label);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  color: var(--ink-faint);
}

/* ===========================================================================
   كروت
   =========================================================================== */
.card {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: clamp(18px, 2.4vw, 26px);
  position: relative;
}
.card.sketch {
  border: var(--stroke) solid var(--ink);
  border-radius: var(--radius-sketch);
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.card-head h3 { font: var(--type-h3); margin: 0; }

.lift { transition: transform var(--dur-base) var(--ease-soft), box-shadow var(--dur-base) var(--ease-soft); }
.lift:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

/* ---------- StatCard ---------- */
.stat-card {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-5);
  min-width: 0;
}
.stat-card .sc-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.stat-card .sc-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--brand-wash);
  color: var(--brand-deep);
  font-size: 17px;
}
.stat-card.health .sc-ico   { background: var(--health-wash);   color: var(--health-deep); }
.stat-card.habits .sc-ico   { background: var(--habits-wash);   color: var(--habits-deep); }
.stat-card.goals .sc-ico    { background: var(--goals-wash);    color: var(--goals-deep); }
.stat-card.finances .sc-ico { background: var(--finances-wash); color: var(--finances-deep); }
.stat-card .sc-label { font: var(--type-label); color: var(--ink-muted); }
.stat-card .sc-value {
  display: flex; align-items: baseline; gap: 6px;
}
.stat-card .sc-value b {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-h2);
  color: var(--ink);
  line-height: 1.3;
}
.stat-card .sc-unit { font: var(--type-body); color: var(--ink-muted); }
.stat-card .sc-delta { margin-top: 8px; font: var(--type-label); color: var(--ink-muted); }
.stat-card .sc-delta.up { color: var(--finances-deep); }
.stat-card .sc-delta.down { color: var(--danger-deep); }

/* ---------- WorldCard ---------- */
.world-card {
  background: var(--surface-card);
  border: var(--stroke) solid var(--ink);
  border-radius: var(--radius-sketch);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform var(--dur-base) var(--ease-soft), box-shadow var(--dur-base) var(--ease-soft);
}
.world-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.world-card .wc-art {
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-4);
  min-height: 130px;
}
.world-card .wc-art img { width: 110px; height: 110px; transition: transform var(--dur-slow) var(--ease-bounce); }
.world-card:hover .wc-art img { transform: translateY(-6px) rotate(-3deg) scale(1.04); }
.world-card.health .wc-art   { background: var(--health-wash); }
.world-card.habits .wc-art   { background: var(--habits-wash); }
.world-card.goals .wc-art    { background: var(--goals-wash); }
.world-card.finances .wc-art { background: var(--finances-wash); }
.world-card .wc-body { padding: var(--space-4) var(--space-5) var(--space-5); }
.world-card .wc-tag {
  display: inline-block;
  font: var(--type-label);
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  margin-bottom: 8px;
}
.world-card.health .wc-tag   { color: var(--health-deep);   background: var(--health-wash); }
.world-card.habits .wc-tag   { color: var(--habits-deep);   background: var(--habits-wash); }
.world-card.goals .wc-tag    { color: var(--goals-deep);    background: var(--goals-wash); }
.world-card.finances .wc-tag { color: var(--finances-deep); background: var(--finances-wash); }
.world-card .wc-metric {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-h3);
  color: var(--ink);
  line-height: 1.3;
}
.world-card .wc-caption { font: var(--type-body); color: var(--ink-muted); margin-top: 4px; }

/* ===========================================================================
   هيكل التطبيق: سايدبار + محتوى
   =========================================================================== */
.dw-app { display: flex; min-height: 100vh; min-height: 100dvh; background: var(--bg-app); }

.dw-sidebar {
  width: 256px;
  flex: none;
  background: var(--surface-card);
  border-inline-end: 1px solid var(--hairline);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 60;
}
.dw-sidebar .side-logo { height: 38px; margin: 4px 8px 20px; cursor: pointer; align-self: flex-start; }

.nav-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font: var(--type-label);
  color: var(--ink-muted);
  text-align: start;
  width: 100%;
  transition: background var(--dur-fast) var(--ease-soft);
}
.nav-btn:hover { background: var(--paper-deep); }
.nav-btn .nb-ico { display: inline-flex; width: 22px; justify-content: center; font-size: 16px; }
.nav-btn[data-active="true"] { color: var(--brand-deep); background: var(--brand-wash); box-shadow: inset 3px 0 0 var(--brand); }
.nav-btn.health[data-active="true"]   { color: var(--health-deep);   background: var(--health-wash);   box-shadow: inset 3px 0 0 var(--health); }
.nav-btn.habits[data-active="true"]   { color: var(--habits-deep);   background: var(--habits-wash);   box-shadow: inset 3px 0 0 var(--habits); }
.nav-btn.goals[data-active="true"]    { color: var(--goals-deep);    background: var(--goals-wash);    box-shadow: inset 3px 0 0 var(--goals); }
.nav-btn.finances[data-active="true"] { color: var(--finances-deep); background: var(--finances-wash); box-shadow: inset 3px 0 0 var(--finances); }

.nav-group {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
  padding: 14px 14px 6px;
}

.side-tip {
  margin-top: 20px;
  padding: 16px;
  background: var(--brand-wash);
  border-radius: var(--radius-md);
  border: 1px solid var(--brand-tint);
}
.side-tip b { display: block; font: var(--type-label); color: var(--brand-deep); margin-bottom: 6px; }
.side-tip span { font-size: var(--text-sm); color: var(--ink-muted); line-height: 1.6; }

.side-user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 8px 4px;
  border-top: 1px solid var(--hairline);
}
.side-user .avatar {
  width: 38px; height: 38px;
  flex: none;
  border-radius: 50%;
  background: var(--brand-tint);
  color: var(--brand-deep);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
}
.side-user .su-name { font: var(--type-label); color: var(--ink); line-height: 1.3; }
.side-user .su-sub { font-size: var(--text-xs); color: var(--ink-faint); }
.side-user .su-logout {
  margin-inline-start: auto;
  border: none; background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  font-size: 16px;
  padding: 6px;
  border-radius: 8px;
}
.side-user .su-logout:hover { color: var(--health-deep); background: var(--health-wash); }

/* المحتوى */
.dw-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dw-main {
  flex: 1;
  min-width: 0;
  padding: clamp(20px, 4vw, 44px);
  width: 100%;
  max-width: 1060px;
  margin: 0 auto;
}

/* توب بار + شريط تابات الموبايل — متخفيين على الديسكتوب */
.dw-topbar { display: none; }
.dw-tabbar { display: none; }

/* انتقال بين الصفحات — transform فقط عشان المحتوى ميختفيش لو الأنيميشن اتجمد */
@keyframes viewFade { from { transform: translateY(10px); } to { transform: translateY(0); } }
.view-fade { animation: viewFade var(--dur-base) var(--ease-soft) both; }
@media (prefers-reduced-motion: reduce) { .view-fade { animation: none; } }

/* ===========================================================================
   رأس الصفحة + الهيدر داخل العوالم
   =========================================================================== */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 26px;
}
.page-head h1 { font: var(--type-h1); font-size: clamp(26px, 3.4vw, 40px); margin: 0; }
.page-head .ph-sub { font: var(--type-lead); color: var(--ink-muted); margin: 4px 0 0; }
.world-pill {
  display: inline-block;
  font: var(--type-label);
  border-radius: var(--radius-pill);
  padding: 4px 14px;
  margin-bottom: 10px;
  color: var(--brand-deep);
  background: var(--brand-wash);
}
.world-pill.health   { color: var(--health-deep);   background: var(--health-wash); }
.world-pill.habits   { color: var(--habits-deep);   background: var(--habits-wash); }
.world-pill.goals    { color: var(--goals-deep);    background: var(--goals-wash); }
.world-pill.finances { color: var(--finances-deep); background: var(--finances-wash); }

.date-chip, .streak-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: var(--type-label);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-sm);
  color: var(--ink-muted);
}
.streak-chip { color: var(--habits-deep); background: var(--habits-wash); border-color: var(--habits-tint); }

/* الإحصائيات الصغيرة في الترحيب */
.mini-stat {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 10px 18px;
  min-width: 84px;
}
.mini-stat b { font-family: var(--font-display); font-weight: 700; font-size: 22px; color: var(--ink); }
.mini-stat small { font-size: var(--text-xs); color: var(--ink-faint); }

/* ===========================================================================
   الكومبوزر (رتّبهالي)
   =========================================================================== */
.composer {
  background: var(--surface-card);
  border: var(--stroke) solid var(--ink);
  border-radius: var(--radius-sketch);
  box-shadow: var(--shadow-md);
  padding: 20px 24px;
}
.composer textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: vertical;
  background: transparent;
  font: var(--type-lead);
  color: var(--ink);
  min-height: 56px;
  font-family: var(--font-body);
}
.composer textarea::placeholder { color: var(--ink-faint); }
.composer .comp-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.composer .comp-hint { font: var(--type-body); font-size: var(--text-sm); color: var(--ink-faint); }
.composer .comp-reply {
  margin-top: 14px;
  padding: 14px 16px;
  background: var(--brand-wash);
  border: 1.5px solid var(--brand-tint);
  border-radius: var(--radius-md);
  font: var(--type-body);
  color: var(--ink);
}
.composer .comp-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* ===========================================================================
   شبكات عامة
   =========================================================================== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; }
.world-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; }
.grid-2-side { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.grid-2-equal { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; }

.section-title { font: var(--type-h2); font-size: clamp(22px, 2.6vw, 30px); margin: 6px 0 14px; }

/* ===========================================================================
   الفيد (آخر ما دوّنته)
   =========================================================================== */
.log-row {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 16px 20px;
}
.log-row .lr-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.log-row .lr-text { font: var(--type-body); color: var(--ink); }
.log-row .lr-time { font: var(--type-body); font-size: var(--text-sm); color: var(--ink-faint); white-space: nowrap; }
.log-row .lr-chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* صفوف لستة عامة (عمليات، صحة، أكل...) */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 12px 16px;
}
.list-row .lm { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.list-row .lm .l1 { font: var(--type-label); color: var(--ink-muted); }
.list-row .lm .l2 { font: var(--type-body); color: var(--ink); }
.list-row .l-amount { font: var(--type-label); white-space: nowrap; color: var(--ink); }
.list-row .l-amount.pos { color: var(--finances-deep); }
.list-row .l-amount.neg { color: var(--danger-deep); }
.row-actions { display: flex; align-items: center; gap: 8px; flex: none; }

/* خط زمني (تقرير الدكتور) */
.tl-rows { display: flex; flex-direction: column; gap: 12px; }
.tl-row { display: flex; align-items: center; gap: 10px; padding-bottom: 12px; border-bottom: 1px dashed var(--hairline); }
.tl-row:last-child { border-bottom: none; padding-bottom: 0; }
.tl-row .tl-text { font: var(--type-body); color: var(--ink); }

/* ===========================================================================
   عادات: ستريك + هيت ماب + صفوف
   =========================================================================== */
.streak-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.streak-head .fl {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  background: var(--habits-wash);
  font-size: 24px;
}
.streak-head b { font-family: var(--font-display); font-weight: 700; font-size: var(--text-h2); color: var(--habits-deep); line-height: 1; }
.streak-head span { font: var(--type-body); color: var(--ink-muted); }

.streak-days { display: flex; gap: 8px; }
.streak-days .sd { display: flex; flex-direction: column; align-items: center; gap: 5px; flex: 1; }
.streak-days .sd-cell {
  width: 100%;
  aspect-ratio: 1 / 1.15;
  max-width: 44px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--habits);
  background: var(--surface-card);
  display: flex; align-items: center; justify-content: center;
  color: var(--on-accent);
  transition: background var(--dur-base) var(--ease-bounce);
}
.streak-days .sd-cell.done { background: var(--habits); }
.streak-days .sd small { font-size: var(--text-xs); color: var(--ink-muted); }

.heatmap { display: grid; gap: 6px; direction: rtl; }
.heatmap .hm-cell {
  aspect-ratio: 1;
  border-radius: 6px;
  background: var(--surface-card);
  border: 1.5px solid var(--hairline);
}
.heatmap .hm-cell.l1 { background: var(--habits-wash); border-color: var(--habits); }
.heatmap .hm-cell.l2 { background: var(--habits-tint); border-color: var(--habits); }
.heatmap .hm-cell.l3 { background: var(--habits); border-color: var(--habits); }
.hm-legend {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 8px;
  font-size: var(--text-xs); color: var(--ink-faint);
}
.hm-legend i { width: 13px; height: 13px; border-radius: 4px; border: 1.5px solid var(--hairline); display: inline-block; }
.hm-legend i.l1 { background: var(--habits-wash); border-color: var(--habits); }
.hm-legend i.l2 { background: var(--habits-tint); border-color: var(--habits); }
.hm-legend i.l3 { background: var(--habits); border-color: var(--habits); }

.habit-row {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.habit-row .hr-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.habit-row .hr-title { font: var(--type-lead); color: var(--ink); display: flex; align-items: center; gap: 8px; }
.habit-row .hr-dots { display: flex; gap: 6px; }
.habit-row .hr-dots i { flex: 1; height: 8px; border-radius: 999px; background: var(--paper-deep); border: 1px solid var(--hairline); }
.habit-row .hr-dots i.on { background: var(--habits); border-color: var(--habits); }
.habit-row .hr-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* ===========================================================================
   أهداف: دواير التقدم
   =========================================================================== */
.ring-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; }
.ring-card {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 26px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.ring-wrap { position: relative; }
.ring-wrap .ring-center {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--goals-deep);
}
.ring-card .rc-caption { font: var(--type-body); color: var(--ink-muted); text-align: center; }
.ring-card .rc-meta { font: var(--type-label); color: var(--ink); text-align: center; }
.ring-card .rc-update { display: flex; gap: 8px; width: 100%; }

/* ===========================================================================
   فلوس: أعمدة + بنود
   =========================================================================== */
.cat-bars { display: flex; flex-direction: column; gap: 14px; }
.cat-bar .cb-top { display: flex; justify-content: space-between; margin-bottom: 6px; font: var(--type-body); }
.cat-bar .cb-top .cb-amount { color: var(--ink-muted); }
.cat-bar .cb-track {
  height: 12px;
  border-radius: 999px;
  background: var(--paper-deep);
  border: 1px solid var(--hairline);
  overflow: hidden;
}
.cat-bar .cb-fill { height: 100%; border-radius: 999px; background: var(--finances); transition: width var(--dur-slow) var(--ease-soft); }
.cat-bar.health .cb-fill { background: var(--health); }
.cat-bar.goals .cb-fill { background: var(--goals); }
.cat-bar.habits .cb-fill { background: var(--habits); }
.cat-bar.coin .cb-fill { background: var(--coin); }

/* ===========================================================================
   فورمات
   =========================================================================== */
.field {
  font: var(--type-body);
  color: var(--ink);
  background: var(--surface-card);
  border: 1.5px solid var(--hairline-strong);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  outline: none;
  font-family: var(--font-body);
  transition: border-color var(--dur-fast) var(--ease-soft);
  min-width: 0;
}
.field:focus { border-color: var(--brand); }
.field::placeholder { color: var(--ink-faint); }
select.field { cursor: pointer; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.inline-form .grow { flex: 1; min-width: 140px; }

/* ===========================================================================
   تدوينات اليوميات
   =========================================================================== */
.entry-card {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
}
.entry-card .e-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.entry-card .e-date { font: var(--type-label); color: var(--ink); }
.entry-card .e-summary { font: var(--type-body); color: var(--ink); margin: 0 0 8px; }
.entry-card .tags { display: flex; flex-wrap: wrap; gap: 6px; }
.entry-card details { margin-top: 10px; }
.entry-card details summary {
  cursor: pointer; font: var(--type-label); font-size: var(--text-xs); color: var(--ink-faint);
}
.entry-card details p {
  margin: 8px 0 0; font: var(--type-body); font-size: var(--text-sm); color: var(--ink-muted);
  background: var(--paper-deep);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  white-space: pre-wrap;
}
.entries { display: flex; flex-direction: column; gap: 12px; }

/* ===========================================================================
   التقويم والمهام
   =========================================================================== */
.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
  margin-bottom: 8px;
  text-align: center;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--ink-faint);
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-cell {
  position: relative;
  aspect-ratio: 1 / 0.92;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--paper-deep);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: background var(--dur-fast) var(--ease-soft), border-color var(--dur-fast) var(--ease-soft), transform var(--dur-fast) var(--ease-soft);
}
.cal-cell:hover { background: var(--brand-wash); border-color: var(--brand-tint); }
.cal-cell:active { transform: scale(0.95); }
.cal-cell.blank { background: transparent; cursor: default; pointer-events: none; }
.cal-cell.today .cal-num {
  background: var(--brand);
  color: var(--on-accent);
  border-radius: 9px;
  padding: 1px 8px;
}
.cal-cell.sel { border-color: var(--ink); background: var(--surface-card); box-shadow: var(--shadow-sm); }
.cal-dots { display: flex; gap: 3px; min-height: 6px; }
.cd { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.cd.p { background: var(--goals); }
.cd.d { background: var(--finances); }

.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.task-check {
  width: 26px; height: 26px; flex: none;
  border-radius: 9px;
  border: 2px solid var(--goals);
  background: var(--surface-card);
  color: var(--on-accent);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background var(--dur-fast) var(--ease-bounce), transform var(--dur-fast) var(--ease-soft);
}
.task-check:active { transform: scale(0.9); }
.task-row.done .task-check { background: var(--finances); border-color: var(--finances); }
.task-row .task-title { font: var(--type-body); font-weight: 500; color: var(--ink); }
.task-row.done .task-title { text-decoration: line-through; color: var(--ink-faint); }
.task-row .task-note { font-size: var(--text-sm); color: var(--ink-muted); }
.time-chip {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--goals-deep);
  background: var(--goals-wash);
  border: 1px solid var(--goals-tint);
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  white-space: nowrap;
}
.task-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.task-form-row { display: flex; gap: 10px; }
.task-form-row .field { flex: 1; }

/* ===========================================================================
   المحادثات
   =========================================================================== */
.chat-card {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
}
.chat-card .chat-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.chat-card .chat-date { font-size: var(--text-xs); color: var(--ink-faint); }
.bubble {
  position: relative;
  max-width: 88%;
  padding: 10px 14px;
  font: var(--type-body);
  margin-bottom: 8px;
}
.bubble .who { display: block; font-size: var(--text-xs); font-weight: 700; color: var(--ink-faint); margin-bottom: 2px; }
.bubble.user {
  background: var(--surface-card);
  border: 1.5px solid var(--ink);
  border-radius: 18px 18px 18px 6px;
  margin-inline-end: auto;
}
.bubble.ai {
  background: var(--brand-wash);
  border: 1.5px solid var(--brand-tint);
  border-radius: 18px 18px 6px 18px;
  margin-inline-start: auto;
  color: var(--ink);
}
.chats { display: flex; flex-direction: column; gap: 12px; }

/* ===========================================================================
   التقرير الشامل + التحليل
   =========================================================================== */
.report-card { background: linear-gradient(180deg, var(--brand-wash), var(--surface-card) 55%); }
.analysis-result {
  margin-top: 16px;
  background: var(--paper-deep);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  font: var(--type-body);
  color: var(--ink);
}
.analysis-result h4.report-h {
  font: var(--type-h3);
  font-size: var(--text-h4);
  margin: 16px 0 8px;
  color: var(--brand-deep);
}
.analysis-result h4.report-h:first-child { margin-top: 0; }
.analysis-result p { margin: 0 0 8px; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--ink-muted); font: var(--type-body); }
.spinner {
  width: 18px; height: 18px;
  border: 2.5px solid var(--hairline-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===========================================================================
   خريطة الجسم (الصحة)
   =========================================================================== */
.bodymap { display: grid; grid-template-columns: 200px 1fr; gap: 22px; align-items: start; }
.body-svg { width: 100%; max-width: 200px; }
.bodypart {
  fill: var(--paper-deep);
  stroke: var(--hairline-strong);
  stroke-width: 2;
  transition: fill var(--dur-fast) var(--ease-soft);
}
.body-neutral { fill: var(--paper-deep); stroke: var(--hairline-strong); stroke-width: 2; }
.bodypart.hot { fill: var(--health-wash); stroke: var(--health); cursor: pointer; }
.bodypart.hot:hover, .bodypart.picked { fill: var(--health-tint); }
#bodyBadges circle { fill: var(--health); }
#bodyBadges text { fill: var(--on-accent); font: 700 11px var(--font-body); }
.general-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.day-nav { display: flex; align-items: center; gap: 8px; }
.day-label { font: var(--type-label); color: var(--ink); min-width: 130px; text-align: center; }

/* المتابعات */
.cond-card {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
  margin-bottom: 12px;
}
.cond-card .cond-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.cond-card .cond-title { font: var(--type-label); font-size: var(--text-base); color: var(--ink); }
.cond-card .cond-meta { font-size: var(--text-sm); color: var(--ink-muted); margin-bottom: 12px; }
.cond-card .cond-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cond-report { margin-top: 14px; }

/* ===========================================================================
   تكلفة الـAI
   =========================================================================== */
.usage-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }

/* ===========================================================================
   حالات فاضية
   =========================================================================== */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: var(--space-7) var(--space-5);
  color: var(--ink-muted);
}
.empty .empty-doodle { width: 90px; height: 90px; opacity: 0.9; }
.empty h3 { font: var(--type-h3); font-size: var(--text-h4); color: var(--ink); margin: 0; }
.empty p { font: var(--type-body); margin: 0; max-width: 38ch; }
.empty.sm { padding: 22px 14px; }

.muted { color: var(--ink-muted); }
.center { text-align: center; }
.hidden { display: none !important; }

/* ===========================================================================
   مودال التأكيد
   =========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(52, 48, 42, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--surface-card);
  border: var(--stroke) solid var(--ink);
  border-radius: var(--radius-sketch);
  box-shadow: var(--shadow-lg);
  padding: 28px 26px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  animation: modalIn var(--dur-base) var(--ease-bounce);
}
@keyframes modalIn { from { transform: translateY(14px) scale(0.97); } to { transform: translateY(0) scale(1); } }
.modal-icon {
  width: 54px; height: 54px;
  margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  border-radius: 50%;
  background: var(--health-wash);
  border: 1.5px solid var(--health-tint);
}
.modal-title { font: var(--type-h3); font-size: var(--text-h4); margin-bottom: 6px; }
.modal-text { font: var(--type-body); font-size: var(--text-sm); color: var(--ink-muted); margin: 0 0 20px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

/* ===========================================================================
   صفحة الدخول
   =========================================================================== */
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  position: relative;
  width: 100%;
  max-width: 410px;
  background: var(--surface-card);
  border: var(--stroke) solid var(--ink);
  border-radius: var(--radius-sketch);
  box-shadow: var(--shadow-lg);
  padding: 38px 32px 26px;
  text-align: center;
}
.auth-card .auth-logo { height: 52px; margin-bottom: 6px; }
.auth-sub { color: var(--ink-muted); margin: 10px 0 24px; font-size: var(--text-sm); }
.auth-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  background: var(--paper-deep);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 5px;
}
.auth-tab {
  flex: 1;
  padding: 9px 10px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-soft), color var(--dur-fast) var(--ease-soft);
}
.auth-tab.active { background: var(--brand); color: var(--on-accent); box-shadow: var(--shadow-sm); }
/* خانة الاسم بتتفتح بنعومة في وضع "حساب جديد" (collapse) */
.auth-collapse {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height var(--dur-base) var(--ease-soft), opacity var(--dur-fast) var(--ease-soft), margin var(--dur-base) var(--ease-soft);
}
.auth-collapse.show { max-height: 92px; opacity: 1; margin-bottom: 14px; }
.auth-form { text-align: right; }
.auth-form label { display: block; font: var(--type-label); color: var(--ink-muted); margin-bottom: 8px; }
.auth-form .field { width: 100%; padding: 12px 14px; }
.auth-form .remember {
  display: flex; align-items: center; gap: 8px;
  margin: 16px 0 20px;
  font-size: var(--text-sm); color: var(--ink-muted);
  cursor: pointer;
}
.auth-form .remember input { accent-color: var(--brand); width: 16px; height: 16px; }
.auth-form button[type="submit"] { width: 100%; justify-content: center; }
.auth-error {
  margin-top: 14px;
  color: var(--danger-deep);
  background: var(--health-wash);
  border: 1px solid var(--health-tint);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: var(--text-sm);
}
.auth-foot { margin-top: 22px; font-size: var(--text-xs); color: var(--ink-faint); }

/* ===========================================================================
   ريسبونسف
   =========================================================================== */
.dash-scrim { display: none; }

@media (max-width: 1000px) {
  .grid-2-side, .grid-2-equal { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .dw-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 40;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    background: color-mix(in srgb, var(--paper) 85%, transparent);
    backdrop-filter: blur(12px) saturate(1.3);
    -webkit-backdrop-filter: blur(12px) saturate(1.3);
    border-bottom: 1px solid var(--hairline);
  }
  .dw-topbar img { height: 30px; }
  .dw-topbar .menu-btn {
    border: none; background: transparent; cursor: pointer;
    color: var(--ink); font-size: 22px; padding: 4px 8px;
  }
  /* الدرج بييجي من اليمين (inline-start في RTL) ويستخبى بره الشاشة يمين */
  .dw-sidebar {
    position: fixed;
    inset-inline-start: 0;
    inset-inline-end: auto;
    top: 0;
    height: 100dvh;
    padding-top: calc(24px + env(safe-area-inset-top));
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    transform: translateX(100%);
    transition: transform var(--dur-base) var(--ease-soft);
    box-shadow: var(--shadow-lg);
  }
  .dw-sidebar.open { transform: translateX(0); }
  .dash-scrim.show {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(52, 48, 42, 0.32);
    z-index: 55;
  }
  .bodymap { grid-template-columns: 1fr; }
  .body-svg { margin: 0 auto; display: block; }
  .page-head { align-items: flex-start; flex-direction: column; }

  /* المحتوى ياخد مساحة من تحت عشان الشريط السفلي ميغطّيهوش */
  .dw-main { padding: 18px 16px calc(88px + env(safe-area-inset-bottom)); }

  /* ===== شريط التابات السفلي — إحساس تطبيق نيتيف ===== */
  .dw-tabbar {
    display: flex;
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 50;
    gap: 2px;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface-card) 90%, transparent);
    backdrop-filter: blur(18px) saturate(1.5);
    -webkit-backdrop-filter: blur(18px) saturate(1.5);
    border-top: 1px solid var(--hairline);
  }
  .tabbar-btn {
    flex: 1; min-width: 0;
    border: none; background: transparent; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 0; color: var(--ink-faint);
    -webkit-tap-highlight-color: transparent;
    transition: color var(--dur-fast) var(--ease-soft), transform var(--dur-fast) var(--ease-soft);
  }
  .tabbar-btn:active { transform: scale(0.92); }
  .tabbar-btn .tb-ico {
    display: inline-flex; align-items: center; justify-content: center;
    width: 56px; max-width: 100%; height: 30px;
    border-radius: 999px;
    transition: background var(--dur-base) var(--ease-soft);
  }
  .tabbar-btn .tb-label { font: 700 10.5px/1 var(--font-body); letter-spacing: -0.01em; }
  .tabbar-btn[data-active="true"]                  { color: var(--brand-deep); }
  .tabbar-btn[data-active="true"] .tb-ico          { background: var(--brand-wash); }
  .tabbar-btn.health[data-active="true"]           { color: var(--health-deep); }
  .tabbar-btn.health[data-active="true"] .tb-ico   { background: var(--health-wash); }
  .tabbar-btn.habits[data-active="true"]           { color: var(--habits-deep); }
  .tabbar-btn.habits[data-active="true"] .tb-ico   { background: var(--habits-wash); }
  .tabbar-btn.goals[data-active="true"]            { color: var(--goals-deep); }
  .tabbar-btn.goals[data-active="true"] .tb-ico    { background: var(--goals-wash); }
  .tabbar-btn.finances[data-active="true"]         { color: var(--finances-deep); }
  .tabbar-btn.finances[data-active="true"] .tb-ico { background: var(--finances-wash); }

  /* ===== إحكام الموبايل — أصغر وأقل اسكرول ===== */
  .dw-main { padding: 14px 14px calc(84px + env(safe-area-inset-bottom)); }
  .page-head { margin-bottom: 12px; }
  .page-head h1 { font-size: clamp(19px, 5.4vw, 23px); line-height: 1.25; }
  .page-head .ph-sub { font-size: var(--text-sm); line-height: 1.5; margin-top: 2px; }
  .section-title { font-size: clamp(17px, 4.8vw, 20px); margin: 2px 0 10px; }
  .world-pill { font-size: var(--text-xs); padding: 3px 10px; margin-bottom: 6px; }
  .card { padding: 14px; }
  .card-head { margin-bottom: 10px; }
  .card-head h3 { font-size: var(--text-h4); }
  .stat-grid { gap: 10px; }
  .stat-card { padding: 12px; }
  .stat-card .sc-top { margin-bottom: 6px; }
  .stat-card .sc-value b { font-size: 1.5rem; }
  .stat-card .sc-ico { width: 30px; height: 30px; font-size: 14px; }
  /* العوالم الأربعة: شبكة 2×2 بدل عمود واحد — بتقصّر الاسكرول كتير */
  .world-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px !important; }
  .world-card .wc-art { min-height: 78px; padding: 10px; }
  .world-card .wc-art img { width: 62px; height: 62px; }
  .world-card .wc-body { padding: 10px 12px 12px; }
  .world-card .wc-tag { font-size: var(--text-xs); padding: 2px 8px; margin-bottom: 5px; }
  .world-card .wc-metric { font-size: var(--text-lg); }
  .world-card .wc-caption { font-size: var(--text-xs); line-height: 1.4; }
  .composer { padding: 13px; margin-bottom: 16px !important; }
  .stack { gap: 14px; }
  .list { gap: 8px; }
  .streak-head b { font-size: 1.5rem; }
}

/* ===========================================================================
   تسجيل الصوت من الكومبوزر
   =========================================================================== */
.rec-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--health-wash);
  border: 1.5px solid var(--health-tint);
  border-radius: var(--radius-md);
}
.rec-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--health);
  flex: none;
  animation: recPulse 1s ease-in-out infinite;
}
@keyframes recPulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.8); } }
.rec-time { font-family: var(--font-display); font-weight: 700; color: var(--health-deep); min-width: 42px; }
.rec-wave { display: inline-flex; align-items: center; gap: 3px; flex: 1; height: 24px; }
.rec-wave i {
  flex: 1; max-width: 4px;
  background: var(--health);
  border-radius: 99px;
  height: 30%;
  animation: recWave 0.9s ease-in-out infinite;
}
.rec-wave i:nth-child(2) { animation-delay: 0.15s; }
.rec-wave i:nth-child(3) { animation-delay: 0.3s; }
.rec-wave i:nth-child(4) { animation-delay: 0.45s; }
.rec-wave i:nth-child(5) { animation-delay: 0.6s; }
.rec-wave i:nth-child(6) { animation-delay: 0.75s; }
.rec-wave i:nth-child(7) { animation-delay: 0.5s; }
.rec-wave i:nth-child(8) { animation-delay: 0.2s; }
.rec-wave i:nth-child(9) { animation-delay: 0.35s; }
@keyframes recWave { 0%, 100% { height: 25%; } 50% { height: 90%; } }
/* الموجة الحيّة: JS بيحرّك كل عمود بـ scaleY حسب مستوى صوتك الحقيقي */
.rec-wave.live i {
  animation: none;
  height: 100%;
  transform-origin: center;
  transform: scaleY(0.12);
  transition: transform 0.08s ease-out;
}
.rec-actions { display: flex; gap: 8px; flex: none; }
/* على الموبايل: الموجة فوق، والزراير في سطر كامل تحتها — عشان مايطفحش */
@media (max-width: 760px) {
  .rec-bar { flex-wrap: wrap; gap: 8px 10px; }
  .rec-bar .rec-wave { min-width: 70px; }
  .rec-actions { flex: 1 1 100%; }
  .rec-actions .btn { flex: 1; }
}

/* ===========================================================================
   زرار التحديث + زرار الصوت العائم + شيت الشات
   =========================================================================== */
[data-refresh].spinning svg { animation: spin360 0.7s var(--ease-soft); }
@keyframes spin360 { to { transform: rotate(-360deg); } }

.voice-fab {
  position: fixed; z-index: 70;
  inset-inline-start: 20px; bottom: 24px;
  width: 60px; height: 60px;
  border: none; border-radius: 50%;
  background: var(--brand); color: var(--on-accent);
  box-shadow: 0 10px 26px rgba(92,138,107,.45), var(--shadow-md);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: transform var(--dur-base) var(--ease-bounce), opacity var(--dur-fast);
  animation: fabIn var(--dur-base) var(--ease-bounce) both;
}
.voice-fab::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  border: 2px solid var(--brand); pointer-events: none;
  animation: fabPulse 2.6s ease-out infinite;
}
.voice-fab:hover { transform: translateY(-3px) scale(1.05); }
.voice-fab:active { transform: scale(0.93); }
.voice-fab.hidden { opacity: 0; pointer-events: none; transform: scale(0.55); }
@keyframes fabIn { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes fabPulse { 0% { transform: scale(1); opacity: .4; } 100% { transform: scale(1.55); opacity: 0; } }

.chat-scrim {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(52,48,42,.4);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-soft);
}
.chat-scrim.show { opacity: 1; pointer-events: auto; }

.chat-sheet {
  position: fixed; z-index: 85;
  inset-inline: 0; bottom: 0; margin: 0 auto;
  width: 100%; max-width: 560px; max-height: 88vh;
  display: flex; flex-direction: column;
  background: var(--paper);
  border: var(--stroke) solid var(--ink); border-bottom: none;
  border-radius: 26px 26px 0 0;
  box-shadow: var(--shadow-lg);
  transform: translateY(106%);
  transition: transform var(--dur-base) var(--ease-bounce);
  padding-bottom: env(safe-area-inset-bottom);
}
.chat-sheet.open { transform: translateY(0); }
.chat-sheet-head { padding: 10px 18px 14px; border-bottom: 1px solid var(--hairline); }
.chat-grip { display: block; width: 42px; height: 5px; border-radius: 99px; background: var(--hairline); margin: 2px auto 12px; }
.chat-head-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chat-head-row b { font: var(--type-h3); font-size: var(--text-h4); margin: 0; }
.chat-sub { display: block; font-size: var(--text-sm); color: var(--ink-muted); margin-top: 4px; }
.chat-sheet-body { padding: 16px 18px 20px; overflow-y: auto; }
.chat-sheet-body .composer { margin: 0 !important; }

@media (max-width: 760px) {
  .voice-fab { bottom: calc(82px + env(safe-area-inset-bottom)); inset-inline-start: 16px; width: 56px; height: 56px; }
}

/* ===========================================================================
   الجولة التعريفية (أول مرة)
   =========================================================================== */
.tour-ov { position: fixed; inset: 0; z-index: 9997; animation: tourFade .25s var(--ease-soft); }
@keyframes tourFade { from { opacity: 0; } to { opacity: 1; } }
.tour-ring {
  position: fixed; z-index: 9998; pointer-events: none;
  border-radius: 16px;
  border: 2px solid var(--on-accent);
  box-shadow: 0 0 0 9999px rgba(40,36,32,.62);
  transition: top .3s var(--ease-soft), left .3s var(--ease-soft), width .3s var(--ease-soft), height .3s var(--ease-soft);
}
.tour-card {
  position: fixed; z-index: 9999;
  left: 50%; transform: translateX(-50%);
  width: min(340px, calc(100vw - 32px));
  background: var(--paper);
  border: var(--stroke) solid var(--ink);
  border-radius: 20px; box-shadow: var(--shadow-lg);
  padding: 20px; text-align: center;
}
.tour-card.centered { top: 50%; transform: translate(-50%, -50%); }
.tour-ico { font-size: 34px; margin-bottom: 6px; }
.tour-card h3 { font: var(--type-h3); font-size: var(--text-h4); margin: 0 0 6px; }
.tour-card p { font-size: var(--text-sm); color: var(--ink-muted); line-height: 1.7; margin: 0 0 16px; }
.tour-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tour-skip { background: none; border: none; color: var(--ink-faint); font: var(--type-label); cursor: pointer; padding: 4px; }
.tour-dots { display: flex; gap: 6px; }
.tour-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--hairline); transition: background var(--dur-fast); }
.tour-dot.on { background: var(--brand); }

/* ===== سحب لتحت للتحديث ===== */
.ptr-ind {
  position: fixed; top: 6px; left: 50%;
  transform: translateX(-50%);
  z-index: 75; opacity: 0; pointer-events: none;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .2s var(--ease-soft);
}
.ptr-ind .ptr-spin {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid var(--brand-tint); border-top-color: var(--brand);
}
.ptr-ind.ready .ptr-spin { border-top-color: var(--brand-deep); }
.ptr-ind.spinning .ptr-spin { animation: ptrSpin .7s linear infinite; }
@keyframes ptrSpin { to { transform: rotate(360deg); } }

/* ===== سجل تفاصيل الهدف ===== */
.rc-tap { cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.rc-hint { font-size: var(--text-xs); color: var(--goals-deep); font-weight: 700; margin-top: 2px; opacity: .85; }
.gl-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.gl-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px;
  background: var(--goals-wash);
}
.gl-delta { font-family: var(--font-display); font-weight: 700; font-size: var(--text-lg); flex: none; min-width: 64px; }
.gl-delta.pos { color: var(--goals-deep); }
.gl-delta.neg { color: var(--health-deep); }
.gl-mid { flex: 1; min-width: 0; }
.gl-note { font-size: var(--text-sm); color: var(--ink); }
.gl-date { font-size: var(--text-xs); color: var(--ink-faint); margin-top: 2px; }
.gl-after { font-size: var(--text-xs); color: var(--ink-muted); flex: none; }
@media (prefers-reduced-motion: reduce) { .rec-dot, .rec-wave i { animation: none; } }

/* ===========================================================================
   الجرس + لوحة الإشعارات
   =========================================================================== */
.topbar-actions { display: flex; align-items: center; gap: 4px; }

.bell-btn {
  position: relative;
  border: none; background: transparent; cursor: pointer;
  color: var(--ink); padding: 7px; border-radius: var(--radius-pill);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.bell-btn:hover { background: var(--brand-wash); color: var(--brand-deep); }
.bell-badge {
  position: absolute; top: 0; inset-inline-end: 0;
  min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--health); color: #fff;
  border: 2px solid var(--paper);
  border-radius: 999px;
  font: 700 10px/1 var(--font-body);
  display: flex; align-items: center; justify-content: center;
}
.bell-badge.hidden { display: none; }

/* جرس السايدبار (ديسكتوب) */
.side-bell { color: var(--ink-muted); }
.side-bell:hover { color: var(--brand-deep); }
.side-bell .bell-badge { border-color: var(--paper-deep); }

.notif-scrim { display: none; position: fixed; inset: 0; background: rgba(52,48,42,.3); z-index: 90; }
.notif-scrim.show { display: block; }

.notif-panel {
  position: fixed; z-index: 95;
  top: 14px; inset-inline-end: 14px;
  width: min(390px, calc(100vw - 28px));
  max-height: min(76vh, 640px);
  display: flex; flex-direction: column;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  transform: translateY(-14px) scale(.97); opacity: 0; pointer-events: none;
  transition: transform var(--dur-base) var(--ease-bounce), opacity var(--dur-fast);
}
.notif-panel.open { transform: translateY(0) scale(1); opacity: 1; pointer-events: auto; }

.notif-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 18px 12px; border-bottom: 1px solid var(--hairline);
}
.notif-head h3 { font: var(--type-h3); font-size: var(--text-h4); margin: 0; }
.notif-head-actions { display: flex; align-items: center; gap: 6px; }
.notif-mark { all: unset; cursor: pointer; font: var(--type-label); font-size: var(--text-xs); color: var(--brand-deep); padding: 4px 6px; border-radius: var(--radius-pill); }
.notif-mark:hover { background: var(--brand-wash); }

.notif-push {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 12px 12px 4px; padding: 12px 14px;
  background: var(--brand-wash); border-radius: 14px;
}
.notif-push.hidden { display: none; }
.notif-push b { display: block; font-size: var(--text-sm); margin-bottom: 2px; }
.notif-push span { font-size: var(--text-xs); color: var(--ink-muted); }
.notif-push .btn { flex: none; }

.notif-list { overflow-y: auto; padding: 8px; }
.notif-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px; border-radius: 14px;
  cursor: pointer; transition: background var(--dur-fast);
}
.notif-item:hover { background: var(--brand-wash); }
.notif-item.unread { background: color-mix(in srgb, var(--brand-wash) 65%, transparent); }
.notif-item .ni-ico { font-size: 22px; flex: none; line-height: 1.25; }
.notif-item .ni-body { flex: 1; min-width: 0; }
.notif-item .ni-title { font-weight: 700; font-size: var(--text-sm); margin-bottom: 2px; }
.notif-item .ni-text { font-size: var(--text-sm); color: var(--ink-muted); line-height: 1.5; word-break: break-word; }
.notif-item .ni-time { font-size: var(--text-xs); color: var(--ink-faint); margin-top: 5px; }
.notif-item .ni-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--health); flex: none; margin-top: 7px; }
.notif-empty { text-align: center; color: var(--ink-faint); font-size: var(--text-sm); padding: 44px 16px; }

@media (max-width: 760px) {
  .notif-panel { top: 8px; inset-inline-end: 8px; inset-inline-start: 8px; width: auto; }
}
