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

.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; direction: rtl;
}
.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;
}
.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-name-fields { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:12px; }
.auth-name-fields .field { min-width:0; }
.auth-optional { font-size:11px; font-weight:400; color:var(--muted); margin-inline-start:3px; }
@media(max-width:760px){.auth-card .field input:not(.otp-input){font-size:16px;}}
@media(max-width:380px){.auth-name-fields{grid-template-columns:1fr;gap:0;}}
.auth-card .signup-policy { font-size:12.5px; line-height:1.8; margin:12px 0 0; text-align:center; white-space:normal; }
.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-google { width:100%; min-height:44px; display:flex; align-items:center; justify-content:center; gap:12px; padding:11px 14px; background:#fff; color:#1f1f1f; border:1px solid #dadce0; border-radius:10px; font-family:inherit; font-size:15px; font-weight:700; line-height:1.4; cursor:pointer; }
.auth-google img { width:20px; height:20px; flex-shrink:0; }
.auth-google:hover { background:#f8faf9; border-color:#a8b9b0; }
.auth-google:focus-visible { outline:3px solid #a9c5b6; outline-offset:3px; }
.auth-google:disabled { opacity:.65; cursor:wait; }
.auth-divider { display:flex; align-items:center; gap:12px; margin:18px 0; color:var(--muted); font-size:13px; }
.auth-divider::before,.auth-divider::after { content:""; flex:1; height:1px; background:var(--line,#e5e7eb); }
.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-spam[hidden]{display:none}
.otp-delivery{margin:12px 0 18px}.otp-resend-row{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}.otp-countdown{color:var(--muted);font-size:12.5px;line-height:1.8}.otp-countdown bdi{color:var(--p1);font-weight:700;font-variant-numeric:tabular-nums}.auth-card .otp-resend{width:auto;margin:0;padding:7px 10px;min-height:40px;font-size:13px}.otp-resend:disabled{color:var(--muted);cursor:default;opacity:.55}.otp-spam{display:flex;align-items:flex-start;gap:8px;padding:12px 13px;background:#f5f8f2;border:1px solid #e0e8da;border-radius:10px;color:#637363;font-size:12.5px;line-height:1.85;margin:10px 0 0}.otp-spam i{color:#ac8744;font-size:17px;line-height:1.45}.otp-success{color:#116348;font-size:14px;line-height:1.8}.otp-error{color:#a33c37;font-size:14px;line-height:1.8}.auth-existing-links{display:flex;align-items:center;gap:14px;flex-wrap:wrap;margin-top:12px}.auth-existing-links a{font-weight:700;text-underline-offset:4px;color:var(--p1)}

.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(3, minmax(0, 1fr)); gap: 26px; }
.owned-empty { padding: 36px; text-align: center; color: var(--muted); }

/* ---------- محرر البيانات ---------- */
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; grid-template-areas: 'form preview'; gap: 24px; align-items: start; }
.editor-layout > .wizard-card { grid-area: form; }
.editor-layout > .live-preview { grid-area: preview; }
.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); }

.skill-suggestions { background: var(--g-50); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 20px; }
.skill-suggestions h3 { margin: 0 0 12px; color: var(--p1); font-size: 14px; font-weight: 800; }
.skill-suggestions-list { display: flex; flex-wrap: wrap; gap: 8px; }
.skill-suggestion {
  display: inline-flex; align-items: center; gap: 7px; max-width: 100%; min-height: 44px;
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: #fff;
  color: var(--p1); font: inherit; font-size: 13px; font-weight: 700; text-align: start;
  transition: border-color .15s, background-color .15s;
}
.skill-suggestion i { flex-shrink: 0; font-size: 16px; }
.skill-suggestion span { min-width: 0; overflow-wrap: anywhere; }
.skill-suggestion:not(:disabled):hover { border-color: var(--p1); }
.skill-suggestion:focus-visible { outline: 2px solid var(--p1); outline-offset: 3px; }
.skill-suggestion:disabled { background: var(--g-50); color: var(--muted); cursor: default; }

.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-save:empty { display: none; }
.live-preview-save:not(:empty) { display: flex; margin-bottom: 8px; }
.live-preview-open { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 0; border: 0; background: transparent; color: var(--g-800); font: inherit; font-weight: 700; cursor: pointer; }
.live-preview-open i { font-size: 19px; }
.live-preview-zoom { display: flex; align-items: center; gap: 4px; direction: ltr; }
.live-preview-zoom button, .live-preview-close { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--g-800); font: inherit; font-size: 25px; cursor: pointer; }
.live-preview-zoom button:disabled { opacity: .35; cursor: default; }
.live-preview-zoom output { min-width: 42px; text-align: center; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.live-preview-open:focus-visible, .live-preview-zoom button:focus-visible, .live-preview-close:focus-visible { outline: 2px solid var(--g-700); outline-offset: 3px; }
.wizard-preview-shortcut, .wizard-preview-slot:empty { display: none; }
.live-preview-box {
  border-radius: 14px; overflow: auto; border: 1px solid var(--line); overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-sm); background: #f1f5f9; direction: ltr; height: 480px; position: relative;
}
.live-preview-surface { display: flex; align-items: center; justify-content: center; padding: 8px; min-width: 100%; min-height: 100%; }
.live-preview-sheet { position: relative; flex: none; overflow: hidden; background: #fff; box-shadow: 0 4px 18px #06352a15; }
.live-preview-box .scale-host { position: absolute; top: 0; left: 0; transform-origin: top left; }
.live-preview-dialog { width: 100%; height: 100vh; height: 100dvh; max-width: none; max-height: none; inset: 0; margin: 0; padding: 0; border: 0; background: #eef3f0; color: var(--ink); overflow: hidden; }
.live-preview-dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); }
.live-preview-dialog::backdrop { background: #04291fe0; }
.live-preview-dialog-head { display: flex; align-items: center; gap: 12px; padding: calc(10px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left)); border-bottom: 1px solid var(--line); background: #fff; }
.live-preview-dialog-head h2 { flex: 1; margin: 0; font-size: 18px; }
.live-preview-dialog .live-preview-box { height: 100%; min-height: 0; border: 0; border-radius: 0; box-shadow: none; background: #eef3f0; }
body:has(> .live-preview-dialog[open]) { overflow: hidden; }

/* ---------- معرض القوالب ---------- */
.gallery-filters { display: flex; gap: 8px; margin-bottom: 22px; flex-wrap: wrap; }
.gallery-filters button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
  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-filters [data-f="canvas"] i { color: var(--gold, #b08a2e); }
@media(max-width:480px) { .gallery-filters button { padding-inline:12px; } }
.gallery-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 26px; }
.g-card { background: #fff; border: 1px solid #e0e7e0; border-radius: 13px; overflow: hidden; display: flex; flex-direction: column; min-width: 0; position: relative; cursor: pointer; }
.g-paper { position: relative; flex: none; }
.g-thumb { width: 100%; aspect-ratio: 210 / 208; border-bottom:1px solid #c6d8ce; overflow: hidden; position: relative; background: #fff; direction: ltr; cursor: zoom-in; }
.g-thumb .cv-page { position: absolute; top: 0; left: 0; margin: 0; box-shadow: none; transform: scale(var(--g-page-scale, .5)); transform-origin: top left; }
.g-thumb > .cv-page ~ .cv-page { display: none; }
.g-thumb .canvas-demo-page { height: 100%; }
.g-thumb .personal-template-loading { min-height: 0; height: 100%; }
.g-model-controls .canvas-demo-controls { margin: 0; }
.g-card-body { padding: 20px 22px; flex: 1; display: flex; flex-direction: column; }
.g-info { display: block; color: inherit; }
.g-card-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.g-card-title h3 { margin: 0; font-size: 21px; font-weight: 800; }
.g-card-type { flex: none; font-size: 10px; font-weight: 500; padding: 3px 7px; border-radius: 5px; color: #7c7e66; background: #f6f2e8; }
.g-card-type.is-free { color: #46715b; background: #eaf3ed; }
.g-card-type.is-hybrid { color: #536480; background: #edf0f5; }
.g-card-description { margin: 0; min-height: 41px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.g-card-features { list-style: none; padding: 0; margin: 16px 0 20px; display: grid; gap: 7px; }
.g-card-features li { display: flex; gap: 7px; align-items: baseline; font-size: 12px; line-height: 1.55; }
.g-card-features li::before { content: '✓'; color: #047857; font-weight: 700; flex: none; }
.g-card-body .template-offer { margin: 0 0 12px; padding: 8px 10px; font-size: 12px; }
.g-card-body .ats-learn-link { align-self: flex-start; margin: 0 0 15px; font-size: 13px; }
.g-card-bottom { margin-top: auto; padding-top: 15px; border-top: 1px solid #eaf0e9; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.g-card-bottom .template-price { column-gap: 8px; row-gap: 1px; padding: 0; border: 0; border-radius: 0; background: none; }
.g-card-bottom .template-price strong { font-size: 22px; }
.g-card-bottom .template-price del { font-size: 12px; color: #8b9690; }
.g-card-bottom .badge-free { padding: 0; border: 0; background: none; color: var(--g-900); font-size: 23px; font-weight: 800; }
.g-preview-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; flex: none; min-height: 40px; padding: 7px 12px; border: 1px solid #06352a; border-radius: 8px; background: #06352a; color: #fff; font-size: 12px; font-weight: 700; }
.g-preview-button i { font-size: 16px; }
.g-preview-button:hover { background: #114b3d; border-color: #114b3d; }
.g-preview-eye { position: absolute; top: 12px; inset-inline-end: 12px; z-index: 3; display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid #d7e6df; border-radius: 50%; background: #fff; color: #06352a; box-shadow: 0 4px 15px #06352a24; font-size: 22px; touch-action: manipulation; }
@media (hover: hover) and (pointer: fine) {
  .g-preview-eye:hover { background: #06352a; color: #fff; }
}
.g-preview-eye:focus-visible, .g-preview-button:focus-visible { outline: 3px solid #d6b25e; outline-offset: 3px; }
.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; scroll-margin-top: 86px; }
.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%; }
.studio-offer .preview-side { scroll-margin-top:90px; }
.preview-badges { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 12px; }

/* ---------- الدفع ---------- */
/* Checkout styles are scoped to this dialog. */

.purchase-result {
  position: fixed; margin: auto; width: min(410px, calc(100% - 28px)); max-height: calc(100dvh - 28px);
  padding: 28px 22px 22px; border: 1px solid #d6e8de; border-radius: 20px;
  background: #fff; color: #183c31; box-shadow: 0 24px 66px rgba(9, 33, 26, .24);
  text-align: center; overflow: auto; animation: purchase-result-open 220ms ease both;
}
.purchase-result::backdrop { background: rgba(7, 28, 23, .55); animation: checkout-fade-in 180ms ease both; }
.purchase-result.is-closing { animation: purchase-result-open 180ms ease both reverse; pointer-events: none; }
.purchase-result.is-closing::backdrop { animation: checkout-fade-in 180ms ease both reverse; }
.purchase-result [hidden] { display: none !important; }
.purchase-result-close {
  position: absolute; inset-block-start: 8px; inset-inline-end: 8px; display: grid; place-items: center;
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 12px; color: #31564a;
  background: transparent; cursor: pointer; font-size: 27px; line-height: 1;
}
.purchase-result-close:hover, .purchase-result-number button:hover { background: #e8f3ed; }
.purchase-result h2 { margin: 16px 12px 8px; font-size: clamp(19px, 4vw, 23px); line-height: 1.45; }
.purchase-result-dots { display: inline-flex; gap: .04em; margin-inline-start: .2em; }
.purchase-result-dots span { animation: purchase-result-dot 1.2s steps(1, end) infinite; }
.purchase-result-dots span:nth-child(2) { animation-delay: .2s; }
.purchase-result-dots span:nth-child(3) { animation-delay: .4s; }
.purchase-result-mark {
  display: grid; place-items: center; width: 62px; height: 62px; margin: 4px auto 0;
  border-radius: 17px; background: #e7f5ed; color: #087653;
}
.purchase-result-mark svg { width: 37px; height: 37px; }
.purchase-result-mark path {
  stroke: currentColor; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1; stroke-dashoffset: 0; animation: purchase-result-draw 420ms 90ms ease-out both;
}
.purchase-result-status { margin: 0 auto 13px; font-size: 14px; line-height: 1.55; color: #456257; }
.purchase-result-status:empty { display: none; }
.purchase-result-number {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 14px 0; padding: 1px 8px; border-radius: 10px; background: #f1f7f3; font-size: 14px;
}
.purchase-result-number bdi { font-size: 16px; font-weight: 800; user-select: text; font-variant-numeric: tabular-nums; }
.purchase-result-number button {
  display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 9px;
  background: transparent; color: #11674d; font-size: 17px; cursor: pointer;
}
.purchase-result .btn { display: flex; justify-content: center; align-items: center; width: 100%; min-height: 44px; margin-top: 8px; }
.purchase-result :focus-visible { outline: 2px solid #087653; outline-offset: 2px; }
@keyframes purchase-result-open {
  from { opacity: 0; transform: translateY(7px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes purchase-result-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes purchase-result-dot { 0%, 60% { opacity: 1; } 61%, 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .purchase-result, .purchase-result::backdrop, .purchase-result-mark path, .purchase-result-dots span { animation: none !important; }
  .modal-backdrop, .modal, .toast { animation: none; }
}

.checkout-backdrop {
  padding: 20px;
  background: rgba(7, 28, 23, .55);
  bottom: auto;
  height: var(--seerti-checkout-window, 100svh);
  animation: checkout-fade-in 180ms ease both;
}
.checkout-modal {
  width: min(100%, 540px);
  max-width: none;
  max-height: calc(100vh - 40px);
  max-height: calc(var(--seerti-checkout-window, 100svh) - 40px);
  padding: 24px;
  border: 1px solid #dce7e1;
  border-radius: 24px;
  color: #17372e;
  background: #fff;
  box-shadow: 0 24px 72px rgba(9, 39, 30, .24);
  overflow: auto;
  overscroll-behavior: contain;
  scroll-padding-block: 12px;
  overflow-anchor: none;
  animation: checkout-slide-in 200ms cubic-bezier(.2,.7,.25,1) both;
}
.checkout-backdrop[hidden], .checkout-modal [hidden] { display: none !important; }
.checkout-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.checkout-eyebrow { margin: 0 0 3px; color: #28745d; font-size: 13px; font-weight: 800; }
.checkout-modal #checkoutTitle { margin: 0; font-size: clamp(22px, 4vw, 27px); line-height: 1.3; font-weight: 900; }
.checkout-close {
  flex: none; display: grid; place-items: center; width: 42px; height: 42px; padding: 0;
  border: 1px solid #e0e9e4; border-radius: 12px; background: #f7faf8; color: #37574c; font-size: 25px; line-height: 1;
}
.checkout-close:hover { color: #104c39; background: #eaf4ee; }
.checkout-modal :is(button, input, a):focus-visible { outline: 2px solid #168465; outline-offset: 2px; }
.checkout-tpl {
  display: flex; align-items: center; gap: 14px; padding: 12px;
  border: 1px solid #e2eae5; border-radius: 16px; background: #f7faf8;
}
.checkout-thumb { flex: none; width: 64px; height: 78px; object-fit: cover; object-position: top; border: 1px solid #d8e3dc; border-radius: 9px; background: #fff; }
.checkout-tpl .ct-detail { min-width: 0; }
.checkout-tpl b { display: block; font-size: 19px; line-height: 1.4; }
.checkout-tpl p { margin: 3px 0 0; color: #435d54; font-size: 14px; line-height: 1.55; }
.checkout-gift {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 7px; padding: 3px 9px;
  border-radius: 999px; background: #e4f2ea; color: #15543f; font-size: 13px; font-weight: 750;
}
.checkout-payment-totals { margin: 14px 0; padding: 12px 14px 8px; border: 1px solid #e0e9e3; border-radius: 15px; background: #fff; }
.checkout-payment-totals > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 3px 0; font-size: 14px; line-height: 1.6; }
.checkout-payment-totals dd { margin: 0; text-align: end; font-variant-numeric: tabular-nums; }
.payment-invoice-amount { margin: 12px 0; color: var(--g-900); font-weight: 800; font-variant-numeric: tabular-nums; }
.checkout-money, .checkout-pay-amount { white-space: nowrap; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.checkout-payment-totals del { color: #5e6f68; text-decoration-thickness: 1.5px; }
.checkout-discount dd { color: #166148; font-weight: 750; }
.checkout-payment-totals .checkout-total {
  margin-top: 7px; padding: 9px 0 2px; border-top: 1px solid #dbe7df; color: #104b38; font-size: 18px; font-weight: 900;
}
.checkout-total dd { font-size: clamp(23px, 5vw, 29px); line-height: 1.35; }
.checkout-payment-totals dd > * { animation: checkout-price-in 180ms ease both; }
.checkout-coupon label { display: block; margin-bottom: 5px; font-size: 14px; font-weight: 800; }
.checkout-coupon-row { display: flex; align-items: stretch; gap: 8px; }
.checkout-coupon-row .input { min-width: 0; flex: 1; }
.checkout-modal .input { min-height: 44px; border-radius: 10px; font-size: 16px; }
.checkout-modal .input:focus:not(:focus-visible) { box-shadow: none; }
.checkout-modal[data-seerti-keyboard] { box-sizing: border-box; block-size: var(--seerti-checkout-height); padding-block-end: calc(var(--seerti-checkout-padding, 24px) + var(--seerti-keyboard-inset)); scroll-padding-block-end: calc(12px + var(--seerti-keyboard-inset)); }
.checkout-coupon-row button { flex: none; min-width: 82px; min-height: 44px; border-color: #c7ded1; }
.checkout-coupon-hint, .checkout-helper { margin: 5px 0 0; font-size: 13px; line-height: 1.65; color: #426054; }
.checkout-coupon-hint { color: #166148; animation: checkout-price-in 160ms ease both; }
.checkout-coupon-hint.is-error, .checkout-status.is-error { color: #8e3324; }
.checkout-payment-details { margin-top: 12px; }
.checkout-footer { margin-top: 12px; }
.checkout-embedded { display: block; width: 100%; height: 340px; margin-top: 12px; border: 0; border-radius: 10px; background: white; }
.checkout-status { margin: 0 0 8px; color: #426054; font-size: 13px; line-height: 1.65; }
.checkout-status a { margin-inline-start: 6px; font-weight: 750; text-decoration: underline; }
.checkout-return-note { margin: 12px 0; padding: 12px; border: 1px solid #cddfd4; border-radius: 10px; background: #f3faf5; color: #234b38; }
.checkout-return-note a { display: table; margin-block-start: 8px; }
.preview-side #btnBuy {
  box-sizing: border-box; width: 100%; height: 44px; min-height: 44px; border-radius: 7px; padding: 0 14px;
}
.checkout-modal .native-apple-pay {
  display: block; width: 100%; height: 44px; border: 0; border-radius: 7px;
  -webkit-appearance: -apple-pay-button;
  -apple-pay-button-type: buy;
  -apple-pay-button-style: black;
  cursor: pointer;
}
.native-apple-pay:focus-visible { outline: 2px solid #087653; outline-offset: 2px; }
.desktop-apple-pay { display: block; width: 100%; --apple-pay-button-width: 100%; --apple-pay-button-height: 44px; --apple-pay-button-border-radius: 7px; --apple-pay-button-padding: 0; }
.desktop-apple-pay[hidden] { display: none; }
.desktop-apple-pay[aria-disabled=true] { opacity: .55; }
.checkout-apple-pay { margin-block-end: 8px; padding: 0; }
.checkout-apple-pay:disabled { opacity: .55; cursor: default; }
.checkout-samsung-pay {
  width: 100%; height: 44px; margin-block-end: 8px; padding: 0;
  border: 0; border-radius: 7px; background: #000; cursor: pointer;
}
.checkout-samsung-pay img { display: block; width: 100%; height: 100%; object-fit: contain; }
.checkout-samsung-pay:focus-visible { outline: 2px solid #087653; outline-offset: 2px; }
.checkout-samsung-pay:disabled { opacity: .55; cursor: default; }
.apple-pay-state:not(:empty) { margin-block: 8px 0; font-size: 13px; }
.checkout-modal .apple-pay-state:empty { display: none; }
.checkout-modal .apple-pay-state:not(:empty) { margin: 0 0 8px; color: #426054; }
.checkout-pay { display: flex; justify-content: space-between; gap: 10px; width: 100%; min-height: 49px; border-radius: 12px; font-size: 16px; color: #fff; background: #126249; border-color: #126249; }
.checkout-pay-title { display: inline-flex; align-items: center; gap: 7px; }
.checkout-card-chevron { font-size: 22px; line-height: 1; margin-inline-start: auto; transition: transform 180ms ease; }
.checkout-pay[aria-expanded=true] .checkout-card-chevron { transform: rotate(180deg); }
.checkout-card-panel { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows 180ms ease, opacity 180ms ease, margin 180ms ease; }
.checkout-card-panel.is-open { grid-template-rows: 1fr; opacity: 1; margin-block-start: 8px; }
.checkout-card-content { min-height: 0; overflow: hidden; }
.checkout-card-content .checkout-embedded { margin: 0; transition: height 180ms ease; }
.checkout-card-placeholder { display:grid; align-content:start; gap:8px; padding:4px 0; min-block-size:var(--checkout-placeholder-height, 0px); }
.checkout-card-placeholder[hidden], .checkout-card-panel[aria-busy=true] .checkout-embedded { display:none; }
.checkout-card-placeholder span { display:block; min-height:44px; border:1px solid #e2ebe5; background:#f4f8f5; border-radius:10px; }
.checkout-card-placeholder span:last-child { width:49%; }
.checkout-pay:hover:not(:disabled) { color: #fff; background: #0d503b; border-color: #0d503b; }
.checkout-pay-amount { font-size: 17px; font-weight: 900; }
.checkout-pay:disabled { color: #4b655a; background: #e7efe9; border-color: #dce9df; opacity: 1; }
.checkout-pay.is-submitting::before {
  content: ''; width: 14px; height: 14px; border: 2px solid currentColor; border-inline-end-color: transparent;
  border-radius: 50%; flex: none; animation: checkout-spin 700ms linear infinite;
}
.checkout-policy { margin: 9px 0 0; color: #4b655a; font-size: 13px; line-height: 1.65; text-wrap: pretty; }
.checkout-policy a { color: #195d47; text-decoration: underline; text-underline-offset: 2px; }
.checkout-maintenance { margin-top: 14px; padding: 14px; border: 1px solid #d6e7dc; border-radius: 14px; background: #f1f8f4; color: #123f32; }
.checkout-maintenance h4 { margin: 0 0 3px; font-size: 16px; line-height: 1.5; }
.checkout-maintenance p { margin: 0 0 10px; font-size: 14px; line-height: 1.6; }
.checkout-backdrop.is-closing { animation: checkout-fade-in 180ms ease both reverse; pointer-events: none; }
.checkout-backdrop.is-closing .checkout-modal { animation: checkout-slide-in 180ms ease both reverse; }
@keyframes checkout-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes checkout-slide-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes checkout-price-in { from { opacity: .55; transform: translateY(2px); } to { opacity: 1; transform: none; } }
@keyframes checkout-spin { to { transform: rotate(360deg); } }
@media (max-width: 600px) {
  .checkout-backdrop { padding: 10px; }
  .checkout-modal { max-height: calc(100vh - 20px); max-height: calc(var(--seerti-checkout-window, 100svh) - 20px); --seerti-checkout-padding: 16px; padding: 16px; border-radius: 19px; }
  .checkout-header { margin-bottom: 12px; }
  .checkout-tpl { gap: 10px; padding: 9px; }
  .checkout-thumb { width: 49px; height: 63px; }
  .checkout-tpl p { font-size: 13px; }
  .checkout-payment-totals { margin-block: 12px; padding-inline: 10px; }
  .checkout-coupon-row button { min-width: 70px; padding-inline: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .checkout-backdrop, .checkout-modal, .checkout-modal *, .checkout-modal *::before { animation: none !important; transition: none !important; }
}
.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); }
.canvas-qr.bw { touch-action:none;cursor:move;outline-offset:0;outline-width:calc(2px / var(--canvas-scale,1)); }
.canvas-qr.bw.selected,.canvas-qr.bw:focus-within { outline:calc(2px / var(--canvas-scale,1)) solid var(--qr-selection,#047857);box-shadow:0 0 0 calc(3px / var(--canvas-scale,1)) var(--qr-selection-halo,#fff); }
.canvas-qr-empty { display:flex;align-items:center;justify-content:center;width:100%;height:100%;border:1px dashed #047857;background:#eef7f2;color:#164e3b;font:12px/1.5 Tajawal,sans-serif;text-align:center;padding:4px; }
.canvas-qr-resize { position:absolute;right:0;bottom:0;transform:translate(50%,50%);display:none;align-items:center;justify-content:center;width:calc(36px / var(--canvas-scale,1));height:calc(36px / var(--canvas-scale,1));border:0;padding:0;background:transparent;line-height:1;cursor:nwse-resize;touch-action:none; }
.canvas-qr-resize > span { display:grid;place-items:center;width:calc(18px / var(--canvas-scale,1));height:calc(18px / var(--canvas-scale,1));background:var(--qr-selection-halo,#fff);border:calc(2px / var(--canvas-scale,1)) solid var(--qr-selection,#047857);border-radius:calc(4px / var(--canvas-scale,1));box-shadow:0 1px 4px #0002; }
.canvas-qr-resize svg { width:100%;height:100%;stroke:var(--qr-selection,#047857);stroke-width:1.7;fill:none; }
.canvas-qr-resize:hover > span,.canvas-qr-resize:focus-visible > span { box-shadow:0 0 0 calc(2px / var(--canvas-scale,1)) var(--qr-selection,#047857); }
.canvas-qr.selected .canvas-qr-resize,.canvas-qr:focus-within .canvas-qr-resize { display:flex; }
.qr-background-toggle { margin-top:10px; }
.qr-settings label { display:grid;gap:7px; }
.qr-settings input[type=range] { width:100%;accent-color:#047857; }
.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) {
  .builder-grid { grid-template-columns: 210px minmax(0, 1fr) 220px; }
}
@media (max-width: 960px) {
  .editor-layout { display: block; }
  .editor-layout > .wizard-card { width: 100%; }
  .wizard-preview-shortcut { display: flex; padding: 4px 16px; border-bottom: 1px solid var(--line); background: var(--g-50); }
  .wizard-preview-slot { padding: 0 12px 18px; }
  .wizard-preview-slot .live-preview { width: 100%; position: static; }
  .live-preview-head { margin-bottom: 8px; }
  .live-preview-head h4 { font-size: 13px; }
  .live-preview-box { height: 440px; border-radius: 10px; background: #eef3f0; }
  .editor-layout .wizard-body :is(input, textarea, select, button) { scroll-margin-top: 110px; }
  /* Keep Safari from zooming the whole page when a data field receives focus. */
  .editor-layout .wizard-body :is(input, textarea, select):not([type="checkbox"]):not([type="range"]):not([type="file"]) { font-size: 16px; }
  .preview-layout { grid-template-columns: 1fr; }
  .preview-side { position: static; }
  .studio-offer .preview-stage { grid-row:1; scroll-margin-top:110px; }
  .studio-offer .preview-side { grid-row:2; }
  .dash-grid { grid-template-columns: 1fr; }
  .builder-grid { grid-template-columns: 1fr; }
  .builder-panel { position: static; max-height: none; }
}
@media (max-width: 800px) {
  .gallery-grid, .owned-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
}
@media (max-width: 600px) {
  .gallery-grid, .owned-grid { grid-template-columns: 1fr; gap: 22px; }
  .g-card { border-radius: 12px; }
  .g-card-body { padding: 19px 20px; }
  .g-card-title h3 { font-size: 22px; }
  .g-card-description { min-height: 0; }
  .g-card-features { margin: 14px 0 19px; }
  .g-card-bottom .template-price strong { font-size: 25px; }
  .g-preview-button { padding-inline: 16px; }
  .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); }
.education-year { min-width:0; margin-bottom:14px; }
.education-year .year-field { margin-bottom:4px; }
.education-year select:disabled { opacity:.5; }
.current-study-toggle { display:flex; align-items:center; gap:10px; min-height:44px; font-size:15px; cursor:pointer; }
.current-study-toggle input { flex:none; width:20px; height:20px; margin:0; 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-context { position:absolute; display:block; max-width:none; opacity:.3; pointer-events:none; user-select:none; }
.photo-context[hidden] { display:none; }
.photo-crop-frame { position:relative; flex:none; border-radius:50%; overflow:hidden; box-shadow:0 0 0 3px #fff,0 0 0 5px #14634d,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;}
}
/* Accent controls for the fixed CV templates; My Canvas keeps its existing toolbar. */
.template-color-controls { border:0; padding:0; margin:16px 0 20px; min-width:0; }
.template-color-controls legend { padding:0; margin-bottom:10px; font-size:14px; font-weight:700; }
.template-color-swatches { display:grid; grid-template-columns:repeat(5,minmax(44px,1fr)); gap:6px; }
.template-color-swatches button { min-width:44px; height:44px; border:1px solid transparent; border-radius:10px; background:transparent; display:grid; place-items:center; }
.template-color-swatches button > span { width:28px; height:28px; border-radius:50%; background:var(--swatch); border:1px solid #0001; }
.template-color-swatches button[aria-pressed="true"] { border-color:var(--g-700); background:var(--g-50); }
.template-color-swatches button[aria-pressed="true"] > span { outline:2px solid var(--g-700); outline-offset:3px; }
.template-color-swatches .template-custom-color { border-color:var(--line); color:var(--g-800); background:var(--g-50); font-size:23px; }
.template-custom-color[aria-expanded="true"] { outline:2px solid var(--g-700); outline-offset:1px; }
.template-color-controls .save-state { display:block; min-height:20px; font-size:12px; margin-top:7px; }
.template-color-controls input[aria-invalid="true"] { border-color:#a12626; }
.template-color-swatches button:focus-visible { outline:2px solid var(--g-700); outline-offset:2px; }
.color-reset { min-height:44px; margin-top:10px; font-size:14px; }
.checkout-coupon-hint{position:relative;border:1px solid #b9d5c6;border-radius:8px;background:#eef6f1;color:#225d41;padding:9px 12px 9px 35px!important;line-height:1.8!important}.checkout-coupon-hint.is-error{border-color:#e5b4ab;background:#fbeae5;color:#99442e}.checkout-coupon-hint button{position:absolute;left:8px;top:3px;border:0;background:transparent;color:inherit;font-size:22px;cursor:pointer}.checkout-coupon-hint[hidden]{display:none!important}
