:root {
  --bg: #f3f1ec;
  --panel: #fffdf9;
  --ink: #1b1f24;
  --muted: #69707a;
  --line: #e3dfd6;
  --brand: #1f4e79;
  --brand-ink: #fff;
  --ok: #0f766e;
  --ok-bg: #e3f3f0;
  --miss: #9a3412;
  --miss-bg: #fbece3;
  --focus: #2f6fb0;
  --radius: 10px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 400 15px/1.5 "Inter", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.mark { width: 26px; height: 26px; border-radius: 7px; background: var(--brand); position: relative; }
.mark::after { content: ""; position: absolute; inset: 6px 8px; background: #fff; border-radius: 1px; clip-path: polygon(0 0, 70% 0, 100% 25%, 100% 100%, 0 100%); }
.status { font-size: 13px; padding: 4px 10px 4px 22px; border-radius: 99px; background: #eceae4; color: var(--muted); position: relative; }
.status::before { content: ""; position: absolute; left: 9px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: #b0aca2; }
.status.live { background: var(--ok-bg); color: var(--ok); }
.status.live::before { background: var(--ok); }
.status.mock::before { background: #d48a1a; }

.layout { display: grid; grid-template-columns: minmax(340px, 440px) 1fr; min-height: calc(100vh - 57px); }
.inputs { padding: 22px 24px 40px; border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-head { display: flex; align-items: center; justify-content: space-between; }
.field label { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.step { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 11px; font-weight: 700; }
textarea, input[type="text"], select { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 10px 12px; font-size: 14px; line-height: 1.5; }
textarea { resize: vertical; min-height: 120px; }
textarea:focus, input:focus, select:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px rgba(47, 111, 176, 0.15); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.label { margin: 0; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.sources { display: flex; flex-direction: column; gap: 8px; }
.source { display: flex; align-items: center; gap: 8px; margin: 0; }
.source input { flex: 1; min-width: 0; padding: 8px 11px; }
.src-icon { width: 34px; height: 34px; flex: none; border-radius: 8px; display: grid; place-items: center; color: #fff; }
.src-icon svg { width: 17px; height: 17px; }
.src-icon.gh { background: #1b1f24; }
.src-icon.li { background: #0a66c2; }
.ghost.small { padding: 7px 12px; font-size: 13.5px; }
.ghost[disabled] { opacity: 0.6; cursor: progress; }
.file-btn { flex: 1; border: 1px dashed #c9c3b7; border-radius: 8px; padding: 7px 12px; font-size: 14px; cursor: pointer; background: #fff; color: var(--ink); text-align: center; }
.file-btn:hover, .file-btn.drag { border-color: #0a66c2; background: #f2f7fc; }
.file-btn:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.li-help { font-size: 13.5px; background: #f6f4ef; border-radius: 8px; padding: 10px 14px; color: #3a414a; }
.li-help p { margin: 0 0 6px; }
.li-help ol { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.src-status { margin: 0; font-size: 13px; color: var(--ok); min-height: 0; }
.src-status:empty { display: none; }
.src-status.bad { color: #b42318; }
.hint { margin: 0; font-size: 12px; color: var(--muted); }
.link { background: none; border: 0; padding: 2px 0; color: var(--brand); font-size: 13px; font-weight: 500; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(31, 78, 121, 0.35); }
.link:hover { text-decoration-color: currentColor; }

.options { display: grid; grid-template-columns: auto 1fr; gap: 12px 16px; }
.opt { display: flex; flex-direction: column; gap: 5px; }
.opt-wide { grid-column: 1 / -1; }
.opt-label { font-size: 13px; font-weight: 500; color: var(--muted); }
.optional { font-weight: 400; opacity: 0.8; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: #f6f4ef; }
.seg button { border: 0; background: none; padding: 6px 10px; border-radius: 6px; font-size: 13px; cursor: pointer; color: var(--muted); white-space: nowrap; }
.seg button[aria-checked="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.08); font-weight: 500; }

.primary { border: 0; border-radius: 9px; background: var(--brand); color: var(--brand-ink); font-weight: 600; font-size: 15px; padding: 13px 18px; cursor: pointer; transition: background 0.15s, transform 0.1s; display: flex; align-items: center; justify-content: center; gap: 10px; }
.primary:hover { background: #173d60; }
.primary:active { transform: translateY(1px); }
.primary[disabled] { opacity: 0.75; cursor: progress; }
.primary .spin { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.35); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error { margin: -6px 0 0; color: #b42318; font-size: 14px; }

.report { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: #fff; display: flex; flex-direction: column; gap: 12px; }
.report-head { display: flex; gap: 14px; align-items: center; }
.report h2 { margin: 0; font-size: 15px; }
.report h3 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); margin: 0; font-size: 13px; }
.score { position: relative; width: 54px; height: 54px; flex: none; }
.score svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score circle { fill: none; stroke-width: 3.5; }
.score .track { stroke: #ece9e2; }
.score .bar { stroke: var(--ok); stroke-linecap: round; stroke-dasharray: 97.4; stroke-dashoffset: 97.4; transition: stroke-dashoffset 0.8s ease; }
.score span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 5px; }
.chips li { font-size: 12.5px; padding: 2px 9px; border-radius: 99px; }
.chips.ok li { background: var(--ok-bg); color: var(--ok); }
.chips.miss li { background: var(--miss-bg); color: var(--miss); }
.chips:empty::after { content: "None"; font-size: 13px; color: var(--muted); }
.notes { margin: 0; padding-left: 18px; font-size: 13.5px; color: #3a414a; display: flex; flex-direction: column; gap: 4px; }

.preview { display: flex; flex-direction: column; min-width: 0; }
.toolbar { display: flex; flex-direction: column; gap: 12px; padding: 16px 24px 14px; border-bottom: 1px solid var(--line); background: var(--bg); }
.styles { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.style-card { flex: none; border: 1.5px solid transparent; background: none; padding: 0; cursor: pointer; border-radius: 8px; text-align: left; width: 104px; }
.style-thumb { display: block; height: 130px; width: 100%; border-radius: 6px; overflow: hidden; background: #fff; box-shadow: 0 0 0 1px var(--line); position: relative; }
.style-thumb .cv-page { transform: scale(0.131); transform-origin: 0 0; position: absolute; left: 0; top: 0; pointer-events: none; }
.style-name { display: block; font-size: 12.5px; font-weight: 500; padding: 5px 2px 0; color: var(--muted); }
.style-card[aria-checked="true"] .style-thumb { box-shadow: 0 0 0 2px var(--brand); }
.style-card[aria-checked="true"] .style-name { color: var(--ink); font-weight: 600; }
.style-card:hover .style-thumb { box-shadow: 0 0 0 2px #9fb4c9; }
.style-card[aria-checked="true"]:hover .style-thumb { box-shadow: 0 0 0 2px var(--brand); }
.tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.accents { display: flex; gap: 6px; margin-right: auto; align-items: center; }
.accents button { width: 22px; height: 22px; border-radius: 50%; border: 0; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12); padding: 0; }
.accents button[aria-checked="true"] { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px currentColor; }
.accents.off { opacity: 0.35; pointer-events: none; }
.ghost, .dark { border-radius: 8px; padding: 8px 14px; font-size: 14px; font-weight: 500; cursor: pointer; }
.ghost { background: #fff; border: 1px solid var(--line); }
.ghost:hover { border-color: #c9c3b7; }
.ghost[aria-pressed="true"] { background: #fff6dc; border-color: #e3c56a; }
.dark { background: var(--ink); color: #fff; border: 1px solid var(--ink); }
.dark:hover { background: #343a42; }
.export { position: relative; display: flex; gap: 6px; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 10px 30px rgba(0,0,0,0.12); padding: 5px; min-width: 210px; z-index: 10; display: flex; flex-direction: column; }
.menu[hidden] { display: none; }
.menu button { border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.menu button:hover { background: #f3f1ec; }

.stage { flex: 1; padding: 28px 24px 60px; overflow: hidden; }
.paper-wrap { margin: 0 auto; position: relative; }
.paper { transform-origin: 0 0; position: absolute; left: 0; top: 0; box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 12px 40px rgba(40, 30, 10, 0.12); }
.paper.editing .cv-page { outline: 2px dashed #e3c56a; outline-offset: 6px; }
.paper.editing [contenteditable] { cursor: text; }
.paper.editing [contenteditable]:hover { background: rgba(255, 220, 120, 0.18); }
.paper.busy { opacity: 0.45; transition: opacity 0.2s; }
.empty-note { position: absolute; z-index: 2; left: 50%; top: 22px; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 13px; padding: 6px 12px; border-radius: 99px; white-space: nowrap; }

.toast { position: fixed; bottom: 22px; z-index: 60 !important; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 9px; font-size: 14px; z-index: 20; box-shadow: 0 8px 24px rgba(0,0,0,0.2); }

#print-root { display: none; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .inputs { border-right: 0; border-bottom: 1px solid var(--line); padding: 18px 16px 28px; }
  .toolbar { position: static; padding: 14px 16px; }
  .stage { padding: 18px 16px 40px; }
  .topbar { padding: 12px 16px; }
}
@media (max-width: 420px) {
  .options { grid-template-columns: 1fr; }
  .export .dark { padding: 8px 10px; }
}

@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  .app, .toast, .gear, .scrim, .settings { display: none !important; }
  #print-root { display: block; }
  #print-root .cv-page { min-height: 296mm; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
}

/* ---------- profile summary + settings drawer ---------- */
.profile-card { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: var(--radius); padding: 10px 12px; cursor: pointer; transition: border-color 0.15s; }
.profile-card:hover { border-color: #c9c3b7; }
.profile-card.empty { border-style: dashed; background: #fbfaf7; }
.pc-avatar { width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 14px; }
.profile-card.empty .pc-avatar { background: #e6e2d9; color: var(--muted); }
.pc-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pc-text strong { font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-text span { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-edit { font-size: 13px; font-weight: 500; color: var(--brand); }

.gear { position: fixed; left: 16px; bottom: 16px; z-index: 30; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--ink); display: grid; place-items: center; cursor: pointer; box-shadow: 0 4px 14px rgba(40, 30, 10, 0.14); transition: transform 0.2s, background 0.15s; }
.gear svg { width: 21px; height: 21px; }
.gear:hover { background: #fff; transform: rotate(30deg); }
.gear[aria-expanded="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.scrim { position: fixed; inset: 0; background: rgba(20, 18, 14, 0.32); z-index: 40; animation: fade 0.2s ease; }
.settings { position: fixed; left: 0; top: 0; bottom: 0; width: min(480px, 100vw); background: var(--panel); z-index: 50; display: flex; flex-direction: column; box-shadow: 8px 0 40px rgba(0, 0, 0, 0.16); animation: slide-in 0.22s ease; }
.settings[hidden], .scrim[hidden] { display: none; }
.settings-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.settings-head h2 { margin: 0; font-size: 18px; }
.icon-btn { width: 34px; height: 34px; border-radius: 8px; border: 0; background: none; cursor: pointer; display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: #eeebe4; color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.settings-body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 22px; }
.settings-body .label { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.settings-body .field label { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.settings-foot { padding: 14px 20px; border-top: 1px solid var(--line); }
.settings-foot .primary { width: 100%; }
@keyframes slide-in { from { transform: translateX(-24px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .settings, .scrim { animation: none; } .gear:hover { transform: none; } }
@media (max-width: 900px) { .stage { padding-bottom: 80px; } }

/* ---------- your own CV templates (settings) ---------- */
.tpl-settings { display: flex; flex-direction: column; gap: 8px; }
.tpl-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.tpl-list:empty { display: none; }
.tpl-list li { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; }
.tpl-swatch { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.tpl-list .tpl-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-list .tpl-name small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.tpl-form { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.tpl-form[hidden] { display: none; }
.tpl-preview { height: 200px; border-radius: 6px; overflow: hidden; position: relative; background: #fff; box-shadow: 0 0 0 1px var(--line); }
.tpl-preview .cv-page { transform: scale(0.52); transform-origin: 0 0; position: absolute; left: 0; top: 0; pointer-events: none; }
.tpl-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.tpl-fields .opt:first-child { grid-column: 1 / -1; }
.tpl-fields select, .tpl-fields input[type="text"] { padding: 8px 10px; }
.opt-color input { width: 100%; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.tpl-css summary { cursor: pointer; font-size: 13px; font-weight: 500; color: var(--muted); }
.tpl-css textarea { margin-top: 8px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; min-height: 100px; }
.tpl-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dark.small { padding: 7px 14px; font-size: 13.5px; }
.style-card .badge { font-size: 10px; font-weight: 600; color: var(--brand); margin-left: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.link.danger { color: #b42318; text-decoration-color: rgba(180, 35, 24, 0.35); }
.tpl-list .link { font-size: 13px; }
.styles { align-items: flex-start; }
.style-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inputs { padding-bottom: 84px; }

/* ---------- background form (settings) ---------- */
.bg-settings { display: flex; flex-direction: column; gap: 10px; }
.bg-form { display: flex; flex-direction: column; gap: 14px; }
.ff-group { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; margin: 0; padding: 12px 14px 14px; min-width: 0; }
.ff-group legend { font-size: 13.5px; font-weight: 600; padding: 0 6px; margin-left: -6px; }
.ff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.ff { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ff.wide { grid-column: 1 / -1; }
.ff > span { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.ff > span small { font-weight: 400; opacity: 0.85; }
.ff input, .ff textarea { padding: 8px 10px; font-size: 14px; }
.ff textarea { min-height: 0; resize: vertical; }
.entries { display: flex; flex-direction: column; gap: 8px; }
.entries:empty { display: none; }
.entry { border: 1px solid var(--line); border-radius: 8px; background: #fcfbf8; }
.entry summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 8px 6px 8px 12px; cursor: pointer; }
.entry summary::-webkit-details-marker { display: none; }
.entry summary::before { content: ""; width: 7px; height: 7px; border-right: 1.8px solid var(--muted); border-bottom: 1.8px solid var(--muted); transform: rotate(-45deg); transition: transform 0.15s; flex: none; margin-right: 2px; }
.entry[open] summary::before { transform: rotate(45deg); }
.entry-title { flex: 1; min-width: 0; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-when { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.entry-del { width: 28px; height: 28px; }
.entry-del svg { width: 14px; height: 14px; }
.entry .ff-grid { padding: 4px 12px 12px; }
.add-entry { margin-top: 8px; border: 1px dashed #c9c3b7; background: none; border-radius: 8px; padding: 8px; width: 100%; font-size: 13.5px; font-weight: 500; color: var(--brand); cursor: pointer; }
.add-entry:hover { border-color: var(--brand); background: #f2f7fc; }
.chips-input { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; cursor: text; }
.chips-input:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(47, 111, 176, 0.15); }
.chips-input input { flex: 1; min-width: 140px; border: 0; padding: 4px 6px; font-size: 14px; box-shadow: none !important; }
.chip { display: inline-flex; align-items: center; gap: 2px; background: #eef2f6; color: #1d3a57; border-radius: 99px; padding: 3px 4px 3px 10px; font-size: 13px; }
.chip button { border: 0; background: none; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; cursor: pointer; color: inherit; padding: 0; }
.chip button:hover { background: rgba(0, 0, 0, 0.08); }
.chip button svg { width: 11px; height: 11px; }
.paste-cv summary { cursor: pointer; font-size: 13px; font-weight: 500; color: var(--muted); }
.paste-cv textarea { margin: 8px 0; }
@media (max-width: 420px) { .ff-grid { grid-template-columns: 1fr; } }

/* ---------- CV check ---------- */
.check { border-top: 1px solid var(--line); padding-top: 12px; }
.check h3 { display: flex; align-items: center; gap: 8px; }
.strength { font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 99px; letter-spacing: 0; text-transform: none; }
.strength.hi { background: var(--ok-bg); color: var(--ok); }
.strength.mid { background: #fdf3dc; color: #8a5a00; }
.strength.lo { background: var(--miss-bg); color: var(--miss); }
.check-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; color: #3a414a; }
.check-list li { position: relative; padding-left: 20px; }
.check-list li::before { position: absolute; left: 0; top: 0; font-weight: 700; width: 14px; text-align: center; }
.check-list .fix::before { content: "!"; color: #b42318; }
.check-list .tip::before { content: "•"; color: #b07000; font-size: 18px; line-height: 1.1; }
.check-list .ok::before { content: "✓"; color: var(--ok); }
