:root {
    /* Colors: warm white with an emerald lead, plus crimson and gold
       secondaries used for categories and stats. */
    --bg-color: #FAFAF7;
    --text-primary: #1A1A18;
    --text-muted: #57574F;
    --accent-color: #047857;
    --accent-hover: #065F46;
    --border-color: #DEDCD5;

    --joy-rose: #BE123C;
    --joy-gold: #A16207;
    --joy-stone: #44403C;
    --joy-rose-tint: rgba(225, 29, 72, 0.09);
    --joy-gold-tint: rgba(234, 179, 8, 0.16);
    --joy-stone-tint: rgba(68, 64, 60, 0.08);

    /* Typography */
    --font-heading: 'Source Serif 4', serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Spacing */
    --baseline: 1.5rem;
    --container-width: 900px;
    --sidebar-width: 264px;
    --header-bg: rgba(250, 250, 247, 0.95);
    --table-hover: rgba(0, 0, 0, 0.03);

    /* Shape: square corners everywhere */
    --radius-sm: 0;
    --radius-md: 0;
    --radius-lg: 0;
    --radius-pill: 0;

    /* Surfaces */
    --sidebar-bg: #F1F0EB;
    --surface: #FFFFFF;
    --surface-2: #F3F2ED;
    --surface-hover: rgba(4, 120, 87, 0.06);
    --accent-tint: rgba(4, 120, 87, 0.1);
    --ink: #047857; /* active states: solid accent block */
    --ink-contrast: #FFFFFF;
}

[data-theme="dark"] {
    --bg-color: #111110;
    --text-primary: #ECEBE6;
    --text-muted: #A8A69E;
    --accent-color: #6EE7B7;
    --accent-hover: #A7F3D0;
    --border-color: #2E2D2A;
    --header-bg: rgba(17, 17, 16, 0.95);
    --table-hover: rgba(255, 255, 255, 0.05);

    --joy-rose: #FDA4AF;
    --joy-gold: #FDE047;
    --joy-stone: #D6D3D1;
    --joy-rose-tint: rgba(253, 164, 175, 0.12);
    --joy-gold-tint: rgba(253, 224, 71, 0.12);
    --joy-stone-tint: rgba(214, 211, 209, 0.1);

    --sidebar-bg: #151514;
    --surface: #1A1A19;
    --surface-2: #232321;
    --surface-hover: rgba(110, 231, 183, 0.07);
    --accent-tint: rgba(110, 231, 183, 0.12);
    --ink: #6EE7B7;
    --ink-contrast: #111110;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: var(--baseline);
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Set while the mobile nav drawer is open, to stop the page scrolling
   behind it. Has no effect on desktop, where the drawer toggle is hidden. */
body.nav-locked {
    overflow: hidden;
}

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-primary);
}

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

a:hover, a:focus {
    color: var(--accent-hover);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
}

a:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Typography Utilities */
.mono {
    font-family: var(--font-mono);
}

/* Skip link: hidden until keyboard-focused, so keyboard/AT users and
   crawlers can bypass the sidebar nav straight to the main content. */
.skip-link {
    position: absolute;
    top: -3rem;
    left: 0;
    background-color: var(--accent-color);
    color: #fff;
    padding: 0.6rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    z-index: 1000;
    transition: top 0.15s ease;
}

.skip-link:focus {
    top: 0;
}

/* Sidebar. Mobile-first: an off-canvas drawer, closed by default and
   toggled via the hamburger button's .nav-open class. The
   min-width:1024px block below docks it as a permanent left column. */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(86vw, 300px);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    box-shadow: 4px 0 28px rgba(0, 0, 0, 0.18);
    overflow-y: auto;
    z-index: 190;
    transform: translateX(-100%);
    /* Hidden while closed so its links leave the tab order and its shadow
       doesn't bleed onto the page edge; visibility flips only after the
       slide-out finishes. */
    visibility: hidden;
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s linear 0.28s;
}

.site-header.nav-open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.header-inner {
    min-height: 100%;
    /* Extra top clearance on mobile so content starts below the floating
       hamburger button; tightened once that button is hidden. */
    padding: 5rem 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2.25rem;
}

/* Profile */
.sidebar-profile {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.sidebar-profile:hover,
.sidebar-profile:focus-visible {
    color: var(--text-primary);
    text-decoration: none;
}

.profile-name {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.01em;
}

.profile-role {
    font-family: var(--font-mono);
    font-size: 0.64rem;
    font-weight: 500;
    line-height: 1.5;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent-color);
}

/* Navigation */
.site-nav {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.nav-label {
    padding: 0 0.75rem;
    margin-bottom: 0.2rem;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.site-nav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.site-nav-list a {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    width: 100%;
    padding: 0.6rem 0.75rem;
    border-left: 2px solid transparent;
    font-family: var(--font-body);
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.nav-num {
    min-width: 1.35rem;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    color: var(--text-muted);
    transition: color 0.18s ease;
}

.site-nav-list a:hover,
.site-nav-list a:focus-visible {
    color: var(--text-primary);
    text-decoration: none;
    background-color: var(--surface-hover);
}

/* Current section: an ink block, the same treatment as active filters. */
.site-nav-list a.active {
    color: var(--ink-contrast);
    background-color: var(--ink);
    border-left-color: var(--accent-color);
}

.site-nav-list a.active .nav-num {
    color: var(--ink-contrast);
    opacity: 0.7;
}

.nav-divider {
    margin: 1.1rem 0.75rem 0.8rem;
    border: 0;
    border-top: 1px dashed var(--border-color);
}

.site-links a {
    color: var(--text-muted);
}

/* Outbound-link marker: a small square box with an arrow, used on every
   external link. Sized in em so it follows the surrounding text. */
.ext-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1.35em;
    height: 1.35em;
    margin-left: 0.35em;
    vertical-align: -0.3em;
    border: 1px solid currentColor;
    opacity: 0.55;
    transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
}

.ext-arrow svg {
    width: 0.75em;
    height: 0.75em;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: square;
}

a:hover > .ext-arrow,
a:focus-visible > .ext-arrow {
    opacity: 1;
    color: var(--ink-contrast);
    background-color: var(--ink);
    border-color: var(--ink);
}

.site-links .ext-arrow {
    margin-left: auto;
    font-size: 0.85rem;
}

/* Theme switch: a "Dark mode" label with a small square track. */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-top: auto;
    padding: 0.85rem 0.75rem 0;
    border: 0;
    border-top: 1px solid var(--border-color);
    background: none;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    transition: color 0.18s ease;
}

.theme-toggle:hover {
    color: var(--text-primary);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 4px;
}

.theme-label {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.theme-icon {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

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

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

.theme-switch {
    position: relative;
    width: 34px;
    height: 18px;
    border: 1px solid var(--text-muted);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.theme-switch-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 10px;
    height: 10px;
    background-color: var(--text-muted);
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), background-color 0.2s ease;
}

[data-theme="dark"] .theme-switch {
    background-color: var(--ink);
    border-color: var(--ink);
}

[data-theme="dark"] .theme-switch-knob {
    transform: translateX(16px);
    background-color: var(--ink-contrast);
}

/* Honor reduced motion site-wide: every animation and transition,
   including the drawer slide and hover effects. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}

main {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 1.5rem 4rem;
}

/* Clears the floating hamburger button below the desktop breakpoint. */
.page-body {
    padding-top: 4rem;
}

/* Hamburger trigger — floats top-left, independent of the drawer's own
   open/closed state so it stays reachable to toggle either way. */
.nav-toggle {
    display: flex;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 210;
    width: 2.75rem;
    height: 2.75rem;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background-color: var(--surface);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.nav-toggle:hover {
    border-color: var(--text-primary);
}

.nav-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background-color: var(--text-primary);
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
}

.nav-toggle[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.45);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.nav-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Desktop: dock the sidebar permanently and drop the drawer chrome.
   Below 1024px the drawer is used instead, so tablets keep full-width
   content rather than a column squeezed beside a fixed sidebar. */
@media (min-width: 1024px) {
    .site-header {
        width: var(--sidebar-width);
        box-shadow: none;
        transform: none;
        visibility: visible;
    }

    .header-inner {
        padding: 3rem 1.25rem 1.5rem;
    }

    .page-body {
        margin-left: var(--sidebar-width);
        padding-top: 2.5rem;
    }

    .nav-toggle,
    .nav-backdrop {
        display: none;
    }
}

/* Sections */
section {
    padding: 4rem 0;
    border-bottom: 1px solid var(--border-color);
}

section:last-of-type {
    border-bottom: none;
}

.section-header {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 2rem;
}

.section-number {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-color);
}

.section-header h2 {
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Shared building blocks. Every card, tag, chip and pill on the page is
   one of these, so the site reads as a single system:
   - cards: one surface, border and radius
   - tags: small uppercase mono labels, neutral or accent-tinted
   - chips: case-preserving mono labels (tech stack, focus areas)
   - buttons: filters and back-to-top; active = solid accent block, the
     same treatment as the sidebar's current section and theme switch
   Categories and stats pick up the crimson and gold secondaries. */
.hero-stat-card,
.featured-card,
.calendar,
.project-list-container,
.research-list-container {
    background-color: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.system-badge,
.tag,
.table-domain-badge,
.research-badge-patent,
.research-badge-paper {
    display: inline-flex;
    align-items: center;
    padding: 0.22rem 0.55rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--surface-2);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.system-badge,
.table-domain-badge.badge-agent {
    color: var(--accent-color);
    background-color: var(--accent-tint);
    border-color: transparent;
}

[data-category="vision-multimodal"] .table-domain-badge,
.research-badge-paper {
    color: var(--joy-rose);
    background-color: var(--joy-rose-tint);
    border-color: transparent;
}

[data-category="ml-data"] .table-domain-badge,
.research-badge-patent {
    color: var(--joy-gold);
    background-color: var(--joy-gold-tint);
    border-color: transparent;
}

[data-category="systems-edge"] .table-domain-badge {
    color: var(--joy-stone);
    background-color: var(--joy-stone-tint);
    border-color: transparent;
}

.focus-chip,
.tech-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.22rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--surface-2);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    line-height: 1.5;
}

.tech-pill {
    color: var(--text-muted);
}

.filter-btn,
.back-to-top-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    background-color: var(--surface);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.filter-btn:hover,
.back-to-top-btn:hover {
    color: var(--accent-color);
    border-color: var(--accent-color);
    text-decoration: none;
}

.filter-btn.active {
    color: var(--ink-contrast);
    background-color: var(--ink);
    border-color: var(--ink);
}

.filter-btn .btn-count {
    font-weight: 500;
    opacity: 0.7;
}

/* Hero */
.hero-section {
    padding: 3rem 0 2.5rem;
}

.hero-main-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2.5rem;
    margin-bottom: 2rem;
}

.hero-header {
    flex-grow: 1;
}

.hero-name {
    margin-bottom: 0.6rem;
    font-family: var(--font-heading);
    font-size: 2.8rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}

.hero-subtitle {
    margin-bottom: 1rem;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-color);
}

.hero-bio {
    max-width: 640px;
    font-size: 1.02rem;
    line-height: 1.65;
    color: var(--text-muted);
}

.hero-sticker-container {
    flex-shrink: 0;
}

.hero-sticker-img {
    width: 180px;
    height: 180px;
    object-fit: cover;
    border: 1px solid var(--border-color);
}

.hero-sticker-img.sticker-dark {
    display: none;
}

.hero-sticker-img.sticker-light {
    display: block;
}

[data-theme="dark"] .hero-sticker-img.sticker-dark {
    display: block;
}

[data-theme="dark"] .hero-sticker-img.sticker-light {
    display: none;
}


.hero-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.hero-stat-card {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 1.15rem 1.25rem;
    color: var(--text-primary);
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.hero-stat-card {
    --stat-color: var(--accent-color);
    --stat-tint: var(--accent-tint);
    border-top: 3px solid var(--stat-color);
}

.hero-stat-card:nth-child(2) {
    --stat-color: var(--joy-rose);
    --stat-tint: var(--joy-rose-tint);
}

.hero-stat-card:nth-child(3) {
    --stat-color: var(--joy-gold);
    --stat-tint: var(--joy-gold-tint);
}

.hero-stat-card .stat-number {
    color: var(--stat-color);
}

.hero-stat-card:hover,
.hero-stat-card:focus-visible {
    color: var(--text-primary);
    text-decoration: none;
    border-color: var(--stat-color);
    background-color: var(--stat-tint);
}

.stat-number {
    font-family: var(--font-body);
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

.stat-label,
.focus-label,
.arch-highlight-title {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.stat-detail {
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--text-muted);
}

.hero-focus-areas {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

.focus-label {
    margin-right: 0.4rem;
}

/* Featured Projects */
.featured-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}

.featured-card {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    transition: border-color 0.2s ease;
}

.featured-card {
    border-top: 3px solid var(--accent-color);
}

.featured-card:hover {
    border-color: var(--accent-color);
    background-color: var(--surface-hover);
}

.card-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.featured-card .repo-name {
    margin-bottom: 0.45rem;
    font-family: var(--font-body);
    font-size: 1.12rem;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.01em;
    word-break: break-word;
}

.featured-card .repo-name a {
    color: var(--text-primary);
}

.featured-card .repo-name a:hover {
    color: var(--accent-color);
    text-decoration: none;
}

.featured-card .repo-desc {
    margin-bottom: 1rem;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-muted);
}

.arch-highlight {
    margin-bottom: 1.25rem;
    padding: 0.75rem 0.9rem;
    border-left: 3px solid var(--accent-color);
    background-color: var(--surface-2);
    font-size: 0.84rem;
    line-height: 1.5;
    color: var(--text-primary);
}

.arch-highlight-title {
    display: block;
    margin-bottom: 0.3rem;
}

.tech-stack-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: auto;
    margin-bottom: 1.25rem;
}

.repo-links {
    display: flex;
    gap: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
}

/* GitHub Contributions */
.calendar {
    --color-calendar-graph-day-bg: #ebedf0;
    --color-calendar-graph-day-L1-bg: #9be9a8;
    --color-calendar-graph-day-L2-bg: #40c463;
    --color-calendar-graph-day-L3-bg: #30a14e;
    --color-calendar-graph-day-L4-bg: #216e39;
    --calendar-cell-border: rgba(27, 31, 35, 0.08);
    padding: 1.25rem 1.5rem;
    color: var(--text-primary);
    overflow-x: auto;
}

.calendar-loading {
    padding: 2rem 0;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.calendar-graph {
    min-width: 700px;
}

.calendar rect.ContributionCalendar-day {
    shape-rendering: crispEdges;
    stroke: var(--calendar-cell-border);
    stroke-width: 1px;
    transition: opacity 0.15s ease;
}

.calendar rect.ContributionCalendar-day:hover {
    stroke: var(--text-primary);
    stroke-width: 1px;
}

.calendar rect.ContributionCalendar-day[data-level="0"] { fill: var(--color-calendar-graph-day-bg); }
.calendar rect.ContributionCalendar-day[data-level="1"] { fill: var(--color-calendar-graph-day-L1-bg); }
.calendar rect.ContributionCalendar-day[data-level="2"] { fill: var(--color-calendar-graph-day-L2-bg); }
.calendar rect.ContributionCalendar-day[data-level="3"] { fill: var(--color-calendar-graph-day-L3-bg); }
.calendar rect.ContributionCalendar-day[data-level="4"] { fill: var(--color-calendar-graph-day-L4-bg); }

.calendar .ContributionCalendar-label {
    fill: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 9px;
}

.calendar-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-muted);
}

.calendar-legend {
    display: flex;
    align-items: center;
    gap: 4px;
}

.calendar-legend .legend-box {
    display: inline-block;
    width: 10px;
    height: 10px;
    outline: 1px solid var(--calendar-cell-border);
    outline-offset: -1px;
}

.calendar-legend .legend-box[data-level="0"] { background-color: var(--color-calendar-graph-day-bg); }
.calendar-legend .legend-box[data-level="1"] { background-color: var(--color-calendar-graph-day-L1-bg); }
.calendar-legend .legend-box[data-level="2"] { background-color: var(--color-calendar-graph-day-L2-bg); }
.calendar-legend .legend-box[data-level="3"] { background-color: var(--color-calendar-graph-day-L3-bg); }
.calendar-legend .legend-box[data-level="4"] { background-color: var(--color-calendar-graph-day-L4-bg); }

/* All Repositories */
.filter-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.project-search-wrapper {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

#project-search {
    flex-grow: 1;
    max-width: 440px;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--surface);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#project-search:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px var(--accent-tint);
}

.project-count-badge {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: var(--text-muted);
}

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

/* Both directories are a table inside a card; the card clips the rows to
   its rounded corners. */
.project-list-container,
.research-list-container {
    overflow-x: auto;
}

.project-table,
.research-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.project-table {
    font-size: 0.88rem;
}

.project-table thead {
    background-color: var(--surface-2);
    border-bottom: 1px solid var(--border-color);
}

.project-table th {
    padding: 0.85rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.project-table th.th-links {
    text-align: right;
}

.project-table td,
.research-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

.project-table tbody tr,
.research-table tbody tr {
    transition: background-color 0.15s ease;
}

.project-table tbody tr:hover,
.research-table tbody tr:hover {
    background-color: var(--surface-hover);
}

.project-table tbody tr:last-child td,
.research-table tbody tr:last-child td {
    border-bottom: none;
}

.project-table .repo-name-col {
    width: 28%;
}

.table-repo-header {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.table-domain-badge {
    align-self: flex-start;
}

.table-repo-link {
    font-family: var(--font-body);
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-word;
}

.table-repo-link:hover {
    color: var(--accent-color);
    text-decoration: none;
}

.project-table .repo-desc-col {
    width: 44%;
    font-size: 0.86rem;
    line-height: 1.55;
    color: var(--text-muted);
}

.project-table .repo-stack-col {
    width: 16%;
}

.table-stack-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.table-stack-item {
    white-space: nowrap;
}

.stack-dot {
    color: var(--border-color);
    user-select: none;
}

.project-table .repo-link-col {
    width: 12%;
    text-align: right;
    white-space: nowrap;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
}

.table-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--accent-color);
    background-color: var(--accent-tint);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--accent-color);
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.table-action-btn:hover,
.table-action-btn:focus-visible {
    color: var(--ink-contrast);
    background-color: var(--accent-color);
    text-decoration: none;
}

.table-action-btn.docs-btn {
    border-color: var(--border-color);
    background-color: var(--surface);
    color: var(--text-muted);
}

.table-action-btn.docs-btn:hover,
.table-action-btn.docs-btn:focus-visible {
    border-color: var(--text-primary);
    background-color: var(--surface);
    color: var(--text-primary);
}

/* Inside a button the arrow drops its own box. */
.table-action-btn .ext-arrow,
.table-action-btn:hover > .ext-arrow,
.table-action-btn:focus-visible > .ext-arrow {
    width: auto;
    height: auto;
    margin-left: 0;
    border: 0;
    background: none;
    color: inherit;
    opacity: 1;
}

.no-results {
    padding: 2.5rem;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.hidden {
    display: none !important;
}

/* Patents & Publications */
.scholar-link {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
}

.research-table {
    font-size: 0.9rem;
}

.research-table td {
    padding: 1.25rem 1rem;
}

.research-table .research-index-col {
    width: 3.5rem;
    padding-top: 1.45rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
}

.research-badge-patent,
.research-badge-paper {
    margin-bottom: 0.55rem;
}

.research-title {
    margin-bottom: 0.3rem;
    font-family: var(--font-body);
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -0.01em;
}

.research-venue {
    margin-bottom: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.research-summary {
    max-width: 760px;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-muted);
}

.research-table .research-link-col {
    width: 1%;
    padding-top: 1.35rem;
    text-align: right;
    white-space: nowrap;
}

.research-row.hidden {
    display: none !important;
}

/* Footer */
.site-footer {
    max-width: var(--container-width);
    margin: 5rem auto 0 auto;
    padding: 3.5rem 1.5rem 2.5rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr 1.2fr;
    gap: 3rem;
    align-items: start;
}

.footer-col {
    display: flex;
    flex-direction: column;
}

.footer-brand {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1.25rem;
}

.footer-name {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.footer-role,
.footer-heading {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.footer-role {
    color: var(--accent-color);
}

.footer-heading {
    margin-bottom: 1.1rem;
    color: var(--text-muted);
}

.footer-nav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.footer-nav-list a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 0.45rem;
    border-bottom: 1px solid var(--border-color);
    font-family: var(--font-body);
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: color 0.15s ease;
}

/* Arrow boxes line up in one column on the right edge. */
.footer-nav-list .ext-arrow {
    margin-left: auto;
}

.footer-nav-list a:hover {
    color: var(--accent-color);
    text-decoration: none;
}

.footer-telemetry {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.telemetry-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding-bottom: 0.45rem;
    border-bottom: 1px solid var(--border-color);
    font-family: var(--font-mono);
    font-size: 0.74rem;
}

.telemetry-label {
    white-space: nowrap;
    color: var(--text-muted);
}

.telemetry-val {
    text-align: right;
    white-space: nowrap;
    font-weight: 600;
    color: var(--text-primary);
}

.back-to-top-btn {
    width: fit-content;
    margin-top: 0.85rem;
}

.footer-bottom-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: var(--text-muted);
}

.footer-meta-tag {
    font-size: 0.74rem;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .hero-main-row {
        flex-direction: column-reverse;
        align-items: flex-start;
        gap: 1.5rem;
    }
    .hero-sticker-img {
        width: 130px;
        height: 130px;
    }
    .hero-stats-grid {
        grid-template-columns: 1fr;
    }
    .featured-grid {
        grid-template-columns: 1fr;
    }
    .section-header {
        flex-direction: column;
        gap: 0.5rem;
    }
    .scholar-link {
        margin-left: 0;
    }
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    /* Stack table columns for mobile */
    .project-table thead {
        display: none;
    }
    .project-table, .project-table tbody, .project-table tr, .project-table td {
        display: block;
        width: 100%;
    }
    .project-table tr {
        border-bottom: 1px solid var(--border-color);
        padding: 1.25rem 1rem;
    }
    .project-table td {
        padding: 0.3rem 0;
        border: none;
    }
    .project-table .repo-name-col {
        margin-bottom: 0.4rem;
        width: 100%;
    }
    .project-table .repo-desc-col {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    .project-table .repo-stack-col {
        width: 100%;
        margin-bottom: 0.75rem;
    }
    .project-table .repo-link-col {
        width: 100%;
        text-align: left;
    }
    .table-actions {
        justify-content: flex-start;
    }

    /* The research table gets the same stacking treatment as the project
       table, so each entry becomes one block inside the card. */
    .research-table,
    .research-table tbody,
    .research-table tr,
    .research-table td {
        display: block;
        width: 100%;
    }
    .research-table tr {
        padding: 1.1rem 1rem;
        border-bottom: 1px solid var(--border-color);
    }
    .research-table tbody tr:last-child {
        border-bottom: none;
    }
    .research-table td,
    .research-table .research-index-col {
        padding: 0;
        border: none;
    }
    .research-table .research-index-col {
        margin-bottom: 0.4rem;
    }
    .research-table .research-link-col {
        margin-top: 0.75rem;
        text-align: left;
    }
}

/* GitHub Calendar Dark Mode Overrides */
[data-theme="dark"] .calendar {
    --color-calendar-graph-day-bg: #262626;
    --calendar-cell-border: rgba(255, 255, 255, 0.1);
    --color-calendar-graph-day-L1-bg: #0e4429;
    --color-calendar-graph-day-L2-bg: #006d32;
    --color-calendar-graph-day-L3-bg: #26a641;
    --color-calendar-graph-day-L4-bg: #39d353;
}

[data-theme="dark"] .calendar rect.ContributionCalendar-day[data-level="0"] { fill: var(--color-calendar-graph-day-bg); }
[data-theme="dark"] .calendar rect.ContributionCalendar-day[data-level="1"] { fill: var(--color-calendar-graph-day-L1-bg); }
[data-theme="dark"] .calendar rect.ContributionCalendar-day[data-level="2"] { fill: var(--color-calendar-graph-day-L2-bg); }
[data-theme="dark"] .calendar rect.ContributionCalendar-day[data-level="3"] { fill: var(--color-calendar-graph-day-L3-bg); }
[data-theme="dark"] .calendar rect.ContributionCalendar-day[data-level="4"] { fill: var(--color-calendar-graph-day-L4-bg); }

[data-theme="dark"] .calendar .ContributionCalendar-label {
    fill: var(--text-muted) !important;
    color: var(--text-muted) !important;
}

[data-theme="dark"] .calendar text {
    fill: var(--text-muted) !important;
}

[data-theme="dark"] .calendar .color-fg-muted {
    color: var(--text-muted) !important;
}
