:root {
    --primary: #0f172a;
    --accent: #2563eb;
    --bg: #f8fafc;
    --card: #ffffff;
    --text-secondary: #64748b;
    --border: #e2e8f0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg);
    color: var(--primary);
    line-height: 1.35;
    padding: 16px;
    font-size: 13.2px;
}

.container {
    max-width: 860px;
    margin: 0 auto;
    background: var(--card);
    padding: 18px 22px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    display: grid;
    grid-template-columns: 2.2fr 1fr;
    gap: 28px;
}

header {
    grid-column: 1 / -1;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 10px;
    margin-bottom: 8px;
}

section {
    margin-bottom: 12px;
    padding-bottom: 8px;
}

section:not(:last-child) {
    border-bottom: 1px solid var(--border);
}

h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.8px;
    color: var(--primary);
    line-height: 1.1;
}

.subtitle {
    font-size: 1rem;
    color: var(--accent);
    font-weight: 600;
    margin-top: 3px;
}

.contact-info {
    text-align: right;
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.contact-info a {
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
    transition: 0.2s;
}

.contact-info a:hover {
    border-color: var(--accent);
    color: var(--accent);
}

h2 {
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    border-left: 3px solid var(--accent);
    padding-left: 8px;
}

p {
    margin-bottom: 8px;
    color: #334155;
}

.timeline-item {
    margin-bottom: 14px;
    break-inside: avoid;
    page-break-inside: avoid;
}

.item-header {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 2px;
}

.role {
    font-weight: 700;
    font-size: 0.98rem;
    line-height: 1.2;
}

.company {
    color: var(--accent);
    font-weight: 500;
    margin-bottom: 3px;
    font-size: 0.92rem;
}

.company a {
    color: var(--accent);
    text-decoration: none;
}

.date {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.description {
    font-size: 0.88rem;
    color: #475569;
    line-height: 1.35;
}

.sidebar-section {
    margin-bottom: 18px;
    break-inside: avoid;
    page-break-inside: avoid;
}

.skill-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    background: #f1f5f9;
    color: #334155;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    border: 1px solid var(--border);
    cursor: default;
    line-height: 1.2;
}

.projects li .tag {
    width: 100%;
}

.tag.highlight {
    background: #eff6ff;
    color: var(--accent);
    border-color: #bfdbfe;
}

.tag:hover {
    border-color: var(--accent);
    color: var(--accent);
}

a {
    text-decoration: none;
    color: var(--primary);
}

.projects,
.interests {
    list-style: none;
}

.projects li,
.interests li {
    margin-bottom: 5px;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.25;
}

main, aside {
    min-width: 0;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        grid-template-columns: 1fr;
        padding: 18px;
        gap: 18px;
    }

    header {
        flex-direction: column;
        text-align: left;
    }

    .contact-info {
        text-align: left;
        margin-top: 14px;
    }
}

@media print {
    @page {
        size: A4;
        margin: 10mm 10mm;
    }

    html, body {
        width: 210mm;
        height: 297mm;
        margin: 0;
        padding: 0;
    }

    body {
        background: white;
        padding: 0;
        font-size: 11px;
        line-height: 1.35;
    }

    /* Make the grid fill the full page height and distribute space */
    .container {
        box-shadow: none;
        border-radius: 0;
        max-width: 100%;
        width: 100%;
        /* Full A4 height minus page margins */
        height: calc(297mm - 20mm);
        padding: 10px 14px;
        gap: 20px;
        grid-template-columns: 2.2fr 1fr;
        /* Key: make grid rows fill height */
        grid-template-rows: auto 1fr;
    }

    /* Main and aside fill remaining height and distribute their children */
    main {
        display: flex;
        flex-direction: column;
    }

    aside {
        display: flex;
        flex-direction: column;
    }

    .sidebar-section h2 {
        font-size: 13px;
    }

    /* Sections within main fill and distribute evenly */
    main section {
        flex: 1;
        display: flex;
        flex-direction: column;
        margin-bottom: 0;
        padding-bottom: 0;
        border-bottom: 1px solid var(--border);
    }

    main section:last-child {
        border-bottom: none;
        margin-top: 20px;
    }

    /* Timeline items within each section fill the section */
    main section > h2 {
        flex-shrink: 0;
    }

    main section > .timeline-item:last-child {
        margin-bottom: 0;
    }

    header {
        padding-bottom: 8px;
        margin-bottom: 0;
    }

    h1 {
        font-size: 22px;
    }

    h2 {
        font-size: 16px;
        margin-bottom: 8px;
        letter-spacing: 1px;
    }

    .subtitle {
        font-size: 12px;
    }

    p {
        margin-bottom: 5px;
    }

    .timeline-item {
        margin-bottom: 11px;
    }

    .item-header {
        margin-bottom: 1px;
    }

    .description,
    .tag,
    .contact-info,
    .company {
        font-size: 12px;
    }

    .projects li,
    .interests li {
        font-size: 10px;
    }

    .role {
        font-size: 14px;
    }

    .date {
        font-size: 12.5px;
    }

    .contact-info {
        line-height: 1.5;
    }

    .skill-tags {
        gap: 5px;
    }

    div[style*="margin-bottom: 20px"] {
        margin-bottom: 12px !important;
    }

    a {
        text-decoration: none;
        color: black;
    }

    .contact-info a {
        color: #2563eb;
    }

    .company a {
        color: #2563eb;
    }

    .tag {
        border: 1px solid #ccc;
        padding: 2px 7px;
    }

    .projects li {
        margin-bottom: 5px;
    }

    .interests li {
        margin-bottom: 5px;
    }
}