/* ==========================================================
   Interface de l'outil (formulaire + zone d'aperçu)
   Thème clair par défaut, thème sombre avec <html data-theme="dark">.
   La feuille du CV reste toujours blanche : c'est elle qu'on imprime.
   ========================================================== */
:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --panel: #ffffff;
  --soft: #f9fafb;
  --hover: #f3f4f6;
  --field: #ffffff;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --line-hover: #9ca3af;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --placeholder: #9ca3af;
  --primary: #111827;
  --primary-hover: #374151;
  --on-primary: #ffffff;
  --focus: #4f46e5;
  --focus-ring: rgba(79, 70, 229, .15);
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --tag-bg: #eef2ff;
  --tag-text: #3730a3;
  --warn-bg: #fef3c7;
  --warn-text: #92400e;
  --success: #15803d;
  --success-soft: #f0fdf4;
  --stage: #e5e7eb;
  --topbar: rgba(255, 255, 255, .92);
  --seg-active: #ffffff;
  --swatch-ring: rgba(0, 0, 0, .1);
  --page-shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 12px 32px rgba(0, 0, 0, .12);
  --topbar-h: 60px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1115;
  --panel: #171a21;
  --soft: #1d2129;
  --hover: #242934;
  --field: #12151b;
  --line: #2a2f3a;
  --line-strong: #3a404d;
  --line-hover: #566070;
  --text: #e8eaf0;
  --text-2: #c3c8d2;
  --muted: #8b93a3;
  --placeholder: #626b7a;
  --primary: #e8eaf0;
  --primary-hover: #ffffff;
  --on-primary: #111827;
  --focus: #818cf8;
  --focus-ring: rgba(129, 140, 248, .25);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, .12);
  --tag-bg: rgba(129, 140, 248, .16);
  --tag-text: #c7d2fe;
  --warn-bg: rgba(245, 158, 11, .15);
  --warn-text: #fcd34d;
  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, .08);
  --stage: #0b0d11;
  --topbar: rgba(23, 26, 33, .9);
  --seg-active: #2a2f3a;
  --swatch-ring: rgba(255, 255, 255, .2);
  --page-shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 16px 40px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Barre du haut ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: var(--topbar);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; flex: none; }
.brand__logo { display: block; height: 34px; width: auto; }
/* Thème sombre : les lettres noires deviennent blanches, le « CV » bleu reste bleu */
:root[data-theme="dark"] .brand__logo { filter: invert(1) hue-rotate(180deg); }
.topbar__status { margin-right: auto; color: var(--muted); font-size: 12.5px; transition: opacity .4s; }
.topbar__actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* Boutons du haut en puces avec icône (même allure que les styles du CV dans l'aperçu) */
.top-chip {
  appearance: none; display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: 9px;
  background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 500; white-space: nowrap;
  cursor: pointer; transition: color .15s, border-color .15s, background .15s;
}
.top-chip svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.top-chip:hover { color: var(--text); border-color: var(--line-hover); }
.top-chip--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.top-chip--danger:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.top-chip--main {
  --c: var(--cv-accent, #2b59c3);
  height: 36px; padding: 0 14px; margin-left: 4px;
  color: color-mix(in srgb, var(--c) 85%, #000);
  border-color: color-mix(in srgb, var(--c) 45%, transparent);
  background: color-mix(in srgb, var(--c) 12%, transparent);
  font-weight: 600;
}
.top-chip--main:hover { color: color-mix(in srgb, var(--c) 85%, #000); border-color: var(--c); background: color-mix(in srgb, var(--c) 18%, transparent); }
:root[data-theme="dark"] .top-chip--main,
:root[data-theme="dark"] .top-chip--main:hover { color: color-mix(in srgb, var(--c) 50%, #fff); border-color: color-mix(in srgb, var(--c) 60%, transparent); background: color-mix(in srgb, var(--c) 20%, transparent); }
:root[data-theme="dark"] .top-chip--main:hover { border-color: color-mix(in srgb, var(--c) 80%, #fff); }

/* ---------- Boutons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--panel); color: var(--text);
  font: inherit; font-size: 13.5px; font-weight: 500;
  padding: 8px 14px;
  cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--soft); border-color: var(--line-hover); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--hover); border-color: transparent; }
.btn--danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn--primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn--small { padding: 6px 11px; font-size: 13px; }
.btn--add { width: 100%; padding: 10px; background: transparent; border-style: dashed; color: var(--muted); }
.btn--add:hover { background: var(--panel); border-color: var(--muted); color: var(--text); }

/* Bouton avec seulement une icône (thème, masquer le formulaire) */
.btn--icon { display: inline-flex; align-items: center; justify-content: center; padding: 7px; color: var(--text-2); }
.btn--icon svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.theme-ico--sun { display: none; }
:root[data-theme="dark"] .theme-ico--sun { display: block; }
:root[data-theme="dark"] .theme-ico--moon { display: none; }

/* ---------- Mise en page générale ---------- */
.app {
  display: grid;
  grid-template-columns: minmax(400px, 520px) 1fr;
  height: calc(100vh - var(--topbar-h));
}
.app.is-collapsed { grid-template-columns: 1fr; }
.app.is-collapsed .editor, .app.is-collapsed .panel-toggle { display: none; }

/* ---------- Menu réduit : barre flottante sur l'aperçu, une icône par partie du formulaire ---------- */
.rail {
  grid-area: 2 / 1; align-self: start; justify-self: start; /* même case que le CV, posée par-dessus */
  z-index: 3;
  display: none; flex-direction: column; align-items: center; gap: 2px;
  margin: 16px; padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .14), 0 2px 6px rgba(0, 0, 0, .06);
}
.app.is-collapsed .rail { display: flex; }
/* Le CV laisse la place à la barre (des deux côtés, pour rester centré) */
.app.is-collapsed .preview__stage { padding-left: 84px; padding-right: 84px; }
.rail__sep { flex: none; width: 24px; height: 1px; margin: 3px 0; background: var(--line); }
.rail__btn {
  appearance: none; position: relative;
  display: grid; flex: none; place-items: center;
  width: 38px; height: 38px; padding: 0;
  border: 0; border-radius: 9px;
  background: transparent; color: var(--muted);
  font: inherit;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.rail__btn:hover { background: var(--hover); color: var(--text); }
.rail__btn svg, .card__ico {
  flex: none; width: 20px; height: 20px;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
/* Nom de la partie dans une bulle, au survol (ou au clavier) */
.rail__btn::after {
  content: attr(aria-label);
  position: absolute; left: calc(100% + 12px); top: 50%;
  transform: translate(-4px, -50%);
  padding: 5px 9px; border-radius: 6px;
  background: var(--primary); color: var(--on-primary);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
  font-size: 12.5px; font-weight: 500; line-height: 1.3; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .12s, transform .12s;
}
.rail__btn:hover::after, .rail__btn:focus-visible::after { opacity: 1; transform: translate(0, -50%); }

/* ---------- Formulaire ---------- */
.editor {
  display: flex; flex-direction: column; gap: 12px;
  padding: 20px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
}
.editor__foot { margin: 4px 0 24px; text-align: center; color: var(--muted); font-size: 12px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; scroll-margin-top: 20px; }
.card__head {
  display: flex; align-items: baseline; gap: 10px;
  padding: 14px 16px;
  list-style: none; cursor: pointer; user-select: none;
}
.card__head::-webkit-details-marker { display: none; }
.card__head::after {
  content: ''; align-self: center; margin-left: auto;
  width: 7px; height: 7px;
  border-right: 2px solid var(--placeholder); border-bottom: 2px solid var(--placeholder);
  transform: rotate(-45deg);
  transition: transform .2s;
}
.card[open] > .card__head::after { transform: rotate(45deg); }
.card__ico { align-self: center; width: 18px; height: 18px; color: var(--muted); }
.card__title { font-size: 15px; font-weight: 600; }
.card__hint { color: var(--muted); font-size: 12.5px; }
.card__body { display: flex; flex-direction: column; gap: 12px; padding: 0 16px 16px; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field__label { color: var(--text-2); font-size: 12.5px; font-weight: 500; }

input[type=text], input[type=email], input[type=tel], input[type=url], input[type=month], select, textarea {
  width: 100%; min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--field); color: var(--text);
  font: inherit; font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.5; }
input:hover, select:hover, textarea:hover { border-color: var(--line-hover); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
input:disabled { background: var(--soft); color: var(--placeholder); }
::placeholder { color: var(--placeholder); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.row { display: flex; gap: 8px; }
.hint { margin: 0; color: var(--muted); font-size: 12px; }
.hint:empty { display: none; }

.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--focus); }

.fieldset { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.fieldset legend { padding: 0 6px; color: var(--text-2); font-size: 12.5px; font-weight: 600; }

.phone { display: flex; gap: 8px; }
.phone select { flex: none; width: 112px; }

/* Photo : la vignette sert aussi à la cadrer (on la fait glisser) */
.photo-field { display: flex; align-items: center; gap: 14px; }
.photo-field__thumb {
  flex: none; width: 84px; height: 84px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--hover);
  border: 1px dashed var(--line-strong);
  touch-action: none;
}
.photo-field__thumb[data-shape="rounded"] { border-radius: 14%; }
.photo-field__thumb[data-shape="square"] { border-radius: 0; }
.photo-field__thumb.has-photo { border: 0; cursor: grab; }
.photo-field__thumb.is-dragging { cursor: grabbing; }
.photo-field__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; user-select: none; }
.photo-field__actions { display: flex; flex: 1; flex-direction: column; gap: 6px; min-width: 0; }
.photo-zoom { display: flex; align-items: center; gap: 8px; }
.photo-zoom[hidden] { display: none; }
.photo-zoom__label { color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.photo-zoom input[type=range] { flex: 1; min-width: 0; accent-color: var(--focus); }

/* Personnaliser la photo : forme, taille, position, bordure, couleur */
.photo-style { --tile-bg: #fff; --tile-r: 50%; border: 1px solid var(--line); border-radius: 10px; }
.photo-style[data-tpl="moderne"] { --tile-bg: color-mix(in srgb, var(--accent) 10%, #fff); }
.photo-style[data-tpl="tendance"] { --tile-bg: var(--accent); }
.photo-style[data-tpl="tech-editor"] { --tile-bg: #0f172a; }
.photo-style[data-shape="rounded"] { --tile-r: 14%; }
.photo-style[data-shape="square"] { --tile-r: 0; }
.photo-style__head {
  display: flex; align-items: baseline; gap: 8px;
  padding: 10px 12px;
  list-style: none; cursor: pointer; user-select: none;
  font-size: 13.5px; font-weight: 600;
}
.photo-style__head::-webkit-details-marker { display: none; }
.photo-style__head::after {
  content: ''; align-self: center; margin-left: auto;
  width: 6px; height: 6px;
  border-right: 2px solid var(--placeholder); border-bottom: 2px solid var(--placeholder);
  transform: rotate(-45deg);
  transition: transform .2s;
}
.photo-style[open] > .photo-style__head::after { transform: rotate(45deg); }
.photo-style__hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.photo-style__body { display: flex; flex-direction: column; gap: 12px; padding: 2px 12px 12px; }
.photo-style__reset { align-self: flex-start; }

.opt { display: flex; align-items: center; gap: 10px; min-width: 0; }
.opt--stack { flex-direction: column; align-items: stretch; gap: 6px; }
.opt__label { flex: none; width: 62px; color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.opt input[type=range] { flex: 1; min-width: 0; accent-color: var(--focus); }
.opt__value { flex: none; width: 44px; color: var(--muted); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.opt__label--auto { width: auto; }
.opt[hidden] { display: none; }
.opt > select { flex: 1; width: auto; }

/* Missions : titre du champ + boutons « Sous-titre », « ← Ramener », « Décaler → » */
.field__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; }
.text-tools { display: flex; gap: 4px; }
.text-tools .btn { padding: 3px 9px; font-size: 12.5px; color: var(--text-2); }
/* Petit dessin « 1 ligne » / « 2 lignes » dans les boutons du nom */
.lines-ico { display: inline-block; width: 12px; height: 2px; margin-right: 6px; border-radius: 1px; background: currentColor; vertical-align: 3px; }
.lines-ico--2 { box-shadow: 0 -4px 0 currentColor; vertical-align: 1px; }
.shape-ico { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border: 1.5px solid currentColor; vertical-align: -1px; }
.shape-ico--round { border-radius: 50%; }
.shape-ico--rounded { border-radius: 3px; }

/* Vignettes des bordures : la forme, la couleur et le fond du CV, avec ta photo */
.frames { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px; }
.frame-btn {
  appearance: none; display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 5px 5px 6px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel); color: var(--muted);
  font: inherit; font-size: 11.5px; font-weight: 500; line-height: 1.2;
  cursor: pointer;
}
.frame-btn:hover { border-color: var(--line-hover); color: var(--text); }
.frame-btn.is-active { border-color: var(--focus); box-shadow: 0 0 0 3px var(--focus-ring); color: var(--text); }
.frame-btn__pad { display: grid; place-items: center; width: 100%; height: 50px; border-radius: 6px; background: var(--tile-bg); }
.frame-btn__ph {
  width: 32px; height: 32px;
  border-radius: var(--tile-r);
  background: var(--tile-photo, linear-gradient(160deg, #cbd5e1, #64748b)) center / cover;
  background-clip: padding-box;
}
.frame-btn[data-value="thin"] .frame-btn__ph { border: 1.5px solid var(--fc); }
.frame-btn[data-value="thick"] .frame-btn__ph { border: 3px solid var(--fc); }
.frame-btn[data-value="ring"] .frame-btn__ph,
.frame-btn[data-value="dashed"] .frame-btn__ph { padding: 2px; border: 1.5px solid var(--fc); background-clip: content-box; background-origin: content-box; }
.frame-btn[data-value="dashed"] .frame-btn__ph { border-style: dashed; }
.frame-btn[data-value="double"] .frame-btn__ph { border: 4.5px double var(--fc); }
.frame-btn[data-value="shadow"] .frame-btn__ph { border: 2.5px solid var(--fc); box-shadow: 0 2px 5px rgba(0, 0, 0, .3); }
.frame-btn[data-value="offset"] .frame-btn__ph { box-shadow: 3.5px 3.5px 0 var(--fc); }
.frame-btn[data-value="gradient"] .frame-btn__ph {
  border: 3px solid transparent;
  background:
    var(--tile-photo, linear-gradient(160deg, #cbd5e1, #64748b)) center / cover padding-box,
    linear-gradient(135deg, var(--fc), color-mix(in srgb, var(--fc) 35%, #fff)) border-box;
}
/* Pastille blanche choisie : un anneau gris (un anneau blanc ne se verrait pas) */
.swatch.swatch--white.is-active { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--line-hover); }

/* ---------- Blocs répétables (expériences, formations…) ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.list:empty { display: none; }
.item {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px;
  background: var(--soft);
  border: 1px solid var(--line); border-radius: 10px;
}
.item__head { display: flex; align-items: center; gap: 8px; }
.item__title { flex: 1; min-width: 0; overflow: hidden; font-size: 13.5px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.item__title.is-empty { color: var(--muted); font-weight: 500; }
.item__tools { display: flex; flex: none; gap: 2px; }
.icon-btn {
  appearance: none; display: grid; place-items: center;
  width: 28px; height: 28px; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted);
  font-size: 13px; cursor: pointer;
}
.icon-btn:hover { background: var(--line); color: var(--text); }
.icon-btn--danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn:disabled { opacity: .3; background: transparent; cursor: default; }

/* Œil : masquer un élément sur le CV sans le supprimer */
.icon-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .eye-off,
.item.is-hidden .icon-btn .eye-on { display: none; }
.item.is-hidden .icon-btn .eye-off { display: block; }
.item.is-hidden .icon-btn--eye { color: var(--focus); }

/* Élément masqué : cadre en pointillés, contenu grisé, étiquette « Masqué sur le CV » */
.item { position: relative; }
.item.is-hidden { border-style: dashed; }
.item.is-hidden > :not(.item__head):not(.item__tools),
.item.is-hidden .item__title { opacity: .45; }
.item.is-hidden::after {
  content: 'Masqué sur le CV';
  position: absolute; top: -9px; right: 12px;
  padding: 1px 8px; border-radius: 999px;
  background: var(--tag-bg); color: var(--tag-text);
  font-size: 11px; font-weight: 600;
}

.item--row { flex-direction: row; align-items: center; gap: 10px; padding: 8px 8px 8px 10px; }
.item--row > input[type=text] { flex: 1 1 auto; }
.item--row > select { flex: 0 0 170px; width: 170px; }
.level { display: flex; flex: none; align-items: center; gap: 8px; }
.level input[type=range] { width: 90px; accent-color: var(--focus); }
.level__label { width: 82px; color: var(--muted); font-size: 12px; }

/* Compétence : nom + niveau sur la 1re ligne, technos en dessous */
.item--skill { flex-wrap: wrap; }
.item--skill > input[data-item="name"] { flex-basis: 0; min-width: 0; }
.item--skill > .item__tags { flex: 1 1 100%; font-size: 13px; }

/* Logo d'entreprise (dans une expérience) : fond blanc dans les deux thèmes */
.logo-field { display: flex; align-items: flex-start; gap: 10px; }
.logo-field__thumb {
  display: grid; place-items: center; flex: none;
  width: 46px; height: 46px; margin-top: 18px;
  overflow: hidden;
  background: #fff;
  border: 1px dashed var(--line-strong); border-radius: 8px;
}
.logo-field__thumb.is-ok { border: 1px solid var(--line); }
.logo-field__thumb img { max-width: 80%; max-height: 80%; object-fit: contain; }
.logo-field__body { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 0; }
.logo-field__row { display: flex; gap: 6px; }
.logo-field__row input { flex: 1; }
.editor.no-logos .logo-field { display: none; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags:empty { display: none; }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 6px 4px 12px; border-radius: 999px;
  background: var(--tag-bg); color: var(--tag-text);
  font-size: 13px; font-weight: 500;
}
.tag button {
  appearance: none; display: grid; place-items: center;
  width: 20px; height: 20px; border: 0; border-radius: 50%;
  background: transparent; color: inherit;
  font-size: 11px; cursor: pointer; opacity: .7;
}
.tag button:hover { background: color-mix(in srgb, currentColor 15%, transparent); opacity: 1; }
.tag-input { display: flex; gap: 8px; }

/* ---------- Adapter à une offre (IA) : propositions « Avant / Après » ---------- */
.adapt-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.adapt-status { color: var(--muted); font-size: 12.5px; }
.adapt-status:empty { display: none; }
.adapt-status.is-warn { color: var(--warn-text); }
.adapt-status.is-error { color: var(--danger); }
.btn:disabled { opacity: .65; cursor: default; }
.spinner {
  display: inline-block; width: 13px; height: 13px; margin-right: 8px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  vertical-align: -2px;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.adapt-privacy { font-size: 11.5px; }

.adapt-result { display: flex; flex-direction: column; gap: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.adapt-result[hidden] { display: none; }
.adapt-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.adapt-head__title { font-size: 14.5px; font-weight: 600; }
.adapt-head__btns { display: flex; gap: 6px; }
.adapt-note { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--warn-bg); color: var(--warn-text); font-size: 12.5px; }
.adapt-list { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.adapt-item {
  padding: 12px 12px 10px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--soft);
  transition: border-color .15s, background .15s, opacity .15s;
}
.adapt-item__label { margin-bottom: 8px; color: var(--muted); font-size: 12px; font-weight: 600; }
.adapt-diff { display: flex; flex-direction: column; gap: 6px; }
.adapt-diff p { margin: 0; font-size: 13.5px; line-height: 1.5; }
.adapt-tag {
  display: inline-block; margin-right: 7px; padding: 1px 6px;
  border-radius: 4px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .02em; vertical-align: 1px;
}
.adapt-before { color: var(--muted); }
.adapt-before .adapt-tag { background: var(--hover); color: var(--muted); }
.adapt-after { color: var(--text); }
.adapt-after .adapt-tag { background: var(--tag-bg); color: var(--tag-text); }
.adapt-why { margin: 7px 0 0; color: var(--muted); font-size: 12px; font-style: italic; }
.adapt-oops { margin: 7px 0 0; color: var(--danger); font-size: 12px; }
.adapt-item__foot { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.adapt-state { margin-right: auto; font-size: 12px; font-weight: 600; }
.adapt-item[data-state="accepte"] { border-color: var(--success); background: var(--success-soft); }
.adapt-item[data-state="accepte"] .adapt-state { color: var(--success); }
.adapt-item[data-state="refuse"] { opacity: .6; }
.adapt-item[data-state="refuse"] .adapt-state { color: var(--muted); }

.adapt-sec__title { margin: 0 0 7px; color: var(--text-2); font-size: 12.5px; font-weight: 600; }
.adapt-sec .hint { margin-top: 6px; }
.adapt-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.adapt-chip { padding: 3px 10px; border-radius: 999px; background: var(--tag-bg); color: var(--tag-text); font-size: 12.5px; font-weight: 500; }
.adapt-chip--warn { background: var(--warn-bg); color: var(--warn-text); }
.adapt-chip--small { display: inline-block; margin: 2px 0 2px 4px; padding: 1px 8px; font-size: 11.5px; }
.adapt-sec .adapt-sec__intro { margin: 0 0 10px; }
.adapt-projet__nom { margin: 0; color: var(--text); font-size: 13.5px; font-weight: 600; line-height: 1.45; }
.adapt-projet__desc { margin: 4px 0 0; color: var(--text-2); font-size: 13px; line-height: 1.5; }
.adapt-tips { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 13px; }
.adapt-tips li + li { margin-top: 4px; }
.adapt-foot { display: flex; flex-wrap: wrap; gap: 8px; }
.adapt-done { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--success-soft); color: var(--success); font-size: 12.5px; font-weight: 500; }
.adapt-sec__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 10px; margin-bottom: 7px; }
.adapt-sec__head .adapt-sec__title { margin: 0; }

/* Compteur du jour (js/ia.js) : « Analyses du jour ▬▬▬ 4 / 5 restantes », vert → jaune → rouge */
.quota {
  --q: var(--sc-ok);
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  padding: 8px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--soft);
  color: var(--muted); font-size: 12px; white-space: nowrap;
}
.quota.is-mid { --q: #eab308; }
:root[data-theme="dark"] .quota.is-mid { --q: #facc15; }
.quota.is-ko { --q: var(--sc-ko); }
.quota b { color: var(--text); }
.quota__bar { height: 6px; min-width: 40px; border-radius: 999px; background: var(--line); overflow: hidden; }
.quota__bar i { display: block; height: 100%; border-radius: 999px; background: var(--q); transition: width .5s ease; }

/* ---------- Score de compatibilité (js/score.js) : grand chiffre, barre Faible / Correct / Très bon ---------- */
:root {
  --sc-ok: #16a34a; --sc-ok-soft: #dcfce7; --sc-ok-text: #166534;
  --sc-mid: #d97706; --sc-mid-soft: #fef3c7; --sc-mid-text: #92400e;
  --sc-ko: #dc2626; --sc-ko-soft: #fee2e2; --sc-ko-text: #991b1b;
}
:root[data-theme="dark"] {
  --sc-ok: #4ade80; --sc-ok-soft: rgba(74, 222, 128, .13); --sc-ok-text: #86efac;
  --sc-mid: #fbbf24; --sc-mid-soft: rgba(251, 191, 36, .14); --sc-mid-text: #fcd34d;
  --sc-ko: #f87171; --sc-ko-soft: rgba(248, 113, 113, .14); --sc-ko-text: #fca5a5;
}
.score-result { animation: score-in .35s ease-out; }
@keyframes score-in { from { opacity: 0; transform: translateY(4px); } }
.score-top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 12px; }
.score-big { font-size: 56px; font-weight: 800; line-height: .9; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.score-big small { color: var(--muted); font-size: 20px; font-weight: 700; letter-spacing: 0; }
.score-top__side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.score-pill, .score-delta {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; white-space: nowrap;
}
.score-pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.score-pill.is-ok { background: var(--sc-ok-soft); color: var(--sc-ok-text); }
.score-pill.is-mid { background: var(--sc-mid-soft); color: var(--sc-mid-text); }
.score-pill.is-ko { background: var(--sc-ko-soft); color: var(--sc-ko-text); }
.score-delta { padding: 3px 9px; background: var(--hover); color: var(--muted); font-size: 12px; }
.score-delta.is-up { background: var(--sc-ok-soft); color: var(--sc-ok-text); }
.score-delta.is-down { background: var(--sc-ko-soft); color: var(--sc-ko-text); }

/* La barre : 3 zones (0-49, 50-74, 75-100), la zone du score en couleur pleine, un repère sur le score */
.score-gauge__track { position: relative; display: grid; grid-template-columns: 50fr 25fr 25fr; gap: 4px; }
.score-gauge__track i { height: 10px; border-radius: 999px; }
.score-gauge__track .is-ko { background: var(--sc-ko-soft); }
.score-gauge__track .is-mid { background: var(--sc-mid-soft); }
.score-gauge__track .is-ok { background: var(--sc-ok-soft); }
.score-gauge__track .is-ko.is-on { background: var(--sc-ko); }
.score-gauge__track .is-mid.is-on { background: var(--sc-mid); }
.score-gauge__track .is-ok.is-on { background: var(--sc-ok); }
.score-gauge__mk {
  position: absolute; top: -5px; width: 4px; height: 20px; margin-left: -2px; border-radius: 3px;
  background: var(--text); box-shadow: 0 0 0 3px var(--panel);
  animation: score-mk .7s cubic-bezier(.2, .8, .2, 1);
}
@keyframes score-mk { from { left: 0; } }
.score-gauge__lbl { display: grid; grid-template-columns: 50fr 25fr 25fr; gap: 4px; margin-top: 6px; color: var(--muted); font-size: 11px; }

.score-cats { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 8px; }
.score-cats span { display: block; color: var(--muted); font-size: 11.5px; }
.score-cats b { font-size: 16px; font-variant-numeric: tabular-nums; }
.score-cats .is-ok { color: var(--sc-ok); }
.score-cats .is-mid { color: var(--sc-mid); }
.score-cats .is-ko { color: var(--sc-ko); }

.score-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.score-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border: 1px solid transparent; border-radius: 999px;
  font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer; transition: transform .12s, box-shadow .12s;
}
.score-chip:hover { transform: translateY(-1px); }
.score-chip:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.score-chip.is-must { font-weight: 700; }
.score-chip.is-ok { background: var(--sc-ok-soft); color: var(--sc-ok-text); }
.score-chip.is-mid { background: var(--sc-mid-soft); color: var(--sc-mid-text); }
.score-chip.is-ko { background: var(--sc-ko-soft); color: var(--sc-ko-text); }
.score-chip[aria-expanded="true"] { border-color: currentColor; }
.score-legend { margin-top: 8px !important; }

.score-detail { margin-top: 10px; padding: 10px 12px; border-left: 3px solid; border-radius: 8px; background: var(--soft); font-size: 13px; }
.score-detail.is-ok { border-color: var(--sc-ok); }
.score-detail.is-mid { border-color: var(--sc-mid); }
.score-detail.is-ko { border-color: var(--sc-ko); }
.score-detail__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 10px; margin-bottom: 4px; }
.score-detail__head span { color: var(--muted); font-size: 12px; }
.score-detail p { margin: 4px 0 0; color: var(--text-2); line-height: 1.5; }
.score-detail__lbl { margin-right: 6px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.score-detail .score-detail__gain { color: var(--sc-ok); font-size: 12px; font-weight: 700; }

.score-tips { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.score-tips li { display: flex; align-items: baseline; gap: 10px; color: var(--text-2); font-size: 13px; line-height: 1.45; }
.score-tips li::before { content: '→'; color: var(--muted); }
.score-tips li span { flex: 1; }
.score-tips b { color: var(--sc-ok); font-size: 12.5px; white-space: nowrap; }
.score-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
@media (max-width: 480px) { .score-top__side { flex-direction: row; flex-wrap: wrap; align-items: center; } }
@media (prefers-reduced-motion: reduce) { .score-result, .score-gauge__mk { animation: none; } }

/* ---------- Traduire le CV (IA) : mêmes cartes « Avant / Après », groupées par partie du CV ---------- */
.trad-sec__head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 10px;
  min-height: 30px; list-style: none; cursor: pointer;
}
.trad-sec__head::-webkit-details-marker { display: none; }
.trad-groupe[open] > .trad-sec__head { margin-bottom: 7px; }
.trad-sec__head .adapt-sec__title { margin: 0; }
/* Petit chevron : vers la droite si replié, vers le bas si ouvert */
.trad-sec__head .adapt-sec__title::before {
  content: ''; display: inline-block; width: 6px; height: 6px; margin: 0 9px 0 2px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg); vertical-align: 2px; transition: transform .15s;
}
.trad-groupe[open] > .trad-sec__head .adapt-sec__title::before { transform: rotate(45deg); vertical-align: 3px; }
.trad-sec__head:hover .adapt-sec__title { color: var(--text); }
.trad-sec__count { margin-left: 4px; color: var(--muted); font-weight: 500; }
/* Texte court (poste, ville, langue…) : « avant → après » sur une ligne */
.trad-court { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; margin: 0; font-size: 13.5px; line-height: 1.5; }
.trad-court__fleche { color: var(--muted); font-size: 12px; }
.adapt-item[data-state="accepte"] .trad-court .adapt-before { text-decoration: line-through; }

/* ---------- Zone d'aperçu ---------- */
/* En haut la barre d'outils ; dessous, le CV (et la barre flottante du menu réduit par-dessus) */
.preview {
  display: grid; grid-template-rows: auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr);
  min-width: 0; min-height: 0;
  background: var(--stage);
}
.preview__bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 9px; background: var(--hover); }
.seg__btn {
  appearance: none; border: 0; border-radius: 7px;
  padding: 6px 12px;
  background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer;
}
.seg__btn:hover { color: var(--text); }
.seg__btn.is-active { background: var(--seg-active); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 1px rgba(0, 0, 0, .04); }
.seg--small .seg__btn { padding: 6px 10px; }

.swatches { display: flex; align-items: center; gap: 7px; }
.swatch {
  appearance: none; position: relative;
  width: 22px; height: 22px; padding: 0;
  border: 0; border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 0 0 1px var(--swatch-ring);
  cursor: pointer;
  transition: transform .15s;
}
.swatch:hover { transform: scale(1.12); }
.swatch.is-active { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--c); }
.swatch--custom { display: block; overflow: hidden; background: conic-gradient(#ef4444, #f59e0b, #22c55e, #06b6d4, #6366f1, #d946ef, #ef4444); }
.swatch--custom input { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.swatch--custom.is-active { overflow: visible; }

/* Barre de l'aperçu : styles du CV en puces avec icône (couleur du CV sur la puce choisie) */
.tpl-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tpl-chip {
  appearance: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border: 1px solid var(--line); border-radius: 9px;
  background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: color .15s, border-color .15s, background .15s;
}
.tpl-chip svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tpl-chip:hover { color: var(--text); border-color: var(--line-hover); }
.tpl-chip.is-active {
  --c: var(--cv-accent, #2b59c3);
  color: color-mix(in srgb, var(--c) 85%, #000);
  border-color: color-mix(in srgb, var(--c) 45%, transparent);
  background: color-mix(in srgb, var(--c) 10%, transparent);
  font-weight: 600;
}
:root[data-theme="dark"] .tpl-chip.is-active { color: color-mix(in srgb, var(--c) 50%, #fff); background: color-mix(in srgb, var(--c) 18%, transparent); border-color: color-mix(in srgb, var(--c) 60%, transparent); }

/* Couleurs du CV dans la barre de l'aperçu : pastille dans un anneau */
.preview__bar .swatches { gap: 6px; }
.preview__bar .swatch { width: 26px; height: 26px; }
.preview__bar .swatch:hover { transform: none; box-shadow: inset 0 0 0 1.5px var(--line-hover); }
.preview__bar .swatch[data-color] { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
.preview__bar .swatch[data-color]::before {
  content: ''; position: absolute; inset: 5px; border-radius: 50%;
  background: var(--c); box-shadow: inset 0 0 0 1px var(--swatch-ring); /* contour fin : l'anthracite reste visible en sombre */
  transition: transform .15s;
}
.preview__bar .swatch[data-color]:hover::before { transform: scale(1.1); }
.preview__bar .swatch[data-color].is-active { box-shadow: inset 0 0 0 2px var(--c); }
:root[data-theme="dark"] .preview__bar .swatch[data-color].is-active { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c) 70%, #fff); }
.preview__bar .swatch--custom.is-active { box-shadow: 0 0 0 2px var(--panel), 0 0 0 3.5px var(--c); }

/* À droite de la barre : zoom (− 85 % + Ajuster) et nombre de pages, toujours ensemble */
.preview__tools { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.zoom { align-items: center; }
.zoom .zoom__step { width: 30px; padding: 3px 0 5px; font-size: 17px; line-height: 1; }
.zoom__value { min-width: 46px; color: var(--text-2); font-size: 12.5px; font-weight: 500; text-align: center; font-variant-numeric: tabular-nums; }
.seg__btn:disabled { opacity: .35; cursor: default; }

.badge { margin-left: auto; padding: 5px 10px; border-radius: 999px; background: var(--hover); color: var(--text-2); font-size: 12px; font-weight: 500; }
.badge.is-warn { background: var(--warn-bg); color: var(--warn-text); }

.preview__stage { grid-area: 2 / 1; overflow: auto; padding: 28px; scrollbar-gutter: stable; }
.preview__box { position: relative; margin: 0 auto; }
.preview__scaler { position: absolute; top: 0; left: 0; transform-origin: top left; }
.cv-page {
  position: relative;
  width: 210mm;
  background: #fff;
  box-shadow: var(--page-shadow);
}

/* ---------- Petite fenêtre de rappel (avant le PDF) ---------- */
.dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--panel); color: var(--text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
}
.dialog::backdrop { background: rgba(17, 24, 39, .45); }
.dialog__body { display: flex; flex-direction: column; gap: 12px; padding: 20px 20px 18px; }
.dialog__body p { margin: 0; }
.dialog__title { margin: 0; font-size: 17px; }
/* Imitation du choix « Destination » de la fenêtre d'impression de Chrome */
.dialog__dest {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--soft);
  font-size: 13.5px;
}
.dialog__dest span { color: var(--muted); }
.dialog__dest strong { color: var(--focus); font-weight: 600; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ---------- Importer un CV PDF ou Word (js/import.js) ---------- */
.dialog--import { width: min(500px, calc(100vw - 32px)); }
.import-file {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft);
}
.import-file svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.import-file__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.import-file__size { color: var(--muted); font-size: 12.5px; }
.import-who { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 10px; background: var(--soft); border: 1px solid var(--line); }
.import-who strong { font-size: 15px; }
.import-who span { color: var(--text-2); }
.import-who small { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.import-parts { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.import-parts li { padding: 4px 10px; border-radius: 99px; background: var(--tag-bg); color: var(--tag-text); font-size: 12.5px; }
.import-ok { color: var(--success); font-size: 13px; }
.import-notes { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 10px 12px 10px 28px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-text); font-size: 12.5px; }
.dialog--import .spinner { margin-right: 6px; }
/* « Annuler l'import » dans la barre du haut */
.topbar__undo {
  appearance: none; margin-left: 4px; padding: 0; border: 0; background: none;
  color: var(--focus); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer;
}

/* ---------- Petits écrans ---------- */
@media (max-width: 980px) {
  .topbar { position: static; flex-wrap: wrap; height: auto; padding: 10px 16px; }
  /* minmax(0, …) : la colonne prend la largeur de l'écran, même si un champ voudrait plus large */
  .app, .app.is-collapsed { grid-template-columns: minmax(0, 1fr); height: auto; }
  .editor { overflow: visible; border-right: 0; padding: 16px; }
  .preview { min-height: 85vh; grid-template-rows: auto auto minmax(0, 1fr); }
  .preview__stage, .app.is-collapsed .preview__stage { grid-row: 3; padding: 16px; }
  /* Menu réduit : la barre passe en ligne au-dessus du CV, sur 2 lignes s'il le faut
     (sans bulles, faites pour la souris) */
  .rail { flex-direction: row; flex-wrap: wrap; max-width: calc(100% - 32px); margin-bottom: 0; }
  .rail__sep { width: 1px; height: 24px; margin: 0 3px; }
  .rail__btn::after { display: none; }
}
@media (max-width: 560px) {
  .grid-2 { grid-template-columns: 1fr; }
  .item--row { flex-wrap: wrap; }
  .item--row > select { flex: 1 1 100%; }
  .opt:not(.opt--stack) { flex-wrap: wrap; row-gap: 6px; } /* les boutons passent sous leur titre s'il manque de place */
  .seg { flex-wrap: wrap; } /* ex. les 5 styles du CV, sur 2 lignes */
}

/* Copie invisible du CV, découpée en colonnes de la taille d'une page A4 :
   le navigateur la coupe comme à l'impression, ce qui donne le nombre exact de pages (app.js) */
.cv-sizer {
  position: absolute; top: 0; left: -10000px;
  width: 210mm; height: 297mm;
  columns: 210mm; column-gap: 0; column-fill: auto;
  visibility: hidden; pointer-events: none;
}
.cv-sizer .cv { min-height: 0; }

/* ---------- Impression / PDF : on ne garde que le CV ---------- */
@page { size: A4; margin: 0; }
@media print {
  .cv-sizer { display: none; }
  html, body { height: auto; background: #fff; }
  .topbar, .editor, .rail, .preview__bar, .dialog { display: none !important; }
  .app { display: block; height: auto; }
  .preview { display: block; background: #fff; }
  .preview__stage { padding: 0 !important; overflow: visible; }
  .preview__box { width: auto !important; height: auto !important; }
  .preview__scaler { position: static; transform: none !important; }
  .cv-page { box-shadow: none; }
}
