/* ================= Builder layout ================= */
body.builder { background: var(--bg); }
body.builder .site-footer { display: none; }

.bar {
  position: sticky; top: var(--header-h); z-index: 30; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.bar .container { display: flex; align-items: center; gap: 10px; padding: 10px 0; flex-wrap: wrap; }
.bar .title-input { max-width: 260px; font-weight: 600; }
.bar .spacer { flex: 1; }
.ats-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 99px;
  background: var(--surface-2); font-size: .88rem; font-weight: 600; cursor: pointer; border: 0; font-family: inherit; color: var(--ink);
}
.ats-pill i { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); display: inline-block; }
.save-state { font-size: .82rem; color: var(--ink-3); }

.workspace {
  display: grid; grid-template-columns: minmax(380px, 520px) 1fr; gap: 24px; padding: 24px 0 48px; align-items: start;
}
.editor { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.preview-col { min-width: 0; }
.stepper { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.stepper button {
  flex: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  padding: 7px 12px; border-radius: 99px; font: inherit; font-size: .85rem; cursor: pointer; display: inline-flex; gap: 6px; align-items: center;
}
.stepper button b {
  width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: .72rem;
  background: var(--surface-2); color: var(--ink-2);
}
.stepper button.on { border-color: var(--ink); color: var(--ink); font-weight: 600; }
.stepper button.on b { background: var(--ink); color: var(--bg); }
.step-card h2 { font-size: 1.25rem; margin-bottom: 4px; }
.step-card > .muted { margin-bottom: 18px; font-size: .92rem; }
.step-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; }

.item { border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 14px; background: var(--bg); }
.item-head { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.item-head strong { flex: 1; font-size: .95rem; direction: ltr; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.add-btn { width: 100%; border-style: dashed; }

.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-bottom: 18px; }
.tpl-card {
  border: 2px solid var(--line); border-radius: 12px; background: var(--surface); padding: 10px; cursor: pointer;
  font: inherit; text-align: center; color: var(--ink-2); font-size: .88rem;
}
.tpl-card.on { border-color: var(--ink); color: var(--ink); font-weight: 600; }
.tpl-thumb { aspect-ratio: 210/297; background: #fff; border: 1px solid #E5E2DA; border-radius: 4px; margin-bottom: 8px; padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.tpl-thumb i { display: block; height: 4px; border-radius: 2px; background: #E5E2DA; }
.tpl-thumb i.n { height: 7px; width: 60%; background: #0F0F0E; }
.tpl-thumb i.h { width: 40%; background: var(--c, var(--primary)); margin-top: 4px; }
.tpl-thumb.center i.n { margin-inline: auto; }
.tpl-thumb.band { border-top: 6px solid var(--c, var(--primary)); }
.colors { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.swatch.on { box-shadow: 0 0 0 2px var(--ink); }

.preview-col { position: sticky; top: calc(var(--header-h) + 72px); }
.preview-wrap { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 12px; overflow: hidden; }
.preview-sizer { position: relative; margin-inline: auto; }
.preview-sizer .cv-page { position: absolute; top: 0; left: 0; transform-origin: top left; box-shadow: 0 12px 40px -12px rgba(0,0,0,.25); }
.preview-hint { font-size: .82rem; color: var(--ink-3); text-align: center; margin-top: 10px; }
.view-switch { display: none; }

@media (max-width: 1000px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .preview-col { position: static; display: none; }
  .view-switch { display: inline-flex; margin: 0; }
  body.show-preview .editor { display: none; }
  body.show-preview .preview-col { display: block; }
  .bar .title-input { max-width: none; flex: 1 1 100%; order: -1; }
}

/* ================= CV page (A4) ================= */
.cv-page {
  --accent: #1f3a5f;
  width: 210mm; min-height: 297mm; background: #fff; color: #1a1a1a;
  padding: 16mm 17mm; direction: ltr; text-align: left;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 10.5pt; line-height: 1.42;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.cv-page * { margin: 0; padding: 0; }
.cv-page h1 { font-size: 22pt; font-weight: 700; letter-spacing: .2px; color: #111; line-height: 1.15; }
.cv-page .cv-role { font-size: 12pt; color: var(--accent); font-weight: 600; margin-top: 3pt; }
.cv-page .cv-contact { font-size: 9.5pt; color: #444; margin-top: 6pt; }
.cv-page .cv-contact .sep { color: #aaa; margin: 0 5pt; }
.cv-page .cv-section { margin-top: 13pt; }
.cv-page h2 {
  font-size: 11pt; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--accent);
  border-bottom: 1.2pt solid var(--accent); padding-bottom: 2pt; margin-bottom: 7pt;
}
.cv-page .cv-item { margin-bottom: 8pt; break-inside: avoid; }
.cv-page .cv-row { display: flex; justify-content: space-between; gap: 12pt; align-items: baseline; }
.cv-page .cv-row strong { font-weight: 700; color: #111; }
.cv-page .cv-row .date { font-size: 9.5pt; color: #555; white-space: nowrap; }
.cv-page .cv-sub { color: #444; font-style: italic; font-size: 10pt; }
.cv-page ul { margin: 3pt 0 0 4pt; list-style: none; }
/* رمز النقطة كنص حقيقي (وليس رسمًا) حتى تقرأه أنظمة ATS من ملف PDF */
.cv-page li { margin-bottom: 2pt; padding-left: 11pt; text-indent: -9pt; }
.cv-page li::before { content: "•"; display: inline-block; width: 9pt; text-indent: 0; }
.cv-page p { margin: 0; }
.cv-page .cv-skills { line-height: 1.6; }
.cv-page a { color: inherit; text-decoration: none; }

/* --- Template: Classic --- */
.cv-page.tpl-classic { font-family: Georgia, "Times New Roman", serif; }
.cv-page.tpl-classic header { text-align: center; }
.cv-page.tpl-classic h2 { text-align: left; }

/* --- Template: Modern --- */
.cv-page.tpl-modern h1 { color: var(--accent); font-size: 24pt; }
.cv-page.tpl-modern .cv-role { color: #333; }
.cv-page.tpl-modern h2 { border-bottom: 0; border-left: 3.5pt solid var(--accent); padding: 0 0 0 7pt; color: #111; }

/* --- Template: Minimal --- */
.cv-page.tpl-minimal { padding: 18mm 20mm; }
.cv-page.tpl-minimal h1 { font-weight: 300; font-size: 26pt; letter-spacing: .5px; }
.cv-page.tpl-minimal .cv-role { color: #555; font-weight: 400; }
.cv-page.tpl-minimal h2 { border: 0; font-size: 9.5pt; letter-spacing: 2.5px; font-weight: 600; margin-bottom: 6pt; }
.cv-page.tpl-minimal .cv-section { margin-top: 16pt; }

/* --- Template: Professional --- */
.cv-page.tpl-professional { border-top: 8pt solid var(--accent); padding-top: 13mm; font-family: Calibri, Carlito, "Segoe UI", Arial, sans-serif; font-size: 11pt; }
.cv-page.tpl-professional header { border-bottom: 1pt solid #ddd; padding-bottom: 9pt; }
.cv-page.tpl-professional h2 { background: color-mix(in srgb, var(--accent) 10%, #fff); border: 0; padding: 3pt 7pt; color: var(--accent); }

/* --- Template: Compact --- */
.cv-page.tpl-compact { padding: 12mm 14mm; font-size: 9.8pt; line-height: 1.35; }
.cv-page.tpl-compact h1 { font-size: 19pt; }
.cv-page.tpl-compact .cv-section { margin-top: 9pt; }
.cv-page.tpl-compact h2 { font-size: 10pt; border-bottom-width: .8pt; margin-bottom: 5pt; }
.cv-page.tpl-compact .cv-item { margin-bottom: 5pt; }

/* ================= Print → PDF ================= */
#print-root { display: none; }
/* هوامش للصفحات التالية حتى لا يلتصق النص بالحافة عند تعدد الصفحات */
@page { size: A4; margin: 14mm 0 12mm; }
@page :first { margin-top: 0; }
@media print {
  html, body { background: #fff !important; display: block; min-height: 0; }
  body::before { display: none !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; }
  #print-root .cv-page { box-shadow: none; min-height: 0; width: 210mm; padding-bottom: 0; }
}

/* المهارات كوسوم */
.tags {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); direction: ltr; cursor: text;
}
.tags:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; border: 0;
  background: var(--surface-2); color: var(--ink); font: inherit; font-size: .85rem; cursor: pointer;
}
.tag span { color: var(--ink-3); }
.tag:hover { background: var(--danger-soft); color: var(--danger); }
.tags input { flex: 1; min-width: 120px; border: 0 !important; box-shadow: none !important; padding: 4px; background: transparent; }
