/* ============================================================
   واجهة التطبيق
   ============================================================ */

.app { min-height: 100vh; display: flex; flex-direction: column; }
.app-view { flex: 1; }

/* ---------- الترويسة ---------- */
.app-header {
  background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 90;
}
.app-header-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 24px; height: 62px;
}
.app-nav { display: flex; gap: 4px; flex: 1; }
.app-nav a {
  color: var(--muted); font-weight: 700; font-size: 14px;
  padding: 8px 14px; border-radius: 10px; transition: all .15s;
}
.app-nav a:hover { color: var(--p1); background: var(--g-50); }
.app-nav a.active { color: var(--p1); background: var(--g-50); }
.app-user { display: flex; align-items: center; gap: 10px; }
.user-chip {
  display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 700;
  background: var(--bg); border: 1px solid var(--line); border-radius: 99px; padding: 5px 13px 5px 6px;
}
html[dir="ltr"] .user-chip { padding: 5px 6px 5px 13px; }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--grad); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800;
}

.page-wrap { max-width: 1280px; margin: 0 auto; padding: 28px 20px 60px; }
.page-title { font-size: 26px; font-weight: 900; margin: 0 0 6px; }
.page-sub { color: var(--muted); margin: 0 0 26px; }

/* ---------- المصادقة ---------- */
.auth-wrap {
  min-height: calc(100vh - 62px); display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(600px 300px at 85% 10%, #dcefe5 0%, transparent 60%),
    radial-gradient(500px 300px at 10% 90%, #e9f3ec 0%, transparent 60%),
    var(--bg);
  padding: 30px 16px;
}
.auth-card { width: 100%; max-width: 420px; padding: 34px 30px; }
.auth-logo { display: flex; justify-content: center; margin-bottom: 18px; }
.auth-tabs { display: flex; background: var(--bg); border-radius: 12px; padding: 4px; margin-bottom: 22px; }
.auth-tabs button {
  flex: 1; border: none; background: transparent; border-radius: 9px;
  padding: 9px; font-size: 14px; font-weight: 700; color: var(--muted); transition: all .15s;
}
.auth-tabs button.active { background: #fff; color: var(--p1); box-shadow: var(--shadow-sm); }
.auth-card .btn { width: 100%; margin-top: 6px; }
.auth-card > a { display: block; margin-top: 1.6em; }
.auth-foot { text-align: center; margin-top: 16px; font-size: 13.5px; color: var(--muted); }
.auth-foot a { display: block; font-weight: 700; cursor: pointer; }

.otp-control { position: relative; direction: ltr; isolation: isolate; }
.otp-cells { position: relative; z-index: 1; pointer-events: none; display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 8px; }
.otp-cell {
  display: flex; align-items: center; justify-content: center; height: 54px; min-width: 0;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
  font: 700 26px/1 Arial,sans-serif; color: var(--g-900);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.otp-cell.is-active { border-color: var(--p1); box-shadow: 0 0 0 3px rgba(5,150,105,.14); }
.otp-cell.is-selected { background: var(--g-50); }
.otp-cell.is-active:empty::after { content: ''; width: 2px; height: 24px; background: var(--p1); }
.field input.otp-input {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0;
  border: 0; padding: 0; background: transparent; color: transparent; caret-color: transparent;
  -webkit-text-fill-color: transparent; font-size: 24px; box-shadow: none; border-radius: 0;
}
.field input.otp-input:focus { border: 0; box-shadow: none; }
@media (max-width:360px) {
  .otp-cells { gap: 5px; }
  .otp-cell { height: 48px; font-size: 24px; border-radius: 8px; }
}
@media (forced-colors:active) {
  .otp-cell { border-color: CanvasText; }
  .otp-cell.is-active { outline: 2px solid Highlight; }
}

/* ---------- لوحة التحكم ---------- */
.dash-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 20px; margin-bottom: 20px; }
.dash-hero { padding: 28px; background: var(--grad); color: #fff; border: none; position: relative; overflow: hidden; }
.dash-hero::after { content: ''; position: absolute; width: 220px; height: 220px; border-radius: 50%; background: rgba(255,255,255,.1); top: -90px; inset-inline-end: -50px; }
.dash-hero h2 { margin: 0 0 8px; font-size: 23px; }
.dash-hero::after { pointer-events: none; }
.dash-greeting { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; position: relative; z-index: 1; }
.dash-greeting h2 { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.name-edit-btn { width: 40px; height: 40px; flex: 0 0 40px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid rgba(255,255,255,.7); border-radius: 9px; background: rgba(255,255,255,.12); color: #fff; font-size: 20px; cursor: pointer; }
.name-edit-btn:hover { background: rgba(255,255,255,.24); }
.name-edit-btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.account-name-form { position: relative; z-index: 1; max-width: 420px; margin: 16px 0 20px; }
.account-name-form label { display: block; font-weight: 700; margin-bottom: 6px; }
.account-name-form input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font: inherit; font-size: 16px; background: #fff; color: var(--ink); }
.account-name-form input:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.name-form-actions { display: flex; gap: 8px; margin-top: 10px; }
.dash-hero #accountNameStatus { margin: 8px 0 0; opacity: 1; }
.dash-hero p { margin: 0 0 20px; opacity: .9; font-size: 14.5px; max-width: 420px; }
.dash-progress-card { padding: 24px; }
.dash-progress-card h3 { margin: 0 0 14px; font-size: 16px; }
.progress-track { height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; margin-bottom: 8px; }
.progress-fill { height: 100%; background: var(--grad); border-radius: 99px; transition: width .6s ease; }
.progress-label { font-size: 13px; color: var(--muted); }
.dash-checklist { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.dash-checklist li { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--muted); }
.dash-checklist li.done { color: var(--ink); }
.dash-checklist .ck { width: 19px; height: 19px; border-radius: 6px; border: 1.5px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 11px; color: #fff; flex: 0 0 auto; }
.dash-checklist li.done .ck { background: var(--ok); border-color: var(--ok); }

.dash-sec-title { font-size: 18px; font-weight: 800; margin: 26px 0 14px; display: flex; align-items: center; justify-content: space-between; }
.owned-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.owned-empty { padding: 36px; text-align: center; color: var(--muted); }

/* ---------- محرر البيانات ---------- */
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
.wizard-card { padding: 0; overflow: hidden; }

.wizard-steps {
  display: flex; overflow-x: auto; gap: 4px; padding: 14px 16px;
  background: #fff; border-bottom: 1px solid var(--line);
}
.wizard-steps button {
  display: flex; align-items: center; gap: 7px; white-space: nowrap;
  border: none; background: transparent; color: var(--muted);
  font-size: 13px; font-weight: 700; padding: 8px 13px; border-radius: 9px; transition: all .15s;
}
.wizard-steps button.active { background: var(--g-50); color: var(--p1); }
.wizard-steps button.filled .st-num { background: var(--ok); color: #fff; border-color: var(--ok); }
.st-num {
  width: 21px; height: 21px; border-radius: 50%; border: 1.5px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-size: 11px; flex: 0 0 auto;
}
.wizard-steps button.active .st-num { background: var(--p1); color: #fff; border-color: var(--p1); }

.wizard-body { padding: 24px; }
.wizard-foot { display: flex; justify-content: space-between; padding: 16px 24px; border-top: 1px solid var(--line); background: #fafbfc; }

.bi-field { margin-bottom: 16px; }
.bi-field > label { display: block; font-size: 13px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
.bi-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bi-input { position: relative; }
.bi-input input, .bi-input textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px;
  padding: 10px 13px; font-size: 14.5px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.bi-input input:focus, .bi-input textarea:focus { border-color: var(--p1); box-shadow: 0 0 0 3px rgba(5,150,105,.14); }
.bi-input .bi-tag {
  position: absolute; top: -8px; inset-inline-end: 10px; background: #fff;
  font-size: 10.5px; font-weight: 800; color: var(--muted); padding: 0 6px; border-radius: 4px;
}
.bi-input[data-l="en"] input, .bi-input[data-l="en"] textarea { direction: ltr; }
.bi-input textarea { min-height: 92px; resize: vertical; line-height: 1.6; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

.item-card { border: 1.5px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 14px; position: relative; background: #fff; }
.item-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.item-card-head b { font-size: 14px; color: var(--p1); }
.item-del { border: none; background: #fef2f2; color: var(--danger); border-radius: 8px; padding: 6px 11px; font-size: 12.5px; font-weight: 700; }
.add-item-btn {
  width: 100%; border: 2px dashed var(--line); background: transparent; border-radius: 12px;
  padding: 13px; color: var(--p1); font-size: 14.5px; font-weight: 700; transition: all .15s;
}
.add-item-btn:hover { border-color: var(--p1); background: var(--g-50); }

.level-input { display: flex; align-items: center; gap: 10px; }
.level-input input[type="range"] { flex: 1; accent-color: var(--p1); }
.level-val { font-size: 12.5px; font-weight: 700; color: var(--p1); min-width: 56px; text-align: center; background: var(--g-50); border-radius: 7px; padding: 4px 8px; }

.photo-row { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.photo-preview {
  width: 76px; height: 76px; border-radius: 50%; background: var(--bg);
  border: 2px dashed var(--line); overflow: hidden; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 24px; flex: 0 0 auto;
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }

.save-state { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.save-state.ok { color: var(--ok); }

/* معاينة حية */
.live-preview { position: sticky; top: 86px; }
.live-preview-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.live-preview-head h4 { margin: 0; font-size: 14px; color: var(--muted); }
.live-preview-box {
  border-radius: 14px; overflow: hidden; border: 1px solid var(--line);
  box-shadow: var(--shadow-sm); background: #f1f5f9; direction: ltr; height: 480px;
}
.live-preview-box .scale-host { transform-origin: top left; }

/* ---------- معرض القوالب ---------- */
.gallery-filters { display: flex; gap: 8px; margin-bottom: 22px; flex-wrap: wrap; }
.gallery-filters button {
  border: 1.5px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: 99px; padding: 7px 18px; font-size: 13.5px; font-weight: 700;
}
.gallery-filters button.active { background: var(--grad); color: #fff; border-color: transparent; }
.gallery-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.g-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; transition: transform .2s, box-shadow .2s; cursor: pointer; position: relative; }
.g-card:hover { transform: translateY(-5px); box-shadow: var(--shadow); }
.g-thumb { height: 280px; overflow: hidden; position: relative; background: #f1f5f9; direction: ltr; }
.g-thumb .cv-page { transform: scale(.345); transform-origin: top left; }
.g-thumb::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 72%, rgba(255,255,255,.96)); pointer-events: none; }
.g-info { padding: 12px 15px 15px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.g-info h4 { margin: 0; font-size: 15.5px; }
.g-info small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.g-corner { position: absolute; top: 10px; inset-inline-start: 10px; z-index: 2; display: flex; gap: 6px; }
.data-src-note { margin: 0 0 18px; font-size: 13px; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; display: inline-block; }
.template-watermark { position:absolute; inset:0; z-index:20; display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); grid-template-rows:repeat(10,minmax(0,1fr)); align-items:center; justify-items:center; pointer-events:none; user-select:none; direction:rtl; }
.template-watermark > span { color:rgba(51,65,85,.24); font-family:'Tajawal',sans-serif; font-size:30px; font-weight:800; line-height:1; white-space:nowrap; transform:rotate(-24deg); -webkit-text-stroke:.5px rgba(255,255,255,.3); }
.personal-template-loading { min-height:240px; display:flex; align-items:center; justify-content:center; padding:24px; gap:10px; flex-direction:column; color:var(--muted); font-size:14px; text-align:center; }

/* ---------- صفحة المعاينة ---------- */
.preview-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 26px; align-items: start; }
.preview-stage {
  background:
    radial-gradient(400px 200px at 80% 0%, #dcefe5 0%, transparent 55%),
    #eef1f6;
  border: 1px solid var(--line); border-radius: 18px; padding: 30px; display: flex; justify-content: center;
  min-height: 70vh; overflow: auto;
}
.preview-scale-wrap { direction: ltr; }
.preview-scale-host { transform-origin: top left; }
.preview-scale-host .cv-page { box-shadow: 0 18px 50px -18px rgba(15,23,42,.35); margin-bottom: 24px; }
.preview-side { position: sticky; top: 86px; display: flex; flex-direction: column; gap: 14px; }
.preview-side .card { padding: 20px; }
.preview-side h3 { margin: 0 0 4px; font-size: 19px; }
.preview-side .tpl-desc { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; }
.lang-pick { display: flex; background: var(--bg); border-radius: 11px; padding: 4px; margin-bottom: 14px; }
.lang-pick button { flex: 1; border: none; background: transparent; border-radius: 8px; padding: 9px; font-size: 13.5px; font-weight: 700; color: var(--muted); }
.lang-pick button.active { background: #fff; color: var(--p1); box-shadow: var(--shadow-sm); }
.preview-side .btn { width: 100%; }
.preview-badges { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 12px; }
.lock-note { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 11px; padding: 11px 14px; font-size: 13px; }

/* ---------- الدفع ---------- */
.checkout-tpl { display: flex; align-items: center; gap: 14px; background: var(--bg); border-radius: 14px; padding: 14px; margin-bottom: 18px; }
.checkout-tpl .ct-swatch { width: 46px; height: 60px; border-radius: 7px; flex: 0 0 auto; box-shadow: var(--shadow-sm); }
.checkout-tpl b { display: block; }
.checkout-tpl small { color: var(--muted); }
.checkout-price { margin-inline-start: auto; font-size: 21px; font-weight: 900; color: var(--p1); white-space: nowrap; }
.checkout-tpl .ct-detail { flex:1; min-width:0; }
.purchase-actions { display:grid; grid-auto-rows:1fr; gap:10px; width:100%; }
.purchase-actions > .btn { width:100%; }
.apple-pay-button { -webkit-appearance:-apple-pay-button; -apple-pay-button-type:plain; -apple-pay-button-style:black; display:block; width:100%; height:100%; min-height:30px; border:0; border-radius:10px; padding:0; cursor:pointer; color:transparent; background:#000; }
.apple-pay-button:focus-visible { outline:3px solid var(--gold); outline-offset:3px; }
.apple-pay-button:disabled { opacity:.55; cursor:wait; }
.builder-locked .purchase-actions { max-width:320px; margin-inline:auto; }
.checkout-price { flex:0 0 auto; }
.checkout-coupon { margin-bottom:18px; }
.checkout-coupon label { display:block; margin-bottom:6px; font-size:14px; font-weight:700; }
.checkout-coupon-row { display:flex; gap:8px; }
.checkout-coupon-row input { min-width:0; flex:1; min-height:44px; font-size:16px; }
.checkout-coupon-row input:disabled { background:#f1f5f3; color:var(--muted); cursor:not-allowed; }
.checkout-coupon-row button { min-height:44px; }
.preview-price { margin:0 0 16px; }
.demo-note { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 11px; padding: 10px 14px; font-size: 12.5px; margin-bottom: 16px; }
.card-visual {
  background: linear-gradient(120deg, #1e293b, #334155); border-radius: 16px; color: #fff;
  padding: 18px 20px; margin-bottom: 18px; font-family: monospace; position: relative; overflow: hidden;
}
.card-visual::after { content: ''; position: absolute; width: 130px; height: 130px; border-radius: 50%; background: rgba(255,255,255,.07); top: -50px; inset-inline-end: -30px; }
.card-visual .cv-num { font-size: 17px; letter-spacing: 2px; direction: ltr; text-align: left; margin: 14px 0 10px; }
.card-visual .cv-meta { display: flex; justify-content: space-between; font-size: 12px; opacity: .85; direction: ltr; }
.pay-success { text-align: center; padding: 20px 0; }
.pay-success .ps-ic {
  width: 74px; height: 74px; margin: 0 auto 16px; border-radius: 50%;
  background: #ecfdf5; color: var(--ok); font-size: 34px;
  display: flex; align-items: center; justify-content: center;
  animation: popIn .4s cubic-bezier(.2,1.4,.4,1);
}

/* قصاصات احتفال */
.confetti { position: fixed; top: -12px; z-index: 3000; width: 9px; height: 15px; border-radius: 2px; animation: confettiFall linear forwards; pointer-events: none; }
@keyframes confettiFall { to { transform: translateY(105vh) rotate(660deg); opacity: .9; } }

/* ---------- الاستوديو ---------- */
.builder-page { max-width: 1500px; margin: 0 auto; padding: 18px 16px 40px; }
.builder-topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.builder-topbar h2 { margin: 0; font-size: 20px; }
.builder-grid { display: grid; grid-template-columns: 250px minmax(0, 1fr) 250px; gap: 16px; align-items: start; }
.builder-panel { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px; position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow: auto; }
.builder-panel h4 { margin: 0 0 12px; font-size: 13.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.builder-panel h4:not(:first-child) { margin-top: 20px; }
.palette-list { display: flex; flex-direction: column; gap: 7px; }
.palette-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: 1.5px solid var(--line); background: #fff; border-radius: 11px;
  padding: 9px 12px; font-size: 13.5px; font-weight: 700; color: var(--ink-2);
  cursor: grab; transition: all .15s; text-align: start;
}
.palette-item:hover { border-color: var(--p1); color: var(--p1); background: var(--g-50); transform: translateX(-2px); }
html[dir="ltr"] .palette-item:hover { transform: translateX(2px); }
.palette-item:active { cursor: grabbing; }

.b-set { margin-bottom: 14px; }
.b-set > label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-2); margin-bottom: 7px; }
.seg { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; }
.seg button { flex: 1; border: none; background: transparent; border-radius: 8px; padding: 7px 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
.seg button.active { background: #fff; color: var(--p1); box-shadow: var(--shadow-sm); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button { width: 28px; height: 28px; border-radius: 50%; border: 2.5px solid transparent; outline: 2px solid transparent; transition: all .15s; }
.swatches button.active { border-color: #fff; outline-color: var(--ink); }
.variant-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.v-btn { border: 1.5px solid var(--line); background: #fff; border-radius: 9px; padding: 8px 6px; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.v-btn.active { border-color: var(--p1); background: var(--g-50); color: var(--p1); }
.b-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.b-actions .btn { width: 100%; }

.builder-canvas {
  background: #eef1f6; border: 1px solid var(--line); border-radius: 16px;
  padding: 20px; overflow: auto; max-height: calc(100vh - 100px); direction: ltr;
}
.canvas-scale { transform-origin: top left; margin: 0 auto; }
.canvas-scale { position: relative; }
.canvas-scale > .cv-page { position: absolute; top: 0; left: 0; transform-origin: top left; }
.app-nav, .app-user, .preview-layout > *, .builder-grid > * { min-width: 0; }
.app-nav a { white-space: nowrap; }
@media (max-width: 700px) {
  .app-header-inner { height: auto; min-height: 62px; padding: 10px 12px; flex-wrap: wrap; gap: 8px; }
  .app-header-inner > .logo { margin-inline-end: auto; }
  .app-nav { order: 4; flex: 1 0 100%; overflow-x: auto; padding-bottom: 3px; }
  .app-nav a { flex-shrink: 0; }
  .user-chip { display: none; }
  .app-user { gap: 4px; }
}
.canvas-scale .cv-page { box-shadow: 0 14px 40px -16px rgba(15,23,42,.3); }

/* الويدجت داخل الكانفس */
.bw { position: relative; cursor: pointer; border-radius: 4px; transition: outline-color .12s; outline: 2px dashed transparent; outline-offset: 3px; }
.bw:hover { outline-color: #bfe0d2; }
.bw.selected { outline: 2px solid var(--p1); }
.bw.dragging { opacity: .4; }
.bw.drop-before::before, .bw.drop-after::after {
  content: ''; position: absolute; left: 0; right: 0; height: 3px; background: var(--p1); border-radius: 3px; z-index: 5;
}
.bw.drop-before::before { top: -5px; }
.bw.drop-after::after { bottom: -5px; }
.bw-empty { padding: 14px; text-align: center; color: var(--muted); background: #f8fafc; border-radius: 8px; font-size: 12px; }

.builder-locked { text-align: center; padding: 70px 24px; }
.builder-locked .bl-ic { font-size: 52px; margin-bottom: 14px; }

/* ---------- استجابة ---------- */
@media (max-width: 1150px) {
  .gallery-grid { grid-template-columns: repeat(3, 1fr); }
  .owned-grid { grid-template-columns: repeat(3, 1fr); }
  .builder-grid { grid-template-columns: 210px minmax(0, 1fr) 220px; }
}
@media (max-width: 960px) {
  .editor-layout { grid-template-columns: 1fr; }
  .live-preview { display: none; }
  .preview-layout { grid-template-columns: 1fr; }
  .preview-side { position: static; }
  .dash-grid { grid-template-columns: 1fr; }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
  .owned-grid { grid-template-columns: repeat(2, 1fr); }
  .builder-grid { grid-template-columns: 1fr; }
  .builder-panel { position: static; max-height: none; }
}
@media (max-width: 600px) {
  .gallery-grid { grid-template-columns: 1fr; }
  .owned-grid { grid-template-columns: 1fr; }
  .bi-inputs { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .app-nav { overflow-x: auto; }
}

/* Studio controls stay full size, outside the scaled A4 preview. */
.studio-toolbar { display:grid; grid-template-columns:repeat(2,minmax(130px,1fr)) minmax(260px,2fr) minmax(200px,1.5fr); gap:18px; background:#fff; border:1px solid var(--line); border-radius:16px; padding:20px; margin-bottom:18px; align-items:start; }
.studio-toolbar .b-set { margin:0; }
.studio-toolbar select,.widget-inline-settings select { width:100%; min-height:44px; border:1px solid var(--line); border-radius:9px; padding:8px; background:#fff; font:inherit; font-size:16px; }
.studio-toolbar label,.widget-inline-settings label { font-size:14px; line-height:1.6; }
.studio-toolbar input[type="range"],.widget-inline-settings input[type="range"] { width:100%; min-height:44px; accent-color:var(--g-700); }
.studio-toolbar output,.widget-inline-settings output { float:inline-end; font-variant-numeric:tabular-nums; }
.studio-toolbar .swatches { display:flex; flex-wrap:wrap; gap:8px; }
.studio-toolbar .swatches button { width:32px; height:32px; min-width:32px; border:2px solid #d4dfda; border-radius:50%; }
.studio-toolbar .swatches .active { outline:2px solid var(--g-700); outline-offset:2px; }
.studio-toolbar .swatches .custom-color-toggle { background:var(--g-50); color:var(--g-800); border-color:#b8cfc2; font-size:19px; display:grid; place-items:center; }
.studio-toolbar .swatches .custom-color-toggle[aria-expanded="true"] { background:var(--g-100); outline:2px solid var(--g-700); outline-offset:2px; }
.custom-color-panel:not([hidden]) { display:grid; grid-template-columns:70px minmax(0,1fr); gap:10px; margin-top:12px; padding:12px; border-radius:10px; background:var(--g-50); }
.custom-color-panel label { display:block; font-size:12px; }
.custom-color-panel input { width:100%; height:44px; padding:4px; font:inherit; font-size:16px; border:1px solid var(--line); border-radius:8px; background:#fff; }
.custom-color-panel small { grid-column:1 / -1; color:#a12626; }
.builder-grid.studio-grid { grid-template-columns:340px minmax(0,1fr); }
.studio-grid .builder-panel { padding:16px; }
.widget-panel-heading { display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; }
.widget-panel-heading h4 { margin:0; }
.widget-panel-heading button { min-height:44px; }
.studio-grid .builder-canvas { padding:16px; }
.widget-accordion { border:1px solid var(--line); border-radius:12px; margin-top:9px; overflow:hidden; }
.widget-accordion.is-open { border-color:var(--g-600); box-shadow:0 3px 12px #06352a0d; }
.widget-row { display:flex; align-items:center; gap:2px; padding-inline-start:8px; background:#fff; }
.widget-row .widget-toggle { min-width:0; flex:1; width:auto; padding-inline-start:8px; }
.widget-drag-handle { flex:0 0 36px; width:36px; height:36px; display:grid; place-items:center; border:1px solid #d4dfda; border-radius:7px; background:#f5f8f6; color:#60766b; cursor:grab; touch-action:none; user-select:none; -webkit-user-select:none; }
.widget-drag-handle>span { display:grid; grid-template-columns:repeat(2,3px); gap:3px; }
.widget-drag-handle i { width:3px; height:3px; border-radius:50%; background:currentColor; }
.widget-drag-handle:focus-visible { outline:2px solid var(--g-600); outline-offset:2px; }
.widget-drag-handle:active { cursor:grabbing; }
.widget-accordion.is-dragging { opacity:.35; }
.widget-accordion.is-dragging .widget-inline-settings { display:none; }
.widget-accordion:is(.drop-before,.drop-after) { position:relative; overflow:visible; }
.widget-accordion.drop-before::before,.widget-accordion.drop-after::after { content:""; position:absolute; inset-inline:0; height:3px; border-radius:2px; background:var(--g-600); pointer-events:none; z-index:2; }
.widget-accordion.drop-before::before { top:-6px; }
.widget-accordion.drop-after::after { bottom:-6px; }
.widget-drag-ghost { position:fixed; z-index:1000; pointer-events:none; padding-inline:8px 0; border:1px solid var(--g-600); border-radius:10px; background:#fff; box-shadow:0 12px 36px #06352a35; }
.widget-order-status { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
.is-open .widget-row { background:var(--g-50); }
.widget-toggle { width:100%; display:flex; align-items:center; gap:10px; border:0; padding:14px; background:#fff; color:var(--ink); font:inherit; font-weight:700; text-align:start; min-height:50px; }
.widget-toggle span { flex:1; }
.is-open .widget-toggle { background:var(--g-50); }
.is-open .widget-toggle>i:last-child { transform:rotate(180deg); }
.widget-inline-settings { padding:16px; border-top:1px solid var(--line); animation:widgetExpand .18s ease-out; }
.widget-inline-settings .v-btn { min-height:44px; font-size:14px; }
.header-fill-toggle { display:flex; align-items:center; justify-content:space-between; gap:12px; width:100%; min-height:44px; padding:10px 12px; border:1px solid var(--line); border-radius:9px; background:#fff; color:var(--ink); font:inherit; font-size:14px; text-align:start; cursor:pointer; }
.header-fill-toggle i { flex:0 0 36px; height:22px; border-radius:20px; background:#cbd5d1; position:relative; }
.header-fill-toggle i::after { content:""; position:absolute; top:3px; inset-inline-start:3px; width:16px; height:16px; border-radius:50%; background:#fff; }
.header-fill-toggle[aria-checked="true"] { border-color:var(--g-600); background:var(--g-50); }
.header-fill-toggle[aria-checked="true"] i { background:var(--g-700); }
.header-fill-toggle[aria-checked="true"] i::after { inset-inline-start:17px; }
.header-fill-toggle:focus-visible { outline:2px solid var(--g-600); outline-offset:2px; }
.widget-inline-settings .b-actions { display:flex; flex-wrap:wrap; gap:8px; }
.widget-inline-settings .b-actions button { min-height:44px; }
.widget-add-list { display:grid; gap:8px; margin-top:14px; }
.widget-add-list button { min-height:46px; font-size:14px; cursor:pointer; }
.widget-add-list span { margin-inline-start:auto; }
.studio-mobile-tabs { display:none; }
.widget-mobile-preview { display:none; }
@keyframes widgetExpand { from{opacity:0;transform:translateY(-6px)}to{opacity:1;transform:translateY(0)} }
@media(prefers-reduced-motion:reduce) { .widget-inline-settings { animation:none; } }
@media(max-width:1100px) { .studio-toolbar { grid-template-columns:1fr 1fr; } .builder-grid.studio-grid { grid-template-columns:300px minmax(0,1fr); } }
@media(max-width:760px) {
 .builder-page { padding:14px 12px 30px; }
 .studio-toolbar { padding:14px; gap:14px; }
 .studio-colors,.studio-font { grid-column:1 / -1; }
 .builder-grid.studio-grid { display:block; }
 .studio-grid .builder-panel { position:static; max-height:none; }
 .studio-mobile-tabs { display:flex; position:sticky; top:0; z-index:5; padding:6px; border-radius:12px; background:#e7f0eb; margin-bottom:12px; gap:6px; }
 .studio-mobile-tabs button { flex:1; min-height:44px; border:0; border-radius:9px; background:transparent; font:inherit; font-weight:700; }
 .studio-mobile-tabs button.active { background:#fff; color:var(--g-800); box-shadow:0 2px 4px #0001; }
 .studio-grid[data-view="edit"] #bCanvas,.studio-grid[data-view="preview"] #bPalette { display:none; }
 .studio-grid .builder-canvas { max-height:none; overflow:hidden; }
 .widget-mobile-preview { display:block; margin-top:16px; padding-top:14px; border-top:1px solid var(--line); }
 .widget-preview-label { margin:0 0 8px; font-size:14px; font-weight:700; color:var(--ink-2); }
 .widget-accordion { scroll-margin-top:110px; }
 .widget-settings-controls { max-height:300px; max-height:min(36svh,300px); overflow:auto; overflow-x:hidden; padding:2px; }
 .studio-grid[data-view="edit"] #bCanvas.is-widget-preview { display:block; padding:8px; border-radius:10px; max-height:280px; max-height:min(34svh,280px); overflow:auto; }
}

/* Month and year selectors provide the same date interaction on phone and desktop. */
.experience-dates { display:grid; grid-template-columns:1fr 1fr; gap:16px; background:#f5f8f6; padding:18px; border:1px solid var(--line); border-radius:14px; margin:12px 0 20px; }
.date-field { border:0; padding:0; margin:0; min-width:0; }
.date-field legend { font-weight:700; font-size:14px; padding:0; margin-bottom:8px; }
.date-selects { display:grid; grid-template-columns:minmax(0,1.3fr) minmax(0,1fr); gap:8px; }
.date-selects select,.year-field select { width:100%; min-height:48px; padding:10px; font:inherit; font-size:16px; border:1px solid #cddbd3; border-radius:10px; background:#fff; color:var(--ink); }
.date-selects select:focus { outline:2px solid var(--g-600); outline-offset:2px; }
.date-field:disabled { opacity:.5; }
.current-job-toggle { grid-column:1 / -1; display:flex; align-items:center; gap:10px; font-size:15px; cursor:pointer; }
.current-job-toggle input { width:20px; height:20px; accent-color:var(--g-700); }
.date-feedback { grid-column:1 / -1; font-size:14px; color:var(--muted); margin:0; }
.date-feedback.is-error { color:#a12626; }
@media(max-width:600px) { .experience-dates { grid-template-columns:1fr; padding:14px; } .item-card { padding:16px; border-radius:14px; } }

/* Shared profile photo editor and My Canvas entry point. */
.personal-hints { display:flex; align-items:flex-start; gap:10px; margin-bottom:18px; line-height:1.8; }
.personal-hints>i { flex:none; font-size:19px; padding-top:2px; }.personal-hints ul { margin:0; padding-inline-start:18px; }.personal-hints li+li { margin-top:6px; }
.photo-actions { display:flex; align-items:center; flex-wrap:wrap; gap:8px; }.photo-actions .btn { min-height:44px; }
.canvas-photo-edit { width:100%; display:flex; align-items:center; gap:12px; text-align:start; padding:13px; margin:0 0 16px; border:1px solid #cdded4; background:#f3f8f5; border-radius:14px; color:#06352a; font:inherit; cursor:pointer; }
.canvas-photo-edit>i:first-child { display:grid; place-items:center; width:42px; height:42px; border-radius:12px; background:#e0eee6; font-size:22px; }
.canvas-photo-edit span { flex:1; font-weight:700; }.canvas-photo-edit small { display:block; margin-top:3px; font-size:12px; font-weight:400; color:#53685c; }
.canvas-photo-dialog { width:min(780px,calc(100% - 32px)); max-height:calc(100dvh - 32px); padding:0; border:1px solid #d4e1d8; border-radius:24px; box-shadow:0 28px 90px #03261e40; color:var(--ink); background:#fff; overflow:auto; }
.canvas-photo-dialog::backdrop { background:#04291fe0; backdrop-filter:blur(6px); }
.photo-editor-head { display:flex; align-items:flex-start; gap:20px; padding:22px 24px 18px; border-bottom:1px solid #e4ece7; }.photo-editor-head>div{flex:1;}
.photo-editor-head h2 { margin:0 0 6px; font-size:23px; color:#06352a; }.photo-editor-head p { margin:0; max-width:510px; color:#65766b; font-size:14px; line-height:1.7; }
.photo-editor-head button { flex:none; width:44px; height:44px; border:0; border-radius:50%; background:#f0f5f2; color:#06352a; font-size:24px; cursor:pointer; }
.photo-editor-body { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,.95fr); gap:24px; padding:24px; }
.photo-stage { min-height:300px; display:flex; align-items:center; justify-content:center; background:radial-gradient(ellipse,#e8efeb,#f6f8f7); border:1px solid #e0e8e2; border-radius:20px; overflow:hidden; position:relative; }
.photo-crop-frame { position:relative; flex:none; border-radius:50%; overflow:hidden; box-shadow:0 0 0 5px #fff,0 12px 35px #06352a24; cursor:grab; touch-action:none; direction:ltr; user-select:none; }
.photo-crop-frame.is-moving { cursor:grabbing; }.photo-crop-frame:focus-visible { outline:3px solid #d6b25e; outline-offset:6px; }
.photo-crop-frame img { display:block; width:100%; height:100%; object-fit:cover; pointer-events:none; }
.photo-guide { position:absolute; inset:0; pointer-events:none; opacity:0; background:linear-gradient(90deg,transparent 33%,#ffffff70 33%,#ffffff70 calc(33% + 1px),transparent calc(33% + 1px),transparent 66%,#ffffff70 66%,#ffffff70 calc(66% + 1px),transparent calc(66% + 1px)),linear-gradient(transparent 33%,#ffffff70 33%,#ffffff70 calc(33% + 1px),transparent calc(33% + 1px),transparent 66%,#ffffff70 66%,#ffffff70 calc(66% + 1px),transparent calc(66% + 1px)); }
.photo-crop-frame.is-moving .photo-guide { opacity:1; }.photo-empty{padding:20px;text-align:center;color:#63776a;}
.photo-editor-controls { display:flex; flex-direction:column; gap:18px; }
.photo-upload { display:flex; align-items:center; justify-content:center; gap:8px; min-height:48px; border:1px dashed #a7bfb0; border-radius:12px; background:#f5f9f6; font-size:15px; font-weight:700; cursor:pointer; position:relative; }
.photo-upload input { position:absolute; inset:0; opacity:0; width:100%; cursor:pointer; }.photo-upload:focus-within{outline:2px solid #047857;outline-offset:2px;}
.photo-zoom-row { display:flex; align-items:center; gap:10px; }.photo-zoom-row label { flex:1; }.photo-zoom-row output { float:inline-end; direction:ltr; font-size:13px; color:#557461; }
.photo-zoom-row button { width:44px; height:44px; border:1px solid #d5e2d9; background:#fff; border-radius:12px; font-size:24px; color:#06352a; cursor:pointer; }
.photo-editor-controls label { color:#294537; font-size:14px; font-weight:700; }
.photo-editor-controls input[type=range] { display:block; width:100%; height:32px; accent-color:#047857; cursor:pointer; }
.photo-dimensions { display:grid; grid-template-columns:1fr 1fr; gap:12px; }.photo-dimensions label>div { display:flex; align-items:center; border:1px solid #cdded4; border-radius:10px; margin-top:8px; padding-inline-end:12px; }
.photo-dimensions input { min-width:0; width:100%; min-height:46px; border:0; border-radius:10px; font:inherit; font-size:16px; padding:10px; direction:ltr; color:#06352a; background:transparent; }.photo-dimensions span{font-weight:400;color:#6b7e71;}
.photo-position-sliders { display:grid; gap:10px; }.photo-reset { align-self:flex-start; border:0; padding:4px 0; background:none; color:#3d6651; text-decoration:underline; text-underline-offset:4px; font:inherit; font-size:13px; cursor:pointer; min-height:32px; }
.photo-error { min-height:0; margin:0; font-size:13px; color:#a12626; }.photo-error:empty{display:none;}
.photo-editor-foot { display:flex; justify-content:flex-end; gap:12px; padding:18px 24px; border-top:1px solid #e4ece7; background:#fff; position:sticky; bottom:0; z-index:2; }.photo-editor-foot .btn{min-height:46px;}
@media(max-width:600px) {
  .canvas-photo-dialog { width:calc(100% - 20px); max-height:calc(100dvh - 20px); border-radius:20px; }
  .photo-editor-head{padding:18px 16px 14px;gap:10px;}.photo-editor-head h2{font-size:20px;}.photo-editor-head p{font-size:13px;}
  .photo-editor-body{grid-template-columns:1fr;gap:20px;padding:16px;}.photo-stage{min-height:255px;}.photo-editor-controls{gap:16px;}.photo-position-sliders{grid-template-columns:1fr 1fr;gap:16px;}
  .photo-editor-foot{padding:14px 16px;}.photo-editor-foot .btn{flex:1;}
}
