* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #080809;
    color: #e8e8ea;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

body.detail-open {
    overflow: hidden;
}

nav {
    background-color: rgba(12, 12, 14, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: max(1rem, env(safe-area-inset-top)) max(1.5rem, env(safe-area-inset-right)) 1rem max(1.5rem, env(safe-area-inset-left));
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.nav-container {
    max-width: 1120px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: #fafafa;
    letter-spacing: -0.02em;
}

.nav-center {
    display: flex;
    gap: 1.75rem;
    align-items: center;
}

.nav-item {
    position: relative;
}

.nav-link {
    color: #b4b4b8;
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s;
    cursor: pointer;
    padding: 0.45rem 0;
    display: block;
}

.nav-link:hover {
    color: #8ec5ff;
}

.dropdown {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #141416;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 0.35rem 0;
    min-width: 240px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    margin-top: 0.45rem;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.nav-item:hover .dropdown {
    opacity: 1;
    visibility: visible;
}

.dropdown-item {
    padding: 0.65rem 1.1rem;
    color: #c4c4c8;
    text-decoration: none;
    display: block;
    transition: background-color 0.15s, color 0.15s;
    cursor: pointer;
    font-size: 0.875rem;
    line-height: 1.4;
}

.dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #9ecfff;
}

.linkedin-icon {
    color: #b4b4b8;
    font-size: 1.15rem;
    font-weight: 700;
    text-decoration: none;
    transition: color 0.2s;
}

.linkedin-icon:hover {
    color: #0a66c2;
}

main {
    margin-top: 72px;
    min-height: calc(100vh - 140px);
}

.container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 max(1.5rem, env(safe-area-inset-right)) 0 max(1.5rem, env(safe-area-inset-left));
}

/* Home: split hero */
.home-hero-split {
    max-width: 1120px;
    margin: 0 auto;
    min-height: calc(100vh - 72px - 4rem);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: clamp(2rem, 5vw, 4rem);
    align-items: center;
    padding:
        clamp(2rem, 5vw, 4rem)
        max(1.25rem, env(safe-area-inset-right))
        max(2rem, env(safe-area-inset-bottom))
        max(1.25rem, env(safe-area-inset-left));
    scroll-margin-top: 80px;
}

.home-hero-left {
    padding-right: clamp(0.5rem, 3vw, 2rem);
    min-width: 0;
}

.home-hero-heading {
    font-size: clamp(2.75rem, 8vw, 4.75rem);
    font-weight: 700;
    color: #f4f4f6;
    letter-spacing: -0.04em;
    line-height: 1.05;
    margin-bottom: 1rem;
}

.home-hero-accent {
    color: #9ecfff;
    display: inline-block;
}

.home-hero-tagline {
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    color: #8a8a94;
    line-height: 1.65;
    max-width: 28ch;
    margin-bottom: 0;
}

.home-hero-cmu {
    color: #9ecfff;
    font-weight: 600;
}

/* Three meshed gears (below tagline) */
.home-hero-gear-train-wrap {
    margin-top: 1.35rem;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
}

.home-hero-gear-train {
    width: min(100%, 240px);
    max-width: 100%;
    touch-action: none;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    border-radius: 12px;
}

.home-hero-gear-train.is-dragging {
    cursor: grabbing;
}

.home-hero-gear-train:focus {
    outline: none;
}

.home-hero-gear-train:focus-visible {
    outline: 2px solid rgba(142, 197, 255, 0.75);
    outline-offset: 4px;
}

.home-hero-gear-svg {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 106 / 63;
    overflow: visible;
}

.home-hero-gear-train.home-hero-gear-train--reduced {
    cursor: default;
    touch-action: manipulation;
}

.home-hero-gear-hint {
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: #6e6e78;
    margin: 0;
    line-height: 1.4;
    max-width: 32ch;
}

@media (hover: none) {
    .home-hero-gear-hint {
        color: #6e6e78;
    }
}

@media (prefers-reduced-motion: reduce) {
    .home-hero-gear-train {
        cursor: default;
        touch-action: manipulation;
    }

    .home-hero-gear-hint {
        display: none;
    }
}

.home-hero-right {
    display: flex;
    flex-direction: column;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    padding-left: clamp(1.5rem, 4vw, 3rem);
    scroll-margin-top: 88px;
}

.home-about-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #6e6e78;
    margin-bottom: 1rem;
}

.home-about-text {
    font-size: 1.05rem;
    color: #a4a4ae;
    line-height: 1.85;
    margin-bottom: 1.75rem;
}

.home-hero-right .btn-see-projects {
    align-self: flex-start;
}

.btn-see-projects {
    appearance: none;
    border: none;
    background: linear-gradient(180deg, rgba(142, 197, 255, 0.22) 0%, rgba(100, 150, 210, 0.14) 100%);
    color: #e8f2ff;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.7rem 1.5rem;
    border-radius: 999px;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 0 0 1px rgba(142, 197, 255, 0.35), 0 4px 20px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn-see-projects:hover {
    background: linear-gradient(180deg, rgba(158, 207, 255, 0.3) 0%, rgba(120, 170, 230, 0.2) 100%);
    box-shadow: 0 0 0 1px rgba(158, 207, 255, 0.5), 0 6px 28px rgba(0, 0, 0, 0.3);
    transform: translateY(-1px);
}

.btn-see-projects:focus-visible {
    outline: 2px solid #8ec5ff;
    outline-offset: 3px;
}

/* Projects page */
.projects-page {
    padding: 2.5rem 0 4.5rem;
}

.projects-page-header {
    text-align: center;
    margin-bottom: 2.75rem;
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
}

.projects-page-title {
    font-size: clamp(1.75rem, 3vw, 2.25rem);
    font-weight: 600;
    color: #fafafa;
    letter-spacing: -0.03em;
    margin-bottom: 0.5rem;
}

.projects-page-subtitle {
    font-size: 0.95rem;
    color: #7a7a84;
    line-height: 1.55;
}

.project-grid {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.project-card {
    display: grid;
    grid-template-columns: minmax(0, 280px) 1fr;
    gap: 0;
    background: linear-gradient(145deg, #121214 0%, #0e0e10 100%);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    overflow: hidden;
    scroll-margin-top: 88px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.project-card:hover {
    border-color: rgba(142, 197, 255, 0.15);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.35);
}

.project-card-visual {
    position: relative;
    min-height: 180px;
    background: #0a0a0c;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.project-thumb {
    width: 100%;
    height: 100%;
    min-height: 180px;
    object-fit: cover;
    display: block;
}

.project-card-visual--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #1a1a22 0%, #0e0e12 100%);
}

.project-card-placeholder-label {
    font-size: 1.5rem;
    font-weight: 700;
    color: rgba(142, 197, 255, 0.35);
    letter-spacing: 0.08em;
}

.project-card-body {
    padding: 1.35rem 1.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.65rem;
}

.project-card-tags {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.5rem;
}

.project-tag {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.28rem 0.55rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: #b8b8c0;
}

.project-tag[data-tag="cad"] {
    border-color: rgba(142, 197, 255, 0.35);
    color: #b8d9ff;
}

.project-tag[data-tag="manufacturing"] {
    border-color: rgba(180, 220, 160, 0.35);
    color: #c5e0b8;
}

.project-tag[data-tag="programming"] {
    border-color: rgba(200, 170, 255, 0.35);
    color: #d4c4f7;
}

.project-tag[data-tag="circuit-design"] {
    border-color: rgba(255, 200, 140, 0.35);
    color: #ffd4a8;
}

.project-card-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: #f4f4f6;
    line-height: 1.35;
    letter-spacing: -0.02em;
}

.project-teaser {
    font-size: 0.95rem;
    color: #9898a2;
    line-height: 1.65;
    flex: 1;
}

.btn-view-project {
    appearance: none;
    border: 1px solid rgba(142, 197, 255, 0.45);
    background: rgba(142, 197, 255, 0.08);
    color: #b8d9ff;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.55rem 1.15rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    font-family: inherit;
}

.btn-view-project:hover {
    background: rgba(142, 197, 255, 0.16);
    border-color: rgba(158, 207, 255, 0.65);
    color: #dceeff;
}

.btn-view-project:focus-visible {
    outline: 2px solid #8ec5ff;
    outline-offset: 2px;
}

/* Project detail: centered modal, fade + scale (no side slide) */
.project-detail-overlay {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right)) max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.28s ease;
}

.project-detail-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

.project-detail-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 4, 6, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    cursor: pointer;
}

.project-detail-panel {
    position: relative;
    z-index: 1;
    width: min(72vw, calc(100vw - 2rem));
    max-height: min(92vh, 52rem);
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #0e0e12;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 18px;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.35),
        0 24px 80px rgba(0, 0, 0, 0.55);
    opacity: 0;
    transform: scale(0.94) translateY(16px);
    transition:
        opacity 0.3s ease,
        transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

.project-detail-overlay.is-open .project-detail-panel {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.project-detail-toolbar {
    flex-shrink: 0;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.project-detail-close {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: none;
    background: transparent;
    color: #9ecfff;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.4rem 0.5rem;
    border-radius: 8px;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}

.project-detail-close:hover {
    background: rgba(142, 197, 255, 0.1);
    color: #c8e4ff;
}

.project-detail-close:focus-visible {
    outline: 2px solid #8ec5ff;
    outline-offset: 2px;
}

.project-detail-close-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.project-detail-titlebar {
    flex-shrink: 0;
    padding: 0.35rem 1.35rem 1.15rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: linear-gradient(180deg, rgba(20, 20, 26, 0.95) 0%, #0e0e12 100%);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.project-detail-tag-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.5rem;
}

.project-detail-tag-list:empty {
    display: none;
}

.project-detail-main-title {
    font-size: clamp(1.2rem, 3.2vw, 1.55rem);
    font-weight: 600;
    color: #fafafa;
    letter-spacing: -0.03em;
    line-height: 1.28;
}

.project-detail-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1.35rem 1.35rem 1.75rem;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

.project-detail-carousel-root:not([hidden]) {
    flex-shrink: 0;
}

.detail-photo-carousel-heading {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.11em;
    color: #6e6e78;
    margin-bottom: 0.75rem;
}

.detail-photo-carousel-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    max-height: min(50vh, 420px);
    border-radius: 14px;
    overflow: hidden;
    background: #08080a;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.detail-photo-carousel-track {
    position: absolute;
    inset: 0;
}

.detail-photo-carousel-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

.detail-photo-carousel-slide.show {
    opacity: 1;
    pointer-events: auto;
    z-index: 1;
}

.detail-photo-carousel-slide img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.detail-photo-carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 18;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(22, 22, 28, 0.92);
    color: #ececee;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.detail-photo-carousel-arrow:hover {
    background: rgba(40, 40, 48, 0.95);
    color: #9ecfff;
}

.detail-photo-carousel-arrow.left {
    left: 10px;
}

.detail-photo-carousel-arrow.right {
    right: 10px;
}

.detail-photo-carousel-arrow.hidden {
    display: none;
}

.detail-photo-carousel-caption-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 14;
    padding: 2.25rem 1rem 0.85rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.88));
    pointer-events: none;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.28s ease, transform 0.28s ease;
}

.detail-photo-carousel-caption-overlay.is-hovering,
.detail-photo-carousel-caption-overlay.is-coarse-active {
    opacity: 1;
    transform: translateY(0);
}

.detail-photo-carousel-blurb {
    font-size: 0.88rem;
    line-height: 1.5;
    color: #e4e4ea;
    margin: 0;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
}

.project-detail-flow {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.project-detail-flow.prose p {
    font-size: 1rem;
    color: #a8a8b0;
    line-height: 1.8;
    margin: 0;
}

.detail-figure {
    margin: 0;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: #08080a;
}

.detail-figure img {
    width: 100%;
    height: auto;
    display: block;
}

.detail-figure figcaption {
    padding: 0.65rem 1rem 0.85rem;
    font-size: 0.875rem;
    color: #8c8c96;
    line-height: 1.5;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

@media (prefers-reduced-motion: reduce) {
    .project-detail-overlay {
        transition: opacity 0.15s ease;
    }

    .project-detail-panel {
        transition: opacity 0.2s ease;
        transform: none;
    }

    .project-detail-overlay.is-open .project-detail-panel {
        transform: none;
    }
}

.page {
    display: none;
}

.page.active {
    display: block;
}

@media (max-width: 720px) {
    main {
        margin-top: clamp(100px, 28vw, 132px);
    }

    .nav-container {
        flex-direction: column;
        gap: 0.85rem;
    }

    .nav-name {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .nav-center {
        gap: 1.25rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    .nav-link {
        padding: 0.55rem 0.35rem;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .linkedin-icon {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .home-hero-split {
        grid-template-columns: 1fr;
        min-height: 0;
        padding-top: max(1.5rem, env(safe-area-inset-top));
        gap: 2.25rem;
    }

    .home-hero-left {
        padding-right: 0;
        text-align: left;
        min-width: 0;
    }

    .home-hero-tagline {
        max-width: none;
    }

    .home-hero-gear-train-wrap {
        align-items: center;
        width: 100%;
    }

    .home-hero-gear-train {
        width: 100%;
    }

    .home-hero-gear-hint {
        text-align: center;
        max-width: none;
    }

    .home-hero-right {
        border-left: none;
        padding-left: 0;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        padding-top: 2rem;
        min-width: 0;
    }

    .project-card {
        grid-template-columns: 1fr;
    }

    .project-card-visual {
        min-height: 200px;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .project-thumb {
        min-height: 200px;
        max-height: 220px;
    }
}
