:root {
    --text: #111111;
    --text-secondary: #4d4d4d;
    --text-tertiary: #8a8a8a;
    --border: #e6e4df;
    --accent: #0034F0;
    --accent-soft: #eef1ff;
    --page: #f4f3ef;
    --card: #fff;
    --page-max: 880px;
    --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 15px; line-height: 1.55; }

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--page);
    padding: 40px 24px 64px;
}

.page {
    max-width: var(--page-max);
    margin: 0 auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px 44px 44px;
    box-shadow: 0 1px 2px rgba(22, 22, 22, 0.04), 0 18px 40px rgba(22, 22, 22, 0.05);
}

a { color: var(--accent); }

.toolbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    background: #fafafa;
    border-bottom: 1px solid var(--border);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 100;
    font-size: 13px;
}
.toolbar a,
.toolbar button {
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid var(--border);
    background: white;
    color: var(--text);
    text-decoration: none;
}
.toolbar button:hover,
.toolbar a:hover { background: #f0f0f0; text-decoration: none; }
.toolbar .spacer { flex: 1; }
.toolbar .cv-tabs {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border-radius: 8px;
    background: #ececec;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.toolbar .cv-tabs a {
    flex: none;
    white-space: nowrap;
    padding: 5px 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-tertiary);
}
.toolbar .cv-tabs a:hover { background: rgba(0, 0, 0, 0.04); }
.toolbar .cv-tabs a[aria-current="page"] {
    background: white;
    color: var(--text);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.toolbar .label { color: var(--text-tertiary); }
.toolbar .langsw {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    padding: 0 4px 0 12px;
    border-left: 1px solid var(--border);
}
.toolbar .langsw button {
    border: 0;
    background: none;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1;
    color: var(--text-tertiary);
    padding: 6px 7px;
    border-radius: 8px;
}
.toolbar .langsw button:hover { background: none; color: var(--text); }
.toolbar .langsw button.on { color: var(--text); font-weight: 600; }

body { padding-top: 88px; }

.resume-header {
    margin-bottom: 28px;
}
.resume-header .intro {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 40px;
    align-items: start;
}
.resume-header .identity {
    min-width: 0;
}
.resume-header .eyebrow {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 8px;
}
.resume-header h1 {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.035em;
    line-height: 1.1;
    margin-bottom: 16px;
}
.resume-header .subtitle {
    font-size: 14.5px;
    line-height: 1.65;
    letter-spacing: -0.015em;
    font-weight: 400;
    color: var(--text-secondary);
    max-width: none;
    margin-bottom: 0;
}
.resume-header .subtitle .kw {
    color: var(--text);
}
.resume-header .contact {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 12px;
    padding-top: 0;
}
.resume-header .contact .contact-item {
    justify-content: flex-start;
    width: auto;
}
.contact-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: #f6f5f1;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 12px;
    text-decoration: none;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}
a.contact-item {
    color: var(--accent);
    background: var(--accent-soft);
    border-color: #d5dcff;
}
a.contact-item:hover {
    background: #e0e6ff;
}
a.contact-item .hint {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.layout {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 40px;
    align-items: start;
}

.section { margin-bottom: 26px; }
.section:last-child { margin-bottom: 0; }
.section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}
.section-title::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.role {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.role:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 0;
}
.role-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    margin-bottom: 3px;
}
.role-title { font-size: 16px; font-weight: 600; letter-spacing: -0.02em; }
.role-meta {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-tertiary);
    white-space: nowrap;
    background: #f6f5f1;
    border-radius: 999px;
    padding: 3px 9px;
}
.role-org { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.role-scopes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 10px;
}
.role-scope {
    display: inline-block;
    font-size: 12px;
    font-weight: 500;
    color: var(--accent);
    background: var(--accent-soft);
    border-radius: 6px;
    padding: 3px 8px;
    margin: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}
.role-scope--muted {
    color: var(--text-tertiary);
    background: #f0efeb;
}
.role ul {
    padding-left: 18px;
    font-size: 13.5px;
    line-height: 1.65;
    letter-spacing: -0.015em;
    font-weight: 400;
    color: var(--text-secondary);
}
.role li { margin-bottom: 6px; }
.role li:last-child { margin-bottom: 0; }
.role li::marker { color: #b8b6b0; }
.kw { font-weight: 600; color: var(--text); }

.side {
    padding-left: 8px;
}
.side-list {
    list-style: none;
    font-size: 13px;
    line-height: 1.55;
    letter-spacing: -0.015em;
    font-weight: 400;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.side-list strong {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 3px;
}

.edu-entry { margin-bottom: 14px; }
.edu-entry:last-child { margin-bottom: 0; }
.edu-entry .degree { display: block; font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }
.edu-entry .school { display: block; font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }
.edu-entry .year { display: block; font-size: 12px; color: var(--text-tertiary); margin-top: 3px; }

.portfolio-page {
    margin-top: 36px;
}
.portfolio-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    margin-bottom: 16px;
}
.portfolio-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--accent);
    margin: 0;
}
.portfolio-access {
    margin: 0;
    font-size: 12.5px;
    color: var(--text-secondary);
    white-space: nowrap;
}
.portfolio-access a { text-decoration: none; }
.portfolio-access strong { font-weight: 600; color: var(--text); }
.portfolio-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px 16px;
}
.work-card {
    display: block;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}
.work-shot {
    aspect-ratio: 16 / 10;
    margin-bottom: 10px;
    border-radius: 10px;
    background: #f3f2ee;
    overflow: hidden;
}
.work-shot img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 9px;
}
.work-shot--agent {
    background: #f4f5f6;
    overflow: hidden;
    border-radius: 10px;
}
.work-shot--agent img {
    object-fit: contain;
    object-position: center;
}
.work-shot--kyc img { object-position: 17% center; }
.work-shot--dash img { object-position: center 30%; }
.work-meta {
    margin-bottom: 3px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}
.work-title {
    margin-bottom: 4px;
    font-size: 14.5px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.3;
}
.work-outcome {
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--text-secondary);
}

@media print {
    .toolbar { display: none !important; }
    .ai-summary { display: none !important; }
    #preview-page-gap { display: none !important; }
    .page { padding-bottom: 0 !important; }
}

/* Screen preview uses the same type, spacing, and image crop as the PDF. */
@media screen, print {
    html { font-size: 13px; }
    body {
        background: white;
        line-height: 1.5;
    }
    .page {
        border: 0;
        border-radius: 0;
        box-shadow: none;
        padding: 0;
        max-width: none;
    }
    .resume-header {
        margin-bottom: 24px;
    }
    .resume-header .eyebrow {
        margin-bottom: 6px;
        font-size: 10px;
    }
    .resume-header h1 {
        font-size: 26px;
        margin-bottom: 14px;
    }
    .resume-header .intro {
        display: grid !important;
        grid-template-columns: 1fr 200px !important;
        gap: 32px !important;
        align-items: start !important;
    }
    .resume-header .subtitle {
        font-size: 12.5px;
        line-height: 1.6;
        letter-spacing: -0.015em;
        font-weight: 400;
        margin-bottom: 0;
        color: var(--text-secondary);
    }
    .resume-header .subtitle .kw {
        color: var(--text) !important;
        font-weight: 600 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .resume-header .contact {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px;
    }
    .resume-header .contact .contact-item {
        width: auto !important;
    }
    .contact-item {
        font-size: 11.5px;
        padding: 5px 11px;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    a.contact-item {
        color: var(--accent) !important;
        background: var(--accent-soft) !important;
        border-color: #d5dcff !important;
        text-decoration: none;
    }
    .layout {
        display: grid !important;
        gap: 32px !important;
        grid-template-columns: 1fr 200px !important;
        align-items: start !important;
    }
    .section { margin-bottom: 20px; }
    .section-title {
        margin-bottom: 14px;
        gap: 10px;
        font-size: 10.5px;
    }
    .section-title::after {
        content: "";
        flex: 1;
        height: 1px;
        background: var(--border) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .role {
        margin-bottom: 16px;
        padding-bottom: 16px;
        break-inside: avoid;
        page-break-inside: avoid;
    }
    /* EN: OKX ends page 1 before the forced break — hide its rule */
    html[lang="en"] .role.role--no-rule {
        border-bottom: 0;
    }
    /* ZH: OKX stays mid-page — keep the divider */
    html[lang="zh-CN"] .role.role--no-rule {
        border-bottom: 1px solid var(--border);
    }
    /* ZH: Manulife ends page 1 — no trailing rule above the page break */
    html[lang="zh-CN"] .role.role--page-two {
        border-bottom: 0;
    }
    .role-title { font-size: 14px; }
    .role-meta {
        font-size: 11px;
        padding: 2px 8px;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .role-org {
        font-size: 12px;
        margin-bottom: 6px;
    }
    .role-scopes {
        gap: 5px;
        margin: 0 0 8px;
    }
    .role-scope {
        font-size: 11px;
        padding: 2px 7px;
        color: var(--accent) !important;
        background: var(--accent-soft) !important;
        border-radius: 5px;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .role-scope--muted {
        color: var(--text-tertiary) !important;
        background: #f0efeb !important;
    }
    .role ul {
        font-size: 12px;
        line-height: 1.55;
        letter-spacing: -0.015em;
        font-weight: 400;
        padding-left: 16px;
        color: var(--text-secondary) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .role li { margin-bottom: 4px; }
    .kw {
        color: var(--text) !important;
        font-weight: 600 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .side { padding-left: 4px; }
    .side-list {
        font-size: 11.5px;
        gap: 12px;
        line-height: 1.5;
        letter-spacing: -0.015em;
        font-weight: 400;
        color: var(--text-secondary) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .side-list strong {
        font-size: 11px;
        margin-bottom: 2px;
    }
    .side .section { margin-bottom: 0; }
    .side .section + .section {
        margin-top: 22px;
    }
    .edu-entry { margin-bottom: 10px; }
    .edu-entry .degree { font-size: 12px; }
    .edu-entry .school, .edu-entry .year { font-size: 11px; }
    /*
      Browser date/title/URL headers render inside @page margins.
      Zero margins clip them; body padding keeps content inset on page 1.
    */
    @page { size: A4; margin: 0; }
    body {
        padding: 12mm 14mm !important;
    }
    /* Match page-1 top inset when a role starts page 2.
       EN breaks before Manulife; ZH is denser and breaks before Quantifeed. */
    html[lang="en"] .role--page-two,
    html[lang="zh-CN"] .role--page-two-zh {
        break-before: page;
        page-break-before: always;
        padding-top: 12mm;
    }
    /* EN page 2 holds three roles plus the portfolio. A slightly
       tighter rhythm keeps both on the page without crowding. */
    html[lang="en"] .role--page-two,
    html[lang="en"] .role--page-two ~ .role {
        margin-bottom: 10px;
        padding-bottom: 10px;
    }
    html[lang="en"] .role--page-two ul,
    html[lang="en"] .role--page-two ~ .role ul {
        line-height: 1.42;
    }
    html[lang="en"] .role--page-two li,
    html[lang="en"] .role--page-two ~ .role li {
        margin-bottom: 2px;
    }
    html[lang="en"] .role--page-two ~ .role:last-child {
        margin-bottom: 0;
        padding-bottom: 0;
        border-bottom: 0;
    }
    .portfolio-page {
        break-before: auto;
        page-break-before: auto;
        /* Same width as the experience column (1fr beside a 200px side, 32px gap). */
        width: calc(100% - 232px);
        margin-top: 18px;
        margin-left: 0;
        margin-right: auto;
        padding-top: 0;
    }
    .portfolio-head { margin-bottom: 10px; }
    .portfolio-grid {
        gap: 16px 16px;
        align-items: start;
        justify-content: stretch;
    }
    .work-card {
        width: auto;
        max-width: none;
        margin: 0;
    }
    /* Same frame colors as the screen: covers composite on #f3f2ee,
       the agent workspace on #f4f5f6. */
    .work-shot,
    .work-shot--kyc,
    .work-shot--dash {
        width: 100%;
        height: auto;
        aspect-ratio: 16 / 10;
        display: block;
        margin: 0 0 8px;
        border-radius: 8px;
        overflow: hidden;
        background: #f3f2ee;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .work-shot--agent {
        width: 100%;
        height: auto;
        aspect-ratio: 16 / 10;
        display: block;
        margin: 0 0 8px;
        border-radius: 8px;
        overflow: hidden;
        background: #f4f5f6;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .work-shot img,
    .work-shot--kyc img,
    .work-shot--dash img {
        display: block;
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        object-fit: cover;
        object-position: center;
        border-radius: 0;
    }
    .work-shot--agent img {
        object-fit: contain;
        object-position: center;
    }
    .work-shot--kyc img { object-position: 17% center; }
    .work-shot--dash img { object-position: center 30%; }
    .work-shot--kyb img { object-position: center top; }
    .work-meta { font-size: 9.5px; margin-bottom: 3px; }
    .work-title { font-size: 11.5px; margin-bottom: 3px; line-height: 1.3; }
    .work-outcome { font-size: 10px; line-height: 1.45; margin: 0; }
}

@media (max-width: 700px) {
    .page { padding: 28px 20px; }
    .layout { grid-template-columns: 1fr; gap: 28px; }
    .resume-header .intro {
        grid-template-columns: 1fr 168px;
        gap: 20px;
    }
}

@media (max-width: 520px) {
    .resume-header .intro { grid-template-columns: 1fr; gap: 16px; }
    .resume-header .contact { flex-direction: row; flex-wrap: wrap; }
    .resume-header .contact .contact-item { width: auto; }
    .portfolio-head { flex-direction: column; align-items: flex-start; gap: 6px; }
    .portfolio-access { white-space: normal; }
    .portfolio-grid { grid-template-columns: 1fr; }
}

body.force-print-desktop .layout,
body.force-print-desktop .resume-header .intro {
    display: grid !important;
    grid-template-columns: 1fr 200px !important;
    gap: 32px !important;
}
body.force-print-desktop .resume-header .contact {
    flex-direction: column !important;
    align-items: flex-start !important;
}
body.force-print-desktop .role-header {
    flex-direction: row !important;
}

@media screen {
    html { background: var(--page); }
    body {
        background: var(--page) !important;
        padding: 88px 16px 48px !important;
        line-height: 1.5;
    }
    .role { border-bottom: 0 !important; }
    .page {
        position: relative;
        isolation: isolate;
        width: 210mm;
        margin: 0 auto;
        background: transparent;
        padding-top: 12mm !important;
        padding-right: 14mm !important;
        padding-left: 14mm !important;
        padding-bottom: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }
    .page::before,
    .page::after {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        height: 297mm;
        background: #fff;
        border: 1px solid var(--border);
        border-radius: 16px;
        box-shadow: 0 1px 2px rgba(22, 22, 22, 0.04), 0 18px 40px rgba(22, 22, 22, 0.05);
        z-index: -1;
        pointer-events: none;
    }
    .page::before { top: 0; }
    .page::after { bottom: 0; }
    .layout,
    .resume-header .intro {
        display: grid !important;
        grid-template-columns: 1fr 200px !important;
        gap: 32px !important;
    }
    .portfolio-grid { grid-template-columns: 1fr 1fr !important; }
    #a4-ruler {
        position: absolute;
        width: 0;
        height: 297mm;
        overflow: hidden;
        visibility: hidden;
        pointer-events: none;
    }
    .ai-summary {
        width: 210mm;
        margin: 0 auto 16px;
        padding: 14px 18px 16px;
        background: var(--accent-soft);
        border: 1px solid #d9e0ff;
        border-radius: 12px;
    }
    .ai-summary-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin-bottom: 6px;
    }
    .ai-summary-label {
        font-size: 11px;
        font-weight: 600;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        color: var(--accent);
    }
    .ai-summary-copy {
        font-family: var(--font);
        font-size: 12px;
        font-weight: 500;
        padding: 4px 12px;
        border: 1px solid #c9d2ff;
        border-radius: 6px;
        background: white;
        color: var(--accent);
        cursor: pointer;
    }
    .ai-summary-copy:hover { background: #f6f8ff; }
    .ai-summary-text {
        font-size: 13px;
        line-height: 1.65;
        color: var(--text-secondary);
    }
    #preview-page-gap { display: block; }
    .preview-page-cut {
        height: 28px;
    }
}
