:root {
  --kv-bg: #eef5ff;
  --kv-surface: #ffffff;
  --kv-surface-2: #f8fbff;
  --kv-line: rgba(15, 23, 42, 0.10);
  --kv-text: #0f172a;
  --kv-muted: #64748b;
  --kv-primary: #0f80ff;
  --kv-primary-2: #06b6d4;
  --kv-danger: #ef4444;
  --kv-radius: 22px;
  --kv-shadow: 0 18px 48px rgba(15, 23, 42, .10);
  --kv-font: 'Cairo', system-ui, -apple-system, Segoe UI, sans-serif;
  --cv-accent: #0f80ff;
  --cv-font: 'Cairo', system-ui, sans-serif;
  --cv-scale-font: 1;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body.cv-builder-page {
  margin: 0;
  min-height: 100vh;
  color: var(--kv-text);
  font-family: var(--kv-font);
  background:
    radial-gradient(circle at 12% 0%, rgba(15, 128, 255, .12), transparent 31%),
    radial-gradient(circle at 92% 0%, rgba(6, 182, 212, .10), transparent 28%),
    linear-gradient(180deg, #eef5ff, #ffffff 70%);
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.kv-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: auto minmax(360px, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin: 14px 18px 0;
  padding: 10px 12px;
  border: 1px solid var(--kv-line);
  border-radius: 24px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(16px);
  box-shadow: var(--kv-shadow);
}
html[dir="rtl"] .kv-brand { grid-column: 3; justify-self: end; direction: rtl; text-align: right; }
html[dir="rtl"] .kv-toolbar { grid-column: 2; }
html[dir="rtl"] .kv-actions { grid-column: 1; justify-self: start; }
html[dir="ltr"] .kv-brand { grid-column: 1; justify-self: start; direction: ltr; text-align: left; }
html[dir="ltr"] .kv-toolbar { grid-column: 2; }
html[dir="ltr"] .kv-actions { grid-column: 3; justify-self: end; }

.kv-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 210px;
}
.kv-brand img {
  width: 46px;
  height: 46px;
  object-fit: contain;
  padding: 5px;
  background: #fff;
  border: 1px solid rgba(15,23,42,.09);
  border-radius: 16px;
  box-shadow: 0 8px 18px rgba(15,23,42,.07);
}
.kv-brand strong { display: block; font-size: .98rem; font-weight: 900; line-height: 1.2; }
.kv-brand small { display: block; margin-top: 2px; color: var(--kv-muted); font-size: .73rem; line-height: 1.35; white-space: nowrap; }

.kv-toolbar {
  display: grid;
  grid-template-columns: 154px minmax(170px, 1.5fr) minmax(130px, .8fr) 100px 56px;
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 7px;
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 18px;
  background: rgba(248, 251, 255, .92);
}
.kv-tool, .kv-lang-switch {
  min-width: 0;
  min-height: 42px;
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 15px;
  background: #fff;
  box-shadow: 0 6px 16px rgba(15,23,42,.04);
}
.kv-tool {
  display: grid;
  grid-template-rows: 14px 1fr;
  padding: 5px 10px 5px;
}
.kv-tool > span {
  color: #64748b;
  font-size: .66rem;
  font-weight: 800;
  line-height: 1;
}
.kv-tool select, .kv-tool input[type="color"] {
  width: 100%;
  height: 25px;
  min-width: 0;
  border: 0;
  background: transparent;
  color: #0f172a;
  outline: 0;
  font-size: .85rem;
  font-weight: 800;
}
.kv-color-tool { padding: 5px; }
.kv-color-tool span { text-align: center; }
.kv-color-tool input[type="color"] { height: 29px; padding: 2px; border-radius: 10px; }
.kv-lang-switch {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
}
.kv-lang-switch button {
  flex: 1;
  min-height: 32px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #64748b;
  font-size: .77rem;
  font-weight: 900;
}
.kv-lang-switch button.is-active {
  background: linear-gradient(135deg, var(--kv-primary), var(--kv-primary-2));
  color: #fff;
  box-shadow: 0 8px 18px rgba(15,128,255,.23);
}
.kv-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 250px;
}
.kv-account { position: relative; }
.kv-account-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 4px 10px;
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 6px 16px rgba(15,23,42,.05);
}
.kv-user-icon {
  display: inline-grid; place-items: center;
  width: 31px; height: 31px;
  border-radius: 999px;
  background: #f3f6ff;
  font-size: .93rem;
}
.kv-plan {
  display: inline-grid; place-items: center;
  min-height: 31px;
  padding: 0 12px;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  font-size: .75rem;
  font-weight: 900;
}
.kv-account-menu {
  position: absolute;
  top: calc(100% + 10px);
  inset-inline-start: 0;
  z-index: 120;
  width: 230px;
  padding: 10px;
  border-radius: 18px;
  border: 1px solid var(--kv-line);
  background: #fff;
  box-shadow: 0 22px 52px rgba(15,23,42,.18);
}
.kv-account-menu button, .kv-account-menu a {
  display: flex;
  width: 100%;
  min-height: 40px;
  align-items: center;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #0f172a;
  text-align: start;
  font-weight: 800;
}
.kv-account-menu button:hover, .kv-account-menu a:hover { background: #eff6ff; color: var(--kv-primary); }
.kv-account-menu hr { border: 0; border-top: 1px solid #e2e8f0; margin: 6px 2px; }
.kv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 14px;
  background: #fff;
  color: #0f172a;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(15,23,42,.05);
}
.kv-btn-primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--kv-primary), var(--kv-primary-2));
  color: #fff;
  box-shadow: 0 12px 24px rgba(15,128,255,.25);
}
.kv-btn-soft { background: #f8fbff; }
.kv-mobile-menu-btn { display: none; }

.kv-builder-shell {
  display: grid;
  grid-template-columns: minmax(600px, 1fr) minmax(390px, 500px) 88px;
  grid-template-areas: "preview editor tabs";
  gap: 16px;
  padding: 16px 18px 18px;
  align-items: stretch;
}
html[dir="ltr"] .kv-builder-shell {
  grid-template-columns: 88px minmax(390px, 500px) minmax(600px, 1fr);
  grid-template-areas: "tabs editor preview";
}
.kv-preview-panel { grid-area: preview; }
.kv-editor-panel { grid-area: editor; display: contents; }
.kv-section-tabs { grid-area: tabs; }

.kv-preview-panel, .kv-form-card, .kv-section-tabs {
  border: 1px solid var(--kv-line);
  border-radius: 24px;
  background: rgba(255,255,255,.90);
  box-shadow: var(--kv-shadow);
}
.kv-preview-panel {
  min-height: calc(100vh - 132px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.kv-preview-toolbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--kv-line);
}
.kv-preview-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 36px 24px;
  background-image: radial-gradient(rgba(15,128,255,.18) 1px, transparent 1px);
  background-size: 24px 24px;
}
.kv-section-tabs {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 8px;
  min-height: calc(100vh - 132px);
}
.kv-section-tabs button {
  min-height: 78px;
  border: 0;
  border-radius: 18px;
  background: #f8fbff;
  color: #64748b;
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 9px 6px;
  font-weight: 900;
}
.kv-section-tabs button span { font-size: 1.2rem; }
.kv-section-tabs button strong { font-size: .77rem; line-height: 1.25; }
.kv-section-tabs button.is-active {
  background: linear-gradient(135deg, var(--kv-primary), var(--kv-primary-2));
  color: #fff;
  box-shadow: 0 12px 24px rgba(15,128,255,.24);
}
.kv-form-card {
  min-height: calc(100vh - 132px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.kv-form-head {
  flex: 0 0 auto;
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--kv-line);
  background: linear-gradient(135deg, #fff, #eef6ff);
}
.kv-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: #ecfeff;
  color: #0369a1;
  border: 1px solid rgba(6,182,212,.18);
  font-size: .74rem;
  font-weight: 900;
}
.kv-form-head h1 { margin: 12px 0 6px; font-size: 1.45rem; line-height: 1.25; }
.kv-form-head p { margin: 0; color: var(--kv-muted); font-size: .88rem; }
.kv-form {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 18px 20px 24px;
}
.kv-tab-panel { animation: kvFade .15s ease both; }
@keyframes kvFade { from { opacity: .4; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.kv-field { display: grid; gap: 7px; margin-bottom: 14px; }
.kv-field > span, .kv-repeat-head h2 { font-weight: 900; color: #0f172a; }
.kv-field small, .kv-repeat-head p { color: var(--kv-muted); font-size: .78rem; margin: 0; }
.kv-field input[type="text"], .kv-field input[type="email"], .kv-field input[type="file"], .kv-field textarea, .kv-field select {
  width: 100%;
  border: 1px solid rgba(15,23,42,.11);
  border-radius: 15px;
  background: #f8fbff;
  color: #0f172a;
  min-height: 45px;
  padding: 10px 13px;
  outline: 0;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.kv-field textarea { resize: vertical; line-height: 1.7; }
.kv-field input:focus, .kv-field textarea:focus, .kv-field select:focus {
  border-color: rgba(15,128,255,.45);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(15,128,255,.11);
}
.kv-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.kv-score-card {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 14px;
  align-items: center;
  padding: 14px;
  margin-bottom: 16px;
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 18px;
  background: linear-gradient(135deg, #f8fbff, #fff);
}
.kv-score-number {
  width: 58px; height: 58px;
  border-radius: 17px;
  display: grid; place-items: center;
  background: #facc15;
  color: #111827;
  font-weight: 950;
}
.kv-score-card span { color: var(--kv-muted); font-size: .76rem; font-weight: 800; }
.kv-score-card strong { display: block; font-size: 1rem; }
.kv-score-line { height: 7px; border-radius: 999px; background: #e2e8f0; overflow: hidden; margin: 7px 0 5px; }
.kv-score-line span { display: block; height: 100%; width: 86%; background: linear-gradient(90deg, #f59e0b, #facc15); }
.kv-repeat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.kv-repeat-head h2 { margin: 0 0 4px; font-size: 1.08rem; }
.kv-repeat-item {
  position: relative;
  padding: 14px;
  margin-bottom: 14px;
  border-radius: 18px;
  border: 1px solid rgba(15,23,42,.10);
  background: #fff;
  box-shadow: 0 8px 20px rgba(15,23,42,.04);
}
.kv-repeat-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.kv-repeat-item-head strong { font-size: .92rem; }
.kv-icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid rgba(239,68,68,.20);
  border-radius: 12px;
  background: #fff7f7;
  color: #991b1b;
  font-weight: 900;
}
.kv-ai-card {
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(15,128,255,.12);
  background: linear-gradient(135deg, #fff, #eff6ff);
}
.kv-ai-card h2 { margin: 12px 0 6px; }
.kv-ai-card p { color: var(--kv-muted); margin-top: 0; }
.kv-ai-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 14px; }
.kv-ai-output {
  min-height: 70px;
  padding: 13px;
  border-radius: 16px;
  border: 1px dashed rgba(15,128,255,.25);
  background: rgba(255,255,255,.75);
  color: #0f172a;
  line-height: 1.8;
}
.kv-toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  z-index: 300;
  max-width: min(92vw, 420px);
  padding: 12px 16px;
  border-radius: 16px;
  background: #0f172a;
  color: #fff;
  box-shadow: 0 18px 45px rgba(15,23,42,.25);
  font-weight: 800;
  transition: .2s ease;
}
.kv-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.cv-paper {
  width: 794px;
  min-height: 1123px;
  margin: 0 auto;
  background: #fff;
  color: #111827;
  box-shadow: 0 20px 60px rgba(15,23,42,.14);
  font-family: var(--cv-font);
  font-size: calc(13px * var(--cv-scale-font));
  line-height: 1.6;
  overflow: hidden;
  direction: inherit;
}
.cv-layout { display: grid; grid-template-columns: 250px 1fr; min-height: 1123px; }
html[dir="rtl"] .cv-layout { grid-template-columns: 1fr 250px; }
.cv-side {
  background: #0f172a;
  color: #fff;
  padding: 42px 30px;
}
html[dir="rtl"] .cv-side { grid-column: 2; }
html[dir="rtl"] .cv-main { grid-column: 1; grid-row: 1; }
.cv-photo {
  width: 110px; height: 110px;
  border-radius: 28px;
  object-fit: cover;
  display: block;
  margin-bottom: 22px;
  border: 3px solid rgba(255,255,255,.18);
}
.cv-name { margin: 0; font-size: calc(30px * var(--cv-scale-font)); line-height: 1.15; font-weight: 950; }
.cv-title { margin: 9px 0 22px; color: rgba(255,255,255,.78); font-weight: 700; }
.cv-contact { display: grid; gap: 9px; margin: 20px 0; }
.cv-contact div { word-break: break-word; }
.cv-side h3, .cv-main h3 {
  margin: 22px 0 10px;
  padding-bottom: 7px;
  border-bottom: 2px solid var(--cv-accent);
  font-size: calc(14px * var(--cv-scale-font));
  font-weight: 950;
}
.cv-list { margin: 0; padding-inline-start: 18px; }
.cv-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.cv-tag { padding: 4px 8px; border-radius: 999px; background: rgba(255,255,255,.12); font-size: .9em; }
.cv-main { padding: 42px 38px; }
.cv-section { margin-bottom: 24px; }
.cv-section p { margin: 0; }
.cv-item { margin-bottom: 16px; }
.cv-item h4 { margin: 0; font-size: calc(15px * var(--cv-scale-font)); font-weight: 950; }
.cv-meta { color: #64748b; font-weight: 800; font-size: .92em; margin: 3px 0 5px; }
.cv-bullet-text { white-space: pre-line; }
.cv-accent-line { height: 4px; width: 52px; border-radius: 999px; background: var(--cv-accent); margin: 10px 0 0; }
html[dir="rtl"] .cv-accent-line { margin-right: 0; margin-left: auto; }

.cv-paper.template-minimal .cv-layout { grid-template-columns: 1fr; }
.cv-paper.template-minimal .cv-side { background: #fff; color: #111827; border-bottom: 5px solid var(--cv-accent); padding: 34px 42px 20px; }
.cv-paper.template-minimal .cv-main { padding: 28px 42px 42px; }
.cv-paper.template-minimal .cv-title { color: #64748b; }
.cv-paper.template-minimal .cv-side h3 { color: #111827; }
.cv-paper.template-minimal .cv-tag { background: #eff6ff; color: #1e3a8a; }
.cv-paper.template-minimal .cv-photo { float: inline-end; margin: 0 0 12px 16px; }
.cv-paper.template-ats { box-shadow: none; border: 1px solid #e2e8f0; }
.cv-paper.template-ats .cv-layout { grid-template-columns: 1fr; }
.cv-paper.template-ats .cv-side { background: #fff; color: #111827; padding: 34px 44px 12px; }
.cv-paper.template-ats .cv-main { padding: 18px 44px 42px; }
.cv-paper.template-ats .cv-title { color: #334155; }
.cv-paper.template-ats .cv-photo { display: none; }
.cv-paper.template-ats .cv-tag { background: transparent; color: #111827; border: 1px solid #cbd5e1; }
.cv-paper.template-executive .cv-side { background: #111827; }
.cv-paper.template-executive .cv-name { letter-spacing: -.02em; }
.cv-paper.template-executive .cv-main h3 { color: #111827; }

.kv-mobile-drawer { display: none; }
.kv-preview-modal { display: none; }

@media (max-width: 1280px) {
  .kv-topbar { grid-template-columns: auto 1fr; }
  html[dir="rtl"] .kv-brand { grid-column: 2; grid-row: 1; }
  html[dir="rtl"] .kv-actions { grid-column: 1; grid-row: 1; }
  html[dir="rtl"] .kv-toolbar { grid-column: 1 / -1; grid-row: 2; }
  html[dir="ltr"] .kv-brand { grid-column: 1; grid-row: 1; }
  html[dir="ltr"] .kv-actions { grid-column: 2; grid-row: 1; }
  html[dir="ltr"] .kv-toolbar { grid-column: 1 / -1; grid-row: 2; }
  .kv-toolbar { grid-template-columns: 154px minmax(180px, 1fr) 150px 110px 56px; }
  .kv-builder-shell { grid-template-columns: minmax(520px, 1fr) minmax(380px, 470px) 84px; }
}

@media (max-width: 920px) {
  body.cv-builder-page { background: #f3f7ff; }
  .kv-topbar {
    margin: 0;
    border-radius: 0;
    border-inline: 0;
    border-top: 0;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    padding: 8px 10px;
  }
  html[dir="rtl"] .kv-brand, html[dir="ltr"] .kv-brand { grid-column: 1; justify-self: stretch; }
  html[dir="rtl"] .kv-actions, html[dir="ltr"] .kv-actions { grid-column: 2 / 4; justify-self: end; min-width: 0; }
  .kv-brand { min-width: 0; }
  .kv-brand img { width: 38px; height: 38px; border-radius: 13px; }
  .kv-brand strong { font-size: .86rem; }
  .kv-brand small { display: none; }
  .kv-toolbar, .kv-account { display: none; }
  .kv-mobile-menu-btn {
    display: inline-grid;
    place-items: center;
    width: 42px; height: 42px;
    border: 1px solid var(--kv-line);
    border-radius: 14px;
    background: #fff;
    font-size: 1.25rem;
    font-weight: 900;
  }
  .kv-actions { gap: 8px; }
  .kv-actions #downloadPdfBtn { min-width: 0; padding: 0 12px; }
  .kv-actions #downloadPdfBtn span:last-child { display: none; }

  .kv-builder-shell {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px 8px 12px;
  }
  .kv-preview-panel { min-height: auto; border-radius: 20px; }
  .kv-preview-toolbar { display: flex; }
  .kv-preview-scroll { display: none; }
  .kv-editor-panel { display: contents; }
  .kv-form-card {
    order: 1;
    min-height: 0;
    border-radius: 20px;
    overflow: visible;
  }
  .kv-form-head { padding: 15px 14px 11px; border-radius: 20px 20px 0 0; }
  .kv-form-head h1 { font-size: 1.15rem; margin-top: 9px; }
  .kv-form-head p { font-size: .78rem; }
  .kv-form { overflow: visible; padding: 14px 12px 14px; }
  .kv-section-tabs {
    order: 2;
    min-height: 0;
    position: sticky;
    bottom: 8px;
    z-index: 90;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
    padding: 6px;
    border-radius: 18px;
    background: rgba(255,255,255,.96);
    backdrop-filter: blur(12px);
  }
  .kv-section-tabs button { min-height: 58px; border-radius: 14px; padding: 5px 2px; gap: 2px; }
  .kv-section-tabs button span { font-size: 1rem; }
  .kv-section-tabs button strong { font-size: .57rem; line-height: 1.15; }
  .kv-grid-2 { grid-template-columns: 1fr; gap: 0; }
  .kv-repeat-head { align-items: stretch; flex-direction: column; }
  .kv-repeat-head .kv-btn { width: 100%; }
  .kv-score-card { grid-template-columns: 54px 1fr; padding: 12px; }
  .kv-score-number { width: 50px; height: 50px; border-radius: 15px; }
  .kv-ai-actions { display: grid; grid-template-columns: 1fr; }

  .kv-mobile-drawer { display: block; position: fixed; inset: 0; z-index: 220; opacity: 0; pointer-events: none; transition: opacity .18s ease; }
  .kv-mobile-drawer.is-open { opacity: 1; pointer-events: auto; }
  .kv-mobile-drawer-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.38); backdrop-filter: blur(4px); }
  .kv-mobile-drawer-panel {
    position: absolute;
    top: 0; bottom: 0;
    width: min(88vw, 370px);
    background: #fff;
    box-shadow: -22px 0 65px rgba(15,23,42,.24);
    display: flex;
    flex-direction: column;
    transform: translateX(104%);
    transition: transform .22s ease;
  }
  html[dir="rtl"] .kv-mobile-drawer-panel { right: 0; }
  html[dir="ltr"] .kv-mobile-drawer-panel { left: 0; transform: translateX(-104%); box-shadow: 22px 0 65px rgba(15,23,42,.24); }
  html[dir="rtl"] .kv-mobile-drawer.is-open .kv-mobile-drawer-panel,
  html[dir="ltr"] .kv-mobile-drawer.is-open .kv-mobile-drawer-panel { transform: translateX(0); }
  .kv-drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px; border-bottom: 1px solid var(--kv-line); }
  .kv-drawer-head button { width: 38px; height: 38px; border: 1px solid var(--kv-line); border-radius: 13px; background: #f8fbff; font-size: 1.3rem; }
  .kv-drawer-body { flex: 1; overflow: auto; display: grid; gap: 9px; padding: 14px; background: #f8fbff; }
  .kv-drawer-body > button, .kv-drawer-body > a, .kv-drawer-body label {
    width: 100%; min-height: 46px; border: 1px solid var(--kv-line); border-radius: 15px; background: #fff; color: #0f172a; padding: 9px 12px; font-weight: 850; text-align: start;
  }
  .kv-drawer-body label { display: grid; gap: 6px; }
  .kv-drawer-body label span { color: var(--kv-muted); font-size: .72rem; font-weight: 900; }
  .kv-drawer-body select, .kv-drawer-body input[type="color"] { border: 0; background: transparent; min-height: 30px; font-weight: 900; outline: 0; }
  .kv-drawer-body hr { width: 100%; border: 0; border-top: 1px solid #e2e8f0; margin: 2px 0; }
  .kv-drawer-lang { width: 100%; }

  .kv-preview-modal {
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0;
    z-index: 210;
    background: #eef5ff;
    transform: translateY(104%);
    opacity: 0;
    pointer-events: none;
    transition: transform .22s ease, opacity .18s ease;
  }
  .kv-preview-modal.is-open { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .kv-preview-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; background: #fff; border-bottom: 1px solid var(--kv-line); }
  .kv-preview-modal-head button { width: 42px; height: 42px; border: 1px solid var(--kv-line); border-radius: 14px; background: #f8fbff; font-size: 1.5rem; line-height: 1; }
  .kv-preview-modal-body { flex: 1; overflow: auto; padding: 18px 10px; }
  .kv-preview-modal .cv-paper { transform: scale(.46); transform-origin: top center; margin: 0 auto; }
}

@media (max-width: 420px) {
  .kv-actions #downloadPdfBtn { width: 42px; height: 42px; padding: 0; border-radius: 14px; }
  .kv-brand strong { max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .kv-form { padding-inline: 10px; }
  .kv-section-tabs button strong { font-size: .52rem; }
  .kv-preview-modal .cv-paper { transform: scale(.43); }
}

@media print {
  body * { visibility: hidden !important; }
  #cvPreview, #cvPreview * { visibility: visible !important; }
  #cvPreview { position: absolute; inset: 0; box-shadow: none !important; }
}

/* Final physical ordering fix: keep Arabic UI visually brand-right, controls-center, actions-left. */
@media (min-width: 921px) {
  .kv-topbar,
  .kv-builder-shell { direction: ltr; }

  html[dir="rtl"] .kv-topbar {
    grid-template-columns: auto minmax(360px, 1fr) auto;
  }
  html[dir="rtl"] .kv-brand { grid-column: 3; grid-row: 1; justify-self: end; direction: rtl; text-align: right; }
  html[dir="rtl"] .kv-toolbar { grid-column: 2; grid-row: 1; direction: rtl; }
  html[dir="rtl"] .kv-actions { grid-column: 1; grid-row: 1; justify-self: start; direction: rtl; }

  html[dir="ltr"] .kv-brand { grid-column: 1; grid-row: 1; justify-self: start; direction: ltr; text-align: left; }
  html[dir="ltr"] .kv-toolbar { grid-column: 2; grid-row: 1; direction: ltr; }
  html[dir="ltr"] .kv-actions { grid-column: 3; grid-row: 1; justify-self: end; direction: ltr; }

  html[dir="rtl"] .kv-builder-shell {
    grid-template-columns: minmax(600px, 1fr) minmax(390px, 500px) 88px;
    grid-template-areas: "preview editor tabs";
  }
  html[dir="ltr"] .kv-builder-shell {
    grid-template-columns: 88px minmax(390px, 500px) minmax(600px, 1fr);
    grid-template-areas: "tabs editor preview";
  }
  .kv-preview-panel { grid-area: preview; direction: inherit; }
  .kv-form-card { grid-area: editor; direction: inherit; }
  .kv-section-tabs { grid-area: tabs; direction: inherit; }

  html[dir="rtl"] .kv-form-card,
  html[dir="rtl"] .kv-section-tabs,
  html[dir="rtl"] .kv-preview-panel { direction: rtl; }
  html[dir="ltr"] .kv-form-card,
  html[dir="ltr"] .kv-section-tabs,
  html[dir="ltr"] .kv-preview-panel { direction: ltr; }
}

/* Mobile no-overlap correction: tabs are part of normal flow, never covering inputs. */
@media (max-width: 920px) {
  .kv-section-tabs {
    order: 1;
    position: static;
    bottom: auto;
    margin: 0;
  }
  .kv-form-card { order: 2; }
  .kv-form { padding-bottom: 18px; }
}

/* =========================================================
   v15 templates + fonts + exact CV direction patch
   ========================================================= */

/* The CV preview must follow the selected CV language, not the page toolbar layout. */
.cv-paper[dir="rtl"] { direction: rtl !important; text-align: right !important; }
.cv-paper[dir="ltr"] { direction: ltr !important; text-align: left !important; }
.cv-paper[dir="rtl"] .cv-layout { direction: rtl !important; grid-template-columns: 1fr 250px !important; }
.cv-paper[dir="rtl"] .cv-side { grid-column: 2 !important; grid-row: 1 !important; text-align: right !important; }
.cv-paper[dir="rtl"] .cv-main { grid-column: 1 !important; grid-row: 1 !important; text-align: right !important; }
.cv-paper[dir="ltr"] .cv-layout { direction: ltr !important; grid-template-columns: 250px 1fr !important; }
.cv-paper[dir="ltr"] .cv-side { grid-column: 1 !important; grid-row: 1 !important; text-align: left !important; }
.cv-paper[dir="ltr"] .cv-main { grid-column: 2 !important; grid-row: 1 !important; text-align: left !important; }
.cv-paper[dir="rtl"] .cv-accent-line { margin-right: 0 !important; margin-left: auto !important; }
.cv-paper[dir="ltr"] .cv-accent-line { margin-left: 0 !important; margin-right: auto !important; }
.cv-paper[dir="rtl"] .cv-tags { justify-content: flex-start; }
.cv-paper[dir="rtl"] .cv-photo { margin-right: 0; margin-left: auto; }
.cv-paper[dir="ltr"] .cv-photo { margin-left: 0; margin-right: auto; }

/* Full template set */
.cv-paper.template-modern .cv-side { background: #0f172a; color: #fff; }
.cv-paper.template-modern .cv-main h3 { color: #0f172a; }

.cv-paper.template-minimal .cv-layout,
.cv-paper.template-global-ats .cv-layout,
.cv-paper.template-premium-classic .cv-layout {
  grid-template-columns: 1fr !important;
}
.cv-paper.template-minimal .cv-side,
.cv-paper.template-minimal .cv-main,
.cv-paper.template-global-ats .cv-side,
.cv-paper.template-global-ats .cv-main,
.cv-paper.template-premium-classic .cv-side,
.cv-paper.template-premium-classic .cv-main {
  grid-column: auto !important;
  grid-row: auto !important;
}

.cv-paper.template-minimal .cv-side {
  background: #fff !important;
  color: #111827 !important;
  border-bottom: 5px solid var(--cv-accent);
  padding: 34px 42px 20px;
}
.cv-paper.template-minimal .cv-main { padding: 28px 42px 42px; }
.cv-paper.template-minimal .cv-title { color: #64748b; }
.cv-paper.template-minimal .cv-side h3 { color: #111827; }
.cv-paper.template-minimal .cv-tag { background: #eff6ff; color: #1e3a8a; }

.cv-paper.template-elegant-fresher .cv-side {
  background: linear-gradient(180deg, #f8fbff, #eef6ff) !important;
  color: #0f172a !important;
  border-inline-end: 1px solid #dbeafe;
}
.cv-paper.template-elegant-fresher[dir="rtl"] .cv-side { border-inline-end: 0; border-inline-start: 1px solid #dbeafe; }
.cv-paper.template-elegant-fresher .cv-title { color: #334155; }
.cv-paper.template-elegant-fresher .cv-side h3 { color: #0f172a; }
.cv-paper.template-elegant-fresher .cv-tag { background: #dbeafe; color: #1e3a8a; }
.cv-paper.template-elegant-fresher .cv-photo { border-color: #dbeafe; }

.cv-paper.template-global-ats {
  box-shadow: none;
  border: 1px solid #e2e8f0;
}
.cv-paper.template-global-ats .cv-side {
  background: #fff !important;
  color: #111827 !important;
  padding: 34px 44px 12px;
  border-bottom: 2px solid #111827;
}
.cv-paper.template-global-ats .cv-main { padding: 18px 44px 42px; }
.cv-paper.template-global-ats .cv-title { color: #334155; }
.cv-paper.template-global-ats .cv-photo { display: none; }
.cv-paper.template-global-ats .cv-tags { gap: 6px; }
.cv-paper.template-global-ats .cv-tag { background: transparent; color: #111827; border: 1px solid #cbd5e1; border-radius: 4px; }
.cv-paper.template-global-ats .cv-side h3,
.cv-paper.template-global-ats .cv-main h3 { border-bottom-color: #111827; }

.cv-paper.template-executive .cv-side { background: #111827 !important; color: #fff; }
.cv-paper.template-executive .cv-name { letter-spacing: -.02em; }
.cv-paper.template-executive .cv-main { background: #fff; }
.cv-paper.template-executive .cv-main h3 { color: #111827; }

.cv-paper.template-professional .cv-side {
  background: linear-gradient(180deg, #1d4ed8, #0f172a) !important;
  color: #fff;
}
.cv-paper.template-professional .cv-tag { background: rgba(255,255,255,.16); }
.cv-paper.template-professional .cv-main h3 { color: #1d4ed8; }
.cv-paper.template-professional .cv-photo { border-radius: 999px; }

.cv-paper.template-premium-classic {
  font-family: var(--cv-font);
  border-top: 10px solid var(--cv-accent);
}
.cv-paper.template-premium-classic .cv-side {
  background: #fff !important;
  color: #111827 !important;
  padding: 42px 48px 18px;
  border-bottom: 1px solid #d1d5db;
}
.cv-paper.template-premium-classic .cv-main { padding: 28px 48px 48px; }
.cv-paper.template-premium-classic .cv-name { font-family: 'Merriweather', Georgia, serif; }
.cv-paper.template-premium-classic .cv-title { color: #4b5563; }
.cv-paper.template-premium-classic .cv-side h3 { color: #111827; }
.cv-paper.template-premium-classic .cv-tag { background: #faf7f0; color: #7c2d12; border: 1px solid #fed7aa; }

.cv-paper.template-ceo-modern .cv-side {
  background: #0b1220 !important;
  color: #fff;
  padding-top: 58px;
}
.cv-paper.template-ceo-modern .cv-main {
  padding-top: 58px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}
.cv-paper.template-ceo-modern .cv-name { font-size: calc(34px * var(--cv-scale-font)); }
.cv-paper.template-ceo-modern .cv-section h3 { text-transform: uppercase; letter-spacing: .06em; }
.cv-paper.template-ceo-modern .cv-tag { background: rgba(255,255,255,.14); }

.cv-paper.template-tech-impact .cv-side {
  background: #020617 !important;
  color: #ecfeff;
}
.cv-paper.template-tech-impact .cv-accent-line,
.cv-paper.template-tech-impact .cv-side h3,
.cv-paper.template-tech-impact .cv-main h3 { border-color: #22c55e; }
.cv-paper.template-tech-impact .cv-accent-line { background: #22c55e; }
.cv-paper.template-tech-impact .cv-main h3 { color: #16a34a; }
.cv-paper.template-tech-impact .cv-tag { background: rgba(34,197,94,.14); color: #dcfce7; border: 1px solid rgba(34,197,94,.28); }
.cv-paper.template-tech-impact .cv-side .cv-title { color: #a7f3d0; }

.cv-paper.template-creative-studio .cv-side {
  background: linear-gradient(165deg, #7c3aed, #0ea5e9 55%, #0f172a) !important;
  color: #fff;
}
.cv-paper.template-creative-studio .cv-main {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}
.cv-paper.template-creative-studio .cv-photo { border-radius: 34% 66% 47% 53% / 43% 40% 60% 57%; }
.cv-paper.template-creative-studio .cv-tag { background: rgba(255,255,255,.18); }
.cv-paper.template-creative-studio .cv-main h3 { color: #6d28d9; }

/* Make long option labels readable in the toolbar. */
.kv-tool select { text-overflow: ellipsis; }
@media (min-width: 921px) {
  .kv-toolbar { grid-template-columns: 154px minmax(220px, 1.7fr) minmax(150px, .85fr) 100px 56px; }
}

/* =========================================================
   v16 stability fixes: Pro locks, CV-only accent, PDF export, auth UI
   ========================================================= */

/* Keep the app UI blue. The color picker changes only --cv-accent. */
body.cv-builder-page {
  --kv-primary: #0f80ff;
  --kv-primary-2: #06b6d4;
}

select option:disabled {
  color: #94a3b8;
  background: #f1f5f9;
}

body.is-guest #accountMenu {
  display: none !important;
}

[data-auth-only][hidden],
[data-guest-only][hidden] {
  display: none !important;
}

.kv-account-toggle {
  min-width: 86px;
}

body.is-authenticated .kv-user-icon {
  font-weight: 950;
  background: #eef2ff;
  color: #3730a3;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
}

/* The CV preview follows its own dir attribute, never the toolbar direction. */
.cv-paper[dir="rtl"] {
  direction: rtl !important;
  text-align: right !important;
}
.cv-paper[dir="ltr"] {
  direction: ltr !important;
  text-align: left !important;
}
.cv-paper[dir="rtl"] .cv-layout {
  direction: rtl !important;
  grid-template-columns: 1fr 250px !important;
}
.cv-paper[dir="rtl"] .cv-side {
  grid-column: 2 !important;
  grid-row: 1 !important;
  text-align: right !important;
}
.cv-paper[dir="rtl"] .cv-main {
  grid-column: 1 !important;
  grid-row: 1 !important;
  text-align: right !important;
}
.cv-paper[dir="ltr"] .cv-layout {
  direction: ltr !important;
  grid-template-columns: 250px 1fr !important;
}
.cv-paper[dir="ltr"] .cv-side {
  grid-column: 1 !important;
  grid-row: 1 !important;
  text-align: left !important;
}
.cv-paper[dir="ltr"] .cv-main {
  grid-column: 2 !important;
  grid-row: 1 !important;
  text-align: left !important;
}
.cv-paper[dir="rtl"] .cv-list {
  padding-inline-start: 0 !important;
  padding-inline-end: 18px !important;
}
.cv-paper[dir="ltr"] .cv-list {
  padding-inline-start: 18px !important;
  padding-inline-end: 0 !important;
}
.cv-paper[dir="rtl"] .cv-accent-line {
  margin-right: 0 !important;
  margin-left: auto !important;
}
.cv-paper[dir="ltr"] .cv-accent-line {
  margin-left: 0 !important;
  margin-right: auto !important;
}

/* One-column templates should still respect text direction. */
.cv-paper.template-minimal .cv-layout,
.cv-paper.template-global-ats .cv-layout,
.cv-paper.template-premium-classic .cv-layout {
  grid-template-columns: 1fr !important;
}
.cv-paper.template-minimal .cv-side,
.cv-paper.template-minimal .cv-main,
.cv-paper.template-global-ats .cv-side,
.cv-paper.template-global-ats .cv-main,
.cv-paper.template-premium-classic .cv-side,
.cv-paper.template-premium-classic .cv-main {
  grid-column: auto !important;
  grid-row: auto !important;
}

#kavenioPdfHost,
#cvPdfExport {
  border-radius: 0 !important;
  box-shadow: none !important;
}
#kavenioPdfHost .cv-paper {
  margin: 0 !important;
  transform: none !important;
  zoom: 1 !important;
}

/* =========================================================
   v17 — Arabic template direction + enhanced AI panel
   ========================================================= */

/* Make grid direction physical and stable. Arabic CV: sidebar right, content left. */
.cv-paper[dir="rtl"] {
  direction: rtl !important;
  text-align: right !important;
}

.cv-paper[dir="ltr"] {
  direction: ltr !important;
  text-align: left !important;
}

.cv-paper[dir="rtl"] .cv-layout {
  direction: ltr !important;
  grid-template-columns: minmax(0, 1fr) 250px !important;
  grid-template-areas: "main side" !important;
}

.cv-paper[dir="ltr"] .cv-layout {
  direction: ltr !important;
  grid-template-columns: 250px minmax(0, 1fr) !important;
  grid-template-areas: "side main" !important;
}

.cv-paper .cv-side {
  grid-area: side !important;
}

.cv-paper .cv-main {
  grid-area: main !important;
}

.cv-paper[dir="rtl"] .cv-side,
.cv-paper[dir="rtl"] .cv-main {
  direction: rtl !important;
  text-align: right !important;
}

.cv-paper[dir="ltr"] .cv-side,
.cv-paper[dir="ltr"] .cv-main {
  direction: ltr !important;
  text-align: left !important;
}

.cv-paper[dir="rtl"] .cv-accent-line {
  margin-inline-start: auto !important;
  margin-inline-end: 0 !important;
}

.cv-paper[dir="ltr"] .cv-accent-line {
  margin-inline-start: 0 !important;
  margin-inline-end: auto !important;
}

.cv-paper[dir="rtl"] .cv-list {
  padding-right: 1.15rem !important;
  padding-left: 0 !important;
}

.cv-paper[dir="ltr"] .cv-list {
  padding-left: 1.15rem !important;
  padding-right: 0 !important;
}

.cv-paper[dir="rtl"] .cv-tags {
  justify-content: flex-start !important;
}

.cv-bullet-text {
  white-space: pre-line !important;
}

/* One-column templates keep Arabic text direction but do not flip into broken columns. */
.cv-paper.template-minimal .cv-layout,
.cv-paper.template-global-ats .cv-layout,
.cv-paper.template-premium-classic .cv-layout {
  grid-template-columns: 1fr !important;
  grid-template-areas:
    "side"
    "main" !important;
  direction: inherit !important;
}

.cv-paper.template-minimal[dir="rtl"] .cv-side,
.cv-paper.template-minimal[dir="rtl"] .cv-main,
.cv-paper.template-global-ats[dir="rtl"] .cv-side,
.cv-paper.template-global-ats[dir="rtl"] .cv-main,
.cv-paper.template-premium-classic[dir="rtl"] .cv-side,
.cv-paper.template-premium-classic[dir="rtl"] .cv-main {
  direction: rtl !important;
  text-align: right !important;
}

.cv-paper.template-minimal[dir="ltr"] .cv-side,
.cv-paper.template-minimal[dir="ltr"] .cv-main,
.cv-paper.template-global-ats[dir="ltr"] .cv-side,
.cv-paper.template-global-ats[dir="ltr"] .cv-main,
.cv-paper.template-premium-classic[dir="ltr"] .cv-side,
.cv-paper.template-premium-classic[dir="ltr"] .cv-main {
  direction: ltr !important;
  text-align: left !important;
}

/* AI Assistant improvements */
.kv-ai-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.kv-ai-actions .kv-btn-primary:last-child {
  grid-column: 1 / -1;
}

.kv-ai-note {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #eff6ff;
  border: 1px solid rgba(15, 128, 255, .15);
  color: #1e3a8a;
  font-size: .82rem;
  line-height: 1.7;
}

.kv-ai-output {
  margin-top: 14px;
  border-radius: 18px;
  border: 1px solid rgba(15, 23, 42, .10);
  background: #ffffff;
  padding: 14px;
  color: #0f172a;
  min-height: 70px;
}

.kv-ai-output:empty {
  display: none;
}

.kv-ai-output strong {
  display: block;
  margin-bottom: 8px;
  font-weight: 900;
}

.kv-ai-output pre {
  margin: 0;
  white-space: pre-wrap;
  font: inherit;
  line-height: 1.8;
}

.kv-ai-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #1d4ed8;
  font-weight: 800;
}

@media (max-width: 760px) {
  .kv-ai-actions {
    grid-template-columns: 1fr;
  }
}

.cv-paper.template-elegant-fresher[dir="rtl"] .cv-side {
  border-left: 1px solid #dbeafe !important;
  border-right: 0 !important;
}

.cv-paper.template-elegant-fresher[dir="ltr"] .cv-side {
  border-right: 1px solid #dbeafe !important;
  border-left: 0 !important;
}

/* =========================================================
   v18 — fixed preview/workspace, A4 export, distinct templates, AI apply flow
   ========================================================= */

@media (min-width: 921px) {
  html,
  body.cv-builder-page {
    height: 100%;
    overflow: hidden;
  }

  body.cv-builder-page {
    display: flex;
    flex-direction: column;
  }

  .kv-topbar {
    flex: 0 0 auto;
    position: sticky;
    top: 0;
    z-index: 120;
    margin-bottom: 0;
  }

  .kv-builder-shell {
    flex: 1 1 auto;
    height: calc(100dvh - 96px);
    min-height: 0;
    overflow: hidden;
    align-items: stretch;
  }

  .kv-preview-panel,
  .kv-form-card,
  .kv-section-tabs {
    min-height: 0 !important;
    height: 100%;
    max-height: 100%;
  }

  .kv-preview-panel {
    position: sticky;
    top: 84px;
    align-self: stretch;
    overflow: hidden;
  }

  .kv-preview-scroll {
    overflow: auto;
    min-height: 0;
  }

  .kv-form-card {
    overflow: hidden;
  }

  .kv-form {
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    scroll-padding-top: 98px;
  }

  .kv-score-card {
    position: sticky;
    top: 0;
    z-index: 40;
    margin: 0 0 16px;
    background: linear-gradient(135deg, #ffffff, #eef6ff) !important;
    box-shadow: 0 14px 28px rgba(15, 23, 42, .10);
  }
}

@media (max-width: 920px) {
  .kv-score-card {
    position: sticky;
    top: 8px;
    z-index: 60;
    background: linear-gradient(135deg, #ffffff, #eef6ff) !important;
    box-shadow: 0 12px 24px rgba(15, 23, 42, .09);
  }
}

/* PDF host must always be a complete A4 canvas without preview scaling. */
#kavenioPdfHost,
#kavenioPdfHost * {
  box-sizing: border-box !important;
}
#kavenioPdfHost {
  direction: ltr !important;
}
#kavenioPdfHost .cv-paper {
  width: 794px !important;
  min-width: 794px !important;
  max-width: 794px !important;
  height: 1123px !important;
  min-height: 1123px !important;
  max-height: 1123px !important;
  margin: 0 !important;
  transform: none !important;
  zoom: 1 !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  overflow: hidden !important;
}
#kavenioPdfHost .cv-layout {
  min-height: 1123px !important;
  height: 1123px !important;
}

/* Make Pro templates feel genuinely different. */
.cv-paper.template-professional .cv-layout {
  grid-template-columns: 1fr !important;
  grid-template-areas:
    "side"
    "main" !important;
}
.cv-paper.template-professional .cv-side {
  grid-area: side !important;
  background: linear-gradient(135deg, #1d4ed8, #0ea5e9) !important;
  color: #fff !important;
  padding: 32px 44px 26px !important;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, .8fr);
  gap: 20px;
  align-items: start;
}
.cv-paper.template-professional[dir="rtl"] .cv-side { grid-template-columns: minmax(220px, .8fr) minmax(0, 1fr); }
.cv-paper.template-professional .cv-main {
  grid-area: main !important;
  padding: 28px 46px 46px !important;
}
.cv-paper.template-professional .cv-side h3,
.cv-paper.template-professional .cv-contact,
.cv-paper.template-professional .cv-tags,
.cv-paper.template-professional .cv-list { margin-top: 8px; }
.cv-paper.template-professional .cv-photo { border-radius: 999px; }
.cv-paper.template-professional .cv-tag { background: rgba(255,255,255,.18); color: #fff; }

.cv-paper.template-executive .cv-side {
  background: #070707 !important;
  color: #f8fafc !important;
  border-inline-end: 6px solid #d4af37;
}
.cv-paper.template-executive[dir="rtl"] .cv-side { border-inline-end: 0; border-inline-start: 6px solid #d4af37; }
.cv-paper.template-executive .cv-name { font-family: 'Merriweather', Georgia, serif; color: #fff; }
.cv-paper.template-executive .cv-accent-line,
.cv-paper.template-executive .cv-side h3,
.cv-paper.template-executive .cv-main h3 { border-color: #d4af37 !important; background-color: #d4af37; }
.cv-paper.template-executive .cv-main { background: #fffdf8; }

.cv-paper.template-premium-classic {
  border: 10px solid #f5efe3;
  background: #fffaf2 !important;
}
.cv-paper.template-premium-classic .cv-layout {
  grid-template-columns: 1fr !important;
  grid-template-areas: "side" "main" !important;
}
.cv-paper.template-premium-classic .cv-side {
  grid-area: side !important;
  background: #fffaf2 !important;
  color: #432818 !important;
  padding: 36px 54px 18px !important;
  text-align: center !important;
  border-bottom: 2px solid #d6ad60;
}
.cv-paper.template-premium-classic .cv-main {
  grid-area: main !important;
  padding: 26px 56px 48px !important;
}
.cv-paper.template-premium-classic .cv-name { font-family: 'Merriweather', Georgia, serif; color: #432818; }
.cv-paper.template-premium-classic .cv-title { color: #7c2d12 !important; }
.cv-paper.template-premium-classic .cv-tag { background: #fff7ed; color: #7c2d12; border: 1px solid #fed7aa; }

.cv-paper.template-ceo-modern .cv-layout {
  grid-template-columns: 300px minmax(0, 1fr) !important;
  grid-template-areas: "side main" !important;
}
.cv-paper.template-ceo-modern[dir="rtl"] .cv-layout {
  grid-template-columns: minmax(0, 1fr) 300px !important;
  grid-template-areas: "main side" !important;
}
.cv-paper.template-ceo-modern .cv-side {
  background: linear-gradient(180deg, #111827, #334155) !important;
  color: #fff !important;
  padding: 50px 34px !important;
}
.cv-paper.template-ceo-modern .cv-main { padding: 54px 48px !important; background: #f8fafc; }
.cv-paper.template-ceo-modern .cv-section { background: #fff; border-radius: 18px; padding: 16px 18px; box-shadow: 0 8px 18px rgba(15,23,42,.05); }
.cv-paper.template-ceo-modern .cv-name { font-size: calc(35px * var(--cv-scale-font)); }

.cv-paper.template-tech-impact {
  background: #020617 !important;
  color: #d1fae5 !important;
}
.cv-paper.template-tech-impact .cv-side {
  background: #020617 !important;
  color: #d1fae5 !important;
  border-inline-end: 1px solid rgba(34,197,94,.35);
}
.cv-paper.template-tech-impact[dir="rtl"] .cv-side { border-inline-end: 0; border-inline-start: 1px solid rgba(34,197,94,.35); }
.cv-paper.template-tech-impact .cv-main { background: #07111f !important; color: #e2e8f0 !important; }
.cv-paper.template-tech-impact .cv-meta { color: #86efac !important; }
.cv-paper.template-tech-impact .cv-tag { background: rgba(34,197,94,.15) !important; color: #bbf7d0 !important; border: 1px solid rgba(34,197,94,.35); }
.cv-paper.template-tech-impact .cv-accent-line,
.cv-paper.template-tech-impact .cv-side h3,
.cv-paper.template-tech-impact .cv-main h3 { border-color: #22c55e !important; background: #22c55e; color: #bbf7d0; }

.cv-paper.template-creative-studio .cv-layout {
  grid-template-columns: 285px minmax(0, 1fr) !important;
  grid-template-areas: "side main" !important;
}
.cv-paper.template-creative-studio[dir="rtl"] .cv-layout {
  grid-template-columns: minmax(0, 1fr) 285px !important;
  grid-template-areas: "main side" !important;
}
.cv-paper.template-creative-studio .cv-side {
  background: radial-gradient(circle at 20% 12%, #fef3c7, transparent 28%), linear-gradient(180deg, #7c3aed, #db2777) !important;
  color: #fff !important;
}
.cv-paper.template-creative-studio .cv-main {
  background: linear-gradient(180deg, #fff, #faf5ff) !important;
  padding: 44px 42px !important;
}
.cv-paper.template-creative-studio .cv-section h3 { color: #7c3aed !important; }
.cv-paper.template-creative-studio .cv-photo { border-radius: 34% 66% 47% 53% / 43% 40% 60% 57% !important; }
.cv-paper.template-creative-studio .cv-tag { background: rgba(255,255,255,.2) !important; color: #fff; }

.cv-paper.template-modern .cv-side { background: #0f172a !important; }
.cv-paper.template-elegant-fresher .cv-side { background: #eff6ff !important; color: #0f172a !important; }
.cv-paper.template-global-ats { box-shadow: none !important; border: 1px solid #d1d5db; }

/* AI apply button appears only after suggestions are generated. */
.kv-ai-apply {
  margin-top: 12px;
  width: 100%;
  justify-content: center;
}
.kv-ai-output pre {
  white-space: pre-wrap;
  font: inherit;
  margin: 0;
}

@media (min-width: 921px) {
  body.cv-builder-page { height: 100dvh; }
  .kv-builder-shell { height: auto !important; min-height: 0 !important; }
}


/* =========================================================
   v19 — PDF export, mobile drawer readability, AI skills split
   ========================================================= */
#kavenioPdfHost,
#kavenioPdfHost * {
  box-sizing: border-box !important;
  animation: none !important;
  transition: none !important;
}
#kavenioPdfHost {
  width: 794px !important;
  min-width: 794px !important;
  min-height: 1123px !important;
  height: 1123px !important;
  display: block !important;
  background: #ffffff !important;
  opacity: 1 !important;
  visibility: visible !important;
  transform: none !important;
}
#kavenioPdfHost .cv-paper,
#cvPdfExport {
  width: 794px !important;
  min-width: 794px !important;
  max-width: 794px !important;
  min-height: 1123px !important;
  height: 1123px !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  transform: none !important;
  zoom: 1 !important;
  opacity: 1 !important;
  visibility: visible !important;
  overflow: visible !important;
  background: #ffffff !important;
}
#kavenioPdfHost .cv-layout {
  min-height: 1123px !important;
}

@media (max-width: 920px) {
  .kv-mobile-drawer-panel {
    width: min(92vw, 390px) !important;
    max-width: 390px !important;
  }
  .kv-drawer-head {
    flex: 0 0 auto !important;
    min-height: 72px !important;
    padding: 16px !important;
    background: #fff !important;
  }
  .kv-drawer-head strong {
    font-size: 1.08rem !important;
    line-height: 1.3 !important;
  }
  .kv-drawer-body {
    display: flex !important;
    flex-direction: column !important;
    align-content: stretch !important;
    gap: 10px !important;
    padding: 14px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    background: #f8fbff !important;
  }
  .kv-drawer-body > button,
  .kv-drawer-body > a {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 100% !important;
    min-height: 48px !important;
    height: auto !important;
    padding: 11px 14px !important;
    line-height: 1.45 !important;
    white-space: normal !important;
    border-radius: 15px !important;
    text-align: start !important;
  }
  .kv-drawer-body label {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    width: 100% !important;
    min-height: auto !important;
    height: auto !important;
    padding: 11px 12px !important;
    gap: 7px !important;
    line-height: 1.35 !important;
    border-radius: 15px !important;
    overflow: visible !important;
  }
  .kv-drawer-body label span {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    color: #64748b !important;
    font-size: .76rem !important;
    font-weight: 900 !important;
    line-height: 1.25 !important;
  }
  .kv-drawer-body select,
  .kv-drawer-body input[type="color"] {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 40px !important;
    height: 40px !important;
    margin: 0 !important;
    padding: 0 10px !important;
    border: 1px solid rgba(15,23,42,.10) !important;
    border-radius: 12px !important;
    background: #ffffff !important;
    color: #0f172a !important;
    font-size: .92rem !important;
    font-weight: 850 !important;
    line-height: 40px !important;
    outline: 0 !important;
  }
  .kv-drawer-body input[type="color"] {
    padding: 4px !important;
  }
  .kv-drawer-lang {
    flex: 0 0 auto !important;
    width: 100% !important;
    min-height: 46px !important;
  }
  .kv-drawer-lang button {
    min-height: 36px !important;
    line-height: 1.2 !important;
  }
}
/* Compact CV readiness header */
.kv-form-head-slim {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 10px 14px !important;
  margin: -18px -18px 12px !important;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.kv-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.kv-head-row h1 {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0 !important;
  font-size: 1rem !important;
  line-height: 1.25 !important;
  font-weight: 950 !important;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kv-score-slim {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 190px;
  padding: 5px 8px;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.kv-score-slim .kv-score-number {
  min-width: 44px;
  height: 26px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #facc15;
  color: #111827;
  font-size: 0.74rem;
  font-weight: 950;
}

.kv-score-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
}

.kv-score-text span {
  font-size: 0.62rem;
  color: #64748b;
  font-weight: 800;
  white-space: nowrap;
}

.kv-score-text strong {
  max-width: 105px;
  font-size: 0.72rem;
  color: #0f172a;
  font-weight: 950;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kv-score-progress {
  margin-top: 7px;
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
}

.kv-score-progress .kv-score-line {
  height: 5px;
  border-radius: 999px;
  overflow: hidden;
  background: #e5e7eb;
}

.kv-score-progress .kv-score-line span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f59e0b, #facc15);
}

.kv-score-progress small {
  min-width: 0;
  color: #64748b;
  font-size: 0.68rem;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mobile */
@media (max-width: 640px) {
  .kv-form-head-slim {
    padding: 8px 10px !important;
    margin: -14px -14px 10px !important;
  }

  .kv-head-row {
    gap: 8px;
  }

  .kv-head-row h1 {
    font-size: 0.9rem !important;
  }

  .kv-score-slim {
    max-width: 70px;
    padding: 3px 5px;
  }

  .kv-score-text {
    display: none;
  }

  .kv-score-slim .kv-score-number {
    min-width: 42px;
    height: 24px;
    font-size: 0.7rem;
  }

  .kv-score-progress {
    grid-template-columns: 70px minmax(0, 1fr);
    gap: 7px;
    margin-top: 6px;
  }

  .kv-score-progress small {
    font-size: 0.62rem;
  }
}

/* Final clean score header override */
.kv-form-head-slim {
  position: sticky !important;
  top: 0 !important;
  z-index: 40 !important;
  padding: 10px 14px 9px !important;
  margin: 0 !important;
  background: rgba(255, 255, 255, 0.98) !important;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08) !important;
  border-radius: 24px 24px 0 0 !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.kv-head-row {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 10px !important;
  min-width: 0 !important;
}

.kv-head-row h1 {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  margin: 0 !important;
  font-size: 1.05rem !important;
  line-height: 1.25 !important;
  font-weight: 950 !important;
  color: #0f172a !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

/* خلي الظاهر فقط النسبة */
.kv-score-slim {
  flex: 0 0 auto !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: auto !important;
  max-width: none !important;
  min-width: 58px !important;
  height: 30px !important;
  padding: 0 12px !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: #facc15 !important;
  box-shadow: none !important;
}

/* إلغاء شكل المربع القديم */
.kv-score-slim .kv-score-number,
.kv-form-head-slim .kv-score-number {
  width: auto !important;
  height: auto !important;
  min-width: 0 !important;
  padding: 0 !important;
  display: inline !important;
  background: transparent !important;
  border-radius: 0 !important;
  color: #111827 !important;
  font-size: 0.78rem !important;
  font-weight: 950 !important;
  line-height: 1 !important;
}

/* إخفاء جاهزية السيرة + ممتازة نهائيًا من الهيدر */
.kv-score-text {
  display: none !important;
}

.kv-score-progress {
  margin-top: 7px !important;
  display: grid !important;
  grid-template-columns: 96px minmax(0, 1fr) !important;
  align-items: center !important;
  gap: 9px !important;
  min-width: 0 !important;
}

.kv-score-progress .kv-score-line {
  height: 5px !important;
  margin: 0 !important;
  border-radius: 999px !important;
  overflow: hidden !important;
  background: #e5e7eb !important;
}

.kv-score-progress .kv-score-line span {
  display: block !important;
  height: 100% !important;
  border-radius: inherit !important;
  background: linear-gradient(90deg, #f59e0b, #facc15) !important;
}

.kv-score-progress small {
  display: block !important;
  min-width: 0 !important;
  color: #64748b !important;
  font-size: 0.68rem !important;
  line-height: 1.25 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

@media (max-width: 640px) {
  .kv-form-head-slim {
    padding: 8px 10px !important;
  }

  .kv-head-row h1 {
    font-size: 0.9rem !important;
  }

  .kv-score-slim {
    min-width: 50px !important;
    height: 26px !important;
    padding: 0 9px !important;
  }

  .kv-score-slim .kv-score-number,
  .kv-form-head-slim .kv-score-number {
    font-size: 0.72rem !important;
  }

  .kv-score-progress {
    grid-template-columns: 72px minmax(0, 1fr) !important;
    gap: 7px !important;
    margin-top: 6px !important;
  }

  .kv-score-progress small {
    font-size: 0.62rem !important;
  }
}

/* =========================================================
   Fix Professional Template — clean corporate sidebar layout
   ========================================================= */

.cv-paper.template-professional {
  background: #ffffff !important;
  color: #111827 !important;
  border: 0 !important;
}

/* LTR: sidebar left, content right */
.cv-paper.template-professional[dir="ltr"] .cv-layout {
  direction: ltr !important;
  display: grid !important;
  grid-template-columns: 270px minmax(0, 1fr) !important;
  grid-template-areas: "side main" !important;
  min-height: 1123px !important;
}

/* RTL: sidebar right, content left */
.cv-paper.template-professional[dir="rtl"] .cv-layout {
  direction: ltr !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 270px !important;
  grid-template-areas: "main side" !important;
  min-height: 1123px !important;
}

.cv-paper.template-professional .cv-side {
  grid-area: side !important;
  display: block !important;
  padding: 46px 30px !important;
  background:
    linear-gradient(180deg, #0f172a 0%, #1e3a8a 58%, #1d4ed8 100%) !important;
  color: #ffffff !important;
}

.cv-paper.template-professional .cv-main {
  grid-area: main !important;
  padding: 48px 46px !important;
  background: #ffffff !important;
  color: #111827 !important;
}

.cv-paper.template-professional[dir="rtl"] .cv-side,
.cv-paper.template-professional[dir="rtl"] .cv-main {
  direction: rtl !important;
  text-align: right !important;
}

.cv-paper.template-professional[dir="ltr"] .cv-side,
.cv-paper.template-professional[dir="ltr"] .cv-main {
  direction: ltr !important;
  text-align: left !important;
}

/* Photo */
.cv-paper.template-professional .cv-photo {
  width: 112px !important;
  height: 112px !important;
  border-radius: 28px !important;
  object-fit: cover !important;
  display: block !important;
  margin: 0 0 24px !important;
  border: 4px solid rgba(255, 255, 255, 0.22) !important;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.20) !important;
}

.cv-paper.template-professional[dir="rtl"] .cv-photo {
  margin-right: 0 !important;
  margin-left: auto !important;
}

.cv-paper.template-professional[dir="ltr"] .cv-photo {
  margin-left: 0 !important;
  margin-right: auto !important;
}

/* Name and title */
.cv-paper.template-professional .cv-name {
  margin: 0 !important;
  color: #ffffff !important;
  font-size: calc(30px * var(--cv-scale-font)) !important;
  line-height: 1.18 !important;
  font-weight: 950 !important;
  letter-spacing: -0.02em !important;
}

.cv-paper.template-professional .cv-title {
  margin: 10px 0 22px !important;
  color: rgba(255, 255, 255, 0.82) !important;
  font-size: calc(14px * var(--cv-scale-font)) !important;
  font-weight: 800 !important;
}

/* Accent line */
.cv-paper.template-professional .cv-accent-line {
  width: 58px !important;
  height: 4px !important;
  margin: 0 0 26px !important;
  border-radius: 999px !important;
  background: #facc15 !important;
}

.cv-paper.template-professional[dir="rtl"] .cv-accent-line {
  margin-right: 0 !important;
  margin-left: auto !important;
}

.cv-paper.template-professional[dir="ltr"] .cv-accent-line {
  margin-left: 0 !important;
  margin-right: auto !important;
}

/* Sidebar headings */
.cv-paper.template-professional .cv-side h3 {
  margin: 24px 0 10px !important;
  padding-bottom: 8px !important;
  color: #ffffff !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.28) !important;
  font-size: calc(13px * var(--cv-scale-font)) !important;
  font-weight: 950 !important;
}

/* Contact and lists */
.cv-paper.template-professional .cv-contact {
  display: grid !important;
  gap: 9px !important;
  margin: 12px 0 18px !important;
  color: rgba(255, 255, 255, 0.88) !important;
  font-size: calc(12px * var(--cv-scale-font)) !important;
  line-height: 1.55 !important;
}

.cv-paper.template-professional .cv-contact div {
  word-break: break-word !important;
}

.cv-paper.template-professional .cv-list {
  margin: 0 !important;
  color: rgba(255, 255, 255, 0.88) !important;
  font-size: calc(12px * var(--cv-scale-font)) !important;
  line-height: 1.7 !important;
}

.cv-paper.template-professional[dir="rtl"] .cv-list {
  padding-right: 18px !important;
  padding-left: 0 !important;
}

.cv-paper.template-professional[dir="ltr"] .cv-list {
  padding-left: 18px !important;
  padding-right: 0 !important;
}

/* Skills tags */
.cv-paper.template-professional .cv-tags {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 7px !important;
  margin-top: 12px !important;
}

.cv-paper.template-professional .cv-tag {
  padding: 5px 9px !important;
  border-radius: 999px !important;
  background: rgba(255, 255, 255, 0.16) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.16) !important;
  font-size: calc(11px * var(--cv-scale-font)) !important;
  font-weight: 800 !important;
}

/* Main content */
.cv-paper.template-professional .cv-main h3 {
  margin: 0 0 14px !important;
  padding-bottom: 8px !important;
  color: #1d4ed8 !important;
  border-bottom: 2px solid #1d4ed8 !important;
  font-size: calc(15px * var(--cv-scale-font)) !important;
  font-weight: 950 !important;
}

.cv-paper.template-professional .cv-section {
  margin-bottom: 26px !important;
}

.cv-paper.template-professional .cv-section p {
  margin: 0 !important;
  color: #334155 !important;
  line-height: 1.75 !important;
}

.cv-paper.template-professional .cv-item {
  position: relative !important;
  margin-bottom: 18px !important;
  padding-bottom: 16px !important;
  border-bottom: 1px solid #e5e7eb !important;
}

.cv-paper.template-professional .cv-item:last-child {
  border-bottom: 0 !important;
  padding-bottom: 0 !important;
}

.cv-paper.template-professional .cv-item h4 {
  margin: 0 0 4px !important;
  color: #0f172a !important;
  font-size: calc(15px * var(--cv-scale-font)) !important;
  font-weight: 950 !important;
}

.cv-paper.template-professional .cv-meta {
  margin: 0 0 8px !important;
  color: #2563eb !important;
  font-size: calc(12px * var(--cv-scale-font)) !important;
  font-weight: 900 !important;
}

.cv-paper.template-professional .cv-bullet-text {
  color: #334155 !important;
  line-height: 1.75 !important;
  white-space: pre-line !important;
}

/* PDF export safety */
#kavenioPdfHost .cv-paper.template-professional .cv-layout {
  min-height: 1123px !important;
}

/* =========================
   Mobile bottom tab bar
   ========================= */
@media (max-width: 920px) {
  .kv-section-tabs {
    position: fixed !important;
    left: 12px !important;
    right: 12px !important;
    bottom: calc(10px + env(safe-area-inset-bottom)) !important;
    z-index: 1400 !important;

    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 8px !important;

    padding: 8px !important;
    margin: 0 !important;

    background: rgba(255, 255, 255, 0.96) !important;
    border: 1px solid rgba(15, 23, 42, 0.08) !important;
    border-radius: 22px !important;
    box-shadow: 0 16px 38px rgba(15, 23, 42, 0.16) !important;

    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .kv-section-tabs button {
    min-width: 0 !important;
    min-height: 72px !important;
    padding: 8px 6px !important;
    margin: 0 !important;

    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;

    border: 0 !important;
    border-radius: 16px !important;
    background: transparent !important;
    color: #64748b !important;

    font-size: 0.72rem !important;
    font-weight: 800 !important;
    line-height: 1.15 !important;
    text-align: center !important;

    transition: 0.2s ease;
  }

  .kv-section-tabs button.is-active {
    background: linear-gradient(135deg, #1d4ed8, #0ea5e9) !important;
    color: #ffffff !important;
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.24) !important;
  }

  .kv-section-tabs button:hover {
    transform: none !important;
  }

  .kv-section-tabs button > i,
  .kv-section-tabs button > svg,
  .kv-section-tabs button .kv-tab-icon,
  .kv-section-tabs button .tab-icon {
    width: 20px !important;
    height: 20px !important;
    font-size: 18px !important;
    flex: 0 0 auto !important;
  }

  .kv-section-tabs button > span,
  .kv-section-tabs button .kv-tab-label,
  .kv-section-tabs button .tab-label {
    display: block !important;
    max-width: 100% !important;
    white-space: normal !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* حتى لا يغطي البار أسفل الصفحة */
  body,
  .kv-app,
  .kv-builder,
  .kv-shell,
  .kv-page {
    padding-bottom: 110px !important;
  }

  /* إذا عندك كرت النموذج أو المحتوى طويل */
  .kv-form-card,
  .kv-main-content,
  .kv-builder-main {
    margin-bottom: 16px !important;
  }
}

/* اختياري: على الشاشات الكبيرة يرجع طبيعي */
@media (min-width: 921px) {
  .kv-section-tabs {
    position: static !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    box-shadow: none !important;
  }
}

/* =========================
   Mobile sticky preview box
   ========================= */
@media (max-width: 920px) {
  .kv-preview-panel {
    position: sticky !important;
    top: 64px !important;
    z-index: 1300 !important;
    order: 0 !important;

    margin: 0 0 10px !important;
    border-radius: 20px !important;
    background: rgba(255, 255, 255, 0.97) !important;
    border: 1px solid rgba(15, 23, 42, 0.08) !important;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12) !important;

    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    overflow: hidden !important;
  }

  .kv-preview-toolbar {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px !important;

    min-height: 64px !important;
    padding: 10px 12px !important;
    background: transparent !important;
    border-bottom: 0 !important;
  }

  .kv-preview-toolbar strong,
  .kv-preview-toolbar h2,
  .kv-preview-toolbar h3 {
    margin: 0 !important;
    font-size: 0.95rem !important;
    font-weight: 950 !important;
    color: #0f172a !important;
    white-space: nowrap !important;
  }

  .kv-preview-toolbar .kv-btn,
  .kv-preview-toolbar button {
    min-height: 42px !important;
    padding: 0 14px !important;
    border-radius: 14px !important;
    font-size: 0.82rem !important;
    font-weight: 900 !important;
  }

  /* نخفي المعاينة الكبيرة داخل الكرت في الجوال */
  .kv-preview-scroll {
    display: none !important;
  }

  /* حتى لا يختفي المحتوى تحت مربع المعاينة الثابت */
  .kv-builder-shell {
    padding-top: 8px !important;
  }
}

/* للشاشات الصغيرة جدًا */
@media (max-width: 420px) {
  .kv-preview-panel {
    top: 58px !important;
    border-radius: 18px !important;
  }

  .kv-preview-toolbar {
    min-height: 58px !important;
    padding: 8px 10px !important;
  }

  .kv-preview-toolbar .kv-btn,
  .kv-preview-toolbar button {
    min-height: 38px !important;
    padding: 0 12px !important;
    font-size: 0.78rem !important;
  }
}

/* ==========================================
   Mobile preview modal fix
   - Hide sticky preview box when modal opens
   - Hide bottom app tabs when modal opens
   - Fit A4 CV inside mobile width
   ========================================== */

@media (max-width: 920px) {
  body.kv-preview-open .kv-preview-panel,
  body.kv-preview-open .kv-section-tabs {
    display: none !important;
  }

  #previewModal.is-open {
    position: fixed !important;
    inset: 0 !important;
    z-index: 5000 !important;
    display: flex !important;
    align-items: stretch !important;
    justify-content: center !important;
    background: #f1f5f9 !important;
    overflow: hidden !important;
  }

  #previewModal.is-open .kv-modal-dialog,
  #previewModal.is-open .kv-preview-modal,
  #previewModal.is-open .kv-modal-content {
    width: 100vw !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    background: #f1f5f9 !important;
    overflow: hidden !important;
  }

  #previewModal.is-open .kv-modal-head,
  #previewModal.is-open .kv-preview-modal-head {
    position: sticky !important;
    top: 0 !important;
    z-index: 20 !important;
    min-height: 62px !important;
    padding: 12px 16px !important;
    background: rgba(255, 255, 255, 0.96) !important;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08) !important;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  #previewModal.is-open .kv-modal-body,
  #previewModal.is-open .kv-preview-modal-body {
    height: calc(100dvh - 62px) !important;
    max-height: calc(100dvh - 62px) !important;
    padding: 14px !important;
    overflow: auto !important;
    overflow-x: hidden !important;
    background: #eef4fb !important;
  }

  #previewModal.is-open #cvPreviewMobile {
    width: 794px !important;
    min-width: 794px !important;
    max-width: 794px !important;
    min-height: 1123px !important;
    margin: 0 auto !important;
    transform-origin: top center !important;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18) !important;
    border-radius: 0 !important;
  }

  /* Fit A4 preview to common mobile widths */
  @media (max-width: 420px) {
    #previewModal.is-open #cvPreviewMobile {
      transform: scale(0.47) !important;
      margin-bottom: -570px !important;
    }
  }

  @media (min-width: 421px) and (max-width: 520px) {
    #previewModal.is-open #cvPreviewMobile {
      transform: scale(0.58) !important;
      margin-bottom: -470px !important;
    }
  }

  @media (min-width: 521px) and (max-width: 720px) {
    #previewModal.is-open #cvPreviewMobile {
      transform: scale(0.72) !important;
      margin-bottom: -315px !important;
    }
  }

  @media (min-width: 721px) and (max-width: 920px) {
    #previewModal.is-open #cvPreviewMobile {
      transform: scale(0.9) !important;
      margin-bottom: -110px !important;
    }
  }
}

/* =====================================================
   Mobile menu + preview modal final fix
   ===================================================== */

@media (max-width: 920px) {
  /* عند فتح القائمة أو المعاينة نخفي العناصر الثابتة */
  body.kv-menu-open .kv-preview-panel,
  body.kv-menu-open .kv-section-tabs,
  body.kv-preview-open .kv-preview-panel,
  body.kv-preview-open .kv-section-tabs {
    display: none !important;
  }

  /* القائمة تكون فوق كل شيء */
  #mobileDrawer {
    z-index: 6500 !important;
  }

  #mobileDrawer.is-open {
    position: fixed !important;
    inset: 0 !important;
    z-index: 6500 !important;
  }

  /* صفحة المعاينة كاملة */
  #previewModal.is-open {
    position: fixed !important;
    inset: 0 !important;
    z-index: 7000 !important;
    display: block !important;
    width: 100vw !important;
    height: 100dvh !important;
    background: #eef4fb !important;
    overflow: hidden !important;
  }

  #previewModal.is-open .kv-modal-dialog,
  #previewModal.is-open .kv-modal-content,
  #previewModal.is-open .kv-preview-modal,
  #previewModal.is-open .kv-preview-modal-content {
    width: 100vw !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    background: #eef4fb !important;
    overflow: hidden !important;
  }

  #previewModal.is-open .kv-modal-head,
  #previewModal.is-open .kv-preview-modal-head {
    position: sticky !important;
    top: 0 !important;
    z-index: 20 !important;
    min-height: 62px !important;
    padding: 12px 16px !important;
    background: rgba(255, 255, 255, 0.97) !important;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08) !important;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  #previewModal.is-open .kv-modal-body,
  #previewModal.is-open .kv-preview-modal-body {
    width: 100vw !important;
    height: calc(100dvh - 62px) !important;
    max-height: calc(100dvh - 62px) !important;
    padding: 14px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    background: #eef4fb !important;
  }

  /* السيرة تظهر كاملة بعرض الهاتف بدون تمرير يمين/يسار */
  #previewModal.is-open #cvPreviewMobile {
    width: 794px !important;
    min-width: 794px !important;
    max-width: 794px !important;
    min-height: 1123px !important;

    position: relative !important;
    left: 50% !important;

    transform: translateX(-50%) scale(var(--kv-mobile-preview-scale, 0.48)) !important;
    transform-origin: top center !important;

    margin-top: 0 !important;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18) !important;
    border-radius: 0 !important;
    background: #ffffff !important;
  }
}
/* =====================================================
   Final Arabic mobile preview centering fix
   ===================================================== */

@media (max-width: 920px) {
  #previewModal.is-open .kv-modal-body,
  #previewModal.is-open .kv-preview-modal-body {
    direction: ltr !important;
    text-align: initial !important;
    overflow-x: hidden !important;
  }

  #previewModal.is-open #cvPreviewMobile {
    width: 794px !important;
    min-width: 794px !important;
    max-width: 794px !important;
    min-height: 1123px !important;

    position: relative !important;

    left: auto !important;
    right: auto !important;

    margin-top: 0 !important;
    margin-left: var(--kv-mobile-preview-left, 0px) !important;
    margin-right: 0 !important;

    transform: scale(var(--kv-mobile-preview-scale, 0.48)) !important;
    transform-origin: top left !important;

    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18) !important;
    border-radius: 0 !important;
    background: #ffffff !important;
  }

  #previewModal.is-open #cvPreviewMobile[dir="rtl"] {
    direction: rtl !important;
  }

  #previewModal.is-open #cvPreviewMobile[dir="ltr"] {
    direction: ltr !important;
  }
}

/* =====================================
   AI Assistant tab upgrade
   ===================================== */

.kv-ai-card-upgraded {
  display: grid;
  gap: 14px;
}

.kv-ai-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.kv-ai-topbar h2 {
  margin: 10px 0 0;
}

.kv-ai-credits-box {
  flex: 0 0 auto;
  min-width: 112px;
  padding: 9px 12px;
  border-radius: 18px;
  background: linear-gradient(135deg, #eff6ff, #ffffff);
  border: 1px solid rgba(15, 128, 255, 0.16);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
  text-align: center;
}

.kv-ai-credits-box span {
  display: block;
  color: #64748b;
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1.2;
}

.kv-ai-credits-box strong {
  display: block;
  margin-top: 4px;
  color: #0f172a;
  font-size: 1.05rem;
  font-weight: 950;
  line-height: 1;
}

.kv-ai-credits-box.is-guest strong {
  font-size: 0.76rem;
  color: #1d4ed8;
}

.kv-ai-result-panel {
  position: sticky;
  top: 0;
  z-index: 8;
  padding: 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(15, 23, 42, 0.10);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.07);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.kv-ai-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.kv-ai-result-head strong {
  font-size: 0.9rem;
  font-weight: 950;
  color: #0f172a;
}

.kv-ai-result-head .kv-ai-apply {
  width: auto;
  min-height: 34px;
  padding: 0 12px;
  margin: 0;
  border-radius: 12px;
  font-size: 0.76rem;
}

.kv-ai-output {
  min-height: 76px;
  max-height: 240px;
  overflow: auto;
  padding: 12px;
  border-radius: 16px;
  border: 1px dashed rgba(15, 128, 255, 0.25);
  background: #f8fbff;
  line-height: 1.75;
}

.kv-ai-output pre {
  margin: 0;
  white-space: pre-wrap;
  font: inherit;
  line-height: 1.75;
}

.kv-ai-empty {
  display: block;
  color: #64748b;
  font-size: 0.85rem;
  font-weight: 800;
}

.kv-ai-inputs {
  display: grid;
  gap: 12px;
}

@media (max-width: 640px) {
  .kv-ai-topbar {
    align-items: stretch;
  }

  .kv-ai-credits-box {
    min-width: 94px;
    padding: 8px 9px;
    border-radius: 16px;
  }

  .kv-ai-credits-box strong {
    font-size: 0.9rem;
  }

  .kv-ai-result-panel {
    padding: 10px;
    border-radius: 18px;
  }

  .kv-ai-output {
    max-height: 210px;
    min-height: 68px;
    font-size: 0.86rem;
  }

  .kv-ai-result-head {
    align-items: flex-start;
  }

  .kv-ai-result-head .kv-ai-apply {
    max-width: 150px;
    white-space: normal;
    line-height: 1.25;
    padding: 6px 10px;
  }
}
/* =====================================
   CV Import box inside AI tab
   ===================================== */

.kv-cv-import-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 13px;
  border-radius: 20px;
  background: linear-gradient(135deg, #f8fbff, #ffffff);
  border: 1px solid rgba(15, 128, 255, 0.14);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
}

.kv-cv-import-box strong {
  display: block;
  color: #0f172a;
  font-size: 0.92rem;
  font-weight: 950;
}

.kv-cv-import-box small {
  display: block;
  margin-top: 3px;
  color: #64748b;
  font-size: 0.76rem;
  line-height: 1.45;
}

.kv-import-file {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  max-width: 190px;
  padding: 0 12px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.12);
  color: #0f172a;
  font-size: 0.8rem;
  font-weight: 900;
  cursor: pointer;
  overflow: hidden;
}

.kv-import-file input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.kv-import-file span {
  display: block;
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 760px) {
  .kv-cv-import-box {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .kv-import-file {
    width: 100%;
    max-width: 100%;
  }

  .kv-import-file span {
    max-width: 100%;
  }
}

/* =====================================================
   FINAL FIX: AI CV Import Box - clean responsive layout
   ===================================================== */

.kv-ai-card-upgraded {
  container-type: inline-size;
}

.kv-cv-import-box {
  display: grid !important;
  grid-template-columns: 1fr !important;
  grid-template-areas:
    "intro"
    "file"
    "read"
    "convert" !important;
  gap: 10px !important;
  align-items: stretch !important;
  width: 100% !important;
  max-width: 100% !important;
  padding: 14px !important;
  border-radius: 20px !important;
  overflow: hidden !important;
  direction: inherit !important;
}

.kv-cv-import-box > div:first-child {
  grid-area: intro !important;
  width: 100% !important;
  min-width: 0 !important;
}

.kv-cv-import-box strong {
  display: block !important;
  margin: 0 !important;
  color: #0f172a !important;
  font-size: 0.98rem !important;
  font-weight: 950 !important;
  line-height: 1.45 !important;
  white-space: normal !important;
  word-break: normal !important;
  overflow-wrap: normal !important;
}

.kv-cv-import-box small {
  display: block !important;
  margin-top: 5px !important;
  color: #64748b !important;
  font-size: 0.78rem !important;
  line-height: 1.75 !important;
  white-space: normal !important;
  word-break: normal !important;
  overflow-wrap: normal !important;
}

.kv-import-file {
  grid-area: file !important;
}

#extractCvBtn {
  grid-area: read !important;
}

#convertImportedCvBtn {
  grid-area: convert !important;
}

.kv-import-file,
#extractCvBtn,
#convertImportedCvBtn {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  min-height: 44px !important;
  height: auto !important;
  border-radius: 15px !important;
  white-space: normal !important;
  line-height: 1.35 !important;
  text-align: center !important;
}

.kv-import-file {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 12px !important;
}

.kv-import-file span {
  display: block !important;
  max-width: 100% !important;
  text-align: center !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

/* إذا صار الصندوق واسع كفاية، نجعل اختيار الملف وزر القراءة بجانب بعض */
@container (min-width: 560px) {
  .kv-cv-import-box {
    grid-template-columns: 1fr 1fr !important;
    grid-template-areas:
      "intro intro"
      "file read"
      "convert convert" !important;
  }
}

/* إذا صار الصندوق واسع جدًا، نجعل الثلاثة في صف واحد */
@container (min-width: 760px) {
  .kv-cv-import-box {
    grid-template-columns: minmax(0, 1fr) 160px 220px !important;
    grid-template-areas:
      "intro intro intro"
      "file read convert" !important;
    align-items: center !important;
  }
}

/* في الجوال اجعله عموديًا دائمًا */
@media (max-width: 920px) {
  .kv-cv-import-box {
    grid-template-columns: 1fr !important;
    grid-template-areas:
      "intro"
      "file"
      "read"
      "convert" !important;
  }
}

/* =====================================================
   Global centered toast / notifications
   ===================================================== */

.kv-toast,
.toast,
.app-toast,
.dashboard-toast,
.checkout-toast {
  position: fixed !important;
  left: 50% !important;
  top: 50% !important;
  bottom: auto !important;
  right: auto !important;
  z-index: 99999 !important;

  width: auto !important;
  max-width: min(92vw, 460px) !important;
  min-width: min(86vw, 300px) !important;

  padding: 14px 18px !important;
  border-radius: 18px !important;

  background: rgba(15, 23, 42, 0.96) !important;
  color: #ffffff !important;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.35) !important;

  text-align: center !important;
  font-weight: 900 !important;
  line-height: 1.7 !important;

  opacity: 0 !important;
  pointer-events: none !important;
  transform: translate(-50%, -42%) scale(0.96) !important;
  transition: opacity 0.2s ease, transform 0.2s ease !important;
}

.kv-toast.is-visible,
.toast.is-visible,
.app-toast.is-visible,
.dashboard-toast.is-visible,
.checkout-toast.is-visible,
.kv-toast.show,
.toast.show,
.app-toast.show,
.dashboard-toast.show,
.checkout-toast.show {
  opacity: 1 !important;
  transform: translate(-50%, -50%) scale(1) !important;
}