:root {
    --primary: #1a1a1a;
    --secondary: #2d2d2d;
    --accent: #4a9cff;
    --accent-woe: #4a9cff;
    --light: #f0f0f0;
    --light2: #e0e0e0;
    --dark: #121212;
    --surface: #333333;
    --border: rgba(255,255,255,0.1);
    --muted: #b0b0b0;
    --success: #46c38b;
    --warning: #f6c76e;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-md: 0 12px 30px rgba(0,0,0,0.25);
    --shadow-sm: 0 6px 16px rgba(0,0,0,0.2);

    --font-sans: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

    --max-w: 1100px;
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;
    --space-8: 4rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-sans);
}

body {
    background-color: var(--primary);
    color: var(--light);
    min-height: 100vh;
    line-height: 1.7;
}

body, html {
    margin: 0;
    padding: 0;
}

a {
    color: var(--light);
    text-decoration: none;
    transition: color 0.2s, opacity 0.2s;
}

a:hover {
    color: var(--accent);
}

.navbar {
    padding: var(--space-4) var(--space-6);
    background-color: var(--dark);
    display: flex;
    align-items: center;
    gap: var(--space-5);
    border-bottom: 1px solid var(--border);
    position: relative;
    z-index: 100;
}

.logo {
    height: 36px;
    transition: opacity 0.2s;
}

.logo:hover {
    opacity: 0.8;
}

.nav-links {
    display: flex;
    gap: var(--space-4);
    margin-left: auto;
}

.nav-link {
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.header-woe {
    color: var(--accent-woe);
}

.header-fullname {
    color: var(--light2);
}

.name-container h1 {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    white-space: nowrap;
}

.header-fullname, .header-woe {
    display: inline;
    margin: 0;
    padding: 0;
}

.nav-link:hover {
    background: rgba(255,255,255,0.05);
    color: var(--accent);
}

.tagline {
    color: var(--muted);
    font-weight: 500;
    letter-spacing: 0.2px;
}

.library-container {
    display: flex;
    gap: var(--space-6);
    margin-left: 16px; /* Sidebar width */
    padding: var(--space-6);
    min-height: calc(100vh - 64px);
    max-width: var(--max-w);
    margin: 0 auto;
}

.count {
    background: var(--primary);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-feature-settings: 'tnum';
}

/* Featured Collections */
.featured-collections .scans-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    width: 100%;
    gap: var(--space-6);
    margin-bottom: var(--space-7);
}

.featured-collections .scan-image {
    aspect-ratio: 3/1;
    height: auto;
}


.scan-card {
    background: var(--secondary);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: transform 0.2s;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.scan-card:hover {
    transform: translateY(-3px);
}

.scan-image {
    background-size: cover;
    background-position: center;
    background-color: var(--surface);
}

.scan-info {
    padding: 1.25rem;
}

.meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    margin: 0.75rem 0;
}

.credits {
    color: var(--accent);
    font-weight: 500;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 1000;
    padding: var(--space-6);
}

.modal-content {
    background: var(--secondary);
    border-radius: var(--radius-md);
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
    padding: var(--space-6);
    position: relative;
}

.modal-images {
    width: 80%;
    margin: 0 auto;
}

.main-modal-image {
    width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    cursor: zoom-in;
    transition: transform 0.2s;
}

.main-modal-image:hover {
    transform: scale(1.01);
}

/* Portfolio Modal */
.portfolio-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
}

.modal-container {
    position: relative;
    width: 90vw;
    max-width: 90vw;
    height: 90vh;
    display: flex;
    flex-direction: column;
    background: var(--secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
}

.modal-close {
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    z-index: 10;
    padding: 0.5rem;
    transition: opacity 0.2s;
}

.modal-close:hover {
    opacity: 0.7;
}

.modal-gallery {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    position: relative;
    overflow: hidden;
}

.gallery-image-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-image {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    border-radius: var(--radius-md);
}

.modal-videos {
    display: none;
    flex-direction: column;
    gap: var(--space-4);
    width: 100%;
    height: 100%;
    max-width: 1200px;
    padding: var(--space-4);
}

.modal-videos.active {
    display: flex;
}

.modal-videos iframe {
    width: 100%;
    min-height: 400px;
    height: 50vh;
    max-height: 600px;
    border: none;
    border-radius: var(--radius-md);
}

.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.5rem;
    padding: 0.8rem 1.2rem;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all 0.2s;
    z-index: 5;
}

.gallery-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.gallery-nav.left {
    left: var(--space-4);
}

.gallery-nav.right {
    right: var(--space-4);
}

.image-counter {
    position: absolute;
    bottom: var(--space-4);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
}

.modal-details {
    padding: var(--space-5);
    background: var(--secondary);
    border-top: 1px solid var(--border);
    max-height: 240px;
    overflow-y: auto;
}

.details-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-5);
}

.details-text h2 {
    color: var(--light);
    margin-bottom: var(--space-2);
    font-size: 1.5rem;
}

.details-text p {
    color: var(--light2);
    font-size: 0.95rem;
    line-height: 1.6;
}

.details-software h4 {
    color: var(--light);
    font-size: 0.9rem;
    margin-bottom: var(--space-3);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.software-icons-grid {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.software-icons-grid img {
    height: 48px;
    width: 48px;
    object-fit: contain;
    transition: transform 0.2s;
}

.software-icons-grid img:hover {
    transform: scale(1.15);
}

/* Responsive modal */
@media (max-width: 768px) {
    .modal-container {
        height: 95vh;
    }

    .details-content {
        grid-template-columns: 1fr;
        gap: var(--space-3);
    }

    .modal-details {
        max-height: 180px;
        padding: var(--space-4);
    }

    .gallery-nav {
        padding: 0.6rem 1rem;
        font-size: 1.2rem;
    }

    .gallery-nav.left {
        left: var(--space-2);
    }

    .gallery-nav.right {
        right: var(--space-2);
    }

    .details-text h2 {
        font-size: 1.25rem;
    }

    .software-icons-grid {
        gap: var(--space-2);
    }

    .software-icons-grid img {
        height: 40px;
        width: 40px;
    }
}

/* Lightbox (existing) */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.97);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.lightbox-image {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.lightbox-close {
    position: absolute;
    top: 2rem;
    right: 2rem;
    font-size: 2rem;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
}

.lightbox-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    padding: 0.85rem 1.25rem;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: background 0.2s;
}

.lightbox-arrow:hover {
    background: rgba(255,255,255,0.2);
}

.lightbox-arrow.left {
    left: 2rem;
}

.lightbox-arrow.right {
    right: 2rem;
}

/* Responsive Design */
@media (max-width: 1600px) {
    .recently-added .scans-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1200px) {
    .recently-added .scans-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .library-container {
        flex-direction: column;
        padding: var(--space-4);
    }
    
    .featured-collections .scans-grid,
    .recently-added .scans-grid {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        width: 100%;
        position: static;
        margin-bottom: 2rem;
    }
    
    .modal-content {
        grid-template-columns: 1fr;
        padding: var(--space-4);
    }
    
    .modal-images {
        width: 100%;
    }
}

/* HTMX Loading States */
.count.htmx-request {
    opacity: 0.5;
    position: relative;
}

.count.htmx-request::after {
    content: "";
    display: block;
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--accent);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    position: absolute;
    right: -1.5rem;
    top: 50%;
    transform: translateY(-50%);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- New: Global layout & hero / portfolio styles --- */
.container {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 var(--space-6);
}

h1, h2, h3, h4 {
    font-weight: 700;
    letter-spacing: -0.01em;
}

h1 { font-size: clamp(2rem, 3.2vw, 3rem); }
h2 { font-size: clamp(1.5rem, 2.2vw, 2rem); }
h3 { font-size: clamp(1.125rem, 1.6vw, 1.35rem); }
p  { color: var(--light2); }

.hero {
    padding: var(--space-5) 0 var(--space-4);
}

.hero .container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-6);
}

.hero-logo {
    height: 60px;
    width: auto;
    transition: transform 0.3s ease;
}

.hero-logo:hover {
    transform: scale(1.05);
}

.hero:empty {
    padding: 0;
    min-height: 0;
}

.hero h1 {
    color: var(--light);
    margin-bottom: var(--space-3);
}

.hero p {
    max-width: 60ch;
}

.skills {
    padding: var(--space-1) 0;
    background: rgba(74,156,255,0.08);
    border-top: 1px solid var(--border);
}

.skills h2 {
    margin-bottom: var(--space-4);
}

.skills-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-6);
}

.skill-card {
    background: var(--primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.skill-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-sm);
}

.skill-card h3 {
    color: var(--accent);
    margin-bottom: var(--space-4);
}

.software-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: var(--space-4);
}

.software-grid img {
    height: 64px;
    width: 64px;
    object-fit: contain;
    transition: transform 0.2s;
}

.software-grid img:hover {
    transform: scale(1.1);
}

.featured-works {
    padding: var(--space-7) 0;
}

.featured-works h2 {
    margin-bottom: var(--space-5);
}

.works-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-6);
}

.work-item {
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    height: 500px;
    position: relative;
}

.work-item:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.work-item .work-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.work-item:hover .work-image {
    transform: scale(1.05);
}

.work-item .work-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--space-5);
    background: linear-gradient(to top, rgba(0,0,0,0.9), rgba(0,0,0,0.7) 60%, transparent);
    color: white;
    z-index: 1;
}

.work-item .work-overlay h3 {
    margin: 0 0 var(--space-2) 0;
    font-size: 1.5rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.work-item .work-overlay p {
    margin: 0;
    opacity: 0.9;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.work-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: var(--surface);
}

.work-item h3 { padding: 0.85rem 1rem 0; }
.work-item p  { padding: 0 1rem 1rem; }

footer {
    border-top: 1px solid var(--border);
    margin-top: var(--space-8);
    padding: var(--space-6) 0;
    color: var(--muted);
}

.about-section {
    padding: var(--space-7) 0;
    background: var(--secondary);
    border-top: 1px solid var(--border);
}

.about-section h2 {
    margin-bottom: var(--space-5);
}

.about-content {
    max-width: 700px;
    line-height: 1.8;
}

.about-content p {
    margin-bottom: var(--space-3);
    color: var(--light2);
}

.about-content a {
    color: var(--accent);
    transition: opacity 0.2s;
}

.about-content a:hover {
    opacity: 0.8;
}

.container-wide {
    max-width: 98%;
    margin: 0 auto;
    padding: 0 var(--space-4);
}

.portfolio-section {
    padding: var(--space-7) 0;
    background: linear-gradient(180deg, rgba(74,156,255,0.08), rgba(0,0,0,0));
}

.portfolio-section h2 {
    margin-bottom: var(--space-6);
    font-size: clamp(1.75rem, 2.5vw, 2.25rem);
}

.portfolio-grid-hero {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-6);
}

.portfolio-card-hero {
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.23, 1, 0.320, 1);
    cursor: pointer;
    height: 600px;
    display: flex;
    flex-direction: column;
    position: relative;
}

.portfolio-card-hero.featured {
    grid-column: span 2;
    grid-row: span 2;
    height: auto;
    min-height: 800px;
}

.portfolio-card-hero:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-md);
}

.portfolio-image-hero {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-color: var(--surface);
    position: absolute;
    top: 0;
    left: 0;
    transition: transform 0.4s cubic-bezier(0.23, 1, 0.320, 1);
}

.portfolio-card-hero:hover .portfolio-image-hero {
    transform: scale(1.05);
}

.portfolio-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--space-4);
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.4));
    z-index: 10;
}

.portfolio-overlay h3 {
    color: white;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8);
    font-size: 1.1rem;
    margin-bottom: var(--space-1);
    font-weight: 700;
    letter-spacing: -0.01em;
}

.portfolio-overlay p {
    color: white;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8);
    font-size: 0.8rem;
    margin-bottom: var(--space-2);
    line-height: 1.4;
}

.portfolio-meta {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.tag {
    display: inline-block;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    padding: 0.3rem 0.65rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.25);
    white-space: nowrap;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8);
}

.tag.accent {
    background: rgba(74, 156, 255, 0.3);
    color: #6ab8ff;
    border-color: rgba(74, 156, 255, 0.5);
}

/* Responsive tweaks */
@media (max-width: 1024px) {
    .navbar { flex-wrap: wrap; gap: var(--space-3); }
    .nav-links { width: 100%; justify-content: flex-end; }
    .works-grid { grid-template-columns: repeat(2, 1fr); }
    .skills-grid { grid-template-columns: 1fr; }
    .software-grid { grid-template-columns: repeat(4, 1fr); }
    .portfolio-grid-hero { grid-template-columns: repeat(2, 1fr); }
    .portfolio-card-hero.featured { grid-column: span 2; grid-row: span 1; min-height: 420px; }
}

@media (max-width: 640px) {
    .navbar { padding: var(--space-4); }
    .name-container h1 { font-size: clamp(1.25rem, 5.5vw, 1.75rem); }
    .works-grid { grid-template-columns: 1fr; }
    .software-grid { grid-template-columns: repeat(3, 1fr); }
    .portfolio-grid-hero { grid-template-columns: 1fr; }
    .portfolio-card-hero { height: 300px; }
    .portfolio-card-hero.featured { grid-column: span 1; grid-row: span 1; min-height: 300px; }
    .portfolio-overlay h3 { font-size: 0.95rem; }
    .portfolio-overlay p { font-size: 0.7rem; }
}