*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --bg: #f5f7fa;
    --bg-elevated: #ffffff;
    --fg: #172b44;
    --fg-muted: #596779;
    --accent: #2563eb;
    --accent-soft: #eff5ff;
    --card-bg: #ffffff;
    --border-soft: #dfe5ed;
    --radius-lg: 12px;
    --radius-pill: 999px;
    --shadow-soft: 0 3px 14px rgba(23, 43, 68, 0.035);
    --transition-fast: 150ms ease-out;
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --page-width: 920px;
    --reading-width: 78ch;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.7;
    background: var(--bg);
    color: var(--fg);
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

button {
    font-family: inherit;
}

a,
button {
    -webkit-tap-highlight-color: transparent;
}

a:focus-visible,
button:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 4px;
}

/* Keep the existing three-tab navigation. */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-soft);
}

.topbar-inner {
    width: 100%;
    max-width: var(--page-width);
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.logo-mark {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #ffffff;
    font-size: 16px;
}

.logo-text {
    font-weight: 600;
    font-size: 15px;
    color: var(--fg);
}

.nav {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.nav-link {
    border: 1px solid transparent;
    background: transparent;
    color: var(--fg-muted);
    min-height: 40px;
    padding: 8px 14px;
    border-radius: var(--radius-pill);
    font-size: 14px;
    line-height: 1.4;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast),
        border-color var(--transition-fast);
}

.nav-link:hover {
    color: var(--accent);
    background: var(--accent-soft);
    border-color: #d4e2fc;
}

.nav-link.active {
    color: #ffffff;
    background: var(--accent);
    border-color: var(--accent);
}

.nav-link.active:hover {
    background: #1d4ed8;
}

/* A consistent page width keeps all tabs aligned. */

.page {
    flex: 1;
    width: 100%;
    max-width: var(--page-width);
    margin: 36px auto 24px;
    padding: 0 24px 32px;
}

.section {
    display: none;
    gap: 24px;
    flex-direction: column;
    min-width: 0;
}

.section-active {
    display: flex;
}

.card {
    min-width: 0;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-soft);
    padding: 32px 36px;
}

.card h2 {
    margin: 0 0 24px;
    font-size: 25px;
    line-height: 1.3;
    letter-spacing: -0.02em;
    font-weight: 650;
    color: var(--fg);
}

/* Homepage typography and reading measure. */

.hero {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.hero-main {
    width: 100%;
    max-width: var(--reading-width);
    min-width: 0;
}

.hero-name {
    margin: 0 0 12px;
    font-size: 40px;
    line-height: 1.2;
    letter-spacing: -0.035em;
    font-weight: 700;
}

.hero-subtitle {
    margin: 0 0 12px;
    font-size: 18px;
    line-height: 1.55;
    color: #3e4f65;
}

.hero-summary {
    margin: 0 0 18px;
    font-size: 14px;
    line-height: 1.75;
    color: var(--fg-muted);
}

.hero-meta {
    margin: 0 0 24px;
    font-size: 14px;
    color: var(--fg-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 4px 6px;
    align-items: center;
}

.hero-meta a {
    color: var(--accent);
    text-decoration: none;
    overflow-wrap: anywhere;
}

.hero-meta a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.hero-about {
    margin: 0 0 20px;
    font-size: 16px;
    line-height: 1.75;
    color: #37475b;
}

.hero-links {
    margin-top: 26px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.pill-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    min-height: 40px;
    margin: 8px 8px 0 0;
    padding: 8px 15px;
    border-radius: var(--radius-pill);
    font-size: 14px;
    line-height: 1.45;
    font-weight: 500;
    text-align: center;
    overflow-wrap: anywhere;
    border: 1px solid #cbd5e1;
    color: #294262;
    text-decoration: none;
    background: var(--bg-elevated);
    transition: background var(--transition-fast), border-color var(--transition-fast),
        color var(--transition-fast);
}

.hero-links .pill-link {
    margin: 0;
}

.pill-link:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: #1d4ed8;
}

/* Paper and project entries remain in their existing HTML lists. */

.list {
    list-style: none;
    max-width: var(--reading-width);
    margin: 0;
    padding-left: 0;
    display: flex;
    flex-direction: column;
    gap: 22px;
    font-size: 16px;
    color: #37475b;
}

.list li {
    min-width: 0;
    line-height: 1.7;
    overflow-wrap: break-word;
}

.list strong {
    color: var(--fg);
    font-weight: 650;
}

.list-links a {
    display: inline-block;
    color: #245bc1;
    text-decoration: none;
    text-underline-offset: 4px;
    overflow-wrap: anywhere;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.6;
}

.list-links a:hover {
    text-decoration: underline;
}

.muted {
    display: block;
    font-size: 14px;
    line-height: 1.75;
    color: var(--fg-muted);
    margin-top: 7px;
}

#projects_skills_experience .card:first-child > .list {
    gap: 0;
}

#projects_skills_experience .card:first-child > .list > li + li {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-soft);
}

#projects_skills_experience .card:first-child .list strong {
    display: inline-block;
    margin-bottom: 4px;
    font-size: 18px;
    line-height: 1.45;
}

.footer {
    text-align: center;
    padding: 12px 20px 24px;
    font-size: 13px;
    color: var(--fg-muted);
}

.footer p {
    margin: 0;
}

/* Wrap links naturally while retaining readable text on small screens. */

@media (max-width: 760px) {
    .topbar-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 14px 20px;
    }

    .nav {
        width: 100%;
        justify-content: flex-start;
        gap: 8px;
    }

    .nav-link {
        min-height: 44px;
        font-size: 13px;
        padding: 9px 13px;
    }

    .page {
        margin-top: 24px;
        padding: 0 20px 24px;
    }

    .card {
        padding: 26px;
    }

    .hero-name {
        font-size: 34px;
    }

    .pill-link {
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    .topbar-inner {
        padding-inline: 14px;
    }

    .page {
        margin-top: 18px;
        padding-inline: 14px;
    }

    .section {
        gap: 18px;
    }

    .card {
        padding: 24px 20px;
    }

    .card h2 {
        font-size: 23px;
        margin-bottom: 22px;
    }

    .hero-name {
        font-size: 31px;
    }

    .hero-subtitle {
        font-size: 17px;
    }

    .hero-summary {
        line-height: 1.8;
    }

    .hero-meta {
        margin-bottom: 22px;
    }

    .hero-links {
        gap: 9px;
    }

    .pill-link {
        padding-inline: 13px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .nav-link,
    .pill-link {
        transition: none;
    }
}
