/* ═══════════════════════════════════════════════════════════════
   أدوات الاستوديو (خطوط، مساحات أمان، مقاسات، ألوان، ثمبنيل، تصدير، عرض سعر)
   فوق kdr-lab.css — نفس ألوان كادر (--k-*) فاتح وداكن. كل شي يبدي بـ st-
   ═══════════════════════════════════════════════════════════════ */
.st-head h1 .k3d { --s: 58px; }
/* hidden لازم يغلب display:grid/flex مال عناصر الأدوات */
.st-split [hidden], .st-stage [hidden], .lab .st-empty[hidden], .ft-grid > [hidden] { display: none !important; }
/* المسافة تحت الهيدر العائم صارت بـ .lab نفسها (kdr-lab.css) لكل صفحات الأدوات */
.lab-ibtn[aria-pressed="true"] { color: #fff; background: var(--k-grad, linear-gradient(135deg, #7744B6, #2E5EC3)); border-color: transparent; }
.lab .lab-btn:not(.ghost):not(.danger):not(.gold) { background: var(--k-grad, linear-gradient(135deg, #7744B6, #2E5EC3)); }
.st-free { font-size: .84rem; color: var(--k-ok, #12805C); }
.st-free i { color: var(--k-ok, #12805C) !important; }

/* تخطيط: لوحة تحكم + معاينة */
.st-split { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 980px) {
  .st-split { grid-template-columns: 340px minmax(0, 1fr); }
  .st-split > .st-side { position: sticky; top: calc(96px + var(--kdr-ann, 0px)); }
}
.st-panel { padding: 18px; }
.st-panel + .st-panel { margin-top: 14px; }
.st-panel h2, .st-h { display: flex; align-items: center; gap: 8px; font-size: 1.02rem; font-weight: 800; margin: 0 0 12px; color: var(--k-ink); }
.st-panel h2 i, .st-h i { color: var(--k-brand, #7744B6); }

/* حقول */
.st-field { display: grid; gap: 6px; margin-bottom: 12px; }
.st-field > span, .st-label { font-size: .84rem; font-weight: 700; color: var(--k-ink-2, #4A4566); display: flex; justify-content: space-between; gap: 8px; }
.st-field > span em { font-style: normal; font-weight: 800; color: var(--k-brand, #7744B6); font-variant-numeric: tabular-nums; }
.st-in, .st-sel, .st-ta { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px; font: inherit; font-size: .95rem; color: var(--k-ink);
  background: var(--k-surface-2, #F1EFF8); border: 1px solid var(--k-line, #E5E1F0); outline: 0; transition: border-color .2s, box-shadow .2s; }
.st-ta { min-height: 90px; resize: vertical; line-height: 1.8; }
.st-in:focus, .st-sel:focus, .st-ta:focus { border-color: rgba(var(--k-brand-rgb), .55); box-shadow: 0 0 0 3px rgba(var(--k-brand-rgb), .14); }
.st-in[type="color"] { padding: 4px; min-height: 44px; cursor: pointer; }
.st-range { width: 100%; accent-color: var(--k-brand, #7744B6); }
.st-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.st-row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.st-check { display: flex; align-items: center; gap: 8px; font-size: .9rem; cursor: pointer; padding: 6px 0; }
.st-check input { width: 18px; height: 18px; accent-color: var(--k-brand, #7744B6); }

/* أزرار مقسّمة (اختيار واحد) */
.st-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.st-seg button { min-height: 38px; padding: 0 13px; border-radius: 11px; cursor: pointer; font: inherit; font-size: .86rem; font-weight: 700;
  color: var(--k-ink-2); background: var(--k-surface-2, #F1EFF8); border: 1px solid var(--k-line, #E5E1F0); transition: all .15s; }
.st-seg button:hover { border-color: rgba(var(--k-brand-rgb), .4); }
.st-seg button[aria-pressed="true"] { color: #fff; background: var(--k-grad, linear-gradient(135deg, #7744B6, #2E5EC3)); border-color: transparent; }

/* منطقة الرفع */
.st-drop { position: relative; display: grid; place-items: center; gap: 8px; min-height: 180px; padding: 24px 16px; text-align: center; cursor: pointer;
  border: 2px dashed rgba(var(--k-brand-rgb), .35); border-radius: 20px; background: rgba(var(--k-brand-rgb), .04); color: var(--k-ink-2); transition: border-color .2s, background-color .2s; }
.st-drop:hover, .st-drop.over { border-color: var(--k-brand, #7744B6); background: rgba(var(--k-brand-rgb), .08); }
.st-drop .k3d { --s: 72px; filter: none !important; }
.st-drop b { font-size: 1rem; color: var(--k-ink); }
.st-drop small { font-size: .82rem; color: var(--k-ink-3); }
.st-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.st-drop.compact { min-height: 0; padding: 12px; grid-auto-flow: column; justify-content: center; }
.st-drop.compact .k3d { --s: 36px; }

/* مساحة المعاينة */
.st-stage { position: relative; display: grid; place-items: center; min-height: 320px; padding: 16px; border-radius: 22px; overflow: hidden;
  background: repeating-conic-gradient(rgba(var(--k-fg-rgb, 30,26,60), .05) 0 25%, transparent 0 50%) 0 0 / 22px 22px, var(--k-surface); border: 1px solid var(--k-line); }
.st-empty { display: grid; justify-items: center; gap: 8px; text-align: center; color: var(--k-ink-3); padding: 30px 10px; }
.st-empty .k3d { --s: 110px; }
.st-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.st-note { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--k-surface-2, #F1EFF8); font-size: .84rem; line-height: 1.75; color: var(--k-ink-2); margin-top: 12px; }
.st-note i { color: var(--k-brand, #7744B6); margin-top: 5px; }
.st-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .76rem; font-weight: 700; background: var(--k-surface-2); color: var(--k-ink-2); border: 1px solid var(--k-line); }

/* الدعوة للسوق */
.st-cta { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 18px 20px; margin-top: 30px;
  background: linear-gradient(160deg, rgba(var(--k-brand-rgb), .1), transparent 60%), var(--k-surface); }
.st-cta-t { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1 1 340px; }
.st-cta-t .k3d { flex: none; }
.st-cta-t b { display: block; font-size: 1.05rem; margin-bottom: 2px; }
.st-cta-t small { display: block; color: var(--k-ink-2); font-size: .88rem; line-height: 1.7; }
.st-cta-a { display: flex; gap: 8px; flex-wrap: wrap; }
.st-more { margin-bottom: 10px; }

/* ═══ استوديو الخط العربي ═══ */
.ft-bar { position: sticky; top: calc(76px + env(safe-area-inset-top, 0px) + var(--kdr-ann, 0px)); z-index: 20; display: grid; gap: 10px; padding: 12px; margin-bottom: 14px;
  background: var(--lg-tint-sheet, var(--k-surface)); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%); }
.ft-bar .ft-text { font-size: 1.05rem; font-weight: 700; }
.ft-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.ft-ctl .st-seg { flex: 1 1 auto; }
.ft-size { display: flex; align-items: center; gap: 8px; flex: 0 1 220px; font-size: .82rem; color: var(--k-ink-3); }
.ft-tools { display: flex; gap: 6px; }
.ft-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); }
.ft-card { display: flex; flex-direction: column; padding: 14px 16px 12px; min-width: 0; transition: border-color .2s; }
.ft-card:hover { border-color: rgba(var(--k-brand-rgb), .35); }
.ft-card header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.ft-card header b { font-size: .95rem; font-family: inherit; }
.ft-card header small { font-size: .74rem; color: var(--k-ink-3); }
.ft-sample { min-height: 92px; display: flex; align-items: center; padding: 6px 0; color: var(--k-ink); line-height: 1.6; overflow-wrap: anywhere; word-break: break-word; }
.ft-sample.loading { opacity: .35; }
.ft-card footer { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--k-line); }
.ft-card footer .st-sel { width: auto; min-height: 36px; padding: 4px 8px; font-size: .82rem; flex: 1 1 110px; }
.ft-card.pinned { border-color: var(--k-brand); box-shadow: 0 0 0 2px rgba(var(--k-brand-rgb), .2); }
.ft-pin[aria-pressed="true"] { color: #fff; background: var(--k-grad); border-color: transparent; }
.ft-count { font-size: .84rem; color: var(--k-ink-3); margin: 0 0 10px; }
.ft-lic { margin-top: 14px; }

/* ═══ مساحات الأمان ═══ */
.sz-wrap { position: relative; width: min(100%, 380px); aspect-ratio: 9 / 16; border-radius: 26px; overflow: hidden; background: #000; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.sz-wrap > .sz-media { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.sz-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 8px; text-align: center; color: rgba(255,255,255,.75); padding: 20px; }
.sz-empty .k3d { --s: 96px; }
.sz-ov { position: absolute; inset: 0; pointer-events: none; }
.sz-ov .z { position: absolute; background: rgba(226, 54, 84, .34); outline: 1px dashed rgba(255,255,255,.65); }
.sz-ov .safe { position: absolute; border: 2px solid rgba(46, 230, 160, .95); border-radius: 6px; box-shadow: 0 0 0 9999px rgba(0,0,0,0); }
.sz-ov.ui .z { background: transparent; outline: 0; }
.sz-ui { position: absolute; inset: 0; pointer-events: none; color: #fff; font-family: inherit; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.sz-ui .rail { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 4.2%; }
.sz-ui .rail span { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.2); font-size: 15px; }
.sz-ui .cap { position: absolute; display: grid; gap: 6px; }
.sz-ui .cap i { display: block; height: 9px; border-radius: 5px; background: rgba(255,255,255,.85); }
.sz-ui .top { position: absolute; display: flex; justify-content: center; gap: 14px; font-size: 12px; font-weight: 800; }
.sz-ui .bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; align-items: center; background: rgba(0,0,0,.55); font-size: 15px; }
.sz-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; font-size: .82rem; color: var(--k-ink-2); justify-content: center; }
.sz-legend span { display: inline-flex; align-items: center; gap: 6px; }
.sz-legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.sz-scrub { width: min(100%, 380px); margin-top: 10px; }

/* ═══ مقاسات السوشيال ═══ */
.is-presets { display: grid; gap: 6px; max-height: 420px; overflow-y: auto; scrollbar-width: thin; padding-inline-end: 4px; }
.is-presets label { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--k-line); background: var(--k-surface-2); font-size: .88rem; }
.is-presets label:has(input:checked) { border-color: rgba(var(--k-brand-rgb), .5); background: rgba(var(--k-brand-rgb), .07); }
.is-presets input { width: 18px; height: 18px; accent-color: var(--k-brand, #7744B6); }
.is-presets small { color: var(--k-ink-3); font-size: .76rem; direction: ltr; font-variant-numeric: tabular-nums; }
.is-out { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); width: 100%; align-items: start; }
.is-item { display: grid; gap: 6px; padding: 10px; }
.is-item canvas { width: 100%; height: auto; border-radius: 10px; background: #000; cursor: grab; touch-action: none; display: block; }
.is-item canvas:active { cursor: grabbing; }
.is-item b { font-size: .86rem; }
.is-item small { color: var(--k-ink-3); font-size: .74rem; direction: ltr; text-align: right; }
.is-item .lab-btn { width: 100%; }

/* ═══ لوحة الألوان ═══ */
.cp-img { max-width: 100%; max-height: 420px; border-radius: 14px; display: block; cursor: crosshair; }
.cp-sw { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 130px), 1fr)); margin-top: 14px; width: 100%; }
.cp-c { display: grid; border-radius: 16px; overflow: hidden; border: 1px solid var(--k-line); background: var(--k-surface); cursor: pointer; text-align: start; padding: 0; font: inherit; color: inherit; }
.cp-c span { height: 84px; display: block; }
.cp-c b { padding: 8px 10px 0; font-size: .92rem; direction: ltr; text-align: left; font-variant-numeric: tabular-nums; }
.cp-c small { padding: 0 10px 8px; color: var(--k-ink-3); font-size: .74rem; direction: ltr; text-align: left; }
.cp-c:hover { border-color: rgba(var(--k-brand-rgb), .5); }
.cp-strip { display: flex; height: 54px; border-radius: 14px; overflow: hidden; margin-top: 14px; width: 100%; }
.cp-strip span { flex: 1; }

/* ═══ معاينة الثمبنيل ═══ */
.tp-feed { width: 100%; border-radius: 18px; padding: 18px; background: #fff; color: #0f0f0f; transition: background-color .2s, color .2s; }
.tp-feed.dark { background: #0f0f0f; color: #f1f1f1; }
.tp-grid { display: grid; gap: 22px 16px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tp-feed.mobile { max-width: 400px; margin: 0 auto; padding: 0 0 12px; overflow: hidden; }
.tp-feed.mobile .tp-grid { grid-template-columns: 1fr; gap: 18px; }
.tp-feed.mobile .tp-v .th { border-radius: 0; }
.tp-feed.mobile .tp-v .meta { padding: 0 12px; }
.tp-v { min-width: 0; }
.tp-v .th { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #ccc center / cover no-repeat; }
.tp-feed.dark .tp-v .th { background-color: #272727; }
.tp-v .th em { position: absolute; bottom: 6px; left: 6px; padding: 1px 5px; border-radius: 4px; font-style: normal; font-size: 12px; font-weight: 700; color: #fff; background: rgba(0,0,0,.8); direction: ltr; }
.tp-v .meta { display: grid; grid-template-columns: 36px 1fr; gap: 10px; margin-top: 10px; }
.tp-v .av { width: 36px; height: 36px; border-radius: 50%; background: #bbb center / cover no-repeat; }
.tp-v .tt { font-size: 15px; font-weight: 700; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.tp-v .ch { font-size: 13px; opacity: .65; margin-top: 3px; }
.tp-v.mine .th { box-shadow: 0 0 0 3px var(--k-brand, #7744B6); }
.tp-v.ghost .th { background-image: linear-gradient(135deg, #d9d9d9, #bdbdbd); }
.tp-feed.dark .tp-v.ghost .th { background-image: linear-gradient(135deg, #2e2e2e, #1f1f1f); }
.tp-v.ghost .tt span, .tp-v.ghost .ch span { display: block; height: 11px; border-radius: 6px; background: currentColor; opacity: .16; margin-bottom: 6px; }
.tp-v.ghost .tt span:last-child { width: 60%; }
.tp-small { display: flex; gap: 14px; align-items: flex-start; margin-top: 18px; padding-top: 16px; border-top: 1px solid rgba(128,128,128,.25); }
.tp-small .th { flex: none; width: 168px; aspect-ratio: 16 / 9; border-radius: 8px; background: #ccc center / cover no-repeat; }
.tp-small .tt { font-size: 14px; font-weight: 700; line-height: 1.4; }
.tp-small small { font-size: 12px; opacity: .65; }

/* ═══ إعدادات التصدير ═══ */
.ex-plat { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
.ex-plat button { display: grid; gap: 2px; justify-items: start; padding: 12px 14px; border-radius: 16px; cursor: pointer; text-align: start; font: inherit; color: var(--k-ink);
  background: var(--k-surface); border: 1.5px solid var(--k-line); transition: border-color .2s; }
.ex-plat button i { font-size: 1.15rem; color: var(--k-brand); margin-bottom: 4px; }
.ex-plat button small { font-size: .74rem; color: var(--k-ink-3); }
.ex-plat button[aria-pressed="true"] { border-color: var(--k-brand); background: rgba(var(--k-brand-rgb), .07); }
.ex-spec { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); margin-top: 14px; }
.ex-spec div { padding: 12px 14px; border-radius: 14px; background: var(--k-surface-2); border: 1px solid var(--k-line); }
.ex-spec dt { font-size: .76rem; color: var(--k-ink-3); }
.ex-spec dd { margin: 2px 0 0; font-weight: 800; font-size: .98rem; font-variant-numeric: tabular-nums; }
.ex-result { margin-top: 12px; padding: 14px 16px; border-radius: 14px; background: rgba(var(--k-brand-rgb), .08); border: 1px solid rgba(var(--k-brand-rgb), .2); font-weight: 700; line-height: 1.9; }
.ex-result b { font-size: 1.25rem; color: var(--k-brand); font-variant-numeric: tabular-nums; }
.ex-cols { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); margin-top: 16px; }

/* ═══ عرض السعر ═══ */
.qm-items { display: grid; gap: 8px; }
/* البند: الاسم بسطر كامل، وتحته العدد والسعر والحذف */
.qm-item { display: grid; grid-template-columns: 70px minmax(0, 1fr) 38px; gap: 6px; align-items: center; padding: 8px; border-radius: 14px; background: var(--k-surface-2, #F1EFF8); border: 1px solid var(--k-line, #E5E1F0); }
.qm-item [data-f="d"] { grid-column: 1 / -1; }
.qm-item .st-in { min-height: 40px; padding: 8px 10px; font-size: .9rem; background: var(--k-surface, #fff); }
/* الورقة دائماً بيضاء بنص غامق (حتى بالوضع الداكن، وضد ستايلات الجداول العامة بالموقع) */
.qm-paper { width: 100%; max-width: 794px; margin: 0 auto; padding: 44px 46px; background: #fff; color: #1E1A3C; border-radius: 6px; box-shadow: 0 20px 60px rgba(0,0,0,.18); font-size: 14px; line-height: 1.8; }
.qm-paper td, .qm-paper b, .qm-paper span, .qm-paper div { color: inherit; }
.qm-paper td { color: #1E1A3C !important; background: transparent !important; }
.qm-paper th { color: #fff !important; }
.qm-paper .qh { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 18px; border-bottom: 3px solid var(--qc, #7744B6); }
.qm-paper .qh h3 { margin: 0; font-size: 26px; color: var(--qc, #7744B6); }
.qm-paper .qh .lg { max-width: 120px; max-height: 70px; object-fit: contain; }
.qm-paper .qmeta { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 18px 0; }
.qm-paper .qmeta small { display: block; color: #827C9C; font-size: 12px; }
.qm-paper table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.qm-paper th { text-align: start; font-size: 12px; color: #fff; background: var(--qc, #7744B6); padding: 8px 10px; }
.qm-paper td { padding: 9px 10px; border-bottom: 1px solid #ECE9F4; vertical-align: top; }
.qm-paper td.n, .qm-paper th.n { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.qm-paper .qt { margin-top: 12px; margin-inline-start: auto; width: min(100%, 280px); }
.qm-paper .qt div { display: flex; justify-content: space-between; padding: 4px 0; }
.qm-paper .qt .tot { border-top: 2px solid var(--qc, #7744B6); margin-top: 6px; padding-top: 8px; font-size: 17px; font-weight: 800; color: var(--qc, #7744B6); }
.qm-paper .qn { margin-top: 18px; padding: 12px 14px; border-radius: 8px; background: #F6F5FA; white-space: pre-wrap; }
.qm-paper .qf { margin-top: 26px; padding-top: 12px; border-top: 1px solid #ECE9F4; font-size: 11px; color: #827C9C; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
@media (max-width: 600px) { .qm-paper { padding: 24px 18px; font-size: 13px; } .qm-paper .qh h3 { font-size: 21px; } }
@media print {
  body.qm-printing > *:not(.qm-print-root) { display: none !important; }
  body.qm-printing .qm-print-root { display: block !important; }
  .qm-print-root .qm-paper { box-shadow: none; border-radius: 0; max-width: none; padding: 0; }
  @page { size: A4; margin: 14mm; }
}
.qm-print-root { display: none; }

@media (max-width: 640px) {
  .st-panel { padding: 14px; }
  .st-stage { min-height: 240px; padding: 10px; }
  .st-cta { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { .st-drop, .ft-card, .cp-c { transition: none; } }
