@import url("answer-reader.css?v=20261001-report-foot");
.learner-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  margin-block-end: 16px;
  border: 1px solid rgba(234, 246, 220, .22);
  border-radius: 16px;
  background: rgba(12, 36, 14, .64);
  color: #f4fbe9;
}
.learner-copy { min-width: 0; }
.top .lm-account-link {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 8px 12px; border: 1px solid #a6cf72;
  border-radius: 12px; background: #ecf8dd; color: #244b20;
  font: 700 .88rem/1.4 var(--font); text-decoration: none; white-space: nowrap;
}
.top .lm-account-link:hover { background: #d9efbd; }
.top .lm-account-link:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
@media (max-width: 600px) {
  .top:has(.lm-account-link) .brand { display: none !important; }
  .top .lm-account-link { gap: 4px; padding-inline: 8px; font-size: .8rem; }
}
.learner-copy h2 { margin: 0 0 4px; font-size: 1rem; }
.learner-copy p { margin: 0; color: #d9e8cd; font-size: .83rem; line-height: 1.65; }
.learner-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; width: min(100%, 360px); flex-shrink: 0; }
.learner-form select, .learner-form button[type="submit"] {
  min-height: 44px;
  min-width: 0;
  max-width: 100%;
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit;
  font-size: .9rem;
}
.learner-form select { width: 100%; border: 1px solid #bad8a1; color: #1e2a1e; background: #fbfef8; }
.learner-form button[type="submit"] { border: 1px solid #88c540; color: #102910; background: #a6da6b; font-weight: 700; cursor: pointer; }
.learner-form button[type="submit"]:hover { background: #bce68e; }
.learner-form :focus-visible { outline: 3px solid #f4fbe9; outline-offset: 3px; }
.learner-status { grid-column: 1 / -1; margin: 0; font-size: .83rem; line-height: 1.6; }
@media (max-width: 700px) {
  .learner-bar { flex-direction: column; align-items: stretch; gap: 12px; padding: 12px; }
  .learner-form { width: 100%; }
}

.topic-dialog {
  width: min(32rem, calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: clamp(1.1rem, 4vw, 2rem);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 20px 70px #142f2840;
  overflow-y: auto;
  font: 1rem/1.8 var(--font);
}
.topic-dialog::backdrop { background: #10291db3; }
.topic-dialog h2 { color: var(--leaf-deep); font-size: 1.45rem; margin: 0 0 .5rem; }
.topic-dialog p { margin: 0 0 1rem; }
.topic-dialog blockquote {
  margin: 0 0 1.4rem;
  padding: .8rem 1rem;
  background: var(--leaf-soft);
  border-inline-start: 3px solid var(--leaf);
  border-radius: 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 25dvh;
  overflow-y: auto;
}
.topic-dialog-actions { display: grid; gap: .65rem; }
.topic-dialog-actions button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .65rem 1rem;
  background: white;
  color: var(--leaf-deep);
  font: 600 1rem/1.5 var(--font);
  cursor: pointer;
}
.topic-dialog-actions [data-topic-choice="new"] { background: var(--leaf-deep); color: white; }
.topic-dialog-actions [data-topic-choice="cancel"] { border-color: transparent; background: transparent; color: var(--muted); }
.topic-dialog-actions button:focus-visible { outline: 3px solid var(--leaf); outline-offset: 3px; }

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font);
}

/*
  خلفية داكنة مع وهج أخضر في الوسط.
  الأنيميشن يحرّك مواقع التدرج فقط (background-position)
  بحركة بطيئة جداً لكسر الملل دون تشتيت.
*/
body {
  background-color: #0c2410;
  background-image:
    radial-gradient(ellipse 70% 55% at 50% 50%, rgba(136, 197, 64, 0.2), transparent 58%),
    radial-gradient(ellipse 65% 50% at 50% 50%, rgba(93, 154, 44, 0.22), transparent 56%),
    radial-gradient(ellipse 55% 45% at 50% 50%, rgba(35, 99, 36, 0.18), transparent 60%),
    linear-gradient(160deg, #0c2410 0%, #163d18 34%, #236324 68%, #122e14 100%);
  background-size: 160% 160%, 170% 170%, 150% 150%, 100% 100%;
  background-position: 28% 22%, 78% 70%, 48% 48%, 0 0;
  background-repeat: no-repeat;
  background-attachment: fixed;
  position: relative;
  overflow-x: hidden;
  animation: bgDrift 42s ease-in-out infinite alternate;
}

/* طبقة ضوء ناعمة إضافية — تغيّر المواضع فقط */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 50% 50%, rgba(182, 224, 106, 0.12), transparent 42%),
    radial-gradient(circle at 50% 50%, rgba(45, 110, 55, 0.16), transparent 46%);
  background-size: 180% 180%, 190% 190%;
  background-position: 35% 30%, 68% 62%;
  background-repeat: no-repeat;
  animation: glowDrift 52s ease-in-out infinite alternate;
  opacity: 0.9;
  -webkit-mask-image: linear-gradient(180deg, transparent 0 56px, #000 110px);
  mask-image: linear-gradient(180deg, transparent 0 56px, #000 110px);
}
body::after { content: none; }
@media (prefers-reduced-motion: reduce) {
  body,
  body::before { animation: none; }
}

#subjectSelect, select.sr-only { display: none !important; visibility: hidden !important; position: absolute !important; width: 0 !important; height: 0 !important; opacity: 0 !important; pointer-events: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 20px 28px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

.top {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin: 0 0 16px;
  padding: 8px 10px;
  border-radius: 16px;
  /* طبقة ثابتة تمنع وميض النص فوق الخلفية المتموجة */
  background: rgba(12, 36, 14, 0.72);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  transition: padding 0.25s ease;
  isolation: isolate;
  transform: translateZ(0);
}
.top.is-compact { padding: 4px 8px; }
/* أزرار الأرشيف/التقدّم/الدفتر تبقى ظاهرة أثناء التمرير */
.top.is-compact .subject-trigger {
  display: none !important;
}
.top.is-compact .top-actions,
.top.is-compact .top-side-stack {
  display: flex !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}
.brand-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}
.brand-cluster .subject-trigger {
  flex: 0 1 auto;
  transition: none;
}
.brand h1,
.brand-cluster .pill {
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
.top-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  max-width: 100%;
  opacity: 1;
  transition: opacity 0.2s ease, max-width 0.2s ease, max-height 0.2s ease, visibility 0.2s ease;
}
.top-side-stack .pill {
  justify-content: flex-start;
  min-width: 7.2rem;
}
.brand { display: flex; gap: 10px; align-items: center; min-width: 0; }
.logo {
  width: 44px; height: 44px; border: 0; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(145deg, #9ad24a, #5d9a2c);
  color: #fff; font: inherit; font-weight: 800; font-size: 0.95rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.logo:hover {
  transform: translateY(-1px) scale(1.03);
  filter: brightness(1.06);
  box-shadow: 0 6px 16px rgba(0,0,0,0.22);
}
.logo:active { transform: scale(0.98); }
.top h1 {
  margin: 0; font-size: 1.2rem; color: #f3fbe8; font-weight: 800;
  letter-spacing: 0.01em; white-space: nowrap;
}
.top.is-compact h1 { font-size: 1.05rem; }
.top.is-compact .logo { width: 36px; height: 36px; border-radius: 10px; font-size: 0.82rem; }
.tag { display: none !important; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  background: var(--leaf-soft); border: 1px solid var(--line); color: var(--leaf-deep);
  padding: 8px 12px; border-radius: 999px; font-size: 0.85rem; font-weight: 700;
  display: inline-flex; align-items: center; gap: 6px; font: inherit; cursor: pointer;
}
.pill.soft { background: var(--white); color: var(--muted); font-weight: 500; }
.top .pill {
  background: rgba(255,255,255,0.12); border: 1px solid rgba(234,246,220,0.26); color: #f4fbe9;
  backdrop-filter: blur(6px);
}
.top .subject-trigger {
  border-radius: 14px;
  padding: 8px 12px;
  white-space: nowrap;
  transition: opacity 0.22s ease, max-width 0.28s ease, transform 0.22s ease;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
}
.layout.notebook-open { grid-template-columns: 1.65fr 0.9fr; }
.side[hidden] { display: none !important; }
.chat-panel, .card {
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 0; /* داخل .layout المرن — وإلا لن تتمرّر .messages */
  height: 100%;
  overflow: hidden;
  position: relative;
  transition: min-height 0.35s ease, background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.ask-hero {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  margin-top: auto;
}
.chat-panel.is-empty {
  min-height: calc(100dvh - 96px) !important;
  height: calc(100dvh - 96px);
  max-width: min(100%, 560px);
  margin-inline: auto;
  width: 100%;
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  justify-content: center !important;
  align-items: stretch;
  gap: 0;
}
.chat-panel.is-empty .conv-bar,
.chat-panel.is-empty .think-dock {
  display: none !important;
}
.chat-panel.is-empty .messages {
  flex: 0 0 0 !important;
  min-height: 0 !important;
  max-height: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  opacity: 0;
  pointer-events: none;
}
.chat-panel.is-empty .ask-hero {
  margin-top: 0;
  margin-block: auto;
  gap: 12px;
  align-items: stretch;
  animation: heroIn 0.45s ease both;
}
.chat-panel.is-empty .composer {
  border-top: 0;
  border-radius: 18px;
  border: 1px solid rgba(234, 246, 220, 0.35);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 16px 40px rgba(8, 24, 10, 0.28);
  position: relative;
  z-index: 2;
}
.chat-panel:not(.is-empty) .empty-stage,
.chat-panel:not(.is-empty) .empty-dock {
  display: none !important;
}

.empty-stage {
  display: none;
  position: relative;
  height: 0;
  pointer-events: none;
  overflow: visible;
}
.chat-panel.is-empty .empty-stage { display: block; }
/*
  هالة هلامية تنبعث من عرض مربع السؤال (روح Gemini/Siri).
  الصندوق أطول من التوهج الفعلي حتى لا يُقصّ blur من الأعلى.
*/
.empty-aura {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -40px;
  height: 420px;
  display: block;
  overflow: visible;
  contain: none;
  isolation: isolate;
  pointer-events: none;
  z-index: 0;
  /* هامش داخلي بصري: الكتلة الحية تبقى بعيدة عن حد القص العلوي */
  padding-top: 48px;
  box-sizing: border-box;
}
.empty-aura[hidden] { display: none !important; }
.empty-aura .fluid-blob,
.empty-aura .fluid-veil,
.empty-aura .fluid-sheen,
.empty-aura .fluid-emit,
.empty-aura .fluid-core,
.empty-aura .fluid-particle {
  position: absolute;
  pointer-events: none;
}
.empty-aura .fluid-blob {
  border-radius: 48% 52% 45% 55% / 55% 45% 55% 45%;
  filter: blur(28px);
  mix-blend-mode: screen;
  opacity: 0.55;
  will-change: transform, opacity, border-radius;
}
/* شفة مضيئة بعرض مربع الإدخال بالكامل — مصدر الانبعاث */
.empty-aura .fluid-emit {
  left: 0;
  right: 0;
  bottom: 38px;
  height: 36px;
  border-radius: 22px;
  background:
    linear-gradient(180deg,
      rgba(245, 255, 210, 0.7) 0%,
      rgba(168, 220, 90, 0.38) 40%,
      rgba(136, 197, 64, 0.12) 75%,
      transparent 100%);
  box-shadow: 0 0 28px 8px rgba(180, 235, 110, 0.22);
  filter: blur(8px);
  opacity: 0.95;
  mix-blend-mode: screen;
  animation: fluidEmitPulse 5.5s ease-in-out infinite;
}
/* نواة أفقية عريضة — ليست كرة مركزية */
.empty-aura .fluid-core {
  left: -1%;
  right: -1%;
  bottom: 24px;
  height: 150px;
  border-radius: 44% 44% 36% 36% / 70% 70% 24% 24%;
  background:
    radial-gradient(ellipse 120% 70% at 50% 100%,
      rgba(250, 255, 220, 0.78) 0%,
      rgba(190, 240, 120, 0.48) 22%,
      rgba(136, 197, 64, 0.26) 48%,
      rgba(35, 99, 36, 0.08) 70%,
      transparent 86%);
  filter: blur(16px);
  opacity: 0.95;
  mix-blend-mode: screen;
  animation: fluidCoreRise 7.5s ease-in-out infinite, fluidMorphWide 10s ease-in-out infinite;
}
/* طبقات هلامية تمتد بعرض الإدخال */
.empty-aura .fluid-blob.b1 {
  left: -4%;
  right: -4%;
  width: auto;
  height: 190px;
  bottom: 18px;
  background:
    radial-gradient(ellipse 130% 75% at 50% 100%,
      rgba(220, 255, 160, 0.72) 0%,
      rgba(136, 197, 64, 0.38) 34%,
      rgba(45, 110, 50, 0.1) 62%,
      transparent 80%);
  filter: blur(24px);
  opacity: 0.82;
  animation: fluidRise 9s ease-in-out infinite, fluidMorphWide 11s ease-in-out infinite;
}
.empty-aura .fluid-blob.b2 {
  width: 70%;
  height: 200px;
  left: -10%;
  bottom: 12px;
  background:
    radial-gradient(ellipse at 62% 82%,
      rgba(150, 230, 160, 0.62) 0%,
      rgba(60, 140, 80, 0.26) 48%,
      transparent 76%);
  opacity: 0.58;
  filter: blur(30px);
  animation: fluidDriftB 12s ease-in-out infinite, fluidMorph 9s ease-in-out infinite reverse;
}
.empty-aura .fluid-blob.b3 {
  width: 70%;
  height: 190px;
  right: -10%;
  bottom: 10px;
  left: auto;
  background:
    radial-gradient(ellipse at 36% 78%,
      rgba(200, 250, 140, 0.58) 0%,
      rgba(90, 160, 70, 0.24) 46%,
      transparent 76%);
  opacity: 0.55;
  filter: blur(28px);
  animation: fluidDriftC 11s ease-in-out infinite, fluidMorph 8s ease-in-out infinite;
}
.empty-aura .fluid-blob.b4 {
  width: 88%;
  height: 140px;
  left: 6%;
  bottom: 40px;
  background:
    radial-gradient(ellipse 90% 70% at 50% 60%,
      rgba(250, 255, 220, 0.62) 0%,
      rgba(160, 220, 90, 0.28) 42%,
      transparent 74%);
  opacity: 0.55;
  filter: blur(18px);
  animation: fluidDriftD 8s ease-in-out infinite, fluidMorph 7s ease-in-out infinite reverse;
}
.empty-aura .fluid-blob.b5 {
  width: 54%;
  height: 130px;
  left: 23%;
  bottom: 78px;
  background:
    radial-gradient(ellipse at 50% 50%,
      rgba(210, 255, 170, 0.42) 0%,
      rgba(100, 180, 70, 0.14) 50%,
      transparent 78%);
  opacity: 0.4;
  filter: blur(22px);
  animation: fluidDriftE 9.5s ease-in-out infinite, fluidMorph 6.5s ease-in-out infinite;
}
.empty-aura .fluid-veil {
  left: -4%;
  right: -4%;
  bottom: 8px;
  height: 220px;
  border-radius: 48% 48% 38% 38% / 78% 78% 16% 16%;
  background:
    radial-gradient(ellipse 140% 85% at 50% 100%,
      rgba(168, 220, 110, 0.3) 0%,
      rgba(40, 100, 50, 0.14) 40%,
      transparent 76%);
  filter: blur(12px);
  opacity: 0.9;
  animation: fluidVeil 13s ease-in-out infinite;
}
.empty-aura .fluid-sheen {
  width: 120px;
  height: 90px;
  left: 50%;
  bottom: 56px;
  margin-left: -60px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 40% 35%,
      rgba(255, 255, 245, 0.72) 0%,
      rgba(200, 255, 150, 0.32) 38%,
      transparent 72%);
  filter: blur(10px);
  opacity: 0.75;
  mix-blend-mode: soft-light;
  animation: fluidSheen 7s ease-in-out infinite;
}
.empty-aura .fluid-particle {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(250, 255, 230, 1);
  box-shadow:
    0 0 7px rgba(210, 255, 140, 1),
    0 0 16px rgba(136, 197, 64, 0.7),
    0 0 26px rgba(93, 154, 44, 0.35);
  opacity: 0;
  animation: particleTwinkle 5.5s ease-in-out infinite;
  will-change: transform, opacity;
  z-index: 3;
}
.empty-aura .fluid-particle.is-soft {
  width: 7px;
  height: 7px;
  background: rgba(200, 245, 150, 0.7);
  filter: blur(1px);
  box-shadow:
    0 0 10px rgba(180, 240, 100, 0.7),
    0 0 20px rgba(136, 197, 64, 0.35);
}
.empty-aura .fluid-particle.is-tiny {
  width: 3px;
  height: 3px;
}
.empty-aura .fluid-particle.p1  { left: 8%;  bottom: 52px;  animation-delay: 0s;    animation-duration: 5.1s; }
.empty-aura .fluid-particle.p2  { left: 18%; bottom: 88px;  width: 4px; height: 4px; animation-delay: -0.8s; animation-duration: 6.2s; }
.empty-aura .fluid-particle.p3  { left: 28%; bottom: 64px;  animation-delay: -1.6s; animation-duration: 4.7s; }
.empty-aura .fluid-particle.p4  { left: 38%; bottom: 118px; width: 3px; height: 3px; animation-delay: -2.3s; animation-duration: 7.1s; }
.empty-aura .fluid-particle.p5  { left: 48%; bottom: 76px;  animation-delay: -0.4s; animation-duration: 5.6s; }
.empty-aura .fluid-particle.p6  { left: 56%; bottom: 142px; width: 4px; height: 4px; animation-delay: -3.1s; animation-duration: 6.8s; }
.empty-aura .fluid-particle.p7  { left: 64%; bottom: 58px;  animation-delay: -1.2s; animation-duration: 5.0s; }
.empty-aura .fluid-particle.p8  { left: 72%; bottom: 98px;  width: 3px; height: 3px; animation-delay: -2.7s; animation-duration: 6.4s; }
.empty-aura .fluid-particle.p9  { left: 82%; bottom: 70px;  animation-delay: -4.0s; animation-duration: 5.8s; }
.empty-aura .fluid-particle.p10 { left: 90%; bottom: 110px; width: 4px; height: 4px; animation-delay: -1.9s; animation-duration: 7.4s; }
.empty-aura .fluid-particle.p11 { left: 14%; bottom: 150px; animation-delay: -3.5s; animation-duration: 6.0s; }
.empty-aura .fluid-particle.p12 { left: 42%; bottom: 46px;  width: 3px; height: 3px; animation-delay: -0.6s; animation-duration: 4.4s; }
.empty-aura .fluid-particle.p13 { left: 68%; bottom: 168px; animation-delay: -2.1s; animation-duration: 7.8s; }
.empty-aura .fluid-particle.p14 { left: 52%; bottom: 190px; width: 4px; height: 4px; animation-delay: -4.4s; animation-duration: 8.2s; }
.empty-aura .fluid-particle.p15 { left: 24%; bottom: 176px; animation-delay: -5.0s; animation-duration: 6.6s; }
.empty-aura .fluid-particle.p16 { left: 86%; bottom: 156px; width: 3px; height: 3px; animation-delay: -3.8s; animation-duration: 5.3s; }
@media (prefers-reduced-motion: reduce) {
  .empty-aura .fluid-blob,
  .empty-aura .fluid-veil,
  .empty-aura .fluid-sheen,
  .empty-aura .fluid-emit,
  .empty-aura .fluid-core,
  .empty-aura .fluid-particle {
    animation: none !important;
  }
  .empty-aura .fluid-particle { opacity: 0.4; }
  .empty-aura .fluid-core { opacity: 0.75; }
}

.empty-dock {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}
.chat-panel.is-empty .empty-dock:not([hidden]) {
  display: flex;
}
.empty-recents {
  list-style: none;
  margin: 0;
  padding: 0;
  width: min(100%, 420px);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.empty-recents:empty { display: none; }
.empty-recent {
  width: 100%;
  border: 0;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(243, 251, 232, 0.78);
  border-radius: 12px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.82rem;
  text-align: right;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.2s ease, background 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.empty-recent:nth-child(1) { opacity: 0.72; }
.empty-recent:nth-child(2) { opacity: 0.48; }
.empty-recent:nth-child(3) { opacity: 0.32; }
.empty-recent:hover { opacity: 0.95; background: rgba(255, 255, 255, 0.16); }
.empty-archive-link {
  border: 1px solid rgba(234, 246, 220, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(243, 251, 232, 0.88);
  border-radius: 999px;
  padding: 7px 14px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  writing-mode: horizontal-tb;
  opacity: 0.78;
  transition: opacity 0.2s ease, background 0.2s ease;
}
.empty-archive-link:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.14);
}
.quota-dock {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 40;
  width: 52px;
  height: 52px;
  border: 0;
  background: rgba(15, 42, 18, 0.72);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(8px);
}
.quota-dock .quota-num { color: #f4fbe9; }
.quota-dock .quota-track { stroke: rgba(255, 255, 255, 0.22); }
.quota-dock .quota-fill { stroke: #b6e06a; }
.quota-dock .quota-tooltip {
  background: #123016;
  color: #f4fbe9;
  bottom: calc(100% + 8px);
  left: 0;
  transform: none;
}

.conv-bar {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #f7fbf0, var(--white));
}
.conv-bar-title {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 800;
  color: var(--leaf-deep);
  font-size: 1.12rem;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-bar .answer-settings-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 44px;
  width: 44px;
  min-height: 44px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--leaf-deep);
  box-shadow: none;
  cursor: pointer;
}
.conv-bar .answer-settings-button:hover { background: #eaf1e4; }
.conv-bar .answer-settings-button:focus-visible { outline: 2px solid var(--leaf-deep); outline-offset: 2px; }
.conv-bar .answer-settings-button:disabled { opacity: .55; cursor: wait; }
.conv-bar .answer-settings-button svg { width: 24px; height: 24px; flex: none; }
.conv-bar-meta {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.conv-bar-meta .clock {
  font-size: 0.85rem;
  opacity: 0.85;
}
#answerTopicActions.is-peek:not(.is-revealed) {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}
#answerTopicActions.is-peek {
  max-width: 10rem;
  overflow: hidden;
  transition: opacity 0.2s ease, max-width 0.2s ease;
}
@media (prefers-reduced-motion: reduce) {
  #answerTopicActions.is-peek { transition: none; }
}

.archive-btn {
  cursor: pointer;
  font: inherit;
  border: 1px solid var(--leaf);
  background: var(--white);
  color: var(--leaf-deep);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.archive-btn:hover, .archive-btn[aria-expanded="true"] {
  background: var(--leaf-soft);
}
.notebook-btn {
  cursor: pointer;
  font: inherit;
  border: 1px solid var(--leaf);
  background: var(--white);
  color: var(--leaf-deep);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.notebook-btn:hover, .notebook-btn[aria-expanded="true"] {
  background: var(--leaf-soft);
}
.progress-btn {
  cursor: pointer;
  font: inherit;
  border: 1px solid var(--leaf);
  background: var(--white);
  color: var(--leaf-deep);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.progress-btn:hover, .progress-btn[aria-expanded="true"] {
  background: var(--leaf-soft);
}
.btn-ico { font-size: 0.95em; line-height: 1; }

.subject-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--leaf-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px 4px 6px;
  color: var(--leaf-deep);
}
.subject-field .field-ico { font-size: 0.95rem; line-height: 1; }
.subject-select {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  color: var(--leaf-deep);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 4px 18px 4px 4px;
  cursor: pointer;
  max-width: 11.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23236324'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 4px center;
}

/* —— أرشيف أفقي مغناطيسي —— */
.archive-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 24px 12px;
}
.archive-overlay[hidden] { display: none !important; }
.archive-scrim {
  position: absolute;
  inset: 0;
  background: var(--popup-backdrop, #0c241066);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.archive-sheet {
  position: relative;
  width: min(920px, 96vw);
  max-height: min(78vh, 560px);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(252, 255, 248, 0.96), rgba(243, 248, 236, 0.94));
  border: 1px solid rgba(220, 230, 212, 0.9);
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(35, 99, 36, 0.18);
  overflow: hidden;
  animation: archive-rise 0.35s ease both;
}
.archive-head {
  position: relative;
  padding: 18px 48px 14px;
  text-align: center;
}
.archive-head h2 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--leaf-deep);
  text-align: center;
}
.archive-hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}
.archive-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px auto 0;
  width: min(100%, 22rem);
  padding: 8px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(93, 154, 44, 0.22);
  box-shadow: 0 4px 12px rgba(35, 99, 36, 0.06);
}
.archive-search-ico {
  flex: 0 0 auto;
  font-size: 0.95rem;
  line-height: 1;
  opacity: 0.75;
}
.archive-search-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--leaf-deep);
  outline: none;
}
.archive-search-input::placeholder {
  color: var(--muted);
  font-weight: 500;
}
.archive-search:focus-within {
  border-color: rgba(136, 197, 64, 0.55);
  box-shadow: 0 0 0 3px rgba(136, 197, 64, 0.18);
}
.archive-close {
  position: absolute;
  top: 12px;
  left: 14px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}
.archive-close:hover { background: var(--leaf-soft); color: var(--leaf-deep); }
.archive-rail-wrap {
  flex: 1;
  min-height: 220px;
  display: flex;
  align-items: center;
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.archive-rail {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 42%;
  padding: 28px 42% 36px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  outline: none;
}
.archive-rail::-webkit-scrollbar { display: none; }
.archive-bead {
  flex: 0 0 auto;
  width: min(220px, 58vw);
  scroll-snap-align: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(251, 254, 248, 0.96));
  padding: 16px 14px;
  cursor: pointer;
  text-align: center;
  transform: scale(0.78) translateY(10px);
  opacity: 0.72;
  transition:
    transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.28s ease,
    background 0.28s ease,
    box-shadow 0.28s ease,
    border-color 0.28s ease,
    color 0.28s ease,
    filter 0.28s ease;
  color: var(--ink);
  font: inherit;
  outline: none;
  box-shadow: 0 6px 16px rgba(35, 99, 36, 0.06);
}
.archive-bead:hover {
  filter: brightness(1.01);
  background: var(--leaf-soft);
  border-color: rgba(136, 197, 64, 0.28);
  box-shadow: 0 10px 22px rgba(35, 99, 36, 0.1);
}
.archive-bead:focus-visible {
  box-shadow: 0 0 0 3px rgba(136, 197, 64, 0.35), 0 10px 22px rgba(35, 99, 36, 0.1);
}
.archive-bead.near {
  transform: scale(0.9) translateY(4px);
  opacity: 0.92;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(247, 252, 240, 0.97));
  border-color: rgba(136, 197, 64, 0.28);
  color: var(--leaf-deep);
  box-shadow: 0 8px 18px rgba(35, 99, 36, 0.08);
}
.archive-bead.selected {
  transform: scale(1.06) translateY(0);
  opacity: 1;
  background: linear-gradient(145deg, #4cae3a 0%, #2f8a2c 42%, #1f6b24 100%);
  border-color: rgba(255, 255, 255, 0.22);
  color: #fff;
  box-shadow: 0 14px 30px rgba(31, 92, 34, 0.32);
}
.archive-bead.near:hover,
.archive-bead.selected:hover {
  filter: brightness(1.03);
  transform: scale(1.04) translateY(-1px);
}
.archive-bead.near:hover {
  background: #e0f2c8;
  color: var(--leaf-deep);
}
.archive-bead.selected:hover {
  transform: scale(1.08) translateY(-1px);
  filter: brightness(1.06);
}
.archive-bead .bead-title {
  display: block;
  font-weight: 800;
  color: inherit;
  font-size: 0.95rem;
  line-height: 1.45;
  margin-bottom: 0;
  max-height: 2.9em;
  overflow: hidden;
}
.archive-bead.selected .bead-title {
  font-size: 1.05rem;
  color: #fff;
}
.archive-bead.selected .bead-ico {
  opacity: 1;
}
.archive-bead:not(.selected) .bead-title {
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  max-height: none;
}
.archive-bead .bead-date {
  display: block;
  color: inherit;
  opacity: 0.78;
  font-size: 0.78rem;
  margin: 0;
  line-height: 1.3;
  white-space: nowrap;
}
.archive-bead .bead-read {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  background: transparent;
  border-radius: 0;
  padding: 0;
  line-height: 1.3;
  white-space: nowrap;
}
.archive-bead .bead-read.is-empty {
  min-height: 1.05em;
  visibility: hidden;
}
.archive-bead .bead-read-ico {
  font-size: 0.85rem;
  opacity: 0.85;
}
.archive-bead:not(.near):not(.selected) .bead-read {
  background: transparent;
  color: inherit;
}
.archive-bead:not(.selected) .bead-side {
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  pointer-events: none;
}
.archive-bead.selected .bead-side {
  opacity: 1;
  width: auto;
  height: auto;
  pointer-events: auto;
}
.archive-bead.selected .bead-date,
.archive-bead.selected .bead-read {
  color: rgba(255, 255, 255, 0.92);
  opacity: 1;
  height: auto;
}
.archive-foot {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 12px 16px 18px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
}
.archive-new, .archive-foot .archive-open {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.archive-new {
  background: linear-gradient(135deg, var(--leaf), var(--leaf-dark));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 18px rgba(31, 92, 34, 0.22);
}
.archive-new:hover {
  filter: brightness(1.05);
  box-shadow: 0 10px 22px rgba(31, 92, 34, 0.28);
}
.archive-foot .archive-open {
  background: linear-gradient(135deg, var(--leaf), var(--leaf-dark));
  color: #fff;
  border-color: transparent;
}
.archive-empty {
  margin: 0 auto;
  color: var(--muted);
  padding: 40px 20px;
  text-align: center;
}

.messages {
  flex: 1 1 auto;
  min-height: 0; /* ضروري ليتمرّر داخل flex بدل تمديد الصفحة */
  overflow: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(180deg, #fcfef9, var(--paper));
}
/* يضغط المحادثة لأسفل فوق مربع السؤال بدل فراغ أبيض بلا معنى */
.messages::before {
  content: "";
  flex: 1 1 0;
  min-height: 0;
  pointer-events: none;
}
.thinking-dot {
  display: inline-block; width: 6px; height: 6px; margin-inline-start: 4px;
  border-radius: 50%; background: var(--leaf);
  animation: pulse 1s infinite ease-in-out;
}
.answer-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--white);
  box-shadow: 0 5px 18px rgba(35, 99, 36, 0.07);
}
.answer-table {
  width: 100%;
  min-width: 34rem;
  border-collapse: collapse;
  color: var(--ink);
  font-size: 0.94rem;
  line-height: 1.65;
}
.answer-table th,
.answer-table td {
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid var(--line);
  border-inline-end: 1px solid var(--line);
  text-align: start;
  vertical-align: top;
}
.answer-table th:last-child,
.answer-table td:last-child { border-inline-end: 0; }
.answer-table thead th {
  background: var(--leaf-soft);
  color: var(--leaf-deep);
  font-weight: 800;
}
.answer-table tbody tr:last-child td { border-bottom: 0; }
.answer-table tbody tr:nth-child(even) td { background: var(--paper-deep); }

.composer {
  display: grid; grid-template-columns: 1fr auto; gap: 10px;
  padding: 14px; border-top: 1px solid var(--line); background: #fcfffa;
}
.think-dock {
  display: none;
  align-items: center;
  gap: 8px;
  margin: 0 14px;
  padding: 10px 12px;
  border: 1px dashed var(--leaf);
  border-radius: 12px;
  background: var(--white);
  color: var(--leaf-deep);
  font-weight: 700;
  font-size: 0.92rem;
}
.think-dock.active,
.think-dock:not([hidden]) {
  display: flex;
}
.think-dock[hidden] { display: none !important; }
.think-label, .think-label { flex: 1; }
.think-dot, .think-dot {
  display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: var(--leaf);
  animation: pulse 1s infinite ease-in-out;
}
textarea {
  resize: none; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; font: inherit; color: var(--ink); background: #fff;
}
textarea:focus { outline: 2px solid rgba(136, 197, 64, 0.35); border-color: var(--leaf); }
.send-btn,
button[type="submit"] {
  border: 0; border-radius: 12px; min-width: 52px; padding: 0 14px;
  background: linear-gradient(135deg, var(--leaf), var(--leaf-dark));
  color: #fff; font: inherit; font-size: 1.35rem; line-height: 1; cursor: pointer;
  transition: transform .15s ease, opacity .15s ease;
}
.send-btn:hover { transform: translateY(-1px); }
button[type="submit"]:disabled { opacity: 0.75; cursor: wait; }
.send-btn[data-state="search"] { filter: saturate(1.1); }
.send-btn[data-state="found"],
.send-btn[data-state="reply"] { filter: saturate(1.2) brightness(1.05); }
.notebook-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
}
.notebook-empty {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.6;
}
.notebook-item {
  position: relative;
  background: var(--white);
  border: 1px solid var(--line);
  border-inline-start: 3px solid var(--ev-concept);
  border-radius: 10px;
  padding: 8px 28px 8px 10px;
}
.notebook-item.role-relation { border-inline-start-color: var(--ev-relation); }
.notebook-item.role-caution { border-inline-start-color: var(--ev-caution); }
.notebook-item p {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.65;
  color: var(--ink);
}
.notebook-del {
  position: absolute;
  top: 4px;
  inset-inline-end: 6px;
  inset-inline-start: auto;
  left: auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.notebook-pop {
  position: fixed;
  transform: translate(-50%, calc(-100% - 4px));
  z-index: 80;
  border: 0;
  border-radius: 999px;
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  background: #1f5c22;
  color: #fff;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(35, 99, 36, 0.28);
  white-space: nowrap;
  opacity: 1;
  line-height: 1;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.notebook-pop:active {
  transform: translate(-50%, calc(-100% - 2px)) scale(0.96);
}
.notebook-pop.is-busy {
  background: #2f6f32;
  cursor: wait;
}
.notebook-pop.is-ok {
  background: #1a7a32;
  box-shadow: 0 0 0 3px rgba(136, 197, 64, 0.35), 0 6px 18px rgba(35, 99, 36, 0.28);
}
.notebook-pop.is-err {
  background: #a33b2d;
}
.notebook-pop-ico {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
}
.notebook-pop-ico svg {
  display: block;
}
.notebook-pop-spin {
  animation: notebookPopSpin 0.7s linear infinite;
}
.notebook-pop[hidden] { display: none !important; }

.notebook-toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%) translateY(12px);
  z-index: 90;
  max-width: min(90vw, 280px);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(26, 79, 29, 0.94);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 700;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  text-align: center;
}
.notebook-toast.is-err {
  background: rgba(140, 48, 36, 0.95);
}
.notebook-toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.side { display: flex; flex-direction: column; gap: 12px; }
.card { padding: 16px; }
.card h2 { margin: 0 0 10px; font-size: 1rem; color: var(--leaf-deep); }
.card p { margin: 0; line-height: 1.7; }
.list, .price { margin: 10px 0 0; padding: 0 18px; line-height: 1.9; color: var(--muted); }
.price strong { color: var(--leaf-deep); }
.fine { margin-top: 10px !important; font-size: 0.82rem; color: var(--muted); }
.soon { background: linear-gradient(180deg, #fff, #f7fcf1); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .top { align-items: flex-start; flex-direction: row; }
  .chat-panel { min-height: 65vh; }
  .chat-panel.is-empty { min-height: calc(100vh - 140px) !important; }
  .archive-rail { padding-inline: 28%; scroll-padding-inline: 28%; }
}


/* —— حصة دائرية —— */
.quota-ring {
  position: relative;
  width: 42px;
  height: 42px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.quota-dock {
  width: 52px;
  height: 52px;
}
.quota-dock svg {
  width: 46px;
  height: 46px;
}
.quota-ring svg {
  width: 42px;
  height: 42px;
  transform: rotate(-90deg);
}
.quota-track {
  fill: none;
  stroke: #e4edd8;
  stroke-width: 3.2;
}
.quota-fill {
  fill: none;
  stroke: var(--leaf);
  stroke-width: 3.2;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.45s ease, stroke 0.3s ease;
}
.quota-fill.low { stroke: #c47a1a; }
.quota-num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--leaf-deep);
  pointer-events: none;
}
.quota-tooltip {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--ink);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 20;
}
.quota-ring:hover .quota-tooltip,
.quota-ring:focus-visible .quota-tooltip,
.quota-ring:focus .quota-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--white);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  color: var(--leaf-deep);
}
.icon-btn:hover, .icon-btn[aria-expanded="true"] {
  background: var(--leaf-soft);
  border-color: var(--leaf);
}
.icon-btn.ghost {
  border: 0;
  background: transparent;
  width: 32px;
  height: 32px;
  font-size: 1.25rem;
  color: var(--muted);
}

.notebook-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.notebook-head h2 { margin: 0; }

/* —— أرشيف عمودي —— */
.archive-sheet-vertical {
  width: min(420px, 94vw);
  max-height: min(82vh, 640px);
}
.archive-rail-wrap-vertical {
  min-height: 280px;
  mask-image: linear-gradient(180deg, transparent, #000 10%, #000 90%, transparent);
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 10%, #000 90%, transparent);
}
.archive-rail-vertical {
  flex-direction: column;
  align-items: stretch;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scroll-padding-block: 36%;
  padding: 36% 18px;
  gap: 12px;
}
.archive-rail-vertical .archive-bead {
  width: 100%;
  scroll-snap-align: center;
  transform: scale(0.92) translateY(0);
  text-align: start;
  padding: 14px 16px;
}
.archive-rail-vertical .archive-bead.near {
  transform: scale(0.97);
}
.archive-rail-vertical .archive-bead.selected {
  transform: scale(1.02);
  background: linear-gradient(145deg, #4cae3a 0%, #2f8a2c 42%, #1f6b24 100%);
  border-color: rgba(255, 255, 255, 0.22);
  color: #fff;
}
.archive-rail-vertical .archive-bead.selected .bead-title {
  color: #fff;
}
.archive-rail-vertical .archive-bead.near:hover {
  transform: scale(0.99) translateY(-1px);
}
.archive-rail-vertical .archive-bead.selected:hover {
  transform: scale(1.035) translateY(-1px);
}
.archive-rail-vertical .archive-bead .bead-title {
  white-space: normal;
  max-height: none;
  text-align: start;
}
.archive-rail-vertical .archive-bead .bead-body {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}
.archive-rail-vertical .archive-bead .bead-main {
  flex: 1;
  min-width: 0;
}
.archive-rail-vertical .archive-bead .bead-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end; /* أقصى اليسار بصريًا في RTL */
  justify-content: space-between;
  align-self: stretch;
  gap: 6px;
  text-align: end;
  flex: 0 0 auto;
  margin: 0;
}
.archive-rail-vertical .archive-bead:not(.selected) .bead-side {
  opacity: 0;
  width: 0;
  min-width: 0;
  height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  gap: 0;
}
.archive-rail-vertical .archive-bead.selected .bead-side {
  opacity: 1;
  width: auto;
  height: auto;
}
.archive-rail-vertical .archive-bead.selected .bead-read,
.archive-rail-vertical .archive-bead.selected .bead-date {
  color: rgba(255, 255, 255, 0.92);
  opacity: 1;
}

@media (max-width: 860px) {
  .layout.notebook-open { grid-template-columns: 1fr; }
  .archive-rail-vertical { padding-block: 28%; scroll-padding-block: 28%; }
}


/* —— مرادفات أسماء الفئات (HTML الحالي) —— */
.archive-scrim { position: absolute; inset: 0; background: var(--popup-backdrop, #0c241066); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.archive-sheet { position: relative; width: min(920px, 96vw); max-height: min(78vh, 560px); display: flex; flex-direction: column; background: linear-gradient(180deg, rgba(252,255,248,.96), rgba(243,248,236,.94)); border: 1px solid rgba(220,230,212,.9); border-radius: 22px; box-shadow: 0 24px 60px rgba(35,99,36,.18); overflow: hidden; animation: archive-rise .35s ease both; }
.archive-sheet-vertical {
  width: min(420px, 94vw);
  height: min(82vh, 640px);
  height: min(82dvh, 640px);
  max-height: calc(100dvh - 48px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.archive-head { position: relative; padding: 18px 48px 14px; text-align: center; }
.archive-head h2 { margin: 0; font-size: 1.15rem; color: var(--leaf-deep); text-align: center; }
.archive-hint { display: none !important; }
.archive-rail-wrap { flex: 1; min-height: 220px; display: flex; align-items: center; }
.archive-rail-wrap-vertical { min-height: 0; overflow: hidden; align-items: stretch; mask-image: linear-gradient(180deg, transparent, #000 10%, #000 90%, transparent); -webkit-mask-image: linear-gradient(180deg, transparent, #000 10%, #000 90%, transparent); }
.archive-rail-vertical {
  height: 100%;
  min-height: 0;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
html.archive-open, body.archive-open { overflow: hidden !important; }
.archive-overlay { overscroll-behavior: contain; touch-action: pan-y; }
.archive-scrim, .archive-head, .archive-foot { touch-action: none; }
.quota-num {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: .72rem; font-weight: 800; color: var(--leaf-deep); pointer-events: none;
}
.quota-tooltip {
  position: absolute; top: calc(100% + 8px); left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--ink); color: #fff; font-size: .72rem; font-weight: 700;
  padding: 6px 10px; border-radius: 8px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .15s ease, transform .15s ease; z-index: 20;
}
.quota-ring:hover .quota-tooltip,
.quota-ring:focus-visible .quota-tooltip { opacity: 1; transform: translateX(-50%) translateY(0); }
.quota-fill.low { stroke: #c47a1a; }
.notebook-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.notebook-head h2 { margin: 0; }
.icon-btn.ghost { border: 0; background: transparent; width: 32px; height: 32px; font-size: 1.25rem; color: var(--muted); }
.chat-panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; min-height: 0; height: 100%; overflow: hidden; position: relative; }
.chat-panel.is-empty {
  min-height: calc(100dvh - 96px) !important;
  height: calc(100dvh - 96px) !important;
  max-width: min(100%, 560px);
  margin-inline: auto;
  width: 100%;
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  justify-content: center !important;
}
.archive-bead {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  position: relative;
}
.archive-bead .bead-ico {
  flex: 0 0 auto;
  font-size: 1.05rem;
  line-height: 1.4;
  opacity: 0.85;
}
.archive-bead .bead-body { flex: 1; min-width: 0; }
.archive-bead .bead-main { min-width: 0; }
.archive-bead .bead-open { display: none !important; }
.archive-foot {
  justify-content: center;
}
.archive-new {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto;
  min-width: 70%;
  justify-content: center;
  background: linear-gradient(135deg, var(--leaf), var(--leaf-dark));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 18px rgba(31, 92, 34, 0.22);
}
.archive-new:hover {
  filter: brightness(1.05);
}
/* conv-bar layout defined once above (flex: title | meta | progress) */


/* —— overrides: UX polish Sep 2026 —— */
.chat-panel.is-empty { min-height: calc(100vh - 120px) !important; }
.notebook-pop {
  background: #1a4f1d !important;
  opacity: 1 !important;
  position: fixed !important;
  transform: translate(-50%, calc(-100% - 4px)) !important;
  width: 36px !important;
  height: 36px !important;
  padding: 0 !important;
  z-index: 80 !important;
}
.notebook-pop.is-ok {
  background: #1a7a32 !important;
}
.notebook-pop.is-err {
  background: #a33b2d !important;
}

/* —— اختيار المادة: شاشة كاملة حديثة —— */
.subject-trigger {
  cursor: pointer;
  font: inherit;
  border: 1px solid var(--leaf);
  background: var(--leaf-soft);
  color: var(--leaf-deep);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 13rem;
}
.subject-trigger:hover,
.subject-trigger[aria-expanded="true"] {
  background: #e2f3cf;
  border-color: var(--leaf-dark, #5d9a2c);
}
.subject-trigger #subjectBtnLabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  font-size: 0.85rem;
}
.subject-chevron {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-inline-start: 2px;
}

.subject-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 0;
}
.subject-overlay[hidden] { display: none !important; }
.subject-scrim {
  position: absolute;
  inset: 0;
  background: rgba(22, 36, 22, 0.48);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.subject-sheet {
  position: relative;
  width: 100%;
  height: 100%;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at top right, rgba(136, 197, 64, 0.18), transparent 42%),
    linear-gradient(180deg, #f7fbf0 0%, #ffffff 38%);
  overflow: hidden;
  animation: subject-rise 0.32s ease both;
}
.subject-head {
  position: relative;
  padding: 28px 56px 12px 24px;
  text-align: center;
}
.subject-head h2 {
  margin: 0;
  font-size: 1.45rem;
  color: var(--leaf-deep);
  font-weight: 800;
}
.subject-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.subject-close {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.85);
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  box-shadow: 0 4px 14px rgba(35, 99, 36, 0.1);
}
.subject-close:hover {
  background: var(--leaf-soft);
  color: var(--leaf-deep);
}
.subject-grid {
  flex: 1;
  overflow: auto;
  padding: 12px 20px 36px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 14px;
  align-content: start;
}
.subject-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 132px;
  padding: 18px 12px 14px;
  border: 1px solid rgba(220, 230, 212, 0.95);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  text-align: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
  box-shadow: 0 8px 20px rgba(35, 99, 36, 0.06);
}
.subject-card:hover:not(.is-locked) {
  transform: translateY(-3px);
  border-color: var(--leaf);
  box-shadow: 0 14px 28px rgba(35, 99, 36, 0.12);
}
.subject-card.is-active {
  border-color: var(--leaf);
  background: linear-gradient(180deg, #eef8e0, #ffffff);
  box-shadow: 0 12px 28px rgba(35, 99, 36, 0.14);
}
.subject-card.is-locked {
  cursor: not-allowed;
  opacity: 0.55;
  filter: grayscale(0.25);
  background: #f7f8f5;
}
.subject-card-ico {
  font-size: 1.85rem;
  line-height: 1;
}
.subject-card-label {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--leaf-deep);
  line-height: 1.35;
}
.subject-card.is-locked .subject-card-label {
  color: #667066;
}
.subject-card-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e8ebe4;
  color: #5f6b5f;
}
.subject-card-badge.on {
  background: var(--leaf);
  color: #fff;
}
body.subject-picker-open { overflow: hidden; }
@media (min-width: 720px) {
  .subject-overlay { padding: 24px 12px; }
  .subject-sheet {
    width: min(880px, 94vw);
    height: min(86vh, 720px);
    max-height: 86vh;
    border-radius: 28px;
    border: 1px solid rgba(220, 230, 212, 0.95);
    box-shadow: 0 28px 70px rgba(35, 99, 36, 0.2);
  }
  .subject-grid {
    grid-template-columns: repeat(3, 1fr);
    padding: 8px 28px 32px;
  }
}

/* aliases matching JS class names */
.subject-card-ico { font-size: 1.85rem; line-height: 1; }
.subject-card-label { font-weight: 800; font-size: 0.95rem; color: var(--leaf-deep); line-height: 1.35; }
.subject-card.is-locked .subject-card-label { color: #667066; }
.subject-card-badge { position: absolute; top: 10px; left: 10px; font-size: 0.68rem; font-weight: 800; padding: 3px 8px; border-radius: 999px; background: #e8ebe4; color: #5f6b5f; }
.subject-card-badge.on { background: var(--leaf); color: #fff; }


/* top bar dark controls */
.top .subject-trigger,
.top .notebook-btn,
.top .archive-btn,
.top .progress-btn,
.top .subject-field {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(234, 246, 220, 0.26);
  color: #f4fbe9;
}
.top .subject-trigger:hover,
.top .notebook-btn:hover,
.top .archive-btn:hover,
.top .progress-btn:hover,
.top .subject-trigger[aria-expanded="true"],
.top .notebook-btn[aria-expanded="true"],
.top .archive-btn[aria-expanded="true"],
.top .progress-btn[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.4);
}
.top .subject-select { color: #f4fbe9; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23f4fbe9'/%3E%3C/svg%3E"); }
.top .subject-chevron { opacity: 0.85; }
@media (max-width: 860px) {
  .top { align-items: flex-start; }
  .brand-cluster { flex-wrap: wrap; }
  .top-side-stack .pill { min-width: 0; }
  .top.is-compact .subject-trigger { display: none; }
  .top.is-compact .top-actions,
  .top.is-compact .top-side-stack {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
  }
  .chat-panel.is-empty { min-height: calc(100vh - 140px) !important; }
  .quota-dock { left: 12px; bottom: 12px; width: 46px; height: 46px; }
}


/* ===== landing hero: viewport-centered (beats legacy overrides) ===== */
/*
  overflow-x:hidden على body يحوّل overflow-y إلى auto فيقصّ التوهج.
  على الشاشة الفارغة نفتح القص حتى يمتد الهلامي للأعلى بحرية.
*/
body.is-landing {
  overflow: visible !important;
}

/* Legal links belong to the home state, not the conversation/dashboard state. */
body:not(.is-landing) .lm-privacy-footer { display: none !important; }
body.is-landing .app,
body.is-landing .layout {
  overflow: visible !important;
}
body.is-landing .chat-panel.is-empty {
  min-height: 0 !important;
  height: auto !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  overflow: visible !important;
}
body.is-landing .chat-panel.is-empty .conv-bar,
body.is-landing .chat-panel.is-empty .think-dock,
body.is-landing .chat-panel.is-empty .messages {
  display: none !important;
}
/* وسط الثلث الأخير: مركز النموذج عند ≈ 83% من ارتفاع الصفحة */
body.is-landing .ask-hero {
  position: fixed !important;
  inset-inline: 0;
  top: 83.333% !important;
  left: 50% !important;
  right: auto !important;
  bottom: auto !important;
  transform: translate(-50%, -50%) !important;
  width: min(560px, calc(100vw - 40px)) !important;
  margin: 0 !important;
  z-index: 20;
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 12px !important;
  pointer-events: none;
  overflow: visible !important;
}
body.is-landing .ask-hero .composer,
body.is-landing .ask-hero .composer-stack,
body.is-landing .ask-hero .quiz-dock-btn,
body.is-landing .ask-hero .empty-dock {
  pointer-events: auto;
}
body.is-landing .chat-panel.is-empty {
  overflow: visible !important;
}
/*
  المرحلة مثبتة على حافة مربع السؤال (أعلى الـ composer)،
  لا على أسفل الـ dock — حتى يخرج التوهج من عرض الإدخال.
*/
body.is-landing .empty-stage {
  display: block !important;
  position: absolute !important;
  left: 0;
  right: 0;
  top: 0;
  bottom: auto !important;
  height: 0;
  pointer-events: none !important;
  overflow: visible !important;
  z-index: 0;
}
body.is-landing .empty-aura {
  left: -2%;
  right: -2%;
  /* يتداخل قليلاً مع أعلى مربع السؤال ليبدو منبعثاً منه */
  bottom: -44px;
  height: 440px;
  overflow: visible !important;
}
body.is-landing .ask-hero .composer {
  order: 0;
  width: 100%;
  position: relative;
  z-index: 2;
  overflow: visible !important;
  box-shadow:
    0 10px 28px rgba(20, 48, 24, 0.18),
    0 -10px 36px rgba(136, 197, 64, 0.12);
}
/* وهج ملاصق لعرض مربع السؤال — يضمن الامتداد الأفقي الكامل */
body.is-landing .ask-hero .composer::before {
  content: "";
  position: absolute;
  left: 4%;
  right: 4%;
  top: -72px;
  height: 88px;
  border-radius: 50% 50% 40% 40% / 80% 80% 20% 20%;
  background:
    radial-gradient(ellipse 100% 90% at 50% 100%,
      rgba(245, 255, 210, 0.55) 0%,
      rgba(168, 220, 100, 0.28) 35%,
      rgba(136, 197, 64, 0.1) 60%,
      transparent 78%);
  filter: blur(14px);
  pointer-events: none;
  z-index: -1;
  animation: fluidComposerWash 8s ease-in-out infinite;
}
body.is-landing .empty-dock {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
body.is-landing .empty-archive-link {
  writing-mode: horizontal-tb;
  opacity: 0.55;
  font-size: 0.78rem;
  padding: 6px 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(234,246,220,0.16);
  color: rgba(243,251,232,0.75);
  letter-spacing: 0.01em;
}
body.is-landing .empty-archive-link:hover {
  opacity: 0.95;
  background: rgba(255,255,255,0.12);
}
body.is-landing .empty-recents {
  width: min(100%, 380px);
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
body.is-landing .empty-recent {
  width: auto;
  max-width: 140px;
  padding: 6px 10px;
  font-size: 0.75rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.07);
}
body.is-landing .empty-recent:nth-child(1) { opacity: 0.55; }
body.is-landing .empty-recent:nth-child(2) { opacity: 0.38; }
body.is-landing .empty-recent:nth-child(3) { opacity: 0.24; }
body:not(.is-landing) .ask-hero {
  position: static !important;
  transform: none !important;
  width: 100% !important;
  inset: auto !important;
  pointer-events: auto;
}


/* ===== top bar: clean shell alignment ===== */
.top {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 10px;
  margin: 0 0 12px;
  padding: 6px 0 !important;
  min-height: 52px;
  height: auto !important;
  border-radius: 0 !important;
  /* landing keeps frameless; answer mode paints opaque bar below */
  background: transparent !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  isolation: isolate;
  transform: translateZ(0);
}
.top.is-compact {
  padding: 4px 0 !important;
}
.brand-cluster {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 10px !important;
  min-width: 0;
  flex: 0 0 auto;
}
.brand {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 10px;
  flex-shrink: 0;
}
.brand-cluster .subject-trigger {
  flex: 0 1 auto;
  max-width: min(22rem, 46vw);
  margin: 0 !important;
  align-self: center !important;
  transition: none !important;
  animation: none !important;
}
.top-side-stack,
.top-actions {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 10px !important;
  flex: 0 0 auto !important;
  max-width: none !important;
  margin-inline-start: auto !important;
  margin-inline-end: 0 !important;
  padding: 0 !important;
  opacity: 1 !important;
  transform: none !important;
}
.top-side-stack .pill {
  min-width: 0;
  justify-content: flex-start;
  margin: 0 !important;
}
.top.is-compact .subject-trigger {
  display: none !important;
}
.top.is-compact .top-actions,
.top.is-compact .top-side-stack {
  display: flex !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}
/* prevent flicker from competing transitions */
.brand-cluster,
.brand-cluster *,
.top h1,
.top .pill {
  animation: none !important;
}
.top .pill {
  backdrop-filter: none;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(234,246,220,0.22);
  color: #f4fbe9;
}
.quota-dock {
  position: fixed !important;
  left: 16px !important;
  bottom: 16px !important;
  right: auto !important;
  top: auto !important;
  z-index: 45 !important;
}
@media (max-width: 860px) {
  .brand-cluster { flex-wrap: nowrap !important; }
  .top-side-stack .pill { min-width: 0; }
  .top .subject-trigger #subjectBtnLabel {
    max-width: 7.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}



/* ===== anti-flicker brand plate (landing stays frameless) ===== */
body:not(.is-landing) .top {
  /* opaque plate while answer CSS loads / before fixed bar wins */
  background: #143416 !important;
  border-radius: 0 !important;
  box-shadow: 0 6px 18px rgba(0,0,0,0.18) !important;
}
.brand-cluster {
  contain: layout style paint;
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-font-smoothing: antialiased;
}
.brand-cluster h1,
.brand-cluster .subject-trigger,
.brand-cluster .logo {
  transform: translateZ(0);
  backface-visibility: hidden;
  filter: none !important;
  transition: none !important;
  animation: none !important;
  will-change: auto !important;
}
.top .subject-trigger,
.top .pill {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
#subjectSelect {
  display: none !important;
  position: absolute !important;
  left: -9999px !important;
}


/* ===== frameless top bar (landing / empty only) ===== */
body.is-landing .top,
body.is-landing .top.is-compact {
  background: transparent !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 4px 0 !important;
  margin: 0 0 10px !important;
  min-height: 0 !important;
  height: auto !important;
  align-items: center !important;
  justify-content: flex-start !important;
  /* مسافة موحّدة بين الشعار والمادة والأزرار */
  gap: 10px !important;
}
/* base spacing when not landing — answer mode overrides below */
body:not(.is-landing) .top,
body:not(.is-landing) .top.is-compact {
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 10px !important;
  min-height: 0 !important;
  height: auto !important;
}
.brand-cluster {
  display: flex !important;
  flex: 0 0 auto !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 10px !important;
  min-width: 0 !important;
}
.brand {
  gap: 10px !important;
  flex-shrink: 0 !important;
}
.top-side-stack,
.top-actions {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 10px !important;
  max-width: none !important;
  flex: 0 0 auto !important;
  /* أقصى اليسار دائمًا (نهاية الصف في RTL) */
  margin-inline-start: auto !important;
  margin-inline-end: 0 !important;
}
.top-side-stack .pill {
  min-width: 0 !important;
  padding: 8px 12px !important;
  gap: 6px !important;
}
/* أولوية لاسم المادة — تأخذ المساحة بين الشعار والأزرار */
.top > .subject-trigger,
.brand-cluster .subject-trigger,
.top .subject-trigger {
  flex: 1 1 auto !important;
  width: auto !important;
  max-width: none !important;
  min-width: 0 !important;
  justify-content: flex-start !important;
  padding: 10px 14px !important;
  border-radius: 14px !important;
  font-size: 1rem !important;
  gap: 8px !important;
  margin: 0 !important;
}
.top .subject-trigger #subjectBtnLabel {
  flex: 1 1 auto;
  font-size: 1.05rem !important;
  font-weight: 800 !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: none !important;
}
.top .subject-trigger .subject-chevron {
  margin-inline-start: 4px;
  flex-shrink: 0;
  opacity: 0.85;
}
.top.is-compact .subject-trigger {
  display: none !important;
}
.top.is-compact .top-actions,
.top.is-compact .top-side-stack {
  display: flex !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

/* شاشات أضيق: أولوية لاسم المادة — أرشيف/دفتري أيقونة فقط */
@media (max-width: 1100px) {
  .top,
  .top.is-compact {
    gap: 8px !important;
  }
  .brand-cluster,
  .top-side-stack,
  .top-actions {
    gap: 8px !important;
  }
  .top .archive-btn .btn-text,
  .top .notebook-btn .btn-text,
  .top .progress-btn .btn-text {
    display: none !important;
  }
  .top .archive-btn,
  .top .notebook-btn,
  .top .progress-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    padding: 0 !important;
    justify-content: center !important;
    border-radius: 12px !important;
  }
  .top .archive-btn .btn-ico,
  .top .notebook-btn .btn-ico,
  .top .progress-btn .btn-ico {
    margin: 0 !important;
    font-size: 1.05rem;
  }
  .top .subject-trigger {
    padding: 8px 12px !important;
  }
  .top .subject-trigger #subjectBtnLabel {
    font-size: 0.95rem !important;
  }
  .brand h1 {
    font-size: 1.05rem !important;
  }
}

@media (max-width: 560px) {
  .brand h1 {
    max-width: 6.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .top .subject-trigger {
    padding: 8px 10px !important;
  }
  .top .subject-trigger #subjectBtnLabel {
    font-size: 0.9rem !important;
  }
  .top .archive-btn,
  .top .notebook-btn {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    border-radius: 11px !important;
  }
}




/* اعتماد على عرض الشريط نفسه (أدق من viewport داخل المعاينة) */
.top {
  container-type: inline-size;
  container-name: topbar;
}
.top.is-narrow .archive-btn .btn-text,
.top.is-narrow .notebook-btn .btn-text,
.top.is-narrow .progress-btn .btn-text {
  display: none !important;
}
.top.is-narrow .archive-btn,
.top.is-narrow .notebook-btn,
.top.is-narrow .progress-btn {
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  padding: 0 !important;
  justify-content: center !important;
  border-radius: 12px !important;
  gap: 0 !important;
}
.top.is-narrow .archive-btn .btn-ico,
.top.is-narrow .notebook-btn .btn-ico,
.top.is-narrow .progress-btn .btn-ico {
  margin: 0 !important;
  font-size: 1.05rem;
}
@container topbar (max-width: 900px) {
  .archive-btn .btn-text,
  .notebook-btn .btn-text,
  .progress-btn .btn-text {
    display: none !important;
  }
  .archive-btn,
  .notebook-btn,
  .progress-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    padding: 0 !important;
    justify-content: center !important;
    border-radius: 12px !important;
    gap: 0 !important;
  }
}

/* ===== answer mode: full-bleed sticky top bar =====
   Use position:fixed + 100vw so the bar is truly edge-to-edge.
   (margin breakout fails inside .app when body has overflow-x:hidden.)
   Opaque plate on .app::before (same stacking context as .top) so chat
   cannot paint through, while brand/actions stay above the plate. */
body:not(.is-landing) .app::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 72px;
  box-sizing: border-box;
  background-color: #0c2410;
  background-image: linear-gradient(180deg, #0c2410 0%, #143416 48%, #1a4a1c 100%);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid rgba(182, 224, 106, 0.14);
  z-index: 9998;
  pointer-events: none;
}
body:not(.is-landing) .app:has(.top.is-compact)::before {
  height: 56px;
  background-color: #0a1e0c;
  background-image: linear-gradient(180deg, #0a1e0c 0%, #123214 100%);
}
body:not(.is-landing) .top,
body:not(.is-landing) .top.is-compact {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: auto !important;
  width: 100vw !important;
  max-width: 100vw !important;
  margin: 0 !important;
  padding-block: 10px !important;
  padding-inline: max(16px, calc(50vw - min(550px, calc(50vw - 20px)))) !important;
  box-sizing: border-box !important;
  background-color: #0c2410 !important;
  background-image:
    linear-gradient(180deg, #0c2410 0%, #143416 48%, #1a4a1c 100%) !important;
  background-repeat: no-repeat !important;
  opacity: 1 !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  box-shadow: none !important;
  border: 0 !important;
  border-bottom: 0 !important;
  border-radius: 0 !important;
  z-index: 9999 !important;
  isolation: isolate !important;
  transform: translateZ(0) !important;
  pointer-events: auto !important;
}
body:not(.is-landing) .top.is-compact {
  padding-block: 6px !important;
  background-color: #0a1e0c !important;
  background-image:
    linear-gradient(180deg, #0a1e0c 0%, #123214 100%) !important;
}
/* Reserve space so content does not jump under the fixed top bar */
body:not(.is-landing) .app {
  padding-top: 72px !important;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  box-sizing: border-box;
}
body:not(.is-landing) .app:has(.top.is-compact) {
  padding-top: 56px !important;
}
body:not(.is-landing) .layout {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

/* الحصة الأسبوعية: تظهر فقط في شاشة البداية، وتختفي خلف/مع نافذة الإجابة */
body:not(.is-landing) .quota-dock {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transform: scale(0.92);
  transition: opacity 0.28s ease, visibility 0.28s ease, transform 0.28s ease;
}
body.is-landing .quota-dock {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  z-index: 20;
  transition: opacity 0.28s ease, visibility 0.28s ease, transform 0.28s ease;
}
body:not(.is-landing) .chat-panel {
  position: relative;
  z-index: 1;
  min-height: 0;
  height: 100%;
}
body:not(.is-landing) .chat-panel .messages {
  min-height: 0;
  /* Keep the last lab controls above the sticky composer so clicks hit buttons, not #question. */
  padding-bottom: max(18px, calc(6.75rem + env(safe-area-inset-bottom, 0px)));
}


/* تثبيت أرشيف/دفتري أقصى اليسار + أولوية اسم المادة */
.top .top-actions,
.top .top-side-stack,
body:not(.is-landing) .top .top-actions,
body.is-landing .top .top-actions {
  margin-inline-start: auto !important;
  margin-inline-end: 0 !important;
  flex: 0 0 auto !important;
}
.top > .subject-trigger,
body:not(.is-landing) .top > .subject-trigger,
body.is-landing .top > .subject-trigger {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  max-width: none !important;
}
.top .subject-trigger #subjectBtnLabel {
  max-width: none !important;
}

/* ===== frame morph ===== */
body.is-morphing {
  overflow: hidden;
}
body.is-morphing .ask-hero,
body.is-morphing .chat-panel {
  /* لا تضبط left/top/width/height هنا — يتحكم بها الـ JS بـ !important */
  animation: none !important;
  pointer-events: none !important;
  will-change: left, top, width, height;
}
body.is-morphing .empty-stage,
body.is-morphing .empty-dock {
  transition: opacity 0.22s ease-in-out;
  pointer-events: none;
}
body.is-morphing .top {
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  body.is-morphing .ask-hero,
  body.is-morphing .chat-panel {
    transition: none !important;
  }
}

/* ===== أسئلة التحقق — هالة فوق زر الإرسال ===== */
.composer-stack {
  position: relative;
  display: block;
  width: 100%;
  padding-top: 0;
  overflow: visible;
  transition: padding-top 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.composer-stack.has-quiz-dock {
  /* بروز ضئيل — الحبة شارة على ركن زر الإرسال */
  padding-top: 0.2rem;
}
/* استعادة زوايا نافذة الدردشة — لا تفرّغ overflow اللوحة */
.chat-panel {
  overflow: hidden !important;
  border-radius: var(--radius, 16px) !important;
}
.chat-panel .messages {
  overflow: auto;
}
.ask-hero {
  overflow: visible;
}

/* تقدّم القراءة — في نهاية شريط المحادثة بعد المدة */
.read-progress {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
}
.read-progress[hidden] { display: none !important; }
.read-progress-metric {
  position: relative;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
}
.read-progress-ring {
  width: 32px;
  height: 32px;
  transform: rotate(-90deg);
  display: block;
}
.read-progress-ring-track {
  fill: none;
  stroke: #e5eedc;
  stroke-width: 3.2;
}
.read-progress-ring-fill {
  fill: none;
  stroke: var(--leaf);
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-dasharray: 97.39;
  stroke-dashoffset: 97.39;
  transition: stroke-dashoffset 0.35s ease;
}
.read-progress-pct {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.56rem;
  font-weight: 800;
  color: var(--leaf-deep);
  line-height: 1;
  pointer-events: none;
}
/* ساعة المكوث: نسخة رمادية تحت + ملء أخضر من الأسفل */
.read-progress-clock-wrap {
  position: relative;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}
.read-progress-clock-icon {
  width: 22px;
  height: 22px;
  display: block;
}
.read-progress-clock-icon.is-base {
  color: #d5e2ce;
}
.read-progress-clock-fill {
  position: absolute;
  inset: 0;
  overflow: hidden;
  /* --dwell من 0% إلى 100% يملأ الأيقونة من الأسفل بالأخضر */
  clip-path: inset(calc(100% - var(--dwell, 0%)) 0 0 0);
  transition: clip-path 0.35s ease;
}
.read-progress-clock-icon.is-fill {
  color: var(--leaf);
}
.read-progress-clock-fill.is-ready .read-progress-clock-icon.is-fill {
  color: var(--leaf-deep);
}
.read-progress-dwell {
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--leaf-deep);
  white-space: nowrap;
}
.chat-panel.is-empty .read-progress { display: none !important; }
body.is-landing .chat-panel.is-empty .read-progress { display: none !important; }

/* ===== عارض 3D — بطاقة داخل الإجابة + نافذة تفاعل ===== */
.viz3d-teaser {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  margin: 0.85rem 0 0.15rem;
  padding: 8px;
  border-radius: 16px;
  border: 1px solid rgba(120, 190, 210, 0.45);
  background:
    linear-gradient(135deg, rgba(210, 240, 248, 0.95) 0%, rgba(236, 248, 255, 0.92) 48%, rgba(255, 255, 255, 0.98) 100%);
  box-shadow: 0 10px 28px rgba(35, 99, 36, 0.08);
  overflow: hidden;
}
.viz3d-teaser-preview {
  position: relative;
  width: 100%;
  min-height: 140px;
  aspect-ratio: 16 / 10;
  max-height: 176px;
  border-radius: 14px;
  border: 2px solid rgba(120, 210, 230, 0.85);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.65) inset,
    0 0 18px rgba(90, 200, 230, 0.35);
  background:
    radial-gradient(ellipse at 50% 30%, #f7fcff 0%, #d9eef5 55%, #b9dbe8 100%);
  overflow: hidden;
}
.viz3d-badge {
  position: absolute;
  top: 8px;
  inset-inline-start: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  color: #1a4a5c;
  font-size: 0.68rem;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(20, 60, 80, 0.12);
}
.viz3d-badge-cube {
  width: 0.7rem;
  height: 0.7rem;
  border: 1.5px solid #1a4a5c;
  transform: rotate(45deg) skewX(-8deg);
  border-radius: 2px;
}
.viz3d-teaser-art {
  position: absolute;
  inset: 12% 10% 18%;
  background:
    radial-gradient(circle at 50% 18%, #fff 0 10%, transparent 11%),
    linear-gradient(180deg, transparent 12%, #f4eee6 12%, #f4eee6 78%, transparent 78%),
    radial-gradient(ellipse at 50% 42%, transparent 36%, rgba(244, 238, 230, 0.95) 37% 58%, transparent 59%);
  filter: drop-shadow(0 6px 10px rgba(40, 70, 90, 0.18));
  opacity: 0.95;
  pointer-events: none;
}
.viz3d-teaser-art--skeleton::before,
.viz3d-teaser-art--skeleton::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 42%;
  height: 22%;
  border: 3px solid rgba(235, 225, 210, 0.95);
  border-radius: 50%;
  transform: translateX(-50%);
  top: 28%;
  box-shadow: 0 18px 0 -1px rgba(235, 225, 210, 0.75);
}
.viz3d-teaser-art--cell {
  background:
    radial-gradient(circle at 50% 48%, rgba(106, 168, 79, 0.95) 0 14%, transparent 15%),
    radial-gradient(circle at 30% 40%, rgba(224, 122, 61, 0.9) 0 6%, transparent 7%),
    radial-gradient(circle at 68% 55%, rgba(224, 122, 61, 0.85) 0 5%, transparent 6%),
    radial-gradient(circle at 50% 50%, rgba(183, 228, 199, 0.55) 0 46%, transparent 47%);
}
.viz3d-teaser-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 0 2px 2px;
}
.viz3d-teaser-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--leaf-deep);
  line-height: 1.35;
}
.viz3d-teaser-blurb {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
}
.viz3d-teaser-actions {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 4px 6px 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 6px 16px rgba(20, 48, 40, 0.18);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: auto;
}
.viz3d-teaser-hand { font-size: 1rem; opacity: 0.9; line-height: 1; }
.viz3d-teaser-btn {
  border: 0;
  border-radius: 999px;
  padding: 0.42rem 0.85rem;
  background: linear-gradient(180deg, #2f7a34, #236324);
  color: #fff;
  font: 800 0.8rem/1 var(--font);
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(35, 99, 36, 0.22);
  white-space: nowrap;
}
.viz3d-teaser-btn:hover { filter: brightness(1.05); }

@media (max-width: 520px) {
  .viz3d-teaser {
    gap: 7px;
    padding: 7px;
  }
  .viz3d-teaser-preview {
    min-height: 132px;
    max-height: 160px;
  }
}

body.viz3d-open,
body.notebook-open { overflow: hidden; }
.labebo-stage-overlay,
.viz3d-overlay {
  position: fixed;
  /* يلتصق بأسفل الهيدر عبر --labebo-stage-top */
  top: var(--labebo-stage-top, 64px);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 140;
  display: flex;
  flex-direction: column;
  padding: 0;
  border-radius: 0;
  /* بدون blur — أخف على الذاكرة/المعالج عند فتح المجسّم */
  background:
    radial-gradient(ellipse at 50% 18%, rgba(70, 130, 140, 0.22), transparent 48%),
    rgba(8, 22, 14, 0.78);
  animation: viz3dIn 0.28s ease both;
}
.labebo-stage-overlay[hidden] { display: none !important; }
.viz3d-stage {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.labebo-stage-stage { flex: 1 1 auto; width: 100%; min-height: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.viz3d-chrome {
  position: absolute;
  top: 10px;
  inset-inline: 10px;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  pointer-events: none;
}
.labebo-stage-chrome {
  position: absolute;
  top: 10px;
  inset-inline: 10px;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  pointer-events: none;
}
.viz3d-chrome > *,
.labebo-stage-chrome > * {
  pointer-events: auto;
}
.viz3d-close {
  width: 2.1rem;
  height: 2.1rem;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
.labebo-stage-close {
  width: 2.1rem;
  height: 2.1rem;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
.viz3d-quality {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.viz3d-quality-label {
  font-size: 0.75rem;
  font-weight: 800;
  color: #e8f5d8;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
.viz3d-q-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(20, 48, 22, 0.55);
  cursor: pointer;
}
.viz3d-q-opt {
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.72);
}
.viz3d-q-opt.is-on {
  background: rgba(136, 197, 64, 0.95);
  color: #143016;
}
.viz3d-q-tip {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  z-index: 2;
  width: min(240px, 70vw);
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: #143016;
  color: #e8f5d8;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.45;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
}
.viz3d-frame {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  width: 100%;
  border-radius: 0 0 22px 22px; /* أعلى مستقيم ليلتقي الهيدر */
  border: 3px solid rgba(140, 220, 240, 0.95);
  border-top-width: 0;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.35) inset,
    0 0 28px rgba(80, 200, 230, 0.4),
    0 18px 40px rgba(10, 30, 40, 0.28);
  background:
    radial-gradient(ellipse at 50% 30%, #f7fcff 0%, #d9eef5 55%, #b9dbe8 100%);
  overflow: hidden;
  touch-action: none;
}
.labebo-stage-frame {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  width: 100%;
  border-radius: 0 0 22px 22px; /* أعلى مستقيم ليلتقي الهيدر */
  border: 3px solid rgba(140, 220, 240, 0.95);
  border-top-width: 0;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.35) inset,
    0 0 28px rgba(80, 200, 230, 0.4),
    0 18px 40px rgba(10, 30, 40, 0.28);
  overflow: hidden;
}
.viz3d-frame canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}
.viz3d-controls {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 7;
  pointer-events: auto;
}
.viz3d-controls[hidden] { display: none !important; }
.viz3d-ctrl {
  width: 2.55rem;
  height: 2.55rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(30, 70, 90, 0.62);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  box-shadow: 0 6px 16px rgba(10, 30, 40, 0.25);
}
.viz3d-ctrl:active {
  transform: scale(0.94);
}
.viz3d-ctrl.is-active {
  background: rgba(136, 197, 64, 0.92);
  color: #143016;
  border-color: rgba(255, 255, 255, 0.7);
}
.viz3d-ctrl-main {
  width: 3rem;
  height: 3rem;
  background: rgba(25, 70, 95, 0.68);
}
.viz3d-hint {
  margin: 0;
  flex: 0 0 auto;
  text-align: center;
  color: rgba(240, 255, 245, 0.9);
  font-size: 0.78rem;
  font-weight: 600;
}
.viz3d-hint strong {
  color: #d8f0a8;
  font-weight: 800;
}


.viz3d-gate {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(8, 22, 14, 0.62);
}
.viz3d-gate-sheet {
  width: min(100%, 22rem);
  padding: 1.15rem 1.1rem 1rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #fbfef8);
  box-shadow: 0 18px 40px rgba(12, 36, 18, 0.22);
  text-align: center;
}
.viz3d-gate-ico {
  width: 2.4rem;
  height: 2.4rem;
  margin: 0 auto 0.55rem;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--leaf-soft);
  color: var(--leaf-deep);
  font-weight: 800;
}
.viz3d-gate-title {
  margin: 0 0 0.45rem;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--leaf-deep);
}
.viz3d-gate-text {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--muted);
}
.viz3d-gate-actions {
  display: flex;
  gap: 0.55rem;
  justify-content: stretch;
}
.viz3d-gate-cancel,
.viz3d-gate-ok {
  flex: 1;
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  font: 800 0.88rem/1.2 var(--font);
  cursor: pointer;
}
.viz3d-gate-cancel {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}
.viz3d-gate-ok {
  border: 0;
  background: linear-gradient(180deg, #2f7a34, #236324);
  color: #fff;
}
.viz3d-loader {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, rgba(238, 248, 251, 0.92), rgba(194, 224, 234, 0.95));
  transition: opacity 0.28s ease;
}
.viz3d-loader[hidden] { display: none !important; }
.viz3d-loader.is-done { opacity: 0; pointer-events: none; }
.viz3d-loader-card {
  width: min(86%, 16rem);
  text-align: center;
}
.viz3d-loader-label {
  margin: 0 0 0.65rem;
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--leaf-deep);
}
.viz3d-loader-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  overflow: hidden;
  border: 1px solid rgba(120, 190, 210, 0.35);
}
.viz3d-loader-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--leaf), #5aa8c2);
  transition: width 0.2s ease;
}
.viz3d-toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translate(-50%, 12px);
  z-index: 160;
  max-width: min(92vw, 22rem);
  padding: 0.7rem 1rem;
  border-radius: 12px;
  background: #143016;
  color: #e8f5d8;
  font-size: 0.86rem;
  font-weight: 700;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.viz3d-toast.is-in {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* —— صفحة تقدّمي (المرحلة E) —— */
.progress-overlay {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: grid;
  place-items: end center;
  padding: 0;
}
.progress-overlay[hidden] { display: none !important; }
.progress-scrim {
  position: absolute;
  inset: 0;
  background: rgba(18, 32, 20, 0.38);
}
.progress-sheet {
  position: relative;
  z-index: 1;
  width: min(100%, 28rem);
  max-height: min(88vh, 40rem);
  margin: 0 auto;
  background: linear-gradient(180deg, #f7fbf2 0%, #eef6e6 100%);
  border-radius: 22px 22px 0 0;
  border: 1px solid rgba(93, 154, 44, 0.18);
  box-shadow: 0 -18px 48px rgba(20, 48, 22, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: progress-sheet-in 0.32s ease-out;
}
.progress-head {
  position: relative;
  padding: 1.1rem 1.15rem 0.65rem;
  border-bottom: 1px dashed var(--line);
}
.progress-head h2 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--leaf-deep);
  font-weight: 800;
}
.progress-hint {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}
.progress-close {
  position: absolute;
  top: 0.85rem;
  left: 0.85rem;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 10px;
  background: rgba(255,255,255,0.7);
  color: var(--leaf-deep);
  font-size: 1.25rem;
  cursor: pointer;
}
.progress-body {
  padding: 0.9rem 1.15rem 1.4rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.progress-totals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}
.progress-stat {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.75rem;
  border-radius: 16px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(247, 252, 240, 0.88));
  border: 1px solid rgba(93, 154, 44, 0.16);
  box-shadow: 0 6px 14px rgba(35, 99, 36, 0.05);
  min-height: 4.6rem;
}
.progress-stat-visual {
  position: relative;
  flex: 0 0 auto;
  width: 3.15rem;
  height: 3.15rem;
}
.progress-stat-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.progress-stat-track,
.progress-stat-fill {
  fill: none;
  stroke-width: 3.2;
}
.progress-stat-track {
  stroke: rgba(93, 154, 44, 0.14);
}
.progress-stat-fill {
  stroke: var(--leaf);
  stroke-linecap: round;
  transition: none;
}
.progress-stat.tone-visits .progress-stat-fill { stroke: #5d9a2c; }
.progress-stat.tone-read .progress-stat-fill { stroke: #3d8a9e; }
.progress-stat.tone-ask .progress-stat-fill { stroke: #6B9F3C; }
.progress-stat.tone-check .progress-stat-fill { stroke: #c4a035; }
.progress-stat-ico {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  line-height: 1;
  pointer-events: none;
}
.progress-stat-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.progress-stat-val {
  display: block;
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--leaf-deep);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.progress-stat-lbl {
  display: block;
  margin-top: 0;
  font-size: 0.76rem;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.3;
}
@media (prefers-reduced-motion: reduce) {
  .progress-stat-fill { transition: none !important; }
}
.progress-sheet progress{appearance:none;width:100%;height:7px;margin-top:6px;border:0;border-radius:4px;overflow:hidden;background:#dce6d4;accent-color:#658849}
.progress-sheet progress::-webkit-progress-bar{background:#dce6d4;border-radius:4px}
.progress-sheet progress::-webkit-progress-value{background:#658849;border-radius:4px}
.progress-sheet progress::-moz-progress-bar{background:#658849;border-radius:4px}
.progress-sheet [data-learning-progress]{margin:0.8rem 0}
.progress-section-title {
  margin: 0 0 0.45rem;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--leaf-deep);
}
.progress-streaks {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: stretch;
}
.progress-streak-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  flex: 1 1 calc(33.333% - 0.45rem);
  min-width: 4.6rem;
  padding: 0.55rem 0.45rem;
  border-radius: 12px;
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(93, 154, 44, 0.1);
  font-size: 0.78rem;
  text-align: center;
}
.progress-streak-label {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.3;
}
.progress-streak-row strong,
.progress-streak-val {
  color: var(--leaf-deep);
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1.2;
}
.progress-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.progress-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  background: rgba(93, 154, 44, 0.12);
  color: var(--leaf-deep);
  font-size: 0.78rem;
  font-weight: 700;
}
.progress-badge.is-locked {
  background: rgba(0,0,0,0.04);
  color: var(--muted);
  font-weight: 600;
}
.progress-soft {
  margin: 0;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  background: rgba(93, 154, 44, 0.08);
  color: var(--leaf-deep);
  font-size: 0.9rem;
  line-height: 1.55;
  font-weight: 600;
}
@media (min-width: 720px) {
  .progress-overlay { place-items: center; padding: 1.5rem; }
  .progress-sheet {
    border-radius: 18px;
    max-height: min(82vh, 36rem);
  }
}

/* —— دفتر ملء الشاشة (نفس طبقة labebo-stage) —— */
.notebook-overlay {
  z-index: 141;
}
.notebook-frame {
  background: linear-gradient(180deg, #f7fbf2 0%, #eef6e6 55%, #e4f0da 100%);
  display: flex;
  flex-direction: column;
  touch-action: auto;
}
.notebook-chrome {
  position: absolute;
  inset-inline: 12px;
  top: 10px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  pointer-events: none;
}
.notebook-chrome > * {
  pointer-events: auto;
}
.notebook-chrome .labebo-stage-close {
  position: absolute;
  top: 0;
  inset-inline-end: 0; /* يسار في RTL */
  inset-inline-start: auto;
}
.notebook-chrome-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(100%, 26rem);
  padding-inline: 2.5rem; /* مساحة زر الإغلاق */
  text-align: center;
}
.notebook-stage-title {
  margin: 0;
  padding: 0.35rem 0.95rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--leaf-deep);
  font-size: 0.95rem;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  text-align: center;
}
.notebook-search.archive-search {
  margin: 10px auto 0;
  width: min(100%, 22rem);
}
.notebook-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 6.4rem 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  -webkit-overflow-scrolling: touch;
}
.notebook-division {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding-bottom: 1rem;
  border-bottom: 1px dashed rgba(93, 154, 44, 0.28);
}
.notebook-division:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}
.notebook-division-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--leaf-deep);
  line-height: 1.45;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.notebook-division-title::before {
  content: '💬';
  font-size: 0.9rem;
}
.notebook-note {
  position: relative;
  padding-block: 0.75rem;
  padding-inline-start: 0.85rem;
  padding-inline-end: 2.6rem; /* مساحة زر الحذف دون تداخل مع النص */
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(93, 154, 44, 0.16);
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.7;
}
.notebook-note.role-relation { border-inline-start: 3px solid var(--ev-relation); }
.notebook-note.role-caution { border-inline-start: 3px solid var(--ev-caution); }
.notebook-note.role-concept { border-inline-start: 3px solid var(--leaf); }
.notebook-note p { margin: 0; padding-inline-end: 0; }
.notebook-note .notebook-del {
  position: absolute;
  top: 0.45rem;
  inset-inline-end: 0.4rem;
  inset-inline-start: auto;
  left: auto;
  width: 1.85rem;
  height: 1.85rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.05rem;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  padding: 0;
  line-height: 1;
}
.notebook-note .notebook-del-ico {
  display: inline-grid;
  place-items: center;
}
.notebook-note .notebook-del-ico svg {
  display: block;
}
.notebook-note .notebook-del:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--leaf-deep);
}
.notebook-empty {
  margin: 2rem auto;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.65;
  max-width: 18rem;
}
.notebook-stage-hint {
  margin: 0;
  padding: 0.35rem 0.75rem 0.55rem;
  text-align: center;
  color: rgba(232, 245, 216, 0.88);
  font-size: 0.78rem;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
.viz3d-hint {
  padding: 0.35rem 0.75rem 0.55rem;
}
.platform-read-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}
.platform-read-actions .pill {
  min-height: 44px;
  max-width: 100%;
  white-space: normal;
}

/* Keep toolbar actions, including the SVG logout, visible on small screens. */
@media(max-width:480px){
  .top{padding-inline:12px!important;gap:6px!important}
  .top .brand{gap:6px}
  .top .top-side-stack{gap:6px!important}
  .top .top-side-stack .pill{padding-inline:8px!important}
}

@keyframes bgDrift {
  0% {
    background-position: 26% 20%, 80% 72%, 46% 50%, 0 0;
  }
  50% {
    background-position: 42% 34%, 62% 56%, 56% 40%, 0 0;
  }
  100% {
    background-position: 58% 48%, 36% 38%, 40% 58%, 0 0;
  }
}
@keyframes glowDrift {
  0% {
    background-position: 32% 28%, 70% 64%;
  }
  100% {
    background-position: 48% 42%, 54% 48%;
  }
}
@keyframes heroIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fluidMorph {
  0%, 100% { border-radius: 42% 58% 48% 52% / 52% 42% 58% 48%; }
  33% { border-radius: 58% 42% 62% 38% / 40% 60% 40% 60%; }
  66% { border-radius: 38% 62% 44% 56% / 60% 40% 55% 45%; }
}
@keyframes fluidMorphWide {
  0%, 100% { border-radius: 58% 58% 38% 38% / 78% 78% 28% 28%; }
  40% { border-radius: 48% 52% 42% 58% / 68% 72% 34% 38%; }
  70% { border-radius: 52% 48% 50% 50% / 74% 70% 32% 30%; }
}
@keyframes fluidRise {
  0%, 100% { transform: translateY(6px) scaleX(1.02) scaleY(0.92); opacity: 0.62; }
  50% { transform: translateY(-20px) scaleX(1.08) scaleY(1.18); opacity: 0.92; }
}
@keyframes fluidCoreRise {
  0%, 100% { transform: translateY(3px) scaleX(1) scaleY(0.9); opacity: 0.78; }
  50% { transform: translateY(-14px) scaleX(1.06) scaleY(1.12); opacity: 1; }
}
@keyframes fluidEmitPulse {
  0%, 100% { opacity: 0.55; transform: scaleX(0.98); filter: blur(8px); }
  50% { opacity: 1; transform: scaleX(1.01); filter: blur(11px); }
}
@keyframes fluidDriftB {
  0%, 100% { transform: translate(0, 4px) scale(1) rotate(0deg); }
  35% { transform: translate(18px, -26px) scale(1.1) rotate(-5deg); }
  70% { transform: translate(-12px, -12px) scale(0.94) rotate(4deg); }
}
@keyframes fluidDriftC {
  0%, 100% { transform: translate(0, 2px) scale(1); }
  50% { transform: translate(-18px, -28px) scale(1.14); }
}
@keyframes fluidDriftD {
  0%, 100% { transform: translate(-6px, 6px) scale(0.94); }
  50% { transform: translate(10px, -22px) scale(1.16); }
}
@keyframes fluidDriftE {
  0%, 100% { transform: translate(4px, 0) scale(0.9); opacity: 0.28; }
  50% { transform: translate(-8px, -30px) scale(1.2); opacity: 0.55; }
}
@keyframes fluidVeil {
  0%, 100% { opacity: 0.42; transform: scaleX(0.97) scaleY(0.9) translateY(6px); }
  50% { opacity: 0.9; transform: scaleX(1.04) scaleY(1.14) translateY(-14px); }
}
@keyframes fluidSheen {
  0%, 100% { transform: translate(-14px, 8px) scale(0.82); opacity: 0.35; }
  50% { transform: translate(10px, -26px) scale(1.35); opacity: 0.92; }
}
@keyframes particleTwinkle {
  0% { opacity: 0; transform: translate(0, 10px) scale(0.45); }
  12% { opacity: 0.2; }
  28% { opacity: 0.95; transform: translate(4px, -16px) scale(1.2); }
  48% { opacity: 0.55; transform: translate(-6px, -34px) scale(0.9); }
  68% { opacity: 0.85; transform: translate(3px, -48px) scale(1.05); }
  86% { opacity: 0.15; transform: translate(-2px, -62px) scale(0.55); }
  100% { opacity: 0; transform: translate(0, -72px) scale(0.35); }
}
@keyframes archive-rise {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@keyframes station-jelly-glow {
  0%, 100% {
    transform: scale(1);
    box-shadow:
      0 0 0 2px rgba(255, 255, 255, 0.55),
      0 0 14px 2px rgba(168, 230, 90, 0.55),
      0 0 28px 6px rgba(136, 197, 64, 0.35),
      0 8px 18px rgba(20, 48, 22, 0.22);
    filter: brightness(1);
  }
  40% {
    transform: scale(1.035);
    box-shadow:
      0 0 0 3px rgba(255, 255, 255, 0.7),
      0 0 20px 4px rgba(200, 255, 120, 0.7),
      0 0 36px 10px rgba(136, 197, 64, 0.45),
      0 10px 22px rgba(20, 48, 22, 0.26);
    filter: brightness(1.06);
  }
  70% {
    transform: scale(0.985);
    box-shadow:
      0 0 0 2px rgba(255, 255, 255, 0.45),
      0 0 12px 2px rgba(136, 197, 64, 0.5),
      0 0 24px 5px rgba(104, 168, 40, 0.32),
      0 7px 16px rgba(20, 48, 22, 0.2);
    filter: brightness(1.02);
  }
}




@keyframes notebookPopSpin {
  to { transform: rotate(360deg); }
}
@keyframes subject-rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}
@keyframes fluidComposerWash {
  0%, 100% { opacity: 0.55; transform: scaleX(0.98) translateY(4px); }
  50% { opacity: 0.95; transform: scaleX(1.02) translateY(-6px); }
}
@keyframes viz3dIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes progress-sheet-in {
  from { transform: translateY(18%); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}
