/* ===========================================================================
   دوّنلي — هوية "دفتر" (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;

  /* ---- الموديولز الجديدة: أفكار (دماغك) + مشاكل (قلبك) ---- */
  --ideas:         #7C6BC9;
  --ideas-deep:    #5B4CA0;
  --ideas-tint:    #D9D2F0;
  --ideas-wash:    #ECE8F8;

  --problems:      #D06A8C;
  --problems-deep: #A84668;
  --problems-tint: #F2CEDB;
  --problems-wash: #FBE9F0;

  --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%; overflow-x: hidden; }

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;
  /* شبكة أمان: أي محتوى نص طويل (لينك/رقم/كلمة من غير مسافات) ميدفعش الصفحة أفقيًا
     فتتزنق في عمود على الجنب في RTL. مع ده overflow-wrap على حاويات النص. */
  overflow-x: hidden;
}

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); max-width: 1400px; margin-inline: auto; }

.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: 6px;
  padding: 14px 8px 4px;
  border-top: 1px solid var(--hairline);
}
.side-user > div { flex: 1; min-width: 0; } /* كتلة الاسم تتقلّص وتتقصّ بدل ما تزقّ الأيقونات */
.side-user .side-bell, .side-user .su-logout { flex: none; }
.side-user .side-bell { width: 32px; height: 32px; padding: 0; }
.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; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .su-sub { font-size: var(--text-xs); color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.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%;
  /* بيملا المساحة جنب السايدبار جوه التطبيق الموسّط — مفيش فجوة ولا لزقة على ناحية. */
}

/* توب بار + شريط تابات الموبايل — متخفيين على الديسكتوب */
.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); }
.world-pill.ideas    { color: var(--ideas-deep);    background: var(--ideas-wash); }
.world-pill.problems { color: var(--problems-deep); background: var(--problems-wash); }

/* ===================== الموديولز الجديدة (أفكار + مشاكل) ===================== */
.btn.ideas        { background: var(--ideas);    border-color: var(--ideas-deep); }
.btn.ideas:hover  { background: var(--ideas-deep); }
.btn.problems       { background: var(--problems); border-color: var(--problems-deep); }
.btn.problems:hover { background: var(--problems-deep); }
.chip.ideas    { color: var(--ideas-deep);    background: var(--ideas-wash);    border-color: var(--ideas); }
.chip.problems { color: var(--problems-deep); background: var(--problems-wash); border-color: var(--problems); }
.badge.ideas       { color: var(--ideas-deep); background: var(--ideas-wash); }
.badge.ideas .dot  { background: var(--ideas); }
.nav-btn.ideas[data-active="true"]    { color: var(--ideas-deep);    background: var(--ideas-wash);    box-shadow: inset 3px 0 0 var(--ideas); }
.nav-btn.problems[data-active="true"] { color: var(--problems-deep); background: var(--problems-wash); box-shadow: inset 3px 0 0 var(--problems); }

/* كروت الأفكار */
.ideas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.idea-card {
  background: var(--surface-card);
  border: 1.5px solid var(--ideas-tint);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.idea-card.done { opacity: 0.7; }
.idea-card.done .ic-title { text-decoration: line-through; text-decoration-color: var(--ideas-tint); }
.ic-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.ic-title { font-weight: 700; line-height: 1.4; }
.ic-detail { margin: 0; color: var(--ink-muted); font-size: var(--text-sm); }
.ic-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.ic-actions { display: flex; gap: 6px; align-items: center; }

/* كروت المشاكل */
.problems-list { display: flex; flex-direction: column; gap: 14px; }
.problem-card {
  background: var(--surface-card);
  border: 1.5px solid var(--hairline);
  border-inline-start: 4px solid var(--problems);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.problem-card.working  { border-inline-start-color: var(--warning); }
.problem-card.resolved { border-inline-start-color: var(--success); opacity: 0.7; }
.problem-card.resolved .pc-title { text-decoration: line-through; text-decoration-color: var(--success); }
.pc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.pc-title { font-weight: 700; line-height: 1.4; }
.pc-detail { margin: 0; color: var(--ink-muted); font-size: var(--text-sm); }
.pc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.pc-actions { display: flex; gap: 6px; align-items: center; }

/* شيت «أقسام أكتر» (موبايل) */
.more-sheet {
  /* z-index لازم يبقى فوق الـ scrim (chat-scrim = 80) زي ما .chat-sheet (85) فوقه —
     كان 60 تحت الـ scrim فالضغطات كانت بتروح للـ scrim ويقفل الشيت = "مش بيجيب بيانات". */
  position: fixed; inset-inline: 0; bottom: 0; z-index: 85;
  background: var(--surface-card);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -12px 40px rgba(40, 36, 32, .18);
  transform: translateY(115%);
  transition: transform .32s var(--ease-pen);
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 560px; margin-inline: auto;
}
.more-sheet.open { transform: translateY(0); }
.more-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 8px 16px 16px; }
.more-item {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 18px 12px;
  background: var(--paper);
  border: 1.5px solid var(--hairline);
  border-radius: 16px;
  font: 700 var(--text-sm)/1.2 var(--font-body);
  color: var(--ink); cursor: pointer;
  transition: transform .12s ease;
}
.more-item:active { transform: scale(.95); }
.more-item .mi-ico { font-size: 26px; }
.more-item.ideas    { border-color: var(--ideas-tint); }
.more-item.problems { border-color: var(--problems-tint); }
.more-sec { grid-column: 1 / -1; font: var(--type-label); color: var(--ink-muted); margin: 4px 2px -2px; }

/* شريط مقسّم (هَب دفترك) */
.seg-bar { display: flex; gap: 6px; background: var(--paper-deep, var(--surface-2, var(--surface-card))); padding: 5px; border-radius: 14px; margin-bottom: 18px; overflow-x: auto; border: 1px solid var(--hairline); }
.seg-btn { flex: 1; white-space: nowrap; border: none; background: transparent; cursor: pointer; padding: 10px 12px; border-radius: 10px; font: 700 var(--text-sm)/1 var(--font-body); color: var(--ink-muted); transition: background .15s ease, color .15s ease; }
.seg-btn[data-active="true"] { background: var(--surface-card); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.seg-btn:active { transform: scale(.97); }
/* الأقسام جوّه الهَب: نشيل أي مسافة علوية زيادة */
#dafterMount > section { display: block; }
#dafterMount > section .page-head { margin-top: 0; }

/* صفحة تفاصيل تكلفة الـ AI */
.aicost-list { display: flex; flex-direction: column; gap: 8px; }
.aicost-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; background: var(--surface-card); border: 1.5px solid var(--hairline); border-radius: var(--radius-md); }
.ac-left { display: flex; flex-direction: column; gap: 2px; }
.ac-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; white-space: nowrap; }
.ac-right b { color: var(--finances-deep); }
#costChip { cursor: pointer; }
#costChip:hover { filter: brightness(.96); }

/* دخلك شهريًا (مقارنة) */
.inc-now { display: flex; flex-direction: column; gap: 2px; margin-bottom: 14px; }
.inc-now-val { font-family: var(--font-display); font-weight: 800; font-size: 26px; color: var(--finances-deep); }
.inc-bars { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; height: 130px; }
.inc-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.inc-col-val { font-size: 10px; color: var(--ink-muted); white-space: nowrap; }
.inc-bar-track { width: 100%; max-width: 34px; flex: 1; display: flex; align-items: flex-end; background: var(--paper-deep, var(--surface-card)); border-radius: 8px; overflow: hidden; }
.inc-bar-fill { width: 100%; background: var(--finances-tint, var(--finances)); border-radius: 8px 8px 0 0; transition: height .4s var(--ease-soft, ease); }
.inc-bar-fill.now { background: var(--finances); }
.inc-col-lbl { font-size: var(--text-xs); color: var(--ink-muted); }

/* صفحة «دوّنلي يعرف عنك» — كروت الأساسيات */
.about-core { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 18px; }
.ac-core-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--surface-card); border: 1.5px solid var(--hairline); border-radius: var(--radius-md); }
.ac-core-card.missing { border-style: dashed; background: var(--paper); }
.acc-ico { font-size: 26px; }
.acc-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.acc-label { font: var(--type-label); color: var(--ink-muted); }
.acc-val { font-weight: 800; overflow-wrap: anywhere; }

/* بوب-اب تفاصيل المهمة/الهدف + الموارد */
.td-sec { margin-bottom: 14px; }
.td-label { display: block; font: var(--type-label); color: var(--ink-muted); margin-bottom: 4px; }
.td-sec p { margin: 0; line-height: 1.7; overflow-wrap: anywhere; }
.td-res { white-space: pre-wrap; line-height: 1.8; overflow-wrap: anywhere; background: var(--paper); border: 1px solid var(--hairline); border-radius: var(--radius-sm, 10px); padding: 10px 12px; }
.td-res a { color: var(--finances-deep); text-decoration: underline; word-break: break-all; }
.res-dot { font-size: 12px; opacity: .7; }
.chk-inline { display: inline-flex; align-items: center; gap: 5px; font-size: var(--text-sm); color: var(--ink-muted); white-space: nowrap; cursor: pointer; }
.chk-inline input { width: 15px; height: 15px; }

/* ===================== اسأل دوّنلي (شات سياقي) ===================== */
.ask-scope { display: flex; gap: 8px; align-items: center; }
.ask-thread {
  min-height: 180px; max-height: 54vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
  padding: 6px 2px; margin-bottom: 12px;
}
.ask-empty { color: var(--ink-muted); font-size: var(--text-sm); text-align: center; padding: 28px 16px; line-height: 1.8; }
.ask-bubble {
  max-width: 86%; padding: 10px 14px; border-radius: 16px;
  line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
}
.ask-bubble.user { align-self: flex-start; background: var(--brand); color: var(--on-accent); border-bottom-right-radius: 5px; }
.ask-bubble.assistant { align-self: flex-end; background: var(--surface-card); border: 1.5px solid var(--hairline); border-bottom-left-radius: 5px; }
.ask-input { display: flex; gap: 8px; align-items: center; }
.ask-input .field { flex: 1; }
#askMic { flex: none; }
#askMic.recording { background: var(--danger); border-color: var(--danger-deep); color: #fff; animation: askPulse 1.2s infinite; }
@keyframes askPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(224, 112, 92, .5); } 50% { box-shadow: 0 0 0 8px rgba(224, 112, 92, 0); } }
.tts-btn { background: none; border: 0; cursor: pointer; font-size: 14px; opacity: .55; padding: 0 2px; vertical-align: middle; line-height: 1; }
.tts-btn:hover { opacity: 1; }
#askCallBtn { flex: none; }

/* وضع المكالمة الصوتية المباشرة */
.ask-call {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 22px 16px; text-align: center;
  background: linear-gradient(160deg, var(--surface-card), var(--paper));
  border: 1.5px solid var(--hairline); border-radius: var(--radius-md); margin-bottom: 12px;
}
.ask-call.hidden { display: none; }
.call-orb {
  width: 96px; height: 96px; border-radius: 50%; border: none; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, var(--brand), var(--finances-deep, #3c6b4f));
  box-shadow: 0 8px 26px rgba(92,138,107,.5);
  position: relative; -webkit-tap-highlight-color: transparent;
  transition: transform var(--dur-fast);
}
.call-orb:active { transform: scale(.95); }
.call-orb::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 2px solid var(--brand); opacity: 0;
}
.call-orb.listening { background: radial-gradient(circle at 35% 30%, #6db38a, var(--brand)); }
.call-orb.listening::after { animation: callPulse 1.5s ease-out infinite; }
.call-orb.thinking { background: radial-gradient(circle at 35% 30%, #d9b15a, #b5852f); animation: callThink 1s ease-in-out infinite; }
.call-orb.speaking { background: radial-gradient(circle at 35% 30%, #6aa0d8, #3b6fb0); }
.call-orb.speaking::after { animation: callPulse 1.1s ease-out infinite; border-color: #6aa0d8; }
@keyframes callPulse { 0% { transform: scale(1); opacity: .55; } 100% { transform: scale(1.5); opacity: 0; } }
@keyframes callThink { 0%, 100% { transform: scale(1); } 50% { transform: scale(.92); } }
.call-status { font-weight: 700; font-size: var(--text-base); color: var(--ink); }
.call-caption { min-height: 20px; font-size: var(--text-sm); color: var(--ink-muted); line-height: 1.6; max-width: 90%; }

/* ===================== مركز الملفات ===================== */
.file-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 26px; border: 2px dashed var(--hairline-strong); border-radius: var(--radius-md);
  cursor: pointer; color: var(--ink-muted); text-align: center; font-size: var(--text-sm);
  transition: border-color var(--dur-fast) var(--ease-soft), background var(--dur-fast) var(--ease-soft);
}
.file-drop:hover { border-color: var(--brand); background: var(--brand-wash); color: var(--brand-deep); }
.file-drop .fd-ico { font-size: 30px; }
.files-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.file-card {
  background: var(--surface-card); border: 1.5px solid var(--hairline);
  border-radius: var(--radius-md); overflow: hidden;
  display: flex; flex-direction: column;
}
.fc-thumb {
  display: flex; align-items: center; justify-content: center;
  height: 128px; background: var(--paper-deep); overflow: hidden;
}
.fc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.fc-thumb .fc-ico { font-size: 44px; }
.fc-body { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.fc-name { font-size: var(--text-sm); font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; word-break: break-word; }
.fc-foot { display: flex; align-items: center; justify-content: space-between; }
.fc-date { font-size: var(--text-xs); color: var(--ink-faint); }

/* ===================== مودال التعديل الموحّد ===================== */
.edit-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.edit-form { display: flex; flex-direction: column; gap: 12px; }
.ef-row { display: flex; flex-direction: column; gap: 6px; }
.ef-row > span { font: var(--type-label); color: var(--ink-muted); }
.ef-row .field { width: 100%; }
.ef-row textarea.field { resize: vertical; min-height: 72px; line-height: 1.6; }
.ef-actions { display: flex; gap: 10px; justify-content: flex-start; margin-top: 6px; }
.ef-actions .btn { flex: 1; justify-content: center; }

/* ===================== فلاتر + تحميل المزيد + ميزانية الشهر ===================== */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.filter-bar .field { padding: 8px 12px; font-size: var(--text-sm); }
.filter-meta { font-size: var(--text-sm); color: var(--ink-muted); margin: 0 2px 10px; }
.load-more { display: flex; justify-content: center; margin-top: 12px; }

.files-filter { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-chip {
  border: 1.5px solid var(--hairline); background: var(--surface-card);
  border-radius: var(--radius-pill); padding: 6px 14px;
  font: 700 var(--text-sm)/1 var(--font-body); color: var(--ink-muted); cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-soft), background var(--dur-fast) var(--ease-soft), color var(--dur-fast) var(--ease-soft);
}
.filter-chip:hover { border-color: var(--brand-tint); }
.filter-chip.on { background: var(--brand-wash); border-color: var(--brand); color: var(--brand-deep); }

.budget-card .budget-row { margin-bottom: 16px; }
.budget-card .budget-row:last-child { margin-bottom: 0; }
.br-label { display: block; font: var(--type-label); color: var(--ink-muted); margin-bottom: 8px; }
.bb-track { height: 12px; background: var(--paper-deep); border-radius: var(--radius-pill); overflow: hidden; }
.bb-fill { height: 100%; border-radius: var(--radius-pill); background: var(--finances); transition: width var(--dur-draw) var(--ease-pen); }
.budget-bar.warn .bb-fill { background: var(--warning); }
.budget-bar.danger .bb-fill { background: var(--danger); }
.bb-meta { display: flex; justify-content: space-between; margin-top: 6px; font-size: var(--text-sm); color: var(--ink-muted); }
.bb-alert { margin-top: 8px; padding: 8px 12px; border-radius: var(--radius-sm); font-size: var(--text-sm); font-weight: 700; }
.bb-alert.danger { color: var(--danger-deep); background: var(--health-wash); }
.bb-alert.warn { color: var(--habits-deep); background: var(--habits-wash); }

/* ===================== الأصول ===================== */
.assets-total {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  padding: 18px 22px;
  background: linear-gradient(120deg, var(--finances-wash), var(--surface-card));
  border: 1.5px solid var(--finances-tint);
  border-radius: var(--radius-md);
}
.at-main { display: flex; flex-direction: column; gap: 2px; }
.at-label { font: var(--type-label); color: var(--ink-muted); }
.at-value { font-family: var(--font-display); font-weight: 800; font-size: 28px; color: var(--finances-deep); }
.at-sub-main { display: flex; flex-direction: column; gap: 1px; margin-top: 6px; padding-top: 8px; border-top: 1px dashed var(--finances-tint); }
.at-value2 { font-family: var(--font-display); font-weight: 800; font-size: 20px; color: var(--ink); }
.at-breakdown { display: flex; gap: 14px; flex-wrap: wrap; font-size: var(--text-sm); color: var(--ink-muted); margin-top: 8px; }
.assets-market { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: var(--text-sm); color: var(--ink-muted); padding: 0 4px; }
.assets-market b { color: var(--ink); }
.asset-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.asset-form .field { flex: 1; min-width: 110px; }
.assets-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.asset-card {
  background: var(--surface-card); border: 1.5px solid var(--hairline);
  border-right: 3px solid var(--finances); border-radius: var(--radius-md); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.asset-card.asset-gold { border-right-color: var(--coin); }
.asset-card.asset-other { border-right-color: var(--goals); }
.asset-card.asset-liability { border-right-color: var(--danger); background: var(--health-wash, var(--surface-card)); }
.asset-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.asset-name { font-weight: 800; }
.asset-val { font-weight: 900; color: var(--finances-deep); white-space: nowrap; }
.asset-val.neg { color: var(--danger-deep); }
.asset-mid { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.asset-detail { font-size: var(--text-sm); color: var(--ink-muted); overflow-wrap: anywhere; }
/* قايمة بنود الدهب تحت الكارت */
.asset-items { list-style: none; margin: 4px 0 0; padding: 8px 0 0; border-top: 1px dashed var(--hairline); display: flex; flex-direction: column; gap: 6px; }
.asset-items li { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: var(--text-sm); }
.asset-items li b { color: var(--coin-deep, var(--finances-deep)); white-space: nowrap; }
.at-neg { color: var(--danger-deep) !important; }
/* repeater بنود الدهب في الفورم */
.asset-gold-box { width: 100%; margin-top: 10px; padding: 10px 12px; border: 1.5px dashed var(--coin); border-radius: var(--radius-md); background: var(--paper); }
.agb-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-size: var(--text-sm); font-weight: 700; color: var(--ink-muted); }
.agb-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.agb-row .gi-g { flex: 1.4; min-width: 70px; }
.agb-row .gi-k { flex: 1.2; min-width: 80px; }
.agb-row .gi-n { flex: 1; min-width: 60px; }
.agb-row .gi-del { flex: none; color: var(--danger-deep); }
.asset-goal { display: flex; flex-direction: column; gap: 4px; }
.asset-goal .ag-track { height: 8px; background: var(--paper-deep); border-radius: var(--radius-pill); overflow: hidden; }
.asset-goal .ag-fill { height: 100%; background: var(--finances); border-radius: var(--radius-pill); }
.asset-goal span { font-size: var(--text-xs); color: var(--ink-muted); }

.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; }

/* حقل كلمة السر مع زرار إظهار/إخفاء (الزرار على الشمال — نهاية الحقل في RTL) */
.pw-wrap { position: relative; display: block; }
.auth-form .pw-wrap .field { padding-left: 46px; }
.pw-toggle {
  position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  background: none; border: 0; cursor: pointer;
  font-size: 18px; line-height: 1; padding: 6px;
  border-radius: 8px; color: var(--ink-muted);
}
.pw-toggle:hover { background: var(--brand-wash); }
.pw-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.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);
  position: relative;
  overflow: hidden;
}
/* شريط تقدّم مدة التسجيل (٧ دقايق) */
.rec-progress {
  position: absolute;
  inset-inline: 0; bottom: 0;
  height: 3px;
  background: color-mix(in srgb, var(--health-tint) 60%, transparent);
}
.rec-progress i {
  display: block; height: 100%; width: 0%;
  background: var(--health);
  transition: width 0.25s linear, background var(--dur-fast);
}
/* آخر ٤٥ ثانية — تحذير */
.rec-bar.warn { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, var(--health-wash)); }
.rec-bar.warn .rec-progress i { background: var(--danger); }
.rec-bar.warn .rec-time { color: var(--danger-deep); }
.rec-bar.warn .rec-dot { background: var(--danger); }
.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: max(20px, calc((100vw - 1400px) / 2 + 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; }

/* زرار «أدوات» الطاير — فوق زرار المايك، بلون مميّز عشان يتفرق عنه */
.tools-fab {
  bottom: 98px; /* فوق الـ voice-fab (24 + 60 + 14) */
  background: var(--ink); color: var(--paper);
  box-shadow: 0 10px 26px rgba(40,36,32,.4), var(--shadow-md);
}
.tools-fab::after { border-color: var(--ink); }
/* الـ widget بياخد نفس شكل شيت الشات + ارتفاع مريح للمحادثة */
.tools-sheet .ask-thread { min-height: 30vh; max-height: 52vh; }
.tools-sheet #askBox { display: flex; flex-direction: column; }

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

/* ===========================================================================
   الجولة التعريفية (أول مرة)
   =========================================================================== */
.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; }

/* كل حاويات النص الحر (كلام المستخدم/الـ agent) لازم تلفّ الكلمات الطويلة بدل ما
   تدفع الصفحة أفقيًا وتزنقها في عمود على الجنب — خصوصًا في RTL. */
.ic-title, .ic-detail, .pc-title, .pc-detail, .lr-text, .entry-card .e-summary,
.bubble, .list-row .lm .l2, .task-row .task-title, .analysis-result, .gl-note {
  overflow-wrap: anywhere;
  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; }
}

/* ===== شارة التسجيلات المحفوظة (لو النت فصل) ===== */
.pending-voice {
  position: fixed;
  inset-inline-start: 16px;
  bottom: calc(150px + env(safe-area-inset-bottom));
  z-index: 72;
  background: var(--finances-deep, #b06a1f);
  color: #fff;
  font: 700 var(--text-sm, 13px)/1 var(--font-body, sans-serif);
  padding: 10px 14px;
  border-radius: var(--radius-pill, 999px);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  -webkit-tap-highlight-color: transparent;
  animation: tourFade .25s ease;
}
.pending-voice b { font-size: 1.05em; }
.pending-voice.pv-busy { cursor: default; opacity: .92; }
.pending-voice .spinner { width: 15px; height: 15px; border-width: 2px; border-color: rgba(255,255,255,.45); border-top-color: #fff; }
.pending-voice .pv-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; margin-inline-start: 4px;
  border: none; border-radius: 50%; cursor: pointer;
  background: rgba(255,255,255,.22); color: #fff; font-size: 13px; line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.pending-voice .pv-x:hover { background: rgba(255,255,255,.34); }
@media (max-width: 760px) { .pending-voice { bottom: calc(146px + env(safe-area-inset-bottom)); } }

/* ===== خواطر / عصف ذهني ===== */
.thought-card {
  position: relative;
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
}
.thought-card .th-text { font-size: var(--text-sm); line-height: 1.75; color: var(--ink); white-space: pre-wrap; word-break: break-word; }
.thought-card .th-meta { font-size: var(--text-xs); color: var(--ink-faint); margin-top: 8px; }
.thought-card .th-del { position: absolute; inset-inline-start: 8px; top: 8px; width: 26px; height: 26px; opacity: .55; }
.thought-card .th-del:hover { opacity: 1; }

/* زر حذف بند في سجل الهدف */
.gl-row .gl-del { flex: none; width: 26px; height: 26px; opacity: .5; }
.gl-row .gl-del:hover { opacity: 1; color: var(--danger-deep, #b52b27); }
.gl-row .gl-edit { flex: none; width: 26px; height: 26px; opacity: .5; }
.gl-row .gl-edit:hover { opacity: 1; }
