:root {
  --bg: #f4f1ec;
  --paper: #fffdf9;
  --ink: #1d1b18;
  --muted: #6f6a62;
  --line: #e4ded4;
  --accent: #0f6b57;
  --accent-ink: #ffffff;
  --accent-soft: #e3f0ec;
  --shadow: 0 1px 2px rgba(30, 25, 15, .06), 0 8px 24px rgba(30, 25, 15, .06);
  --r: 14px;
  font-family: Tajawal, system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { display: flex; flex-direction: column; overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

/* header */
.top {
  height: 64px; flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; background: var(--paper); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .mark { width: 34px; height: 34px; color: var(--accent); }
.brand b { font-size: 22px; font-weight: 800; display: block; line-height: 1; }
.brand small { color: var(--muted); font-size: 12.5px; }
.btn {
  border: 1px solid var(--line); background: var(--paper); padding: 9px 18px; border-radius: 10px; font-weight: 700;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.chev { font-size: 11px; margin-inline-start: 4px; }
.menu { position: relative; }
.dropdown {
  position: absolute; inset-inline-end: 0; top: calc(100% + 8px); width: 300px; z-index: 20;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 6px;
}
.dropdown button {
  display: block; width: 100%; text-align: start; border: 0; background: none; padding: 10px 12px; border-radius: 10px;
}
.dropdown button:hover { background: var(--accent-soft); }
.dropdown b { display: block; font-size: 14.5px; }
.dropdown small { color: var(--muted); font-size: 12.5px; }
.dropdown hr { border: 0; border-top: 1px solid var(--line); margin: 4px 8px; }

/* layout */
.app { flex: 1; display: grid; grid-template-columns: 360px 1fr; min-height: 0; }
.panel { overflow-y: auto; background: var(--paper); border-inline-end: 1px solid var(--line); padding: 8px 18px 40px; }
.panel section { padding: 16px 0; border-bottom: 1px solid var(--line); }
.panel section:last-child { border: 0; }
.panel h3 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.panel h3 span {
  width: 22px; height: 22px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 12px;
  display: grid; place-items: center;
}
.panel h3 em { font-style: normal; color: var(--muted); font-weight: 500; font-size: 12px; }

.types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tgroup { grid-column: 1 / -1; font-size: 12px; color: var(--muted); font-weight: 700; margin: 8px 2px 0; }
.tgroup:first-child { margin-top: 0; }
.tdesc { margin: 10px 2px 0; font-size: 12.5px; color: var(--accent); font-weight: 500; }
.check[hidden] { display: none; }
.type {
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--paper); padding: 8px; text-align: center;
  transition: border-color .15s, background .15s;
}
.type:hover { border-color: #cfc6b8; }
.type.on { border-color: var(--accent); background: var(--accent-soft); }
.type svg { width: 100%; height: 46px; display: block; }
.type b { font-size: 12px; display: block; margin-top: 4px; line-height: 1.3; }
.types .type { padding: 6px 4px; }
.type small { font-size: 11px; color: var(--muted); display: block; line-height: 1.35; min-height: 30px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.presets button {
  border: 1px dashed #cfc6b8; background: none; padding: 4px 10px; border-radius: 99px; font-size: 12.5px; color: var(--muted);
}
.presets button:hover { color: var(--accent); border-color: var(--accent); }

.dim { display: grid; grid-template-columns: 64px 1fr 72px 26px; align-items: center; gap: 10px; margin-bottom: 10px; }
.dim span { font-size: 13.5px; color: var(--muted); }
.dim input[type=number] {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; text-align: center; background: #fff; direction: ltr;
}
input[type=range] { width: 100%; accent-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips.small { margin-top: 8px; }
.chip {
  display: flex; align-items: center; gap: 7px; border: 1.5px solid var(--line); background: #fff;
  border-radius: 99px; padding: 5px 12px 5px 10px; font-size: 13px;
}
.chip i { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(0,0,0,.12); }
.chip.on { border-color: var(--accent); background: var(--accent-soft); }
.chips.small .chip { padding: 3px 11px; font-size: 12.5px; }

.row { display: flex; gap: 8px; }
.grow { flex: 1; }
.color { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); min-width: 0; }
.color label { position: relative; width: 100%; display: block; cursor: pointer; }
.color input { width: 100%; height: 36px; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: #fff; cursor: pointer; display: block; }
/* بلا لون: مربعات شفافية مع خط مائل */
.color .nc { display: none; position: absolute; inset: 4px; border-radius: 7px; pointer-events: none;
  background: linear-gradient(to top left, transparent calc(50% - 1px), #e11d48 calc(50% - 1px), #e11d48 calc(50% + 1px), transparent calc(50% + 1px)),
  repeating-conic-gradient(#e7e2d9 0 25%, #fff 0 50%) 0 0 / 10px 10px; }
.color.none .nc { display: block; }
.ncbtn { border: 1px solid var(--line); background: #fff; border-radius: 99px; font-size: 11px; font-weight: 700; padding: 2px 9px; color: var(--muted); }
.color.none .ncbtn { background: var(--ink); color: #fff; border-color: var(--ink); }
.swatches i.none { background: repeating-conic-gradient(#e7e2d9 0 25%, #fff 0 50%) 0 0 / 8px 8px; }
.unitrow { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.seg.mini { margin: 0; flex-wrap: nowrap; }
.seg.mini button { flex: none; padding: 3px 12px; font-size: 12px; }
.seg button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.sublabel { font-size: 12.5px; color: var(--muted); font-weight: 700; margin: 12px 0 2px; }
.swatches { display: flex; gap: 6px; margin: 10px 0 4px; flex-wrap: wrap; }
.swatches button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid rgba(0,0,0,.1); padding: 0; overflow: hidden; display: flex; }
.swatches button i { flex: 1; }
.field { display: block; margin-top: 10px; }
.field span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fff; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; margin-top: 12px; color: var(--muted); }
.check input { accent-color: var(--accent); }

.upload { margin-top: 12px; }
.drop {
  display: block; border: 1.5px dashed #cfc6b8; border-radius: 12px; padding: 14px; text-align: center; cursor: pointer; background: #fcfaf6;
}
.drop:hover { border-color: var(--accent); }
.drop b { display: block; font-size: 14px; }
.drop small { color: var(--muted); font-size: 12px; }
.drop.has { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.drop.slim { padding: 10px; margin-top: 8px; }
.link { background: none; border: 0; color: var(--accent); padding: 0; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.upload .link, details .link#fullClear { margin-top: 6px; font-size: 12.5px; }
details.pro { margin-top: 14px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 13px; }
details.pro summary { cursor: pointer; font-weight: 700; }
details.pro ol { padding-inline-start: 18px; color: var(--muted); line-height: 1.8; margin: 8px 0; }

/* stage */
.stagewrap {
  position: relative; min-width: 0; min-height: 0;
  background: radial-gradient(120% 90% at 50% 30%, #ffffff 0%, #efebe4 70%, #e6e0d6 100%);
}
.viewer, .flat { position: absolute; inset: 0; }
.viewer canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.flat { display: grid; place-items: center; padding: 70px 40px 120px; }
.flat[hidden] { display: none; }
.flat svg { max-width: 100%; max-height: 100%; width: auto; height: auto; filter: drop-shadow(0 6px 18px rgba(30,25,15,.12)); }
.viewtabs {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%); z-index: 5; display: flex;
  background: rgba(255,255,255,.95); border: 1px solid var(--line); border-radius: 99px; padding: 3px;
}
.viewtabs button { border: 0; background: none; padding: 7px 16px; border-radius: 99px; font-size: 13.5px; font-weight: 700; color: var(--muted); }
.viewtabs button.on { background: var(--ink); color: #fff; }
.dock {
  position: absolute; bottom: 64px; left: 50%; transform: translateX(-50%); z-index: 5;
  display: flex; align-items: center; gap: 12px; width: min(460px, calc(100% - 32px));
  background: rgba(255,255,255,.96); border: 1px solid var(--line);
  border-radius: 99px; padding: 6px 8px; box-shadow: var(--shadow);
}
.dock input { flex: 1; direction: ltr; }
.foldlbl { font-size: 12.5px; color: var(--muted); min-width: 44px; text-align: center; }
.iconbtn {
  width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--ink); color: #fff; display: grid; place-items: center; flex: none;
}
.iconbtn svg { width: 18px; height: 18px; }
.iconbtn.ghost { background: transparent; color: var(--ink); }
#spin { background: transparent; color: var(--muted); }
#spin.on { color: var(--accent); background: var(--accent-soft); }
.specs {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 5;
  display: flex; gap: 18px; font-size: 12.5px; color: var(--muted); white-space: nowrap;
}
.specs b { color: var(--ink); font-weight: 700; direction: ltr; unicode-bidi: isolate; }

.toast {
  position: fixed; bottom: 24px; left: 24px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 13.5px; z-index: 50; box-shadow: var(--shadow);
}

/* header actions */
.actions { display: flex; align-items: center; gap: 8px; }
.btn { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn svg { width: 17px; height: 17px; }
.btn.accent { background: #d4a24c; border-color: #d4a24c; color: #1d1b18; }
.btn.accent:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.ghost.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.small { padding: 5px 12px; font-size: 13px; border-radius: 8px; }
.btn.wide { width: 100%; justify-content: center; margin-top: 10px; }
.btn.danger { color: #b42318; border-color: #f2b8b5; background: #fff3f2; }
.dropdown.small { width: 200px; }

/* modal */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(20, 18, 14, .45); display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.sheet {
  position: relative; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--paper); border-radius: 18px; padding: 24px 22px 22px; box-shadow: 0 24px 60px rgba(0,0,0,.25);
}
.sheet.narrow { width: min(400px, 100%); }
.sheet.wide { width: min(820px, 100%); }
.sheet h2 { margin: 0 0 4px; font-size: 21px; }
.sheet .sub { color: var(--muted); margin: 0 0 14px; font-size: 14px; line-height: 1.6; }
.sheet .x { position: absolute; top: 12px; inset-inline-end: 12px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: #f1ede6; font-size: 20px; line-height: 1; }
.sheet textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fff; font: inherit; resize: vertical; }
.sheet .err { color: #b42318; background: #fff3f2; border-radius: 8px; padding: 8px 10px; font-size: 13px; margin: 10px 0 0; }
.sheet .muted { color: var(--muted); }
.btn.google { width: 100%; justify-content: center; background: #fff; padding: 11px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; margin: 14px 0 4px; }
.or::before, .or::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.links { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; font-size: 13px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; background: #f1ede6; padding: 4px; border-radius: 12px; margin: 10px 0 16px; width: fit-content; }
.tabs button { border: 0; background: none; padding: 7px 16px; border-radius: 9px; font-weight: 700; color: var(--muted); }
.tabs button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.dgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-top: 14px; }
.dcard { border: 1px solid var(--line); border-radius: 14px; padding: 8px; background: #fff; }
.dcard.cur { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.dcard b { display: block; font-size: 14px; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dcard small { color: var(--muted); font-size: 12px; }
.drow { display: flex; gap: 6px; margin-top: 8px; }
.drow .btn { flex: 1; justify-content: center; }
.dthumb { aspect-ratio: 4 / 3; border-radius: 10px; background: radial-gradient(circle at 50% 35%, #fff, #ece7df); overflow: hidden; }
.dthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dthumb.sm { width: 84px; flex: none; }
.qlist { display: flex; flex-direction: column; gap: 8px; }
.qrow, .qsum { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 8px; background: #fff; }
.qsum { margin-bottom: 4px; }
.qsum b, .qinfo b { display: block; font-size: 14.5px; }
.qsum small, .qinfo small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.qinfo { flex: 1; min-width: 0; }
.badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px; white-space: nowrap; }
.st-new { background: #fff4d6; color: #8a5a00; }
.st-cont { background: #e3eefc; color: #1d4f91; }
.st-priced { background: #efe6fb; color: #5b2d9b; }
.st-done { background: var(--accent-soft); color: var(--accent); }
.st-closed { background: #eee; color: #666; }
#qQty { align-items: center; }
#qQty input { width: 120px; border: 1px solid var(--line); border-radius: 99px; padding: 5px 12px; background: #fff; direction: rtl; }
.hint { color: var(--accent); font-size: 12.5px; display: block; margin-top: 6px; min-height: 1em; }
.done { text-align: center; }
.done .tick { width: 64px; height: 64px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 34px; display: grid; place-items: center; margin: 4px auto 12px; }
.done .ref { font-size: 28px; font-weight: 800; letter-spacing: 2px; margin: 0 0 12px; }
.btn.wa { background: #25d366; border-color: #25d366; color: #fff; text-decoration: none; }

/* ---------- مكتبة الأنواع ---------- */
.hlink { margin-inline-start: auto; font-size: 12.5px; }
.gtabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.gtabs button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 4px 11px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.gtabs button.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.lib-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 6px 0 4px; }
.lib-top input { flex: 1; min-width: 160px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: #fff; }
.lib-top .tabs { margin: 0; flex-wrap: wrap; max-width: 100%; }
.sheet { overflow-x: hidden; }
.libgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.libcard { border: 1.5px solid var(--line); border-radius: 14px; background: #fff; padding: 10px; text-align: start; display: flex; flex-direction: column; gap: 4px; }
.libcard:hover { border-color: var(--accent); }
.libcard.on { border-color: var(--accent); background: var(--accent-soft); }
.libcard svg { width: 100%; height: 92px; display: block; background: #faf8f4; border-radius: 10px; padding: 6px; }
.libcard b { font-size: 14px; }
.libcard small { color: var(--muted); font-size: 12px; line-height: 1.45; }
.libcard .g { font-size: 11px; color: var(--accent); font-weight: 700; }

/* ---------- عناصر التحكم ---------- */
.sl { display: grid; grid-template-columns: 82px 1fr 58px; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; }
.sl > span { color: var(--muted); }
.sl output, .sl input[type=number] { font-size: 12.5px; text-align: center; color: var(--ink); direction: ltr; }
.sl input[type=number] { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 4px; background: #fff; }
.sl:has(em) { grid-template-columns: 82px 1fr 58px 14px; }
.sl em { font-style: normal; color: var(--muted); font-size: 12px; }
.seg { display: flex; gap: 4px; margin-top: 10px; flex-wrap: wrap; }
.seg button { flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 6px 4px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.seg button:hover, .tools button:hover { border-color: var(--accent); color: var(--accent); }
#lightPresets { margin-top: 14px; }

/* ---------- طبقات الصور ---------- */
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.laylist { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.laylist .small { font-size: 12.5px; margin: 0; }
.lrow { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 4px 6px; background: #fff; cursor: pointer; }
.lrow.on { border-color: var(--accent); background: var(--accent-soft); }
.lrow b { flex: 1; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lthumb { width: 34px; height: 34px; border-radius: 6px; flex: none; overflow: hidden; background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0 / 10px 10px; }
.lthumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.lbtn { border: 0; background: none; color: var(--muted); width: 26px; height: 26px; border-radius: 6px; font-size: 13px; }
.lbtn:hover { background: #f1ede6; color: var(--ink); }
.layedit { margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 4px 12px 12px; background: #fcfaf6; }
.layedit[hidden] { display: none; }
.xy { display: flex; gap: 8px; align-items: center; margin-top: 10px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.xy input { width: 70px; border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; background: #fff; direction: ltr; text-align: center; }
.xy em { font-style: normal; font-size: 11.5px; }
.tools { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 12px; }
.tools button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 5px 9px; font-size: 12.5px; font-weight: 700; }
.tools button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.tools button.danger { color: #b42318; }
.tip { font-size: 12px; color: var(--muted); margin: 10px 0 0; line-height: 1.6; }

/* محرر الصورة فوق خط القص */
.edit { position: absolute; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }
.edit[hidden] { display: none; }
.sel { position: absolute; pointer-events: auto; cursor: move; outline: 1.5px solid var(--accent); touch-action: none; }
.flipwrap { position: absolute; inset: 0; }
.clipbox { position: absolute; inset: 0; overflow: hidden; }
.sel img { position: absolute; max-width: none; pointer-events: none; user-select: none; }
.sel .ghost { display: none; opacity: .35; }
.sel.cropping .ghost { display: block; }
.sel.cropping { outline: 2px dashed #d4a24c; }
.h { position: absolute; width: 14px; height: 14px; background: #fff; border: 2px solid var(--accent); border-radius: 50%; margin: -7px; z-index: 2; }
.h.r[data-h=nw] { left: 0; top: 0; cursor: nwse-resize; } .h.r[data-h=se] { left: 100%; top: 100%; cursor: nwse-resize; }
.h.r[data-h=ne] { left: 100%; top: 0; cursor: nesw-resize; } .h.r[data-h=sw] { left: 0; top: 100%; cursor: nesw-resize; }
.h.rot { left: 50%; top: -30px; cursor: grab; background: var(--accent); }
.h.rot::after { content: ''; position: absolute; left: 50%; top: 12px; height: 18px; border-left: 1.5px solid var(--accent); }
.h.c { display: none; background: #d4a24c; border-color: #fff; border-radius: 3px; }
.sel.cropping .h.c { display: block; }
.sel.cropping .h.r, .sel.cropping .h.rot { display: none; }
.c-n { left: 50%; top: 0; cursor: ns-resize; } .c-s { left: 50%; top: 100%; cursor: ns-resize; }
.c-e { left: 100%; top: 50%; cursor: ew-resize; } .c-w { left: 0; top: 50%; cursor: ew-resize; }
.c-nw { left: 0; top: 0; cursor: nwse-resize; } .c-se { left: 100%; top: 100%; cursor: nwse-resize; }
.c-ne { left: 100%; top: 0; cursor: nesw-resize; } .c-sw { left: 0; top: 100%; cursor: nesw-resize; }
.flat { touch-action: none; }

/* أزرار زوايا العرض */
.views {
  position: absolute; top: 64px; inset-inline-start: 14px; z-index: 5; display: flex; flex-direction: column; gap: 2px;
  background: rgba(255,255,255,.95); border: 1px solid var(--line); border-radius: 12px; padding: 4px;
}
.views button { border: 0; background: none; border-radius: 8px; padding: 5px 10px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.views button:hover { background: var(--accent-soft); color: var(--accent); }

/* قائمة التنزيل */
.dropdown.wide { width: 330px; max-height: calc(100vh - 90px); overflow-y: auto; }
.dhead { font-size: 11.5px; font-weight: 800; color: var(--muted); padding: 8px 12px 2px; }

/* نوافذ التصدير */
.opt { margin-top: 14px; }
.opt > b { display: block; font-size: 13.5px; margin-bottom: 6px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pills button { border: 1.5px solid var(--line); background: #fff; border-radius: 10px; padding: 7px 12px; font-size: 13px; font-weight: 700; text-align: start; }
.pills button small { display: block; font-weight: 500; color: var(--muted); font-size: 11.5px; }
.pills button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.pills button:disabled { opacity: .45; cursor: not-allowed; }
.note { background: #f7f3ea; border-radius: 10px; padding: 10px 12px; font-size: 12.5px; color: var(--muted); line-height: 1.7; margin-top: 14px; }
.bar { height: 8px; border-radius: 99px; background: #eee7dc; overflow: hidden; margin: 18px 0 8px; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.recmask { position: absolute; inset: 0; z-index: 30; background: rgba(20,18,14,.55); display: grid; place-items: center; color: #fff; font-weight: 700; }

@media (max-width: 860px) {
  .views { top: 54px; inset-inline-start: 8px; padding: 2px; }
  .views button { padding: 4px 7px; font-size: 11.5px; }
  .top { padding: 0 12px; }
  .actions { gap: 6px; }
  .actions .btn { padding: 8px 11px; }
  #quoteBtn span { display: none; }
  body { overflow: auto; }
  .app { grid-template-columns: 1fr; }
  .stagewrap { height: 68vh; order: -1; }
  .viewer { bottom: 96px; }
  .dock { bottom: 38px; }
  .specs { bottom: 10px; }
  .viewtabs { top: 10px; }
  .flatbar { top: 54px; inset-inline-start: 8px; padding: 4px 8px; gap: 6px; }
  .flatbar .check { font-size: 12px; }
  .viewer.pip { bottom: 10px; inset-inline-end: 10px; width: 36%; }
  .viewer.pip.min { width: 130px; }
  .panel { border: 0; }
  .brand small { display: none; }
  .specs { gap: 10px; font-size: 11.5px; }
}

/* شريط خط القص: المقاسات والوحدة */
.flatbar { position: absolute; top: 64px; inset-inline-start: 14px; z-index: 5; display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.96); border: 1px solid var(--line); border-radius: 12px; padding: 5px 10px; }
.flatbar[hidden] { display: none; }
.flatbar .check { margin: 0; font-weight: 700; color: var(--ink); white-space: nowrap; }

/* نافذة المجسم الصغيرة أثناء تعديل خط القص */
.pipbar { display: none; }
.viewer.pip {
  inset: auto; bottom: 16px; inset-inline-end: 16px; width: min(34%, 360px); aspect-ratio: 4 / 3; z-index: 6;
  border-radius: 14px; overflow: hidden; border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(30,25,15,.18);
  background: #f1eee8;
}
.viewer.pip .pipbar { display: flex; position: absolute; top: 0; inset-inline: 0; z-index: 2; align-items: center; gap: 4px;
  padding: 5px 6px 5px 10px; background: linear-gradient(rgba(255,255,255,.92), rgba(255,255,255,0)); font-size: 12px; pointer-events: none; }
.pipbar b { flex: 1; }
.pipbar button { pointer-events: auto; width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-weight: 800; line-height: 1; padding: 0; }
.viewer.pip.min { width: 150px; aspect-ratio: auto; height: 36px; }
.viewer.pip.min canvas { visibility: hidden; }
.dim .du { font-style: normal; font-size: 12px; color: var(--muted); }
/* إفساح مكان لنافذة المجسم حتى لا تغطي خط القص */
.stagewrap.pipon .flat { padding-left: calc(min(34%, 360px) + 28px); }
.stagewrap.pipon.pipmin .flat { padding-left: 40px; }
@media (max-width: 860px) {
  .stagewrap.pipon .flat { padding: 92px 10px calc(27vw + 18px); }
  .stagewrap.pipon.pipmin .flat { padding-bottom: 56px; }
}
.viewtabs button { white-space: nowrap; }
/* زر وضع الفتح في الشريط السفلي */
.ombtn { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 10px; font-size: 12px; font-weight: 800; white-space: nowrap; color: var(--ink); }
.ombtn.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.ombtn:disabled { opacity: .4; }
#openMode button:disabled { opacity: .4; cursor: not-allowed; }

/* لوحة الطبقات في خط القص */
.lpbtn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 3px 10px; font-size: 12px; font-weight: 800; }
.lpbtn.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.laypanel { position: absolute; top: 108px; inset-inline-start: 14px; z-index: 7; width: 236px; max-height: calc(100% - 128px); overflow-y: auto;
  background: rgba(255,255,255,.97); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; font-size: 12.5px; }
.laypanel[hidden] { display: none; }
.lp-h { font-size: 11px; font-weight: 800; color: var(--muted); padding: 6px 6px 3px; display: flex; justify-content: space-between; }
.lp-row { display: flex; align-items: center; gap: 6px; padding: 4px 5px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.lp-row:hover { background: #f6f3ec; }
.lp-row.on { border-color: var(--accent); background: var(--accent-soft); }
.lp-row.drag { opacity: .4; }
.lp-row.over { box-shadow: inset 0 2px 0 var(--accent); }
.lp-row .th { width: 28px; height: 28px; border-radius: 6px; overflow: hidden; flex: none; background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0/8px 8px; display: grid; place-items: center; border: 1px solid var(--line); }
.lp-row .th img { max-width: 100%; max-height: 100%; }
.lp-row .th.sw { border-radius: 50%; width: 20px; height: 20px; margin: 4px; }
.lp-row b { flex: 1; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-row .grip { cursor: grab; color: var(--muted); font-size: 13px; }
.lp-row button { border: 0; background: none; width: 24px; height: 24px; border-radius: 6px; padding: 0; color: var(--muted); font-size: 13px; }
.lp-row button:hover { background: #ece7dd; color: var(--ink); }
.lp-row button.off { opacity: .35; }
.lp-tip { color: var(--muted); font-size: 11.5px; padding: 4px 6px 6px; line-height: 1.6; }

/* بطاقة تلوين جزء */
.facecard { position: absolute; top: 64px; inset-inline-end: 14px; z-index: 7; width: 236px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 10px; }
.facecard[hidden] { display: none; }
.fchead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.fchead .x { border: 0; background: none; font-size: 18px; line-height: 1; color: var(--muted); }
.fcrow { display: flex; align-items: center; gap: 6px; }
.fcswatch { position: relative; width: 52px; flex: none; }
.fcswatch input { width: 52px; height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: #fff; display: block; }
.fcswatch .nc { display: none; position: absolute; inset: 3px; border-radius: 6px; pointer-events: none;
  background: linear-gradient(to top left, transparent calc(50% - 1px), #e11d48 calc(50% - 1px), #e11d48 calc(50% + 1px), transparent calc(50% + 1px)), repeating-conic-gradient(#e7e2d9 0 25%, #fff 0 50%) 0 0 / 10px 10px; }
.facecard.none .fcswatch .nc { display: block; }
.facecard.none #fcNone { background: var(--ink); color: #fff; }
.facecard .check { margin-top: 8px; font-size: 12px; }
.fcpal { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.fcpal button { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(0,0,0,.12); padding: 0; }

/* تمييز الأجزاء في خط القص */
.fhl { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.fhl path { fill: rgba(15,107,87,.12); stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 4; }
.fhl path.hov { fill: rgba(15,107,87,.06); stroke-width: 1.2; stroke-dasharray: none; stroke-opacity: .6; }
.sel.locked { outline-style: dotted; cursor: default; pointer-events: none; }
.sel.locked .h { display: none !important; }
@media (max-width: 860px) {
  .laypanel { top: 96px; inset-inline-start: 8px; width: 200px; max-height: calc(100% - 110px); }
  .facecard { top: 96px; inset-inline-end: 8px; width: 200px; }
}
.stagewrap.lpon .flat { padding-right: 268px; }
@media (max-width: 860px) { .stagewrap.lpon .flat { padding-right: 10px; } }
.fcrow .ncbtn { white-space: nowrap; padding: 3px 8px; }

.lidrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0; font-size: 14px; font-weight: 700; }
.lidrow small { display: block; color: var(--muted); font-weight: 500; font-size: 11.5px; }

/* نافذة التنزيل بالمعاينة المباشرة */
.sheet.studiowrap { width: min(1120px, 100%); height: min(760px, calc(100vh - 32px)); padding: 0; overflow: hidden; }
.studio { display: grid; grid-template-columns: 230px 1fr; height: 100%; }
.snav { border-inline-end: 1px solid var(--line); background: #faf8f4; overflow-y: auto; padding: 14px 10px; }
.sgrp { font-size: 11.5px; font-weight: 800; color: var(--muted); padding: 12px 8px 6px; }
.snav button { display: block; width: 100%; text-align: start; border: 0; background: none; border-radius: 10px; padding: 8px 10px; margin-bottom: 2px; }
.snav button b { display: block; font-size: 13.5px; }
.snav button small { color: var(--muted); font-size: 11.5px; }
.snav button:hover { background: #f1ede6; }
.snav button.on { background: var(--accent-soft); color: var(--accent); }
.snav button.lock { opacity: .75; }
.snav .lk { font-style: normal; color: #d4a24c; font-size: 12px; }
.smain { display: grid; grid-template-columns: 1fr 330px; min-height: 0; }
.sprev { background: #eeeae3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; min-height: 0; overflow: hidden; }
.pv { position: relative; max-width: 100%; max-height: calc(100% - 50px); display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 24px rgba(0,0,0,.12); background: #fff; border-radius: 6px; overflow: hidden; }
.pv img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.pv svg { display: block; width: 100%; height: 100%; max-height: 100%; }
.pv.paper { padding: 14px; width: 100%; height: calc(100% - 50px); }
.pv.marks { outline: 1px solid transparent; background:
  linear-gradient(#111,#111) 4px 4px/14px 1px no-repeat, linear-gradient(#111,#111) 4px 4px/1px 14px no-repeat,
  linear-gradient(#111,#111) calc(100% - 4px) 4px/14px 1px no-repeat, linear-gradient(#111,#111) calc(100% - 4px) 4px/1px 14px no-repeat,
  linear-gradient(#111,#111) 4px calc(100% - 4px)/14px 1px no-repeat, linear-gradient(#111,#111) 4px calc(100% - 4px)/1px 14px no-repeat,
  linear-gradient(#111,#111) calc(100% - 4px) calc(100% - 4px)/14px 1px no-repeat, linear-gradient(#111,#111) calc(100% - 4px) calc(100% - 4px)/1px 14px no-repeat, #fff; }
.pv.checker { background: repeating-conic-gradient(#e6e2db 0% 25%, #fff 0% 50%) 0 0/18px 18px; }
.pv.proofpv { width: 100%; height: calc(100% - 40px); background: #d9d4cc; }
.pv.proofpv iframe { width: 100%; height: 100%; border: 0; }
.vbadge { position: absolute; bottom: 10px; inset-inline-start: 10px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 20px; }
.pcap { margin: 0; color: var(--muted); font-size: 12.5px; font-weight: 700; direction: rtl; }
.sside { padding: 22px 20px; overflow-y: auto; display: flex; flex-direction: column; border-inline-start: 1px solid var(--line); }
.sside #sGo { margin-top: auto; }
.sside .note { font-size: 12.5px; color: var(--muted); line-height: 1.7; margin: 14px 0; }
.lockmsg { background: #fdf6e7; color: #8a6116; border-radius: 10px; padding: 10px 12px; font-size: 13px; font-weight: 700; margin: 0 0 12px; }
.sprev .spin, .studio .spin { width: 26px; height: 26px; border: 3px solid #d6d0c6; border-top-color: var(--accent); border-radius: 50%; animation: gspin .8s linear infinite; }
@keyframes gspin { to { transform: rotate(360deg); } }
.btn.icon { display: inline-flex; align-items: center; gap: 6px; }
@media (max-width: 860px) {
  .sheet.studiowrap { height: calc(100vh - 24px); }
  .studio { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .snav { display: flex; gap: 6px; overflow-x: auto; padding: 8px; border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .sgrp { display: none; }
  .snav button { flex: none; width: auto; white-space: nowrap; }
  .snav button small { display: none; }
  .smain { grid-template-columns: 1fr; grid-template-rows: 42% 1fr; }
  .sside { border-inline-start: 0; border-top: 1px solid var(--line); }
  .btn.icon span { display: none; }
}

/* الباقات */
.sheet.pricing { width: min(1100px, 100%); }
.center { text-align: center; }
.period { display: flex; justify-content: center; gap: 4px; margin: 6px auto 18px; background: #f1ede6; border-radius: 12px; padding: 4px; width: fit-content; }
.period button { border: 0; background: none; padding: 8px 20px; border-radius: 9px; font-weight: 800; }
.period button.on { background: var(--ink); color: #fff; }
.period i { font-style: normal; background: #22a35a; color: #fff; font-size: 11px; padding: 2px 7px; border-radius: 10px; margin-inline-start: 4px; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.plan { position: relative; border: 1.5px solid var(--line); border-radius: 16px; padding: 18px 16px; display: flex; flex-direction: column; gap: 6px; background: #fff; }
.plan.hot { border-color: var(--accent); box-shadow: 0 8px 26px rgba(15,107,87,.15); }
.plan.cur { border-color: #d4a24c; }
.pbadge { position: absolute; top: -11px; inset-inline-start: 14px; background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 800; padding: 3px 10px; border-radius: 20px; }
.pname { font-size: 20px; }
.pdesc { color: var(--muted); font-size: 12.5px; min-height: 34px; }
.pprice b { font-size: 30px; font-weight: 800; }
.pprice span { color: var(--muted); font-size: 13px; }
.psub { color: #22a35a; font-size: 12px; font-weight: 700; }
.plan ul { list-style: none; padding: 0; margin: 8px 0 0; font-size: 13px; line-height: 1.5; display: grid; gap: 6px; }
.plan li::before { content: '✓'; color: var(--accent); font-weight: 800; margin-inline-end: 6px; }
.sheet.pricing h3 { margin: 26px 0 10px; }
.cmpwrap { overflow-x: auto; }
.cmp { width: 100%; border-collapse: collapse; font-size: 13px; }
.cmp th, .cmp td { padding: 9px 8px; border-bottom: 1px solid #f0ebe3; text-align: center; }
.cmp tbody th { text-align: start; font-weight: 700; }
.cmp th small { display: block; color: var(--muted); font-weight: 500; font-size: 11px; }
.cmp td { font-weight: 700; }
.cmp td.no { color: #c8c1b6; }
.small { font-size: 12px; }
.upsell { text-align: center; }
.uicon { width: 56px; height: 56px; border-radius: 50%; background: #fdf6e7; color: #d4a24c; font-size: 28px; display: grid; place-items: center; margin: 4px auto 10px; }
.upsell .btn { margin-top: 8px; }

.sside .note:empty, #sLock:empty { display: none; }
@media (max-width: 860px) { .hidem { display: none !important; } }

/* معاينة قابلة للتدوير + المعاينة الحية للفيديو */
.pv.rot { cursor: grab; touch-action: none; user-select: none; }
.pv.rot.grab { cursor: grabbing; }
.pv canvas { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.vbar { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.vbar button { border: 1px solid var(--line, #d8d2c6); background: #fff; border-radius: 20px; padding: 4px 12px; font: inherit; font-size: 12px; cursor: pointer; }
.vbar button:hover { background: #f3efe7; }
.pcap.hint { opacity: .7; font-size: 12px; margin: 0; }

/* تحديد متعدد وأدوات الترتيب */
.sel2wrap { position: absolute; inset: 0; pointer-events: none; }
.sel2 { position: absolute; outline: 1.5px dashed var(--accent); background: rgba(37, 99, 235, .06); pointer-events: none; }
.lp-tools { display: flex; gap: 8px; justify-content: space-between; padding: 2px 4px 4px; }
.lp-grp { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.lp-grp button { border: 0; background: none; padding: 4px 8px; font-size: 13px; cursor: pointer; border-inline-start: 1px solid var(--line); line-height: 1; }
.lp-grp button:first-child { border-inline-start: 0; }
.lp-grp button:hover { background: var(--accent-soft); }

/* خط من ملف + نافذة الفيكتور */
.fontadd { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 700; color: var(--accent); cursor: pointer; }
.fontadd:hover { text-decoration: underline; }
.vlist { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; max-height: 46vh; overflow: auto; }
.vrow { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; }
.vth { width: 44px; height: 44px; flex: none; border-radius: 6px; overflow: hidden; background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0/10px 10px; display: grid; place-items: center; }
.vth img { max-width: 100%; max-height: 100%; }
.vnm { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.vnm small { color: var(--muted); font-size: 11px; }
.vbtns { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.vbtns .grow { flex: 1; }
