/*
 * المحرّر وصفحات الحساب واللوحة: نفس هوية KONTAKTI (كحلي وأبيض، مسطّح، زوايا 8–12px).
 * Layout: شريط كحلي فوق فيه العنوان ← محرر بخطوات مرقمة على جهة، ومعاينة موبايل ثابتة على الجهة التانية.
 */
:root {
  --cobalt: #001f3f;
  --cobalt-deep: #1e3a5f;
  --cobalt-tint: #8a98a8;
  --field: #eef0e3;
  --tint: #e4e8d8;
}

body {
  background: var(--bg);
  color: var(--ink);
}

h1,
h2 {
  font-family: var(--display);
}

:focus-visible {
  outline: 2px solid var(--navy-2);
  outline-offset: 2px;
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--line);
}

.btn-ghost:hover {
  border-color: var(--cobalt-tint);
  background: var(--surface);
}

/* ---------- الشريط العلوي ---------- */
/* الشريط الكحلي فوق (المحرّر، حسابي، الإدارة): نفس تدرّج الهوية بس خفيف وأفقي:
   كحلي بيسيطر، وبطرفه البعيد تركوازي (الليموني بيوقف قبل ما يوصل، لحتى الأزرار البيضا تضل واضحة).
   أفقي عن قصد: الشريط الثابت والجزء اللي تحته بياخدوا نفس التدرّج فما بيبيّن خط بيناتهن */
.d-top,
.d-top.is-fixed .d-top-inner {
  --top-angle: 270deg;
  background-color: var(--navy);
  background-image: linear-gradient(var(--top-angle), var(--navy) 0%, var(--navy) 55%, #073f56 80%, #0e6f74 100%);
}

[dir="ltr"] .d-top,
[dir="ltr"] .d-top.is-fixed .d-top-inner {
  --top-angle: 90deg;
}

@supports (background: linear-gradient(in oklch, red, blue)) {
  .d-top,
  .d-top.is-fixed .d-top-inner {
    background-image: linear-gradient(var(--top-angle) in oklch, var(--navy) 0%, var(--navy) 55%, var(--lime) 150%);
  }
}

.d-top {
  position: relative;
  overflow: hidden;
  color: #f6f7ed;
  padding-top: env(safe-area-inset-top, 0px);
}

.d-top-inner,
.d-intro {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding-inline: max(20px, env(safe-area-inset-left, 0px));
}

.d-top-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 68px;
}

.d-top .kt-logo {
  color: #f6f7ed;
  font-size: 1rem;
}

.d-top-actions {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

.d-saved {
  font-size: 0.85rem;
  color: rgba(246, 247, 237, 0.78);
}

.d-saved.is-error {
  color: #ffd2d2;
}

.d-saved.is-pending {
  color: #f6f7ed;
}

/* حساب الزبون: رابط «حسابي» وزر «انشر» فوق */
.d-acct-link {
  background: rgba(246, 247, 237, 0.16);
  color: #f6f7ed;
}

/* زر الحفظ: أول شي جنب اللوغو (قبل اللغة والحساب). نفس شكل زر الحساب (دائرة شفافة):
   أيقونة الحفظ لما في شي ما انحفظ، و✓ لما كلشي محفوظ */
.d-publish-top {
  order: -1;
  background: rgba(246, 247, 237, 0.16);
  color: #f6f7ed;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.12s ease;
}

.d-publish-top:active {
  transform: scale(0.95);
}

.d-publish-top.is-pending:hover {
  background: rgba(246, 247, 237, 0.24);
}

.d-publish-top.is-saved {
  cursor: default;
}

.d-publish-top.is-saved:active {
  transform: none;
}

/* حالة الحفظ صارت بالزر نفسه: النص القديم بيطلع بس إذا صار خطأ */
.d-saved:not(.is-error) {
  display: none;
}

/* ---------- الشريط الكحلي فوق ثابت دايماً (المحرّر وصفحة الحساب) ---------- */
.d-top.is-fixed {
  padding-top: calc(68px + env(safe-area-inset-top, 0px));
}

.d-top.is-fixed .d-top-inner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 25; /* تحت المعاينة الكاملة (30) ونوافذ الصور */
  max-width: none;
  height: calc(68px + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  padding-inline: max(20px, env(safe-area-inset-left, 0px), calc((100vw - 1200px) / 2 + 20px));
  transition: box-shadow 0.2s ease;
}

/* لما ينزل عالمحتوى الفاتح: ظل خفيف تحت الشريط */
.is-scrolled .d-top.is-fixed .d-top-inner {
  box-shadow: 0 8px 20px -14px rgba(0, 31, 63, 0.7);
}

.d-saved.flash {
  animation: flash 0.6s ease;
}

@keyframes flash {
  from { opacity: 0.2; }
  to { opacity: 1; }
}

.d-open {
  background: #f6f7ed;
  color: var(--navy);
}

.d-intro {
  padding-top: 18px;
  padding-bottom: 76px;
}

.d-intro h1 {
  font-size: clamp(1.7rem, 3.6vw, 2.3rem);
  font-weight: 600;
  margin: 0 0 6px;
}

.d-intro p {
  margin: 0;
  color: rgba(246, 247, 237, 0.8);
}

/* ---------- التخطيط ---------- */
.d-layout {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 28px;
  max-width: 1200px;
  margin: -52px auto 0;
  padding: 0 max(20px, env(safe-area-inset-left, 0px)) 90px;
  align-items: start;
}

.d-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.d-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.88rem;
  box-shadow: var(--shadow);
}

.d-banner i {
  color: var(--navy);
}

.d-card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.d-card h2 {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 16px;
}

/* رقم الخطوة */
.d-step {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--navy);
  color: #f6f7ed;
  font-size: 0.95rem;
}

.d-step i {
  font-size: 0.85rem;
}

.tag {
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--brand-soft);
  color: var(--navy);
  padding: 0.25em 0.8em;
  border-radius: 999px;
}

.d-hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 8px 0 14px;
}

/* ---------- الحقول ---------- */
.field {
  display: grid;
  /* حقلين جنب بعض بطولين مختلفين (متل الصورة والشعار مع أشكاله): المحتوى بيبلّش من فوق، ما بيتوزّع عالطول */
  align-content: start;
  gap: 7px;
  margin-bottom: 14px;
}

.field label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-2);
}

input:not([type="color"]):not([type="file"]),
select,
textarea {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1.5px solid transparent;
  background: var(--field);
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--line);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--navy);
  background-color: #f6f7ed;
  box-shadow: 0 0 0 4px var(--brand-soft);
}

textarea {
  resize: vertical;
}

/* القوائم: نفس شكل الحقول (Safari كان يرسمها رمادية بتدرّج)، وسهم صغير بآخرها */
select {
  -webkit-appearance: none;
  appearance: none;
  min-height: 46px;
  padding-inline-end: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236a7090' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 16px;
  background-position: left 14px center;
  cursor: pointer;
}

[dir="ltr"] select {
  background-position: right 14px center;
}

input[type="color"] {
  width: 100%;
  height: 44px;
  padding: 4px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: #f6f7ed;
  cursor: pointer;
}

.row-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0 14px;
}

@media (max-width: 560px) {
  .row-2 {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- أزرار الاختيار ---------- */
.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--tint);
}

.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 600;
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--ink-2);
  white-space: nowrap;
}

.seg button.is-active {
  background: var(--navy);
  color: #f6f7ed;
  box-shadow: 0 6px 14px -8px var(--navy);
}

.seg-sm {
  margin-bottom: 10px;
  width: fit-content;
}

.seg-sm button {
  padding: 5px 12px;
  font-size: 0.85rem;
}

/* ---------- القوالب: صور حقيقية للقوالب ---------- */
/* القوالب: 4 بسطر إذا في مكان، وإلا 2 و2 (ما في 3+1 ولا أعمدة فاضية).
   minmax(0, …): صور القوالب ما بتقدر توسّع العمود لبرّا البطاقة (Safari كان يقصّ آخر قالب) */
.d-card:has(> .tpl-grid) {
  container-type: inline-size;
}

.tpl-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 4px 0 18px;
}

@container (min-width: 540px) {
  .tpl-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.d-for {
  font-weight: 500;
  font-size: 0.75rem;
  color: var(--muted);
}

.tpl {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding: 6px 6px 10px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: var(--tint);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.tpl:hover:not(:disabled) {
  transform: translateY(-2px);
}

.tpl.is-active {
  border-color: var(--navy);
  background: var(--brand-soft);
}

.tpl.is-active::after {
  content: "";
  position: absolute;
  top: 12px;
  inset-inline-start: 12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'%3E%3Cpath fill='%23f6f7ed' d='M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z'/%3E%3C/svg%3E") center / 11px no-repeat, var(--navy);
}

.tpl:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.tpl-thumb {
  display: block;
  aspect-ratio: 208 / 280;
  border-radius: 10px;
  overflow: hidden;
  background: #f6f7ed;
}

.tpl-thumb img {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.tpl-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
}

.tpl-name .fa-lock {
  font-size: 0.75rem;
  color: var(--muted);
}

/* ---------- الألوان ---------- */
.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sw {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid #f6f7ed;
  background: var(--c);
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
}

.sw.is-active {
  box-shadow: 0 0 0 2px var(--ink);
}

.sw-lg {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

/* ---------- الرفع ---------- */
.drop {
  margin-bottom: 14px;
}

.drop-inner {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 24px;
  border: 2px dashed var(--cobalt-tint);
  border-radius: 12px;
  background: var(--brand-soft);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease;
}

.drop-inner:hover {
  border-color: var(--navy);
}

.drop-inner i {
  font-size: 1.6rem;
  color: var(--navy);
}

.drop-inner span {
  color: var(--muted);
  font-size: 0.85rem;
}

.img-pick {
  display: flex;
  flex-wrap: wrap; /* الشاشات الضيقة (320) بالإنجليزي: الأزرار بتنزل سطر بدل ما تطلع برّا */
  align-items: center;
  gap: 10px;
}

.img-thumb {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--tint);
  color: var(--muted);
}

.img-thumb.is-logo {
  border-radius: 12px;
}

/* معاينة الشعار بالشكل المختار */
#thumb-logo[data-shape="circle"] {
  border-radius: 50%;
}

#thumb-logo[data-shape="square"] {
  border-radius: 14px;
}

#thumb-logo[data-shape="rect"] {
  width: 84px;
  height: 42px;
  border-radius: 8px;
}

/* اختيار شكل الشعار */
.logo-shape {
  justify-self: start;
  display: inline-flex;
  flex-wrap: wrap;
  max-width: 100%;
  gap: 4px;
  margin-top: 10px;
  padding: 3px;
  border-radius: 10px;
  background: var(--tint);
}

.logo-shape button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.logo-shape button[aria-checked="true"] {
  background: #f6f7ed;
  color: var(--navy);
  box-shadow: 0 1px 2px rgba(0, 31, 63, 0.12);
}

.ls {
  display: inline-block;
  border: 2px solid currentColor;
}

.ls-circle {
  width: 13px;
  height: 13px;
  border-radius: 50%;
}

.ls-square {
  width: 13px;
  height: 13px;
  border-radius: 3px;
}

.ls-rect {
  width: 18px;
  height: 10px;
  border-radius: 2px;
}

.img-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.img-thumb.is-logo img {
  object-fit: contain;
  padding: 4px;
}

.icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f6f7ed;
  color: var(--ink-2);
  cursor: pointer;
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.icon-btn.danger:hover,
.btn.danger:hover {
  color: #dc2626;
  border-color: #fecaca;
}

.btn.danger.is-armed {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

/* ---------- الروابط ---------- */
.links-list {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.link-row {
  display: grid;
  grid-template-columns: 42px 140px 1fr 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 12px;
  background: var(--field);
}

.link-row input,
.link-row select {
  background-color: #f6f7ed;
}

.link-ico {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--brand-color);
  color: #f6f7ed;
}

.link-actions {
  display: flex;
  gap: 4px;
}

@media (max-width: 760px) {
  .link-row {
    grid-template-columns: 42px 1fr;
  }
  .link-row input,
  .link-actions {
    grid-column: 1 / -1;
  }
  .link-actions {
    justify-content: flex-end;
  }
}

.d-empty {
  margin: 0;
  padding: 14px;
  text-align: center;
  color: var(--muted);
}

.add-row {
  display: flex;
  gap: 8px;
}

.add-row select {
  max-width: 220px;
}

/* ---------- الرابط والـ QR ---------- */
.slug-input {
  display: flex;
  align-items: center;
  border-radius: 10px;
  background: var(--field);
  overflow: hidden;
}

.slug-input span {
  padding: 0 4px 0 13px;
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.slug-input input {
  background: transparent !important;
  padding-inline-start: 2px !important;
}

.publish {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.qr {
  flex: none;
  padding: 10px;
  border-radius: 12px;
  background: #f6f7ed;
  border: 1px solid var(--line);
}

.qr img,
.qr canvas {
  display: block;
}

.publish-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.publish-actions .d-hint {
  width: 100%;
  margin-top: 0;
}

.publish-msg {
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--tint);
  font-size: 0.88rem;
  color: var(--ink-2);
  user-select: all;
  overflow-wrap: anywhere;
}

@media (max-width: 560px) {
  .publish {
    flex-direction: column;
    align-items: center;
  }
}

/* ---------- المعاينة ---------- */
.d-preview {
  position: sticky;
  top: 20px;
  padding-top: 64px;
}

.d-preview-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

body.show-preview .d-preview-label {
  color: #f6f7ed;
}

.d-preview-label .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #8a98a8;
  box-shadow: 0 0 0 4px rgba(125, 255, 181, 0.25);
}

/*
 * إطار موبايل بنسب iPhone الحقيقية (شاشة 390×844).
 * dashboard.js (fitPreview) بيحسب العرض ليناسب المكان المتاح، وبيحط --u = نسبة التصغير.
 */
.d-phone {
  --u: 0.82;
  --bezel: 9px;
  position: relative;
  width: 320px;
  height: calc(320px * 844 / 390);
  margin: 0 auto;
  padding: var(--bezel);
  border-radius: calc(55px * var(--u) + var(--bezel));
  background: #001f3f;
  box-shadow: inset 0 0 0 1.5px rgba(246, 247, 237, 0.12), 0 40px 70px -30px rgba(0, 31, 63, 0.55);
}

/* أزرار الجنب: الطاقة يمين، والصوت يسار */
.d-phone::before,
.d-phone::after {
  content: "";
  position: absolute;
  width: 3px;
  background: #001f3f;
}

.d-phone::before {
  right: -3px;
  top: 25%;
  height: 11%;
  border-radius: 0 2px 2px 0;
}

.d-phone::after {
  left: -3px;
  top: 20%;
  height: 7%;
  border-radius: 2px 0 0 2px;
  box-shadow: 0 calc(var(--u) * 80px) 0 #001f3f;
}

.d-screen {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: calc(55px * var(--u));
  overflow: hidden;
  background: #001f3f;
  transform: translateZ(0);
}

/* الصفحة بعرض موبايل حقيقي (390px) تحت شريط الحالة، وبتتصغّر مع الشاشة */
.d-screen iframe {
  position: absolute;
  top: calc(47px * var(--u));
  left: 0;
  width: 390px;
  height: 769px;
  border: 0;
  transform: scale(var(--u));
  transform-origin: top left;
  background: #f6f7ed;
}

.d-chrome {
  position: absolute;
  top: 0;
  left: 0;
  width: 390px;
  height: 844px;
  transform: scale(var(--u));
  transform-origin: top left;
  pointer-events: none;
}

/* شريط الحالة: لونه من أعلى الصفحة نفسها (dashboard.js)، متل Safari */
.d-status {
  --ink: #f6f7ed;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 47px;
  padding: 4px 30px 0 46px;
  background: var(--status-bg, #001f3f);
  color: var(--ink);
  font-family: -apple-system, "SF Pro Text", "Manrope", system-ui, sans-serif;
  transition: background-color 0.3s ease;
}

.d-status.is-light {
  --ink: #001f3f;
}

.d-time {
  width: 54px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.2px;
  text-align: center;
}

.d-island {
  position: absolute;
  top: 11px;
  left: 50%;
  width: 122px;
  height: 35px;
  margin-left: -61px;
  border-radius: 20px;
  background: #000;
}

.d-icons {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.d-icons svg {
  display: block;
  fill: currentColor;
}

/* شريط مؤشر الرجوع تحت (28px)، بلون أسفل الصفحة */
.d-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 28px;
  background: var(--bottom-bg, #001f3f);
  transition: background-color 0.3s ease;
}

.d-home {
  position: absolute;
  bottom: 9px;
  left: 50%;
  width: 136px;
  height: 5px;
  margin-left: -68px;
  border-radius: 3px;
  background: #f6f7ed;
}

.d-bottom.is-light .d-home {
  background: #001f3f;
}

/* زر «معاينة صفحتي» تحت: بس على الشاشات الضيقة (تحت) */
.preview-fab {
  display: none;
}

@media (max-width: 980px) {
  .d-layout {
    /* minmax(0,…): أعرض عنصر جوّا (متل أزرار شكل الشعار بالإنجليزي) ما بيوسّع الصفحة لبرّا الشاشة */
    grid-template-columns: minmax(0, 1fr);
  }
  .d-preview {
    display: none;
  }
  /* معاينة ملء الشاشة: عمود مرن، والموبايل بياخد كل الطول الباقي */
  body.show-preview .d-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: fixed;
    inset: 0;
    z-index: 30;
    padding: calc(68px + env(safe-area-inset-top, 0px)) 16px calc(84px + env(safe-area-inset-bottom, 0px));
    background: var(--navy);
  }
  /* بالمعاينة: فوق عاليسار «معاينة كاملة» بس، بلا زر الحفظ والحساب واللغة */
  body.show-preview .d-top-actions {
    visibility: hidden;
  }
  /* كبسة برّا الموبايل بترجّع للتعديل */
  body.show-preview .d-preview {
    cursor: zoom-out;
  }
  body.show-preview .d-phone {
    cursor: auto;
  }
  /* الموبايل بيكفي لحاله؛ منوفّر المكان ليطلع أكبر */
  body.show-preview .d-preview-label {
    display: none;
  }
  /* الصفحة ورا المعاينة ما بتتحرّك (Safari على iOS ما بيكفيه overflow: hidden، فمنثبّت body ومنرجّع مكان التمرير عند الإغلاق) */
  body.show-preview {
    position: fixed;
    left: 0;
    right: 0;
    overflow: hidden;
    overscroll-behavior: none;
  }
  .preview-fab {
    position: fixed;
    /* --vv-gap: كم مغطّى من تحت بشريط Safari (assets/js/vv-fix.js) */
    bottom: calc(20px + var(--sab-eff, 0px) + var(--vv-gap, 0px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 40;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 13px 24px;
    border: 0;
    border-radius: 999px;
    background: var(--navy);
    color: #f6f7ed;
    font: inherit;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 14px 30px -10px rgba(25, 51, 214, 0.7);
    cursor: pointer;
    transition: opacity 0.2s ease, bottom 0.18s ease;
  }
  /* عم يكتب والكيبورد طالع: الزر بيختفي لحتى ما يغطّي الحقل */
  .kt-typing body:not(.show-preview) .preview-fab,
  body.at-order:not(.show-preview) .preview-fab {
    opacity: 0;
    pointer-events: none;
  }
  body.show-preview .d-phone {
    flex: none;
  }
}

@media (max-width: 560px) {
  .d-intro {
    padding-bottom: 70px;
  }
}

/* قالب مقفل بقائمة القوالب */
.tpl.is-locked {
  cursor: not-allowed;
  opacity: 1;
}

.tpl.is-locked .tpl-thumb img {
  filter: blur(9px) saturate(1.15);
  transform: scale(1.15);
}

.tpl.is-locked:hover {
  transform: none;
}

.tpl-thumb {
  position: relative;
}

.tpl-lock {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(0, 31, 63, 0.42);
  color: #f6f7ed;
  font-size: 0.78rem;
  font-weight: 600;
}

.tpl-lock-ico {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(246, 247, 237, 0.2);
  border: 1px solid rgba(246, 247, 237, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-size: 1.05rem;
}



/* ---------- محرّر القص ---------- */
button.img-thumb {
  padding: 0;
  border: 0;
  cursor: pointer;
}

body.crop-open {
  overflow: hidden;
}

.crop-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px));
  background: rgba(0, 31, 63, 0.72);
}

.crop-dialog {
  width: min(380px, 100%);
  padding: 20px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.5);
}

.crop-dialog h3 {
  margin: 0 0 4px;
  font-family: var(--display);
  font-size: 1.2rem;
}

.crop-hint {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.88rem;
}

.crop-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 12px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  /* مربعات رمادية لتبيّن الشفافية بالشعار */
  background:
    conic-gradient(#e4e8d8 25%, #eef0e3 0 50%, #e4e8d8 0 75%, #eef0e3 0) 0 0 / 22px 22px;
}

.crop-stage:active {
  cursor: grabbing;
}

.crop-img {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none;
  transform-origin: 0 0;
  pointer-events: none;
}

/* الإطار: دائرة للصورة الشخصية (والبرا معتّم)، ومربع للشعار */
.crop-frame {
  position: absolute;
  inset: 0;
  border: 2px solid #f6f7ed;
  pointer-events: none;
}

.crop-modal[data-shape="circle"] .crop-frame {
  border-radius: 50%;
  box-shadow: 0 0 0 999px rgba(0, 31, 63, 0.5);
}

.crop-modal[data-shape="square"] .crop-frame,
.crop-modal[data-shape="rect"] .crop-frame {
  border-radius: 12px;
  border: 2px dashed var(--cobalt-tint);
}

/* المستطيل: نص الارتفاع بالنص، والبرا معتّم */
.crop-modal[data-shape="rect"] .crop-frame {
  inset: 25% 0;
  border-radius: 10px;
  box-shadow: 0 0 0 999px rgba(0, 31, 63, 0.35);
}

.crop-zoom {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
}

.crop-zoom input {
  flex: 1;
  accent-color: var(--navy);
}

.crop-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.crop-spacer {
  flex: 1;
}

/* ---------- زر «شاهد صفحتك» فوق ---------- */
.d-open {
  gap: 8px;
  padding: 0.6em 1.1em;
  font-weight: 700;
  box-shadow: 0 8px 20px -10px rgba(0, 0, 0, 0.45);
}

/* ---------- الحفظ والنشر ---------- */
.btn-wa .fa-whatsapp {
  font-size: 1.25em;
}

.d-order {
  border: 1px solid var(--navy);
}

.order-error {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #fef2f2;
  color: #b91c1c;
  font-weight: 600;
  font-size: 0.92rem;
}

.order-done {
  display: grid;
  justify-items: center;
  gap: 6px;
  margin-top: 16px;
  padding: 22px 18px;
  border-radius: 12px;
  background: #ecfdf3;
  text-align: center;
}

.order-done-ico {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #1fa855;
  color: #f6f7ed;
  font-size: 1.4rem;
}

.order-done strong {
  font-family: var(--display);
  font-size: 1.2rem;
}

.order-done p {
  margin: 0 0 8px;
  color: var(--muted);
}

/* ---------- زر «افتح صفحتك» فوق: نص واضح + سهم صفحة جديدة ---------- */
.d-top .d-open {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
  padding-inline-start: 16px;
  border-radius: 12px;
  background: #f6f7ed;
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s ease;
}

.d-top .d-open:active {
  transform: scale(0.97);
}

.d-open-text {
  display: grid;
  line-height: 1.2;
}

.d-open-text b {
  font-size: 0.95rem;
}

.d-open-text small {
  color: var(--muted);
  font-size: 0.72rem;
}

.d-open-ico {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--navy);
  color: #f6f7ed;
  font-size: 0.85rem;
}

/* شارة «الحساب مفعّل»: دائرة خضرا صغيرة فيها ✓، تحت يمين زر الحساب وفوقه شوي.
   الحلقة بلون الهيدر بتفصلها عن الأيقونة متل شارات التطبيقات */
.d-acct-wrap {
  position: relative;
  display: inline-flex;
}

.d-acct-badge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: var(--badge, 15px);
  height: var(--badge, 15px);
  border-radius: 50%;
  background: #22c55e url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5.5 12.5l4 4L18.5 7.5'/%3E%3C/svg%3E") center / 66% no-repeat;
  box-shadow: 0 0 0 2px var(--navy);
  pointer-events: none;
}

.d-acct-badge[hidden] {
  display: none;
}

@media (max-width: 560px) {
  .d-saved-text,
  .d-acct-text {
    display: none;
  }
  /* بالموبايل: «حسابي» أيقونة بس، وزر النشر تحت بالخطوة 6 (ما في مكان جنب «صفحتي الآن») */
  .d-acct-link {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
  }
  /* زر الحفظ أيقونة بس، دائرة بنفس قياس الحساب */
  .d-publish-top {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
  }
  .d-save-text {
    display: none;
  }
}

/* ---------- زر «معاينة صفحتي»: ثابت فوق عاليسار وبيضل ظاهر مع التمرير ---------- */
.preview-btn {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top, 0px));
  /* محاذي لطرف المحتوى (1200px) على الشاشات العريضة */
  inset-inline-end: max(calc(16px + env(safe-area-inset-left, 0px)), calc((100vw - 1200px) / 2 + 20px));
  z-index: 45;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  background: #f6f7ed;
  color: var(--navy);
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 0 0 1px rgba(25, 51, 214, 0.12), 0 12px 28px -10px rgba(0, 31, 63, 0.45);
  transition: transform 0.15s ease;
}

.preview-btn:active {
  transform: scale(0.97);
}

/* نقطة «مباشر» خضرا */
.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.2);
  animation: live 1.8s ease-in-out infinite;
}

@keyframes live {
  50% { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0.08); }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot {
    animation: none;
  }
}

/* «معاينة كاملة»: ما بتطلع وهو عم يعدّل. على الموبايل بتطلع فوق بس لما يفتح «معاينة صفحتي»،
   وعلى الكمبيوتر رابط صغير تحت الموبايل الجانبي */
.preview-btn-ico {
  display: none;
}

.preview-btn {
  display: none;
}

body.show-preview .preview-btn {
  display: inline-flex;
}

.d-preview-full {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: max-content;
  margin: 14px auto 0;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--navy);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.d-preview-full:hover {
  background: var(--brand-soft);
}

/* بمعاينة الموبايل (فوق كل شي) الزر الثابت فوق بيكفي */
body.show-preview .d-preview-full {
  display: none;
}

/* ---------- طلب الصفحة (حساب لسا ما تفعّل) ---------- */
.d-request {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.d-request h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 1.05rem;
}

.d-request .d-hint {
  margin: 0;
}

.d-plans {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.d-plan {
  display: grid;
  gap: 2px;
  justify-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f6f7ed;
  font: inherit;
  color: inherit;
  text-align: start;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.d-plan:hover {
  border-color: var(--slate);
}

.d-plan.is-active {
  border-color: var(--navy);
  box-shadow: inset 0 0 0 1px var(--navy);
}

.d-plan b {
  font-size: 0.92rem;
}

.d-plan-price {
  font-family: "Manrope", var(--font);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--navy);
}

.d-plan small {
  font-size: 0.75rem;
  color: var(--muted);
}

.d-request-done {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 18px;
  border-radius: 12px;
  background: #ecfdf3;
  text-align: center;
}

.d-request-done p {
  margin: 0;
  color: var(--ink-2);
}

.d-request-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
}

@media (max-width: 560px) {
  .d-plans {
    grid-template-columns: 1fr;
  }

  .d-plan {
    grid-template-columns: 1fr auto;
    align-items: baseline;
  }

  .d-plan small {
    grid-column: 1 / -1;
  }
}

/* أزرار جوّا الشريط فوق (استعمل التصميم / تجاهله) */
.d-banner-btn {
  margin-inline-start: 6px;
  padding: 3px 10px;
  border: 0;
  border-radius: 6px;
  background: var(--navy);
  color: #f6f7ed;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.d-banner-btn.is-ghost {
  background: transparent;
  color: var(--navy);
  text-decoration: underline;
}

/* زر اللغة بالشريط الكحلي فوق */
.d-top-actions .kt-lang {
  color: #f6f7ed;
}

/* الشريط ثابت فوق: أي «انزل لهون» (الأخطاء، الخطوة 6) بيوقف تحته مش وراه */
html:has(.d-top.is-fixed) {
  scroll-padding-top: calc(84px + env(safe-area-inset-top, 0px));
}

/* ---------- هوية الزبون (للإدارة بس، بالمحرّر من «صمّم صفحته») ---------- */
.bk {
  margin-top: 18px;
  padding: 16px;
  border: 1.5px dashed color-mix(in srgb, var(--navy) 35%, #f6f7ed);
  border-radius: 14px;
  background: #eef0e3;
}

.bk[hidden] {
  display: none;
}

.bk-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.bk-head b {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.bk-tag {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--navy);
  color: #f6f7ed;
  font-size: 0.75rem;
  font-weight: 600;
}

.bk .d-hint {
  margin: 6px 0 12px;
}

.bk-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.bk-row label {
  min-width: 64px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-2);
}

.bk-row input[type="color"] {
  flex: none;
  width: 44px;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f6f7ed;
  cursor: pointer;
}

.bk .bk-hex {
  width: 110px;
  font-family: "Manrope", monospace;
  text-transform: uppercase;
}

.bk .bk-hex.is-bad {
  border-color: #b42318;
}

.bk-row select {
  flex: 1;
  min-width: 0;
}

.bk-from-logo {
  margin: 4px 0 12px;
}

.bk-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.bk-note:empty {
  display: none;
}

.bk-chips {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.bk-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  background: #f6f7ed;
  box-shadow: 0 0 0 1px var(--line);
}

.bk-chip-sw {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.bk-chip code {
  flex: 1;
  font-size: 0.85rem;
}

.bk-chip button {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f6f7ed;
  color: var(--navy);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.bk-chip button:hover {
  background: var(--navy);
  border-color: var(--navy);
  color: #f6f7ed;
}

/* =====================================================================
 * المحرّر على الموبايل (حتى 760px): الصفحة هي المحرّر.
 *   - صفحتك بالشاشة كلها (نفس معاينة الكمبيوتر بس بحجمها الحقيقي)، وتحتها شريط تبويبات
 *   - كل تبويب بيفتح لوحة من تحت (الفورم نفسه)، والصفحة فوقها بتتغيّر فوراً
 *   - زر «تعديل | معاينة» بالهيدر: المعاينة بتخفي اللوحة والتبويبات وبتبيّن الصفحة متل ما بيشوفها الزائر
 * فوق 760px (كمبيوتر وتابلت) ما بيتغيّر شي.
 * ===================================================================== */
.d-switch,
.d-sheet-head,
.d-tabbar,
.d-tip,
.d-vislang,
.d-stats {
  display: none;
}

.d-sheet-body {
  display: contents;
}

@media (max-width: 760px) {
  :root {
    --hd: calc(68px + env(safe-area-inset-top, 0px));
    --tb: calc(64px + var(--sab-eff, env(safe-area-inset-bottom, 0px)));
  }

  /* الصفحة ما بتتمرّر: التمرير جوّا اللوحة وجوّا المعاينة. للمحرّر بس (الحساب والإدارة body.admin بيتمرّروا عادي) */
  html:has(body:not(.admin)),
  body:not(.admin) {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  body:not(.admin) {
    position: fixed;
    inset: 0;
    width: 100%;
  }

  /* للمحرّر بس: صفحة الحساب والإدارة (body.admin) بتحتفظ بترحيبها واسم البراند بالشريط */
  body:not(.admin) .d-intro,
  .d-preview-label,
  .d-preview-full,
  .preview-btn,
  .preview-fab,
  .d-chrome {
    display: none !important;
  }

  /* ---------- الهيدر: شعار + زر تعديل/معاينة + الحساب والحفظ واللغة ---------- */
  body:not(.admin) .d-top.is-fixed .d-top-inner {
    gap: 8px;
    padding-inline: max(14px, env(safe-area-inset-left, 0px));
  }

  body:not(.admin) .d-top .kt-word {
    display: none;
  }

  .d-switch {
    display: inline-flex;
    margin-inline: auto;
    padding: 3px;
    gap: 2px;
    border-radius: 999px;
    background: rgba(246, 247, 237, 0.16);
  }

  .d-switch button {
    padding: 6px 16px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: rgba(246, 247, 237, 0.82);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
  }

  .d-switch button[aria-pressed="true"] {
    background: #f6f7ed;
    color: var(--navy);
  }

  /* ---------- الصفحة (المعاينة) بالشاشة كلها ---------- */
  .d-layout {
    display: block;
    padding: 0;
  }

  .d-preview {
    display: block !important;
    position: fixed;
    z-index: 1;
    top: var(--hd);
    left: 0;
    right: 0;
    /* الصفحة بتكمّل 28px تحت الشريط، فزوايا الشريط المدوّرة بتطلع على صفحتك مش على خلفية فاتحة (بتبيّن زاوية حادة بالقوالب الغامقة) */
    bottom: calc(var(--tb) + var(--vv-gap, 0px) - 28px);
    margin: 0;
    padding: 0;
    background: #f6f7ed;
  }

  body.is-previewing .d-preview {
    bottom: 0;
  }

  .d-phone {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    margin: 0;
    padding: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .d-phone::before,
  .d-phone::after {
    display: none;
  }

  .d-screen {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  /* حاويات المعاينة ما بتتمرّر أبداً (حتى برمجياً): سفاري كان يمرّر الحاوية لما التمرير جوّا الإطار بيتجاوز آخره، فبتطلع الصفحة معلّقة لفوق ونصها فاضي */
  body:not(.admin) .d-layout,
  body:not(.admin) .d-preview,
  body:not(.admin) .d-phone,
  body:not(.admin) .d-screen {
    overflow: clip;
  }

  .d-screen iframe {
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: none;
  }

  /* ---------- اللوحة: الفورم نفسه ---------- */
  .d-editor {
    position: fixed;
    z-index: 20;
    left: 0;
    right: 0;
    bottom: calc(var(--tb) + var(--vv-gap, 0px));
    height: var(--sheet-h, 46vh);
    max-height: calc(100dvh - var(--hd) - var(--tb) - 10px);
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    gap: 0;
    background: var(--off-white, #f6f7ed);
    border-radius: 28px 28px 0 0;
    box-shadow: 0 -14px 34px -14px rgba(0, 31, 63, 0.5);
    overflow: hidden;
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), height 0.22s ease, visibility 0s;
  }

  .d-editor.is-dragging {
    transition: none;
  }

  body:not([data-sheet="open"]) .d-editor,
  body.is-previewing .d-editor {
    transform: translateY(calc(100% + var(--tb) + 24px));
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s 0.28s;
  }

  .d-sheet-head {
    position: relative;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 20px 8px;
    touch-action: none;
    cursor: grab;
  }

  .d-grip {
    position: absolute;
    top: 8px;
    left: 50%;
    width: 42px;
    height: 5px;
    border-radius: 3px;
    background: var(--line);
    transform: translateX(-50%);
  }

  .d-sheet-head b {
    font-size: 1.2rem;
    font-weight: 600;
  }

  .d-sheet-x {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--off-white-2, #eef0e3);
    color: var(--ink-2, #33475f);
    cursor: pointer;
  }

  .d-sheet-body {
    display: block;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 0 20px calc(24px + var(--sab-eff, env(safe-area-inset-bottom, 0px)));
  }

  .d-sheet-body > .d-card {
    display: none;
    margin: 0 0 6px;
    padding: 4px 0 14px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  body[data-tab="style"] .d-sheet-body > [data-tab="style"],
  body[data-tab="info"] .d-sheet-body > [data-tab="info"],
  body[data-tab="links"] .d-sheet-body > [data-tab="links"],
  body[data-tab="stats"] .d-sheet-body > [data-tab="stats"],
  body[data-tab="publish"] .d-sheet-body > [data-tab="publish"] {
    display: block;
  }

  /* بالإحصاءات العنوان هو عنوان اللوحة نفسه */
  .d-stats > h2 {
    display: none;
  }

  .d-sheet-body > .d-card > h2 {
    font-size: 1.02rem;
  }

  /* القوالب: صف أفقي مدمج (بدل شبكة طويلة) لحتى ما تحتاج تسكرول كتير */
  .d-sheet-body .tpl-grid {
    display: flex;
    gap: 10px;
    margin: 2px -20px 14px;
    padding: 4px 20px 10px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scroll-padding-inline: 20px;
    scrollbar-width: none;
  }

  .d-sheet-body .tpl-grid::-webkit-scrollbar {
    display: none;
  }

  .d-sheet-body .tpl {
    flex: 0 0 96px;
    gap: 6px;
    padding: 4px 4px 8px;
    scroll-snap-align: start;
  }

  .d-sheet-body .tpl-name {
    font-size: 0.8rem;
  }

  .d-sheet-body .tpl.is-active::after {
    top: 9px;
    inset-inline-start: 9px;
    width: 20px;
    height: 20px;
  }

  /* أرقام الخطوات (1..6) ما إلها معنى بالتبويبات، وعنوان اللوحة بيكفي بتبويب الشكل والروابط */
  .d-sheet-body > .d-card .d-step {
    display: none;
  }

  body[data-tab="style"] .d-sheet-body > [data-tab="style"] > h2,
  body[data-tab="links"] .d-sheet-body > [data-tab="links"] > h2 {
    display: none;
  }

  /* ---------- شريط التبويبات تحت ---------- */
  .d-tabbar {
    display: flex;
    position: fixed;
    z-index: 21;
    left: 0;
    right: 0;
    bottom: var(--vv-gap, 0px);
    height: var(--tb);
    padding: 8px 6px var(--sab-eff, env(safe-area-inset-bottom, 0px));
    background: var(--off-white, #f6f7ed);
    border-radius: 26px 26px 0 0;
    box-shadow: 0 -12px 30px -14px rgba(0, 31, 63, 0.4);
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  body.is-previewing .d-tabbar {
    transform: translateY(130%);
  }

  .d-tabbar button {
    position: relative;
    flex: 1;
    display: grid;
    justify-items: center;
    align-content: start;
    gap: 3px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
  }

  .d-tabbar i {
    display: grid;
    place-items: center;
    width: 46px;
    height: 30px;
    border-radius: 15px;
    transition: background-color 0.15s ease;
  }

  .d-tabbar svg {
    width: 21px;
    height: 21px;
  }

  .d-tabbar button[aria-selected="true"] {
    color: var(--navy);
  }

  .d-tabbar button[aria-selected="true"] i {
    background: var(--lime);
  }

  .d-tab-dot {
    position: absolute;
    top: 2px;
    inset-inline-end: calc(50% - 26px);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--off-white, #f6f7ed);
    background: #e5484d;
  }

  /* الكيبورد طالع: الشريط بيختفي، واللوحة بتلزق فوق الكيبورد */
  html.kt-typing .d-tabbar {
    display: none;
  }

  html.kt-typing .d-editor {
    bottom: var(--kb, 0px);
    max-height: calc(var(--vvh, 100dvh) - var(--hd) - 8px);
  }

  /* ---------- تلميح أول مرة + لغة المعاينة ---------- */
  .d-tip {
    display: block;
    position: fixed;
    z-index: 22;
    left: 50%;
    bottom: calc(var(--tb) + 16px + var(--vv-gap, 0px));
    transform: translateX(-50%);
    margin: 0;
    padding: 9px 16px;
    border-radius: 14px;
    background: var(--navy);
    color: #f6f7ed;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 10px 24px -10px rgba(0, 31, 63, 0.7);
  }

  .d-tip[hidden] {
    display: none;
  }

  .d-tip::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -6px;
    margin-left: -6px;
    border: 6px solid transparent;
    border-bottom: 0;
    border-top-color: var(--navy);
  }

  body[data-sheet="open"] .d-tip,
  body.is-previewing .d-tip {
    display: none;
  }

  .d-vislang {
    position: fixed;
    z-index: 22;
    top: calc(var(--hd) + 10px);
    inset-inline-start: 14px;
    padding: 3px;
    border-radius: 999px;
    background: rgba(0, 31, 63, 0.78);
    backdrop-filter: blur(8px);
  }

  .d-vislang:not([hidden]) {
    display: flex;
  }

  body:not(.is-previewing) .d-vislang {
    display: none;
  }

  .d-vislang button {
    padding: 5px 12px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: rgba(246, 247, 237, 0.85);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
  }

  .d-vislang button[aria-pressed="true"] {
    background: var(--lime);
    color: var(--navy);
  }
}

/* تبويب الإحصاءات: بطاقة الترقية للباقة الأساسية */
.d-upsell {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 22px 16px;
  border: 1.5px solid var(--line);
  border-radius: 20px;
  background: var(--off-white, #f6f7ed);
  text-align: center;
}

.d-upsell-lock {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--lime);
}

.d-upsell-lock svg {
  width: 24px;
  height: 24px;
}

.d-upsell b {
  font-size: 1.1rem;
}

.d-upsell p {
  margin: 0 0 6px;
  color: var(--ink-2, #33475f);
  line-height: 1.7;
}


/* النسخة بلغة تانية (اختياري) تحت نصوص الصفحة */
.d-alt {
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.d-alt > summary {
  margin-bottom: 10px;
  font-weight: 700;
  cursor: pointer;
}

.d-alt[open] > summary {
  margin-bottom: 12px;
}

/* المحرّر: الشريط فوق بلون صفحة الزبون (--top-bg من dashboard.js)، مش التدرّج الكحلي الثابت اللي كان يتصارع مع ألوان القوالب */
body:not(.admin) .d-top,
body:not(.admin) .d-top.is-fixed .d-top-inner {
  background-color: var(--top-bg, var(--navy));
  background-image: none;
  transition: background-color 0.35s ease;
}
