/* ============================================================
 *  الرَّقيم — Al-Raqim  |  Core Stylesheet
 *  الطقسُ البصري: ليلٌ قديم، حبرٌ على ورقٍ مُعتَّق، ومضاتٌ قرمزية.
 * ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&family=Amiri:wght@400;700&family=Tajawal:wght@400;500;700&display=swap');

:root {
  /* ═══ الثيم الفاتح الفاخر — الافتراضي ═══
     عاجيٌّ ناعم، ذهبيٌّ دافئ، بنّيٌّ قديم —
     إحساسُ ورقِ مخطوطةٍ ثمينة تحت ضوءٍ هادئ.
  */
  --bg-deep:      #f5ecd7;          /* عاجيٌّ عميق */
  --bg-paper:     #faf2de;          /* ورقُ المخطوط */
  --bg-soft:      #f0e5c8;          /* ظلالُ الورق */
  --ink:          #2a1e0c;          /* حبرٌ بنّيٌّ داكن */
  --ink-muted:    rgba(42, 30, 12, 0.72);
  --ink-faint:    rgba(42, 30, 12, 0.28);
  --accent:       #8a2818;          /* قرمزيٌّ عتيق */
  --accent-warm:  #b0341e;
  --accent-dim:   rgba(138, 40, 24, 0.35);
  --gold:         #a67320;          /* ذهبٌ بنّيٌّ فاخر */
  --gold-dim:     rgba(166, 115, 32, 0.48);
  --gold-glow:    rgba(166, 115, 32, 0.14);

  /* خطوط */
  --font-display: 'Amiri', 'Noto Naskh Arabic', serif;
  --font-body:    'IBM Plex Sans Arabic', 'Tajawal', sans-serif;
  --font-ui:      'IBM Plex Sans Arabic', 'Tajawal', sans-serif;

  --ease-slow:    cubic-bezier(0.19, 1, 0.22, 1);
  --ease-ink:     cubic-bezier(0.65, 0.05, 0.36, 1);

  --radius:       8px;
  --max-read:     720px;
}

/* ═══ الثيم الغامق — فرعي ═══ */
[data-theme="dark"],
[data-theme="mystery"] {
  --bg-deep:      #06040a;
  --bg-paper:     #0d0a14;
  --bg-soft:      #16121c;
  --ink:          #f0e6d2;
  --ink-muted:    rgba(240, 230, 210, 0.72);
  --ink-faint:    rgba(240, 230, 210, 0.32);
  --accent:       #c23b1d;
  --accent-warm:  #e8522f;
  --accent-dim:   rgba(194, 59, 29, 0.4);
  --gold:         #e8a33d;
  --gold-dim:     rgba(232, 163, 61, 0.42);
  --gold-glow:    rgba(232, 163, 61, 0.16);
}

[data-theme="dark"] {
  --bg-deep:  #09090c;
  --bg-paper: #131318;
  --bg-soft:  #1e1e25;
  --ink:      #f2f2f2;
  --accent:   #9c9590;
  --accent-warm: #bab0a8;
  --gold:     #c4a878;
}

[data-theme="light"] {
  /* نفس المتغيّراتِ الافتراضيّة — الفاتحُ هو الأساس */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  direction: rtl;
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--ink);
  background: var(--bg-deep);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ═════════════════════════════════════════════════════════
 *  الطبقات: خلفية ورقية، حبيبات، دخان، ثم الوجه.
 * ═════════════════════════════════════════════════════════ */

.stage {
  position: fixed; inset: 0;
  overflow: hidden;
  z-index: 0;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(166, 115, 32, 0.05), transparent 55%),
    radial-gradient(ellipse at 20% 80%, rgba(138, 40, 24, 0.03), transparent 60%),
    linear-gradient(180deg, var(--bg-deep), var(--bg-paper) 60%, var(--bg-deep));
}

/* طبقة الحبيبات — SVG noise ثابتة، خفيفة على الأداء */
.stage::before {
  content: "";
  position: absolute; inset: -50%;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='7'/><feColorMatrix values='0 0 0 0 0.5  0 0 0 0 0.4  0 0 0 0 0.3  0 0 0 0.2 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  opacity: 0.08;
  mix-blend-mode: multiply;
  pointer-events: none;
}

/* الوضع الغامق — حبيبات فاتحة */
[data-theme="dark"] .stage::before,
[data-theme="mystery"] .stage::before {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='7'/><feColorMatrix values='0 0 0 0 0.9  0 0 0 0 0.85  0 0 0 0 0.75  0 0 0 0.25 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  opacity: 0.12;
  mix-blend-mode: overlay;
}

/* طبقة الفينييت — بتدرُّج الثيم */
.stage::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(42, 30, 12, 0.25) 100%);
  pointer-events: none;
}
[data-theme="dark"] .stage::after,
[data-theme="mystery"] .stage::after {
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.55) 100%);
}

/* ═════════════════════════════════════════════════════════
 *  الوجه في الخلفية
 *  صورة بورتريه مُفلترة، تنبضُ أحيانًا كأنها تحاولُ الخروج.
 * ═════════════════════════════════════════════════════════ */

.face-layer {
  position: fixed; inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 2.4s var(--ease-slow);
}
.face-layer.ready { opacity: 1; }

.face-portrait {
  position: absolute;
  width: 70vmin; height: 90vmin;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(1);
  filter: sepia(0.2) contrast(0.9) brightness(1);
  opacity: 0.16;
  mix-blend-mode: multiply;
  transition: opacity 2s var(--ease-slow), filter 2s var(--ease-slow);
  will-change: opacity, filter;
  pointer-events: none;
}

/* الثيم الغامق — عكس نمط المزج */
[data-theme="dark"] .face-portrait,
[data-theme="mystery"] .face-portrait {
  mix-blend-mode: screen;
  opacity: 0.28;
  filter: grayscale(0.6) contrast(1) brightness(0.65);
}

.face-portrait.surge {
  opacity: 0.32;
  filter: sepia(0.15) contrast(1.05) brightness(0.95);
}
[data-theme="dark"] .face-portrait.surge,
[data-theme="mystery"] .face-portrait.surge {
  opacity: 0.55;
  filter: grayscale(0.3) contrast(1.15) brightness(0.85);
}

/* ═════════════════════════════════════════════════════════
 *  الإطار الزخرفي — كأنه صفحة من مخطوطة
 * ═════════════════════════════════════════════════════════ */

.frame {
  position: fixed;
  inset: 24px;
  z-index: 2;
  pointer-events: none;
  border: 1px solid var(--ink-faint);
  border-radius: var(--radius);
}
.frame::before, .frame::after {
  content: "";
  position: absolute;
  width: 24px; height: 24px;
  border: 1px solid var(--gold-dim);
}
.frame::before { top: -6px; right: -6px; border-left: 0; border-bottom: 0; }
.frame::after  { bottom: -6px; left: -6px; border-right: 0; border-top: 0; }

.frame-seal {
  position: fixed;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--gold);
  letter-spacing: 0.3em;
  opacity: 0.65;
  pointer-events: none;
}

/* ═════════════════════════════════════════════════════════
 *  المسرح — حيث تتناثر الكلمات
 * ═════════════════════════════════════════════════════════ */

.ink-stage {
  position: fixed; inset: 0;
  z-index: 4;
  pointer-events: none;
  overflow: hidden;
}

.ink-word {
  position: absolute;
  font-family: var(--font-display);
  color: var(--ink);
  text-shadow: 0 0 24px rgba(232, 227, 214, 0.25);
  white-space: nowrap;
  opacity: 0;
  will-change: transform, opacity, filter;
  pointer-events: none;
}
.ink-word.red {
  color: var(--accent-warm);
  text-shadow: 0 0 24px rgba(154, 23, 40, 0.5);
}
.ink-word.gold {
  color: var(--gold);
  text-shadow: 0 0 18px rgba(201, 169, 110, 0.4);
}

/* ═════════════════════════════════════════════════════════
 *  الرسالة المجتمعة — في المنتصف
 * ═════════════════════════════════════════════════════════ */

.scroll-box {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  width: min(var(--max-read), calc(100vw - 80px));
  max-height: 72vh;
  pointer-events: auto;           /* التمرير اليدوي دومًا مُفعَّل */
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--gold-dim) transparent;
  /* حوافٌّ علويّةٌ وسفليّةٌ متلاشية — تخفي ما خرج عن الشاشة بنعومة */
  -webkit-mask-image: linear-gradient(to bottom,
    transparent 0,
    black 64px,
    black calc(100% - 64px),
    transparent 100%);
  mask-image: linear-gradient(to bottom,
    transparent 0,
    black 64px,
    black calc(100% - 64px),
    transparent 100%);
  scroll-behavior: smooth;
}

.scroll-box::-webkit-scrollbar { width: 3px; }
.scroll-box::-webkit-scrollbar-thumb {
  background: var(--gold-dim);
  border-radius: 2px;
}
.scroll-box::-webkit-scrollbar-track { background: transparent; }

/* مؤشّرا التمرير — سهمان خافتان يظهران عند وجود محتوى مخفيّ */
.scroll-indicator {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  z-index: 7;
  font-family: var(--font-ui);
  font-size: 10px;
  color: var(--gold);
  letter-spacing: 0.3em;
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
  display: flex; align-items: center; gap: 6px;
}
.scroll-indicator.up   { top: calc(50% - 36vh); }
.scroll-indicator.down { top: calc(50% + 36vh); }
.scroll-indicator.on { opacity: 0.75; }
.scroll-indicator svg { animation: scroll-bob 1.8s ease-in-out infinite; }
@keyframes scroll-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(3px); }
}
.scroll-indicator.up svg { animation-direction: reverse; }

.verse {
  font-family: var(--font-display);
  font-size: clamp(26px, 3.6vw, 40px);
  line-height: 1.9;
  text-align: center;
  color: var(--ink);
  padding: 44px 18px;
  opacity: 0;
  transition: opacity 1.6s var(--ease-ink);
  filter: drop-shadow(0 0 32px rgba(240, 230, 210, 0.06));
  font-weight: 400;
  letter-spacing: 0;
}
.verse.show { opacity: 1; }
.verse.fade { opacity: 0; }

/* ═══ الوضع الغنيّ للردودِ التخصّصيّة (كود، رياضيّات، شرح) ═══ */
.verse.rich-mode {
  font-family: var(--font-body);
  font-size: clamp(15px, 1.8vw, 17px);
  line-height: 1.9;
  text-align: right;
  padding: 40px 24px 60px;
  filter: none;
}
.rq-rich {
  max-width: 760px;
  margin: 0 auto;
  opacity: 0;
  color: var(--ink);
}
.rq-rich .rq-h2 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  margin: 24px 0 12px;
  padding-right: 12px;
  border-right: 3px solid var(--gold);
  line-height: 1.4;
}
.rq-rich .rq-h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--gold);
  margin: 20px 0 10px;
}
.rq-rich .rq-p {
  margin: 12px 0;
  line-height: 1.95;
  color: var(--ink);
}
.rq-rich strong {
  color: var(--gold);
  font-weight: 700;
}
.rq-rich em {
  color: var(--accent);
  font-style: italic;
}

.rq-rich .rq-ul,
.rq-rich .rq-ol {
  margin: 14px 0;
  padding-right: 28px;
}
.rq-rich .rq-ul li,
.rq-rich .rq-ol li {
  margin: 8px 0;
  line-height: 1.85;
  color: var(--ink);
}
.rq-rich .rq-ul {
  list-style: none;
  padding-right: 0;
}
.rq-rich .rq-ul li {
  position: relative;
  padding-right: 22px;
}
.rq-rich .rq-ul li::before {
  content: "◆";
  position: absolute;
  right: 0; top: 0;
  color: var(--gold);
  font-size: 11px;
  line-height: 1.85;
  margin-right: 4px;
}
.rq-rich .rq-ol li {
  padding-right: 8px;
}

/* الكود ، صندوقٌ يشبهُ دفترَ الملاحظات */
.rq-rich .rq-code {
  background: rgba(42, 30, 12, 0.06);
  border: 1px solid var(--gold-dim);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 16px 0;
  overflow-x: auto;
  direction: ltr;
  text-align: left;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink);
  box-shadow: inset 0 1px 4px rgba(166, 115, 32, 0.05);
  position: relative;
}
.rq-rich .rq-code .rq-copy {
  position: absolute;
  top: 8px; right: 8px;
  background: var(--bg-paper);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  opacity: 0.7;
}
.rq-rich .rq-code .rq-copy:hover {
  opacity: 1;
  background: var(--gold);
  color: #faf2de;
}
.rq-rich .rq-code.copied .rq-copy {
  background: #2d6a3e;
  color: #faf2de;
  border-color: #2d6a3e;
  opacity: 1;
}
.rq-rich .rq-code code {
  font-family: inherit;
  background: none;
  padding: 0;
  white-space: pre;
}
.rq-rich .rq-inline-code {
  background: var(--gold-glow);
  border: 1px solid var(--gold-dim);
  border-radius: 5px;
  padding: 2px 7px;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  font-size: 0.92em;
  color: var(--gold);
  direction: ltr;
  display: inline-block;
}

[data-theme="dark"] .rq-rich .rq-code,
[data-theme="mystery"] .rq-rich .rq-code {
  background: rgba(0, 0, 0, 0.35);
}

.verse .red,
.verse .rq-word.red { color: var(--accent-warm); }
.verse .gold,
.verse .rq-word.gold { color: var(--gold); }

/* كلماتٌ تظهرُ كلمةً كلمة، الحروف في كلمة واحدة متّصلة */
.rq-word {
  display: inline-block;
  white-space: nowrap;
  vertical-align: baseline;
  will-change: opacity, transform, filter;
}

/* ═════════════════════════════════════════════════════════
 *  حقل الكتابة — ألفا شفّاف، خطٌّ ذهبيٌّ يسطع عند التركيز
 * ═════════════════════════════════════════════════════════ */

.quill {
  position: fixed;
  left: 50%; bottom: 54px;
  transform: translateX(-50%);
  z-index: 10;
  width: min(620px, calc(100vw - 80px));
}

.quill-slab {
  background: transparent;
  border: 0;
  padding: 0;
  position: relative;
  display: block;
}

/* خطٌّ ذهبيٌّ خفيفٌ أسفل الحقل */
.quill-slab::before {
  content: "";
  position: absolute;
  left: 30%; right: 30%;
  bottom: -2px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
  transition: all 0.8s var(--ease-slow);
  pointer-events: none;
}

.quill-slab:focus-within::before {
  left: 0; right: 0;
  background: linear-gradient(90deg, transparent 5%, var(--gold) 50%, transparent 95%);
  box-shadow: 0 0 16px rgba(201, 169, 110, 0.35), 0 0 32px rgba(201, 169, 110, 0.15);
  height: 1px;
}

/* نقطتان ذهبيّتان خفيّتان على طرفَي الخط — عند التركيز فقط */
.quill-slab::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -4px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--gold);
  opacity: 0;
  transform: translateX(-50%) scale(0);
  transition: all 0.8s var(--ease-slow);
  box-shadow: 0 0 10px var(--gold);
}
.quill-slab:focus-within::after {
  opacity: 0.9;
  transform: translateX(-50%) scale(1);
  animation: quill-dot-pulse 2.4s ease-in-out infinite;
}
@keyframes quill-dot-pulse {
  0%, 100% { opacity: 0.6; transform: translateX(-50%) scale(1); }
  50%      { opacity: 1;   transform: translateX(-50%) scale(1.5); }
}

.quill-input {
  width: 100%;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(20px, 2.4vw, 26px);
  padding: 16px 8px;
  direction: rtl;
  text-align: center;
  caret-color: var(--gold);
  letter-spacing: 0.02em;
  font-weight: 400;
  text-shadow: 0 0 16px rgba(232, 227, 214, 0.05);
}
.quill-input::placeholder {
  color: var(--ink-muted);
  font-style: italic;
  opacity: 0.5;
  letter-spacing: 0.04em;
  transition: opacity 0.6s;
}
.quill-input:focus::placeholder { opacity: 0.25; }

/* إزالة التلميحُ القديم لأنه لم يعد ضروريًّا */
.quill-hint { display: none; }

/* زر الكيبورد للجوال */
.keyboard-pill {
  position: fixed;
  bottom: 34px; left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  background: rgba(250, 242, 222, 0.85);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--gold);
  color: var(--gold);
  font-family: var(--font-ui);
  font-size: 12px;
  padding: 14px 26px;
  border-radius: 999px;
  letter-spacing: 0.3em;
  cursor: pointer;
  display: none;
  transition: all 0.4s var(--ease-slow);
  gap: 10px;
}
.keyboard-pill::before {
  content: "";
  position: absolute; inset: -4px;
  border-radius: 999px;
  border: 1px solid var(--gold-dim);
  opacity: 0.5;
  animation: pill-pulse 2.8s ease-in-out infinite;
  pointer-events: none;
}
@keyframes pill-pulse {
  0%, 100% { transform: scale(1);   opacity: 0.5; }
  50%      { transform: scale(1.12); opacity: 0; }
}

@media (max-width: 720px) {
  .keyboard-pill { display: inline-flex; align-items: center; }
  .quill:not(.show) { display: none; }

  /* الحقل على الجوّال — تصميم تطبيق */
  .quill {
    bottom: 16px;
    width: calc(100vw - 24px);
  }
  .quill-input {
    font-size: 17px;
    padding: 14px 12px;
  }

  /* الإطار على الجوّال — أنحف */
  .frame { inset: 8px; border-radius: 8px; }

  /* الشريط العلوي — اليسار مضغوط، اليمين بطاقة الجلسة */
  .topbar-left {
    top: 12px; left: 12px;
    gap: 8px;
  }
  .icon-btn {
    width: 38px; height: 38px;
  }

  .session-badge {
    top: 12px; right: 12px;
    padding: 8px 14px;
    font-size: 12px;
    max-width: calc(100vw - 120px);
  }
  .session-label { display: none; }  /* في الجوّال نشيل كلمة "جلسة" */
  .session-name {
    max-width: 130px;
    font-size: 13px;
  }
  .admin-mark {
    width: 22px; height: 22px;
  }
  .admin-mark svg {
    width: 12px; height: 12px;
  }

  /* الرسائل على الجوّال */
  .scroll-box {
    max-height: 70vh;
    width: calc(100vw - 28px);
  }
  .verse {
    padding: 18px 8px;
    font-size: clamp(22px, 5.2vw, 30px);
    line-height: 1.85;
  }

  /* المؤشّرات السفليّة */
  .presence { bottom: 10px; right: 12px; font-size: 10px; letter-spacing: 0.1em; }

  /* بوّابات الدخول — احترافيّة على الجوال */
  .gate-card {
    padding: 44px 28px 32px;
    border-radius: 12px;
  }
  .gate-title { font-size: 44px; }
  .field input { font-size: 16px; }  /* 16px يمنع زوم iOS */

  /* مؤشّر التفكير — أصغر على الجوّال */
  .thinking { width: 110px; height: 110px; }
}

/* شاشات صغيرة جدًّا */
@media (max-width: 380px) {
  .icon-btn { width: 36px; height: 36px; }
  .session-badge {
    padding: 7px 12px;
    font-size: 11px;
    max-width: calc(100vw - 110px);
  }
  .session-name { max-width: 110px; font-size: 12px; }
}

/* ═════════════════════════════════════════════════════════
 *  شريط علوي خفيف (الإعدادات، خروج)
 * ═════════════════════════════════════════════════════════ */

/* ═════════════════════════════════════════════════════════
 *  شريطٌ علويٌّ جديد — البرجر على اليسار + بطاقةُ الجلسة على اليمين
 * ═════════════════════════════════════════════════════════ */

/* حاوية اليسار: البرجر + زر الحفظ */
.topbar-left {
  position: fixed; top: 18px; left: 18px;
  z-index: 25;
  display: flex; gap: 10px; align-items: center;
}

/* أيقونة الأزرار — تصميمٌ فاخرٌ للثيم الفاتح */
.icon-btn {
  background: rgba(250, 242, 222, 0.7);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  width: 40px; height: 40px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.3s var(--ease-slow);
  padding: 0;
  backdrop-filter: blur(12px) saturate(1.1);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
  box-shadow: 0 2px 10px rgba(166, 115, 32, 0.12);
}
.icon-btn:hover {
  background: var(--gold);
  color: #faf2de;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(166, 115, 32, 0.28);
}
[data-theme="dark"] .icon-btn,
[data-theme="mystery"] .icon-btn {
  background: rgba(22, 18, 28, 0.7);
  color: var(--ink-muted);
  border-color: var(--ink-faint);
  box-shadow: none;
}
[data-theme="dark"] .icon-btn:hover,
[data-theme="mystery"] .icon-btn:hover {
  color: var(--gold);
  border-color: var(--gold-dim);
  background: var(--gold-glow);
  box-shadow: none;
}

/* زرّ الحفظ — يظهر جنب البرجر بلون مميّز */
.save-btn {
  border-color: var(--accent-dim);
  color: var(--accent);
}
.save-btn:hover {
  background: var(--accent);
  color: #faf2de;
  border-color: var(--accent);
}

/* ═══ بطاقةُ الجلسة — على اليمين، فريدة ═══ */
.session-badge {
  position: fixed; top: 18px; right: 18px;
  z-index: 24;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  background: linear-gradient(135deg, rgba(250, 242, 222, 0.9), rgba(240, 229, 200, 0.9));
  border: 1px solid var(--gold-dim);
  border-radius: 999px;
  backdrop-filter: blur(12px) saturate(1.15);
  -webkit-backdrop-filter: blur(12px) saturate(1.15);
  box-shadow: 0 4px 16px rgba(166, 115, 32, 0.15);
  max-width: calc(100vw - 120px);
  overflow: hidden;
}
.session-label {
  color: var(--ink-muted);
  font-size: 12px;
}
.session-name {
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
[data-theme="dark"] .session-badge,
[data-theme="mystery"] .session-badge {
  background: rgba(22, 18, 28, 0.75);
  border-color: var(--ink-faint);
  box-shadow: none;
}
[data-theme="dark"] .session-name,
[data-theme="mystery"] .session-name {
  color: var(--ink);
}

.admin-mark {
  display: inline-flex;
  align-items: center; justify-content: center;
  color: #faf2de;
  width: 26px; height: 26px;
  padding: 0;
  background: linear-gradient(135deg, var(--gold), #c89548);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(166, 115, 32, 0.35), 0 0 0 2px rgba(250, 242, 222, 0.5);
  position: relative;
}
.admin-mark svg {
  width: 14px; height: 14px;
}
/* نقطةٌ تأكيدٍ ذهبيّةٌ صغيرةٌ أسفل الأيقونة */
.admin-mark::after {
  content: "";
  position: absolute;
  bottom: -2px; right: -2px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gold);
  border: 1.5px solid var(--bg-paper);
}
[data-theme="dark"] .admin-mark::after,
[data-theme="mystery"] .admin-mark::after {
  border-color: var(--bg-deep);
}

/* ═══ الدرج المنسدل ═══ */
.drawer-overlay {
  position: fixed; inset: 0;
  z-index: 40;
  background: rgba(42, 30, 12, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease-slow);
}
.drawer-overlay.on {
  opacity: 1;
  pointer-events: auto;
}
[data-theme="dark"] .drawer-overlay,
[data-theme="mystery"] .drawer-overlay {
  background: rgba(0, 0, 0, 0.7);
}

.drawer {
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 45;
  width: min(340px, 85vw);
  background: linear-gradient(180deg, var(--bg-paper), var(--bg-soft));
  border-right: 1px solid var(--gold-dim);
  box-shadow: 4px 0 40px rgba(42, 30, 12, 0.2);
  transform: translateX(-102%);
  transition: transform 0.4s var(--ease-slow);
  display: flex; flex-direction: column;
  padding: 20px 18px;
  overflow-y: auto;
}
[dir="rtl"] .drawer {
  left: auto; right: 0;
  transform: translateX(102%);
  border-right: 0;
  border-left: 1px solid var(--gold-dim);
  box-shadow: -4px 0 40px rgba(42, 30, 12, 0.2);
}
.drawer.open { transform: translateX(0); }
[data-theme="dark"] .drawer,
[data-theme="mystery"] .drawer {
  background: linear-gradient(180deg, #14101a, #0a070f);
  border-color: var(--ink-faint);
}

.drawer-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 6px 20px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--gold-dim);
}
.drawer-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
}

.drawer-nav, .drawer-section {
  display: flex; flex-direction: column;
  gap: 4px;
}

.drawer-link {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 14px;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  border-radius: 10px;
  transition: all 0.25s var(--ease-slow);
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  width: 100%;
  text-align: right;
}
.drawer-link:hover {
  background: var(--gold-glow);
  border-color: var(--gold-dim);
  color: var(--gold);
}
.drawer-link svg {
  flex-shrink: 0;
  opacity: 0.85;
}
.drawer-btn { cursor: pointer; }

.drawer-sep {
  height: 1px;
  background: var(--gold-dim);
  margin: 14px 8px;
  opacity: 0.5;
}

.drawer-exit {
  color: var(--accent);
  margin-top: auto;
}
.drawer-exit:hover {
  background: rgba(138, 40, 24, 0.08);
  border-color: var(--accent-dim);
  color: var(--accent);
}
[data-theme="dark"] .drawer-exit,
[data-theme="mystery"] .drawer-exit {
  color: var(--accent-warm);
}

/* ═════════════════════════════════════════════════════════
 *  مرفقاتُ الصورِ + تحذيرُ التخصّص
 * ═════════════════════════════════════════════════════════ */

.quill-attach {
  background: transparent;
  border: 0;
  color: var(--gold);
  cursor: pointer;
  padding: 8px;
  display: grid; place-items: center;
  border-radius: 50%;
  transition: all 0.25s var(--ease-slow);
  flex-shrink: 0;
}
.quill-attach:hover {
  background: var(--gold-glow);
  transform: scale(1.06);
}

/* زرّ الميكروفون مع حالة التسجيل */
.quill-mic {
  position: relative;
}
.quill-mic.recording {
  background: linear-gradient(135deg, var(--accent), #c14728);
  color: #faf2de;
  border-radius: 50%;
}
.quill-mic.recording::before {
  content: "";
  position: absolute;
  inset: -4px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  animation: mic-pulse 1.4s ease-out infinite;
}
.quill-mic.recording::after {
  content: attr(data-time);
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #faf2de;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 10px rgba(138, 40, 24, 0.4);
}
.quill-mic.uploading {
  background: var(--gold-glow);
  color: var(--gold);
  pointer-events: none;
}
.quill-mic.uploading svg {
  animation: mic-uploading 1.2s linear infinite;
}
@keyframes mic-pulse {
  0%   { opacity: 1;   transform: scale(0.95); }
  100% { opacity: 0;   transform: scale(1.5);  }
}
@keyframes mic-uploading {
  0%   { transform: rotate(0deg)   scale(1); opacity: 0.6; }
  50%  { transform: rotate(180deg) scale(1.1); opacity: 1; }
  100% { transform: rotate(360deg) scale(1); opacity: 0.6; }
}

.quill-attachments {
  display: none;
  gap: 8px;
  padding: 0 12px 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.quill-attachments.on {
  display: flex;
}
.attach-thumb {
  position: relative;
  width: 64px; height: 64px;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--gold-dim);
  box-shadow: 0 2px 8px rgba(166, 115, 32, 0.18);
  background: var(--bg-soft);
}
.attach-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.attach-remove {
  position: absolute;
  top: 4px; left: 4px;
  width: 22px; height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(42, 30, 12, 0.85);
  color: #faf2de;
  cursor: pointer;
  display: grid; place-items: center;
  padding: 0;
  transition: transform 0.2s;
}
.attach-remove:hover {
  transform: scale(1.12);
  background: var(--accent);
}

/* بطاقةُ التحذير التخصّصيّ */
.disclaimer-pill {
  position: fixed;
  top: 86px; left: 50%;
  transform: translateX(-50%) translateY(-12px);
  z-index: 22;
  max-width: min(560px, calc(100vw - 32px));
  padding: 12px 18px;
  background: rgba(250, 242, 222, 0.96);
  border: 1px solid var(--gold-dim);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
  text-align: center;
  line-height: 1.6;
  box-shadow: 0 4px 18px rgba(166, 115, 32, 0.15);
  opacity: 0;
  pointer-events: none;
  transition: all 0.5s var(--ease-slow);
}
.disclaimer-pill.on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
[data-theme="dark"] .disclaimer-pill,
[data-theme="mystery"] .disclaimer-pill {
  background: rgba(22, 18, 28, 0.92);
  border-color: var(--ink-faint);
  color: var(--ink-muted);
}

/* ═══ زرُّ الترقية ، يظهر عند تجاوز الحدّ ═══ */
.upgrade-pill {
  position: fixed;
  bottom: 130px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 28;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  background: linear-gradient(135deg, var(--gold), #c89548);
  color: #faf2de;
  border: 1px solid var(--gold);
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 8px 26px rgba(166, 115, 32, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: all 0.5s var(--ease-slow);
  animation: upgrade-pulse 2.4s ease-in-out infinite;
}
.upgrade-pill svg { flex-shrink: 0; }
.upgrade-pill.on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.upgrade-pill:hover {
  background: linear-gradient(135deg, #c89548, var(--gold));
  transform: translateX(-50%) translateY(-3px);
  box-shadow: 0 12px 32px rgba(166, 115, 32, 0.6);
}
@keyframes upgrade-pulse {
  0%, 100% { box-shadow: 0 8px 26px rgba(166, 115, 32, 0.45); }
  50%      { box-shadow: 0 8px 32px rgba(166, 115, 32, 0.75); }
}
@media (max-width: 720px) {
  .upgrade-pill {
    bottom: 100px;
    font-size: 13px;
    padding: 10px 18px;
  }
}

@media (max-width: 720px) {
  .disclaimer-pill {
    top: 70px;
    font-size: 11px;
    padding: 10px 14px;
    max-width: calc(100vw - 24px);
  }
  .attach-thumb { width: 56px; height: 56px; }
}

/* ═════════════════════════════════════════════════════════
 *  البوّابات — دخول/تسجيل/تفضيلات
 * ═════════════════════════════════════════════════════════ */

.gate {
  position: fixed; inset: 0;
  z-index: 5;
  display: grid; place-items: center;
  padding: 24px;
  overflow-y: auto;
}
.gate-card {
  width: min(460px, 100%);
  padding: 56px 48px 44px;
  background: linear-gradient(160deg, var(--bg-paper), var(--bg-soft));
  backdrop-filter: blur(20px) saturate(1.15);
  -webkit-backdrop-filter: blur(20px) saturate(1.15);
  border: 1px solid var(--gold-dim);
  border-radius: 14px;
  box-shadow:
    0 30px 60px -20px rgba(42, 30, 12, 0.25),
    0 10px 30px -10px rgba(166, 115, 32, 0.12),
    0 0 0 1px var(--gold-glow) inset;
  position: relative;
}
[data-theme="dark"] .gate-card,
[data-theme="mystery"] .gate-card {
  background: linear-gradient(160deg, rgba(22, 18, 28, 0.88), rgba(10, 8, 16, 0.92));
  border-color: var(--ink-faint);
  box-shadow:
    0 40px 80px -20px rgba(0,0,0,0.8),
    0 0 1px 0 rgba(232, 163, 61, 0.1) inset;
}
.gate-card::before {
  content: "";
  position: absolute; inset: 12px;
  border: 1px solid var(--gold-dim);
  border-radius: 8px;
  pointer-events: none;
  opacity: 0.5;
}

.gate-title {
  font-family: var(--font-display);
  font-size: 58px;
  font-weight: 700;
  text-align: center;
  color: var(--ink);
  margin-bottom: 8px;
  letter-spacing: 0;
  line-height: 1.35;
  padding-top: 6px;
  text-shadow: 0 2px 24px rgba(166, 115, 32, 0.1);
}
.gate-subtitle {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  color: var(--gold);
  text-align: center;
  letter-spacing: 0.3em;
  margin-bottom: 36px;
  opacity: 0.9;
}

.field {
  display: block;
  margin-bottom: 22px;
}
.field label {
  display: block;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.field input {
  width: 100%;
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid var(--gold-dim);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 500;
  padding: 13px 15px;
  outline: 0;
  transition: all 0.3s;
  direction: rtl;
  border-radius: 8px;
}
[data-theme="dark"] .field input,
[data-theme="mystery"] .field input {
  background: rgba(255, 255, 255, 0.02);
  border-color: var(--ink-faint);
}
.field input:focus {
  border-color: var(--gold);
  background: rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 0 3px var(--gold-glow);
}
[data-theme="dark"] .field input:focus,
[data-theme="mystery"] .field input:focus {
  background: rgba(232, 163, 61, 0.04);
}

.btn {
  width: 100%;
  margin-top: 16px;
  padding: 15px;
  background: linear-gradient(135deg, var(--gold), #c89548);
  border: 1px solid var(--gold);
  color: #faf2de;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.15em;
  cursor: pointer;
  transition: all 0.4s var(--ease-slow);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(166, 115, 32, 0.22);
}
[data-theme="dark"] .btn,
[data-theme="mystery"] .btn {
  background: transparent;
  color: var(--gold);
  box-shadow: none;
  border-color: var(--gold-dim);
}
.btn:hover {
  background: linear-gradient(135deg, #c89548, var(--gold));
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(166, 115, 32, 0.3);
}
[data-theme="dark"] .btn:hover,
[data-theme="mystery"] .btn:hover {
  background: var(--gold);
  color: var(--bg-deep);
}
.btn.primary {
  background: linear-gradient(135deg, var(--gold), #c89548);
  border-color: var(--gold);
}
[data-theme="dark"] .btn.primary,
[data-theme="mystery"] .btn.primary {
  background: transparent;
  border-color: var(--accent-dim);
  color: var(--accent-warm);
}
.btn.primary:hover {
  background: linear-gradient(135deg, #c89548, var(--gold));
}
[data-theme="dark"] .btn.primary:hover,
[data-theme="mystery"] .btn.primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink);
}

.gate-link {
  display: block;
  text-align: center;
  margin-top: 20px;
  color: var(--ink-muted);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  letter-spacing: 0.05em;
  transition: color 0.3s;
}
.gate-link:hover { color: var(--gold); }
.err {
  color: var(--accent-warm);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  margin-bottom: 16px;
  letter-spacing: 0;
  padding: 10px 14px;
  background: rgba(194, 59, 29, 0.08);
  border: 1px solid var(--accent-dim);
  border-radius: 6px;
}

/* ═════════════════════════════════════════════════════════
 *  التفضيلات — خيارات بتصميم راقٍ
 * ═════════════════════════════════════════════════════════ */

.choice-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.choice-row label {
  flex: 1;
  display: block;
  text-align: center;
  padding: 16px 8px;
  border: 1px solid var(--gold-dim);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0;
  transition: all 0.3s var(--ease-slow);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.35);
}
[data-theme="dark"] .choice-row label,
[data-theme="mystery"] .choice-row label {
  background: rgba(255, 255, 255, 0.01);
  border-color: var(--ink-faint);
  color: var(--ink-muted);
  font-weight: 500;
}
.choice-row input { display: none; }
.choice-row label:hover {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(255, 255, 255, 0.55);
}
[data-theme="dark"] .choice-row label:hover,
[data-theme="mystery"] .choice-row label:hover {
  background: rgba(232, 163, 61, 0.04);
}
.choice-row label:has(input:checked) {
  border-color: var(--gold);
  color: #faf2de;
  background: linear-gradient(135deg, var(--gold), #c89548);
  box-shadow: 0 4px 14px rgba(166, 115, 32, 0.25);
}
[data-theme="dark"] .choice-row label:has(input:checked),
[data-theme="mystery"] .choice-row label:has(input:checked) {
  background: var(--gold-glow);
  color: var(--gold);
  box-shadow: none;
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--ink-faint);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0;
}
.toggle-row:last-child { border-bottom: 0; }
.toggle-row input[type="checkbox"] {
  accent-color: var(--gold);
  transform: scale(1.3);
  cursor: pointer;
}

/* ═════════════════════════════════════════════════════════
 *  مُختارُ شكلِ التفكير ـ ٤ بطاقاتٍ بمعاينةٍ حيّة
 * ═════════════════════════════════════════════════════════ */
.thinker-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.thinker-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 10px;
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid var(--gold-dim);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.25s var(--ease-slow);
}
.thinker-option input { display: none; }
.thinker-option:hover {
  background: rgba(255, 255, 255, 0.6);
  border-color: var(--gold);
}
.thinker-option:has(input:checked) {
  background: var(--gold-glow);
  border-color: var(--gold);
  box-shadow: 0 4px 14px rgba(166, 115, 32, 0.2);
}
.thinker-option-preview {
  width: 70px; height: 70px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 10px;
  border: 1px solid var(--gold-dim);
}
.thinker-option-preview svg {
  width: 50px; height: 50px;
}
.thinker-option-label {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.05em;
}

/* معاينةُ الدخان (مصغّرة) */
.tp-smoke {
  position: relative;
  width: 50px; height: 50px;
}
.tp-smoke span {
  position: absolute;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(200, 149, 72, 0.7) 0%, transparent 70%);
  filter: blur(6px);
  mix-blend-mode: screen;
  animation: tp-smoke-flow 3s ease-in-out infinite;
}
.tp-smoke span:nth-child(1) { top: 6px;  left: 6px;  animation-delay: 0s; }
.tp-smoke span:nth-child(2) { top: 12px; left: 22px; animation-delay: 0.4s; background: radial-gradient(circle, rgba(166, 115, 32, 0.6) 0%, transparent 70%); }
.tp-smoke span:nth-child(3) { top: 22px; left: 14px; animation-delay: 0.8s; background: radial-gradient(circle, rgba(224, 184, 120, 0.7) 0%, transparent 70%); }
.tp-smoke span:nth-child(4) { top: 4px;  left: 18px; animation-delay: 1.2s; }
@keyframes tp-smoke-flow {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(3px, -2px) scale(1.15); }
}

/* معاينةُ النبضة */
.tp-pulse {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 4px;
  gap: 4px;
  align-items: center;
  height: 40px;
}
.tp-pulse span {
  width: 4px;
  background: linear-gradient(180deg, #e0b878, #a67320);
  border-radius: 2px;
  animation: tp-bar 1s ease-in-out infinite;
}
.tp-pulse span:nth-child(1) { animation-delay: 0s;    height: 14px; }
.tp-pulse span:nth-child(2) { animation-delay: 0.1s;  height: 22px; }
.tp-pulse span:nth-child(3) { animation-delay: 0.2s;  height: 30px; }
.tp-pulse span:nth-child(4) { animation-delay: 0.3s;  height: 22px; }
.tp-pulse span:nth-child(5) { animation-delay: 0.4s;  height: 14px; }
@keyframes tp-bar {
  0%, 100% { transform: scaleY(0.4); }
  50%      { transform: scaleY(1.2); }
}

/* معاينةُ المدار */
.tp-orbit {
  position: relative;
  width: 50px; height: 50px;
}
.tp-orbit .tpo-core {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 6px; height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle, #e0b878 0%, #a67320 100%);
  box-shadow: 0 0 6px rgba(200, 149, 72, 0.8);
}
.tp-orbit .tpo-ring {
  position: absolute;
  top: 50%; left: 50%;
  width: 36px; height: 22px;
  margin: -11px 0 0 -18px;
  border: 1px solid rgba(166, 115, 32, 0.6);
  border-radius: 50%;
  animation: tp-orbit-spin 2s linear infinite;
}
.tp-orbit .tpo-ring::before {
  content: '';
  position: absolute;
  top: -2px; left: 50%;
  margin-left: -2px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: #c89548;
  box-shadow: 0 0 4px rgba(200, 149, 72, 0.9);
}
.tp-orbit .tpo-ring-2 {
  width: 46px; height: 30px;
  margin: -15px 0 0 -23px;
  transform: rotate(60deg);
  animation-duration: 3s;
}
@keyframes tp-orbit-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@media (max-width: 480px) {
  .thinker-picker { grid-template-columns: 1fr 1fr; }
  .thinker-option-preview { width: 60px; height: 60px; }
}

/* ═════════════════════════════════════════════════════════
 *  مُختارُ الشخصيّة (Personality picker)
 * ═════════════════════════════════════════════════════════ */
.personality-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.personality-option {
  cursor: pointer;
}
.personality-option input { display: none; }

.personality-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 14px 12px;
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid var(--gold-dim);
  border-radius: 12px;
  transition: all 0.25s var(--ease-slow);
  height: 100%;
  box-sizing: border-box;
}
.personality-option:hover .personality-card {
  background: rgba(255, 255, 255, 0.6);
  border-color: var(--gold);
}
.personality-option:has(input:checked) .personality-card {
  background: var(--gold-glow);
  border-color: var(--gold);
  box-shadow: 0 4px 14px rgba(166, 115, 32, 0.2);
}
.personality-icon {
  width: 32px; height: 32px;
  color: var(--gold);
  margin-bottom: 4px;
}
.personality-icon svg { width: 100%; height: 100%; }
.personality-name {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.03em;
}
.personality-desc {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-muted);
  line-height: 1.5;
}

@media (max-width: 480px) {
  .personality-picker { grid-template-columns: 1fr; }
}

/* ═════════════════════════════════════════════════════════
 *  نبضة الحضور — مؤشر صغير
 * ═════════════════════════════════════════════════════════ */

.presence {
  position: fixed;
  bottom: 18px; right: 28px;
  z-index: 15;
  font-family: var(--font-ui);
  font-size: 10px;
  color: var(--ink-muted);
  letter-spacing: 0.3em;
  display: flex; align-items: center; gap: 8px;
}
.presence-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-warm);
  box-shadow: 0 0 12px var(--accent-warm);
  animation: pulse 3.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.8); }
  50%      { opacity: 1;    transform: scale(1.2); }
}

/* ═════════════════════════════════════════════════════════
 *  مؤشّرُ "يُفكِّر" — حلقةٌ دوّارةٌ بنقاطٍ ذهبيّةٍ تتنفَّس
 * ═════════════════════════════════════════════════════════ */

.thinking {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 6;
  width: 280px; height: 280px;
  display: grid; place-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s var(--ease-slow);
}
.thinking.on { opacity: 1; }

/* ═════════════════════════════════════════════════════════
 *  غيمةُ الدخان الذهبيّة ، تتنفّسُ بهدوءٍ كأنها تفكّر
 * ═════════════════════════════════════════════════════════ */

/* ─── نظامُ تبديل المؤشّرات ـ يُختارُ بـ data-thinker على body ─── */
.thinker {
  display: none !important;
  position: relative;
  width: 100%; height: 100%;
}

/* فقط الشكلُ المختار يَظهر */
body[data-thinker="smoke"] .thinker.thinker-smoke,
body[data-thinker="ink"]   .thinker.thinker-ink,
body[data-thinker="pulse"] .thinker.thinker-pulse,
body[data-thinker="orbit"] .thinker.thinker-orbit,
/* fallback لو ما اخترَ شيئًا */
body:not([data-thinker]) .thinker.thinker-smoke {
  display: grid !important;
  place-items: center;
}

.thinker-smoke {
  filter: blur(0); /* الـ blur على كل blob فردي ليتراكب لطيفًا */
}

/* الكتلُ الضبابيّةُ ، كلٌّ مع animation فردي ، مزجها يَخلقُ شكلًا عضويًّا متغيِّرًا */
.smoke-blob {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  mix-blend-mode: screen;
  filter: blur(28px);
  transform-origin: center;
  will-change: transform, opacity;
}

/* كلُّ كتلةٍ بلونٍ ذهبيٍّ مختلفِ الكثافة، حركتها مستقلّة */
.smoke-blob.b1 {
  width: 130px; height: 130px;
  background: radial-gradient(circle, rgba(200, 149, 72, 0.85) 0%, rgba(200, 149, 72, 0) 70%);
  animation: blob-flow-1 6.5s ease-in-out infinite;
}
.smoke-blob.b2 {
  width: 110px; height: 110px;
  background: radial-gradient(circle, rgba(166, 115, 32, 0.7) 0%, rgba(166, 115, 32, 0) 70%);
  animation: blob-flow-2 7.8s ease-in-out infinite;
}
.smoke-blob.b3 {
  width: 150px; height: 150px;
  background: radial-gradient(circle, rgba(224, 184, 120, 0.6) 0%, rgba(224, 184, 120, 0) 70%);
  animation: blob-flow-3 8.2s ease-in-out infinite;
}
.smoke-blob.b4 {
  width: 95px; height: 95px;
  background: radial-gradient(circle, rgba(200, 149, 72, 0.75) 0%, rgba(200, 149, 72, 0) 70%);
  animation: blob-flow-4 5.4s ease-in-out infinite;
}
.smoke-blob.b5 {
  width: 120px; height: 120px;
  background: radial-gradient(circle, rgba(166, 115, 32, 0.55) 0%, rgba(166, 115, 32, 0) 70%);
  animation: blob-flow-5 9.1s ease-in-out infinite;
}
.smoke-blob.b6 {
  width: 100px; height: 100px;
  background: radial-gradient(circle, rgba(224, 184, 120, 0.7) 0%, rgba(224, 184, 120, 0) 70%);
  animation: blob-flow-6 6.9s ease-in-out infinite;
}
.smoke-blob.b7 {
  width: 140px; height: 140px;
  background: radial-gradient(circle, rgba(200, 149, 72, 0.5) 0%, rgba(200, 149, 72, 0) 70%);
  animation: blob-flow-7 7.3s ease-in-out infinite;
}

/* مساراتُ كلّ كتلة ، حركةٌ على شكلِ ٨ أو دوّامة */
@keyframes blob-flow-1 {
  0%, 100% { transform: translate(-30px, -25px) scale(1);    opacity: 0.5; }
  25%      { transform: translate(15px,  -40px) scale(1.15); opacity: 0.85; }
  50%      { transform: translate(35px,   10px) scale(0.95); opacity: 0.7; }
  75%      { transform: translate(-10px,  30px) scale(1.05); opacity: 0.6; }
}
@keyframes blob-flow-2 {
  0%, 100% { transform: translate(35px,  20px)  scale(1);    opacity: 0.55; }
  30%      { transform: translate(-25px, 30px)  scale(1.1);  opacity: 0.8; }
  60%      { transform: translate(-30px, -20px) scale(0.85); opacity: 0.55; }
  85%      { transform: translate(20px,  -15px) scale(1.05); opacity: 0.7; }
}
@keyframes blob-flow-3 {
  0%, 100% { transform: translate(0,    35px)   scale(1.05); opacity: 0.4; }
  35%      { transform: translate(40px,  0)     scale(0.9);  opacity: 0.65; }
  65%      { transform: translate(0,    -35px)  scale(1.15); opacity: 0.55; }
}
@keyframes blob-flow-4 {
  0%, 100% { transform: translate(-40px, 0)     scale(1);    opacity: 0.6; }
  40%      { transform: translate(20px,  35px)  scale(1.2);  opacity: 0.85; }
  70%      { transform: translate(35px,  -25px) scale(0.9);  opacity: 0.7; }
}
@keyframes blob-flow-5 {
  0%, 100% { transform: translate(25px, -35px) scale(1);    opacity: 0.45; }
  33%      { transform: translate(-35px, -10px) scale(1.1); opacity: 0.7; }
  66%      { transform: translate(-15px, 30px)  scale(0.95); opacity: 0.55; }
}
@keyframes blob-flow-6 {
  0%, 100% { transform: translate(-20px, 15px)  scale(1);    opacity: 0.5; }
  45%      { transform: translate(30px,  25px)  scale(1.15); opacity: 0.8; }
  75%      { transform: translate(15px,  -30px) scale(0.9);  opacity: 0.65; }
}
@keyframes blob-flow-7 {
  0%, 100% { transform: translate(15px,  -20px) scale(1);    opacity: 0.4; }
  50%      { transform: translate(-30px, 20px)  scale(1.1);  opacity: 0.6; }
}

/* ═══ النواةُ المضيئة في القلب ═══ */
.smoke-core {
  position: absolute;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle, #faf2de 0%, #e0b878 40%, #c89548 70%, transparent 100%);
  box-shadow:
    0 0 18px rgba(224, 184, 120, 0.85),
    0 0 36px rgba(200, 149, 72, 0.6),
    0 0 64px rgba(166, 115, 32, 0.4);
  animation: core-pulse 1.8s ease-in-out infinite;
}
@keyframes core-pulse {
  0%, 100% { transform: scale(1);   opacity: 0.85; }
  50%      { transform: scale(1.4); opacity: 1;    }
}

/* ═══ الشراراتُ الذهبيّةُ تَطفو حول الغيمة ═══ */
.smoke-spark {
  position: absolute;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: #e0b878;
  box-shadow:
    0 0 8px rgba(224, 184, 120, 0.9),
    0 0 16px rgba(200, 149, 72, 0.5);
  opacity: 0;
}
.smoke-spark.s1 { animation: spark-orbit-1 4.8s ease-in-out infinite; }
.smoke-spark.s2 { animation: spark-orbit-2 6.2s ease-in-out infinite 1.6s; }
.smoke-spark.s3 { animation: spark-orbit-3 5.4s ease-in-out infinite 3.0s; }

@keyframes spark-orbit-1 {
  0%   { transform: translate(0, 0)        scale(0.3); opacity: 0; }
  20%  { opacity: 1; }
  50%  { transform: translate(70px, -40px) scale(1);   opacity: 0.9; }
  80%  { opacity: 0.4; }
  100% { transform: translate(110px, -60px) scale(0.4); opacity: 0; }
}
@keyframes spark-orbit-2 {
  0%   { transform: translate(0, 0)         scale(0.3); opacity: 0; }
  20%  { opacity: 1; }
  50%  { transform: translate(-60px, -50px) scale(1);   opacity: 0.9; }
  80%  { opacity: 0.4; }
  100% { transform: translate(-90px, -70px) scale(0.4); opacity: 0; }
}
@keyframes spark-orbit-3 {
  0%   { transform: translate(0, 0)        scale(0.3); opacity: 0; }
  20%  { opacity: 1; }
  50%  { transform: translate(40px,  60px) scale(1);   opacity: 0.9; }
  80%  { opacity: 0.4; }
  100% { transform: translate(70px,  90px) scale(0.4); opacity: 0; }
}

.thinking-label {
  position: absolute;
  bottom: 4px; left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 0.3em;
  font-weight: 600;
  animation: thinking-label 2.8s ease-in-out infinite;
  white-space: nowrap;
}
@keyframes thinking-label {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 0.95; }
}

/* في الوضع المظلم ، الدخانُ يَكونُ فاتحًا (أبيض/فضي) كأنه دخانٌ حقيقي */
[data-theme="dark"] .smoke-blob,
[data-theme="mystery"] .smoke-blob {
  mix-blend-mode: screen;
  filter: blur(32px);
}
[data-theme="dark"] .smoke-blob.b1,
[data-theme="mystery"] .smoke-blob.b1 {
  background: radial-gradient(circle, rgba(255, 250, 240, 0.55) 0%, rgba(255, 250, 240, 0) 70%);
}
[data-theme="dark"] .smoke-blob.b2,
[data-theme="mystery"] .smoke-blob.b2 {
  background: radial-gradient(circle, rgba(245, 240, 230, 0.45) 0%, rgba(245, 240, 230, 0) 70%);
}
[data-theme="dark"] .smoke-blob.b3,
[data-theme="mystery"] .smoke-blob.b3 {
  background: radial-gradient(circle, rgba(255, 245, 220, 0.5) 0%, rgba(255, 245, 220, 0) 70%);
}
[data-theme="dark"] .smoke-blob.b4,
[data-theme="mystery"] .smoke-blob.b4 {
  background: radial-gradient(circle, rgba(240, 230, 215, 0.4) 0%, rgba(240, 230, 215, 0) 70%);
}
[data-theme="dark"] .smoke-blob.b5,
[data-theme="mystery"] .smoke-blob.b5 {
  background: radial-gradient(circle, rgba(255, 248, 230, 0.55) 0%, rgba(255, 248, 230, 0) 70%);
}
[data-theme="dark"] .smoke-blob.b6,
[data-theme="mystery"] .smoke-blob.b6 {
  background: radial-gradient(circle, rgba(250, 235, 200, 0.4) 0%, rgba(250, 235, 200, 0) 70%);
}
[data-theme="dark"] .smoke-blob.b7,
[data-theme="mystery"] .smoke-blob.b7 {
  background: radial-gradient(circle, rgba(255, 250, 235, 0.5) 0%, rgba(255, 250, 235, 0) 70%);
}
[data-theme="dark"] .smoke-core,
[data-theme="mystery"] .smoke-core {
  background: radial-gradient(circle, rgba(255, 245, 220, 0.95) 0%, rgba(255, 245, 220, 0.4) 60%, rgba(255, 245, 220, 0) 100%);
  box-shadow: 0 0 30px rgba(255, 245, 220, 0.6), 0 0 60px rgba(255, 245, 220, 0.3);
}
[data-theme="dark"] .smoke-spark,
[data-theme="mystery"] .smoke-spark {
  background: rgba(255, 250, 235, 0.9);
  box-shadow: 0 0 8px rgba(255, 250, 235, 0.6);
}

/* نخفي مؤشّر scribe القديم */
/* ═════════════════════════════════════════════════════════
 *  (٢) الحبرُ السائلُ ـ خيطٌ ذهبيٌّ يَتدفّقُ ويُعيدُ رسمَ نفسه
 * ═════════════════════════════════════════════════════════ */
.thinker-ink {
  width: 240px;
  height: 240px;
  filter: drop-shadow(0 0 18px rgba(200, 149, 72, 0.4));
}
.thinker-ink .ink-path {
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: ink-flow 3.6s cubic-bezier(0.4, 0, 0.4, 1) infinite;
}
.thinker-ink .ink-path-1 { animation-delay: 0s; }
.thinker-ink .ink-path-2 { animation-delay: 0.6s; }

@keyframes ink-flow {
  0%   { stroke-dashoffset: 100; opacity: 0; }
  20%  { opacity: 1; }
  60%  { stroke-dashoffset: 0;   opacity: 1; }
  85%  { opacity: 0.4; }
  100% { stroke-dashoffset: -100; opacity: 0; }
}

.thinker-ink .ink-droplet {
  filter: drop-shadow(0 0 6px rgba(224, 184, 120, 0.95));
}

/* ═════════════════════════════════════════════════════════
 *  (٣) النبضةُ الصوتيّة ـ ٥ أعمدة ترقص
 * ═════════════════════════════════════════════════════════ */
.thinker-pulse {
  width: 200px;
  height: 200px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 14px;
  gap: 12px;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 0 14px rgba(200, 149, 72, 0.35));
}
.thinker-pulse .pulse-bar {
  width: 14px;
  background: linear-gradient(180deg, #e0b878, #a67320);
  border-radius: 7px;
  box-shadow: 0 2px 8px rgba(166, 115, 32, 0.3);
  transform-origin: center;
  animation: bar-dance 1.2s ease-in-out infinite;
}
.thinker-pulse .bar-1 { animation-delay: 0.0s;  height: 30px; }
.thinker-pulse .bar-2 { animation-delay: 0.15s; height: 50px; }
.thinker-pulse .bar-3 { animation-delay: 0.3s;  height: 70px; }
.thinker-pulse .bar-4 { animation-delay: 0.45s; height: 50px; }
.thinker-pulse .bar-5 { animation-delay: 0.6s;  height: 30px; }

@keyframes bar-dance {
  0%, 100% { transform: scaleY(0.4); opacity: 0.5; }
  20%      { transform: scaleY(1.0); opacity: 1; }
  40%      { transform: scaleY(0.7); opacity: 0.85; }
  60%      { transform: scaleY(1.4); opacity: 1; }
  80%      { transform: scaleY(0.6); opacity: 0.7; }
}

/* ═════════════════════════════════════════════════════════
 *  (٤) المدارُ الكوكبيّ ـ ٣ أفلاك متداخلة بنواةٍ مضيئة
 * ═════════════════════════════════════════════════════════ */
.thinker-orbit {
  width: 220px;
  height: 220px;
  position: relative;
}

.thinker-orbit .orbit-core {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 16px; height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle, #faf2de 0%, #e0b878 50%, #a67320 100%);
  box-shadow:
    0 0 14px rgba(224, 184, 120, 0.85),
    0 0 28px rgba(200, 149, 72, 0.55),
    0 0 50px rgba(166, 115, 32, 0.35);
  animation: orbit-core-pulse 2s ease-in-out infinite;
}
@keyframes orbit-core-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1);   }
  50%      { transform: translate(-50%, -50%) scale(1.3); }
}

.thinker-orbit .orbit-ring {
  position: absolute;
  top: 50%; left: 50%;
  border: 1px solid rgba(166, 115, 32, 0.35);
  border-radius: 50%;
  transform-origin: center;
}
.thinker-orbit .orbit-ring.r1 {
  width: 90px; height: 60px;
  margin: -30px 0 0 -45px;
  animation: orbit-spin-1 2.8s linear infinite;
}
.thinker-orbit .orbit-ring.r2 {
  width: 140px; height: 90px;
  margin: -45px 0 0 -70px;
  transform: rotate(60deg);
  animation: orbit-spin-2 4s linear infinite;
}
.thinker-orbit .orbit-ring.r3 {
  width: 190px; height: 130px;
  margin: -65px 0 0 -95px;
  transform: rotate(-45deg);
  animation: orbit-spin-3 6s linear infinite;
}

.thinker-orbit .orbit-dot {
  position: absolute;
  top: -4px;
  left: 50%;
  margin-left: -4px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #c89548;
  box-shadow:
    0 0 8px rgba(200, 149, 72, 0.95),
    0 0 16px rgba(166, 115, 32, 0.5);
}

@keyframes orbit-spin-1 {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes orbit-spin-2 {
  from { transform: rotate(60deg); }
  to   { transform: rotate(420deg); }
}
@keyframes orbit-spin-3 {
  from { transform: rotate(-45deg); }
  to   { transform: rotate(315deg); }
}

.scribe { display: none; }


/* ═════════════════════════════════════════════════════════
 *  طبقةُ الأشكالِ الخلفيّةِ المتفاعلة (stage-shape)
 *  جسيماتٌ تَتجمَّعُ في صورٍ خفيّةٍ حسب موضوعِ المحادثة
 * ═════════════════════════════════════════════════════════ */
.stage-shape {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
  opacity: 0;
  transition: opacity 1.4s var(--ease-slow);
}
.stage-shape.on { opacity: 1; }

.shape-particle {
  position: absolute;
  top: 50%; left: 50%;
  width: 14px; height: 14px;
  margin-left: -7px; margin-top: -7px;
  background: radial-gradient(circle at 50% 50%, rgba(166, 115, 32, 0.22) 0%, rgba(166, 115, 32, 0.05) 60%, transparent 100%);
  border-radius: 50%;
  filter: blur(3.5px);
  transition: transform 2.6s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              filter    1.0s var(--ease-slow),
              opacity   1.6s var(--ease-slow);
  will-change: transform, opacity;
}

/* وضعٌ حادّ ، للأشكال الهندسيّة (مثلّثات، رياضيّات، حروف) */
.stage-shape.shape-sharp .shape-particle {
  filter: blur(1.5px);
  background: radial-gradient(circle at 50% 50%, rgba(166, 115, 32, 0.42) 0%, rgba(166, 115, 32, 0.12) 50%, transparent 100%);
}
/* وضعٌ ناعم ، للأشكال العضويّة (قلب، قمر، شمس) */
.stage-shape.shape-soft .shape-particle {
  filter: blur(4px);
}

[data-theme="dark"] .shape-particle,
[data-theme="mystery"] .shape-particle {
  background: radial-gradient(circle at 50% 50%, rgba(200, 149, 72, 0.16) 0%, rgba(200, 149, 72, 0.04) 60%, transparent 100%);
}
[data-theme="dark"] .stage-shape.shape-sharp .shape-particle,
[data-theme="mystery"] .stage-shape.shape-sharp .shape-particle {
  background: radial-gradient(circle at 50% 50%, rgba(200, 149, 72, 0.3) 0%, rgba(200, 149, 72, 0.08) 50%, transparent 100%);
}

/* ═════════════════════════════════════════════════════════
 *  زرُّ الرجوع الموحَّد للصفحات الفرعية
 * ═════════════════════════════════════════════════════════ */
.back-to-chat {
  position: fixed;
  top: 18px; right: 18px;
  z-index: 30;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px 9px 12px;
  background: linear-gradient(135deg, rgba(250, 242, 222, 0.95), rgba(240, 229, 200, 0.95));
  border: 1px solid var(--gold-dim);
  border-radius: 999px;
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--gold);
  backdrop-filter: blur(12px) saturate(1.15);
  -webkit-backdrop-filter: blur(12px) saturate(1.15);
  box-shadow: 0 4px 16px rgba(166, 115, 32, 0.18);
  transition: all 0.25s var(--ease-slow);
}
.back-to-chat:hover {
  background: linear-gradient(135deg, var(--gold), #c89548);
  color: #faf2de;
  border-color: var(--gold);
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(166, 115, 32, 0.32);
}
.back-to-chat svg {
  width: 16px; height: 16px;
  flex-shrink: 0;
}
[data-theme="dark"] .back-to-chat,
[data-theme="mystery"] .back-to-chat {
  background: rgba(22, 18, 28, 0.85);
  color: var(--gold);
  border-color: var(--ink-faint);
  box-shadow: none;
}

@media (max-width: 720px) {
  .back-to-chat {
    top: 12px; right: 12px;
    padding: 8px 14px 8px 10px;
    font-size: 12px;
  }
}

/* إخفاء الـ topbar القديم إن وُجد */
.topbar { display: none !important; }


/* ═════════════════════════════════════════════════════════
 *  مصادرُ البحث (raqim-sources)
 * ═════════════════════════════════════════════════════════ */
.raqim-sources {
  position: fixed;
  bottom: 200px;
  right: 24px;
  z-index: 26;
  width: 320px;
  max-width: calc(100vw - 48px);
  max-height: 50vh;
  display: flex;
  flex-direction: column;
  background: rgba(252, 246, 230, 0.96);
  border: 1px solid var(--gold-dim);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(42, 30, 12, 0.18), 0 0 0 1px rgba(166, 115, 32, 0.08);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.4s var(--ease-slow), transform 0.4s var(--ease-slow);
  overflow: hidden;
  font-family: var(--font-ui);
}
.raqim-sources.on {
  opacity: 1;
  transform: translateY(0);
}
[data-theme="dark"] .raqim-sources,
[data-theme="mystery"] .raqim-sources {
  background: rgba(22, 18, 28, 0.92);
  border-color: rgba(166, 115, 32, 0.35);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.raqim-sources-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gold-dim);
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.raqim-sources-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.raqim-sources-close {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  background: rgba(166, 115, 32, 0.08);
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--gold);
  cursor: pointer;
  padding: 0;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.raqim-sources-close:hover {
  background: rgba(166, 115, 32, 0.18);
  border-color: var(--gold);
  transform: rotate(90deg);
}
[data-theme="dark"] .raqim-sources-close,
[data-theme="mystery"] .raqim-sources-close {
  background: rgba(250, 242, 222, 0.06);
  color: var(--gold);
}
[data-theme="dark"] .raqim-sources-close:hover,
[data-theme="mystery"] .raqim-sources-close:hover {
  background: rgba(250, 242, 222, 0.14);
}

.raqim-sources-list {
  overflow-y: auto;
  padding: 6px 0;
  flex: 1;
}
.raqim-sources-list::-webkit-scrollbar { width: 5px; }
.raqim-sources-list::-webkit-scrollbar-thumb {
  background: var(--gold-dim);
  border-radius: 3px;
}

.raqim-source-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  text-decoration: none;
  color: var(--ink);
  transition: background 0.2s ease;
  border-bottom: 1px solid rgba(166, 115, 32, 0.08);
}
.raqim-source-item:last-child { border-bottom: 0; }
.raqim-source-item:hover {
  background: rgba(200, 149, 72, 0.1);
}

.raqim-source-num {
  flex-shrink: 0;
  width: 22px; height: 22px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--gold), #c89548);
  color: #faf2de;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
}

.raqim-source-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.raqim-source-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.raqim-source-host {
  font-size: 10.5px;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
}

[data-theme="dark"] .raqim-source-title,
[data-theme="mystery"] .raqim-source-title {
  color: rgba(250, 242, 222, 0.92);
}
[data-theme="dark"] .raqim-source-host,
[data-theme="mystery"] .raqim-source-host {
  color: rgba(250, 242, 222, 0.55);
}

@media (max-width: 720px) {
  .raqim-sources {
    bottom: 130px;
    right: 16px;
    left: 16px;
    width: auto;
    max-width: none;
  }
}

/* ═════════════════════════════════════════════════════════
 *  حقلُ النجوم ـ يَظهرُ في وضع Mystery فقط
 * ═════════════════════════════════════════════════════════ */
.starfield {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 1.5s ease;
}
[data-theme="mystery"] .starfield {
  opacity: 1;
}
.starfield .star {
  position: absolute;
  width: 2px;
  height: 2px;
  background: rgba(255, 250, 235, 0.9);
  border-radius: 50%;
  box-shadow:
    0 0 4px rgba(255, 245, 220, 0.8),
    0 0 8px rgba(255, 245, 220, 0.4);
  animation: twinkle 3s ease-in-out infinite;
}
.starfield .star.bright {
  width: 3px;
  height: 3px;
  background: rgba(255, 248, 225, 1);
  box-shadow:
    0 0 6px rgba(255, 245, 220, 1),
    0 0 14px rgba(255, 245, 220, 0.6),
    0 0 24px rgba(224, 184, 120, 0.3);
}
.starfield .star.golden {
  background: rgba(224, 184, 120, 0.85);
  box-shadow:
    0 0 6px rgba(200, 149, 72, 0.8),
    0 0 12px rgba(200, 149, 72, 0.4);
}
@keyframes twinkle {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50%      { opacity: 1;   transform: scale(1.1); }
}

/* في الوضع الفاتح والداكن (غير Mystery) ، النجومُ لا تَظهر */
[data-theme="light"] .starfield,
[data-theme="dark"] .starfield {
  opacity: 0;
  display: none;
}
