:root {
    --primary:     #0f172a;
    --accent:      #4f46e5;
    --bg:          #f8fafc;
    --card-bg:     #ffffff;
    --text:        #334155;
    --text-light:  #64748b;
    --border:      #e2e8f0;
    --accent-light: #eef2ff;
    --accent-mid:   #6366f1;
    --accent-dark:  #4338ca;
    --primary-soft: #1e293b;
    --section-alt-bg: #f1f5f9;
    --badge-ai-bg: #eef2ff; --badge-ai-text: #3730a3; --badge-ai-border: #c7d2fe;
    --badge-lang-bg: #f0fdf4; --badge-lang-text: #166534; --badge-lang-border: #bbf7d0;
    --badge-web-bg: #faf5ff; --badge-web-text: #6b21a8; --badge-web-border: #e9d5ff;
    --badge-tools-bg: #fff7ed; --badge-tools-text: #92400e; --badge-tools-border: #fed7aa;
    --shadow-sm: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
    --shadow-md: 0 4px 12px rgba(15,23,42,.08), 0 2px 6px rgba(15,23,42,.05);
    --shadow-lg: 0 12px 28px rgba(15,23,42,.12), 0 4px 10px rgba(15,23,42,.07);
    --shadow-glow: 0 0 0 3px rgba(99,102,241,.2);
    --radius-sm: 6px; --radius-md: 10px; --radius-lg: 14px;
    --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Top accent bar */
html { border-top: 3px solid var(--accent); }

* { margin: 0; padding: 0; box-sizing: border-box; }

/* ── Selection ───────────────────────────────────────── */
::selection { background: rgba(99,102,241,.18); color: var(--primary); }

/* ── Custom scrollbar ────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Reading progress bar ────────────────────────────── */
#reading-progress {
    position: fixed;
    top: 0; left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-mid) 60%, #818cf8 100%);
    z-index: 101;
    transition: width 0.1s linear;
    pointer-events: none;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1, h2, h3 { font-family: 'Inter', sans-serif; color: var(--primary); letter-spacing: -0.02em; }

a { text-decoration: none; color: inherit; transition: color var(--transition); }
a:hover { color: var(--accent); }

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

.container { max-width: 1000px; margin: 0 auto; padding: 0 20px; }

/* ── Header ─────────────────────────────────────────── */
header {
    background: rgba(255,255,255,.82);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid rgba(226,232,240,.7);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: .75rem 0;
    transition: box-shadow var(--transition), background var(--transition);
}
header.scrolled { box-shadow: var(--shadow-md); background: rgba(255,255,255,.95); }

nav { display: flex; justify-content: space-between; align-items: center; }

.logo { font-weight: 700; font-size: 1.05rem; color: var(--primary); letter-spacing: -0.01em; }

.nav-links { display: flex; gap: 18px; }
.nav-links a {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-light);
    position: relative;
    padding-bottom: 2px;
    transition: color var(--transition);
}
.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -2px; left: 0;
    width: 0; height: 2px;
    background: var(--accent);
    border-radius: 1px;
    transition: width var(--transition);
}
.nav-links a:hover, .nav-links a.active { color: var(--primary); }
.nav-links a:hover::after, .nav-links a.active::after { width: 100%; }

/* ── Hero ────────────────────────────────────────────── */
.hero {
    padding: 60px 0 50px;
    display: flex;
    align-items: center;
    gap: 50px;
    position: relative;
    scroll-margin-top: 70px;
}
.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, #c7d2fe 1px, transparent 1px);
    background-size: 26px 26px;
    opacity: 0.45;
    pointer-events: none;
    z-index: 0;
}
.hero-content { flex: 2; position: relative; z-index: 1; }
.hero-img-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 200px; height: 200px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0; flex-grow: 0;
    position: relative; z-index: 1;
    box-shadow:
        0 0 0 4px var(--card-bg),
        0 0 0 7px var(--accent),
        0 0 0 11px rgba(37,99,235,.15),
        var(--shadow-lg);
    transition: box-shadow var(--transition);
}
.hero-img-container:hover {
    box-shadow:
        0 0 0 4px var(--card-bg),
        0 0 0 7px var(--accent-mid),
        0 0 0 12px rgba(37,99,235,.25),
        var(--shadow-lg);
}
.hero-img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.4) translateX(12px); transform-origin: center; }

.hero h1 {
    font-size: 2.4rem;
    font-weight: 700;
    margin-bottom: 7px;
    letter-spacing: -0.03em;
    line-height: 1.15;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-soft) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero .subtitle {
    font-size: 0.95rem;
    color: var(--accent);
    margin-bottom: 18px;
    font-weight: 500;
    letter-spacing: 0.01em;
    display: flex;
    align-items: center;
    gap: 8px;
}
.hero .subtitle::before {
    content: '';
    display: inline-block;
    width: 22px; height: 2px;
    background: var(--accent);
    border-radius: 1px;
    flex-shrink: 0;
}
.hero p { color: var(--text-light); margin-bottom: 0; font-size: 0.925rem; line-height: 1.7; }
.hero-content > p + p { margin-top: 10px; }
.hero-content > p:last-of-type { margin-bottom: 20px; }
.hero .institution { font-weight: 600; color: var(--primary); }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-soft) 100%);
    color: white;
    padding: 9px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.875rem;
    letter-spacing: 0.01em;
    margin-right: 8px;
    box-shadow: var(--shadow-sm);
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition), color var(--transition);
    white-space: nowrap;
}
.btn:hover { background: linear-gradient(135deg, var(--accent-dark) 0%, var(--accent) 100%); color: white; transform: translateY(-2px); box-shadow: var(--shadow-md), var(--shadow-glow); }
.btn:active { transform: translateY(0); box-shadow: var(--shadow-sm); }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--primary); box-shadow: none; }
.btn-outline:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent-dark); box-shadow: var(--shadow-glow); transform: translateY(-2px); }

.social-links { margin-top: 18px; }
.social-links a {
    font-size: 1.1rem;
    margin-right: 4px;
    color: var(--text-light);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    border-radius: 50%;
    border: 1px solid transparent;
    transition: color var(--transition), background var(--transition), border-color var(--transition), transform var(--transition);
}
.social-links a:hover { color: var(--accent); background: var(--accent-light); border-color: rgba(37,99,235,.25); transform: translateY(-2px); }

/* ── Sections ────────────────────────────────────────── */
section { padding: 48px 0; scroll-margin-top: 70px; }

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 26px;
    position: relative;
    padding-bottom: 12px;
    letter-spacing: -0.025em;
}
.section-title::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0;
    width: 36px; height: 3px;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-mid) 100%);
    border-radius: 2px;
    transition: width 0.4s ease;
}
.section-title.in-view::after { width: 52px; }

/* ── Cards ───────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    padding: 20px 22px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: #cbd5e1; }

/* Force two columns in grids */
.container .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 768px) { .container .grid { grid-template-columns: 1fr; } }

.date-badge {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-light);
    margin-bottom: 5px;
    display: inline-block;
    font-weight: 500;
    background: var(--section-alt-bg);
    padding: 2px 7px;
    border-radius: 3px;
}
.card-title { font-size: 1rem; font-weight: 700; margin-bottom: 3px; color: var(--primary); letter-spacing: -0.01em; line-height: 1.3; }
.card-subtitle { color: var(--accent); font-weight: 500; margin-bottom: 8px; font-size: 0.875rem; }

/* ── Publications ────────────────────────────────────── */
.pub-item {
    border-left: 3px solid var(--accent);
    padding: 14px 18px;
    margin-bottom: 16px;
    background: var(--card-bg);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    box-shadow: var(--shadow-sm);
    transition: border-left-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.pub-item:hover { border-left-color: var(--accent-dark); box-shadow: var(--shadow-md); transform: translateX(3px); }
.pub-title { font-family: 'Merriweather', serif; font-size: 0.95rem; font-weight: 700; color: var(--primary); margin-bottom: 6px; line-height: 1.5; }
.pub-title a { color: var(--primary); transition: color var(--transition); }
.pub-title a:hover { color: var(--accent); }
.pub-authors { font-size: 0.85rem; color: var(--text-light); margin-bottom: 5px; line-height: 1.5; }
.pub-venue { font-size: 0.85rem; color: var(--text); display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }

#publications > div > h3 { padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
#publications > div:last-child { background: linear-gradient(135deg, var(--accent-light) 0%, #f8fafc 100%) !important; border-radius: var(--radius-sm); }

/* ── Tags ────────────────────────────────────────────── */
.tag {
    display: inline-block;
    background: var(--accent-light);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid rgba(37,99,235,.2);
}
.tag.preprint { background: #f1f5f9; color: var(--text-light); border-color: var(--border); }

/* ── Grid & Badges ───────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.tech-stack { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.tech-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 9px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    letter-spacing: 0.02em;
    transition: transform .15s ease, box-shadow .15s ease;
}
.tech-badge:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,.08); }

/* ── Skills section card wrappers ────────────────────── */
#skills .grid > div {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px 16px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), transform var(--transition);
}
#skills .grid > div:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
#skills .grid > div:nth-child(1) .tech-badge { background: var(--badge-ai-bg);    color: var(--badge-ai-text);    border-color: var(--badge-ai-border); }
#skills .grid > div:nth-child(2) .tech-badge { background: var(--badge-lang-bg);  color: var(--badge-lang-text);  border-color: var(--badge-lang-border); }
#skills .grid > div:nth-child(3) .tech-badge { background: var(--badge-web-bg);   color: var(--badge-web-text);   border-color: var(--badge-web-border); }
#skills .grid > div:nth-child(4) .tech-badge { background: var(--badge-tools-bg); color: var(--badge-tools-text); border-color: var(--badge-tools-border); }

/* ── Section alternation ─────────────────────────────── */
#education, #service {
    background: linear-gradient(180deg, var(--section-alt-bg) 0%, #fff 100%) !important;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
#skills { background: linear-gradient(180deg, #fff 0%, var(--bg) 100%); border-top: 1px solid var(--border); }
#projects .card:first-of-type { border-radius: var(--radius-lg); padding: 24px 26px; }

/* ── Workshop Card Layout ────────────────────────────── */
.workshop-card-inner {
    display: flex;
    gap: 20px;
    align-items: stretch;
}
.workshop-card-content {
    flex: 1;
    min-width: 0;
}

/* ── Carousel ────────────────────────────────────────── */
.workshop-carousel {
    width: 230px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.carousel-track {
    position: relative;
    width: 100%;
    height: 160px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #0f172a;
    border: 1px solid var(--border);
    cursor: zoom-in;
}
.carousel-slide {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.55s ease;
    pointer-events: none;
}
.carousel-slide.active { opacity: 1; }
.carousel-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
}
.carousel-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--border);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition), width var(--transition);
    flex-shrink: 0;
}
.carousel-dot.active {
    background: var(--accent);
    width: 18px;
    border-radius: 4px;
    transform: none;
}
.carousel-dot:not(.active):hover { background: #94a3b8; transform: scale(1.2); }

/* gallery-img used only as lightbox hook — no standalone layout styles */
.gallery-img { cursor: zoom-in; }

@media (max-width: 700px) {
    .workshop-card-inner { flex-direction: column; }
    .workshop-carousel { width: 100%; }
    .carousel-track { height: 200px; }
}

/* ── Lightbox ─────────────────────────────────────────── */
#img-lightbox {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
    cursor: pointer;
}
#img-lightbox.open {
    opacity: 1;
    pointer-events: auto;
}
#lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
#lightbox-img {
    position: relative;
    z-index: 1;
    max-width: min(90vw, 560px);
    max-height: min(80vh, 480px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: 0 24px 64px rgba(15,23,42,.55), 0 4px 16px rgba(15,23,42,.3);
    transform: scale(0.88);
    transition: transform 0.28s cubic-bezier(0.34, 1.46, 0.64, 1);
    cursor: pointer;
}
#img-lightbox.open #lightbox-img {
    transform: scale(1);
}
#lightbox-close {
    position: absolute;
    top: 18px; right: 22px;
    z-index: 2;
    background: rgba(255,255,255,.13);
    border: 1px solid rgba(255,255,255,.22);
    color: #fff;
    width: 34px; height: 34px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.15rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    transition: background var(--transition), transform var(--transition);
}
#lightbox-close:hover { background: rgba(255,255,255,.26); transform: scale(1.12); }

/* ── Scroll fade-in ──────────────────────────────────── */
.section-fade { opacity: 0; transform: translateY(20px); transition: opacity .45s ease, transform .45s ease; }
.section-fade.visible { opacity: 1; transform: translateY(0); }
.card.section-fade { transition-timing-function: cubic-bezier(0.22, 1, 0.36, 1); }

/* ── Footer ──────────────────────────────────────────── */
footer {
    text-align: center;
    padding: 48px 0 32px;
    background: linear-gradient(180deg, var(--bg) 0%, var(--section-alt-bg) 100%);
    border-top: 1px solid var(--border);
}
footer a[style*="background: white"] {
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-sm) !important;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition) !important;
}
footer a[style*="background: white"]:hover {
    transform: translateY(-3px) !important;
    box-shadow: var(--shadow-md) !important;
    border-color: var(--accent) !important;
    color: var(--accent) !important;
}

/* ── Scroll-to-top ───────────────────────────────────── */
#scroll-top {
    position: fixed;
    bottom: 24px; right: 24px;
    width: 40px; height: 40px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity var(--transition), transform var(--transition), background var(--transition), box-shadow var(--transition);
    z-index: 200;
    pointer-events: none;
}
#scroll-top.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
#scroll-top:hover { background: var(--accent-dark); transform: translateY(-2px); box-shadow: var(--shadow-lg); }

/* ── Mobile hamburger ────────────────────────────────── */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 4px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.menu-toggle:hover { background: var(--accent-light); }
.menu-toggle span {
    display: block;
    width: 22px; height: 2px;
    background: var(--primary);
    border-radius: 1px;
    transition: transform var(--transition), opacity var(--transition);
}

/* ── Mobile ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .hero { flex-direction: column-reverse; text-align: center; padding: 40px 0 32px; gap: 28px; }
    .hero .subtitle { justify-content: center; }
    .hero .subtitle::before { display: none; }
    .section-title::after { left: 50%; transform: translateX(-50%); }
    .nav-links { display: none; }
    .btn { margin-right: 6px; margin-bottom: 8px; }
    #awards .grid { grid-template-columns: 1fr; }

    .menu-toggle { display: flex; }

    header.nav-open .nav-links {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 100%; left: 0; right: 0;
        background: rgba(255,255,255,.98);
        -webkit-backdrop-filter: blur(16px);
        backdrop-filter: blur(16px);
        padding: 8px 24px 20px;
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-md);
        gap: 0;
        z-index: 99;
    }
    header.nav-open .nav-links a {
        padding: 11px 0;
        border-bottom: 1px solid var(--border);
        font-size: 0.9rem;
        color: var(--text);
    }
    header.nav-open .nav-links a:last-child { border-bottom: none; }

    header.nav-open .menu-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
    header.nav-open .menu-toggle span:nth-child(2) { opacity: 0; transform: scaleX(0); }
    header.nav-open .menu-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

    #scroll-top { bottom: 16px; right: 16px; }
}
