:root {
    --ink: #102a38;
    --navy: #002333;
    --teal: #137f82;
    --teal-dark: #0d6668;
    --teal-soft: #e7f5f2;
    --paper: #ffffff;
    --page: #f5f8f7;
    --line: #d7e2df;
    --muted: #5f6f76;
    --danger: #a33b3b;
    --shadow: 0 12px 35px rgba(0, 35, 51, .10);
}

* { box-sizing: border-box; }
body.builder-page { background: var(--page); color: var(--ink); min-height: 100vh; }
.builder-header { position: sticky; top: 0; width: 100%; padding: 0; background: var(--navy); z-index: 50; }
.builder-nav { max-width: 1480px; margin: 0 auto; min-height: 72px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; width: 100%; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: white; text-decoration: none; font-weight: 700; font-size: 1.2rem; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--teal); color: white; font-family: 'Merriweather', serif; }
.builder-nav ul { margin: 0; }
.builder-nav ul li { margin: 0 4px; }
.builder-nav ul li a { font-size: .95rem; padding: 12px 14px; }
.builder-nav ul li a.active { background: var(--teal); border-radius: 7px; }

.builder-main { max-width: 1480px; margin: 0 auto; padding: 36px 28px 56px; text-align: left; align-items: stretch; }
.builder-intro { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.builder-intro h1 { margin: 4px 0 8px; font-size: clamp(2rem, 4vw, 3.1rem); }
.builder-intro > div:first-child > p:last-child { max-width: 720px; margin: 0; color: var(--muted); line-height: 1.6; }
.eyebrow, .step-count { margin: 0; color: var(--teal-dark); font-size: .77rem; text-transform: uppercase; letter-spacing: .11em; font-weight: 700; }
.save-status { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--muted); background: white; padding: 9px 13px; border: 1px solid var(--line); border-radius: 999px; }
.status-dot { width: 8px; height: 8px; background: var(--teal); border-radius: 50%; }

.builder-workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(430px, .88fr); gap: 24px; align-items: start; }
.editor-panel, .preview-panel { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.editor-panel { overflow: hidden; }
.step-nav { display: flex; overflow-x: auto; padding: 0 22px; border-bottom: 1px solid var(--line); background: #fbfcfc; }
.step-button { width: auto; background: transparent; color: var(--muted); border: 0; border-bottom: 3px solid transparent; border-radius: 0; padding: 18px 13px 15px; font-size: .9rem; white-space: nowrap; }
.step-button:hover { background: transparent; color: var(--ink); }
.step-button.active { color: var(--teal-dark); border-bottom-color: var(--teal); font-weight: 700; }
#resumeForm { display: block; width: auto; padding: 0; background: transparent; box-shadow: none; border-radius: 0; }
.form-step { padding: 30px; min-height: 470px; }
.step-heading { display: flex; justify-content: space-between; gap: 30px; align-items: start; border-bottom: 1px solid var(--line); padding-bottom: 20px; margin-bottom: 24px; }
.step-heading h2 { margin: 4px 0 0; font-size: 1.55rem; }
.step-heading > p { max-width: 310px; margin: 3px 0 0; color: var(--muted); font-size: .9rem; line-height: 1.55; }
.optional-pill { font-family: 'Montserrat', sans-serif; font-size: .68rem; padding: 4px 8px; border-radius: 999px; background: var(--teal-soft); color: var(--teal-dark); vertical-align: middle; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field { min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { display: flex; justify-content: space-between; gap: 10px; font-weight: 700; font-size: .88rem; margin-bottom: 7px; }
.field label span { font-weight: 400; color: var(--muted); font-size: .8rem; }
.field input, .field textarea { width: 100%; border: 1px solid #bfcfcb; border-radius: 9px; padding: 12px 13px; color: var(--ink); background: white; font-family: inherit; font-size: .95rem; outline: none; transition: border-color .2s, box-shadow .2s; }
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(19,127,130,.14); }
.field-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 7px; color: var(--muted); font-size: .76rem; }
.entry-list { display: grid; gap: 16px; }
.entry-card { padding: 18px; border: 1px solid var(--line); background: #fbfcfc; border-radius: 12px; }
.entry-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
.entry-card-header h3 { margin: 0; font-size: 1rem; }
.remove-entry { width: auto; padding: 5px 8px; background: transparent; color: var(--danger); font-size: .78rem; }
.remove-entry:hover { background: #fff0f0; }
.entry-card .field-grid { gap: 12px; }

.editor-actions { display: flex; justify-content: space-between; gap: 12px; padding: 18px 30px; border-top: 1px solid var(--line); background: #fbfcfc; }
.primary-button, .secondary-button, .ghost-button { width: auto; border-radius: 9px; font-weight: 700; font-size: .9rem; }
.primary-button { background: var(--teal); color: white; padding: 11px 18px; }
.primary-button:hover { background: var(--teal-dark); }
.secondary-button { margin-top: 16px; background: var(--teal-soft); color: var(--teal-dark); padding: 10px 14px; }
.secondary-button:hover { background: #d7eeea; }
.ghost-button { background: transparent; color: var(--ink); border: 1px solid var(--line); padding: 10px 14px; }
.ghost-button:hover { background: #f2f6f5; }
.ghost-button:disabled { opacity: .45; cursor: not-allowed; }

.preview-panel { position: sticky; top: 96px; padding: 22px; }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.preview-toolbar h2 { margin: 3px 0 0; font-size: 1.25rem; }
.template-badge { font-size: .75rem; padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }
.resume-paper { aspect-ratio: 8.5 / 11; min-height: 640px; background: white; border: 1px solid #cdd8d5; box-shadow: 0 5px 20px rgba(0,0,0,.08); padding: 8.5% 8%; color: #1e262a; font-family: Arial, Helvetica, sans-serif; overflow: hidden; }
.resume-header { position: static; inset: auto; display: block; width: auto; background: transparent; text-align: center; padding: 0 0 18px; border-bottom: 2px solid #26373e; color: #1e262a; z-index: auto; }
.resume-header h2 { margin: 0; font-family: Arial, Helvetica, sans-serif; font-size: clamp(1.45rem, 2.4vw, 2rem); letter-spacing: .03em; color: #1e262a; }
.resume-headline { margin: 7px 0 0; font-weight: 700; font-size: .88rem; color: #1e262a; }
.resume-contact { display: block; margin: 6px 0 0; font-size: .75rem; line-height: 1.4; color: #4e5c62; }
.preview-section { margin-top: 18px; }
.preview-section h3 { margin: 0 0 7px; padding-bottom: 4px; border-bottom: 1px solid #aeb9bd; font-family: Arial, Helvetica, sans-serif; font-size: .86rem; text-transform: uppercase; letter-spacing: .08em; }
.preview-section p { margin: 0; font-size: .72rem; line-height: 1.48; }
.preview-placeholder { color: #7f8b90; font-style: italic; }
.preview-entry { margin-top: 9px; }
.preview-entry:first-child { margin-top: 0; }
.preview-entry-title { display: flex; justify-content: space-between; gap: 12px; font-size: .74rem; font-weight: 700; }
.preview-entry-meta { font-size: .68rem; color: #526167; margin-top: 2px; }
.preview-entry-description { margin-top: 4px !important; white-space: pre-line; }
.skill-line { white-space: normal; }
.preview-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; }
.privacy-note { text-align: center; color: var(--muted); font-size: .74rem; margin: 12px 0 0; }

.builder-footer { margin-top: 0; display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 24px 28px; }
.builder-footer p { margin: 0; }
.builder-footer nav { display: flex; gap: 20px; }
.builder-footer a { color: var(--ink); }

@media (max-width: 1050px) {
    .builder-workspace { grid-template-columns: 1fr; }
    .preview-panel { position: static; }
    .resume-paper { max-width: 720px; margin: 0 auto; }
}
@media (max-width: 768px) {
    .builder-nav { padding: 0 18px; }
    .builder-nav .menu-toggle { display: flex; position: static; width: auto; padding: 7px; background: transparent; }
    .builder-nav ul { top: 64px; right: 18px; }
    .builder-main { padding: 24px 14px 40px; }
    .builder-intro { align-items: flex-start; flex-direction: column; }
    .field-grid { grid-template-columns: 1fr; }
    .field.full { grid-column: auto; }
    .step-heading { flex-direction: column; gap: 8px; }
    .form-step { padding: 22px 18px; min-height: 0; }
    .editor-actions { padding: 16px 18px; }
    .resume-paper { min-height: 0; }
    .builder-footer { flex-direction: column; }
}
@media (max-width: 480px) {
    .brand { font-size: 1rem; }
    .brand-mark { width: 30px; height: 30px; }
    .preview-actions { flex-direction: column; }
    .preview-actions button { width: 100%; }
    .resume-paper { padding: 7%; }
}

/* Phase 2A: design controls and resume templates */
.design-panel { margin: 0 0 16px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfc; }
.design-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.design-heading h3 { margin: 3px 0 0; font-size: 1rem; }
.design-heading > p { margin: 1px 0 0; max-width: 220px; color: var(--muted); font-size: .72rem; line-height: 1.45; text-align: right; }
.template-picker { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.template-option { width: 100%; min-width: 0; padding: 10px; text-align: left; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 9px; }
.template-option:hover { background: #f3f8f7; }
.template-option.active { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); background: var(--teal-soft); }
.template-option strong, .template-option span { display: block; }
.template-option strong { font-size: .8rem; }
.template-option span { margin-top: 3px; color: var(--muted); font-size: .64rem; line-height: 1.25; }
.design-controls { display: grid; grid-template-columns: .8fr 1fr 1fr; gap: 9px; margin-top: 11px; }
.design-controls label { color: var(--muted); font-size: .68rem; font-weight: 700; }
.design-controls select, .design-controls input[type="color"] { display: block; width: 100%; height: 36px; margin-top: 5px; border: 1px solid #bfcfcb; border-radius: 7px; background: white; color: var(--ink); font: inherit; }
.design-controls select { padding: 0 8px; }
.design-controls input[type="color"] { padding: 3px; cursor: pointer; }
.download-actions { display: flex; gap: 8px; }
.secondary-download { width: auto; padding: 10px 14px; border: 1px solid var(--teal); border-radius: 9px; background: white; color: var(--teal-dark); font-weight: 700; font-size: .9rem; }
.secondary-download:hover { background: var(--teal-soft); }

.resume-paper { --resume-accent: #137f82; --resume-font: Arial, Helvetica, sans-serif; --resume-section-gap: 18px; --resume-entry-gap: 9px; font-family: var(--resume-font); }
.resume-paper .resume-header h2,
.resume-paper .preview-section h3 { font-family: var(--resume-font); }
.resume-paper[data-spacing="compact"] { --resume-section-gap: 12px; --resume-entry-gap: 6px; }
.resume-paper[data-spacing="airy"] { --resume-section-gap: 23px; --resume-entry-gap: 12px; }
.resume-paper .preview-section { margin-top: var(--resume-section-gap); }
.resume-paper .preview-entry { margin-top: var(--resume-entry-gap); }

/* Classic: intentionally conservative and ATS-friendly */
.resume-paper[data-template="classic"] .resume-header { text-align: center; border-bottom: 2px solid #26373e; }
.resume-paper[data-template="classic"] .preview-section h3 { color: #1e262a; border-bottom-color: #aeb9bd; }

/* Modern */
.resume-paper[data-template="modern"] { border-top: 8px solid var(--resume-accent); }
.resume-paper[data-template="modern"] .resume-header { text-align: left; border-bottom: 0; padding-bottom: 11px; }
.resume-paper[data-template="modern"] .resume-header h2 { color: var(--resume-accent); font-size: clamp(1.55rem, 2.6vw, 2.15rem); letter-spacing: 0; }
.resume-paper[data-template="modern"] .resume-contact { color: #44545b; }
.resume-paper[data-template="modern"] .preview-section h3 { color: var(--resume-accent); border-bottom: 2px solid var(--resume-accent); letter-spacing: .06em; }

/* Professional */
.resume-paper[data-template="professional"] .resume-header { text-align: left; padding: 14px 16px; margin: -1.5% -2% 0; border: 0; background: #f1f4f4; border-left: 5px solid var(--resume-accent); }
.resume-paper[data-template="professional"] .resume-header h2 { color: #15252c; letter-spacing: .015em; }
.resume-paper[data-template="professional"] .resume-headline { color: var(--resume-accent); }
.resume-paper[data-template="professional"] .preview-section h3 { color: #15252c; border-bottom: 1px solid var(--resume-accent); }
.resume-paper[data-template="professional"] .preview-entry-title { color: #15252c; }

/* Creative: expressive without using graphics or skill bars */
.resume-paper[data-template="creative"] { border-left: 10px solid var(--resume-accent); }
.resume-paper[data-template="creative"] .resume-header { text-align: left; border-bottom: 0; padding-bottom: 10px; }
.resume-paper[data-template="creative"] .resume-header h2 { color: var(--resume-accent); font-size: clamp(1.6rem, 2.8vw, 2.25rem); letter-spacing: -.01em; }
.resume-paper[data-template="creative"] .resume-headline { text-transform: uppercase; letter-spacing: .06em; font-size: .76rem; }
.resume-paper[data-template="creative"] .preview-section h3 { width: fit-content; padding: 3px 9px 3px 0; color: var(--resume-accent); border: 0; border-bottom: 3px solid var(--resume-accent); }

@media (max-width: 700px) {
    .template-picker { grid-template-columns: 1fr 1fr; }
    .design-controls { grid-template-columns: 1fr; }
    .design-heading { flex-direction: column; }
    .design-heading > p { max-width: none; text-align: left; }
}

@media (max-width: 480px) {
    .download-actions { width: 100%; flex-direction: column; }
    .download-actions button { width: 100%; }
}

/* Browser print is the PDF renderer. It keeps real text selectable and uses the same template CSS as the live preview. */
@page { size: Letter; margin: 0; }
@media print {
    html, body.builder-page { width: 8.5in; margin: 0 !important; padding: 0 !important; background: white !important; }
    .builder-header, .builder-intro, .editor-panel, .preview-toolbar, .resume-check, .design-panel, .preview-actions, .privacy-note, .builder-footer { display: none !important; }
    .builder-main, .builder-workspace, .preview-panel { display: block !important; width: auto !important; max-width: none !important; margin: 0 !important; padding: 0 !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; background: white !important; }
    .preview-panel { position: static !important; }
    .resume-paper {
        width: 8.5in !important;
        max-width: none !important;
        min-height: 11in !important;
        height: auto !important;
        aspect-ratio: auto !important;
        margin: 0 !important;
        padding: .58in .62in !important;
        border: 0 !important;
        box-shadow: none !important;
        overflow: visible !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
    /* Print typography is sized in points so the saved PDF remains comfortably readable. */
    .resume-paper .resume-header h2 { font-size: 24pt !important; line-height: 1.08; }
    .resume-paper .resume-headline { font-size: 11pt !important; line-height: 1.3; }
    .resume-paper .resume-contact { font-size: 10.5pt !important; line-height: 1.35; }
    .resume-paper .preview-section h3 { font-size: 12pt !important; line-height: 1.2; }
    .resume-paper .preview-section p { font-size: 10.5pt !important; line-height: 1.42; }
    .resume-paper .preview-entry-title { font-size: 10.5pt !important; line-height: 1.3; }
    .resume-paper .preview-entry-meta { font-size: 10pt !important; line-height: 1.3; }

    /* Spacing presets affect both density and type size in the finished PDF. */
    .resume-paper[data-spacing="compact"] { --resume-section-gap: 11px; --resume-entry-gap: 5px; }
    .resume-paper[data-spacing="compact"] .resume-contact,
    .resume-paper[data-spacing="compact"] .preview-section p,
    .resume-paper[data-spacing="compact"] .preview-entry-title { font-size: 10pt !important; }
    .resume-paper[data-spacing="compact"] .preview-entry-meta { font-size: 9.5pt !important; }

    .resume-paper[data-spacing="airy"] { --resume-section-gap: 25px; --resume-entry-gap: 13px; }
    .resume-paper[data-spacing="airy"] .resume-contact,
    .resume-paper[data-spacing="airy"] .preview-section p,
    .resume-paper[data-spacing="airy"] .preview-entry-title { font-size: 11pt !important; }
    .resume-paper[data-spacing="airy"] .preview-entry-meta { font-size: 10.5pt !important; }
    .resume-paper[data-template="modern"] { border-top: 8px solid var(--resume-accent) !important; }
    .resume-paper[data-template="creative"] { border-left: 10px solid var(--resume-accent) !important; }
    .preview-entry, .resume-header, .preview-section h3 { break-inside: avoid; page-break-inside: avoid; }
}
@media print {
    .resume-paper .preview-section.is-empty { display: none !important; }
}

/* Phase 2B: section management, custom sections, and resume readiness */
.arrange-grid { display: grid; grid-template-columns: 1fr; gap: 24px; }
.subsection-heading { margin-bottom: 10px; }
.subsection-heading h3 { margin: 0; font-size: 1rem; }
.subsection-heading p { margin: 4px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.45; }
.section-manager { display: grid; gap: 8px; }
.section-row { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.section-row-main { display: flex; align-items: center; gap: 9px; min-width: 0; }
.section-row-main input { width: 18px; height: 18px; accent-color: var(--teal); }
.section-row-main label { margin: 0; font-size: .85rem; font-weight: 700; cursor: pointer; }
.section-row-main small { display: block; color: var(--muted); font-size: .68rem; font-weight: 400; }
.section-order-actions { display: flex; gap: 5px; }
.section-order-actions button { width: 32px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 7px; background: #f8faf9; color: var(--ink); font-weight: 800; }
.section-order-actions button:disabled { opacity: .35; cursor: default; }
.custom-section-add { padding: 14px; border: 1px dashed #b9cbc7; border-radius: 10px; background: #fbfdfc; }
.custom-section-add .field + .field { margin-top: 10px; }
.custom-section-add button { margin-top: 10px; }
.compact-list { margin-top: 12px; }
.custom-entry-card { padding: 12px; }
.custom-entry-card .field-grid { gap: 9px; }

.resume-check { margin: 0 0 16px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.resume-check-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.resume-check-top h3 { margin: 3px 0 0; font-size: 1rem; }
.score-ring { display: grid; place-items: center; width: 46px; height: 46px; flex: 0 0 46px; border: 3px solid var(--teal); border-radius: 50%; font-size: .9rem; font-weight: 800; color: var(--teal-dark); background: var(--teal-soft); }
.score-ring::after { content: '%'; font-size: .58rem; margin-left: 1px; }
.score-bar { height: 7px; margin: 11px 0; overflow: hidden; border-radius: 999px; background: #e8efed; }
.score-bar span { display: block; width: 0; height: 100%; background: var(--teal); border-radius: inherit; transition: width .2s ease; }
.resume-tips { margin: 0; padding-left: 18px; color: #435257; font-size: .74rem; line-height: 1.45; }
.resume-tips li + li { margin-top: 4px; }
.resume-tips .tip-good { color: #276b55; }
.check-note { margin: 9px 0 0; color: var(--muted); font-size: .66rem; }

.preview-custom-content { white-space: pre-line; }

@media (min-width: 640px) {
    .arrange-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
    .section-row { grid-template-columns: 1fr; }
    .section-order-actions { padding-left: 27px; }
}


/* Phase 3: review and finish */
.resume-contact a {
    color: inherit;
    text-decoration: none;
}
.resume-contact a:hover,
.resume-contact a:focus-visible {
    text-decoration: underline;
}
.preview-bullets {
    margin: 5px 0 0 18px;
    padding: 0;
}
.preview-bullets li {
    margin: 2px 0;
    line-height: 1.4;
}
.review-grid {
    display: grid;
    gap: 16px;
}
.review-card {
    border: 1px solid var(--builder-border, #d8e0e0);
    border-radius: 16px;
    padding: 20px;
    background: #fff;
}
.review-card h3 { margin: 2px 0 8px; }
.review-card p { margin-top: 0; }
.review-card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}
.review-score {
    font-size: 1.65rem;
    line-height: 1;
    color: #116f72;
}
.review-checklist {
    list-style: none;
    margin: 16px 0;
    padding: 0;
    display: grid;
    gap: 9px;
}
.review-checklist li {
    display: grid;
    grid-template-columns: 26px 1fr;
    align-items: start;
    gap: 8px;
}
.review-checklist li span {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    font-weight: 800;
}
.review-good span {
    background: #e7f5ef;
    color: #176b4d;
}
.review-issue span {
    background: #fff1dd;
    color: #8b5600;
}
.review-download-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}
.review-new-card {
    background: #f7fafa;
}
@media print {
    .preview-bullets { margin-left: 16px !important; }
    .preview-bullets li { font-size: inherit !important; }
}


/* Phase 3.2: secondary professional links row */
.resume-links {
    margin: 4px 0 0;
    font-size: 0.88em;
    line-height: 1.35;
    color: #53636a;
}
.resume-links a {
    color: inherit;
    text-decoration: none;
}
.resume-links a:hover,
.resume-links a:focus-visible {
    text-decoration: underline;
}
@media print {
    .resume-paper .resume-links {
        font-size: 9.5pt !important;
        line-height: 1.3 !important;
    }
    .resume-paper[data-spacing="compact"] .resume-links {
        font-size: 9pt !important;
    }
    .resume-paper[data-spacing="airy"] .resume-links {
        font-size: 10pt !important;
    }
}


/* Phase 3.3: normalize resume body typography */
.resume-paper .resume-links {
    font-size: 13px;
    line-height: 1.4;
}
.resume-paper .preview-bullets {
    font-size: 13px;
    line-height: 1.4;
}
.resume-paper .preview-bullets li {
    font-size: inherit;
    line-height: inherit;
    margin: 2px 0;
}

/* Keep density controls consistent with the rest of the resume. */
.resume-paper[data-spacing="compact"] .resume-links,
.resume-paper[data-spacing="compact"] .preview-bullets {
    font-size: 12.5px;
}
.resume-paper[data-spacing="airy"] .resume-links,
.resume-paper[data-spacing="airy"] .preview-bullets {
    font-size: 13.5px;
}

@media print {
    .resume-paper .resume-links,
    .resume-paper .preview-bullets {
        font-size: 10.5pt !important;
        line-height: 1.42 !important;
    }
    .resume-paper[data-spacing="compact"] .resume-links,
    .resume-paper[data-spacing="compact"] .preview-bullets {
        font-size: 10pt !important;
    }
    .resume-paper[data-spacing="airy"] .resume-links,
    .resume-paper[data-spacing="airy"] .preview-bullets {
        font-size: 11pt !important;
    }
}


/* Phase 4B.1 responsive navigation hardening */
.builder-nav { position: relative; }
.builder-nav .menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-direction: column;
    min-width: 42px;
    min-height: 42px;
    margin: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    box-shadow: none;
}
.builder-nav .menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    margin: 0;
    border-radius: 999px;
    background: #fff;
}
.builder-nav .menu-toggle:hover,
.builder-nav .menu-toggle:focus-visible { background: rgba(255,255,255,.10); }
@media (max-width: 768px) {
    .builder-nav { min-height: 64px; }
    .builder-nav .menu-toggle {
        display: flex !important;
        position: static !important;
        right: auto !important;
        top: auto !important;
        padding: 7px !important;
    }
    .builder-nav > ul {
        position: absolute !important;
        top: 64px !important;
        left: auto !important;
        right: 18px !important;
        width: min(260px, calc(100vw - 36px)) !important;
        z-index: 100;
        border-radius: 10px;
        overflow: hidden;
    }
    .builder-nav > ul li {
        width: 100%;
        margin: 0;
        padding: 0;
        text-align: left;
    }
    .builder-nav > ul li a {
        display: block;
        width: 100%;
        padding: 12px 14px;
        text-align: left;
    }
}


/* Phase 4C.2: keep the live resume visible while users enter content */
.preview-toolbar {
    margin-bottom: 14px;
}

.preview-panel > .resume-paper {
    margin-top: 0;
    margin-bottom: 16px;
}

.preview-panel > .design-panel {
    margin-top: 0;
    margin-bottom: 16px;
}

.preview-panel > .resume-check {
    margin-top: 0;
    margin-bottom: 16px;
}

/* On larger screens the preview column stays in view while the editor grows. */
@media (min-width: 1051px) {
    .preview-panel {
        position: sticky;
        top: 86px;
        align-self: start;
    }
}

/* On stacked layouts, keep controls after the preview without sticky behavior. */
@media (max-width: 1050px) {
    .preview-panel {
        position: static;
    }
}


/* Phase 4C.3: persistent readiness dashboard in the intro area */
.builder-intro {
    align-items: start;
    gap: 32px;
    margin-bottom: 18px;
}

.builder-status-stack {
    flex: 0 0 360px;
    display: grid;
    gap: 10px;
}

.builder-status-stack .save-status {
    justify-self: end;
}

.intro-readiness {
    margin: 0;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: white;
    box-shadow: 0 8px 22px rgba(0,35,51,.06);
}

.intro-readiness .resume-check-top {
    align-items: center;
}

.intro-readiness .resume-check-top h3 {
    margin: 2px 0 0;
    font-size: 1rem;
}

.intro-readiness .score-ring {
    width: 48px;
    height: 48px;
    font-size: .9rem;
}

.intro-readiness .score-bar {
    margin-top: 10px;
}

.intro-readiness .resume-tips {
    margin: 8px 0 0;
    max-height: 54px;
    overflow: hidden;
}

.intro-readiness .resume-tips li {
    font-size: .74rem;
    line-height: 1.35;
}

.intro-readiness .check-note {
    margin-top: 7px;
    font-size: .68rem;
}

/* Pull the working area closer to the top now that the readiness card uses hero space. */
.builder-main {
    padding-top: 24px;
}

@media (max-width: 1100px) {
    .builder-intro {
        grid-template-columns: 1fr;
    }

    .builder-status-stack {
        flex-basis: auto;
        width: 100%;
    }

    .builder-status-stack .save-status {
        justify-self: start;
    }

    .intro-readiness {
        max-width: 520px;
    }
}

@media (max-width: 768px) {
    .builder-status-stack {
        gap: 8px;
    }

    .intro-readiness {
        max-width: none;
    }

    .intro-readiness .resume-tips {
        max-height: none;
    }
}


/* Phase 4C.4: readiness stays visible while editing */
.builder-status-stack {
    flex: 0 0 auto;
}

.readiness-dock {
    position: sticky;
    top: 72px;
    z-index: 42;
    display: flex;
    justify-content: flex-end;
    max-width: 1480px;
    margin: -8px auto 12px;
    padding: 0 28px;
    pointer-events: none;
}

.readiness-dock .intro-readiness {
    width: min(390px, 100%);
    pointer-events: auto;
    box-shadow: 0 10px 28px rgba(0,35,51,.10);
}

.readiness-dock .resume-tips {
    max-height: 42px;
    overflow: hidden;
}

/* Keep the dock compact when it is pinned under the navigation. */
.readiness-dock .intro-readiness {
    padding: 11px 14px;
}

.readiness-dock .resume-check-top h3 {
    font-size: .95rem;
}

.readiness-dock .score-ring {
    width: 44px;
    height: 44px;
}

.readiness-dock .score-bar {
    margin-top: 8px;
}

.readiness-dock .check-note {
    margin-top: 5px;
}

@media (max-width: 1050px) {
    .readiness-dock {
        top: 64px;
        padding: 0 14px;
        margin-top: -4px;
    }

    .readiness-dock .intro-readiness {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .readiness-dock {
        position: static;
        margin: 0 0 12px;
        padding: 0;
    }

    .readiness-dock .resume-tips {
        max-height: none;
    }
}


/* Phase 4C.5: dedicated tools column */
.readiness-dock { display: none !important; }

@media (min-width: 1181px) {
    .builder-workspace {
        grid-template-columns: minmax(500px, 1.05fr) minmax(500px, 1fr) 300px;
        max-width: 1760px;
        gap: 18px;
        align-items: start;
    }

    .preview-panel {
        position: static;
    }

    .builder-sidebar {
        min-width: 0;
    }

    .sidebar-sticky {
        position: sticky;
        top: 88px;
        display: grid;
        gap: 14px;
    }

    .sidebar-readiness .intro-readiness {
        width: 100%;
        margin: 0;
        padding: 16px;
    }

    .builder-sidebar .design-panel {
        margin: 0;
        padding: 16px;
    }

    .builder-sidebar .design-heading {
        display: block;
        margin-bottom: 12px;
    }

    .builder-sidebar .design-heading > p {
        margin: 5px 0 0;
        text-align: left;
        font-size: .72rem;
    }

    .builder-sidebar .template-picker {
        grid-template-columns: 1fr 1fr;
        gap: 7px;
    }

    .builder-sidebar .template-option {
        min-height: 58px;
        padding: 9px;
    }

    .builder-sidebar .design-controls {
        grid-template-columns: 1fr;
        gap: 9px;
    }
}

/* At ordinary laptop widths, keep two columns and place tools under preview. */
@media (min-width: 1051px) and (max-width: 1180px) {
    .builder-sidebar {
        grid-column: 2;
    }

    .sidebar-sticky {
        display: grid;
        gap: 14px;
    }

    .sidebar-readiness .intro-readiness,
    .builder-sidebar .design-panel {
        margin: 0;
    }
}

@media (max-width: 1050px) {
    .builder-sidebar {
        grid-column: 1;
    }

    .sidebar-sticky {
        display: grid;
        gap: 14px;
    }

    .sidebar-readiness .intro-readiness,
    .builder-sidebar .design-panel {
        margin: 0;
    }
}


/* Phase 4C.6: responsive layout stabilization */

/* Avoid any child forcing the builder wider than the viewport. */
.builder-main,
.builder-workspace,
.editor-panel,
.preview-panel,
.builder-sidebar,
.sidebar-sticky {
    min-width: 0;
}

.builder-main {
    width: 100%;
    max-width: 1800px;
    overflow-x: clip;
}

/* Wide desktop: true three-column workspace. */
@media (min-width: 1500px) {
    .builder-workspace {
        grid-template-columns: minmax(560px, 1.08fr) minmax(520px, 1fr) 300px;
        gap: 18px;
    }

    .builder-sidebar {
        grid-column: auto;
    }

    .sidebar-sticky {
        position: sticky;
        top: 88px;
    }
}

/* Typical desktop/laptop: editor + preview, with tools below preview.
   This prevents the third column from squeezing the page sideways. */
@media (min-width: 1150px) and (max-width: 1499px) {
    .builder-workspace {
        grid-template-columns: minmax(0, 1.04fr) minmax(430px, .96fr);
        gap: 20px;
    }

    .editor-panel { grid-column: 1; grid-row: 1 / span 2; }
    .preview-panel { grid-column: 2; grid-row: 1; position: sticky; top: 88px; }
    .builder-sidebar { grid-column: 2; grid-row: 2; }

    .sidebar-sticky {
        position: static;
        display: grid;
        grid-template-columns: 1fr;
        gap: 14px;
    }
}

/* Tablet / narrow laptop: one clean column. */
@media (max-width: 1149px) {
    .builder-workspace {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 18px;
    }

    .editor-panel,
    .preview-panel,
    .builder-sidebar {
        grid-column: 1 !important;
        grid-row: auto !important;
        width: 100%;
    }

    .preview-panel {
        position: static !important;
    }

    .sidebar-sticky {
        position: static !important;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 14px;
    }

    .sidebar-readiness .intro-readiness,
    .builder-sidebar .design-panel {
        height: 100%;
    }
}

/* The section tabs should not create a full-page horizontal overflow. */
.step-nav {
    max-width: 100%;
    scrollbar-width: thin;
}

@media (min-width: 769px) and (max-width: 1149px) {
    .step-nav {
        flex-wrap: wrap;
        overflow-x: visible;
        padding: 0 14px;
    }

    .step-button {
        flex: 0 0 auto;
        padding: 14px 10px 11px;
    }
}

/* Switch to the hamburger before the full nav starts wrapping. */
@media (max-width: 1100px) {
    .builder-nav {
        min-height: 64px;
        padding: 0 18px;
    }

    .builder-nav .menu-toggle {
        display: flex !important;
        position: static !important;
        margin-left: auto;
    }

    .builder-nav > ul {
        display: none !important;
        position: absolute !important;
        top: 64px !important;
        left: auto !important;
        right: 18px !important;
        width: min(270px, calc(100vw - 36px)) !important;
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 8px !important;
        background: var(--navy) !important;
        border: 1px solid rgba(255,255,255,.12);
        border-radius: 10px;
        box-shadow: 0 14px 32px rgba(0,0,0,.24);
        z-index: 120;
    }

    .builder-nav > ul.active {
        display: flex !important;
    }

    .builder-nav > ul li {
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .builder-nav > ul li a {
        display: block;
        width: 100%;
        padding: 12px 14px;
        text-align: left;
        white-space: normal;
    }
}

@media (max-width: 768px) {
    .builder-main {
        padding: 18px 12px 36px;
    }

    .builder-intro {
        margin-bottom: 14px;
    }

    .sidebar-sticky {
        grid-template-columns: 1fr;
    }

    .step-nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 0 10px;
        -webkit-overflow-scrolling: touch;
    }

    .step-button {
        padding: 14px 10px 11px;
    }

    .preview-panel,
    .editor-panel {
        border-radius: 14px;
    }
}


/* Phase 4C.7: replace scrolling section tabs with a stable grid */
.step-nav {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    overflow: visible !important;
    padding: 0 !important;
    background: #fbfcfc;
    border-bottom: 1px solid var(--line);
    scrollbar-width: none;
}

.step-nav::-webkit-scrollbar {
    display: none;
}

.step-button {
    width: 100% !important;
    min-width: 0;
    padding: 13px 8px 11px !important;
    border: 0 !important;
    border-right: 1px solid var(--line) !important;
    border-bottom: 1px solid var(--line) !important;
    border-radius: 0 !important;
    text-align: center;
    white-space: normal !important;
    line-height: 1.2;
    font-size: .82rem !important;
}

.step-button:nth-child(4n) {
    border-right: 0 !important;
}

.step-button:nth-child(n+5) {
    border-bottom: 0 !important;
}

.step-button.active {
    position: relative;
    background: var(--teal-soft) !important;
    color: var(--teal-dark) !important;
}

.step-button.active::after {
    content: "";
    position: absolute;
    left: 18%;
    right: 18%;
    bottom: 0;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--teal);
}

/* Keep the form content comfortably wide beneath the step grid. */
.form-step {
    min-width: 0;
}

@media (max-width: 700px) {
    .step-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .step-button:nth-child(4n) {
        border-right: 1px solid var(--line) !important;
    }

    .step-button:nth-child(2n) {
        border-right: 0 !important;
    }

    .step-button:nth-child(n+5) {
        border-bottom: 1px solid var(--line) !important;
    }

    .step-button:nth-child(n+7) {
        border-bottom: 0 !important;
    }
}


/* Phase 4C.8: prevent a trailing blank PDF page */
@media print {
    html,
    body.builder-page {
        width: auto !important;
        min-height: 0 !important;
        height: auto !important;
        overflow: visible !important;
    }

    /* The tools column has no role in the printed resume. Hide the wrapper too,
       not just the cards inside it. */
    .builder-sidebar,
    .sidebar-sticky,
    .sidebar-readiness {
        display: none !important;
    }

    .builder-main,
    .builder-workspace,
    .preview-panel {
        min-height: 0 !important;
        height: auto !important;
        overflow: visible !important;
    }

    .resume-paper {
        /* A printed page is already Letter-sized. Giving the resume an exact
           11in minimum height can round onto a second sheet in Chromium. */
        width: 8.5in !important;
        min-height: 0 !important;
        height: auto !important;
        box-sizing: border-box !important;
        break-after: auto !important;
        page-break-after: auto !important;
    }
}


/* Phase 4C.9: final print refinement */
@media print {
    /* Keep the header polished but use less vertical space. */
    .resume-header {
        padding-top: .28in !important;
        padding-bottom: .25in !important;
    }

    .resume-header h2 {
        margin-bottom: .04in !important;
    }

    .resume-headline {
        margin-bottom: .045in !important;
    }

    .resume-contact {
        margin-bottom: .025in !important;
    }

    .resume-links {
        margin-top: 0 !important;
    }

    /* Normalize vertical rhythm between resume sections. */
    .preview-section {
        margin-top: .16in !important;
        margin-bottom: 0 !important;
    }

    .preview-section h3 {
        margin-bottom: .07in !important;
    }

    .preview-entry {
        margin-bottom: .09in !important;
    }

    /* Project URLs are supporting information, not date metadata. */
    #previewProjects .entry-top {
        display: block !important;
    }

    #previewProjects .entry-meta {
        display: block !important;
        margin-top: .025in !important;
        font-size: 9.5pt !important;
        font-weight: 400 !important;
        color: #52636a !important;
        text-align: left !important;
    }
}

/* Phase 5 launch-prep accessibility */
.skip-link{position:fixed;left:1rem;top:-5rem;z-index:9999;background:#fff;color:#102a35;padding:.75rem 1rem;border-radius:.5rem;box-shadow:0 4px 18px rgba(0,0,0,.18);font-weight:700}
.skip-link:focus{top:1rem}
a:focus-visible,button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible{outline:3px solid #20a6a0;outline-offset:3px}
@media (prefers-reduced-motion:reduce){html{scroll-behavior:auto!important}*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}}
