/* ============================================================
   CSS Custom Properties
   ============================================================ */
:root {
    /* Colors */
    --bg-primary: #f9f7f4;
    --bg-secondary: #f0ede8;
    --bg-card: #ffffff;
    --text-primary: #1a1714;
    --text-secondary: #5a534d;
    --text-muted: #9c9590;
    --accent: #c84b2f;
    --accent-hover: #a83a20;
    --accent-subtle: rgba(200, 75, 47, 0.08);
    --border: #e2ddd8;
    --border-light: #ede9e4;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --shadow-lg: 0 20px 40px -8px rgb(0 0 0 / 0.12), 0 8px 16px -4px rgb(0 0 0 / 0.06);

    /* Typography */
    --font-display: 'Syne', sans-serif;
    --font-family-base: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-size-base: 16px;
    --line-height-base: 1.6;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;

    /* Spacing */
    --section-padding-desktop: 80px;
    --section-padding-mobile: 48px;
    --container-max-width: 1200px;
    --header-height: 68px;
    --nav-pill-height: 40px;

    /* Transitions */
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    /* RAG credits divider spacing */
    --rag-divider-gap: 8px;

    /* Glass card tokens */
    --glass-surface: rgba(255, 255, 255, 0.7);
    --glass-blur: 16px;
    --glass-border: rgba(0, 0, 0, 0.07);
    --glass-border-strong: rgba(200, 75, 47, 0.35);
    --glass-shadow: 0 8px 32px -8px rgba(0, 0, 0, 0.12);
    --glass-radius: 14px;
    --glass-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Keep edu tokens for compatibility */
    --edu-surface: var(--glass-surface);
    --edu-surface-blur: var(--glass-blur);
    --edu-border: var(--glass-border);
    --edu-border-strong: var(--glass-border-strong);
    --edu-accent-gradient: linear-gradient(90deg, var(--accent) 0%, var(--accent-hover) 100%);
    --edu-gap: 20px;
    --edu-radius: var(--glass-radius);
    --edu-card-padding: 1.5rem 1.75rem;
    --edu-transition: var(--glass-transition);
}

/* Dark theme */
:root.dark {
    --bg-primary: #0d0f14;
    --bg-secondary: #141720;
    --bg-card: #181c26;
    --text-primary: #eeeae4;
    --text-secondary: #9a9590;
    --text-muted: #5c5a55;
    --accent: #e8653e;
    --accent-hover: #c84b2f;
    --accent-subtle: rgba(232, 101, 62, 0.1);
    --border: #252932;
    --border-light: #1e2230;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 20px 40px -8px rgb(0 0 0 / 0.5), 0 8px 16px -4px rgb(0 0 0 / 0.3);

    --glass-surface: rgba(255, 255, 255, 0.035);
    --glass-blur: 20px;
    --glass-border: rgba(255, 255, 255, 0.07);
    --glass-border-strong: rgba(232, 101, 62, 0.4);
    --glass-shadow: 0 8px 32px -8px rgba(0, 0, 0, 0.6);
}

/* ============================================================
   Reset & Base
   ============================================================ */
* { 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: background-color 0.3s ease, color 0.3s ease;
    scroll-behavior: smooth;
    /* Subtle noise texture overlay */
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
}

.dark body {
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.06'/%3E%3C/svg%3E");
}

/* ============================================================
   Typography
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.15;
    margin: 0 0 1rem 0;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

h1 { font-size: 2.75rem; }
h2 { font-size: 2.25rem; }
h3 { font-size: 1.35rem; font-weight: 600; }

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

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

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

/* ============================================================
   Layout
   ============================================================ */
.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ============================================================
   Header & Navigation
   ============================================================ */
.header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-height);
    background-color: rgba(249, 247, 244, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    box-shadow: 0 1px 0 var(--border-light);
    display: flex;
    align-items: center;
}

.dark .header {
    background-color: rgba(13, 15, 20, 0.88);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04);
}

.nav {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 6rem 0 2rem;
    position: relative;
}

.nav-list {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0.25rem;
    flex: 0 0 auto;
    justify-content: center;
}

.nav-list li { list-style: none; }

.nav-list a {
    font-family: var(--font-family-base);
    color: var(--text-secondary);
    font-weight: var(--font-weight-medium);
    padding: 0.4rem 0.9rem;
    border-radius: 0.5rem;
    transition: var(--transition);
    font-size: 0.9rem;
    letter-spacing: 0.01em;
    height: var(--nav-pill-height);
    display: flex;
    align-items: center;
}

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

.theme-switcher {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
}

.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: 5px;
    position: absolute;
    left: 1rem;
}

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

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

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

/* Crescent-moon icon drawn in CSS (keeps the toggle icon-only and fully ASCII) */
#theme-toggle::before {
    content: "";
    width: 16px;
    height: 16px;
    border-radius: 50%;
    box-shadow: inset -5px -3px 0 0 currentColor;
}

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

/* ============================================================
   Hero
   ============================================================ */
.hero {
    padding: calc(var(--section-padding-desktop) + 20px) 0 var(--section-padding-desktop) 0;
    min-height: calc(100vh - var(--header-height));
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
}

/* Animated mesh background for hero */
.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 20% 40%, rgba(200, 75, 47, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse 60% 80% at 80% 20%, rgba(200, 75, 47, 0.04) 0%, transparent 60%),
        radial-gradient(ellipse 40% 40% at 60% 80%, rgba(100, 60, 200, 0.03) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

.dark .hero::before {
    background:
        radial-gradient(ellipse 80% 60% at 20% 40%, rgba(232, 101, 62, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse 60% 80% at 80% 20%, rgba(232, 101, 62, 0.05) 0%, transparent 60%),
        radial-gradient(ellipse 40% 40% at 60% 80%, rgba(100, 80, 220, 0.04) 0%, transparent 60%);
}

.hero .container { position: relative; z-index: 1; }

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

.hero-image, .rag-pane { flex: 1 1 50%; }

.hero-image img {
    width: 260px;
    height: 260px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 9%; /* DO NOT CHANGE */
    border: 3px solid var(--accent);
    box-shadow: 0 0 0 8px var(--accent-subtle), var(--shadow-lg);
    margin: 0;
}

.hero-image .hero-text { margin-top: 1.5rem; }
.hero-image .hero-text .hero-subtitle { max-width: 520px; }

.hero-text h1 {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 5vw, 4.2rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.05;
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    max-width: 520px;
    line-height: 1.65;
    font-weight: var(--font-weight-normal);
}

.cta-group { display: flex; gap: 0.875rem; flex-wrap: wrap; align-items: center; }

.cta-button {
    display: inline-flex;
    align-items: center;
    padding: 0.875rem 1.75rem;
    background-color: var(--accent);
    color: white;
    border-radius: 0.5rem;
    font-family: var(--font-family-base);
    font-weight: var(--font-weight-medium);
    font-size: 0.95rem;
    transition: var(--transition);
    box-shadow: 0 4px 14px rgba(200, 75, 47, 0.3);
    min-height: 48px;
    letter-spacing: 0.01em;
}

.cta-button:hover {
    background-color: var(--accent-hover);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(200, 75, 47, 0.4);
}

.cta-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
    box-shadow: none;
}

.cta-secondary:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--accent);
    box-shadow: none;
}

/* ============================================================
   Section Shared
   ============================================================ */
.section { padding: var(--section-padding-desktop) 0; }

.section h2 {
    font-family: var(--font-display);
    text-align: center;
    font-size: clamp(2.25rem, 4.4vw, 3.1rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 3.5rem;
    position: relative;
    color: var(--text-primary);
}

.section h2::after {
    content: '';
    position: absolute;
    bottom: -0.75rem;
    left: 50%;
    transform: translateX(-50%);
    width: 48px;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 2px;
}

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

.dark .rag-pane {
    background: rgba(24, 28, 38, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow:
        0 20px 40px -8px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.rag-header {
    margin-bottom: 1.25rem;
    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-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.02em;
}

.rag-chip {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 0.3rem;
    font-family: var(--font-family-base);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.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);
}

.rag-subtitle {
    font-size: 0.825rem;
    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: 2px 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 */
.rag-pipeline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin: 0.75rem 0 1.25rem;
    padding: 0.875rem;
    background: var(--accent-subtle);
    border: 1px solid rgba(200, 75, 47, 0.1);
    border-radius: 0.75rem;
    font-size: 0.75rem;
}

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

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

.pipeline-node[data-stage="query"] .pipeline-dot { background: var(--accent); border-color: var(--accent); }
.pipeline-node[data-stage="retrieval"] .pipeline-dot { background: #7c6af7; border-color: #7c6af7; }
.pipeline-node[data-stage="llm"] .pipeline-dot { background: #22c07a; border-color: #22c07a; }
.pipeline-node[data-stage="answer"] .pipeline-dot { background: #f0a030; border-color: #f0a030; }

.pipeline-label {
    font-family: var(--font-family-base);
    font-size: 0.6rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: center;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

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

@keyframes pipeline-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); 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; }

/* Thinking states */
.rag-thinking {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.875rem;
    background: var(--accent-subtle);
    border: 1px solid rgba(200, 75, 47, 0.1);
    border-radius: 0.75rem;
    margin-bottom: 0.875rem;
}

[hidden] { display: none !important; }

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

.thinking-stage.active {
    opacity: 1;
    background: rgba(200, 75, 47, 0.08);
    transform: translateX(3px);
}

.thinking-icon {
    font-size: 1.1rem;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--accent-subtle);
}

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

.thinking-text {
    font-size: 0.825rem;
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    font-family: var(--font-family-base);
}

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

.rag-bg-title {
    text-align: center;
    color: var(--text-muted);
    opacity: 0.55;
    pointer-events: none;
    font-size: 0.95rem;
    padding: 1rem 0 0.25rem;
    font-family: var(--font-family-base);
}

.rag-output {
    flex: 1 1 auto;
    overflow-y: auto;
    color: var(--text-secondary);
    padding: 0.5rem 0.25rem 0.75rem;
    line-height: 1.65;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
}

.rag-output strong { color: var(--text-primary); font-weight: 600; }
.rag-output em { font-style: italic; }
.rag-output code {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 0.25rem;
    padding: 0.1em 0.35em;
    font-size: 0.85em;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}
.rag-output pre {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    overflow-x: auto;
    margin: 0.5rem 0;
}
.rag-output pre code { background: none; border: none; padding: 0; font-size: 0.85em; }
.rag-output ul { margin: 0.5rem 0; padding-left: 1.25rem; }
.rag-output li { margin-bottom: 0.25rem; }

/* Chat bubbles */
.rag-msg {
    max-width: 85%;
    padding: 0.6rem 0.875rem;
    border-radius: 1rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.6;
    word-wrap: break-word;
}

.rag-msg-user {
    align-self: flex-end;
    margin-left: auto;
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 0.25rem;
}

.rag-msg-ai {
    align-self: flex-start;
    margin-right: auto;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-bottom-left-radius: 0.25rem;
}

.rag-msg-ai strong { color: var(--text-primary); }
.rag-msg-ai code {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 0.25rem;
    padding: 0.1em 0.35em;
    font-size: 0.85em;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}
.rag-msg-ai pre {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    overflow-x: auto;
    margin: 0.5rem 0;
}
.rag-msg-ai pre code { background: none; border: none; padding: 0; }
.rag-msg-ai ul { margin: 0.5rem 0; padding-left: 1.25rem; }
.rag-msg-ai li { margin-bottom: 0.25rem; }

.rag-form button[type="submit"].rag-stop { background: #e05050; border-color: #e05050; }
.rag-form button[type="submit"].rag-stop:hover { background: #c43030; border-color: #c43030; }

/* Typing indicator */
.rag-typing { display: flex; align-items: center; gap: 4px; padding: 4px 0; }
.rag-typing-dot {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: rag-typing-bounce 1.2s ease-in-out infinite;
}
.rag-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.rag-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes rag-typing-bounce {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

.rag-retry {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.35rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 2rem;
    background: none;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-family-base);
}
.rag-retry:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-subtle);
}

.rag-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 0;
    justify-content: center;
}

.rag-suggestion-pill {
    padding: 0.35rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 2rem;
    background: none;
    color: var(--text-secondary);
    font-size: 0.78rem;
    cursor: pointer;
    transition: var(--transition);
    opacity: 0;
    animation: pill-fade-in 0.4s ease forwards;
    text-align: left;
    line-height: 1.4;
    font-family: var(--font-family-base);
}
.rag-suggestion-pill:nth-child(1) { animation-delay: 0.05s; }
.rag-suggestion-pill:nth-child(2) { animation-delay: 0.12s; }
.rag-suggestion-pill:nth-child(3) { animation-delay: 0.19s; }
.rag-suggestion-pill:nth-child(4) { animation-delay: 0.26s; }
.rag-suggestion-pill:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-subtle);
    transform: translateY(-1px);
}
@keyframes pill-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.rag-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--accent);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: rag-blink 0.7s step-end infinite;
}
@keyframes rag-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.rag-form {
    margin-top: auto;
    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: 44px;
    padding: 0 1rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
    font-family: var(--font-family-base);
    font-size: 0.9rem;
    transition: var(--transition);
}

.rag-form input[type="text"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(200, 75, 47, 0.15);
}

.rag-form button[type="submit"] {
    height: 44px;
    padding: 0 1.25rem;
    border-radius: 999px;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-family-base);
    font-size: 0.9rem;
}
.rag-form button[type="submit"]:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(200, 75, 47, 0.3);
}

.rag-credits {
    margin-top: auto;
    padding-top: calc(var(--rag-divider-gap));
    text-align: center;
    position: relative;
}
.rag-credits::before {
    content: '';
    position: absolute;
    top: calc(var(--rag-divider-gap) / 2);
    left: 50%;
    transform: translateX(-50%);
    width: 48px;
    height: 1px;
    background: var(--border-light);
}

.rag-note {
    margin-top: 0.25rem;
    margin-bottom: calc(var(--rag-divider-gap));
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: var(--font-family-base);
}

.rag-stream-note {
    margin-top: 0.35rem;
    font-size: 0.75rem;
    font-style: italic;
    color: var(--text-muted);
}

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

.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 */
.rag-explanation {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    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(200, 75, 47, 0.1);
}

.explanation-icon {
    font-size: 1.4rem;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-subtle);
    border-radius: 0.5rem;
    flex-shrink: 0;
}

.explanation-content h4 {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.4rem 0;
}
.explanation-content p {
    font-size: 0.825rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.modal-footer {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-light);
    text-align: center;
}
.tech-stack-info {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0;
    letter-spacing: 0.025em;
    font-family: var(--font-family-base);
}
.tech-stack-info strong { color: var(--accent); font-weight: 600; }

/* Screen reader only */
.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;
}

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

.filter-btn {
    padding: 0.5rem 1.25rem;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 2rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-family-base);
    font-weight: var(--font-weight-medium);
    font-size: 0.875rem;
    min-height: 38px;
}
.filter-btn:hover,
.filter-btn.active {
    background-color: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(200, 75, 47, 0.25);
}

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

/* Redesign: featured + secondary split inside #project-list */
#project-list {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}
.project-grid--featured {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.project-grid--secondary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem;
}
.project-card__outcome {
    margin: 0 0 0.35rem;
    color: var(--accent);
    font-weight: var(--font-weight-semibold);
    font-size: 0.95rem;
    line-height: 1.3;
}
.project-card__summary {
    color: var(--text-secondary);
    margin: 0;
}
.project-grid--featured .project-content { padding: 1.875rem; }
.project-grid--featured .project-card h3 { font-size: 1.4rem; }
.project-grid--secondary .project-card__outcome { font-size: 0.85rem; }
.project-grid--secondary .project-card h3 { font-size: 1.1rem; }
@media (max-width: 1024px) {
    .project-grid--secondary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
    .project-grid--featured,
    .project-grid--secondary { grid-template-columns: 1fr; }
}

/* Project detail paragraphs (shared by the modal and project.html) */
.project-detail {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 1.1rem 0;
}
.project-detail:empty { display: none; }
.project-detail p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

.project-card {
    background: var(--glass-surface);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--glass-radius);
    overflow: hidden;
    transition: var(--glass-transition);
    cursor: pointer;
    box-shadow: var(--glass-shadow);
    position: relative;
}

.project-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;
}

.project-card:hover {
    transform: translateY(-5px);
    border-color: var(--glass-border-strong);
    box-shadow: 0 20px 48px -10px rgba(0, 0, 0, 0.18);
}

.dark .project-card:hover {
    box-shadow: 0 20px 48px -10px rgba(0, 0, 0, 0.6);
}

.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;
    inset: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(255, 255, 255, 0.07) 10px,
        rgba(255, 255, 255, 0.07) 20px
    );
}


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

.project-meta { display: grid; gap: 0.875rem; margin: 1rem 0; font-size: 0.875rem; }
.project-meta-item { display: flex; gap: 0.5rem; }
.project-meta-label { font-weight: var(--font-weight-medium); color: var(--text-primary); min-width: 72px; }
.project-meta-value { color: var(--text-secondary); }

.project-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 1rem; margin-bottom: 1rem; }

.tag {
    background: var(--accent-subtle);
    color: var(--accent);
    padding: 0.2rem 0.65rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: var(--font-weight-medium);
    border: 1px solid rgba(200, 75, 47, 0.15);
    font-family: var(--font-family-base);
}

.dark .tag {
    background: rgba(232, 101, 62, 0.12);
    border-color: rgba(232, 101, 62, 0.2);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1rem;
}
.actions a {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 1rem;
    transition: var(--transition);
    font-weight: var(--font-weight-medium);
    font-size: 0.8rem;
    text-decoration: none;
    color: var(--text-primary);
    font-family: var(--font-family-base);
}
.actions a:hover {
    border-color: var(--accent);
    background-color: var(--accent);
    color: white;
}

/* ============================================================
   Skills - Tag-cloud redesign
   ============================================================ */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
}

.skill-card {
    background: var(--glass-surface);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--glass-radius);
    padding: 1.5rem;
    transition: var(--glass-transition);
    box-shadow: var(--glass-shadow);
    position: relative;
    overflow: hidden;
}

.skill-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    right: 0; height: 2px;
    background: linear-gradient(90deg, var(--accent), transparent);
    border-radius: 999px 999px 0 0;
}

.skill-card:hover {
    border-color: var(--glass-border-strong);
    transform: translateY(-3px);
    box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.15);
}

.dark .skill-card:hover {
    box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.5);
}

.skill-card h3 {
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.07em;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

/* Tag-cloud pills inside skill cards */
.skill-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.skill-tag {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 0.25rem 0.65rem;
    border-radius: 0.375rem;
    font-size: 0.82rem;
    font-weight: var(--font-weight-medium);
    border: 1px solid var(--border);
    transition: var(--transition);
    cursor: default;
    font-family: var(--font-family-base);
    line-height: 1.5;
}

.skill-tag:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-subtle);
}

/* ============================================================
   Experience - Timeline layout
   ============================================================ */
#experience-list {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
}

/* Vertical timeline line */
#experience-list::before {
    content: '';
    position: absolute;
    left: 0;
    top: 12px;
    bottom: 12px;
    width: 1px;
    background: linear-gradient(180deg, var(--accent), transparent);
    opacity: 0.4;
}

.experience-item {
    background: var(--glass-surface);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--glass-radius);
    padding: 1.75rem 1.75rem 1.75rem 2.25rem;
    margin-bottom: 1.5rem;
    position: relative;
    transition: var(--glass-transition);
    box-shadow: var(--glass-shadow);
}

/* Timeline dot */
.experience-item::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 1.875rem;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-primary);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.experience-item:hover {
    border-color: var(--glass-border-strong);
    transform: translateX(4px);
    box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.15);
}

.dark .experience-item:hover {
    box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.5);
}

.experience-item h3 {
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    font-size: 1.1rem;
}

.experience-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.experience-company {
    font-weight: var(--font-weight-medium);
    color: var(--accent);
    font-size: 0.875rem;
    font-family: var(--font-family-base);
}

.experience-dates {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: var(--font-family-base);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
}

.experience-item ul {
    margin: 0;
    padding-left: 1.1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.experience-item li {
    margin-bottom: 0.6rem;
    line-height: 1.6;
}

.experience-item li:last-child { margin-bottom: 0; }

/* ============================================================
   Education - Glass Cards
   ============================================================ */
.education { padding: var(--section-padding-desktop) 0; }
.education__inner { max-width: 1000px; margin: 0 auto; padding: 0 1.25rem; }
.education__title {
    font-family: var(--font-display);
    text-align: center;
    font-size: clamp(2.25rem, 4.4vw, 3.1rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 3rem;
    position: relative;
    color: var(--text-primary);
}
.education__title::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -0.75rem;
    transform: translateX(-50%);
    width: 48px;
    height: 3px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
}
.education__list { display: flex; flex-direction: column; gap: var(--edu-gap); }

.edu-card {
    background: var(--glass-surface);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--glass-radius);
    padding: var(--edu-card-padding);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: relative;
    transition: var(--glass-transition);
    box-shadow: var(--glass-shadow);
}

.edu-card__header {
    display: flex;
    align-items: center;
    gap: 2rem;
    width: 100%;
}

.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(-5px);
    border-color: var(--glass-border-strong);
    box-shadow: 0 20px 48px -10px rgba(0, 0, 0, 0.18);
}

.dark .edu-card:hover {
    box-shadow: 0 20px 48px -10px rgba(0, 0, 0, 0.6);
}

@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: 5px; min-width: 240px; }
.edu-card__school { font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.edu-card__degree { font-size: 0.9rem; 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: 150px; }
.edu-card__range { font-size: 0.75rem; font-weight: 600; color: var(--accent); letter-spacing: 0.05em; text-transform: uppercase; font-family: var(--font-family-base); }
.edu-card__grade { font-size: 0.72rem; background: var(--accent); color: #fff; padding: 3px 10px; border-radius: 999px; font-weight: 600; font-family: var(--font-family-base); }
.edu-card__note { font-size: 0.62rem; color: var(--text-muted); letter-spacing: 1px; text-transform: uppercase; font-weight: 600; font-family: var(--font-family-base); }

@media (max-width: 720px) {
    .edu-card__header { 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; }
}

.edu-card__details {
    border-top: 1px solid var(--glass-border);
    padding-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}
.edu-card__label { font-weight: 600; color: var(--text-primary); margin-right: 0.35rem; }
.edu-card__specialization,
.edu-card__credits { margin: 0; }
.edu-card__thesis { display: flex; flex-direction: column; gap: 0.25rem; }
.edu-card__thesis-title { font-style: italic; color: var(--text-primary); }
.edu-card__thesis-summary { margin: 0.25rem 0 0; color: var(--text-secondary); line-height: 1.55; }
.edu-card__coursework { margin-top: 0.25rem; }
.edu-card__coursework > summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--accent);
    padding: 0.35rem 0;
    user-select: none;
    list-style: revert;
}
.edu-card__coursework[open] > summary { margin-bottom: 0.5rem; }
.edu-card__coursework-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}
.edu-card__coursework-table th,
.edu-card__coursework-table td {
    padding: 0.4rem 0.6rem;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}
.edu-card__coursework-table th { font-weight: 600; color: var(--text-primary); }
.edu-card__coursework-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.edu-card__code { color: var(--text-muted); font-size: 0.75rem; font-weight: 400; }

/* ============================================================
   Certifications
   ============================================================ */
.certifications { padding: var(--section-padding-desktop) 0; }
.certifications__inner { max-width: 1000px; margin: 0 auto; padding: 0 1.25rem; }
.certifications__title {
    font-family: var(--font-display);
    text-align: center;
    font-size: clamp(2.25rem, 4.4vw, 3.1rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 3rem;
    position: relative;
    color: var(--text-primary);
}
.certifications__title::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -0.75rem;
    transform: translateX(-50%);
    width: 48px;
    height: 3px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
}
.certifications__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.1rem; }

.cert-card {
    background: var(--glass-surface);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-left: 3px solid var(--accent);
    border-radius: var(--glass-radius);
    position: relative;
    transition: var(--glass-transition);
    box-shadow: var(--glass-shadow);
    overflow: hidden;
}
.cert-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(145deg, rgba(255,255,255,0.04), rgba(255,255,255,0));
    pointer-events: none;
}
.cert-card:hover {
    transform: translateY(-4px);
    border-color: var(--glass-border-strong);
    border-left-color: var(--accent);
    box-shadow: 0 16px 38px -8px rgba(0, 0, 0, 0.15);
}
.dark .cert-card:hover { box-shadow: 0 16px 38px -8px rgba(0, 0, 0, 0.55); }
@media (prefers-reduced-motion: reduce) { .cert-card, .cert-card:hover { transform: none; } }

.cert-card__link { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.25rem 1.4rem; text-decoration: none; color: inherit; height: 100%; }
.cert-card__link:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: var(--glass-radius); }

.cert-card__body { display: flex; flex-direction: column; gap: 0.3rem; flex: 1; min-width: 0; }
.cert-card__issuer { font-size: 0.68rem; font-weight: 700; color: var(--accent); letter-spacing: 0.08em; text-transform: uppercase; font-family: var(--font-family-base); }
.cert-card__title { font-family: var(--font-display); font-size: 0.9rem; font-weight: 600; line-height: 1.3; color: var(--text-primary); }
.cert-card__date { font-size: 0.68rem; color: var(--text-muted); letter-spacing: 0.03em; font-family: var(--font-family-base); }

.cert-card__arrow { font-size: 0.9rem; color: var(--text-muted); transition: color var(--glass-transition), transform var(--glass-transition); flex-shrink: 0; }
.cert-card:hover .cert-card__arrow { color: var(--accent); transform: translate(2px, -2px); }

@media (max-width: 600px) { .certifications__grid { grid-template-columns: 1fr; } }

/* ============================================================
   Publications
   ============================================================ */
#publications-list {
    list-style: none;
    padding: 0;
    max-width: 800px;
    margin: 0 auto;
}

#publications-list li {
    background: var(--glass-surface);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--glass-radius);
    padding: 1.5rem 1.75rem;
    margin-bottom: 1rem;
    transition: var(--glass-transition);
    box-shadow: var(--glass-shadow);
    position: relative;
}

#publications-list li::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    border-radius: 999px 0 0 999px;
    background: linear-gradient(180deg, var(--accent), transparent);
}

#publications-list li:hover {
    border-color: var(--glass-border-strong);
    transform: translateX(4px);
}

/* ============================================================
   Contact Section
   ============================================================ */
#contact.section {
    position: relative;
}

#contact .container {
    text-align: center;
}

.contact-card {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    background: var(--glass-surface);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: 1.5rem;
    padding: 3rem 4rem;
    box-shadow: var(--glass-shadow);
    position: relative;
    overflow: hidden;
    max-width: 600px;
    width: 100%;
}

.contact-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, var(--accent-subtle), transparent 60%);
    pointer-events: none;
}

.contact-card p {
    font-size: 1.05rem;
    color: var(--text-secondary);
    margin: 0;
    max-width: 400px;
    text-align: center;
    line-height: 1.65;
}

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

.social-links a {
    display: inline-flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    transition: var(--transition);
    font-weight: var(--font-weight-medium);
    font-size: 0.9rem;
    min-height: 44px;
    color: var(--text-primary);
    background: var(--bg-card);
    font-family: var(--font-family-base);
}

.social-links a:hover {
    border-color: var(--accent);
    background-color: var(--accent);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(200, 75, 47, 0.25);
}

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

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

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

.modal #modal-title {
    font-family: var(--font-display);
    margin-top: 0;
    margin-right: 3rem;
    padding-right: 1rem;
}
.modal #modal-summary { margin-top: 0.25rem; }
.modal #modal-description { margin-top: 0.75rem; }
.modal .tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.4rem;
    margin-top: 1rem;
}
.modal .actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    margin-top: 1rem;
}
.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-medium);
    line-height: 1;
    transition: var(--transition);
    font-family: var(--font-family-base);
    font-size: 0.85rem;
}
.modal .actions a:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    transform: translateY(-1px);
}

.modal-content .highlights { margin-top: 16px; }
.modal-content .highlights h3 { margin: 0 0 8px; font-size: 0.95rem; font-family: var(--font-display); }
.modal-content .highlights ul { padding-left: 20px; }
.modal-content .highlights li { margin: 6px 0; font-size: 0.9rem; color: var(--text-secondary); }

.close-button {
    color: var(--text-muted);
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    font-size: 1.75rem;
    font-weight: bold;
    cursor: pointer;
    width: 40px;
    height: 40px;
    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); color: var(--text-primary); }

/* ============================================================
   Accessibility
   ============================================================ */
:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

/* ============================================================
   Responsive - Mobile
   ============================================================ */
@media (max-width: 768px) {
    :root {
        --section-padding-desktop: var(--section-padding-mobile);
    }

    .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%; }
    .theme-switcher { position: relative; right: auto; top: auto; transform: none; margin-left: auto; display: flex; align-items: center; }
    #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 li { width: 100%; }
    .nav-list a {
        display: flex;
        width: 100%;
        padding: 0.875rem 1rem;
        border-bottom: 1px solid var(--border-light);
        min-height: 48px;
        align-items: center;
    }

    .hero {
        padding: calc(var(--section-padding-mobile) + 40px) 0 var(--section-padding-mobile) 0;
        min-height: calc(100vh - var(--header-height) - 40px);
    }
    .hero-content { flex-direction: column; text-align: center; gap: 2rem; align-items: center; }
    .hero-image, .rag-pane { flex: 1 1 auto; width: 100%; }
    .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: 1rem; max-width: 100%; }
    .cta-group { justify-content: center; width: 100%; }

    /* RAG responsive */
    .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.05rem; }
    .rag-subtitle { font-size: 0.78rem; 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.58rem; }
    .pipeline-arrow { display: none; }
    .rag-thinking { padding: 0.75rem; gap: 0.4rem; }
    .thinking-icon { width: 26px; height: 26px; font-size: 1rem; }
    .rag-msg { max-width: 92%; }
    .rag-form { margin-bottom: calc(var(--rag-divider-gap)); }
    .rag-credits { padding-top: calc(var(--rag-divider-gap)); }
    .credits-text { font-size: 0.68rem; }
    .rag-explanation { gap: 0.875rem; }
    .explanation-item { padding: 0.75rem; }
    .explanation-icon { width: 34px; height: 34px; font-size: 1.2rem; }

    /* Experience */
    #experience-list::before { display: none; }
    .experience-item { padding: 1.4rem; }
    .experience-item::before { display: none; }
    .experience-item:hover { transform: none; }

    /* Project grid */
    .project-grid { grid-template-columns: 1fr; }
    .project-content { text-align: left; }

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

    /* Contact */
    .contact-card { padding: 2rem 1.5rem; }

    /* Social links */
    .social-links { flex-direction: column; align-items: center; }
    .social-links a { width: 100%; max-width: 280px; justify-content: center; }
}

@media (max-width: 375px) {
    .container { padding: 0 1rem; }
    .hero-image img { width: 160px; height: 160px; }
    .hero-text h1 { font-size: 2rem; }
    .hero-subtitle { font-size: 0.95rem; }
    .cta-button { padding: 0.75rem 1.25rem; font-size: 0.9rem; }
    .project-grid { grid-template-columns: 1fr; gap: 1rem; }
}

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

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

/* ============================================================
   Print
   ============================================================ */
@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; }
}

/* ============================================================
   Legacy / Compat
   ============================================================ */
.edu-list { list-style: none; padding: 0; }
.edu-list li {
    background: var(--glass-surface);
    border: 1px solid var(--glass-border);
    padding: 1.5rem;
    border-radius: var(--glass-radius);
    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.875rem; }

@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; }
    .edu-middle { order: 3; }
}
