/* ═══════════════════════════════════════════════════════════════════
   رِزق داتا — ساحة التحكيم  ·  "المخطوطة المُضيئة"
   تعشيق هندسي إسلامي (يشمي + ذهبي) × واجهة مالية حديثة · RTL · موبايل أولاً
   ═══════════════════════════════════════════════════════════════════ */

:root {
  /* نظام رِزق المعتمد — يشمي (jade) + ذهبي (gold). الوضع الفاتح هو الأساس (مطابق للتطبيق) */
  --jade:      #12876A;   /* --brand */
  --jade-lit:  #17A17E;   /* --brand-2 */
  --jade-deep: #0C5E4C;   /* --brand-deep */
  --gold:      #C99A22;   /* --gold */
  --gold-lit:  #E3B84A;   /* --gold-2 */
  --gold-deep: #9A7413;
  --gold-ink:  #8A6811;

  --bg:        #EEF7F4;   /* --bg المعتمد */
  --bg-2:      #E4F0EB;
  --surface:   #FFFFFF;   /* --card */
  --surface-2: #F5FBF9;
  --hair:      rgba(201,154,34,.30);   /* خيط ذهبي رفيع */
  --hair-soft: rgba(18,135,106,.16);
  --ink:       #10201B;   /* --ink */
  --ink-2:     #3C4E47;
  --ink-3:     #5B6B65;   /* --muted */

  --r-lg: 22px;
  --r-md: 18px;          /* --radius المعتمد */
  --r-sm: 12px;
  --shadow: 0 14px 34px -18px rgba(12,94,76,.22), 0 2px 0 rgba(201,154,34,.05);
  --shadow-gold: 0 16px 40px -16px rgba(201,154,34,.42);
  --ease: cubic-bezier(.16,.84,.44,1);
  --ease-back: cubic-bezier(.34,1.56,.64,1);

  --font-disp: "Reem Kufi", system-ui, sans-serif;
  --font-body: "IBM Plex Sans Arabic", system-ui, sans-serif;
}

/* الوضع الداكن (اختياري) — "المخطوطة المُضيئة": نفس اليشمي/الذهب بدرجات ألمع على جلدٍ عتيق */
:root[data-theme="dark"] {
  --jade:      #3FBE97;
  --jade-lit:  #6FE3BE;
  --jade-deep: #12876A;
  --gold:      #E3B84A;
  --gold-lit:  #FAD879;
  --gold-deep: #C99A22;
  --gold-ink:  #FAD879;
  --bg:        #08110E;
  --bg-2:      #0A1512;
  --surface:   #0E1E19;
  --surface-2: #12271F;
  --hair:      rgba(227,184,74,.22);
  --hair-soft: rgba(227,184,74,.10);
  --ink:       #EDE4CF;
  --ink-2:     #A9BEB4;
  --ink-3:     #6E837A;
  --shadow: 0 24px 60px -24px rgba(0,0,0,.7), 0 2px 0 rgba(227,184,74,.05);
  --shadow-gold: 0 20px 50px -18px rgba(227,184,74,.4);
}

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

/* السمة الافتراضية (display:flex على .pane وغيرها) تتغلّب على [hidden] — نُصلح ذلك */
[hidden] { display: none !important; }

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 1.6;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-font-smoothing: antialiased;
  transition: background .5s var(--ease), color .5s var(--ease);
}

/* ── الخلفية المُذهّبة ─────────────────────────────────── */
.illumination {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% -10%, var(--bg-2), var(--bg) 60%);
}
.girih {
  position: absolute; inset: -5%; width: 110%; height: 110%;
  color: var(--jade);
  opacity: .08;
  animation: drift 90s linear infinite;
}
:root[data-theme="dark"] .girih { color: var(--gold); opacity: .045; }
:root[data-theme="dark"] .dialect-badge { color: var(--jade-lit); }
@keyframes drift { to { transform: translate(-120px, -120px); } }

.glow { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .5; }
.glow-a { top: -140px; inset-inline-start: -120px; width: 420px; height: 420px;
  background: radial-gradient(circle, var(--jade-deep), transparent 70%); }
.glow-b { bottom: -180px; inset-inline-end: -140px; width: 460px; height: 460px;
  background: radial-gradient(circle, var(--gold-deep), transparent 70%); opacity: .35; }

/* ── الترويسة ─────────────────────────────────── */
.top {
  position: relative; z-index: 3;
  display: flex; align-items: center; gap: 14px;
  padding: 18px clamp(16px, 5vw, 40px);
  max-width: 1080px; margin-inline: auto;
}
.back-btn { display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 9px 15px 9px 12px; border-radius: 999px; text-decoration: none;
  font-family: var(--font-body); font-size: 14px; font-weight: 600; color: var(--ink-2);
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--hair);
  transition: color .25s, box-shadow .25s, transform .25s var(--ease-back); }
.back-btn:hover { color: var(--jade); box-shadow: inset 0 0 0 1px var(--jade); transform: translateX(3px); }
.back-btn:focus-visible { outline: 2px solid var(--jade); outline-offset: 2px; }
.back-chev { font-size: 20px; line-height: 1; margin-top: -2px; }

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-logo { width: 40px; height: 40px; border-radius: 12px; display: block;
  box-shadow: 0 6px 18px -10px var(--jade-deep); }
.brand-words { display: flex; flex-direction: column; line-height: 1; font-family: var(--font-disp); }
.brand-words b { font-size: 21px; font-weight: 700; color: var(--ink); letter-spacing: .5px; }
.brand-words i { font-size: 11px; font-style: normal; font-weight: 500; letter-spacing: 5px;
  color: var(--gold); margin-top: 3px; }

.wallet { margin-inline-start: auto; display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: 999px;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--hair);
  animation: popIn .5s var(--ease-back) both; }
.wallet-coin { width: 15px; height: 15px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gold-lit), var(--gold-deep));
  box-shadow: 0 0 0 2px rgba(228,184,75,.15); flex: none; }
.wallet-num { font-family: var(--font-disp); font-weight: 600; font-size: 16px;
  color: var(--gold-ink); font-variant-numeric: tabular-nums; }
.wallet-lbl { font-size: 11px; color: var(--ink-3); }

.ghost-btn { margin-inline-start: 4px; width: 40px; height: 40px; flex: none;
  border: none; border-radius: 12px; cursor: pointer; display: grid; place-items: center;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--hair);
  transition: transform .3s var(--ease-back), background .3s; }
.wallet[hidden] ~ .ghost-btn { margin-inline-start: auto; }
.ghost-btn:hover { transform: rotate(-20deg); }
.theme-ico { width: 18px; height: 18px; border-radius: 50%;
  background: var(--jade);
  box-shadow: 0 0 0 2px var(--jade); transition: all .4s var(--ease); }
:root[data-theme="dark"] .theme-ico { background: var(--gold-lit);
  box-shadow: inset -6px -3px 0 0 var(--surface); }

/* ── الساحة ─────────────────────────────────── */
.stage { position: relative; z-index: 2; max-width: 780px;
  margin-inline: auto; padding: clamp(8px, 3vw, 24px) clamp(16px, 5vw, 40px) 120px; }
.pane { display: flex; flex-direction: column; align-items: center; text-align: center; }

/* التحميل */
.loading { padding-top: 22vh; color: var(--ink-3); gap: 20px; }
.spinner { display: flex; gap: 8px; }
.spinner i { width: 11px; height: 11px; border-radius: 50%; background: var(--gold);
  animation: bob 1s var(--ease) infinite; }
.spinner i:nth-child(2){ animation-delay: .15s; background: var(--jade); }
.spinner i:nth-child(3){ animation-delay: .3s; }
@keyframes bob { 0%,100%{ transform: translateY(0); opacity: .4 } 50%{ transform: translateY(-12px); opacity: 1 } }

/* ── العدسة (البُعد الوحيد) ─────────────────── */
.lens { position: relative; width: 96px; height: 96px; margin-top: 8px;
  animation: lensIn .7s var(--ease-back) both; }
.lens-ring { position: absolute; inset: 0; transform: rotate(-90deg); }
.lr-bg { fill: none; stroke: var(--hair-soft); stroke-width: 3; }
.lr-fg { fill: none; stroke: var(--gold); stroke-width: 3; stroke-linecap: round;
  stroke-dasharray: 264; stroke-dashoffset: 66;
  filter: drop-shadow(0 0 6px rgba(228,184,75,.5));
  animation: trace 1s var(--ease) both .2s; }
.lens-glyph { position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--font-disp); font-size: 34px; color: var(--gold-lit);
  text-shadow: 0 0 18px rgba(228,184,75,.5); }
@keyframes trace { from { stroke-dashoffset: 264; } }
@keyframes lensIn { from { opacity: 0; transform: scale(.6) translateY(10px); } }

.lens-cap { margin-top: 14px; font-size: 12px; letter-spacing: 3px; color: var(--jade-lit);
  text-transform: none; animation: rise .6s var(--ease) both .35s; }
.lens-cap b { color: var(--gold-lit); font-weight: 700; }
.dimension { font-family: var(--font-disp); font-weight: 700; font-size: clamp(30px, 8vw, 44px);
  color: var(--ink); margin-top: 2px; line-height: 1.15;
  animation: rise .6s var(--ease) both .42s; }
.instructions { max-width: 46ch; color: var(--ink-2); font-size: 14.5px; margin-top: 8px;
  animation: rise .6s var(--ease) both .5s; }

/* بطاقة السياق */
.prompt-card { position: relative; width: 100%; margin-top: 22px; padding: 20px 22px;
  border-radius: var(--r-md); background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--hair-soft);
  animation: rise .6s var(--ease) both .58s; }
.prompt-card::before { content: ""; position: absolute; inset-inline-start: 0; top: 14px; bottom: 14px;
  width: 3px; border-radius: 3px; background: linear-gradient(var(--jade), var(--gold)); }
.dialect-badge { display: inline-block; margin-bottom: 8px; padding: 3px 12px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; color: var(--jade-deep);
  background: rgba(63,190,151,.12); box-shadow: inset 0 0 0 1px rgba(63,190,151,.25); }
.prompt-text { color: var(--ink); font-size: 16px; font-weight: 500; }

/* ── ساحة الخيارين ─────────────────────────── */
.arena { position: relative; width: 100%; margin-top: 20px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: stretch; }

.choice { position: relative; overflow: hidden; cursor: pointer; text-align: start;
  padding: 22px 20px 44px; min-height: 132px;
  border: none; border-radius: var(--r-md); background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--hair), var(--shadow);
  color: var(--ink); font-family: inherit;
  transition: transform .35s var(--ease-back), box-shadow .35s var(--ease), background .35s; }
.choice:nth-child(1){ animation: slideR .6s var(--ease) both .66s; }
.choice:nth-child(3){ animation: slideL .6s var(--ease) both .66s; }
.choice::after { content: ""; position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(120% 90% at 50% 120%, rgba(228,184,75,.22), transparent 60%);
  transition: opacity .4s; }
@media (hover: hover) {
  .choice:hover { transform: translateY(-4px); box-shadow: inset 0 0 0 1px var(--gold), var(--shadow-gold); }
  .choice:hover::after { opacity: 1; }
}
.choice-tag { position: absolute; top: 14px; inset-inline-end: 14px;
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px;
  font-family: var(--font-disp); font-weight: 700; font-size: 18px; color: var(--gold-lit);
  background: rgba(228,184,75,.10); box-shadow: inset 0 0 0 1px var(--hair); }
.choice-body { display: block; margin-top: 6px; font-size: 15.5px; line-height: 1.7;
  color: var(--ink); font-weight: 500; }
.choice-key { position: absolute; bottom: 12px; inset-inline-start: 14px;
  font-family: var(--font-body); font-size: 10.5px; color: var(--ink-3);
  padding: 2px 7px; border-radius: 6px; box-shadow: inset 0 0 0 1px var(--hair-soft); }
.choice-pick { position: absolute; bottom: 12px; inset-inline-end: 14px;
  font-size: 12px; font-weight: 700; color: var(--bg); opacity: 0; transform: translateY(4px);
  transition: all .3s var(--ease-back); }

/* الخيار المُختار */
.choice.chosen {
  background: linear-gradient(150deg, var(--jade-deep), var(--gold-deep));
  box-shadow: inset 0 0 0 1px var(--gold-lit), var(--shadow-gold);
  transform: translateY(-4px) scale(1.015); }
.choice.chosen .choice-body, .choice.chosen .choice-tag { color: #fff; }
.choice.chosen .choice-tag { background: rgba(255,255,255,.18); box-shadow: none; }
.choice.chosen .choice-key { display: none; }
.choice.chosen .choice-pick { opacity: 1; transform: translateY(0); color: #08110E; }
.choice.dimmed { opacity: .4; transform: scale(.97); filter: saturate(.6); }

/* الفاصل المُذهّب */
.divider { position: absolute; inset-block: 0; inset-inline-start: 50%; transform: translateX(50%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  pointer-events: none; z-index: 2; animation: popIn .5s var(--ease-back) both .9s; }
.divider svg { width: 40px; height: 40px; fill: var(--gold);
  filter: drop-shadow(0 0 10px rgba(228,184,75,.55));
  background: var(--bg); border-radius: 50%; padding: 3px;
  animation: spin 14s linear infinite; }
.divider span { font-family: var(--font-disp); font-size: 12px; color: var(--gold-lit);
  background: var(--bg); padding: 1px 6px; border-radius: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── الأفعال ─────────────────────────────────── */
.actions { display: flex; align-items: center; gap: 12px; width: 100%; margin-top: 22px;
  animation: rise .6s var(--ease) both .8s; }
.skip-btn { padding: 15px 20px; border: none; border-radius: var(--r-sm); cursor: pointer;
  background: transparent; color: var(--ink-3); font-family: inherit; font-size: 14px; font-weight: 500;
  box-shadow: inset 0 0 0 1px var(--hair-soft); transition: color .3s, box-shadow .3s; }
.skip-btn:hover { color: var(--ink); box-shadow: inset 0 0 0 1px var(--hair); }

.submit-btn { position: relative; flex: 1; display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 16px 22px; border: none; border-radius: var(--r-sm); cursor: pointer;
  font-family: var(--font-disp); font-weight: 600; font-size: 16px; color: #08110E;
  background: linear-gradient(135deg, var(--gold-lit), var(--gold));
  box-shadow: var(--shadow-gold); text-decoration: none;
  transition: transform .3s var(--ease-back), filter .3s, opacity .3s; }
.submit-btn.wide { flex: none; width: min(320px, 100%); margin-top: 22px; }
.submit-btn:not(:disabled):hover { transform: translateY(-2px); filter: brightness(1.06); }
.submit-btn:not(:disabled):active { transform: translateY(0) scale(.98); }
.submit-btn:disabled { opacity: .4; cursor: not-allowed;
  background: var(--surface-2); color: var(--ink-3); box-shadow: inset 0 0 0 1px var(--hair-soft); }
.reward-chip { font-family: var(--font-body); font-size: 12px; font-weight: 700;
  padding: 2px 9px; border-radius: 999px; background: rgba(8,17,14,.22);
  font-variant-numeric: tabular-nums; }
.submit-btn:disabled .reward-chip { display: none; }

/* ── اكتمال / ختم ─────────────────────────────── */
.done, .error { padding-top: 14vh; gap: 8px; }
.seal { width: 130px; height: 130px; animation: popIn .7s var(--ease-back) both; }
.seal svg { width: 100%; height: 100%; fill: none; }
.seal-o { stroke: var(--hair); stroke-width: 2; stroke-dasharray: 4 6; }
.seal-i { stroke: var(--jade); stroke-width: 2.5; }
.seal-check { stroke: var(--gold-lit); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 60; animation: trace 0.7s var(--ease) both .4s; }
.done h2, .error h2 { font-family: var(--font-disp); font-size: 26px; color: var(--ink); margin-top: 16px; }
.done p, .error p { color: var(--ink-2); max-width: 42ch; }
.err-mark { width: 84px; height: 84px; display: grid; place-items: center; border-radius: 50%;
  font-family: var(--font-disp); font-size: 44px; color: var(--gold-lit);
  box-shadow: inset 0 0 0 2px var(--hair); animation: popIn .6s var(--ease-back) both; }
.link-btn { margin-top: 4px; background: none; border: none; cursor: pointer;
  color: var(--ink-3); font-family: inherit; font-size: 13px; text-decoration: underline dotted; }
.link-btn:hover { color: var(--jade-lit); }

/* ── هامش المخطوطة (التقدّم) ─────────────────── */
.margin { position: fixed; inset-inline-start: clamp(10px, 3vw, 26px); top: 50%;
  transform: translateY(-50%); z-index: 3;
  display: flex; flex-direction: column; gap: 20px;
  padding: 18px 14px; border-radius: 999px; background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--hair-soft), var(--shadow);
  animation: popIn .6s var(--ease-back) both .4s; }
.margin-item, .margin-flame { display: flex; flex-direction: column; align-items: center; }
.margin-num { font-family: var(--font-disp); font-weight: 700; font-size: 22px; color: var(--ink);
  font-variant-numeric: tabular-nums; transition: transform .3s var(--ease-back); }
.margin-num.gold { color: var(--gold-lit); }
.margin-num.bump { transform: scale(1.4); color: var(--jade-lit); }
.margin-lbl { font-size: 10.5px; color: var(--ink-3); writing-mode: horizontal-tb; margin-top: 2px; }

/* ── سكّ الدينار (المكافأة) ─────────────────── */
.mint { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center;
  pointer-events: none; opacity: 0; }
.mint.show { animation: mintFlash 1.5s var(--ease) forwards; }
.dinar { width: 120px; height: 120px; transform: scale(.3) rotateY(90deg); }
.mint.show .dinar { animation: strike 1.5s var(--ease-back) forwards; }
.dinar svg { width: 100%; height: 100%; }
.d-o { fill: none; stroke: var(--gold-lit); stroke-width: 3; }
.d-i { fill: none; stroke: var(--gold); stroke-width: 1.5; stroke-dasharray: 3 4; }
.d-glyph { fill: var(--gold-lit); font-family: var(--font-disp); font-size: 15px; font-weight: 700; }
.mint-label { position: absolute; margin-top: 150px; font-family: var(--font-disp);
  color: var(--gold-lit); font-size: 18px; opacity: 0; }
.mint.show .mint-label { animation: rise .5s var(--ease) forwards .4s; }
.mint-gold { position: absolute; margin-top: 188px; color: var(--jade-lit); font-size: 13px;
  font-weight: 700; opacity: 0; }
.mint.show .mint-gold:not([hidden]) { animation: rise .5s var(--ease) forwards .55s; }
@keyframes strike { 0%{ transform: scale(.3) rotateY(90deg); opacity: 0 }
  35%{ transform: scale(1.15) rotateY(0); opacity: 1 }
  70%{ transform: scale(1) rotateY(0); opacity: 1 }
  100%{ transform: scale(.5) translate(40vw, -40vh) rotateY(0); opacity: 0 } }
@keyframes mintFlash { 0%,80%{ opacity: 1 } 100%{ opacity: 0 } }

/* ── التوست ─────────────────────────────────── */
.toast { position: fixed; bottom: calc(24px + env(safe-area-inset-bottom)); inset-inline: 0;
  margin-inline: auto; width: max-content; max-width: 90vw; z-index: 50;
  padding: 13px 22px; border-radius: 999px; font-size: 14px; font-weight: 500;
  background: var(--surface-2); color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--hair), var(--shadow);
  opacity: 0; transform: translateY(20px); pointer-events: none;
  transition: opacity .3s var(--ease), transform .3s var(--ease-back); }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.good { box-shadow: inset 0 0 0 1px rgba(63,190,151,.5), var(--shadow); }
.toast.bad  { box-shadow: inset 0 0 0 1px rgba(228,120,80,.5), var(--shadow); }

/* ── الحركات المشتركة ─────────────────────────── */
@keyframes rise   { from { opacity: 0; transform: translateY(16px); } }
@keyframes slideR { from { opacity: 0; transform: translateX(28px) rotate(1deg); } }
@keyframes slideL { from { opacity: 0; transform: translateX(-28px) rotate(-1deg); } }
@keyframes popIn  { from { opacity: 0; transform: scale(.85); } }

/* ── موبايل ─────────────────────────────────── */
@media (max-width: 560px) {
  .margin { flex-direction: row; inset-inline: 0; inset-inline-start: auto; top: auto;
    bottom: calc(16px + env(safe-area-inset-bottom)); transform: none; margin-inline: auto;
    width: max-content; padding: 10px 22px; gap: 26px; }
  .stage { padding-bottom: 150px; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .wallet-lbl { display: none; }
  .brand-words { display: none; } /* يبقى اللوجو؛ زرّ «التطبيق» هو أفوردانس الرجوع الواضح */
  .arena { gap: 10px; }
  .choice { padding: 18px 16px 40px; min-height: 118px; }
}
@media (max-width: 380px) {
  .brand { display: none; } /* أضيق شاشة: اكتفِ بزرّ الرجوع + المحفظة + السمة */
  .arena { grid-template-columns: 1fr; }
  .divider { position: static; transform: none; flex-direction: row; margin: 2px 0; }
  .divider svg { width: 30px; height: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; }
}

/* نص الترخيص الكامل في شاشة الموافقة (كان style مضمّناً يحجبه CSP) */
.consent-terms-text { white-space: pre-wrap; text-align: right; font-size: .8rem; }

/* ── كتلة النسخ الصوتي ─────────────────────── */
.transcribe { width: 100%; margin-top: 20px;
  display: flex; flex-direction: column; gap: 12px;
  animation: rise .6s var(--ease) both .66s; }
.transcribe audio { width: 100%; border-radius: var(--r-sm); }
.transcribe textarea { width: 100%; min-height: 156px; resize: vertical;
  padding: 16px 18px; border: none; border-radius: var(--r-md);
  background: var(--surface); color: var(--ink);
  font-family: var(--font-body); font-size: 15.5px; line-height: 1.8;
  box-shadow: inset 0 0 0 1px var(--hair), var(--shadow);
  transition: box-shadow .3s var(--ease); }
.transcribe textarea:focus { outline: none;
  box-shadow: inset 0 0 0 1px var(--gold), var(--shadow-gold); }
.transcribe textarea::placeholder { color: var(--ink-3); }
.transcribe textarea:disabled { opacity: .45; cursor: not-allowed; }
.transcribe-hint { font-size: 12.5px; color: var(--ink-3); text-align: center; }

/* صورة مهمة الوسم — بعرض كامل وارتفاع مضبوط، تُعرض كاملة بلا قصّ */
.image-view { width: 100%; max-height: min(52vh, 380px); object-fit: contain;
  border-radius: var(--r-md); background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--hair), var(--shadow); }

/* النصّ المساهَم (عناصر التصنيف المُجسَّرة من الاستطلاعات) — اقتباس داخل بطاقة السياق */
.quoted-text { margin-top: 12px; padding: 12px 16px; text-align: start;
  border-inline-start: 3px solid var(--gold); border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--ink);
  font-size: 15px; font-weight: 400; line-height: 1.8; white-space: pre-wrap; }

/* قائمة الخيارات — زرّ لكلّ خيار (التصنيف المُجسَّر متعدد الخيارات) */
.option-list { width: 100%; margin-top: 20px;
  display: flex; flex-direction: column; gap: 10px;
  animation: rise .6s var(--ease) both .66s; }
.option-btn { padding: 16px 18px; border: none; border-radius: var(--r-md); cursor: pointer;
  text-align: start; background: var(--surface); color: var(--ink);
  font-family: inherit; font-size: 15px; font-weight: 500; line-height: 1.7;
  box-shadow: inset 0 0 0 1px var(--hair), var(--shadow);
  transition: transform .3s var(--ease-back), box-shadow .3s var(--ease),
    background .3s, opacity .3s, filter .3s; }
@media (hover: hover) {
  .option-btn:hover { transform: translateY(-2px);
    box-shadow: inset 0 0 0 1px var(--gold), var(--shadow-gold); }
}
.option-btn.chosen { background: linear-gradient(150deg, var(--jade-deep), var(--gold-deep));
  color: #fff; box-shadow: inset 0 0 0 1px var(--gold-lit), var(--shadow-gold);
  transform: translateY(-2px); }
.option-btn.dimmed { opacity: .45; filter: saturate(.6); }

/* ── منتقي المشاريع (عند تعدّد المشاريع النشطة) ── */
.picker { padding-top: 14vh; gap: 8px; }
.picker h2 { font-family: var(--font-disp); font-size: 26px; color: var(--ink); }
.picker p { color: var(--ink-2); max-width: 42ch; }
.project-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px;
  width: 100%; margin-top: 18px; }
.project-chip { display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 16px 24px; border: none; border-radius: var(--r-md); cursor: pointer;
  background: var(--surface); color: var(--ink); font-family: inherit;
  box-shadow: inset 0 0 0 1px var(--hair), var(--shadow);
  transition: transform .3s var(--ease-back), box-shadow .3s var(--ease); }
.project-chip:hover { transform: translateY(-3px);
  box-shadow: inset 0 0 0 1px var(--gold), var(--shadow-gold); }
.chip-name { font-family: var(--font-disp); font-weight: 600; font-size: 16px; }
.chip-domain { margin-inline-start: 8px; font-family: var(--font-body, inherit); font-weight: 700;
  font-size: 11px; color: var(--gold); background: var(--surface-2, rgba(0,0,0,.05));
  padding: 2px 9px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--hair); vertical-align: middle; }
.chip-meta { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* مقطع مهمة وصف الفيديو — نفس إطار الصورة (blob محلي عبر نقطة الوسائط المحمية) */
.video-view { width: 100%; max-height: min(52vh, 380px);
  border-radius: var(--r-md); background: #000;
  box-shadow: inset 0 0 0 1px var(--hair), var(--shadow); }

/* ── كتلة الكيانات (NER) — تظليل النصّ وتسميته ── */
.ner-wrap { width: 100%; margin-top: 20px;
  display: flex; flex-direction: column; gap: 12px;
  animation: rise .6s var(--ease) both .66s; }
.ner-help, .ner-count { font-size: 12.5px; color: var(--ink-3); text-align: center; }
.ner-text { width: 100%; padding: 18px 20px; text-align: start;
  border-radius: var(--r-md); background: var(--surface); color: var(--ink);
  font-size: 16.5px; line-height: 2.2; white-space: pre-wrap; cursor: text;
  box-shadow: inset 0 0 0 1px var(--hair), var(--shadow);
  user-select: text; -webkit-user-select: text; }
.ner-text::selection, .ner-text *::selection { background: rgba(227,184,74,.45); }

/* كيان موسوم: تظليل يشمي + شارة التسمية (::before من data-label) + علامة إزالة (::after) —
   كلاهما عنصر زائف فلا يدخلان في حساب الإزاحات النصّية */
.ner-mark { cursor: pointer; border-radius: 6px; padding: 2px 4px;
  background: rgba(63,190,151,.16); color: inherit;
  box-shadow: inset 0 0 0 1px rgba(63,190,151,.45);
  transition: background .25s, box-shadow .25s; }
.ner-mark::before { content: attr(data-label); margin-inline-end: 5px;
  font-size: 10.5px; font-weight: 700; color: var(--jade-lit);
  padding: 1px 6px; border-radius: 999px; background: rgba(63,190,151,.14);
  box-shadow: inset 0 0 0 1px rgba(63,190,151,.3); }
.ner-mark::after { content: "✕"; margin-inline-start: 5px;
  font-size: 10.5px; font-weight: 700; color: var(--ink-3); }
@media (hover: hover) {
  .ner-mark:hover { background: rgba(228,120,80,.14);
    box-shadow: inset 0 0 0 1px rgba(228,120,80,.5); }
  .ner-mark:hover::after { color: #E47850; }
}

/* رقاقات التسمية — تظهر عند وجود تحديد بانتظار تسميته */
.ner-labels { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.ner-chip { padding: 9px 18px; border: none; border-radius: 999px; cursor: pointer;
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  background: var(--surface); color: var(--jade-lit);
  box-shadow: inset 0 0 0 1px var(--hair), var(--shadow);
  transition: transform .25s var(--ease-back), box-shadow .25s var(--ease), color .25s; }
.ner-chip:hover { transform: translateY(-2px); color: var(--gold-lit);
  box-shadow: inset 0 0 0 1px var(--gold), var(--shadow-gold); }

/* ── رسم الصناديق (image_bbox) ── */
.bbox-wrap { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.bbox-help { font-size: 12.5px; color: var(--ink-3); text-align: center; }
.bbox-labels { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.bbox-chip { padding: 8px 16px; border: none; border-radius: 999px; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 700;
  background: var(--surface); color: var(--jade-lit);
  box-shadow: inset 0 0 0 1px var(--hair), var(--shadow);
  transition: transform .2s var(--ease-back), box-shadow .2s, color .2s, background .2s; }
.bbox-chip:hover { transform: translateY(-2px); }
.bbox-chip.on { background: var(--jade-lit); color: #fff; box-shadow: inset 0 0 0 1px var(--jade); }
.bbox-stage { position: relative; display: inline-block; max-width: 100%; line-height: 0;
  border-radius: 12px; overflow: hidden; box-shadow: inset 0 0 0 1px var(--hair-soft); }
.bbox-image { display: block; max-width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.bbox-canvas { position: absolute; inset: 0; width: 100%; height: 100%;
  cursor: crosshair; touch-action: none; } /* touch-action: none — السحب يرسم لا يمرّر الصفحة */
.bbox-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: 100%; }
.bbox-row { display: inline-flex; align-items: center; gap: 8px; padding: 5px 6px 5px 12px;
  border-radius: 999px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--hair-soft); }
.bbox-row-label { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.bbox-del { border: none; background: rgba(179,38,30,.10); color: #b3261e; cursor: pointer;
  width: 22px; height: 22px; border-radius: 50%; font-size: 12px; font-weight: 700; line-height: 1; }
.bbox-del:hover { background: #b3261e; color: #fff; }
.bbox-count { flex-basis: 100%; text-align: center; font-size: 12.5px; color: var(--ink-3); }

/* ═══════════════════════════════════════════════════════════════════
   💻 طبقة الشاشات الكبيرة — إضافية بحتة: الموبايل (<768px) لا يتأثر.
   بطاقتا (أ/ب) جنباً إلى جنب أصلاً، والوسائط ونصّ الكيانات مقيّدة بعرض العمود.
   ═══════════════════════════════════════════════════════════════════ */

/* ── تابلت ≥768px: عمود المحتوى ~680px ── */
@media (min-width: 768px) {
  .stage { max-width: 680px; }
}

/* ── حاسوب ≥1100px: عمود المحتوى ~760px وتباعد أرحب ── */
@media (min-width: 1100px) {
  .stage { max-width: 760px; }
  .prompt-card { padding: 24px 26px; }
  .choice { padding: 24px 22px 46px; min-height: 140px; }
  .ner-text { padding: 22px 24px; }
  .transcribe textarea { min-height: 180px; }
}

/* ═══ كتلة اقتراح ردٍّ أفضل (الدورة الاقتصادية §5.1) ═══ */
.suggest-wrap { margin: 4px 0 2px; }
.suggest-toggle { width: 100%; text-align: right; cursor: pointer;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 13px 18px; border: none; border-radius: var(--r-md);
  background: var(--surface); color: var(--ink);
  font-family: var(--font-body); font-size: 14.5px; font-weight: 500;
  box-shadow: inset 0 0 0 1px var(--hair);
  transition: box-shadow .3s var(--ease); }
.suggest-toggle:hover { box-shadow: inset 0 0 0 1px var(--jade); }
.suggest-toggle[aria-expanded="true"] { box-shadow: inset 0 0 0 1px var(--jade); }
.suggest-badge { margin-inline-start: auto; font-size: 11.5px; font-weight: 600;
  color: var(--gold-deep); background: color-mix(in srgb, var(--gold) 16%, transparent);
  padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.suggest-body { margin-top: 10px; }
.suggest-body textarea { width: 100%; min-height: 84px; resize: vertical;
  padding: 14px 16px; border: none; border-radius: var(--r-md);
  background: var(--surface); color: var(--ink);
  font-family: var(--font-body); font-size: 15px; line-height: 1.75;
  box-shadow: inset 0 0 0 1px var(--hair);
  transition: box-shadow .3s var(--ease); }
.suggest-body textarea:focus { outline: none;
  box-shadow: inset 0 0 0 1px var(--gold), var(--shadow-gold); }
.suggest-body textarea::placeholder { color: var(--ink-3); }
.suggest-hint { margin: 8px 2px 0; font-size: 12.5px; color: var(--ink-3); line-height: 1.6; }

/* ── كتلة التحليل الصرفي (جذر/وزن/نوع) ── */
.morph-wrap { width: 100%; margin-top: 20px; }
.morph-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.morph-field { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; font-weight: 700; }
.morph-field small { font-weight: 400; opacity: .7; }
.morph-field input, .morph-field select {
  width: 100%; padding: 12px 14px; font-family: inherit; font-size: 1rem;
  border: 1.5px solid var(--line); border-radius: var(--r-sm);
  background: var(--card); color: var(--ink);
}
.morph-field input:focus, .morph-field select:focus { outline: none; border-color: var(--brand); }
@media (max-width: 560px) { .morph-grid { grid-template-columns: 1fr; } }
