:root {
    /* Anthropic Brand Palette */
    --bg-dark: #141413;
    --bg-light: #faf9f5;
    --text-primary: #faf9f5;
    --text-secondary: #b0aea5;
    --text-inverse: #141413;

    /* Brand Accents (Earthy) */
    --accent-primary: #d97757;
    /* Orange */
    --accent-secondary: #6a9bcc;
    /* Blue */
    --accent-tertiary: #788c5d;
    /* Green */

    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: rgba(255, 255, 255, 0.08);

    --font-heading: 'Poppins', sans-serif;
    --font-body: 'Lora', serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.7;
    min-height: 100vh;
    overflow-x: hidden;
    /* Blueprint Grid Pattern */
    background-image:
        linear-gradient(rgba(250, 249, 245, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(250, 249, 245, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    background-position: center top;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

h1 {
    font-size: 3.5rem;
}

h2 {
    font-size: 2.5rem;
}

h3 {
    font-size: 1.5rem;
}

a {
    color: inherit;
    text-decoration: none;
    transition: all 0.2s ease;
}

/* Utilities */
.container {
    max-width: 1200px;
    /* More editorial, narrower reading width */
    margin: 0 auto;
    padding: 2rem;
}

.text-gradient {
    /* Subtle earthy gradient */
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Components */
.glass-panel {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    /* Less rounded than before */
    padding: 2.5rem;
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.glass-panel:hover {
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.btn-modern {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1.6rem;
    background: var(--bg-light);
    color: var(--bg-dark);
    border-radius: 8px;
    /* Slightly squared */
    font-weight: 500;
    font-family: var(--font-heading);
    transition: all 0.2s ease;
}

.btn-modern:hover {
    background: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Navbar */
.lab-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: rgba(20, 20, 19, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--card-border);
    padding: 1rem 0;
    z-index: 100;
    display: flex;
    justify-content: center;
}

.lab-nav .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    padding: 0 2rem;
    margin: 0;
}

.nav-links {
    display: flex;
    gap: 2.5rem;
}

.nav-links a {
    color: var(--text-secondary);
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 500;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--text-primary);
}

/* Project Grid */
#project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

#home-project-grid {
    display: grid;
    /* Force 3 columns for the top 3 projects */
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
}

/* Responsiveness for home grid */
@media (max-width: 900px) {
    #home-project-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
}

.project-card .card-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 1.5rem;
    opacity: 0.9;
}

.project-card h3 {
    margin-bottom: 0.75rem;
    font-size: 1.25rem;
}

.project-link {
    height: 100%;
    display: block;
    text-decoration: none;
}

.project-card {
    display: flex;
    flex-direction: column;
    padding: 2rem;
    height: 100%;
    min-height: 320px;
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.project-card .status-badge {
    /* If status badge is absolute, it doesn't affect flow. */
}

/* Ensure progress section stays at bottom */
.project-card>div:last-child {
    margin-top: auto;
}

.status-badge {
    position: absolute;
    top: 2rem;
    right: 2rem;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    background: rgba(20, 20, 19, 0.8);
    backdrop-filter: blur(4px);
    text-transform: uppercase;
}

/* Hero Animation */
.hero-scroll-container {
    height: 350vh;
    /* Scroll distance */
    position: relative;
}

.hero-sticky-frame {
    position: sticky;
    top: 0;
    height: 100vh;
    width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

canvas#hero-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0;
    /* Hidden until loaded */
    transition: opacity 0.5s ease;
    filter: brightness(0.7);
    /* Dim slightly for text readability */
}

/* Ensure text is above canvas */
.hero-content-wrapper {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 800px;
    padding: 2rem;
}

.hero-content-wrapper h1,
.hero-content-wrapper div {
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
}

#hero-text {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 1), 0 0 40px rgba(0, 0, 0, 0.5);
    color: #fff !important;
    /* Force lighter color for contrast if needed */
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-entry {
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Inputs */
.modern-input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 1rem 0;
    margin-bottom: 2rem;
    outline: none;
    border-radius: 0;
    font-family: var(--font-body);
    font-size: 1.1rem;
    transition: border-color 0.3s ease;
}

.modern-input:focus {
    border-color: var(--accent-secondary);
    box-shadow: none;
}

/* Select specific styling to match text inputs */
select.modern-input {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b0aea5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0 center;
    background-size: 1em;
    cursor: pointer;
    border-radius: 0;
}

select.modern-input option {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    padding: 10px;
}

/* Rich Text Editor Toolbar */
.rte-btn {
    background: transparent;
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.rte-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

/* --- Project Block Editor --- */
#project-block-stream {
    position: relative;
    min-height: 200px;
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    align-items: flex-start;
    /* Prevent stretching */
}

.block-editor-toolbar {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed var(--glass-border);
    border-radius: 8px;
    justify-content: center;
    width: 100%;
}

.project-block {
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease, width 0.3s ease;
    width: 100%;
    /* Default full width */
}

/* Width Classes */
.project-block.width-full {
    width: 100%;
}

.project-block.width-half {
    width: calc(50% - 1rem);
}

.project-block.width-third {
    width: calc(33.333% - 1.33rem);
}

/* Mobile fallback */
@media (max-width: 768px) {

    .project-block.width-half,
    .project-block.width-third {
        width: 100%;
    }
}

/* Drag & Drop States */
.project-block.dragging {
    opacity: 0.5;
    transform: scale(0.98);
    background: rgba(0, 0, 0, 0.2);
    border: 1px dashed var(--accent-primary);
}

/* Lightbox */
.lightbox-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    cursor: zoom-out;
}

.lightbox-modal.active {
    opacity: 1;
    pointer-events: all;
}

.lightbox-modal img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 4px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.lightbox-modal.active img {
    transform: scale(1);
}

.project-block.drag-over {
    border-top: 2px solid var(--accent-primary);
}

/* Block Controls (Admin Only) */
.block-controls {
    position: absolute;
    top: -12px;
    right: 10px;
    display: flex;
    gap: 0.3rem;
    background: var(--bg-dark);
    padding: 2px;
    border: 1px solid var(--card-border);
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
}

.project-block:hover .block-controls {
    opacity: 1;
}

.block-control-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 4px;
    border-radius: 2px;
}

.block-control-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.block-control-btn.danger:hover {
    background: rgba(255, 50, 50, 0.2);
    color: #ff6b6b;
}

.drag-handle {
    cursor: grab;
    color: var(--text-secondary);
    padding: 0 4px;
}

.drag-handle:active {

    /* RTE Content Overrides */
    .block-content i,
    .block-content em {
        font-style: italic;
        color: var(--accent-primary);
        /* Optional: make italics pop a bit? Or keep standard. Let's keep standard but ensure it works. */
        color: inherit;
    }

    .block-content b,
    .block-content strong {
        font-weight: 700;
        color: var(--text-primary);
    }

    .block-content ul {
        list-style: disc;
        margin-left: 1.5rem;
        margin-bottom: 1rem;
    }

    .block-content li {
        padding-left: 0.5rem;
    }