:root {
    --bg: #ffffff;
    --surface: #f5f5f7;
    --surface-hover: #eeeef0;
    --text: #1d1d1f;
    --muted: #6e6e73;
    --faint: #86868b;
    --line: #e3e3e8;
    --line-strong: #d2d2d7;
    --radius: 12px;
    --max: 1100px;
    --measure: 740px;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    font-size: 1.02rem;
    line-height: 1.65;
}

h1,
h2,
h3 {
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 400;
    line-height: 1.15;
    letter-spacing: -0.01em;
    margin-top: 0;
    text-wrap: balance;
}

p {
    margin: 0 0 1em;
}

p:last-child {
    margin-bottom: 0;
}

a {
    color: var(--text);
    text-decoration-color: var(--line-strong);
    text-underline-offset: 3px;
    transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

a:hover {
    color: var(--muted);
    text-decoration-color: currentColor;
}

:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 3px;
    border-radius: 3px;
}

.container {
    width: min(92vw, var(--max));
    margin: 0 auto;
}

.narrow {
    max-width: var(--measure);
}

/* Header */

.site-header {
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.82);
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
}

.header-inner {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.25rem;
    text-decoration: none;
    color: var(--text);
    white-space: nowrap;
}

.brand:hover {
    color: var(--text);
}

.nav-list {
    list-style: none;
    display: flex;
    gap: 4px;
    margin: 0;
    padding: 0;
}

.nav-list a {
    display: inline-block;
    text-decoration: none;
    color: var(--muted);
    font-size: 0.92rem;
    padding: 6px 12px;
    border-radius: 999px;
}

.nav-list a:hover {
    color: var(--text);
    background: var(--surface);
}

.nav-list a.active {
    color: var(--text);
    background: var(--surface);
}

/* Page head — the only heading a subpage gets */

.eyebrow,
.page-label {
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--faint);
    font-size: 0.78rem;
    line-height: 1.4;
    margin: 0;
}

.page-head {
    padding: 56px 0 8px;
}

/* Home hero */

.hero {
    padding: 104px 0 56px;
}

.hero h1 {
    font-size: clamp(2.8rem, 7vw, 4.6rem);
    margin: 0;
}

/* Sections */

.section {
    padding: 36px 0;
}

.section:last-child {
    padding-bottom: 72px;
}

.section+.section {
    border-top: 1px solid var(--line);
}

.section h2 {
    font-size: 1.45rem;
    margin: 0 0 22px;
    color: var(--text);
}

.lead {
    font-size: 1.15rem;
    line-height: 1.6;
    color: var(--muted);
}

/* Project list */

.project-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.project {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px 22px;
    background: var(--bg);
    transition: background 0.15s ease, border-color 0.15s ease;
}

.project:hover {
    background: var(--surface);
    border-color: var(--line-strong);
}

.project h3 {
    font-size: 1.15rem;
    margin: 0 0 6px;
}

.project p {
    color: var(--muted);
    margin: 0;
}

.project .link {
    display: inline-block;
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--muted);
    text-decoration: none;
}

.project .link:hover {
    color: var(--text);
}

.project .link::after {
    content: " →";
}

/* Timeline (CV) */

.timeline {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.timeline-entry {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 22px;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--line);
}

.timeline-entry:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.timeline-date {
    color: var(--faint);
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    white-space: nowrap;
    padding-top: 3px;
}

.timeline-entry h3 {
    font-size: 1.15rem;
    margin: 0 0 2px;
}

.timeline-entry .place {
    color: var(--muted);
    font-size: 0.95rem;
    margin: 0 0 8px;
}

.timeline-entry p:last-child {
    color: var(--muted);
    margin: 0;
}

/* Skills */

.skills {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.skills li {
    display: grid;
    grid-template-columns: 170px 1fr;
    gap: 22px;
    color: var(--muted);
}

.skills strong {
    font-weight: 500;
    color: var(--text);
    font-size: 0.95rem;
}

/* Publications */

.pub-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.pub-entry {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px 26px;
}

.pub-venue {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
}

.pub-venue img {
    height: 40px;
    width: auto;
    max-width: 190px;
    object-fit: contain;
}

.pub-entry h3 {
    font-size: 1.2rem;
    margin: 0 0 6px;
}

.pub-entry .pub-meta {
    color: var(--faint);
    font-size: 0.88rem;
    margin: 0;
}

.pub-entry .pub-meta+p {
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 0.97rem;
}

.abstract {
    margin-top: 14px;
    border-top: 1px solid var(--line);
    padding-top: 12px;
}

.abstract>summary {
    cursor: pointer;
    list-style: none;
    color: var(--muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.abstract>summary::-webkit-details-marker {
    display: none;
}

.abstract>summary::after {
    content: "+";
    font-size: 0.95rem;
    letter-spacing: 0;
    line-height: 1;
}

.abstract[open]>summary::after {
    content: "–";
}

.abstract>summary:hover {
    color: var(--text);
}

.abstract p {
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 0.97rem;
}

.pub-entry .doi {
    display: inline-block;
    margin-top: 14px;
    font-size: 0.85rem;
    color: var(--muted);
    text-decoration: none;
    word-break: break-word;
}

.pub-entry .doi:hover {
    color: var(--text);
}

.pub-entry .doi::after {
    content: " ↗";
}

/* Contact */

.contact-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.contact-list li {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 22px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.contact-list li:last-child {
    border-bottom: none;
}

.contact-list .label {
    color: var(--faint);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding-top: 2px;
}

/* Footer */

.site-footer {
    border-top: 1px solid var(--line);
    padding: 28px 0 40px;
    color: var(--faint);
    font-size: 0.85rem;
}

/* Chat widget */

#chat-launcher {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 50;
    background: var(--text);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 13px 22px;
    font-size: 0.92rem;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
    transition: transform 0.15s ease, background 0.15s ease;
}

#chat-launcher:hover {
    background: #3a3a3c;
    transform: translateY(-1px);
}

#chat-panel {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 51;
    width: min(380px, 88vw);
    height: min(520px, 72vh);
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#chat-panel[hidden] {
    display: none;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.chat-header h2 {
    font-size: 0.95rem;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    font-weight: 500;
}

#chat-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--muted);
    line-height: 1;
    padding: 0 2px;
}

#chat-close:hover {
    color: var(--text);
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-msg {
    max-width: 85%;
    padding: 9px 14px;
    border-radius: 16px;
    font-size: 0.92rem;
    line-height: 1.45;
}

.chat-msg.user {
    align-self: flex-end;
    background: var(--text);
    color: #fff;
    border-bottom-right-radius: 5px;
}

.chat-msg.bot {
    align-self: flex-start;
    background: var(--surface);
    border-bottom-left-radius: 5px;
}

.chat-msg.error {
    align-self: flex-start;
    background: var(--surface);
    color: var(--muted);
    border-bottom-left-radius: 5px;
}

.chat-form {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--line);
}

.chat-form input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 9px 14px;
    font-size: 0.92rem;
    font-family: inherit;
}

.chat-form input:focus {
    outline: none;
    border-color: var(--text);
}

.chat-form button {
    border: none;
    background: var(--text);
    color: #fff;
    border-radius: 999px;
    padding: 0 18px;
    cursor: pointer;
    font-size: 0.92rem;
    font-family: inherit;
}

.chat-form button:disabled {
    background: var(--faint);
    cursor: default;
}

@media (max-width: 700px) {
    .header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        padding: 12px 0;
    }

    .nav-list {
        flex-wrap: wrap;
        gap: 2px;
        margin-left: -12px;
    }

    .hero {
        padding: 64px 0 40px;
    }

    .page-head {
        padding: 40px 0 8px;
    }

    .timeline-entry,
    .skills li,
    .contact-list li {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .pub-entry {
        padding: 20px 18px;
    }

    #chat-panel {
        right: 12px;
        bottom: 12px;
        left: 12px;
        width: auto;
    }

    #chat-launcher {
        right: 12px;
        bottom: 12px;
    }
}
