/* Miral Invite — واجهة العميلة. تصميم هادئ بألوان الورد الغباري والأخضر المريمي، يبدأ من الجوال. */

:root {
  --bg: #FBF9FD;
  --surface: #FFFFFF;
  --surface-soft: #FDFCFE;
  --rose: #D5BFEA;
  --rose-deep: #6F547A;
  --rose-darker: #57405F;
  --rose-soft: #F3EEF8;
  --sage: #E8DB9B;
  --sage-deep: #6B5D1E;
  --sage-soft: #F7F1D8;
  --ink: #3A2F40;
  --muted: #776B7E;
  --line: #E9E1F0;
  --line-strong: #D9CCE5;
  --error: #A23D4A;
  --error-soft: #FBECEC;
  --error-line: #EDC7CB;
  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 24px;
  --shadow-sm: 0 1px 2px rgba(58, 47, 64, 0.05);
  --shadow: 0 1px 2px rgba(58, 47, 64, 0.04), 0 10px 30px -14px rgba(58, 47, 64, 0.18);
  --shadow-lg: 0 2px 6px rgba(58, 47, 64, 0.06), 0 24px 60px -24px rgba(58, 47, 64, 0.35);
  --focus: 0 0 0 3px rgba(111, 84, 122, 0.35);
  --font-ui: "MI Plex Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --font-phrase: "MI Amiri", "MI Plex Arabic", serif;
  --stage-h: 72dvh;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(60rem 30rem at 100% -10%, rgba(243, 238, 248, 0.75), transparent 60%),
    radial-gradient(50rem 26rem at -10% 0%, rgba(248, 242, 220, 0.8), transparent 60%),
    var(--bg);
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, video, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
p { margin: 0; }
h1, h2, h3 { margin: 0; line-height: 1.4; font-weight: 600; }

:focus-visible { outline: 3px solid rgba(111, 84, 122, 0.55); outline-offset: 2px; }

.container { width: 100%; max-width: 1180px; margin-inline: auto; padding-inline: 16px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.skip-link {
  position: absolute; inset-inline-start: 12px; top: -60px; z-index: 50;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm); text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* ───── الترويسة ───── */
.site-header { padding-block: 14px 6px; }
.header-inner { display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; border-radius: var(--radius-sm); }
.brand-mark { width: 44px; height: 44px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.wordmark {
  font-family: "MI Amiri", Georgia, "Times New Roman", serif;
  font-size: 1.6rem; font-weight: 400; letter-spacing: 0.04em; color: var(--ink);
}
.tagline { font-size: 0.85rem; color: var(--rose-deep); font-weight: 500; margin-top: 2px; }

/* ───── شريط الخطوات ───── */
.stepper-wrap { padding-block: 8px 14px; }
.stepper { list-style: none; margin: 0 auto; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.step { position: relative; display: flex; justify-content: center; }
.step:not(:first-child)::before {
  content: ""; position: absolute; top: 21px; inset-inline-start: -50%; width: 100%; height: 2px;
  background: var(--line); z-index: 0;
}
.step.is-done::before, .step.is-current::before { background: var(--rose); }
.step-btn {
  position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: 0; padding: 4px 2px; min-height: 44px; min-width: 44px; cursor: pointer; border-radius: var(--radius-sm);
}
.step-btn:disabled { cursor: default; }
.step-dot {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); border: 1.5px solid var(--line-strong); color: var(--muted);
  font-size: 0.85rem; font-weight: 600; transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}
.step-label { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.step.is-done .step-dot { background: var(--rose-soft); border-color: var(--rose); color: var(--rose-deep); }
.step.is-done .step-label { color: var(--ink); }
.step.is-current .step-dot { background: var(--rose-deep); border-color: var(--rose-deep); color: #fff; box-shadow: 0 0 0 4px rgba(111, 84, 122, 0.25); }
.step.is-current .step-label { color: var(--rose-deep); font-weight: 600; }
.step-btn:not(:disabled):hover .step-dot { border-color: var(--rose-deep); }

/* ───── مساحة العمل ───── */
main { outline: none; }
.workspace { display: flex; flex-direction: column; gap: 20px; padding-bottom: 24px; }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 22px 18px 24px; min-width: 0;
}
.stage { min-width: 0; }
.workspace[data-step="5"] .stage { order: -1; }

@media (max-width: 1023.98px) {
  .workspace[data-step="2"] .stage, .workspace[data-step="3"] .stage { display: none; }
  /* على الجوال أثناء كتابة العبارة: معاينة مدمجة ثابتة أعلى الشاشة حتى ترى العميلة التصميم وهي تكتب. */
  .workspace[data-step="4"] .stage {
    order: -1; position: sticky; top: 0; z-index: 20; --stage-h: 26dvh;
    background: var(--bg); padding: 8px 0 10px; box-shadow: 0 8px 12px -10px rgba(58, 47, 64, 0.25);
  }
  .workspace[data-step="4"] .stage .stage-head { flex-direction: row; align-items: baseline; gap: 8px; margin-bottom: 6px; }
  .workspace[data-step="4"] .stage .player-badge { bottom: 4px; inset-inline: 4px; font-size: 0.72rem; padding: 4px 6px; }
}

/* ───── رأس الخطوة ───── */
.step-head { margin-bottom: 18px; }
.step-kicker { font-size: 0.8rem; color: var(--rose-deep); font-weight: 600; letter-spacing: 0.02em; }
.step-title { font-size: 1.55rem; outline: none; margin-top: 2px; }
.step-lead { color: var(--muted); margin-top: 6px; max-width: 60ch; }
.section-title { font-size: 1.05rem; margin-bottom: 10px; }

/* ───── الأزرار ───── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 22px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 600; font-size: 1rem; line-height: 1.3; cursor: pointer; text-decoration: none; text-align: center;
  transition: background-color 0.18s, border-color 0.18s, color 0.18s, box-shadow 0.18s, transform 0.18s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { cursor: not-allowed; opacity: 0.5; }
.btn-primary { background: var(--rose-deep); color: #fff; box-shadow: 0 6px 16px -8px rgba(111, 84, 122, 0.8); }
.btn-primary:hover:not(:disabled) { background: var(--rose-darker); }
.btn-primary:disabled { box-shadow: none; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover:not(:disabled) { border-color: var(--rose); color: var(--rose-deep); }
.btn-ghost { background: transparent; color: var(--rose-deep); }
.btn-ghost:hover:not(:disabled) { background: var(--rose-soft); }
.btn-link { background: transparent; color: var(--rose-deep); min-height: 44px; padding: 6px 4px; border-radius: var(--radius-sm); }
.btn-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.btn-lg { min-height: 56px; font-size: 1.05rem; padding-inline: 28px; }
.btn-sm { min-height: 44px; padding: 6px 16px; font-size: 0.9rem; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 0; border-radius: 50%; background: var(--rose-soft); color: var(--rose-deep); cursor: pointer;
}
.icon-btn:hover { background: #E6DAF2; }
.link-btn { background: none; border: 0; color: var(--rose-deep); cursor: pointer; min-height: 44px; padding: 0 6px; font-size: 0.9rem; text-decoration: underline; text-underline-offset: 3px; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-top: 24px; }
.actions > .btn-primary { flex: 1 1 100%; }
@media (min-width: 600px) { .actions > .btn-primary { flex: 0 1 auto; } }

/* ───── صناديق التنبيه ───── */
.callout {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius);
  background: var(--rose-soft); color: var(--ink); margin-bottom: 18px;
}
.callout-icon { flex: none; color: var(--rose-deep); margin-top: 3px; }
.callout-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.callout-body > .btn { align-self: flex-start; margin-top: 8px; }
.callout-title { font-weight: 600; }
.callout-text { color: var(--ink); font-size: 0.95rem; }
.callout-success { background: var(--sage-soft); }
.callout-success .callout-icon { color: var(--sage-deep); }
.callout-error { background: var(--error-soft); border: 1px solid var(--error-line); }
.callout-error .callout-icon, .callout-error .callout-title { color: var(--error); }

.notice-area:empty { display: none; }
.notice-area { margin-bottom: 14px; }
.notice {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px 10px 8px; border-radius: var(--radius);
  background: var(--rose-soft); border: 1px solid #E3D6EF; box-shadow: var(--shadow-sm);
}
.notice > .icon { flex: none; color: var(--rose-deep); }
.notice-text { flex: 1 1 200px; font-weight: 500; }
.notice-error { background: var(--error-soft); border-color: var(--error-line); }
.notice-error > .icon { color: var(--error); }
.notice-close { background: transparent; }

/* ───── النماذج ───── */
.form { display: block; }
.fields { display: flex; flex-direction: column; gap: 22px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-weight: 600; font-size: 1rem; }
.optional { color: var(--muted); font-weight: 400; font-size: 0.9rem; }
.field-hint { color: var(--muted); font-size: 0.9rem; }
.field-sublabel { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }
.field-error { color: var(--error); font-size: 0.9rem; font-weight: 500; }
.field-foot { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; min-height: 1.5em; }
.field-foot > :first-child { flex: 1 1 auto; }
.counter { flex: none; margin-inline-start: auto; font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.counter.is-over { color: var(--error); font-weight: 600; }
.input {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface-soft); transition: border-color 0.15s, box-shadow 0.15s;
}
.input:hover { border-color: #C9B8D8; }
.input:focus { outline: none; border-color: var(--rose); box-shadow: var(--focus); background: #fff; }
.input[aria-invalid="true"], .input.is-invalid { border-color: #D99AA2; background: #FFF9F9; }
textarea.input { resize: vertical; line-height: 1.7; }
select.input { appearance: auto; }
.occasion-pill { display: inline-flex; gap: 4px; align-items: center; background: var(--sage-soft); padding: 6px 14px; border-radius: 999px; margin-bottom: 20px; font-size: 0.95rem; }
.form-summary:empty { display: none; }
.form-summary { margin-top: 18px; }
.form-summary .callout { margin-bottom: 0; }

/* أزرار الاختيار (مقسّمة) */
.segmented { display: flex; flex-wrap: wrap; gap: 8px; }
.seg-option { position: relative; display: inline-flex; }
.seg-input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg-label {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 8px 20px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); font-weight: 500;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s; pointer-events: none;
}
.seg-option:hover .seg-label { border-color: var(--rose); }
.seg-input:checked + .seg-label { background: var(--rose-soft); border-color: var(--rose-deep); color: var(--rose-deep); font-weight: 600; }
.seg-input:focus-visible + .seg-label { box-shadow: var(--focus); border-color: var(--rose-deep); }
.segmented[aria-invalid="true"] .seg-label { border-color: #D99AA2; }
.segmented-sm .seg-label { min-height: 44px; padding: 6px 16px; font-size: 0.95rem; }

.date-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.input-date { width: auto; min-width: 200px; flex: 0 1 260px; }
.date-extra { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; padding: 12px 14px; border-radius: var(--radius); background: var(--bg); border: 1px dashed var(--line-strong); }
.date-shown { font-size: 0.95rem; min-height: 1.6em; }
.date-shown strong { font-size: 1.05rem; color: var(--ink); }

/* ───── الخطوة ١: القوالب ───── */
.tpl-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (min-width: 700px) { .tpl-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 20px; } }
.tpl-card {
  display: flex; flex-direction: column; width: 100%; height: 100%; padding: 0; text-align: start; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-sm); transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.tpl-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.tpl-card.is-selected { border-color: var(--rose); box-shadow: 0 0 0 2px var(--rose-soft), var(--shadow); }
.tpl-thumb { position: relative; display: block; background: #EEE8F4; }
.tpl-thumb img { width: 100%; height: auto; object-fit: cover; }
.tpl-thumb .badge, .tpl-thumb .badges { position: absolute; top: 8px; inset-inline-start: 8px; }
.badges { display: inline-flex; flex-wrap: wrap; align-items: flex-start; gap: 4px; }
.tpl-thumb .badges { flex-direction: column; }
.tpl-thumb .badges .badge { position: static; }
.badge { white-space: nowrap; }
.tpl-chosen {
  position: absolute; bottom: 8px; inset-inline-start: 8px; display: inline-flex; align-items: center; gap: 4px;
  background: var(--rose-deep); color: #fff; font-size: 0.8rem; font-weight: 600; padding: 3px 10px 3px 12px; border-radius: 999px;
}
.tpl-info { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px 14px; flex: 1; }
.tpl-name { font-weight: 600; font-size: 1.05rem; }
.tpl-desc { color: var(--muted); font-size: 0.85rem; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tpl-cta { margin-top: auto; padding-top: 6px; color: var(--rose-deep); font-size: 0.9rem; font-weight: 600; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600; background: rgba(255, 255, 255, 0.92); color: var(--ink);
  box-shadow: 0 1px 3px rgba(58, 47, 64, 0.12);
}
.badge .icon { color: var(--rose-deep); }
.badge-sep { width: 4px; height: 4px; border-radius: 50%; background: var(--rose); margin-inline: 2px; }

/* نافذة معاينة القالب */
.tpl-dialog {
  border: 0; padding: 0; background: var(--surface); color: var(--ink);
  width: 100%; max-width: 100%; max-height: 94dvh; margin: auto auto 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: var(--shadow-lg); overflow: auto;
}
.tpl-dialog::backdrop { background: rgba(58, 47, 64, 0.5); }
.dlg-inner { position: relative; display: flex; flex-direction: column; gap: 16px; padding: 16px 16px 20px; }
.dlg-close { position: absolute; top: 12px; inset-inline-end: 12px; z-index: 2; background: rgba(255, 255, 255, 0.92); box-shadow: var(--shadow-sm); }
.dlg-media {
  position: relative; width: min(100%, calc(58dvh * var(--ar, 0.5625))); margin-inline: auto;
  border-radius: var(--radius); overflow: hidden; background: #EEE8F4; box-shadow: var(--shadow);
}
.dlg-media video, .dlg-media img { width: 100%; height: 100%; object-fit: cover; }
.dlg-body { display: flex; flex-direction: column; gap: 8px; }
.dlg-title { font-size: 1.35rem; }
.dlg-meta { display: flex; gap: 8px; }
.dlg-meta .badge { background: var(--rose-soft); box-shadow: none; }
.dlg-desc { color: var(--muted); }
.dlg-occasions { font-size: 0.9rem; color: var(--sage-deep); font-weight: 500; }
.dlg-actions { margin-top: 12px; }
.variant-switch { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; margin: 0 0 16px; padding: 10px 14px;
  border: 1px dashed var(--line-strong); border-radius: 12px; background: var(--surface-soft); color: var(--ink); font-size: 0.95rem; }
.variant-switch .btn { margin-inline-start: auto; }
/* فيديو أو صورة ثابتة */
.variant-pick { border: 0; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; }
.variant-pick[hidden] { display: none; }
.variant-pick legend { font-weight: 600; font-size: 0.95rem; margin-bottom: 6px; padding: 0; }
.variant-opt { position: relative; display: grid; grid-template-columns: auto 1fr; column-gap: 10px; row-gap: 2px; align-items: center;
  padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); cursor: pointer; }
.variant-opt:hover { border-color: var(--rose); }
.variant-opt:has(.variant-input:checked) { border-color: var(--rose-deep); background: var(--rose-soft); box-shadow: 0 0 0 3px rgba(111, 84, 122, 0.15); }
.variant-input { accent-color: var(--rose-deep); width: 18px; height: 18px; margin: 0; }
.variant-label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.variant-desc { grid-column: 2; font-size: 0.85rem; color: var(--muted); }
.variant-price { margin-inline-start: auto; padding-inline-start: 10px; font-weight: 700; color: var(--rose-darker); white-space: nowrap; }
.variant-label { width: 100%; }
.dlg-price { font-weight: 700; color: var(--rose-darker); margin: 4px 0 0; }
.dlg-price[hidden] { display: none; }
/* بيانات الدفع */
.checkout { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; padding: 18px; }
.checkout[hidden] { display: none; }
.checkout .field { display: flex; flex-direction: column; gap: 6px; }
.checkout .field-error[hidden] { display: none; }
.checkout .input[type="tel"], .checkout .input[type="email"] { text-align: right; }
@media (min-width: 768px) {
  .tpl-dialog { width: min(880px, calc(100vw - 48px)); margin: auto; border-radius: var(--radius-lg); max-height: calc(100dvh - 48px); }
  .dlg-inner { flex-direction: row; align-items: center; gap: 28px; padding: 24px; }
  .dlg-media { flex: none; width: calc(min(78dvh, 720px) * var(--ar, 0.5625)); margin: 0; }
  .dlg-body { flex: 1; min-width: 0; padding-inline-end: 24px; }
}

/* ───── الخطوة ٣: الأسلوب ───── */
.style-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 600px) { .style-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.style-card {
  position: relative; display: flex; gap: 12px; align-items: flex-start; padding: 16px; min-height: 88px;
  border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}
.style-card:hover:not(.is-disabled) { border-color: var(--rose); }
.style-input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.style-card:has(.style-input:checked) { border-color: var(--rose-deep); background: #F8F4FC; box-shadow: 0 0 0 3px rgba(111, 84, 122, 0.2); }
.style-card:has(.style-input:focus-visible) { box-shadow: var(--focus); }
.style-card.is-disabled { cursor: not-allowed; background: #F8F6FA; }
.style-card.is-disabled .style-input { cursor: not-allowed; }
.style-card.is-disabled .style-name, .style-card.is-disabled .style-desc, .style-card.is-disabled .style-icon { opacity: 0.55; }
.style-icon { flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--rose-soft); color: var(--rose-deep); }
.style-card:has(.style-input:checked) .style-icon { background: var(--rose-deep); color: #fff; }
.style-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.style-name { font-weight: 600; font-size: 1.05rem; }
.style-desc { color: var(--muted); font-size: 0.9rem; }
.style-tag { align-self: flex-start; margin-top: 6px; font-size: 0.75rem; font-weight: 600; color: var(--muted); background: #F0EBF5; padding: 2px 10px; border-radius: 999px; }

/* ───── الخطوة ٤: الاقتراحات والمحرّر ───── */
.status-line { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.95rem; margin-bottom: 14px; }
.status-line.is-ok { color: var(--sage-deep); font-weight: 500; }
.sug-grid { display: grid; gap: 14px; }
.sug-card {
  display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface-soft); box-shadow: var(--shadow-sm);
}
.sug-title { font-size: 0.85rem; color: var(--rose-deep); }
.sug-field { display: flex; flex-direction: column; gap: 2px; padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
.sug-label { font-size: 0.78rem; color: var(--muted); font-weight: 500; }
.sug-text { font-family: var(--font-phrase); font-size: 1.2rem; line-height: 1.9; white-space: pre-line; overflow-wrap: anywhere; }
.sug-text.is-empty { font-family: var(--font-ui); font-size: 0.9rem; color: var(--muted); }
.sug-note { color: var(--rose-deep); font-size: 0.85rem; display: inline-flex; gap: 6px; align-items: center; }
.sug-note-all { background: var(--rose-soft); padding: 6px 10px; border-radius: var(--radius-sm); }
.sug-choose { align-self: flex-start; }
.sug-card.is-loading { gap: 12px; }
.skel {
  display: block; height: 14px; border-radius: 8px;
  background: linear-gradient(90deg, #F1ECF6 0%, #FBF9FD 50%, #F1ECF6 100%); background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skel-title { width: 30%; height: 12px; }
.skel-short { width: 60%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.editor-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin: -6px 0 8px; }
.editor-top:empty { display: none; }
.editor-fields { display: flex; flex-direction: column; gap: 16px; }
.fe { padding: 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-soft); }
.fe:focus-within { border-color: var(--line-strong); box-shadow: var(--shadow-sm); background: #fff; }
.fe-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; }
.fe-time { display: inline-flex; align-items: center; gap: 5px; font-size: 0.8rem; color: var(--muted); }
.input-phrase { font-family: var(--font-phrase); font-size: 1.2rem; line-height: 1.9; padding-block: 8px; min-height: 0; }
.fit-status { display: flex; align-items: center; gap: 6px; font-size: 0.9rem; min-height: 1.6em; color: var(--muted); }
.fit-status .icon { flex: none; }
.fit-status.is-ok { color: var(--sage-deep); font-weight: 500; }
.fit-status.is-error { color: var(--error); font-weight: 500; }
.fit-status.is-pending, .fit-status.is-muted { color: var(--muted); }
.data-note { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--sage-deep); margin-top: 2px; }
.data-errors:empty { display: none; }
.sync-line { display: flex; align-items: center; gap: 8px; margin-top: 16px; font-size: 0.92rem; color: var(--muted); min-height: 1.6em; }
.sync-line.is-ok { color: var(--sage-deep); font-weight: 500; }
.sync-line .callout { margin-bottom: 0; width: 100%; }

.chips { margin-top: 6px; }

/* صورة بدل النص (اسم بخط العميلة) */
.seg { display: inline-flex; align-self: flex-start; width: fit-content; gap: 0; border: 1px solid var(--line-strong); border-radius: 999px; padding: 3px; margin: 2px 0 8px; background: #fff; }
.seg-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 0.9rem; color: var(--muted); cursor: pointer; }
.seg-btn[aria-pressed="true"] { background: var(--rose-soft); color: var(--rose-darker); font-weight: 600; }
.seg-btn:focus-visible { outline: 2px solid var(--rose-deep); outline-offset: 1px; }
.img-panel { display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px dashed var(--line-strong); border-radius: 12px; background: #FDFBFE; }
.img-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.img-note { margin: 0; flex: 1 1 200px; }
.img-file:focus-visible + .img-pick, .img-pick:focus-within { outline: 2px solid var(--rose-deep); outline-offset: 2px; }
.img-pick.is-busy { opacity: 0.6; pointer-events: none; }
.img-status { margin: 0; font-size: 0.9rem; color: var(--muted); min-height: 0; }
.img-status:empty { display: none; }
.img-status.is-error { color: var(--error); font-weight: 500; }
.img-status.is-warn { color: #8A6418; }
/* خلفية مربعات توضح الشفافية بعد إزالة الورق */
.img-thumb { align-self: center; max-width: 100%; padding: 10px; border-radius: 10px; border: 1px solid var(--line);
  background: repeating-conic-gradient(#EEE8F4 0% 25%, #FFFFFF 0% 50%) 50% / 18px 18px; }
.img-thumb img { display: block; max-width: 100%; max-height: 160px; margin-inline: auto; }
.img-modes { display: grid; gap: 6px; }
.img-mode { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: #fff; }
.img-mode:has(input:checked) { border-color: var(--rose); background: var(--rose-soft); }
.img-mode-label { font-weight: 600; font-size: 0.92rem; }
.img-mode-desc { grid-column: 2; font-size: 0.82rem; color: var(--muted); }
.chips summary { display: inline-flex; align-items: center; min-height: 40px; color: var(--rose-deep); font-size: 0.9rem; font-weight: 500; cursor: pointer; list-style: none; }
.chips summary::-webkit-details-marker { display: none; }
.chips summary::before { content: "+"; display: inline-grid; place-items: center; width: 20px; height: 20px; margin-inline-end: 6px; border-radius: 50%; background: var(--rose-soft); font-weight: 600; line-height: 1; }
.chips[open] summary::before { content: "−"; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.chip {
  display: inline-flex; flex-direction: column; align-items: flex-start; gap: 0; max-width: 100%; min-height: 44px; padding: 5px 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: #fff; cursor: pointer; text-align: start;
}
.chip:hover { border-color: var(--rose); }
.chip-label { font-size: 0.72rem; color: var(--muted); }
.chip-value { font-size: 0.92rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ───── لوحة المعاينة والمشغّل ───── */
.stage-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.stage-title { font-size: 1rem; }
.stage-caption { font-size: 0.85rem; color: var(--muted); }
.stage-caption:empty { display: none; }
.player { display: flex; flex-direction: column; gap: 10px; }
.player-frame {
  position: relative; width: 100%; max-width: calc(var(--stage-h) * var(--ar, 0.5625)); margin-inline: auto;
  border-radius: var(--radius); overflow: hidden; background: #EEE8F4; box-shadow: var(--shadow-lg);
  isolation: isolate; user-select: none; -webkit-user-select: none;
}
.player-media, .player-layers { position: absolute; inset: 0; }
.player-video, .player-image { width: 100%; height: 100%; object-fit: contain; background: #EEE8F4; cursor: pointer; }
.player-image { cursor: default; }
.player-layers { pointer-events: none; }
.player-layer { position: absolute; max-width: none; opacity: 0; visibility: hidden; will-change: opacity; }
.player-busy {
  position: absolute; top: 10px; inset-inline-start: 10px; display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, 0.92); color: var(--ink); font-size: 0.8rem; padding: 5px 12px; border-radius: 999px; box-shadow: var(--shadow-sm);
}
.player-badge {
  position: absolute; bottom: 10px; inset-inline: 10px; background: rgba(58, 47, 64, 0.8); color: #fff;
  font-size: 0.85rem; padding: 8px 12px; border-radius: var(--radius-sm); text-align: center;
}
.player-controls { display: flex; align-items: center; gap: 10px; width: 100%; max-width: calc(var(--stage-h) * 0.5625 + 120px); margin-inline: auto; }
.player-note { font-size: 0.85rem; color: var(--muted); text-align: center; }
.player-time { font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 72px; text-align: center; }
.player-range {
  --fill: 0%;
  flex: 1; min-width: 0; height: 44px; margin: 0; background: transparent; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.player-range::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px;
  background: linear-gradient(to left, var(--rose-deep) var(--fill), var(--line) var(--fill));
}
.player-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%;
  background: #fff; border: 2px solid var(--rose-deep); box-shadow: var(--shadow-sm);
}
.player-range::-moz-range-track { height: 6px; border-radius: 999px; background: var(--line); }
.player-range::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--rose-deep); }
.player-range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 2px solid var(--rose-deep); }

/* ───── الخطوة ٥: المعاينة ───── */
.timeline-wrap:empty { display: none; }
.timeline-wrap { margin-bottom: 18px; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.tl-item {
  display: grid; grid-template-columns: 1fr; gap: 2px; width: 100%; padding: 12px 14px; text-align: start;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-soft); cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
div.tl-item { cursor: default; }
button.tl-item:hover { border-color: var(--rose); background: #fff; }
.tl-when { font-size: 0.82rem; font-weight: 600; color: var(--rose-deep); }
.tl-label { font-size: 0.82rem; color: var(--muted); }
.tl-text { font-family: var(--font-phrase); font-size: 1.1rem; line-height: 1.8; white-space: pre-line; overflow-wrap: anywhere; }
.tl-warn { font-size: 0.82rem; color: var(--error); font-weight: 500; }
.tl-wait { font-size: 0.82rem; color: var(--muted); }
.tl-item.is-missing { border-style: dashed; border-color: var(--error-line); }
.preview-status:empty { display: none; }
.preview-status .callout { margin-bottom: 0; }
.problem-list { margin: 4px 0 0; padding-inline-start: 18px; font-size: 0.92rem; }

/* ───── الخطوة ٦: التجهيز ───── */
.job-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.job-card { padding: 18px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-soft); }
.job-card > .callout { margin-bottom: 0; }
.job-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.job-status { flex: 1; font-weight: 600; font-size: 1.05rem; }
.progress-pct { font-weight: 600; color: var(--rose-deep); font-variant-numeric: tabular-nums; }
.progress { height: 12px; border-radius: 999px; background: #EFE9F5; overflow: hidden; }
.progress-fill { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(to left, var(--rose), var(--rose-deep)); transition: width 0.6s ease; }
.job-queue { margin-top: 10px; font-weight: 500; color: var(--ink); }
.job-note { margin-top: 12px; color: var(--muted); font-size: 0.92rem; }

.result { display: grid; gap: 22px; }
.result-media-wrap { display: flex; justify-content: center; }
.result-media { width: min(100%, calc(70dvh * 0.5625)); height: auto; border-radius: var(--radius); background: #EEE8F4; box-shadow: var(--shadow-lg); }
.result-info { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.result-info .callout { margin-bottom: 0; }
.result-info > .btn-primary { width: 100%; }
.result-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
.result-meta > div { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--line); }
.result-meta dt { font-size: 0.8rem; color: var(--muted); }
.result-meta dd { margin: 0; font-weight: 600; }
.result-expiry { display: flex; gap: 8px; align-items: flex-start; font-size: 0.9rem; color: var(--muted); }
.result-expiry .icon { flex: none; margin-top: 4px; }
.result-info .actions { margin-top: 4px; }
@media (min-width: 900px) {
  .result { grid-template-columns: minmax(260px, 360px) minmax(0, 1fr); align-items: start; }
  .result-media { width: 100%; }
}

/* ───── التحميل والحالات العامة ───── */
.boot { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 48px 16px; color: var(--muted); text-align: center; }
.boot-error { color: var(--ink); }
.boot-error .icon { color: var(--error); }
.spinner { width: 24px; height: 24px; flex: none; border-radius: 50%; border: 2.5px solid var(--rose-soft); border-top-color: var(--rose-deep); animation: spin 0.9s linear infinite; }
.spinner.small { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.site-footer { padding: 8px 0 32px; text-align: center; color: var(--muted); font-size: 0.85rem; }
.noscript { max-width: 560px; margin: 24px auto; padding: 16px; text-align: center; background: var(--error-soft); border-radius: var(--radius); }

/* ───── الحاسوب: المحرّر والمعاينة جنبًا إلى جنب ───── */
@media (min-width: 1024px) {
  :root { --stage-h: calc(100dvh - 240px); }
  .site-header { padding-top: 22px; }
  .panel { padding: 30px 32px 32px; }
  .step-title { font-size: 1.8rem; }
  .workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); gap: 28px; align-items: start; }
  .workspace[data-step="5"] { grid-template-columns: minmax(0, 1fr) minmax(360px, 460px); }
  .workspace[data-step="1"], .workspace[data-step="6"] { grid-template-columns: minmax(0, 1fr); }
  .workspace[data-step="5"] .stage { order: 0; }
  .stage {
    position: sticky; top: 16px; padding: 16px; border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.6); border: 1px solid var(--line);
  }
  .only-mobile { display: none; }
  .stepper { max-width: 760px; }
}

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