/* ===== CSS Variables ===== */
:root {
    --primary: #1a365d;
    --primary-light: #2c5282;
    --accent: #3182ce;
    --accent-light: #63b3ed;
    --bg: #ffffff;
    --bg-alt: #f7fafc;
    --text: #1a202c;
    --text-secondary: #4a5568;
    --text-light: #718096;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.3s ease;
    --max-width: 1100px;
}

/* Dark Mode Variables */
[data-theme="dark"] {
    --primary: #4299e1;
    --primary-light: #3182ce;
    --accent: #63b3ed;
    --accent-light: #90cdf4;
    --bg: #1a202c;
    --bg-alt: #2d3748;
    --text: #f7fafc;
    --text-secondary: #cbd5e0;
    --text-light: #a0aec0;
    --border: #4a5568;
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.4), 0 2px 4px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.5), 0 4px 6px rgba(0,0,0,0.4);
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.7;
    font-size: 16px;
}

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

a:hover {
    color: var(--primary);
}

/* ===== Navigation ===== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    transition: box-shadow var(--transition), background var(--transition);
}

.navbar.scrolled {
    box-shadow: var(--shadow-md);
}

.nav-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.nav-logo {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.02em;
}

.nav-logo:hover {
    color: var(--accent);
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 0.25rem;
}

.nav-links a {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    transition: all var(--transition);
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary);
    background: var(--bg-alt);
}

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.nav-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: all var(--transition);
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    margin-right: 1rem;
}

.search-toggle,
.dark-mode-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.1rem;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.search-toggle:hover,
.dark-mode-toggle:hover {
    color: var(--accent);
    background: var(--bg-alt);
}

/* ===== Hero ===== */
.hero {
    padding: 8rem 2rem 4rem;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    min-height: 85vh;
    display: flex;
    align-items: center;
}

.hero-content {
    max-width: var(--max-width);
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4rem;
    align-items: center;
    width: 100%;
}

.hero h1 {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.15;
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
}

.hero-subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.hero-affiliation {
    font-size: 1.05rem;
    color: var(--text-light);
    margin-bottom: 1.25rem;
}

.hero-research {
    font-size: 1.05rem;
    color: var(--text-secondary);
    line-height: 1.7;
    max-width: 560px;
    margin-bottom: 2rem;
}

.hero-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
    border: 2px solid transparent;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-light);
    border-color: var(--primary-light);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-outline {
    background: var(--bg);
    color: var(--primary);
    border-color: var(--border);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.hero-photo {
    width: 260px;
    height: 260px;
    border-radius: 50%;
    overflow: hidden;
    border: 4px solid white;
    box-shadow: var(--shadow-lg);
    flex-shrink: 0;
}

.hero-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(0.90);
}

.photo-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
}

.photo-placeholder i {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    opacity: 0.8;
}

.photo-placeholder p {
    font-size: 0.75rem;
    text-align: center;
    opacity: 0.7;
    line-height: 1.4;
}

.photo-placeholder code {
    background: rgba(255,255,255,0.2);
    padding: 0.15em 0.4em;
    border-radius: 3px;
    font-size: 0.7rem;
}

/* ===== Sections ===== */
.section {
    padding: 5rem 2rem;
}

.section-alt {
    background: var(--bg-alt);
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
}

.section-title {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 2.5rem;
    letter-spacing: -0.01em;
}

.section-title::after {
    content: '';
    display: block;
    width: 50px;
    height: 3px;
    background: var(--accent);
    margin-top: 0.5rem;
    border-radius: 2px;
}

/* ===== About ===== */
.about-content p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-size: 1.02rem;
}

.highlights {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-top: 2.5rem;
}

.highlight-card {
    background: var(--bg);
    padding: 1.75rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform var(--transition), box-shadow var(--transition);
    border: 1px solid var(--border);
}

.highlight-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.highlight-card i {
    font-size: 2rem;
    color: var(--accent);
    margin-bottom: 0.75rem;
}

.highlight-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--primary);
}

.highlight-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.8;
}

.date {
    font-size: 0.8rem;
    color: var(--text-light);
    font-style: italic;
}

/* ===== Publications ===== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.citation-stats {
    display: flex;
    gap: 2rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.stat-item i {
    color: var(--accent);
    font-size: 1.5rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.publication-filters {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
    padding: 1rem;
    background: var(--bg-alt);
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.filter-group label i {
    color: var(--accent);
}

.filter-group select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition);
}

.filter-group select:hover,
.filter-group select:focus {
    border-color: var(--accent);
    outline: none;
}

.filter-reset {
    margin-left: auto;
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.filter-reset:hover {
    background: var(--primary-light);
}

.publication.hidden {
    display: none;
}

.subsection-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1.25rem;
    margin-top: 0.5rem;
}

.publication-list {
    margin-bottom: 2rem;
}

.publication {
    display: flex;
    gap: 1rem;
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--border);
}

.publication:last-child {
    border-bottom: none;
}

.pub-marker {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    margin-top: 0.55rem;
    flex-shrink: 0;
}

.pub-title {
    font-weight: 600;
    color: var(--text);
    font-size: 1.02rem;
    margin-bottom: 0.25rem;
}

.pub-authors {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.15rem;
}

.pub-venue {
    color: var(--text-light);
    font-size: 0.875rem;
    margin-bottom: 0.35rem;
}

.pub-note {
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.pub-note i {
    margin-right: 0.25rem;
}

.pub-links {
    display: flex;
    gap: 0.75rem;
}

.pub-link {
    font-size: 0.825rem;
    font-weight: 500;
    color: var(--accent);
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--accent);
    border-radius: 4px;
    transition: all var(--transition);
}

.pub-link:hover {
    background: var(--accent);
    color: white;
}

/* Page Header */
.page-header {
    margin-bottom: 2.5rem;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    transition: color var(--transition);
}

.back-link:hover {
    color: var(--accent);
}

.page-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    font-family: 'Source Serif 4', Georgia, serif;
}

/* Publication Preview */
.publications-preview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.publication-preview-item {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.75rem;
    background: var(--bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    transition: all var(--transition);
    height: 100%;
}

.publication-preview-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--accent);
}

.pub-preview-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.pub-preview-content h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.pub-preview-venue {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.pub-preview-badge {
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: 500;
}

.pub-preview-badge i {
    margin-right: 0.25rem;
}

.section-cta {
    text-align: center;
    margin-top: 2rem;
}

/* ===== Timeline ===== */
.timeline {
    position: relative;
    padding-left: 2rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: 2.5rem;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-marker {
    position: absolute;
    left: -2rem;
    top: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid white;
    box-shadow: 0 0 0 2px var(--accent);
    z-index: 1;
}

.timeline-content {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: box-shadow var(--transition);
}

.timeline-content:hover {
    box-shadow: var(--shadow-md);
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.25rem;
    flex-wrap: wrap;
}

.timeline-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
}

.timeline-date {
    font-size: 0.825rem;
    color: var(--text-light);
    font-weight: 500;
    white-space: nowrap;
    background: var(--bg-alt);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
}

.timeline-role {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 0.75rem;
    font-style: italic;
}

.timeline-content ul {
    list-style: none;
    padding: 0;
}

.timeline-content li {
    position: relative;
    padding-left: 1.25rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.65;
}

.timeline-content li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--accent);
    font-weight: 600;
}

/* ===== Projects Grid ===== */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.project-card {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: transform var(--transition), box-shadow var(--transition);
    display: flex;
    flex-direction: column;
}

.project-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.project-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.project-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.project-course {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 0.75rem;
    font-style: italic;
}

.project-card > p:not(.project-course) {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.65;
    flex: 1;
}

.project-date {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 1rem;
    font-weight: 500;
    background: var(--bg-alt);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
}

/* ===== Teaching ===== */
.teaching-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 1.5rem;
}

.teaching-card {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: box-shadow var(--transition);
}

.teaching-card:hover {
    box-shadow: var(--shadow-md);
}

.teaching-card i {
    font-size: 2rem;
    color: var(--accent);
    margin-bottom: 1rem;
}

.teaching-card h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.teaching-card > p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.teaching-detail {
    font-size: 0.825rem !important;
    color: var(--text-light) !important;
    margin-top: 0.5rem;
    font-weight: 500;
}

/* ===== Skills ===== */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.skill-category {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.skill-category h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 1rem;
}

.skill-category h3 i {
    margin-right: 0.5rem;
    color: var(--accent);
}

.skill-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    background: var(--bg-alt);
    color: var(--text-secondary);
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.825rem;
    font-weight: 500;
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.tag:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== Footer ===== */
.footer {
    background: var(--primary);
    color: white;
    padding: 2rem;
}

.footer-content {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-content p {
    font-size: 0.875rem;
    opacity: 0.8;
}

.footer-links {
    display: flex;
    gap: 1.25rem;
}

.footer-links a {
    color: white;
    font-size: 1.2rem;
    opacity: 0.7;
    transition: opacity var(--transition);
}

.footer-links a:hover {
    opacity: 1;
    color: white;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .nav-toggle {
        display: flex;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--bg);
        flex-direction: column;
        padding: 1rem 2rem;
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-md);
    }

    .nav-links.open {
        display: flex;
    }

    .nav-controls {
        order: -1;
        margin-right: 0.5rem;
        margin-left: 0;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .citation-stats {
        width: 100%;
        justify-content: space-around;
    }

    .publication-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group select {
        width: 100%;
    }

    .filter-reset {
        margin-left: 0;
        width: 100%;
    }

    .search-modal-content {
        width: 95%;
        max-height: 80vh;
    }

    .publications-preview {
        grid-template-columns: 1fr;
    }

    .hero {
        padding: 7rem 1.5rem 3rem;
        min-height: auto;
    }

    .hero-content {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
    }

    .hero-photo {
        width: 180px;
        height: 180px;
        margin: 0 auto;
        order: -1;
    }

    .hero h1 {
        font-size: 2.2rem;
    }

    .hero-research {
        max-width: 100%;
    }

    .hero-links {
        justify-content: center;
    }

    .highlights {
        grid-template-columns: 1fr;
    }

    .section {
        padding: 3.5rem 1.5rem;
    }

    .section-title {
        font-size: 1.7rem;
    }

    .projects-grid {
        grid-template-columns: 1fr;
    }

    .teaching-grid {
        grid-template-columns: 1fr;
    }

    .skills-grid {
        grid-template-columns: 1fr;
    }

    .timeline {
        padding-left: 1.5rem;
    }

    .timeline-header {
        flex-direction: column;
        gap: 0.25rem;
    }

    .footer-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .hero h1 {
        font-size: 1.8rem;
    }

    .hero-photo {
        width: 150px;
        height: 150px;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.825rem;
    }
}

/* ===== Animations ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-in {
    animation: fadeInUp 0.6s ease forwards;
}

/* ===== Search Modal ===== */
.search-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.search-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.search-modal-content {
    background: var(--bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 650px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

.search-modal.active .search-modal-content {
    transform: translateY(0);
}

.search-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.search-header i {
    color: var(--accent);
    font-size: 1.1rem;
}

.search-header input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    color: var(--text);
    background: transparent;
}

.search-header input::placeholder {
    color: var(--text-light);
}

.search-close {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all var(--transition);
}

.search-close:hover {
    background: var(--bg-alt);
    color: var(--text);
}

.search-results {
    overflow-y: auto;
    max-height: calc(70vh - 80px);
    padding: 1rem;
}

.search-results::-webkit-scrollbar {
    width: 6px;
}

.search-results::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.search-hint {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-light);
}

.search-hint i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--accent);
    opacity: 0.5;
}

.search-hint p {
    font-size: 0.9rem;
    line-height: 1.6;
}

.search-result-item {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid transparent;
}

.search-result-item:hover {
    background: var(--bg-alt);
    border-color: var(--border);
}

.search-result-title {
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
}

.search-result-type {
    display: inline-block;
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    background: var(--accent);
    color: white;
    border-radius: 12px;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.search-result-snippet {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.search-result-snippet mark {
    background: var(--accent-light);
    color: var(--text);
    padding: 0.1rem 0.2rem;
    border-radius: 2px;
}

.no-results {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-light);
}

.no-results i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* ===== Chatbot Widget ===== */
.chatbot-fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 1.4rem;
    box-shadow: 0 4px 16px rgba(49,130,206,0.35);
    z-index: 10000;
    transition: background var(--transition), transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chatbot-fab:hover {
    background: var(--primary-light);
    transform: scale(1.08);
}
.chatbot-fab.active {
    background: var(--primary);
}

.chatbot-window {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 540px;
    max-height: calc(100vh - 140px);
    background: var(--bg);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.chatbot-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Header */
.chatbot-header {
    background: var(--primary);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.chatbot-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}
.chatbot-header-title {
    font-weight: 600;
    font-size: 0.95rem;
}
.chatbot-header-subtitle {
    font-size: 0.75rem;
    opacity: 0.8;
    margin-top: 1px;
}
.chatbot-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    padding: 4px;
}
.chatbot-close:hover {
    opacity: 1;
}

/* Messages area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--bg-alt);
}
.chatbot-messages::-webkit-scrollbar {
    width: 5px;
}
.chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* Message bubbles */
.chatbot-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.88rem;
    line-height: 1.55;
    word-wrap: break-word;
    animation: chatFadeIn 0.2s ease;
}
.chatbot-msg-user {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chatbot-msg-bot {
    align-self: flex-start;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.chatbot-msg-bot code {
    background: var(--bg-alt);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.82rem;
}
.chatbot-msg-bot pre {
    background: var(--bg-alt);
    padding: 8px 10px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 6px 0;
    font-size: 0.8rem;
}
.chatbot-msg-bot a {
    color: var(--accent);
    text-decoration: underline;
}
.chatbot-msg-error {
    border-color: #fc8181;
    background: #fff5f5;
    color: #c53030;
}

/* Provider/model badge */
.chatbot-meta {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: var(--text-light);
}
.chatbot-provider-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* Typing indicator */
.chatbot-typing {
    display: flex;
    gap: 5px;
    padding: 12px 18px;
    align-items: center;
}
.chatbot-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-light);
    animation: typingBounce 1.2s infinite;
}
.chatbot-typing span:nth-child(2) { animation-delay: 0.15s; }
.chatbot-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

@keyframes chatFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Input area */
.chatbot-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}
.chatbot-input-area textarea {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 0.88rem;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 120px;
    line-height: 1.4;
    transition: border-color 0.2s;
}
.chatbot-input-area textarea:focus {
    border-color: var(--accent);
}
.chatbot-input-area button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    flex-shrink: 0;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chatbot-input-area button:hover {
    background: var(--primary-light);
}

/* API key prompt */
.chatbot-api-key-prompt {
    text-align: center;
    padding: 24px 16px;
}
.chatbot-api-key-prompt p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.5;
}
.chatbot-api-key-prompt a {
    color: var(--accent);
    text-decoration: underline;
}
.chatbot-api-input-row {
    display: flex;
    gap: 8px;
}
.chatbot-api-input-row input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    outline: none;
    font-family: inherit;
}
.chatbot-api-input-row input:focus {
    border-color: var(--accent);
}
.chatbot-api-input-row button {
    padding: 10px 20px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.chatbot-api-input-row button:hover {
    background: var(--primary-light);
}
.chatbot-api-note {
    font-size: 0.72rem !important;
    color: var(--text-light) !important;
    margin-top: 10px !important;
    margin-bottom: 0 !important;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .chatbot-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    .chatbot-fab {
        bottom: 18px;
        right: 18px;
    }
}
