:root {
    --brand: #2563eb;
    --brand-dark: #1d4ed8;
    --slate-900: #0f172a;
    --slate-700: #334155;
    --slate-500: #64748b;
    --slate-200: #e2e8f0;
    --slate-100: #f1f5f9;
    --white: #ffffff;
    --shadow: 0 10px 30px -12px rgba(15, 23, 42, 0.18);
    --cv-margin-top: 20mm;
    --cv-margin-bottom: 28mm;
    --cv-margin-x: 16mm;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, sans-serif;
    color: var(--slate-700);
    background: #f8fafc;
}

a { color: inherit; text-decoration: none; }

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--slate-200);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-weight: 800;
    color: var(--slate-900);
}

.brand-mark {
    width: 2rem;
    height: 2rem;
    border-radius: 0.65rem;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    display: grid;
    place-items: center;
    color: white;
    font-size: 0.85rem;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn {
    border: none;
    border-radius: 0.75rem;
    padding: 0.65rem 1rem;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s ease;
}

.btn-ghost {
    background: var(--slate-100);
    color: var(--slate-700);
}

.btn-ghost:hover { background: var(--slate-200); }

.btn-primary {
    background: var(--brand);
    color: white;
    box-shadow: 0 8px 20px -8px rgba(37, 99, 235, 0.55);
}

.btn-primary:hover { background: var(--brand-dark); }

.btn-danger {
    background: #fee2e2;
    color: #b91c1c;
}

.layout {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(320px, 420px) 1fr;
    min-height: 0;
}

.editor-pane {
    border-right: 1px solid var(--slate-200);
    background: white;
    overflow: auto;
    max-height: calc(100vh - 65px);
}

.preview-pane {
    overflow: auto;
    padding: 1.5rem;
    background: linear-gradient(180deg, #eef2ff 0%, #f8fafc 40%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

#cv-preview {
    width: 100%;
    max-width: calc(210mm + 2rem);
    display: flex;
    justify-content: center;
}

.cv-preview-shell {
    width: 100%;
    display: flex;
    justify-content: center;
    overflow: visible;
}

.cv-preview-scale {
    width: 210mm;
    transform-origin: top center;
}

.cv-preview-pages {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.cv-preview-page {
    width: 210mm;
    height: 297mm;
    overflow: hidden;
    background: white;
    box-shadow: var(--shadow);
    position: relative;
    flex-shrink: 0;
}

.cv-preview-page-inner {
    width: 210mm;
}

.cv-preview-page-inner .cv-page {
    width: 210mm !important;
    max-width: none !important;
    margin: 0 !important;
    box-shadow: none !important;
    height: 297mm;
}

.cv-preview-measure {
    position: fixed;
    left: 0;
    top: 0;
    width: 210mm;
    z-index: -1;
    opacity: 0;
    pointer-events: none;
}

.section-nav {
    display: flex;
    gap: 0.35rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--slate-200);
    overflow-x: auto;
    position: sticky;
    top: 0;
    background: white;
    z-index: 5;
}

.section-tab {
    white-space: nowrap;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    border: 1px solid var(--slate-200);
    background: white;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.section-tab.active {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: var(--brand);
}

.panel {
    display: none;
    padding: 1.25rem;
}

.panel.active { display: block; }

.panel h2 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
    color: var(--slate-900);
}

.field-grid {
    display: grid;
    gap: 0.85rem;
}

.field-grid.two { grid-template-columns: 1fr 1fr; }

.hidden { display: none !important; }

.photo-upload-block { grid-column: 1 / -1; }

.photo-upload {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.85rem;
}

.photo-preview-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.photo-preview-img {
    width: 72px;
    height: 72px;
    border-radius: 999px;
    object-fit: cover;
    border: 2px solid var(--slate-200);
    background: #f8fafc;
}

.photo-remove-btn {
    padding: 0.45rem 0.75rem;
    font-size: 0.78rem;
}

.photo-upload-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed #93c5fd;
    background: #eff6ff;
    color: #1d4ed8;
    border-radius: 0.75rem;
    padding: 0.65rem 1rem;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s ease;
}

.photo-upload-label:hover {
    background: #dbeafe;
    border-color: #60a5fa;
}

.photo-upload-hint {
    flex: 1 1 100%;
    margin: 0;
    font-size: 0.72rem;
}

label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--slate-500);
    margin-bottom: 0.35rem;
}

input, textarea, select {
    width: 100%;
    border: 1px solid var(--slate-200);
    border-radius: 0.65rem;
    padding: 0.65rem 0.75rem;
    font: inherit;
    color: var(--slate-900);
    background: white;
}

input:focus, textarea:focus, select:focus {
    outline: 2px solid #bfdbfe;
    border-color: #93c5fd;
}

input[type="month"].date-month-input {
    cursor: pointer;
}

input[type="month"].date-month-input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.date-end-wrap {
    display: flex;
    flex-direction: column;
}

.present-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.45rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--slate-500);
    cursor: pointer;
    user-select: none;
}

.present-toggle input {
    width: auto;
    margin: 0;
    cursor: pointer;
}

textarea { min-height: 96px; resize: vertical; }

.list-block {
    border: 1px solid var(--slate-200);
    border-radius: 0.85rem;
    padding: 0.85rem;
    margin-bottom: 0.75rem;
    background: #fcfdff;
}

.list-block-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.65rem;
}

.list-block-head strong { color: var(--slate-900); font-size: 0.9rem; }

.icon-btn {
    border: none;
    background: transparent;
    color: #ef4444;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}

.hint {
    font-size: 0.78rem;
    color: var(--slate-500);
    margin-top: 0.75rem;
}

.save-status {
    font-size: 0.75rem;
    color: var(--slate-500);
}

.cv-page {
    width: min(100%, 210mm);
    height: 297mm;
    min-height: 297mm;
    max-height: 297mm;
    margin: 0 auto;
    background: white;
    box-shadow: var(--shadow);
    padding: 0;
    color: #111827;
    box-sizing: border-box;
    overflow: hidden;
}

.cv-text-margins {
    padding: var(--cv-margin-top) var(--cv-margin-x) var(--cv-margin-bottom);
    box-sizing: border-box;
    height: 100%;
}

.cv-preview-measure .cv-page {
    width: 210mm !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

.cv-preview-measure .cv-modern-layout,
.cv-preview-measure .cv-text-margins,
.cv-preview-measure .cv-band-content,
.cv-preview-measure .cv-main {
    height: auto !important;
    max-height: none !important;
}

/* Global pagination — never split these blocks across pages */
.cv-header,
.cv-entry,
.cv-flow-group {
    break-inside: avoid;
    page-break-inside: avoid;
}

.cv-section p,
.cv-entry p {
    orphans: 3;
    widows: 3;
}

.cv-modern-layout {
    display: grid;
    grid-template-columns: 32% 1fr;
    min-height: 297mm;
    height: 100%;
    align-items: stretch;
}

.cv-band-content {
    padding: 0 var(--cv-margin-x) var(--cv-margin-bottom);
    box-sizing: border-box;
    height: calc(100% - 14mm);
}

.preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    width: 100%;
    max-width: calc(210mm + 2rem);
}

.preview-toolbar-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--slate-500);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.template-picker {
    display: grid;
    gap: 0.75rem;
    max-height: 420px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.template-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    text-align: left;
    border: 2px solid var(--slate-200);
    border-radius: 0.85rem;
    padding: 0.75rem;
    background: white;
    cursor: pointer;
    transition: 0.2s ease;
}

.template-card:hover { border-color: #bfdbfe; }

.template-card.active {
    border-color: var(--brand);
    background: #eff6ff;
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.15);
}

.template-thumb {
    width: 3.5rem;
    height: 4.5rem;
    border-radius: 0.35rem;
    border: 1px solid var(--slate-200);
    overflow: hidden;
    flex-shrink: 0;
    background: white;
}

.template-card-body { min-width: 0; }

.template-card-body strong {
    display: block;
    color: var(--slate-900);
    font-size: 0.9rem;
}

.template-card-body span {
    display: block;
    color: var(--slate-500);
    font-size: 0.76rem;
    margin-top: 0.15rem;
}

.template-badge {
    display: inline-block;
    margin-top: 0.35rem;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #047857;
    background: #ecfdf5;
    border-radius: 999px;
    padding: 0.15rem 0.45rem;
}

.template-quick-picker {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.template-chip {
    border: 1px solid var(--slate-200);
    background: white;
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--slate-600);
    cursor: pointer;
}

.template-chip.active {
    background: var(--brand);
    border-color: var(--brand);
    color: white;
}

.example-picker {
    display: grid;
    gap: 0.75rem;
}

.example-card {
    display: block;
    width: 100%;
    text-align: left;
    border: 2px solid var(--slate-200);
    border-radius: 0.85rem;
    padding: 0.85rem;
    background: white;
    cursor: pointer;
    transition: 0.2s ease;
}

.example-card:hover {
    border-color: #bfdbfe;
    background: #f8fbff;
}

.example-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.example-card strong {
    display: block;
    color: var(--slate-900);
    font-size: 0.92rem;
}

.example-card-role {
    display: block;
    color: var(--brand);
    font-size: 0.78rem;
    font-weight: 600;
    margin-top: 0.1rem;
}

.example-card p {
    margin: 0;
    color: var(--slate-500);
    font-size: 0.76rem;
    line-height: 1.45;
}

.example-tag {
    flex-shrink: 0;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6d28d9;
    background: #f5f3ff;
    border-radius: 999px;
    padding: 0.2rem 0.45rem;
}

.thumb-modern { background: linear-gradient(90deg, #2563eb 35%, white 35%); }
.thumb-classic { background: linear-gradient(180deg, #1e40af 0 18%, white 18%); }
.thumb-minimal { background: white; box-shadow: inset 0 0 0 8px white, inset 0 0 0 9px #e5e7eb; }
.thumb-professional { background: linear-gradient(180deg, #f8fafc 0 22%, white 22%); border-left: 3px solid #7c3aed; }
.thumb-tech { background: linear-gradient(90deg, #0f172a 35%, white 35%); }
.thumb-navy { background: linear-gradient(90deg, #1e3a8a 35%, white 35%); }
.thumb-emerald { background: linear-gradient(90deg, #059669 35%, white 35%); }
.thumb-coral { background: linear-gradient(90deg, #f97316 35%, white 35%); }
.thumb-slate-sidebar { background: linear-gradient(90deg, #475569 35%, white 35%); }
.thumb-burgundy { background: linear-gradient(90deg, #881337 35%, white 35%); }
.thumb-teal { background: linear-gradient(90deg, #0d9488 35%, white 35%); }
.thumb-corporate { background: linear-gradient(180deg, #374151 0 16%, white 16%); }
.thumb-academic { background: linear-gradient(180deg, #f8fafc 0 20%, white 20%); border-bottom: 2px solid #6b7280; }
.thumb-legal { background: white; border-left: 4px solid #1f2937; }
.thumb-sales { background: linear-gradient(180deg, #dc2626 0 14%, white 14%); }
.thumb-elegant { background: white; box-shadow: inset 0 0 0 10px white, inset 0 0 0 11px #d1d5db; }
.thumb-executive { background: linear-gradient(180deg, #b45309 0 14%, white 14%); }
.thumb-consultant { background: linear-gradient(180deg, #64748b 0 8%, white 8%); }
.thumb-ats { background: repeating-linear-gradient(180deg, #111 0 2px, white 2px 6px); }
.thumb-ats-simple { background: linear-gradient(180deg, #fff 0 30%, #111 30% 32%, #fff 32% 38%, #111 38% 40%, #fff 40%); }
.thumb-ats-compact { background: repeating-linear-gradient(180deg, #111 0 1px, white 1px 4px); }
.thumb-purple { background: linear-gradient(90deg, #7c3aed 35%, white 35%); }
.thumb-indigo { background: linear-gradient(90deg, #4f46e5 35%, white 35%); }
.thumb-rose { background: linear-gradient(90deg, #e11d48 35%, white 35%); }
.thumb-midnight { background: linear-gradient(90deg, #111827 35%, white 35%); }
.thumb-amber { background: linear-gradient(90deg, #d97706 35%, white 35%); }
.thumb-startup { background: linear-gradient(180deg, #059669 0 16%, white 16%); }
.thumb-healthcare { background: linear-gradient(180deg, #0d9488 0 14%, white 14%); }
.thumb-swiss { background: white; border: 1px solid #cbd5e1; box-shadow: inset 0 0 0 8px white; }
.thumb-director-navy { background: linear-gradient(180deg, #1e3a8a 0 14%, white 14%); }
.thumb-platinum { background: linear-gradient(180deg, #64748b 0 14%, white 14%); }

.help-tip {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 0.75rem;
    padding: 0.75rem;
    font-size: 0.78rem;
    color: #1e40af;
    margin-bottom: 1rem;
    line-height: 1.45;
}

.help-guide {
    display: grid;
    gap: 0.85rem;
}

.help-guide-block {
    border: 1px solid var(--slate-200);
    border-radius: 0.85rem;
    padding: 0.85rem;
    background: #fcfdff;
}

.help-guide-block h3 {
    margin: 0 0 0.5rem;
    font-size: 0.92rem;
    color: var(--slate-900);
}

.help-guide-block ul {
    margin: 0;
    padding-left: 1.1rem;
    color: var(--slate-600);
    font-size: 0.78rem;
    line-height: 1.5;
}

.template-ats-simple {
    font-family: Arial, Helvetica, sans-serif;
}

.template-ats-simple .cv-name { font-size: 1.25rem; }
.template-ats-simple .cv-section h3 { font-size: 0.75rem; }

.cv-header {
    border-bottom: 2px solid #111827;
    padding-bottom: 0.85rem;
    margin-bottom: 1rem;
}

.cv-name {
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0;
}

.cv-title {
    margin: 0.25rem 0 0;
    font-size: 1rem;
    color: #374151;
}

.cv-contact {
    margin-top: 0.65rem;
    font-size: 0.82rem;
    color: #4b5563;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
}

.cv-section {
    margin-top: 1rem;
}

.cv-section:first-child {
    margin-top: 0;
}

.cv-section h3 {
    margin: 0 0 0.45rem;
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #111827;
    border-bottom: 1px solid #d1d5db;
    padding-bottom: 0.2rem;
    break-after: avoid;
    page-break-after: avoid;
}

.cv-header {
    break-inside: avoid;
    page-break-inside: avoid;
}

.cv-section p, .cv-section li {
    font-size: 0.86rem;
    line-height: 1.45;
    color: #374151;
}

.cv-entry {
    margin-bottom: 0.75rem;
    page-break-inside: avoid;
    break-inside: avoid;
}

.cv-entry-long {
    break-inside: auto;
    page-break-inside: auto;
}

.cv-entry-head {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 0.88rem;
}

.cv-entry-sub {
    color: #4b5563;
    font-size: 0.82rem;
    margin-top: 0.1rem;
}

.skills-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.skill-chip {
    background: #f3f4f6;
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    font-size: 0.78rem;
}

/* Template: Classic (default) */
.template-classic .cv-name { color: #1e40af; }
.template-classic .cv-section h3 { color: #1e40af; border-bottom-color: #bfdbfe; }

/* Template: Minimal — text styling only */
.template-minimal { font-family: Georgia, 'Times New Roman', serif; }
.template-minimal .cv-header { border-bottom: none; padding-bottom: 0; margin-bottom: 0.5rem; }
.template-minimal .cv-name { font-size: 2rem; font-weight: 700; color: #111827; }
.template-minimal .cv-title { font-style: italic; color: #6b7280; }
.template-minimal .cv-section h3 {
    text-transform: none;
    letter-spacing: 0;
    font-size: 1rem;
    border-bottom: none;
    font-weight: 700;
    color: #374151;
}

/* Template: Professional */
.template-professional {
    font-family: Georgia, 'Times New Roman', serif;
}
.template-professional.cv-page {
    border-top: 4px solid #7c3aed;
}
.template-professional .cv-name { color: #111827; font-size: 1.85rem; }
.template-professional .cv-header { border-bottom: 1px solid #d1d5db; }
.template-professional .cv-section h3 { color: #7c3aed; border-bottom-color: #ddd6fe; }

/* Template: ATS — text styling only */
.template-ats { font-family: Arial, Helvetica, sans-serif; }
.template-ats .cv-header { border-bottom: 1px solid #000; }
.template-ats .cv-name { font-size: 1.4rem; color: #000; }
.template-ats .cv-title,
.template-ats .cv-contact,
.template-ats .cv-section p,
.template-ats .cv-entry-sub { color: #000; }
.template-ats .cv-section h3 {
    color: #000;
    border-bottom: 1px solid #000;
    letter-spacing: 0.04em;
}
.template-ats .skill-chip { background: transparent; border-radius: 0; padding: 0; font-size: 0.86rem; }
.template-ats .skills-wrap { display: block; }
.template-ats .skill-chip::after { content: ' •'; }
.template-ats .skill-chip:last-child::after { content: ''; }

/* Template: Sidebar — full-height sidebar; text margins only in .cv-main */
.template-modern,
.template-tech,
.template-navy,
.template-emerald,
.template-coral,
.template-slate-sidebar,
.template-burgundy,
.template-teal,
.template-purple,
.template-indigo,
.template-rose,
.template-midnight,
.template-amber {
    overflow: hidden;
}

.cv-sidebar {
    padding: 14mm 10mm;
    color: white;
    min-height: 100%;
    height: 100%;
    align-self: stretch;
    box-sizing: border-box;
}

.cv-page-continuation .cv-sidebar-inner {
    display: none;
}

.cv-sidebar-photo-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 0.85rem;
}

.cv-sidebar-photo {
    width: 22mm;
    height: 22mm;
    border-radius: 999px;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.65);
    background: rgba(255, 255, 255, 0.12);
}

.cv-header-with-photo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.cv-header-with-photo .cv-header-text {
    flex: 1;
    min-width: 0;
}

.cv-photo {
    width: 24mm;
    height: 24mm;
    border-radius: 999px;
    object-fit: cover;
    border: 2px solid #e5e7eb;
    background: #f3f4f6;
    flex-shrink: 0;
}

.template-executive .cv-photo {
    border-color: #fed7aa;
}

.template-minimal .cv-photo,
.template-elegant .cv-photo {
    width: 20mm;
    height: 20mm;
    border-radius: 999px;
}

.template-professional .cv-photo {
    border-color: #ddd6fe;
}

.template-modern .cv-sidebar { background: linear-gradient(180deg, #2563eb, #1d4ed8); }
.template-tech .cv-sidebar { background: linear-gradient(180deg, #0f172a, #1e293b); }
.template-navy .cv-sidebar { background: linear-gradient(180deg, #1e3a8a, #172554); }
.template-emerald .cv-sidebar { background: linear-gradient(180deg, #059669, #047857); }
.template-coral .cv-sidebar { background: linear-gradient(180deg, #f97316, #ea580c); }
.template-slate-sidebar .cv-sidebar { background: linear-gradient(180deg, #475569, #334155); }
.template-burgundy .cv-sidebar { background: linear-gradient(180deg, #881337, #701a3a); }
.template-teal .cv-sidebar { background: linear-gradient(180deg, #0d9488, #0f766e); }
.template-purple .cv-sidebar { background: linear-gradient(180deg, #7c3aed, #6d28d9); }
.template-indigo .cv-sidebar { background: linear-gradient(180deg, #4f46e5, #4338ca); }
.template-rose .cv-sidebar { background: linear-gradient(180deg, #e11d48, #be123c); }
.template-midnight .cv-sidebar { background: linear-gradient(180deg, #111827, #030712); }
.template-amber .cv-sidebar { background: linear-gradient(180deg, #d97706, #b45309); }

.cv-sidebar-name {
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1.2;
    margin: 0;
}

.cv-sidebar-title {
    margin: 0.35rem 0 0;
    font-size: 0.82rem;
    opacity: 0.9;
}

.cv-sidebar-block {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.25);
}

.cv-sidebar-block h4 {
    margin: 0 0 0.45rem;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.85;
}

.cv-sidebar-block p,
.cv-sidebar-block li {
    margin: 0 0 0.3rem;
    font-size: 0.76rem;
    line-height: 1.35;
}

.cv-main {
    padding: var(--cv-margin-top) 12mm var(--cv-margin-bottom);
    box-sizing: border-box;
    min-height: 297mm;
}

.template-modern .cv-main .cv-section h3,
.template-tech .cv-main .cv-section h3,
.template-navy .cv-main .cv-section h3,
.template-emerald .cv-main .cv-section h3,
.template-coral .cv-main .cv-section h3,
.template-slate-sidebar .cv-main .cv-section h3,
.template-burgundy .cv-main .cv-section h3,
.template-teal .cv-main .cv-section h3,
.template-purple .cv-main .cv-section h3,
.template-indigo .cv-main .cv-section h3,
.template-rose .cv-main .cv-section h3,
.template-midnight .cv-main .cv-section h3,
.template-amber .cv-main .cv-section h3 {
    color: #111827;
    border-bottom-color: #e5e7eb;
}

.template-tech .cv-main { font-family: 'Segoe UI', Tahoma, sans-serif; }

/* Template: Classic variants */
.template-corporate { font-family: 'Segoe UI', Tahoma, sans-serif; }
.template-corporate .cv-header { border-bottom-color: #374151; }
.template-corporate .cv-name { color: #1f2937; }
.template-corporate .cv-section h3 { color: #374151; border-bottom-color: #d1d5db; }

.template-academic {
    font-family: Georgia, 'Times New Roman', serif;
}
.template-academic .cv-name { font-size: 1.75rem; color: #111827; }
.template-academic .cv-header { border-bottom: 1px solid #9ca3af; }
.template-academic .cv-section h3 {
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.95rem;
    color: #374151;
}

.template-legal {
    font-family: Georgia, 'Times New Roman', serif;
    border-left: 4px solid #1f2937;
}
.template-legal .cv-header { border-bottom: 1px solid #6b7280; }
.template-legal .cv-name { color: #111827; font-size: 1.5rem; }
.template-legal .cv-section h3 { color: #1f2937; border-bottom-color: #d1d5db; }

.template-sales .cv-header { border-bottom: 3px solid #dc2626; }
.template-sales .cv-name { color: #991b1b; }
.template-sales .cv-section h3 { color: #b91c1c; border-bottom-color: #fecaca; }

/* Template: Minimal variants */
.template-elegant {
    font-family: 'Segoe UI', Tahoma, sans-serif;
}
.template-elegant .cv-header { border-bottom: none; padding-bottom: 0; margin-bottom: 0.75rem; }
.template-elegant .cv-name {
    font-size: 1.9rem;
    font-weight: 300;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #111827;
}
.template-elegant .cv-title { font-weight: 400; color: #6b7280; letter-spacing: 0.04em; }
.template-elegant .cv-section { margin-top: 1.25rem; }
.template-elegant .cv-section h3 {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.72rem;
    font-weight: 600;
    color: #9ca3af;
    border-bottom: none;
    padding-bottom: 0;
}

/* Template: Executive band — full-width accent, flush to page top */
.cv-top-band {
    display: block;
    width: 100%;
    height: 14mm;
    background: linear-gradient(90deg, #b45309, #d97706);
}
.template-executive .cv-header { border-bottom: none; margin-bottom: 0.75rem; }
.template-executive .cv-name { color: #92400e; font-size: 1.85rem; }
.template-executive .cv-section h3 { color: #b45309; border-bottom-color: #fed7aa; }

/* Template: Consultant */
.template-consultant {
    font-family: 'Segoe UI', Tahoma, sans-serif;
}
.template-consultant.cv-page {
    border-top: 4px solid #64748b;
}
.template-consultant .cv-name { color: #0f172a; }
.template-consultant .cv-section h3 { color: #475569; border-bottom-color: #cbd5e1; }

/* Template: ATS Compact */
.template-ats-compact {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 0.92rem;
}
.template-ats-compact .cv-header { border-bottom: 1px solid #000; margin-bottom: 0.65rem; padding-bottom: 0.5rem; }
.template-ats-compact .cv-name { font-size: 1.2rem; color: #000; }
.template-ats-compact .cv-title,
.template-ats-compact .cv-contact,
.template-ats-compact .cv-section p,
.template-ats-compact .cv-entry-sub { color: #000; font-size: 0.82rem; }
.template-ats-compact .cv-section { margin-top: 0.65rem; }
.template-ats-compact .cv-section h3 {
    color: #000;
    border-bottom: 1px solid #000;
    font-size: 0.72rem;
    margin-bottom: 0.3rem;
}
.template-ats-compact .cv-entry { margin-bottom: 0.45rem; }
.template-ats-compact .skill-chip { background: transparent; border-radius: 0; padding: 0; font-size: 0.82rem; }
.template-ats-compact .skills-wrap { display: block; }
.template-ats-compact .skill-chip::after { content: ' •'; }
.template-ats-compact .skill-chip:last-child::after { content: ''; }

.template-startup .cv-name { color: #047857; }
.template-startup .cv-header { border-bottom: 3px solid #10b981; }
.template-startup .cv-section h3 { color: #059669; border-bottom-color: #a7f3d0; }

.template-healthcare .cv-name { color: #0f766e; }
.template-healthcare .cv-header { border-bottom: 2px solid #5eead4; }
.template-healthcare .cv-section h3 { color: #0d9488; border-bottom-color: #ccfbf1; }

.template-swiss {
    font-family: 'Segoe UI', Tahoma, Geneva, sans-serif;
}
.template-swiss .cv-header { border-bottom: 2px solid #111827; }
.template-swiss .cv-name { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.03em; }
.template-swiss .cv-section h3 {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.72rem;
    color: #111827;
}

.template-director-navy .cv-top-band { background: linear-gradient(90deg, #1e3a8a, #2563eb); }
.template-director-navy .cv-header { border-bottom: none; margin-bottom: 0.75rem; }
.template-director-navy .cv-name { color: #1e3a8a; font-size: 1.85rem; }
.template-director-navy .cv-section h3 { color: #1d4ed8; border-bottom-color: #bfdbfe; }
.template-director-navy .cv-photo { border-color: #bfdbfe; }

.template-platinum .cv-top-band { background: linear-gradient(90deg, #475569, #94a3b8); }
.template-platinum .cv-header { border-bottom: none; margin-bottom: 0.75rem; }
.template-platinum .cv-name { color: #334155; font-size: 1.85rem; }
.template-platinum .cv-section h3 { color: #475569; border-bottom-color: #cbd5e1; }
.template-platinum .cv-photo { border-color: #cbd5e1; }

@media (max-width: 960px) {
    .layout { grid-template-columns: 1fr; }
    .editor-pane { max-height: none; border-right: none; border-bottom: 1px solid var(--slate-200); }
    .preview-pane { padding: 1rem; }
    .field-grid.two { grid-template-columns: 1fr; }
}

@media print {
    @page {
        margin: 0;
    }

    body { background: white; }
    .topbar, .editor-pane, .preview-pane { display: none !important; }
    #print-root { display: block !important; }

    #print-root .cv-page {
        box-shadow: none;
        margin: 0;
        width: 210mm;
        break-after: page;
        page-break-after: always;
    }

    #print-root .cv-page:last-child {
        break-after: auto;
        page-break-after: auto;
    }
}

#print-root { display: none; }

#pdf-export-stage {
    position: fixed;
    left: 0;
    top: 0;
    width: 210mm;
    height: 297mm;
    z-index: 2147483646;
    background: #ffffff;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

#pdf-export-stage .cv-page {
    width: 210mm !important;
    max-width: none !important;
    height: 297mm !important;
    max-height: 297mm !important;
    margin: 0 !important;
    box-shadow: none !important;
    overflow: hidden !important;
}

#pdf-export-stage .cv-layout-sidebar .cv-modern-layout {
    height: 297mm !important;
    min-height: 297mm !important;
}

.phrase-assist {
    margin-top: 0.85rem;
    padding: 0.75rem;
    border: 1px dashed #cbd5e1;
    border-radius: 0.85rem;
    background: #f8fafc;
}

.phrase-assist-title {
    margin: 0 0 0.5rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--slate-700);
}

.phrase-cats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.65rem;
}

.phrase-cat {
    border: 1px solid var(--slate-200);
    background: white;
    border-radius: 999px;
    padding: 0.25rem 0.65rem;
    font: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--slate-700);
}

.phrase-cat.active {
    background: var(--brand);
    border-color: var(--brand);
    color: white;
}

.phrase-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.phrase-list.skills {
    flex-direction: row;
    flex-wrap: wrap;
}

.phrase-chip {
    text-align: left;
    border: 1px solid var(--slate-200);
    background: white;
    border-radius: 0.65rem;
    padding: 0.55rem 0.7rem;
    font: inherit;
    font-size: 0.78rem;
    line-height: 1.4;
    cursor: pointer;
    color: var(--slate-700);
}

.phrase-chip:hover {
    border-color: var(--brand);
    color: var(--brand-dark);
}

.phrase-toggle {
    border: none;
    background: transparent;
    padding: 0;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--brand);
    cursor: pointer;
}

.phrase-toggle:hover { text-decoration: underline; }
