/* ========================================
   CSS Variables & Theme
   ======================================== */
:root {
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

    --nav-height: 64px;
    --container-max: 1100px;
    --section-padding: 100px;
}

[data-theme="dark"] {
    --bg-primary: #0c0c0f;
    --bg-secondary: #111115;
    --bg-card: #141418;
    --bg-card-hover: #1c1c22;
    --border: #27272a;
    --border-light: #1f1f23;
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --accent: #10b981;
    --accent-soft: rgba(16, 185, 129, 0.12);
    --accent-glow: rgba(16, 185, 129, 0.22);
    --gradient-start: #10b981;
    --gradient-end: #34d399;
    --tag-bg: rgba(16, 185, 129, 0.1);
    --tag-border: rgba(16, 185, 129, 0.22);
    --tag-text: #34d399;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.55);
    --nav-bg: rgba(12, 12, 15, 0.85);
}

[data-theme="light"] {
    --bg-primary: #f8faf9;
    --bg-secondary: #f0f3f1;
    --bg-card: #ffffff;
    --bg-card-hover: #f2f5f3;
    --border: #e4e4e7;
    --border-light: #ebebef;
    --text-primary: #18181b;
    --text-secondary: #52525b;
    --text-muted: #71717a;
    --accent: #059669;
    --accent-soft: rgba(5, 150, 105, 0.08);
    --accent-glow: rgba(5, 150, 105, 0.18);
    --gradient-start: #059669;
    --gradient-end: #10b981;
    --tag-bg: rgba(5, 150, 105, 0.07);
    --tag-border: rgba(5, 150, 105, 0.18);
    --tag-text: #047857;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.1);
    --nav-bg: rgba(248, 250, 249, 0.85);
}

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

[hidden] {
    display: none !important;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: var(--nav-height);
}

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    transition: background 0.4s var(--ease-out), color 0.3s var(--ease-out);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

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

a:hover { opacity: 0.85; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
[role="tab"]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

::selection {
    background: var(--accent-soft);
    color: var(--accent);
}

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

/* ========================================
   Navigation
   ======================================== */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--gradient-start), var(--gradient-end));
    z-index: 1001;
    transition: width 0.1s linear;
}

.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    z-index: 1000;
    background: var(--nav-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-light);
    transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}

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

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

.nav-logo {
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

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

.nav-links {
    display: flex;
    gap: 8px;
}

.nav-links a {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 8px;
    transition: color 0.2s, background 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--text-primary);
    background: var(--accent-soft);
    opacity: 1;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

[data-theme="dark"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

.btn-lang {
    height: 36px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-lang:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

.nav-menu-toggle {
    display: none;
}

/* ========================================
   Hero
   ======================================== */
.hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding-top: var(--nav-height);
}

.hero-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.grid-pattern {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(var(--border-light) 1px, transparent 1px),
        linear-gradient(90deg, var(--border-light) 1px, transparent 1px);
    background-size: 60px 60px;
    opacity: 0.4;
    mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
    -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
}

.gradient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
}

.orb-1 {
    width: 500px;
    height: 500px;
    background: var(--gradient-start);
    top: -100px;
    right: -100px;
    animation: float 8s ease-in-out infinite;
}

.orb-2 {
    width: 400px;
    height: 400px;
    background: var(--gradient-end);
    bottom: -50px;
    left: -100px;
    animation: float 10s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(30px, -30px); }
}

.hero-content {
    position: relative;
    text-align: center;
    padding: 40px 0;
}

.hero-badge {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 100px;
    border: 1px solid var(--tag-border);
    background: var(--tag-bg);
    color: var(--tag-text);
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 32px;
    animation: fadeInDown 0.8s var(--ease-out) both;
}

.hero-greeting {
    display: block;
    font-size: clamp(1rem, 2vw, 1.25rem);
    font-weight: 400;
    color: var(--text-secondary);
    margin-bottom: 8px;
    animation: fadeInDown 0.8s var(--ease-out) 0.1s both;
}

.hero-title {
    margin-bottom: 16px;
}

.hero-name {
    display: block;
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 800;
    letter-spacing: -2px;
    line-height: 1.1;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: fadeInDown 0.8s var(--ease-out) 0.2s both;
}

.hero-subtitle {
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
    color: var(--accent);
    font-weight: 500;
    min-height: 2em;
    margin-bottom: 20px;
    animation: fadeInDown 0.8s var(--ease-out) 0.3s both;
}

.typed-cursor {
    animation: blink 1s step-end infinite;
    color: var(--accent);
}

@keyframes blink {
    50% { opacity: 0; }
}

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

    .typed-cursor {
        animation: none;
    }

    .reveal {
        opacity: 1 !important;
        transform: none !important;
    }
}

.hero-description {
    max-width: 600px;
    margin: 0 auto 32px;
    color: var(--text-secondary);
    font-size: 1.05rem;
    animation: fadeInDown 0.8s var(--ease-out) 0.4s both;
}

.hero-features-live {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    letter-spacing: 0.02em;
}

.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    flex-shrink: 0;
    animation: live-pulse 2.2s ease-in-out infinite;
}

@keyframes live-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
    50%       { box-shadow: 0 0 0 5px rgba(34, 197, 94, 0); }
}

.hero-features {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 28px;
    animation: fadeInDown 0.8s var(--ease-out) 0.45s both;
}

.hero-feature-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 16px;
    border-radius: 100px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    font-family: var(--font-main);
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
    white-space: nowrap;
    position: relative;
}

.hero-feature-pill[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 400;
    padding: 6px 12px;
    border-radius: 8px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s var(--ease-out);
    box-shadow: var(--shadow);
    z-index: 10;
}

.hero-feature-pill[data-tooltip]:hover::after {
    opacity: 1;
}

.hero-feature-pill:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
    transform: translateY(-2px);
    box-shadow: 0 4px 14px var(--accent-glow);
}

.hero-feature-pill svg {
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.hero-feature-pill:hover svg {
    opacity: 1;
}

.hero-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 48px;
    animation: fadeInDown 0.8s var(--ease-out) 0.5s both;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s var(--ease-out);
    cursor: pointer;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: #fff;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px var(--accent-glow);
    color: #fff;
    opacity: 1;
}

.btn-outline {
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn-outline:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
    opacity: 1;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 48px;
    animation: fadeInUp 0.8s var(--ease-out) 0.6s both;
}

.stat {
    text-align: center;
}

.stat-number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.stat-plus {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 2px;
}

.scroll-indicator {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-muted);
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(8px); }
}

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

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

.section-title {
    font-size: clamp(1.75rem, 3vw, 2.25rem);
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 48px;
    position: relative;
    display: inline-block;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 40px;
    height: 3px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--gradient-start), var(--gradient-end));
}

/* ========================================
   About
   ======================================== */
.about-grid {
    display: grid;
    grid-template-columns: 220px 1fr 1fr;
    gap: 48px;
    align-items: start;
}

.about-photo-col {
    display: flex;
    justify-content: center;
}

.about-photo {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center top;
    border: 3px solid var(--border);
    box-shadow: var(--shadow);
}

.about-text p {
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-size: 1rem;
}

.about-details {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 24px;
}

.detail {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.detail svg {
    color: var(--accent);
    flex-shrink: 0;
}

.about-highlights {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.highlight-card {
    padding: 24px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    transition: all 0.3s var(--ease-out);
}

.highlight-card:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.highlight-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.highlight-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.highlight-card p {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ========================================
   Skills
   ======================================== */
.skills-section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 0;
}

.skills-section-header .section-title {
    margin-bottom: 0;
}

.skills-view-toggle {
    font-size: 13px;
    color: var(--text-muted);
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 14px;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.skills-view-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
}

#skills-viz {
    width: 100%;
    margin-top: 24px;
}

.skills-viz-tooltip {
    position: fixed;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 13px;
    color: var(--text);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 9999;
    white-space: nowrap;
    box-shadow: var(--shadow-lg);
    line-height: 1.5;
}

.skills-viz-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    margin-top: 20px;
    justify-content: center;
}

.skills-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    background: none;
    border: 1px solid transparent;
    border-radius: 20px;
    padding: 4px 10px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.skills-legend-item:hover {
    background: var(--accent-soft);
    color: var(--text);
}

.skills-legend-item.active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--text);
}

.skills-legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.skill-category {
    padding: 24px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    transition: all 0.3s var(--ease-out);
}

.skill-category:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.skill-category-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.skill-category-header svg {
    color: var(--accent);
}

.skill-category-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.skill-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.skill-tag {
    padding: 5px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    background: var(--tag-bg);
    color: var(--tag-text);
    border: 1px solid var(--tag-border);
    transition: all 0.2s;
}

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

/* ========================================
   Timeline (Experience)
   ======================================== */
.timeline {
    position: relative;
    padding-left: 32px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: linear-gradient(to bottom, var(--accent), var(--border));
    border-radius: 1px;
}

.timeline-item {
    position: relative;
    margin-bottom: 40px;
}

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

.timeline-marker {
    position: absolute;
    left: -28px;
    top: 8px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    border: 3px solid var(--bg-primary);
    box-shadow: 0 0 0 2px var(--accent);
}

.timeline-content {
    padding: 24px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    transition: all 0.3s var(--ease-out);
}

.timeline-content:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}

.timeline-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.timeline-org {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 4px;
}

.timeline-date {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: 500;
    white-space: nowrap;
    padding: 4px 12px;
    border-radius: 8px;
    background: var(--accent-soft);
}

.timeline-details {
    list-style: none;
}

.timeline-details li {
    position: relative;
    padding-left: 20px;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.timeline-details li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 10px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.5;
}

.timeline-details li:last-child {
    margin-bottom: 0;
}

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

.project-card {
    padding: 28px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    transition: all 0.3s var(--ease-out);
}

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

.project-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    color: var(--accent);
}

.project-date {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.project-title,
.project-card h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 4px;
    line-height: 1.35;
}

.project-subtitle {
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 12px;
}

.project-desc {
    color: var(--text-secondary);
    font-size: 0.88rem;
    flex: 1;
    margin-bottom: 16px;
}

.project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.project-tags span {
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: var(--font-mono);
    background: var(--tag-bg);
    color: var(--tag-text);
    border: 1px solid var(--tag-border);
}

.project-links {
    display: flex;
    align-items: center;
    gap: 12px;
}

.project-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 500;
}

.project-badge {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 6px;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
}

a.project-badge:hover {
    background: var(--accent);
    color: #fff;
    opacity: 1;
}

.project-wip-badge {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(255, 180, 50, 0.12);
    color: #e0a030;
    font-weight: 500;
    border: 1px solid rgba(255, 180, 50, 0.2);
}

/* ========================================
   Publications
   ======================================== */
/* Publication semantic search */
.pub-search-box {
    margin-bottom: 2rem;
}

.pub-search-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border);
}

.pub-search-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: 0.5rem 1.1rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.pub-search-tab:hover {
    color: var(--text-primary);
}

.pub-search-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.pub-search-bar {
    position: relative;
}

.pub-search-input-wrap {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 1rem;
    gap: 0.5rem;
    margin-top: 0.75rem;
    transition: border-color 0.2s;
}

.pub-search-input-wrap:focus-within {
    border-color: var(--accent);
}

.pub-search-icon {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

#pub-search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    padding: 0.7rem 0;
}

#pub-search-input::placeholder {
    color: var(--text-secondary);
}

.pub-search-clear {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    line-height: 1;
}

.pub-search-clear:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.pub-search-results {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.pub-search-result {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem 1.2rem;
    transition: border-color 0.2s;
}

.pub-search-result:hover {
    border-color: var(--accent);
}

.pub-search-result-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.4rem;
}

.pub-search-result-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
}

.pub-search-result-score {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
    padding: 0.15rem 0.5rem;
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    border-radius: 12px;
    flex-shrink: 0;
}

.pub-search-result-snippet {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pub-search-no-results {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 1rem;
}

/* Q&A answer box */
.pub-ask-answer {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.1rem 1.3rem;
    font-size: 0.88rem;
    line-height: 1.65;
    color: var(--text-primary);
    white-space: pre-wrap;
    min-height: 3rem;
}

.pub-ask-sources {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.pub-ask-sources-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.2rem;
}

.pub-ask-source-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    font-family: inherit;
    color: var(--accent);
    text-decoration: none;
    padding: 0.25rem 0.7rem;
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    border-radius: 20px;
    border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
    transition: background 0.2s;
    width: fit-content;
    cursor: pointer;
}

.pub-ask-source-chip:hover {
    background: color-mix(in srgb, var(--accent) 20%, transparent);
}

/* Streaming cursor */
.pub-ask-cursor {
    display: inline-block;
    color: var(--text-secondary);
    animation: blink 0.8s step-end infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

/* Highlight flash when scrolled to via source button */
@keyframes pub-highlight-flash {
    0%   { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 60%, transparent); }
    100% { box-shadow: none; }
}

.pub-item-highlight {
    animation: pub-highlight-flash 2s ease-out forwards;
    border-radius: 10px;
}

.publications-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pub-item {
    display: flex;
    align-items: baseline;
    gap: 24px;
    padding: 20px 24px;
    border-radius: 12px;
    transition: background 0.2s;
}

.pub-item:hover {
    background: var(--bg-card);
}

.pub-year {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--accent);
    min-width: 48px;
}

.pub-title,
.pub-content h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 4px;
    line-height: 1.4;
}

.pub-venue {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.pub-authors {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.pub-abstract {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 6px;
    line-height: 1.6;
}

.pub-links {
    margin-top: 6px;
    font-size: 0.82rem;
}

.section-see-more {
    text-align: center;
    margin-top: 32px;
}

.pub-links a {
    font-weight: 500;
}

/* ========================================
   Education
   ======================================== */
.education-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.edu-card {
    display: flex;
    gap: 24px;
    padding: 28px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    transition: all 0.3s var(--ease-out);
}

.edu-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
}

.edu-year {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    min-width: 80px;
}

.edu-content h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.edu-org {
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 8px;
}

.edu-thesis {
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-style: italic;
    margin-bottom: 6px;
}

.edu-details {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ========================================
   Standalone Pages
   ======================================== */
.page-section {
    padding-top: 100px;
}

.page-intro {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    max-width: 640px;
}

.page-return {
    margin-top: 48px;
}

.nav-return-btn {
    font-size: 0.82rem;
    padding: 6px 14px;
}

/* ========================================
   Formation Page
   ======================================== */
.formation-list {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    max-width: 800px;
}

.formation-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    transition: border-color 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out);
}

.formation-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
}

.formation-card-inner {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.formation-content {
    flex: 1;
    min-width: 200px;
}

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

.formation-badge {
    background: var(--text-secondary);
    color: var(--bg-primary);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.formation-badge-primary {
    background: var(--accent);
    color: #fff;
}

.formation-date {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.formation-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.formation-specialty {
    font-size: 0.9rem;
    color: var(--accent);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.formation-school {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.formation-subtitle {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.formation-thesis-title {
    font-size: 0.92rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.formation-thesis-title a {
    color: var(--text-primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.formation-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1rem;
}

.formation-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.formation-card .skill-tag {
    font-size: 0.78rem;
    padding: 3px 8px;
    border-radius: 4px;
}

.formation-links {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.formation-links .project-link {
    font-size: 0.85rem;
}

/* ========================================
   Contact
   ======================================== */
.contact-container {
    text-align: center;
}

.contact-text {
    color: var(--text-secondary);
    max-width: 500px;
    margin: 0 auto 32px;
    font-size: 1.05rem;
}

.contact-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 40px;
}

.contact-available-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.contact-cv-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.contact-cv-btn::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='7 10 12 15 17 10'/%3E%3Cline x1='12' y1='15' x2='12' y2='3'/%3E%3C/svg%3E") no-repeat center;
    background-size: contain;
}

.contact-links {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.contact-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 28px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    transition: all 0.3s var(--ease-out);
    font-weight: 500;
    font-size: 0.9rem;
}

.contact-card svg {
    color: var(--accent);
}

.contact-card:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    color: var(--accent);
    opacity: 1;
}

.contact-card-email {
    padding: 0;
    overflow: hidden;
}

.contact-card-email-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    flex: 1;
    color: inherit;
    font-weight: 500;
    font-size: 0.9rem;
}

.contact-card-email-link svg {
    color: var(--accent);
    flex-shrink: 0;
}

.copy-email-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    border: none;
    border-left: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
    align-self: stretch;
    font-family: var(--font-main);
}

.copy-email-btn:hover {
    color: var(--accent);
    background: var(--accent-soft);
}

.copy-email-btn.copied {
    color: #22c55e;
}

/* ========================================
   Footer
   ======================================== */
.footer {
    padding: 32px 0;
    border-top: 1px solid var(--border-light);
}

.footer-content {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 0.85rem;
    gap: 12px 0;
}

.footer-star {
    width: 100%;
    text-align: center;
    margin: 0;
}

.footer-star-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.82rem;
    transition: color 0.2s;
}

.footer-star-link svg {
    color: #f5c518;
    flex-shrink: 0;
}

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

.footer-nav {
    display: flex;
    gap: 20px;
}

.footer-nav a {
    color: var(--text-muted);
    transition: color 0.2s;
}

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

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

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

.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ========================================
   Mobile Menu
   ======================================== */
.nav-links.open {
    display: flex;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 900px) {
    :root {
        --section-padding: 72px;
    }

    .nav-links {
        display: none;
        position: fixed;
        top: var(--nav-height);
        left: 0;
        right: 0;
        background: var(--nav-bg);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        flex-direction: column;
        padding: 16px;
        border-bottom: 1px solid var(--border);
        gap: 4px;
    }

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

    .nav-menu-toggle {
        display: flex;
    }

    .about-grid {
        grid-template-columns: 1fr 1fr;
        gap: 32px;
    }

    .about-photo-col {
        grid-column: 1 / -1;
    }

    .about-photo {
        width: 160px;
        height: 160px;
    }

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

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

    .hero-stats {
        gap: 24px;
    }

    .timeline-header {
        flex-direction: column;
        gap: 8px;
    }

    .edu-card {
        flex-direction: column;
        gap: 12px;
    }

    .contact-links {
        flex-direction: column;
        align-items: center;
    }

    .pub-item {
        flex-direction: column;
        gap: 6px;
        padding: 16px;
    }
}

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

    .about-photo-col {
        grid-column: 1;
    }

    :root {
        --section-padding: 48px;
    }

    /* Orbs — prevent horizontal overflow on small screens */
    .orb-1 {
        width: 250px;
        height: 250px;
    }

    .orb-2 {
        width: 200px;
        height: 200px;
    }

    .hero-actions {
        flex-direction: column;
        align-items: center;
    }

    .hero-stats {
        flex-direction: column;
        gap: 16px;
    }

    .stat-number {
        font-size: 1.5rem;
    }

    /* pub-search tabs — smaller text on narrow screens */
    .pub-search-tab {
        font-size: 0.8rem;
        padding: 0.4rem 0.7rem;
    }

    /* Matcher tabs — full width so they don't overflow */
    .matcher-tabs {
        width: 100%;
    }

    .matcher-tab {
        flex: 1;
        text-align: center;
    }

    /* Touch targets — 44px min per WCAG */
    .chat-send,
    .skills-submit {
        width: 44px;
        height: 44px;
    }

    /* Bottom padding so floating buttons don't overlap page content */
    body {
        padding-bottom: 88px;
    }
}

/* ========================================
   Job Matcher
   ======================================== */
.matcher-subtitle {
    text-align: center;
    color: var(--text-secondary);
    max-width: 600px;
    margin: -24px auto 40px;
    font-size: 1rem;
}

/* Daily AI news digest */
.news-subtitle {
    text-align: center;
    color: var(--text-secondary);
    max-width: 640px;
    margin: -24px auto 40px;
    font-size: 1rem;
}

.news-tabs {
    display: flex;
    gap: 6px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 10px;
    width: fit-content;
    margin: 0 auto 20px;
}

/* En-tête de la section veille : onglets centrés (colonne du milieu), RSS aligné à droite
   sur la largeur du contenu (760px) pour rester cohérent avec les cartes. */
.news-head {
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
    max-width: 760px; margin: 0 auto 20px;
}
.news-head .news-tabs { grid-column: 2; margin: 0; }
.news-rss-wrap { grid-column: 3; justify-self: end; position: relative; }
.news-rss {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 13px; color: var(--text-secondary);
    padding: 5px 12px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg-card); cursor: pointer; font-family: var(--font-main);
    transition: color .15s, border-color .15s;
}
.news-rss:hover { color: var(--accent); border-color: var(--accent); }

/* Popover « s'abonner ». */
.news-rss-pop {
    position: absolute; top: calc(100% + 8px); right: 0; z-index: 30;
    width: 280px; max-width: 80vw; text-align: left;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: var(--shadow); padding: 14px;
}
.news-rss-hint { font-size: 12px; color: var(--text-secondary); margin: 0 0 8px; line-height: 1.5; }
.news-rss-row { display: flex; gap: 6px; }
#news-rss-url {
    flex: 1; min-width: 0; font-size: 12px; font-family: var(--font-mono);
    padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg-secondary); color: var(--text-primary);
}
#news-rss-copy {
    flex: 0 0 auto; font-size: 12px; padding: 6px 12px; border: none; border-radius: 8px;
    background: var(--accent); color: #fff; cursor: pointer; font-family: var(--font-main);
}
.news-rss-raw { display: inline-block; margin-top: 10px; font-size: 12px; color: var(--accent); text-decoration: none; }
.news-rss-raw:hover { text-decoration: underline; }

.news-tab {
    padding: 6px 20px;
    border-radius: 7px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    font-family: var(--font-main);
}

.news-tab.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.news-card {
    max-width: 760px;
    margin: 0 auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.news-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}

/* Carte de digest repliable : l'en-tête (date/compteur) sert de bouton plier/déplier. */
.news-fold > summary.news-meta { cursor: pointer; justify-content: flex-start; list-style: none; }
.news-fold > summary.news-meta::-webkit-details-marker { display: none; }
.news-fold > summary .news-count { margin-left: auto; }
.news-fold > summary.news-meta::after {
    content: "⌄";
    margin-left: 12px;
    font-size: 14px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}
.news-fold[open] > summary.news-meta::after { transform: rotate(180deg); }
.news-fold > summary.news-meta:hover::after { color: var(--accent); }
/* Replié : pas de bordure ni d'espace résiduels sous l'en-tête. */
.news-fold:not([open]) > summary.news-meta { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }

.news-date {
    font-weight: 600;
    color: var(--text-primary);
}
.news-date::first-letter { text-transform: uppercase; }

.news-count {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--accent);
    background: var(--accent-soft);
    border: 1px solid var(--tag-border);
    padding: 2px 10px;
    border-radius: 999px;
}

.news-status {
    color: var(--text-muted);
    text-align: center;
    padding: 24px 0;
}
.news-error { color: var(--text-secondary); }

/* Markdown du résumé (mêmes règles visuelles que le matcher) */
.news-summary h3 { font-size: 1.05rem; color: var(--text-primary); margin: 22px 0 10px; }
.news-summary h3:first-child { margin-top: 0; }
.news-summary h4 { font-size: 0.95rem; color: var(--text-primary); margin: 16px 0 8px; }
.news-summary p { color: var(--text-secondary); margin: 0 0 10px; line-height: 1.65; }
.news-summary ul, .news-summary ol { margin: 4px 0 14px; padding-left: 20px; color: var(--text-secondary); }
.news-summary li { margin-bottom: 6px; line-height: 1.6; }
.news-summary li > ul, .news-summary li > ol { margin: 6px 0 4px; }
.news-summary strong { color: var(--text-primary); font-weight: 600; }
.news-summary a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--tag-border); }
.news-summary a:hover { border-bottom-color: var(--accent); }
.news-summary code { font-family: var(--font-mono); font-size: 12px; background: var(--accent-soft); color: var(--accent); padding: 1px 5px; border-radius: 3px; }
.news-summary hr { border: none; border-top: 1px solid var(--border-light); margin: 18px 0; }
.news-cite {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.82em;
    vertical-align: super;
    padding: 0 1px;
}
.news-cite:hover { text-decoration: underline; }

.news-sources {
    margin-top: 18px;
    border-top: 1px solid var(--border-light);
    padding-top: 14px;
}
.news-sources > summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
    list-style: none;
}
.news-sources > summary::-webkit-details-marker { display: none; }
.news-sources > summary::before {
    content: '▸';
    color: var(--accent);
    margin-right: 8px;
    display: inline-block;
    transition: transform 0.2s var(--ease-out);
}
.news-sources[open] > summary::before { transform: rotate(90deg); }
.news-sources-list { margin: 14px 0 0; padding-left: 22px; }
.news-sources-list li { margin-bottom: 8px; line-height: 1.5; color: var(--text-secondary); }
.news-sources-list a { color: var(--text-primary); text-decoration: none; border-bottom: 1px solid var(--tag-border); }
.news-sources-list a:hover { color: var(--accent); }
.news-source-host { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); margin-left: 4px; }
.news-source-date { font-size: 11px; color: var(--text-muted); margin-left: 4px; white-space: nowrap; }

/* Bande de jours partagée (chips), façon carrousel avec flèches. */
.news-daystrip-wrap {
    display: flex; align-items: center; gap: 6px;
    max-width: 760px; margin: 0 auto 18px;
}
.news-daystrip {
    display: flex; gap: 8px; flex: 1; min-width: 0;
    overflow-x: auto; padding: 4px 2px;
    scrollbar-width: thin; scroll-behavior: smooth;
    scroll-snap-type: x proximity;
}
.news-day { scroll-snap-align: end; }
.news-day-nav {
    flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%;
    border: 1px solid var(--border); background: var(--bg-card); color: var(--text-secondary);
    cursor: pointer; font-size: 18px; line-height: 1; display: flex; align-items: center; justify-content: center;
    transition: border-color .15s, color .15s, opacity .15s;
}
.news-day-nav:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.news-day-nav:disabled { opacity: .35; cursor: default; }
.news-day {
    flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 1px;
    min-width: 58px; padding: 7px 10px;
    border: 1px solid var(--border); border-radius: 12px;
    background: var(--bg-card); color: var(--text-secondary);
    cursor: pointer; font-family: var(--font-main);
    transition: border-color .15s, color .15s, background .15s;
}
.news-day:hover { border-color: var(--accent); color: var(--text-primary); }
.news-day.active { border-color: var(--accent); background: var(--accent-soft); color: var(--text-primary); }
.news-day-wd { font-size: 11px; text-transform: capitalize; color: var(--text-muted); }
.news-day.active .news-day-wd { color: var(--accent); }
.news-day-dm { font-size: 13px; font-weight: 600; }
.news-day-count {
    margin-top: 2px; font-family: var(--font-mono); font-size: 10px;
    color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 0 5px;
}
.news-day.active .news-day-count { background: var(--bg-card); }
.news-day-count.zero { color: var(--text-muted); background: transparent; padding: 0; }
/* Dimanche = jour de récap hebdo : petit logo en coin + bordure accentuée. */
.news-day { position: relative; }
.news-day.recap { border-color: var(--accent); }
.news-day-recap {
    position: absolute; top: 3px; right: 4px;
    display: inline-flex; color: var(--accent); pointer-events: none;
}
.news-day-recap svg { width: 11px; height: 11px; }
/* Badge de fraîcheur dans l'en-tête du digest. */
.news-fresh { font-size: 11px; color: var(--text-muted); margin-left: 10px; white-space: nowrap; }
.news-fresh.stale { color: #d97706; font-weight: 600; }

@media (max-width: 600px) {
    .news-card { padding: 20px; }
}

.matcher-card {
    max-width: 720px;
    margin: 0 auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.matcher-tabs {
    display: flex;
    gap: 6px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 10px;
    width: fit-content;
}

.matcher-tab {
    padding: 6px 18px;
    border-radius: 7px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    font-family: var(--font-main);
}

.matcher-tab.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.matcher-input {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-main);
    line-height: 1.6;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}

.matcher-input:focus { border-color: var(--accent); }
.matcher-input::placeholder { color: var(--text-muted); }

.matcher-url-input {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-main);
    outline: none;
    transition: border-color 0.2s;
}

.matcher-url-input:focus { border-color: var(--accent); }
.matcher-url-input::placeholder { color: var(--text-muted); }

.matcher-url-note {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

.matcher-btn { align-self: flex-start; }
.matcher-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.matcher-result {
    max-width: 720px;
    margin: 24px auto 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px 32px;
    box-shadow: var(--shadow);
    animation: chat-msg-in 0.25s var(--ease-out);
}

.matcher-result h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 20px 0 8px;
}

.matcher-result h3:first-child { margin-top: 0; }

.matcher-result p { color: var(--text-secondary); margin: 0 0 8px; line-height: 1.65; }
.matcher-result p:last-child { margin-bottom: 0; }
.matcher-result ul, .matcher-result ol { margin: 4px 0 10px; padding-left: 20px; color: var(--text-secondary); }
.matcher-result li { margin-bottom: 4px; line-height: 1.55; }
.matcher-result strong { color: var(--text-primary); font-weight: 600; }
.matcher-result code { font-family: var(--font-mono); font-size: 12px; background: var(--accent-soft); color: var(--accent); padding: 1px 5px; border-radius: 3px; }

.matcher-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 14px;
}

.matcher-error {
    color: #f87171;
    font-size: 14px;
}

.matcher-draft-trigger {
    margin-top: 20px;
    display: block;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.matcher-draft {
    max-width: 720px;
    margin: 16px auto 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
    animation: chat-msg-in 0.25s var(--ease-out);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.matcher-draft-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin: 0;
}

.matcher-draft-textarea {
    width: 100%;
    min-height: 220px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-main);
    line-height: 1.65;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}

.matcher-draft-textarea:focus { border-color: var(--accent); }

.matcher-draft-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.matcher-draft-hint {
    font-size: 12px;
    color: var(--text-muted);
}

.matcher-result hr, .chat-msg hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 12px 0;
}

/* ========================================
   Chat Widget
   ======================================== */
.chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px var(--accent-glow), var(--shadow);
    transition: transform 0.3s var(--ease-out), box-shadow 0.3s;
    z-index: 1000;
    color: white;
}

.chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px var(--accent-glow), var(--shadow-lg);
}

.chat-icon-open,
.chat-icon-close {
    position: absolute;
    transition: opacity 0.2s, transform 0.2s;
}

.chat-icon-close {
    opacity: 0;
    transform: scale(0.6) rotate(45deg);
}

.chat-toggle.open .chat-icon-open {
    opacity: 0;
    transform: scale(0.6) rotate(-45deg);
}

.chat-toggle.open .chat-icon-close {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

.chat-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 360px;
    max-height: 520px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    z-index: 999;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.25s var(--ease-out), transform 0.25s var(--ease-out);
}

.chat-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.panel-close-btn { display: none; }

.chat-header {
    padding: 14px 18px;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chat-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.skills-header-avatar {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
}

.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name { font-weight: 600; font-size: 15px; line-height: 1.2; }

.chat-header-status {
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.chat-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    flex-shrink: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: chat-msg-in 0.2s var(--ease-out);
}

@keyframes chat-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chat-msg-baptiste {
    align-self: flex-start;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-bottom-left-radius: 4px;
    color: var(--text-primary);
}

.chat-msg p { margin: 0 0 6px; }
.chat-msg p:last-child { margin-bottom: 0; }
.chat-msg ul, .chat-msg ol { margin: 4px 0 6px; padding-left: 18px; }
.chat-msg li { margin-bottom: 2px; }
.chat-msg strong { font-weight: 600; }
.chat-msg em { font-style: italic; }
.chat-msg code { font-family: var(--font-mono); font-size: 12px; background: rgba(0,0,0,0.12); padding: 1px 5px; border-radius: 3px; }
.chat-msg-user code { background: rgba(255,255,255,0.2); }
.chat-msg a { color: inherit; text-decoration: underline; opacity: 0.85; }

.chat-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-typing {
    align-self: flex-start;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    padding: 12px 16px;
    display: flex;
    gap: 5px;
    align-items: center;
}

.chat-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typing-bounce 1.1s infinite ease-in-out;
}

.chat-typing-dot:nth-child(2) { animation-delay: 0.18s; }
.chat-typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

.chat-footer {
    padding: 10px 14px;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 13px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-main);
    resize: none;
    outline: none;
    line-height: 1.45;
    max-height: 96px;
    overflow-y: auto;
    transition: border-color 0.2s;
}

.chat-input:focus { border-color: var(--accent); }
.chat-input::placeholder { color: var(--text-muted); }

.chat-send {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    transition: opacity 0.2s, transform 0.15s;
}

.chat-send:hover:not(:disabled) { opacity: 0.88; transform: scale(1.05); }
.chat-send:disabled { opacity: 0.38; cursor: not-allowed; }


.back-to-top {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    box-shadow: var(--shadow);
    z-index: 1000;
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 0.25s var(--ease-out), transform 0.25s var(--ease-out), border-color 0.2s, color 0.2s, background 0.2s, box-shadow 0.2s;
}

.back-to-top.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.back-to-top:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 4px 14px var(--accent-glow);
}

.skills-toggle {
    position: fixed;
    bottom: 24px;
    right: 92px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px var(--accent-glow), var(--shadow);
    transition: transform 0.25s var(--ease-out), box-shadow 0.25s, background 0.2s;
    z-index: 1000;
    color: var(--accent);
}

.skills-toggle:hover {
    transform: scale(1.1);
    background: var(--accent-soft);
    box-shadow: 0 4px 20px var(--accent-glow), var(--shadow-lg);
}

.skills-toggle.open {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 20px var(--accent-glow), var(--shadow);
}

.skills-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    transform-origin: bottom right;
    width: 360px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    z-index: 999;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px) scale(0.97);
    transition: opacity 0.25s var(--ease-out), transform 0.25s var(--ease-out);
}

.skills-panel.open {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

.skills-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.skills-hint {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.5;
}

.skills-input-row {
    display: flex;
    gap: 8px;
}

.skills-input {
    flex: 1;
    padding: 9px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.skills-input:focus { border-color: var(--accent); }
.skills-input::placeholder { color: var(--text-muted); }

.skills-submit {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    transition: opacity 0.2s, transform 0.2s;
}

.skills-submit:hover:not(:disabled) { opacity: 0.88; transform: scale(1.05); }
.skills-submit:disabled { opacity: 0.38; cursor: not-allowed; }

.skills-result {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    max-height: 340px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.skills-result:empty { display: none; }

.skills-result-muted {
    color: var(--text-muted);
}

.skills-result h2 {
    font-size: 15px;
    font-weight: 600;
    margin: 12px 0 4px;
    color: var(--text);
}

.skills-result h2:first-child { margin-top: 0; }

.skills-result strong { font-weight: 600; }
.skills-result p { margin: 0 0 6px; }
.skills-result p:last-child { margin-bottom: 0; }
.skills-result ul { margin: 4px 0 6px; padding-left: 18px; }
.skills-result li { margin-bottom: 2px; }

@media (max-width: 480px) {
    .chat-panel {
        bottom: 0;
        right: 0;
        width: 100%;
        max-height: 85vh;
        border-radius: 20px 20px 0 0;
    }

    .chat-toggle {
        bottom: 20px;
        right: 16px;
    }

    .skills-toggle {
        bottom: 20px;
        right: 82px;
    }

    .skills-panel {
        bottom: 0;
        right: 0;
        width: 100%;
        max-height: 85vh;
        border-radius: 20px 20px 0 0;
    }

    /* Close button in panel header — mobile only */
    .panel-close-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(255,255,255,0.15);
        border: none;
        border-radius: 50%;
        width: 32px;
        height: 32px;
        color: white;
        cursor: pointer;
        flex-shrink: 0;
        margin-left: auto;
        transition: background 0.2s;
    }

    .panel-close-btn:hover {
        background: rgba(255,255,255,0.25);
    }

    /* Hide floating buttons when a panel is open — bottom sheet pattern */
    .chat-toggle.open,
    body:has(.chat-panel.open) .skills-toggle,
    .skills-toggle.open,
    body:has(.skills-panel.open) .chat-toggle {
        opacity: 0;
        pointer-events: none;
        transform: scale(0.8);
        transition: opacity 0.2s, transform 0.2s;
    }
}
