/* CSS Custom Properties */
:root {
    /* Colors - Neutral theme with single accent */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-card: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* Typography */
    --font-family-base: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-size-base: 16px;
    --line-height-base: 1.5;
    --font-weight-normal: 400;
    --font-weight-semibold: 600;
    
    /* Spacing */
    --section-padding-desktop: 64px;
    --section-padding-mobile: 32px;
    --container-max-width: 1200px;
    --header-height: 72px;
    --nav-pill-height: 44px;
    
    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* RAG credits divider spacing */
    --rag-divider-gap: 8px;
}

/* Dark theme */
:root.dark {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --accent: #60a5fa;
    --accent-hover: #3b82f6;
    --border: #334155;
    --border-light: #475569;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.3), 0 8px 10px -6px rgb(0 0 0 / 0.3);
}

/* Additional Design Tokens (Education revamp) */
:root {
    --edu-surface: rgba(255,255,255,0.04);
    --edu-surface-blur: 18px;
    --edu-border: rgba(255,255,255,0.12);
    --edu-border-strong: rgba(255,255,255,0.28);
    --edu-accent-gradient: linear-gradient(90deg, var(--accent) 0%, var(--accent-hover) 100%);
    --edu-gap: 24px;
    --edu-radius: 14px;
    --edu-card-padding: 1.4rem 1.6rem;
    --edu-transition: 0.35s cubic-bezier(.4,0,.2,1);
}

/* Reset and base styles */
* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family-base);
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
    font-weight: var(--font-weight-normal);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    margin: 0;
    padding: 0;
    transition: var(--transition);
    scroll-behavior: smooth;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-weight-semibold);
    line-height: 1.2;
    margin: 0 0 1rem 0;
    color: var(--text-primary);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }

p {
    margin: 0 0 1rem 0;
    color: var(--text-secondary);
}

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

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

/* Container */
.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-height);
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    transition: var(--transition);
    box-shadow: 0 2px 4px -2px rgba(0,0,0,0.25);
    display: flex;
    align-items: center; /* vertical center children */
}

.dark .header {
    background-color: var(--bg-primary); /* use dark primary solid */
    box-shadow: 0 2px 6px -2px rgba(0,0,0,0.6);
}

.nav {
    display: flex;
    align-items: center;
    justify-content: center; /* center primary nav list */
    height: 100%;
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 6rem 0 2rem; /* extra right padding to reserve space for theme toggle */
    position: relative; /* anchor theme switcher */
}

/* Navigation layout */
.nav-list {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0; /* list centers because parent uses justify-content:center */
    padding: 0;
    gap: 2.5rem;
    flex: 0 0 auto; /* shrink-wrap width */
    justify-content: center;
}

/* Ensure no bullets appear if earlier rules fail to load */
.nav-list li { list-style: none; }

.nav-list a {
    color: var(--text-primary);
    font-weight: var(--font-weight-normal);
    padding: 0 1.15rem; /* horizontal only */
    border-radius: 0.75rem;
    transition: var(--transition);
    position: relative;
    font-size: 1rem;
    line-height: 1;
    height: var(--nav-pill-height);
    display: flex;
    align-items: center;
}

.nav-list a:hover,
.nav-list a.active {
    color: var(--accent);
    background: var(--bg-secondary);
}

/* Theme switcher pinned to far right (desktop) */
.theme-switcher { margin-left: 0; position: absolute; right: 1rem; top: 50%; transform: translateY(-50%); }

/* Adjust previous duplicated rules removal */

/* (Legacy nav styles removed above) */

/* Mobile menu toggle */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    width: 44px;
    height: 44px;
    justify-content: center;
    align-items: center;
    gap: 4px;
    position: absolute;
    left: 1rem;
}

.mobile-menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background-color: var(--text-primary);
    transition: var(--transition);
}

/* Remove duplicated theme-switcher rule (kept desktop absolute above). */

#theme-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 1.2rem;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

#theme-toggle:hover {
    background-color: var(--bg-secondary);
}

/* Main content */
.main { padding-top: var(--header-height); }

/* Hero section */
.hero {
    padding: calc(var(--section-padding-desktop) + 20px) 0 var(--section-padding-desktop) 0;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    min-height: calc(100vh - var(--header-height));
    display: flex;
    align-items: center;
}

.hero-content {
    display: flex;
    align-items: center; /* vertical alignment */
    gap: 4rem;
}

/* Make hero halves split evenly on desktop */
.hero-image, .rag-pane { flex: 1 1 50%; }

/* RAG Pane styles - Enhanced */
.rag-pane {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    box-shadow: var(--shadow), 0 0 0 1px rgba(255, 255, 255, 0.05);
    min-height: 520px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(12px);
}

.dark .rag-pane {
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 
        0 20px 25px -5px rgba(0, 0, 0, 0.4), 
        0 8px 10px -6px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* RAG Header Styles */
.rag-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.rag-title-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.rag-title {
    font-size: 1.25rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.025em;
}

.rag-chip {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.7rem;
    font-weight: var(--font-weight-semibold);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 1px 3px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.rag-info-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.25rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.875rem;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
}

.rag-info-btn:hover {
    background-color: var(--bg-secondary);
    border-color: var(--accent);
    color: var(--accent);
    transform: scale(1.05);
}

.rag-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin: 0;
    max-width: 90%;
}

.rag-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: var(--text-secondary);
    height: 100%;
    text-align: center;
}

.rag-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: rag-spin 1s linear infinite;
}

@keyframes rag-spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* RAG Pipeline Visualization */
.rag-pipeline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin: 1rem 0 1.5rem 0;
    padding: 1rem;
    background: rgba(59, 130, 246, 0.02);
    border: 1px solid rgba(59, 130, 246, 0.1);
    border-radius: 0.75rem;
    font-size: 0.75rem;
}

.dark .rag-pipeline {
    background: rgba(59, 130, 246, 0.05);
    border: 1px solid rgba(59, 130, 246, 0.15);
}

.pipeline-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
    position: relative;
}

.pipeline-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid;
}

/* Pipeline color progression */
.pipeline-node[data-stage="query"] .pipeline-dot {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

.pipeline-node[data-stage="retrieval"] .pipeline-dot {
    background: #8b5cf6;
    border-color: #8b5cf6;
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.3);
}

.pipeline-node[data-stage="llm"] .pipeline-dot {
    background: #10b981;
    border-color: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.3);
}

.pipeline-node[data-stage="answer"] .pipeline-dot {
    background: #f59e0b;
    border-color: #f59e0b;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.3);
}

.pipeline-label {
    font-size: 0.65rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    text-align: center;
    letter-spacing: 0.025em;
    text-transform: uppercase;
}

.pipeline-arrow {
    color: var(--text-muted);
    font-size: 0.875rem;
    opacity: 0.6;
}

/* Pipeline animations */
@keyframes pipeline-pulse {
    0%, 100% { 
        transform: scale(1);
        opacity: 1;
    }
    50% { 
        transform: scale(1.2);
        opacity: 0.8;
    }
}

.pipeline-node.active .pipeline-dot {
    animation: pipeline-pulse 1.5s ease-in-out infinite;
}

.pipeline-node.processing .pipeline-dot {
    animation: pipeline-pulse 0.8s ease-in-out infinite;
    box-shadow: 0 0 16px currentColor;
}

/* Enhanced Thinking States */
.rag-thinking {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(59, 130, 246, 0.05);
    border: 1px solid rgba(59, 130, 246, 0.1);
    border-radius: 0.75rem;
    margin-bottom: 1rem;
}

[hidden] { display: none !important; }

.thinking-stage {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
    opacity: 0.5;
}

.thinking-stage.active {
    opacity: 1;
    background: rgba(59, 130, 246, 0.1);
    transform: translateX(4px);
}

.thinking-icon {
    font-size: 1.25rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.1);
}

.thinking-stage.active .thinking-icon {
    animation: thinking-pulse 1s ease-in-out infinite;
}

.thinking-text {
    font-size: 0.875rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

@keyframes thinking-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.rag-bg-title {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    text-align: center;
    color: var(--text-muted);
    opacity: 0.6;
    pointer-events: none;
    font-size: 1.05rem;
}

.rag-output {
    flex: 1 1 auto;
    overflow-y: auto;
    color: var(--text-secondary);
    padding: 0.5rem 0.25rem 0.75rem;
    white-space: pre-wrap;
}

.rag-form {
    margin-top: auto;
    /* Reduce the gap; final spacing is created by the credits' divider */
    margin-bottom: calc(var(--rag-divider-gap));
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-top: 0.5rem;
    background: linear-gradient(180deg, transparent, var(--bg-card));
}

.rag-form input[type="text"] {
    flex: 1 1 auto;
    height: 48px;
    padding: 0 1rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #ffffff; /* white bar in both themes */
    color: #0f172a;
    outline: none;
}

.rag-form input[type="text"]:focus {
    border-color: var(--accent);
    box-shadow: 
        0 0 0 3px rgba(59, 130, 246, 0.25),
        0 0 12px rgba(59, 130, 246, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    background: #ffffff;
    transform: translateY(-1px);
}

.dark .rag-form input[type="text"]:focus {
    box-shadow: 
        0 0 0 3px rgba(96, 165, 250, 0.25),
        0 0 16px rgba(96, 165, 250, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.rag-form button[type="submit"] {
    height: 48px;
    padding: 0 1.25rem;
    border-radius: 999px;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    transition: var(--transition);
}

.rag-form button[type="submit"]:hover { 
    background: var(--accent-hover); 
    border-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* RAG Credits Section */
.rag-credits {
    margin-top: auto;
    /* Tighten vertical spacing */
    padding-top: calc(var(--rag-divider-gap));
    text-align: center;
    position: relative;
}

.rag-credits::before {
    content: '';
    position: absolute;
    /* Center the divider vertically between the form and the text */
    top: calc(var(--rag-divider-gap) / 2);
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 1px;
    background: var(--border-light);
}

/* One-time cold-start helper note */
.rag-note {
    margin-top: 0.25rem;
    margin-bottom: calc(var(--rag-divider-gap));
    font-size: 0.8rem;
    color: var(--text-muted);
}

.credits-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.025em;
}

.credits-link {
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    position: relative;
}

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

.credits-link::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--accent);
    transition: width 0.2s ease;
}

.credits-link:hover::after {
    width: 100%;
}

/* RAG Info Modal Styles */
.rag-explanation {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin: 1.5rem 0;
}

.explanation-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 0.75rem;
    border: 1px solid var(--border-light);
    transition: var(--transition);
}

.explanation-item:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
}

.explanation-icon {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 0.5rem;
    flex-shrink: 0;
}

.explanation-content h4 {
    font-size: 1rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
}

.explanation-content p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.modal-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-light);
    text-align: center;
}

.tech-stack-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
    letter-spacing: 0.025em;
}

.tech-stack-info strong {
    color: var(--accent);
    font-weight: var(--font-weight-semibold);
}

/* Screen reader only utility */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap; border: 0;
}

.hero-image img {
    width: 300px;
    height: 300px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 9%; /* DO NOT CHANGE */ 
    border: 4px solid var(--accent);
    box-shadow: var(--shadow-lg);
    margin: 0; /* remove manual vertical offset */
}

/* Stack hero text under the image */
.hero-image .hero-text { margin-top: 1.25rem; }
.hero-image .hero-text .hero-subtitle { max-width: 600px; }

.hero-text h1 {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    max-width: 600px;
}

.cta-button {
    display: inline-flex;
    align-items: center;
    padding: 1rem 2rem;
    background-color: var(--accent);
    color: white;
    border-radius: 0.5rem;
    font-weight: var(--font-weight-semibold);
    font-size: 1.1rem;
    transition: var(--transition);
    box-shadow: var(--shadow);
    min-height: 48px;
}

.cta-button:hover {
    background-color: var(--accent-hover);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* CTA group for multiple hero buttons */
.cta-group { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }
.cta-secondary { background: transparent; color: var(--text-primary); border: 1px solid var(--border); }
.cta-secondary:hover { background: var(--bg-secondary); color: var(--text-primary); border-color: var(--accent); }

/* Sections */
.section {
    padding: var(--section-padding-desktop) 0;
}

.section h2 {
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
}

.section h2::after {
    content: '';
    position: absolute;
    bottom: -0.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background-color: var(--accent);
    border-radius: 2px;
}

/* Project filters */
.project-filters {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 3rem;
    flex-wrap: wrap;
    width: 100%;
}

/* New Education Glass Cards */
.education { padding: var(--section-padding-desktop) 0; }
.education__inner { max-width: 1100px; margin: 0 auto; padding: 0 1.25rem; }
.education__title { text-align: center; font-size: clamp(2.25rem,4.4vw,3.1rem); font-weight: var(--font-weight-semibold); letter-spacing: .5px; margin:0 0 2.75rem; position:relative; }
.education__title::after { content:''; position:absolute; left:50%; bottom:-1rem; transform:translateX(-50%); width:140px; height:6px; border-radius:999px; background: linear-gradient(90deg,var(--accent), var(--accent-hover)); box-shadow:0 0 0 4px rgba(255,255,255,0.05); }
.education__list { display:flex; flex-direction:column; gap: var(--edu-gap); }
.edu-card { background: var(--edu-surface); backdrop-filter: blur(var(--edu-surface-blur)); border:1px solid var(--edu-border); border-radius: var(--edu-radius); padding: var(--edu-card-padding); display:flex; align-items:center; gap:2rem; position:relative; transition: var(--edu-transition); box-shadow: 0 8px 28px -8px rgba(0,0,0,0.6); }
.edu-card::before { content:''; position:absolute; inset:0; border-radius:inherit; background:linear-gradient(145deg,rgba(255,255,255,0.06),rgba(255,255,255,0)); pointer-events:none; }
.edu-card:hover { transform:translateY(-6px); border-color: var(--edu-border-strong); box-shadow:0 18px 42px -10px rgba(0,0,0,0.75); }
@media (prefers-reduced-motion: reduce) { .edu-card, .edu-card:hover { transform:none; } }
.edu-card:focus-within { outline:2px solid var(--accent); outline-offset:3px; }
.edu-card__left { display:flex; flex-direction:column; gap:6px; min-width:260px; }
.edu-card__school { font-size:1.15rem; font-weight: var(--font-weight-semibold); letter-spacing:.4px; }
.edu-card__degree { font-size:0.95rem; font-weight: var(--font-weight-normal); color: var(--text-secondary); }
.edu-card__right { margin-left:auto; display:flex; flex-direction:column; align-items:flex-end; gap:6px; min-width:160px; }
.edu-card__range { font-size:0.8rem; font-weight: var(--font-weight-semibold); color: var(--accent); letter-spacing:.5px; text-transform:uppercase; }
.edu-card__grade { font-size:0.75rem; background: var(--accent); color:#0f172a; padding:4px 10px; border-radius:999px; font-weight: var(--font-weight-semibold); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35); }
.edu-card__note { font-size:0.65rem; color: var(--text-secondary); letter-spacing:1px; text-transform:uppercase; font-weight: var(--font-weight-semibold); }
@media (max-width: 720px) { .edu-card { flex-direction:column; align-items:flex-start; gap:1rem; } .edu-card__right { align-items:flex-start; margin-left:0; min-width:0; } .edu-card__left { min-width:0; } }

@media (max-width: 900px) {
    .edu-row { grid-template-columns: 1fr; gap: 0.75rem; align-items: start; }
    .edu-right { justify-content: flex-start; }
    .edu-item { padding: 1.25rem 1.25rem; }
    .edu-middle { order: 3; }
}

.filter-btn {
    padding: 0.75rem 1.5rem;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 2rem;
    cursor: pointer;
    transition: var(--transition);
    font-weight: var(--font-weight-normal);
    min-height: 44px;
}

.filter-btn:hover,
.filter-btn.active {
    background-color: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Project grid */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
}

.project-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
    box-shadow: var(--shadow);
}

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

.project-thumbnail {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    display: none;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 3rem;
    position: relative;
    overflow: hidden;
}

.project-thumbnail::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(255, 255, 255, 0.1) 10px,
        rgba(255, 255, 255, 0.1) 20px
    );
}

.project-thumbnail[data-project="gaze-clip"] {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

.project-thumbnail[data-project="gaze-clip"]::after {
    content: '👁️';
    font-size: 4rem;
}

.project-thumbnail[data-project="sentiment-bert"] {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.project-thumbnail[data-project="sentiment-bert"]::after {
    content: '💬';
    font-size: 4rem;
}

.project-thumbnail[data-project="glaucoma"] {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.project-thumbnail[data-project="glaucoma"]::after {
    content: '👁️‍🗨️';
    font-size: 4rem;
}

.project-content {
    padding: 1.5rem;
}

.project-content h3 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.project-meta {
    display: grid;
    gap: 1rem;
    margin: 1rem 0;
    font-size: 0.9rem;
}

.project-meta-item {
    display: flex;
    gap: 0.5rem;
}

.project-meta-label {
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    min-width: 80px;
}

.project-meta-value {
    color: var(--text-secondary);
}

.project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
    margin-bottom: 1rem; /* Add space below tags */
}

.tag {
    background-color: var(--accent);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: var(--font-weight-normal);
}

/* Project card actions */
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem; /* Space above action links */
}

.actions a {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 1rem;
    transition: var(--transition);
    font-weight: var(--font-weight-semibold);
    font-size: 0.8rem;
    text-decoration: none;
    color: var(--text-primary);
}

.actions a:hover {
    border-color: var(--accent);
    background-color: var(--accent);
    color: white;
}

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

.skill-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    padding: 1.5rem;
    border-radius: 1rem;
    transition: var(--transition);
    text-align: center;
}

.skill-card:hover {
    border-color: var(--accent);
}

.skill-card h3 {
    margin-bottom: 1rem;
    color: var(--accent);
}

/* Experience */
.experience-item {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    padding: 2rem;
    border-radius: 1rem;
    margin-bottom: 2rem;
}

.experience-item h3 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.experience-item ul {
    margin: 1rem 0 0 1rem;
    color: var(--text-secondary);
}

.experience-item li {
    margin-bottom: 0.5rem;
}

/* Education list */
.edu-list {
    list-style: none;
    padding: 0;
}

.edu-list li {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    padding: 1.5rem;
    border-radius: 1rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.muted {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Social links */
.social-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 2rem;
}

.social-links a {
    display: inline-flex;
    align-items: center;
    padding: 1rem 2rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    transition: var(--transition);
    font-weight: var(--font-weight-semibold);
    min-height: 48px;
}

.social-links a:hover {
    border-color: var(--accent);
    background-color: var(--accent);
    color: white;
}

/* Footer */
.footer {
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 2rem 0;
    text-align: center;
    color: var(--text-muted);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--bg-card);
    margin: 5% auto;
    padding: 2rem;
    border-radius: 1rem;
    max-width: 700px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
}

/* Modal content spacing and layout for tags and action links */
.modal #modal-title { 
    margin-top: 0; 
    margin-right: 3rem; /* Space for close button */
    padding-right: 1rem; /* Extra padding to prevent text overlap */
}
.modal #modal-summary { margin-top: 0.25rem; }
.modal #modal-description { margin-top: 0.75rem; }
.modal .tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.5rem; /* row and column gaps */
    margin-top: 1rem;
}
.modal .actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem; /* clear space from tags */
}
.modal .actions a {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-weight: var(--font-weight-semibold);
    line-height: 1;
    transition: var(--transition);
}
.modal .actions a:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    transform: translateY(-1px);
}

/* Modal highlights */
.modal-content .highlights { margin-top: 16px; }
.modal-content .highlights h3 { margin: 0 0 8px; font-size: 1rem; }
.modal-content .highlights ul { padding-left: 20px; }
.modal-content .highlights li { margin: 6px 0; }

.close-button {
    color: var(--text-muted);
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    transition: var(--transition);
    z-index: 10;
}

.close-button:hover {
    background-color: var(--bg-secondary);
}

/* Focus styles for accessibility */
:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Responsive design */
@media (max-width: 768px) {
    :root {
        --section-padding-desktop: var(--section-padding-mobile);
    }
    
    /* Mobile navigation */
    .mobile-menu-toggle { display: flex; position: relative; left: 0; align-self: center; }
    .nav { justify-content: flex-start; align-items: center; padding: 0 1rem; height: 100%; }
    /* Reset theme switcher for mobile so it participates in flow */
    .theme-switcher { position: relative; right: auto; top: auto; transform: none; margin-left: auto; display: flex; align-items: center; }
    /* Ensure controls have perfectly centered glyphs within square tap targets */
    #theme-toggle { line-height: 1; }
    .mobile-menu-toggle { width: 44px; height: 44px; }
    .nav-list {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-primary);
        border: 1px solid var(--border);
        border-radius: 0 0 12px 12px;
        flex-direction: column;
        padding: 0.75rem 1rem 1rem;
        gap: 0.25rem;
        transform: translateY(-8px);
        opacity: 0;
        pointer-events: none;
        visibility: hidden;
        transition: var(--transition);
        box-shadow: var(--shadow-lg);
    }
    .nav-list.active {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
        visibility: visible;
    }
    .nav-list a { width: 100%; }
    
    .nav-list li {
        width: 100%;
    }
    
    .nav-list a {
        display: block;
        padding: 1rem;
        border-bottom: 1px solid var(--border-light);
        min-height: 48px;
        display: flex;
        align-items: center;
    }
    
    /* Hero responsive */
    .hero {
        padding: calc(var(--section-padding-mobile) + 50px) 0 var(--section-padding-mobile) 0;
        min-height: calc(100vh - var(--header-height) - 50px);
    }

    .hero-content {
        flex-direction: column;
        text-align: center;
        gap: 2rem;
        align-items: center;
    }

    /* Reset equal split on mobile; stack full width */
    .hero-image, .rag-pane { flex: 1 1 auto; width: 100%; }

    /* RAG responsive styles */
    .rag-pane {
        min-height: 450px;
        padding: 1.25rem;
    }

    .rag-header {
        margin-bottom: 1.25rem;
        padding-bottom: 0.75rem;
    }

    .rag-title-row {
        gap: 0.5rem;
    }

    .rag-title {
        font-size: 1.125rem;
    }

    .rag-subtitle {
        font-size: 0.8rem;
        max-width: 100%;
    }

    .rag-pipeline {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.75rem;
        margin: 0.75rem 0 1rem 0;
    }

    .pipeline-label {
        font-size: 0.6rem;
    }

    .pipeline-arrow {
        display: none;
    }

    .pipeline-node::after {
        content: '↓';
        position: absolute;
        bottom: -1.5rem;
        left: 50%;
        transform: translateX(-50%);
        color: var(--text-muted);
        font-size: 0.75rem;
    }

    .pipeline-node:last-child::after {
        display: none;
    }

    .rag-thinking {
        padding: 0.75rem;
        gap: 0.5rem;
    }

    .thinking-stage {
        padding: 0.375rem;
    }

    .thinking-icon {
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }

    .thinking-text {
        font-size: 0.8rem;
    }

    .rag-form { margin-bottom: calc(var(--rag-divider-gap)); }
    .rag-credits { padding-top: calc(var(--rag-divider-gap)); }

    .credits-text {
        font-size: 0.7rem;
    }

    /* Modal responsive */
    .rag-explanation {
        gap: 1rem;
    }

    .explanation-item {
        padding: 0.75rem;
    }

    .explanation-icon {
        width: 36px;
        height: 36px;
        font-size: 1.25rem;
    }

    .explanation-content h4 {
        font-size: 0.9rem;
    }

    .explanation-content p {
        font-size: 0.8rem;
    }

    .hero-image img {
        width: 200px;
        height: 200px;
    }

    .hero-text {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .hero-text h1 {
        font-size: 2.5rem;
    }

    .hero-subtitle {
        font-size: 1.1rem;
        max-width: 100%;
    }

    .cta-group {
        justify-content: center;
        width: 100%;
    }
    
    /* Project grid */
    .project-grid {
        grid-template-columns: 1fr;
    }
    
    /* Center project card internals on mobile */
    .project-content { text-align: center; }
    .project-tags { justify-content: center; }
    .actions { justify-content: center; }
    .project-filters { justify-content: center; width: 100%; }
    
    /* Skills grid */
    .skills-grid {
        grid-template-columns: 1fr;
    }
    
    /* Social links */
    .social-links {
        flex-direction: column;
        align-items: center;
    }
    
    /* Education list */
    .edu-list li {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 375px) {
    .container {
        padding: 0 0.75rem;
    }
    
    .hero-image img {
        width: 180px;
        height: 180px;
    }
    
    .hero-text h1 {
        font-size: 2rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .cta-button {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
    
    .project-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* Smooth scrolling enhancement */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border: #000000;
        --text-secondary: var(--text-primary);
    }
}

/* Print styles */
@media print {
    .header,
    .mobile-menu-toggle,
    .theme-switcher,
    .modal {
        display: none !important;
    }
    
    .main {
        margin-top: 0;
    }
    
    .hero {
        min-height: auto;
        padding: 2rem 0;
    }
    
    .section {
        padding: 1rem 0;
        page-break-inside: avoid;
    }
}
