/* ═══ صفحة رسم سير العمل — هوية إذكاء ═══
   الألوانُ والخطوطُ منقولةٌ من رموز الهوية في المستودع (`عروض/src/brand.mjs`) لا مقترحة.
   والمذهبُ «المَجمَع الساكن»: كريميٌّ دافئ، وحبرٌ فحميّ بدرجاته، وذهبٌ واحد لا يظهر إلا حيث يقع المعنى.
   والصفحةُ أداةُ عمل: الهويةُ تعطيها الخطَّ واللونَ والكثافةَ وحركةً واحدة (انقلابُ الخريطة)، ولا تعطيها شكلَ التحكم. */

@font-face { font-family: 'Thmanyah Sans'; src: url('../fonts/thmanyahsans-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Thmanyah Sans'; src: url('../fonts/thmanyahsans-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Thmanyah Sans'; src: url('../fonts/thmanyahsans-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Thmanyah Serif Display'; src: url('../fonts/thmanyahserifdisplay-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }

:root {
  --bg: #F4F1EA;        /* الكريمي — خلفية النسخة الفاتحة */
  --surface: #FDFCF8;   /* بطاقةٌ على الكريمي */
  --surface2: #EFEBE0;  /* لوحةٌ مظلَّلة */
  --line: #E4DFD2;      /* خيطٌ فاصل */
  --line2: #D3CBB8;     /* حدُّ عنصرٍ تفاعلي */
  --ink: #232830;       /* نصُّ المتن (١٤:١) */
  --ink2: #5F6672;      /* نصٌّ ثانويّ (٥٫١:١) — أخفُّ نصٍّ مسموح */
  --ink3: #9AA0A8;      /* للخطوط والنقاط وحدها، لا للنص */
  --gold: #B9933A;      /* ذهبُ الشعار: أشكالٌ لا نصّ على الفاتح */
  --gold-ink: #7E6029;  /* ذهبُ النصّ على الكريمي (٥٫٢:١) */
  --gold-soft: #F1E8D2;
  --night: #12171E;
  --pearl: #EAE5D8;
  --gold-night: #C6A55C;
  --warm: #9A6A1F;      /* علامةُ التعثر: دافئةٌ هادئة، ونصُّها ٥:١ */
  --warm-soft: #F5E9D3;
  --danger: #A84545;

  --font: 'Thmanyah Sans', system-ui, 'Segoe UI', Tahoma, sans-serif;
  --head: 'Thmanyah Serif Display', 'Thmanyah Sans', serif;
  /* سلّمُ الطباعة: أدوارٌ لا قيم */
  --t-display: 2rem; --t-h1: 1.75rem; --t-h2: 1.3rem; --t-body: 1.0625rem; --t-small: .9375rem; --t-meta: .8125rem;
  --r: 12px;
  --u: 8px;
  --hit: 44px;           /* أصغرُ هدفٍ للمس */
  --ease: cubic-bezier(.16, 1, .3, 1);
  --sheet-w: 420px;
  color-scheme: light;
  accent-color: var(--ink);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--line2) transparent; }
body {
  margin: 0; background: var(--bg); color: var(--ink); caret-color: var(--gold-ink);
  font-family: var(--font); font-size: var(--t-body); line-height: 1.75;
  -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
}
::selection { background: var(--gold-soft); color: var(--ink); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 10px; border: 3px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--gold-ink); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.ic { flex-shrink: 0; display: block; }

/* ── الترويسة */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; min-height: 56px; background: rgba(244, 241, 234, .96);
  border-bottom: 1px solid var(--line);
}
.top .logo { height: 24px; width: auto; display: block; flex-shrink: 0; }
.top .org { font-size: var(--t-meta); color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; padding-inline-start: 12px; border-inline-start: 1px solid var(--line2); }
.top .sp { flex: 1; }
.steps { display: flex; align-items: center; gap: 10px; font-size: var(--t-meta); color: var(--ink2); white-space: nowrap; }
.steps .dots { display: flex; gap: 5px; }
.steps .dots i { width: 7px; height: 7px; transform: rotate(45deg); background: var(--line2); display: block; border-radius: 1px; }
.steps .dots i.done { background: var(--ink2); }
.steps .dots i.now { background: var(--gold); }
.icon-btn {
  border: 1px solid var(--line2); background: var(--surface); border-radius: 999px;
  padding: 0 14px; font-size: var(--t-small); color: var(--ink); display: inline-flex; align-items: center; gap: 6px; min-height: var(--hit); min-width: var(--hit); justify-content: center;
  transition: background .15s, border-color .15s;
}
.icon-btn:hover { border-color: var(--ink2); }
.icon-btn:disabled { opacity: .45; cursor: default; }
.icon-btn.danger { color: var(--danger); }
@media (max-width: 560px) { .hide-sm { display: none; } .steps > span:last-child { display: none; } }

/* ── الصفحات */
main { padding: 28px 18px 128px; }
.page { max-width: 640px; margin: 0 auto; }
.page.wide { max-width: none; }
h1, h2, h3 { font-family: var(--head); font-weight: 500; line-height: 1.4; margin: 0; text-wrap: balance; color: var(--ink); }
h1 { font-size: var(--t-h1); }
h2 { font-size: var(--t-h2); }
h1 + .lead, h1 + .q { margin-top: 12px; }
.lead { color: var(--ink2); margin: 12px 0 0; max-width: 58ch; text-wrap: pretty; }
p { margin: 0; text-wrap: pretty; }
.muted { color: var(--ink2); }
.small { font-size: var(--t-small); }
.rule { height: 1px; background: var(--line); border: 0; margin: 36px 0 8px; }
.progress-line { font-size: var(--t-meta); color: var(--ink2); margin-bottom: 8px; }
.h-q { font-size: var(--t-h2); line-height: 1.55; }

/* ── الأزرار */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 500; text-decoration: none; transition: background .15s, border-color .15s, color .15s;
}
.btn.primary { background: var(--ink); color: var(--surface); }
.btn.primary:hover { background: #0F1318; }
.btn.primary:disabled { background: var(--ink2); cursor: progress; }
.btn.ghost { background: transparent; border-color: var(--line2); color: var(--ink); }
.btn.ghost:hover { background: var(--surface); border-color: var(--ink2); }
.btn.link { background: none; border: 0; padding: 0 6px; min-height: var(--hit); color: var(--gold-ink); text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 1px; font-weight: 400; }
.btn.link:hover { color: var(--ink); }
.btn.rec { border-color: var(--danger); color: var(--danger); }
.btn.rec .timer { font-variant-numeric: tabular-nums; }
.actions { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-top: 24px; }
.bar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 15;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--line);
  display: flex; justify-content: center;
}
.bar .in { width: 100%; max-width: 640px; display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.bar .note { font-size: var(--t-small); color: var(--ink2); }

/* ── الترحيب — بلغة صدر موقع إذكاء التعريفي (`mezan/site`): حقلُ معيّناتٍ خافت، وتوهّجان ذهبيّان،
   وغبارٌ ذهبيّ ينعقد معيّنًا، وعنوانٌ بثمانية العريض، وزرٌّ ذهبيّ يميل نحو المؤشّر */
@font-face { font-family: 'Thmanyah Serif Display'; src: url('../fonts/thmanyahserifdisplay-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }
:root { --accent: #A9853F; --accent-btn: #8E6E31; --accent-press: #6F5622; --on-accent: #FFFDF6; --accent-soft: #A9853F1F; }
.hello { position: relative; max-width: 1080px; margin: -12px auto 0; text-align: center; }
.hello-ground {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1100px 520px at 88% -8%, var(--accent-soft), transparent 62%),
    radial-gradient(900px 480px at -12% 108%, var(--accent-soft), transparent 55%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='74' height='64'%3E%3Crect x='34' y='28' width='4.6' height='4.6' rx='.8' transform='rotate(45 36.3 30.3)' fill='%23A9853F' fill-opacity='.2'/%3E%3C/svg%3E");
}
.hello-stage { display: flex; flex-direction: column; align-items: center; }
.dust { display: block; width: min(560px, 100%); height: clamp(210px, 30vw, 320px); color: var(--accent); touch-action: pan-y; }
.hello-eyebrow { display: inline-flex; align-items: center; gap: 10px; margin: 6px 0 14px; font-family: var(--head); font-weight: 700; font-size: clamp(15px, 1.4vw, 19px); color: var(--gold-ink); }
.hello-eyebrow .mk { width: 14px; height: 14px; }
.hello-title { font-family: var(--head); font-weight: 700; font-size: clamp(34px, 6.2vw, 70px); line-height: 1.24; max-width: 17ch; margin-inline: auto; text-wrap: balance; }
.hello-org { display: block; margin-top: .18em; font-size: .6em; color: var(--gold-ink); }
.hello-promise { font-family: var(--head); font-weight: 500; font-size: clamp(18px, 2vw, 22px); line-height: 1.85; color: var(--ink2); max-width: 44ch; margin: 22px auto 0; text-align: center; text-wrap: balance; }

.hello-steps { list-style: none; margin: 46px auto 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: 0; max-width: 980px; text-align: start; }
.hello-steps li { position: relative; display: grid; grid-template-columns: 2.6rem 1fr; column-gap: 6px; padding: 18px 6px 18px; border-top: 1px solid var(--line2); cursor: default; outline-offset: -2px; transition: background-color .25s; }
.hello-steps li::after { content: ''; position: absolute; inset-inline: 0; bottom: -1px; height: 1px; background: var(--line); }
.hello-steps .n { grid-row: span 2; font-family: var(--head); font-weight: 700; font-size: 1.7rem; line-height: 1.15; color: var(--gold-ink); }
.hello-steps b { font-weight: 500; font-size: 1.0625rem; }
.hello-steps .t { color: var(--ink2); font-size: var(--t-small); }
.hello-steps .run { position: absolute; top: -1px; inset-inline-start: 0; height: 2px; width: 0; background: var(--accent); }
.hello-steps li.on { background: color-mix(in srgb, var(--surface) 70%, transparent); }
.hello-steps li.on .run { width: 100%; transition: width 3.6s linear; }

.hello-cta { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 14px; margin-top: 34px; }
.btn.gold { background: var(--accent-btn); color: var(--on-accent); min-height: 52px; padding: 0 34px; font-size: 1.0625rem; transition: background-color .15s, transform .2s var(--ease); }
.btn.gold:hover { background: var(--accent-press); }
.btn.gold:active { transform: scale(.97); }
.hello-confirm { max-width: 560px; margin: 18px auto 0; text-align: start; }

.hello-facts { list-style: none; margin: 46px auto 0; padding: 18px 0 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr; gap: 14px 28px; max-width: 980px; text-align: start; font-size: var(--t-small); color: var(--ink2); }
.hello-facts li { position: relative; padding-inline-start: 18px; }
.hello-facts li::before { content: ''; position: absolute; inset-inline-start: 2px; top: .75em; width: 6px; height: 6px; background: var(--accent); transform: rotate(45deg); }
.hello-facts b { display: block; color: var(--ink); font-weight: 500; }
@media (min-width: 760px) {
  .hello-steps { grid-template-columns: repeat(3, 1fr); column-gap: 28px; }
  .hello-steps li { border-top-color: var(--ink); }
  .hello-steps li::after { display: none; }
  .hello-facts { grid-template-columns: repeat(4, 1fr); }
}
.confirm { margin-top: 16px; border: 1px solid var(--line2); border-radius: var(--r); padding: 14px 16px; background: var(--surface); }
.confirm .actions { margin-top: 10px; }
.gone { padding-top: 64px; text-align: center; }
.gone .logo { height: 30px; margin: 0 auto 28px; display: block; }
.gone .lead { margin-inline: auto; }

/* ── الحقول والاختيارات */
.q { margin-top: 28px; }
.q > label.ql, .q > .ql, .q > span.ql { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-weight: 500; margin-bottom: 10px; flex-wrap: wrap; }
.q > .ql .muted { font-weight: 400; font-size: var(--t-small); }
.hint { font-size: var(--t-small); color: var(--ink2); margin-top: 10px; }
.input, .textarea {
  width: 100%; border: 1px solid var(--line2); background: var(--surface); border-radius: 10px;
  padding: 11px 14px; min-height: 48px; line-height: 1.6;
  transition: border-color .15s, box-shadow .15s;
}
.input.narrow { max-width: 200px; margin-top: 10px; }
.q .input + .input, .chips + .input, .chips + label + .input { margin-top: 10px; }
.textarea { min-height: 140px; resize: vertical; display: block; }
.textarea.tall { min-height: 220px; }
.textarea.short { min-height: 96px; }
.input::placeholder, .textarea::placeholder { color: var(--ink2); opacity: .75; }
.input:focus, .textarea:focus { outline: none; border-color: var(--gold-ink); box-shadow: 0 0 0 3px var(--gold-soft); }
.input[aria-invalid='true'] { border-color: var(--danger); }
.field-err { color: var(--danger); font-size: var(--t-small); margin-top: 6px; }
.field-foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-top: 8px; }
.count { font-size: var(--t-meta); color: var(--ink2); white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: var(--hit);
  padding: 0 16px; border-radius: 999px; border: 1px solid var(--line2);
  background: var(--surface); font-size: var(--t-small); line-height: 1.4; text-align: start;
  transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--ink2); }
.chip[aria-pressed='true'] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip[aria-pressed='true'] .sh { box-shadow: 0 0 0 1.5px var(--surface); }
.chip.suggested { border-style: dashed; color: var(--ink2); background: transparent; }
.chip.suggested::after { content: 'مقترح'; font-size: .6875rem; color: var(--gold-ink); border: 1px solid var(--line2); border-radius: 999px; padding: 0 7px; line-height: 1.7; }
.chip.inferred::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); order: -1; }
.chip.unk { color: var(--ink2); }
.chip.unk[aria-pressed='true'] { background: var(--surface2); color: var(--ink); border-color: var(--ink2); }
.chip.add { border-style: dashed; color: var(--gold-ink); background: transparent; }
.inline-add { display: flex; gap: 8px; margin-top: 10px; }
.consent { display: flex; gap: 12px; align-items: flex-start; margin-top: 24px; font-size: var(--t-small); color: var(--ink2); cursor: pointer; }
.consent input { width: 20px; height: 20px; margin-top: 4px; flex-shrink: 0; }
.voice { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 12px; }

/* أشكالُ الأدوار — اللونُ ومعه شكل، لمن يصعب عليه تمييز الألوان */
.sh { display: inline-block; width: 10px; height: 10px; flex-shrink: 0; background: var(--c, var(--ink)); }
.sh.diamond { transform: rotate(45deg) scale(.85); }
.sh.square { border-radius: 1px; }
.sh.circle { border-radius: 50%; }
.sh.triangle { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.sh.dash { height: 5px; width: 12px; }
.sh.ring { background: none; border: 2.5px solid var(--c); border-radius: 50%; }
.sh.cross { clip-path: polygon(35% 0, 65% 0, 65% 35%, 100% 35%, 100% 65%, 65% 65%, 65% 100%, 35% 100%, 35% 65%, 0 65%, 0 35%, 35% 35%); }
.sh.hex { clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); }
.fd { display: inline-block; width: 7px; height: 7px; background: var(--warm); transform: rotate(45deg); flex-shrink: 0; }

/* ── قائمة المهام: سجلٌّ بخيوطٍ فاصلة لا شبكةُ بطاقات */
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 999px; padding: 3px; background: var(--surface); gap: 2px; }
.seg button { border: 0; background: none; border-radius: 999px; padding: 0 18px; min-height: 40px; font-size: var(--t-small); color: var(--ink2); }
.seg button[aria-pressed='true'] { background: var(--ink); color: var(--surface); }
.tpl-list { list-style: none; margin: 18px 0 0; padding: 0; border-top: 1px solid var(--line); }
.tpl-list li { border-bottom: 1px solid var(--line); }
.tpl {
  width: 100%; text-align: start; border: 0; background: none; padding: 14px 4px; min-height: 64px;
  display: flex; gap: 14px; align-items: center; color: var(--ink); transition: background .15s;
}
.tpl .tx { flex: 1; min-width: 0; }
.tpl b { display: block; font-weight: 500; }
.tpl .tx > span { display: block; color: var(--ink2); font-size: var(--t-small); }
.tpl .ic { color: var(--ink3); transition: color .15s, transform .2s var(--ease); }
.tpl:hover { background: var(--surface); }
.tpl:hover .ic { color: var(--gold); transform: translateX(-3px); }
.tpl.other b { color: var(--gold-ink); }
.tpl-list .empty { padding: 16px 4px; color: var(--ink2); font-size: var(--t-small); }

/* ── طريقة الرسم: خياران متكافئان في الحجم والمكانة */
.twin { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 24px; }
.choice {
  text-align: start; border: 1px solid var(--line2); background: var(--surface); border-radius: 16px;
  padding: 22px 20px; min-height: 148px; display: flex; flex-direction: column; gap: 8px; transition: border-color .15s, box-shadow .2s;
}
.choice:hover { border-color: var(--gold); box-shadow: 0 6px 20px -12px rgba(18, 23, 30, .35); }
.choice h2 { font-size: var(--t-h2); }
.choice p { color: var(--ink2); font-size: var(--t-small); }

/* ── الحكاية */
.prompts { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.prompts li { color: var(--ink2); padding-inline-start: 18px; position: relative; font-size: var(--t-small); }
.prompts li::before { content: ''; position: absolute; inset-inline-start: 2px; top: .75em; width: 6px; height: 6px; border: 1px solid var(--gold); transform: rotate(45deg); }
.example { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.example summary, .story-box summary, .deep summary, .more summary, .sheet summary { cursor: pointer; min-height: var(--hit); display: flex; align-items: center; gap: 10px; list-style: none; }
.example summary::-webkit-details-marker, .story-box summary::-webkit-details-marker, .deep summary::-webkit-details-marker, .more summary::-webkit-details-marker, .sheet summary::-webkit-details-marker { display: none; }
.example summary::before, .story-box summary::before, .deep summary::before, .more summary::before, .sheet summary::before {
  content: ''; width: 7px; height: 7px; border-inline-end: 1.5px solid var(--ink2); border-bottom: 1.5px solid var(--ink2); transform: rotate(45deg); margin-top: -4px; transition: transform .2s var(--ease); flex-shrink: 0;
}
details[open] > summary::before { transform: rotate(-135deg); margin-top: 4px; }
.example summary { color: var(--gold-ink); font-size: var(--t-small); }
.example p { color: var(--ink2); font-size: var(--t-small); background: var(--surface2); border-radius: var(--r); padding: 14px 16px; }
.more { margin-top: 14px; }
.more summary { font-size: var(--t-small); color: var(--gold-ink); }
.privacy { font-size: var(--t-small); color: var(--ink2); }
.story-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 0 16px; font-size: var(--t-small); color: var(--ink2); margin-top: 14px; }
.story-box summary { color: var(--ink); font-weight: 500; }
.story-box p { padding-bottom: 14px; white-space: pre-wrap; }
.growing { display: flex; flex-direction: column; gap: 10px; margin-top: 32px; }
.growing span { height: 54px; border-radius: var(--r); border: 1px solid var(--line); border-inline-start: 4px solid var(--line2); background: var(--surface); opacity: 0; animation: appear .6s var(--ease) forwards; animation-delay: calc(var(--i) * .9s); }
@keyframes appear { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── مساحة الرسم */
.canvas-head { max-width: 640px; margin: 0 auto 20px; }
.banner { font-size: var(--t-h2); line-height: 1.55; }
.rule-line { font-size: var(--t-small); color: var(--ink2); border-inline-start: 2px solid var(--gold); padding: 2px 12px; margin-top: 16px; }
.help { font-size: var(--t-small); color: var(--ink2); margin-top: 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: var(--t-meta); color: var(--ink2); margin-top: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.track-wrap { position: relative; margin: 0 auto; max-width: 640px; }
.track { position: relative; display: flex; flex-direction: column; align-items: stretch; padding: 4px 0 4px 48px; }
.arrows { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.arrows path { fill: none; stroke: var(--ink2); stroke-width: 1.4; stroke-dasharray: 4 4; }
.arrows .head { fill: var(--ink2); stroke: none; }

.end-pill { align-self: flex-start; display: inline-flex; gap: 10px; align-items: baseline; font-size: var(--t-small); color: var(--ink2); background: var(--surface2); border-radius: 10px; padding: 8px 14px; max-width: 100%; }
.end-pill b { color: var(--ink); font-weight: 500; }

/* الفاصلُ بين المرحلتين: طولُه بقدر الانتظار، وكثافةُ نقاطه تقلّ كلما طال */
.gap { position: relative; display: flex; align-items: center; justify-content: center; min-height: var(--len, 28px); transition: min-height .7s var(--ease), min-width .7s var(--ease); }
.gap::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: 28px; width: 2px; background: radial-gradient(circle, var(--ink3) 1.2px, transparent 1.6px) center top / 2px var(--dot, 9px) repeat-y; }
.gap.still::before { background: var(--line2); width: 1px; }
.gap .wait-tag { position: absolute; inset-inline-start: 44px; font-size: var(--t-meta); color: var(--ink2); background: var(--bg); padding: 0 6px; white-space: nowrap; }
.gap .wait-tag.long { color: var(--warm); }
.gap .hand { position: absolute; inset-inline-start: 19px; width: 20px; height: 20px; border-radius: 50%; background: var(--bg); border: 1px solid var(--ink3); display: grid; place-items: center; color: var(--ink2); z-index: 1; }
.gap .hand.external { border: 2px solid var(--ink); color: var(--ink); }
.gap .hand.slow { border-color: var(--warm); color: var(--warm); }
.plus {
  position: absolute; inset-inline-end: -46px; width: 36px; height: 36px; border-radius: 50%;
  border: 1px dashed var(--line2); background: var(--bg); color: var(--ink2);
  display: grid; place-items: center; z-index: 2; transition: border-color .15s, color .15s;
}
.plus::after { content: ''; position: absolute; inset: -4px; } /* هدفُ اللمس ٤٤ */
.plus:hover, .plus:focus-visible { border-color: var(--gold-ink); color: var(--gold-ink); border-style: solid; }
.plus.end { position: relative; width: auto; height: var(--hit); padding: 0 18px; border-radius: 999px; font-size: var(--t-small); gap: 8px; display: inline-flex; align-items: center; margin: 14px 0; align-self: flex-start; }

/* بطاقةُ المرحلة — لونُ حدّها من يتولاها (يطلبه الموجز صراحة) */
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 14px; width: 100%; text-align: start;
  transition: opacity .6s var(--ease), transform .6s var(--ease), max-height .7s var(--ease), padding .6s var(--ease), border-color .3s, background .3s, box-shadow .2s;
  max-height: 900px; overflow: hidden;
}
.card:hover { box-shadow: 0 4px 14px -10px rgba(18, 23, 30, .4); }
.card.grow { animation: grow .5s var(--ease); transform-origin: top center; }
@keyframes grow { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
.card .row { display: flex; align-items: flex-start; gap: 10px; }
.card .nm { flex: 1; font-weight: 500; line-height: 1.55; }
.card .num { font-size: var(--t-meta); color: var(--ink2); min-width: 18px; padding-top: 2px; }
.card .grip { border: 0; background: none; color: var(--ink3); width: var(--hit); height: var(--hit); margin: -10px -6px -10px -8px; display: grid; place-items: center; cursor: grab; touch-action: none; border-radius: 8px; }
.card .grip:hover { color: var(--ink2); }
.card .marks { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: var(--t-meta); color: var(--ink2); }
.card .marks span { display: inline-flex; align-items: center; gap: 6px; }
.card .marks .faint { font-style: normal; opacity: .85; }
.card .marks .sug { opacity: .6; }
.card .marks .inf::after { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--gold); }
.card.cond { border-style: dashed; }
.card .cond-tag { font-size: var(--t-meta); color: var(--ink2); border: 1px dashed var(--ink3); border-radius: 999px; padding: 0 10px; }
.card .fric { color: var(--warm); }
.card .fric.soft { color: var(--ink2); }
.card.hot { box-shadow: inset 0 3px 0 var(--warm-soft); }
.card .ask, .card .clar { margin-top: 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card .clar { flex-direction: column; align-items: flex-start; border-top: 1px dashed var(--line2); padding-top: 10px; }
.card .ask .lbl, .card .clar .lbl { font-size: var(--t-small); color: var(--ink2); margin-inline-end: 4px; }
.card .ask .chip, .card .clar .chip { min-height: 40px; padding: 0 16px; }
.card.pending { background: transparent; border-style: dashed; }
.card.pending .nm { color: var(--ink2); }
.card.guide .nm { color: var(--ink2); font-weight: 400; }
.card.dragging { opacity: .6; z-index: 5; box-shadow: 0 12px 28px -12px rgba(18, 23, 30, .45); }
.card .open { position: absolute; inset: 0; border: 0; background: none; z-index: 0; border-radius: var(--r); }
.card .row, .card .marks, .card .ask, .card .clar { position: relative; z-index: 1; pointer-events: none; }
.card .row > button, .card .ask > *, .card .clar > * { pointer-events: auto; }
.card .after-tag { display: none; }
.card.selected { border-color: var(--ink2); box-shadow: 0 0 0 3px var(--gold-soft); }

.folded { display: flex; align-items: center; gap: 8px; font-size: var(--t-small); color: var(--ink2); border: 1px dashed var(--line2); border-radius: 999px; padding: 0 4px 0 14px; align-self: flex-start; max-width: 100%; }
.folded s { text-decoration-color: var(--ink3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* نقطةُ القرار: معيّنٌ يتفرّع منه مساران */
.dec { position: relative; display: flex; align-items: center; gap: 14px; padding: 12px 0; }
.dec .dia { width: 32px; height: 32px; flex-shrink: 0; margin-inline-start: 12px; transform: rotate(45deg); border: 1.5px solid var(--ink); background: var(--surface); border-radius: 4px; display: grid; place-items: center; }
.dec .dia span { transform: rotate(-45deg); font-weight: 700; font-size: var(--t-small); }
.dec .body { flex: 1; font-size: var(--t-small); }
.dec .body b { display: block; font-weight: 500; }
.dec .body .br { color: var(--ink2); display: block; }
.dec .edit { border: 0; background: none; position: absolute; inset: 0; border-radius: 10px; }

/* ── لوحة الخصائص: نافذةٌ سفلية على الجوال، وجانبيةٌ على الحاسوب */
.scrim { position: fixed; inset: 0; background: rgba(18, 23, 30, .28); z-index: 40; opacity: 0; transition: opacity .25s; }
.scrim.on { opacity: 1; }
.sheet {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 41; max-height: 88vh; overflow: auto;
  background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: 0 -10px 40px rgba(18, 23, 30, .14);
  padding: 6px 18px 0; transform: translateY(100%); visibility: hidden;
  transition: transform .32s var(--ease), visibility 0s .32s; overscroll-behavior: contain;
}
.sheet.on { transform: none; visibility: visible; transition: transform .32s var(--ease); }
.sheet .handle { width: 40px; height: 4px; border-radius: 4px; background: var(--line2); margin: 6px auto 8px; }
.sheet .s-head { display: flex; align-items: center; gap: 8px; font-size: var(--t-meta); color: var(--ink2); }
.sheet .s-head .sp { flex: 1; }
.sheet .s-head .icon-btn { border: 0; background: none; padding: 0; }
.sheet .name-in { font-family: var(--head); font-size: 1.3rem; border: 0; border-bottom: 1px solid var(--line2); background: none; width: 100%; padding: 6px 0 8px; margin-top: 2px; border-radius: 0; }
.sheet .name-in:focus { outline: none; border-bottom-color: var(--gold-ink); box-shadow: 0 1px 0 var(--gold-ink); }
.sheet .q { margin-top: 22px; }
.sheet .q > .ql { font-size: var(--t-small); margin-bottom: 8px; }
.sheet .apply { font-size: var(--t-meta); color: var(--gold-ink); background: none; border: 0; text-decoration: underline; text-underline-offset: 4px; padding: 0; min-height: 32px; font-weight: 400; }
.sheet .ex { font-size: var(--t-meta); color: var(--ink); background: var(--gold-soft); border-radius: 8px; padding: 8px 12px; margin: 0 0 10px; }
.evidence { font-size: var(--t-meta); color: var(--ink2); margin: 2px 0 10px; padding-inline-start: 10px; border-inline-start: 2px solid var(--gold); }
.evidence span { color: var(--gold-ink); }
.sheet details { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 4px; }
.sheet summary { font-weight: 500; font-size: var(--t-small); }
.sheet summary .muted { font-weight: 400; }
.sheet .tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.sheet .tools .icon-btn { font-size: var(--t-meta); }
.sheet .nav { position: sticky; bottom: 0; background: var(--surface); display: flex; gap: 10px; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); margin-top: 20px; border-top: 1px solid var(--line); }
.sheet .nav .btn { flex: 1; }

/* ── أضف بالكلام، والمرحلة الغائبة */
.speak-open { max-width: 640px; margin: 10px auto 0; }
.speak, .suggest { max-width: 640px; margin: 18px auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.speak .ql { display: block; font-weight: 500; margin: 14px 0 8px; }
.speak .ql:first-child { margin-top: 0; }
.speak .actions { margin-top: 12px; }
.suggest { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.suggest p { flex: 1 1 220px; }

/* ── الانعكاس */
.reflect-head { max-width: 640px; margin: 0 auto; }
.sec { margin-top: 40px; }
/* الأرقام: سجلٌّ مدوَّن تحت الحقل المرسوم */
.ledger { margin: 14px 0 0; border-top: 1px solid var(--ink); }
.led { display: grid; grid-template-columns: 1fr; gap: 2px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.led dt { font-size: var(--t-small); color: var(--ink2); }
.led dd { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.led dd b { font-family: var(--head); font-weight: 500; font-size: 1.85rem; line-height: 1.25; }
.led dd span { flex-basis: 100%; font-size: var(--t-small); color: var(--ink2); }
.led.key dt { display: flex; align-items: center; gap: 8px; }
.led.key dt::before { content: ''; width: 7px; height: 7px; background: var(--gold); transform: rotate(45deg); }
.led.key dd b { color: var(--gold-ink); }
.led .missing { color: var(--ink2); font-size: var(--t-small); }
.est-note { font-size: var(--t-meta); color: var(--ink2); margin-top: 10px; }
.sentence { font-family: var(--head); font-size: 1.2rem; line-height: 1.75; margin-top: 22px; text-wrap: pretty; }
.gap-note { margin-top: 8px; }
.aside-note { font-size: var(--t-small); color: var(--ink); background: var(--surface2); border-radius: var(--r); padding: 12px 16px; margin-top: 18px; }
.deep { max-width: 640px; margin: 36px auto 0; border-top: 1px solid var(--line); }
.deep details { border-bottom: 1px solid var(--line); padding: 2px 0 6px; }
.deep summary { font-weight: 500; }
.deep .chips { margin-top: 6px; }
.journey { list-style: none; padding: 0; margin: 14px 0 8px; display: flex; flex-wrap: wrap; gap: 6px 0; align-items: center; font-size: var(--t-small); }
.journey li { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; }
.journey li + li::before { content: ''; width: 14px; height: 1px; background: var(--ink3); margin-inline: -18px 10px; }
.journey li + li { margin-inline-start: 18px; }

/* ── الختام */
.share-box { margin-top: 18px; background: var(--surface2); border-radius: var(--r); padding: 14px 16px; font-size: var(--t-small); }
.share-box .input { margin-top: 10px; font-size: var(--t-small); direction: ltr; text-align: left; }
.share-box .actions { margin-top: 10px; }

/* ── النوافذ */
.modal { position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow: auto; }
.modal main { padding-bottom: 48px; }
.toast {
  position: fixed; bottom: calc(92px + env(safe-area-inset-bottom)); inset-inline: 16px; margin: 0 auto; max-width: 440px; z-index: 60;
  background: var(--night); color: var(--pearl); border-radius: 12px; padding: 8px 8px 8px 16px; padding-inline-start: 16px; font-size: var(--t-small);
  display: flex; gap: 12px; align-items: center; justify-content: space-between; animation: rise .35s var(--ease);
  box-shadow: 0 10px 30px -12px rgba(18, 23, 30, .5);
}
.toast button { background: none; border: 0; color: var(--gold-night); text-decoration: underline; text-underline-offset: 4px; min-height: 40px; padding: 0 10px; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.print-only { display: none; }

/* ── الحاسوب: المسارُ من اليمين إلى اليسار */
@media (min-width: 900px) {
  :root { --t-display: 2.5rem; --t-h1: 2.125rem; --t-h2: 1.45rem; }
  main { padding: 44px 32px 128px; }
  .twin { grid-template-columns: 1fr 1fr; }
  .ledger { display: grid; grid-template-columns: repeat(3, 1fr); column-gap: 28px; }
  .led { border-bottom: 0; }

  .track-wrap { max-width: none; overflow-x: auto; padding: 88px 8px 28px; }
  .track { flex-direction: row; align-items: center; padding: 0 0 52px; width: max-content; min-width: 100%; }
  .card { width: 216px; flex-shrink: 0; min-height: 124px; }
  .gap { min-height: 0; min-width: var(--len, 28px); align-self: stretch; }
  .gap::before { inset-block: auto; top: 50%; inset-inline: 0; width: auto; height: 2px; background: radial-gradient(circle, var(--ink3) 1.2px, transparent 1.6px) left center / var(--dot, 9px) 2px repeat-x; }
  .gap.still::before { height: 1px; width: auto; background: var(--line2); }
  .gap .wait-tag { inset-inline-start: auto; top: calc(50% + 12px); }
  .gap .hand { inset-inline-start: auto; top: calc(50% - 10px); }
  .plus { inset-inline-end: auto; top: auto; bottom: -48px; }
  .dec { flex-direction: column; padding: 0 12px; width: 156px; flex-shrink: 0; text-align: center; gap: 10px; }
  .dec .dia { margin: 0; }
  .end-pill { align-self: center; max-width: 180px; flex-shrink: 0; flex-direction: column; gap: 0; }
  .plus.end { align-self: center; margin: 0 14px; }
  .folded { align-self: center; flex-direction: column; border-radius: 12px; padding: 8px; width: 124px; flex-shrink: 0; }
  .folded s { white-space: normal; text-align: center; }

  .scrim, .scrim.on { background: transparent; pointer-events: none; }
  .sheet { left: 0; right: auto; top: 0; bottom: 0; max-height: none; width: var(--sheet-w); border-radius: 0; transform: translateX(-100%); box-shadow: 10px 0 40px rgba(18, 23, 30, .12); padding-top: 14px; }
  .sheet .handle { display: none; }
  body.sheet-open main { padding-left: calc(var(--sheet-w) + 24px); }
  .toast { bottom: 96px; }
}

/* الحركةُ المختزَلة: تبقى تغيّراتُ الحالة ظاهرةً بتبدّل اللون والوضع، وتسقط الإزاحةُ والانزلاق */
@media (prefers-reduced-motion: reduce) {
  .card, .gap, .sheet, .scrim, .tpl .ic, .choice { transition-duration: 0s !important; }
  .track .card, .track .gap { transition: opacity .2s linear !important; }
  .card.grow, .growing span, .toast { animation: none !important; opacity: 1; }
  .hello-steps li.on .run { transition: none; }
}

/* ── الخريطة الأنيقة: تُعرض ورقةً في شاشة الختام، وهي نفسُها ما يُطبع */
.done h1 { margin-bottom: 4px; }
.paper { margin-top: 28px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 36px 34px 28px; box-shadow: 0 18px 40px -28px rgba(18, 23, 30, .45); font-size: .9rem; overflow-x: auto; }
.pr-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 1px solid var(--line2); padding-bottom: 8px; }
.pr-head svg { height: 22px; width: auto; }
.pr-head .meta { font-size: 9pt; color: var(--ink2); }
.pr h1 { font-size: 20pt; margin-top: 14px; }
.pr .sub { color: var(--ink2); font-size: 10pt; margin-top: 4px; }
.pr table { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 9.5pt; }
.pr th { text-align: start; font-weight: 500; color: var(--ink2); border-bottom: 1px solid var(--ink); padding: 5px 6px; }
.pr td { border-bottom: 1px solid var(--line); padding: 6px; vertical-align: top; }
.pr td.n { color: var(--ink2); width: 22px; }
.pr tr.wait td { border: 0; padding: 0 6px; color: var(--warm); font-size: 8.5pt; }
.pr tr.pr-dec td { color: var(--ink2); font-size: 9pt; }
.pr .nums { display: flex; gap: 10px; margin-top: 14px; }
.pr .nums div { flex: 1; border-top: 1.5px solid var(--ink); padding: 6px 2px; }
.pr .nums b { font-family: var(--head); font-size: 15pt; font-weight: 500; display: block; }
.pr .nums span { font-size: 9pt; color: var(--ink2); }
.pr h2 { font-size: 13pt; margin-top: 18px; }
.pr ul { margin: 6px 0 0; padding-inline-start: 18px; font-size: 10pt; }
.pr .foot { margin-top: 18px; font-size: 8.5pt; color: var(--ink2); border-top: 1px solid var(--line); padding-top: 6px; }
.pr .sh { -webkit-print-color-adjust: exact; print-color-adjust: exact; margin-inline-end: 4px; }

@media (max-width: 640px) {
  .paper { padding: 24px 18px 18px; }
  .paper .pr .nums { flex-wrap: wrap; }
  .paper .pr .nums div { flex: 1 1 40%; }
  .paper .pr thead { display: none; }
  .paper .pr table, .paper .pr tbody, .paper .pr tr, .paper .pr td { display: block; }
  .paper .pr tr { display: grid; grid-template-columns: 1.6rem 1fr; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .paper .pr td { border: 0; padding: 2px 0; grid-column: 2; }
  .paper .pr td.n { grid-column: 1; grid-row: 1; }
  .paper .pr td.nm { font-weight: 500; }
  .paper .pr td[data-l]::before { content: attr(data-l) ': '; color: var(--ink2); }
}

/* ── الطباعة: ملفٌّ أنيق بهوية إذكاء */
@media print {
  @page { size: A4; margin: 16mm 14mm; }
  body { background: #fff; font-size: 11pt; }
  #app, .bar, .sheet, .scrim, #toast, #modal { display: none !important; }
  .print-only { display: block; }
}
.sheet:not(.on) { box-shadow: none; }
