:root {
    color-scheme: light;
    --primary: #2563eb;
    --accent: #38bdf8;
    --dark: #0f172a;
    --light: #f8fafc;
    --ink: #142033;
    --muted: #64748b;
    --line: rgba(15, 23, 42, .12);
    --surface: rgba(255, 255, 255, .84);
    --surface-solid: #ffffff;
    --shadow: 0 20px 45px rgba(15, 23, 42, .11);
    --radius: 8px;
    --max: 1180px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --light: #0f172a;
    --ink: #e5edf8;
    --muted: #a6b3c5;
    --line: rgba(226, 232, 240, .14);
    --surface: rgba(15, 23, 42, .82);
    --surface-solid: #111c31;
    --shadow: 0 22px 48px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 18% 18%, rgba(56, 189, 248, .18), transparent 26rem),
        radial-gradient(circle at 82% 8%, rgba(20, 184, 166, .16), transparent 24rem),
        linear-gradient(180deg, var(--light), color-mix(in srgb, var(--light) 88%, var(--accent)));
    color: var(--ink);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
    background-size: 54px 54px;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,.36), transparent 65%);
    z-index: -2;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }

#particles {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.loader {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: var(--light);
    z-index: 20;
    transition: opacity .35s ease, visibility .35s ease;
}
.loader span {
    width: 42px;
    height: 42px;
    border: 4px solid var(--line);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
.loaded .loader { opacity: 0; visibility: hidden; }

.skip-link {
    position: absolute;
    left: 1rem;
    top: -4rem;
    background: var(--primary);
    color: white;
    padding: .7rem 1rem;
    z-index: 30;
}
.skip-link:focus { top: 1rem; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: .8rem clamp(1rem, 3vw, 2rem);
}
.navbar {
    max-width: var(--max);
    margin: 0 auto;
    min-height: 66px;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .65rem .8rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: .7rem;
    font-weight: 800;
    white-space: nowrap;
}
.brand-mark {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 8px;
    letter-spacing: 0;
}
.nav-menu {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .2rem;
}
.nav-menu a {
    padding: .65rem .85rem;
    border-radius: 8px;
    color: var(--muted);
    font-weight: 700;
    font-size: .94rem;
}
.nav-menu a:hover, .nav-menu a.active { color: var(--primary); background: rgba(37, 99, 235, .1); }
.nav-actions { display: flex; align-items: center; gap: .45rem; }

.icon-button {
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: inline-grid;
    place-items: center;
    background: var(--surface-solid);
    color: var(--ink);
}
.theme-toggle .moon { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: inline; }
.nav-toggle { display: none; }
.nav-toggle span {
    width: 18px;
    height: 2px;
    background: currentColor;
    display: block;
    margin: 2px 0;
}

.section {
    max-width: var(--max);
    margin: 0 auto;
    padding: clamp(3.5rem, 8vw, 7rem) clamp(1rem, 3vw, 2rem);
}
.hero {
    max-width: none;
    min-height: calc(100vh - 94px);
    display: grid;
    place-items: center;
    position: relative;
    overflow: hidden;
}
.hero-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, rgba(37,99,235,.2), rgba(56,189,248,.13), rgba(20,184,166,.16));
    background-size: 240% 240%;
    animation: gradientMove 10s ease infinite;
}
.hero-bg::before,
.hero-bg::after {
    content: "";
    position: absolute;
    width: 23rem;
    aspect-ratio: 1;
    border-radius: 50%;
    filter: blur(8px);
    opacity: .34;
    animation: float 8s ease-in-out infinite;
}
.hero-bg::before { left: 7vw; top: 12vh; background: var(--primary); }
.hero-bg::after { right: 7vw; bottom: 12vh; background: var(--accent); animation-delay: -3s; }
.hero-content {
    width: min(var(--max), calc(100% - 2rem));
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(280px, .72fr);
    gap: clamp(2rem, 5vw, 5rem);
    align-items: center;
    position: relative;
    z-index: 1;
    padding: 3rem 0 5rem;
}
.hero-copy {
    padding: clamp(1.2rem, 3vw, 2.2rem);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
}
.eyebrow {
    margin: 0 0 .8rem;
    color: var(--primary);
    text-transform: uppercase;
    font-size: .78rem;
    font-weight: 900;
    letter-spacing: .14em;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
    font-size: clamp(3.1rem, 8vw, 6.6rem);
    line-height: .95;
    margin-bottom: 1.1rem;
    letter-spacing: 0;
}
h2 { font-size: clamp(2rem, 4vw, 3.7rem); line-height: 1.04; letter-spacing: 0; }
h3 { font-size: 1.15rem; }
p { color: var(--muted); line-height: 1.75; }
.hero-role {
    font-size: clamp(1.25rem, 2vw, 1.6rem);
    font-weight: 800;
    color: var(--ink);
}
.typing {
    color: var(--primary);
    border-right: 3px solid var(--accent);
    padding-right: .2rem;
    animation: caret 1s steps(1) infinite;
}
.hero-summary { max-width: 66ch; font-size: 1.06rem; }
.hero-actions, .social-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .8rem;
}
.hero-actions { margin: 1.8rem 0 1rem; }
.button {
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .82rem 1.1rem;
    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--primary);
    color: white;
    font-weight: 900;
    box-shadow: 0 14px 26px rgba(37, 99, 235, .22);
    transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}
.button:hover { transform: translateY(-2px); box-shadow: 0 18px 32px rgba(37, 99, 235, .28); }
.button-secondary { background: var(--ink); color: var(--light); box-shadow: none; }
.button-ghost { background: transparent; color: var(--primary); border-color: currentColor; box-shadow: none; }
.button-small { min-height: 40px; padding: .62rem .9rem; font-size: .9rem; }
.social-row a, .section-head a {
    color: var(--primary);
    font-weight: 800;
}
.profile-shell { position: relative; }
.profile-shell img {
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    animation: float 7s ease-in-out infinite;
}
.floating-card {
    position: absolute;
    padding: .75rem .9rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
    font-weight: 900;
}
.floating-card.top { top: 8%; right: -8%; }
.floating-card.bottom { left: -9%; bottom: 11%; }
.scroll-indicator {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    width: 30px;
    height: 48px;
    border: 2px solid var(--muted);
    border-radius: 999px;
    z-index: 1;
}
.scroll-indicator span {
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    position: absolute;
    left: 50%;
    top: 9px;
    transform: translateX(-50%);
    animation: scrollDot 1.5s infinite;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}
.stat-card, .skill-card, .project-card, .education-card, .publication-card, .contact-card, .placeholder-panel, .timeline-content, details {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.stat-card {
    min-height: 130px;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 1.2rem;
}
.stat-card strong { font-size: 2.6rem; color: var(--primary); }
.stat-card span { color: var(--muted); font-weight: 800; }
.split-section {
    display: grid;
    grid-template-columns: .45fr 1fr;
    gap: 2rem;
    align-items: start;
}
.section-kicker {
    color: var(--primary);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .14em;
}
.section-copy p { font-size: 1.1rem; }
.section-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.section-head h2 { margin-bottom: 0; }
.skills-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}
.skill-card, .project-card, .education-card, .placeholder-panel {
    padding: 1.25rem;
    transition: transform .22s ease, border-color .22s ease;
}
.skill-card:hover, .project-card:hover, .education-card:hover { transform: translateY(-6px); border-color: color-mix(in srgb, var(--primary) 55%, var(--line)); }
.education-card span {
    color: var(--primary);
    font-weight: 900;
    font-size: .9rem;
}
.skill-tags, .tech-list, .badge-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: .55rem;
}
.skill-tags span, .tech-list span, .badge-cloud span {
    position: relative;
    overflow: hidden;
    padding: .48rem .65rem;
    border-radius: 8px;
    background: rgba(37, 99, 235, .1);
    color: var(--ink);
    font-weight: 800;
    font-size: .88rem;
}
.skill-tags span::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: var(--level);
    background: linear-gradient(90deg, var(--primary), var(--accent));
}
.project-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}
.project-grid.compact { grid-template-columns: repeat(3, 1fr); }
.project-card {
    min-height: 292px;
    display: flex;
    flex-direction: column;
    gap: .7rem;
}
.project-card p { flex: 1; }
.project-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    font-weight: 900;
}
.testimonial-band {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}
.testimonial-band h2 { max-width: 850px; margin-bottom: 0; }

.page-hero {
    padding-top: clamp(4rem, 8vw, 6rem);
    padding-bottom: clamp(2rem, 5vw, 4rem);
}
.page-hero p { max-width: 780px; font-size: 1.12rem; }
.centered { text-align: center; display: grid; justify-items: center; }
.about-layout, .contact-layout, .extras-grid {
    display: grid;
    grid-template-columns: .8fr 1.2fr;
    gap: 1.2rem;
    align-items: start;
}
.profile-panel, .publication-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 1.4rem;
}
.profile-panel img { border-radius: var(--radius); margin-bottom: 1rem; }
.center { justify-content: center; }
.about-copy {
    padding: 1rem 0 0 1rem;
}
.education-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.timeline {
    position: relative;
    display: grid;
    gap: 1.2rem;
}
.timeline::before {
    content: "";
    position: absolute;
    left: 1.08rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(var(--primary), var(--accent));
}
.timeline-item {
    position: relative;
    display: grid;
    grid-template-columns: 2.4rem 1fr;
    gap: 1rem;
}
.timeline-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    border: 4px solid var(--surface-solid);
    margin-top: 1.4rem;
    z-index: 1;
}
.timeline-content { padding: 1.3rem; }
.timeline-content span { color: var(--primary); font-weight: 900; }
.timeline-content h2 { font-size: 1.6rem; margin: .4rem 0 .2rem; }
.timeline-content h3 { color: var(--muted); margin-bottom: 1rem; }
.timeline-content li { margin-bottom: .55rem; line-height: 1.6; }
.cert-section .large span { font-size: 1rem; padding: .7rem .9rem; }

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .65rem;
    margin-bottom: 1.3rem;
}
.filter-bar button {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: .6rem .9rem;
    background: var(--surface-solid);
    color: var(--ink);
    font-weight: 900;
}
.filter-bar button.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}
.heatmap {
    display: grid;
    grid-template-columns: repeat(14, 1fr);
    gap: .35rem;
    margin-top: 1rem;
}
.heatmap span {
    aspect-ratio: 1;
    border-radius: 3px;
    background: color-mix(in srgb, var(--primary) var(--shade), rgba(37, 99, 235, .1));
}

.contact-card { padding: 1.4rem; }
.contact-actions {
    display: grid;
    align-content: start;
    gap: 1rem;
}
.command-input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-solid);
    color: var(--ink);
    padding: .86rem .95rem;
}
.alert {
    padding: .9rem 1rem;
    border-radius: 8px;
    font-weight: 800;
}
.alert.success { color: #065f46; background: #d1fae5; }
.alert.error { color: #991b1b; background: #fee2e2; }
.faq {
    display: grid;
    gap: .8rem;
}
details { padding: 1rem 1.2rem; }
summary { cursor: pointer; font-weight: 900; }

.footer {
    padding: 2rem clamp(1rem, 3vw, 2rem);
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface-solid) 78%, transparent);
}
.footer-inner {
    max-width: var(--max);
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    align-items: center;
}
.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: .9rem;
    font-weight: 900;
    color: var(--primary);
}
.copyright { grid-column: 1 / -1; margin: 0; font-size: .9rem; }
.back-to-top {
    position: fixed;
    right: 1.2rem;
    bottom: 1.2rem;
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: .2s ease;
    z-index: 8;
}
.back-to-top.show { opacity: 1; transform: translateY(0); pointer-events: auto; }

.command-palette {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: start center;
    padding-top: 12vh;
    background: rgba(15, 23, 42, .48);
}
.command-palette[hidden],
[hidden] {
    display: none !important;
}
.command-dialog {
    width: min(620px, calc(100% - 2rem));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-solid);
    box-shadow: var(--shadow);
    padding: 1rem;
}
.command-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: .8rem;
}
.command-head h2 { font-size: 1.2rem; margin: 0; }
.command-list {
    display: grid;
    gap: .35rem;
    margin-top: .8rem;
}
.command-list a {
    padding: .75rem .8rem;
    border-radius: 8px;
    font-weight: 800;
}
.command-list a:hover { background: rgba(37, 99, 235, .1); color: var(--primary); }

.reveal {
    opacity: 0;
    transform: translateY(22px);
    transition: opacity .65s ease, transform .65s ease;
}
.reveal.visible { opacity: 1; transform: translateY(0); }
.delay-1 { transition-delay: .12s; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes gradientMove {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-16px); }
}
@keyframes caret {
    50% { border-color: transparent; }
}
@keyframes scrollDot {
    0% { opacity: 0; transform: translate(-50%, 0); }
    50% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, 20px); }
}

@media (max-width: 980px) {
    .hero-content, .about-layout, .contact-layout, .split-section, .extras-grid { grid-template-columns: 1fr; }
    .skills-grid, .project-grid, .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .floating-card.top { right: .5rem; }
    .floating-card.bottom { left: .5rem; }
    .about-copy { padding-left: 0; }
}

@media (max-width: 760px) {
    .site-header { padding: .55rem; }
    .navbar { flex-wrap: wrap; }
    .nav-toggle { display: inline-grid; margin-left: auto; }
    .nav-menu {
        order: 4;
        width: 100%;
        display: none;
        flex-direction: column;
        align-items: stretch;
        margin-left: 0;
    }
    .nav-menu.open { display: flex; }
    .nav-actions { margin-left: 0; }
    .command-trigger { display: none; }
    .hero { min-height: auto; }
    .hero-content { grid-template-columns: 1fr; padding-top: 1rem; }
    .hero-copy { padding: 1rem; }
    h1 { font-size: clamp(2.7rem, 16vw, 4rem); }
    h2 { font-size: clamp(1.9rem, 9vw, 2.7rem); }
    .skills-grid, .project-grid, .project-grid.compact, .stats-grid, .education-grid { grid-template-columns: 1fr; }
    .section-head, .testimonial-band, .footer-inner { align-items: start; flex-direction: column; grid-template-columns: 1fr; }
    .timeline::before { left: .7rem; }
    .timeline-item { grid-template-columns: 1.7rem 1fr; }
    .timeline-dot { width: 16px; height: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}
