/* Shared identity and small-screen adaptations. */
.mobile-table-hint {
    display: none;
}

.mobile-brand {
    flex: 0 1 auto;
    min-width: 0;
    margin-right: auto;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 750;
    letter-spacing: -0.035em;
    line-height: 1.15;
}

.skip-link {
    position: fixed;
    z-index: 1100;
    top: max(0.75rem, env(safe-area-inset-top));
    left: max(0.75rem, env(safe-area-inset-left));
    padding: 0.7rem 1rem;
    transform: translateY(calc(-100% - 2rem - env(safe-area-inset-top)));
    border-radius: 0.55rem;
    background: var(--surface-raised);
    color: var(--primary-dark);
    font-weight: 700;
}

.skip-link:focus { transform: none; }

@media (max-width: 1024px) {
    .navbar { padding-block: calc(7px + env(safe-area-inset-top)) 7px; }
    .navbar .container { justify-content: flex-start; gap: 12px; }
    .mobile-brand {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }
    .nav-toggle { flex: 0 0 44px; border: 1px solid var(--border-color); border-radius: 9px; }
    .nav-toggle:is(:hover, .active) { background: var(--bg-secondary); }
    .nav-toggle span { width: 19px; height: 2px; }
    .nav-toggle.active span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
    .nav-toggle.active span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
    .nav-menu {
        position: absolute;
        inset: 100% 0 auto;
        width: 100%;
        max-height: calc(100vh - 76px - env(safe-area-inset-top));
        max-height: calc(100dvh - 76px - env(safe-area-inset-top));
        padding: 10px max(18px, calc((100vw - 580px) / 2)) 18px;
        gap: 4px;
        overflow-y: auto;
        overscroll-behavior: contain;
        border-top: 1px solid var(--border-color);
        border-radius: 0 0 14px 14px;
        visibility: hidden;
        opacity: 0;
        pointer-events: none;
        transform: translateY(-8px);
        transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
    }
    .nav-menu.active {
        visibility: visible;
        opacity: 1;
        pointer-events: auto;
        transform: none;
    }
    .nav-item { width: 100%; }
    .nav-menu .nav-link {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        min-height: 46px;
        border-radius: 8px;
        padding: 10px 14px;
    }
    .nav-link::after { display: none; }
    .nav-menu .nav-link:not(.nav-link-cv):not(.nav-link-contact):hover {
        background: var(--surface-hover);
    }
    .language-selector { margin-left: auto; gap: 2px; padding: 2px; }
    .lang-option { font-size: 0.82rem; padding-inline: 8px; }
    .nav-link:focus-visible,
    .mobile-brand:focus-visible {
        outline: 3px solid var(--primary-color);
        outline-offset: 3px;
    }
}

@media (max-width: 760px) {
    body { -webkit-text-size-adjust: 100%; }
    .container {
        width: 100%;
        padding-inline: max(18px, env(safe-area-inset-left)) max(18px, env(safe-area-inset-right));
    }
    .hero.hero-expanded { padding: calc(105px + env(safe-area-inset-top)) 0 3rem; }
    .hero-expanded .hero-content-expanded {
        padding-inline: max(18px, env(safe-area-inset-left)) max(18px, env(safe-area-inset-right));
        grid-template-columns: minmax(0, 1fr) clamp(62px, 20vw, 106px);
        column-gap: max(12px, 3vw);
        row-gap: 0;
        align-items: start;
    }
    .hero-expanded .hero-text { display: contents; }
    .hero-expanded .hero-kicker {
        grid-column: 1;
        grid-row: 1;
        margin-bottom: 0.5rem;
        font-size: 0.875rem;
    }
    .hero-expanded .hero-text h1 {
        grid-column: 1;
        grid-row: 2;
        max-width: min(100%, 20ch);
        margin: 0;
        font-size: clamp(1.75rem, 6.9vw, 3.2rem);
        line-height: 1.08;
        letter-spacing: -0.044em;
    }
    .hero-expanded .hero-subtitle {
        grid-column: 1 / -1;
        grid-row: 3;
        margin: 0.8rem 0 0;
        font-size: clamp(1.1rem, 4vw, 1.35rem);
        line-height: 1.45;
        overflow-wrap: normal;
    }
    .hero-expanded .hero-image {
        grid-column: 2;
        grid-row: 1 / 3;
        justify-self: stretch;
        padding: 0;
        align-self: center;
    }
    .hero-expanded .profile-img {
        border-radius: 0.65rem;
        box-shadow: 0 8px 22px #06102270;
    }
    .hero-expanded .hero-text .hero-buttons {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-column: 1 / -1;
        grid-row: 5;
        margin-top: 1.35rem;
        gap: 8px;
    }
    .hero-expanded .hero-buttons .btn {
        display: flex;
        justify-content: center;
        align-items: center;
        min-width: 0;
        padding: 12px 10px;
        min-height: 48px;
        font-size: 0.9rem;
        line-height: 1.25;
    }
    .hero-expanded .hero-buttons .hero-collaborative-link {
        grid-column: 1 / -1;
    }
    .hero-expanded .hero-description {
        grid-column: 1 / -1;
        grid-row: 4;
        margin-top: 1rem;
        font-size: 1rem;
        line-height: 1.63;
        overflow-wrap: break-word;
    }
    .hero .scroll-arrow { display: none; }

    .section-title { font-size: clamp(1.75rem, 7vw, 2.35rem); margin-bottom: 22px; }
    section[id], .internship-item[id], .project-detail[id], .project-directory { scroll-margin-top: calc(84px + env(safe-area-inset-top)); }
    .section-intro { margin-top: -8px; margin-bottom: 24px; text-align: left; }
    .timeline-section, .internships-section, .projects-carousel-section { padding-block: 48px; }
    .timeline { padding-block: 0; }
    .timeline::before { left: 5px; width: 2px; }
    .timeline-item { margin-bottom: 26px; }
    .timeline-item[data-year]::before { margin-left: 22px; font-size: 0.85rem; padding: 5px 12px; }
    .timeline-item:nth-child(odd) .timeline-content,
    .timeline-item:nth-child(even) .timeline-content {
        width: calc(100% - 22px);
        margin-left: 22px;
        padding: 18px;
        border-radius: 14px;
    }
    .timeline-item:nth-child(odd) .timeline-dot,
    .timeline-item:nth-child(even) .timeline-dot { left: -25px; width: 16px; height: 16px; }
    .timeline-content h3, .internship-content h3 { font-size: 1.12rem; }
    .timeline-content .description, .timeline-highlights, .timeline-content .timeline-result { font-size: 0.95rem; }
    .timeline-logos, .internship-logos { gap: 12px; margin-bottom: 16px; }
    .timeline-logo, .timeline-logo-small { width: 56px; height: 46px; }
    .internship-item { gap: 10px; margin-bottom: 26px; }
    .internship-date { font-size: 0.95rem; padding-left: 4px; }
    .internship-content { padding: 20px; border-radius: 14px; }
    .internship-logo { width: 72px; height: 52px; }
    .internship-tags, .project-tags { gap: 6px; }
    .tag { max-width: 100%; font-size: 0.78rem; padding: 4px 9px; line-height: 1.55; }
    .career-reveal { --career-y: 20px; }
    .career-reveal.career-reveal-from-above { --career-y: -20px; }

    /* A native scroll track replaces the overlapping desktop carousel. */
    .view-all-projects.projects-access { flex-direction: column; margin-bottom: 0.85rem; }
    .projects-access p { font-size: 0.95rem; text-align: left; }
    .projects-access .btn { width: auto; max-width: 100%; font-size: 0.9rem; padding: 11px 14px; min-height: 46px; }
    .carousel-container { perspective: none; padding: 8px 0 64px; }
    .carousel {
        height: auto;
        display: flex;
        justify-content: flex-start;
        align-items: flex-start;
        gap: 14px;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scroll-snap-type: x mandatory;
        scroll-padding-inline: 3px;
        scrollbar-width: thin;
        scrollbar-color: var(--border-strong) transparent;
        padding: 6px 3px 18px;
        -webkit-overflow-scrolling: touch;
    }
    .carousel-slide {
        position: relative;
        flex: 0 0 calc(100% - 18px);
        width: calc(100% - 18px);
        max-width: none;
        scroll-snap-align: start;
        transition: none;
    }
    .project-card, .project-card-with-company { border-radius: 16px; }
    .project-card { padding: 20px; }
    .project-company-footer { padding: 0 20px 18px; }
    .project-card h3 { font-size: 1.2rem; }
    .project-category { font-size: 0.82rem; }
    .project-description { font-size: 0.95rem; margin-bottom: 18px; }
    .project-preview { border-radius: 10px; margin-bottom: 18px; }
    .project-preview-label { font-size: 0.65rem; }
    .carousel-btn { min-height: 44px; min-width: 44px; }
    .carousel-dots { gap: 0; margin-top: 8px; }
    .carousel-dot, .carousel-dot.active {
        width: 32px;
        height: 44px;
        border-radius: 0;
        background: transparent;
        display: grid;
        place-items: center;
    }
    .carousel-dot::after { content: ''; width: 8px; height: 8px; background: var(--border-strong); border-radius: 99px; }
    .carousel-dot.active::after { width: 20px; background: var(--primary-color); }

    .projects-header, .project-hero { padding: calc(100px + env(safe-area-inset-top)) 0 32px; }
    .projects-header h1, .project-hero-content h1, .page-title {
        font-size: clamp(1.8rem, 7vw, 2.5rem);
        line-height: 1.22;
        letter-spacing: -0.025em;
        overflow-wrap: anywhere;
    }
    .projects-header .subtitle, .project-subtitle { font-size: 1rem; line-height: 1.7; }
    .project-breadcrumb { margin-bottom: 20px; }
    .project-breadcrumb a { display: inline-flex; align-items: center; min-height: 44px; }
    .project-badges { gap: 6px; margin-bottom: 18px; }
    .badge { font-size: 0.75rem; max-width: 100%; white-space: normal; padding: 5px 10px; }
    .projects-detail, .project-content { padding-block: 32px 48px; }
    .project-detail { padding: 20px; margin-bottom: 28px; border-radius: 16px; }
    .project-detail h2, .project-section h3, .content-section h2 {
        font-size: 1.35rem;
        line-height: 1.4;
        overflow-wrap: anywhere;
    }
    .content-section h3 { font-size: 1.12rem; }
    .content-section p, .content-section li, .project-section p, .project-section li { font-size: 1rem; line-height: 1.75; }
    .project-meta { font-size: 0.88rem; line-height: 1.65; }
    .content-wrapper, .project-detail, .project-section, .content-section { min-width: 0; }
    .project-scope-grid, .project-evidence-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .project-directory { padding: 18px; margin-bottom: 28px; }
    .project-directory-links { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
    .project-directory-links a { min-height: 48px; padding: 10px 12px; font-size: 0.92rem; }
    .project-method-highlight, .project-academic-result, .references { padding: 18px; }
    .project-section ul li { padding-left: 20px; }
    .project-divider { margin-block: 28px; }
    .project-video video { border-radius: 10px; max-width: 100%; }
    .project-image { margin-block: 24px; }
    .project-image-link { display: block; }
    .project-image-link::after {
        content: attr(aria-label) ' ↗';
        display: block;
        padding: 9px 12px;
        border-radius: 0 0 10px 10px;
        background: var(--surface-hover);
        color: var(--primary-dark);
        font-size: 0.8rem;
        font-weight: 600;
    }
    .project-image img { width: 100%; max-width: 100%; height: auto; border-radius: 10px; }
    .image-caption { font-size: 0.85rem; line-height: 1.65; }
    .project-link, .project-resource-list a { overflow-wrap: anywhere; line-height: 1.65; }
    .project-link { padding-block: 10px; min-height: 44px; }
    .project-table-wrapper, .project-table-scroll {
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: auto;
        scrollbar-color: var(--border-strong) var(--bg-primary);
        -webkit-overflow-scrolling: touch;
    }
    .mobile-table-hint { display: block; margin: 16px 0 8px; font-size: 0.82rem; color: var(--text-secondary); }
    .project-table-wrapper:focus-visible { outline: 3px solid var(--primary-color); outline-offset: 3px; }
    .project-table, .project-data-table { font-size: 0.88rem; line-height: 1.65; }
    .project-table th, .project-table td, .project-data-table th, .project-data-table td { padding: 12px; }
    pre { max-width: 100%; overflow-x: auto; font-size: 0.85rem; }
    .contact-page { padding: calc(100px + env(safe-area-inset-top)) 0 48px; }
    .page-title { margin-bottom: 32px; }
    .contact-content { gap: 22px; }
    .contact-card { padding: 24px 18px; }
    .contact-link { display: inline-flex; justify-content: center; padding: 12px 14px; min-height: 48px; font-size: 1rem; }
    .contact-text { font-size: 1rem; }
    .footer { padding: 28px 0 calc(24px + env(safe-area-inset-bottom)); text-align: center; }
    .footer .container { gap: 16px; }
    .footer-links { flex-direction: row; gap: 4px 20px; }
    .footer-links a { display: inline-flex; align-items: center; min-height: 44px; }
}

@media (max-width: 380px) {
    .lang-option { font-size: 0.75rem; padding-inline: 6px; }
    .navbar .container { gap: 7px; }
    .mobile-brand { font-size: 0.925rem; }
    .timeline-item:nth-child(odd) .timeline-content,
    .timeline-item:nth-child(even) .timeline-content,
    .project-detail { padding: 16px; }
    .project-card { padding: 18px; }
    .project-company-footer { padding-inline: 18px; }
}

@media (min-width: 761px) and (max-width: 1024px) {
    .hero-expanded .hero-text h1 {
        font-size: clamp(2.8rem, 5.5vw, 3.9rem);
    }
}

@media (hover: none) and (pointer: coarse) {
    .project-preview-play { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .carousel { scroll-behavior: auto; }
    .nav-menu { transition: none; }
}
