:root {
    /* Core Brand Colors */
    --primary: #0066FF;
    --primary-dark: #0052CC;
    --primary-light: #3385FF;
    --accent: #00D4FF;
    --accent-glow: rgba(0, 212, 255, 0.3);
    
    /* Neutral Palette */
    --bg-base: #0A0E17;
    --bg-elevated: #12161F;
    --bg-card: #1A1F2E;
    --bg-card-hover: #202632;
    
    /* Text Colors */
    --text-primary: #FFFFFF;
    --text-secondary: #B4B9C8;
    --text-muted: #6B7280;
    
    /* Border & Dividers */
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-medium: rgba(255, 255, 255, 0.12);
    
    /* Status Colors */
    --status-stable: #10B981;
    --status-stable-bg: rgba(16, 185, 129, 0.1);
    --status-experimental: #F59E0B;
    --status-experimental-bg: rgba(245, 158, 11, 0.1);
    
    /* Effects */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(0, 102, 255, 0.3);
    
    /* Animation Timings */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-primary);
    background: var(--bg-base);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== BACKGROUND ===== */
.background-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.grid-overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 50px 50px;
    opacity: 0.5;
}

.gradient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.15;
    animation: float 20s ease-in-out infinite;
}

.orb-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
    top: -200px;
    right: -200px;
    animation-delay: 0s;
}

.orb-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
    bottom: -150px;
    left: -150px;
    animation-delay: -7s;
}

.orb-3 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #8B5CF6 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -14s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.1); }
    66% { transform: translate(-20px, 20px) scale(0.9); }
}

/* ===== HEADER ===== */
.lab-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 14, 23, 0.8);
    backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border-subtle);
    padding: 1rem 0;
    transition: all var(--transition-base);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: transform var(--transition-base);
}

.logo:hover {
    transform: translateY(-2px);
}

.logo-mark {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon {
    font-size: 1.5rem;
    position: relative;
    z-index: 2;
}

.logo-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--primary);
    border-radius: 12px;
    opacity: 0.2;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.2; }
    50% { transform: scale(1.1); opacity: 0.1; }
}

.logo-text {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo-main {
    color: var(--text-primary);
}

.logo-accent {
    color: var(--primary);
    font-family: 'Space Mono', monospace;
}

.header-nav {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-link {
    position: relative;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    padding: 0.5rem 0;
    transition: color var(--transition-base);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-indicator {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary);
    transition: width var(--transition-base);
}

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

.nav-link:hover .nav-indicator,
.nav-link.active .nav-indicator {
    width: 100%;
}

.nav-link.active {
    color: var(--text-primary);
}

.nav-link-external svg {
    transition: transform var(--transition-base);
}

.nav-link-external:hover svg {
    transform: translate(2px, -2px);
}

/* ===== MAIN CONTAINER ===== */
.lab-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 4rem 2rem;
}

/* ===== HERO ===== */
.hero {
    text-align: center;
    margin-bottom: 4rem;
    animation: fadeInUp 0.8s ease-out;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    animation: fadeInUp 0.8s ease-out 0.1s both;
}

.badge-dot {
    width: 8px;
    height: 8px;
    background: var(--status-stable);
    border-radius: 50%;
    animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.hero-title {
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 1.5rem;
    letter-spacing: -0.02em;
}

.title-line {
    display: block;
    animation: fadeInUp 0.8s ease-out both;
}

.title-line:nth-child(1) { animation-delay: 0.2s; }
.title-line:nth-child(2) { animation-delay: 0.3s; }
.title-line:nth-child(3) { animation-delay: 0.4s; }

.title-accent {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    position: relative;
}

.hero-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    max-width: 700px;
    margin: 0 auto 3rem;
    line-height: 1.7;
    animation: fadeInUp 0.8s ease-out 0.5s both;
}

.subtitle-highlight {
    color: var(--text-primary);
    font-weight: 600;
}

/* Stats Bar */
.stats-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    padding: 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    max-width: 600px;
    margin: 0 auto;
    animation: fadeInUp 0.8s ease-out 0.6s both;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    font-family: 'Space Mono', monospace;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-divider {
    width: 1px;
    height: 40px;
    background: var(--border-subtle);
}

/* ===== CONTROLS ===== */
.controls-section {
    margin-bottom: 3rem;
    animation: fadeInUp 0.8s ease-out 0.7s both;
}

.controls-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.controls-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.view-toggle {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-card);
    padding: 0.25rem;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
}

.view-btn {
    padding: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.view-btn:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.view-btn.active {
    background: var(--primary);
    color: white;
}

.controls-bar {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-wrapper {
    flex: 1;
    position: relative;
    min-width: 300px;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

input#searchInput {
    width: 100%;
    padding: 1rem 3rem 1rem 3rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    font-size: 0.95rem;
    color: var(--text-primary);
    outline: none;
    transition: all var(--transition-base);
    font-family: 'DM Sans', sans-serif;
}

input#searchInput::placeholder {
    color: var(--text-muted);
}

input#searchInput:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

.search-results-count {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: 'Space Mono', monospace;
}

.filters {
    display: flex;
    gap: 1rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
}

.filters select {
    padding: 1rem 2.5rem 1rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.95rem;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    transition: all var(--transition-base);
    font-family: 'DM Sans', sans-serif;
}

.filters select:hover {
    border-color: var(--border-medium);
}

.filters select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

/* ===== GRID ===== */
.demo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.5rem;
    animation: fadeInUp 0.8s ease-out 0.8s both;
}

.demo-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 1.75rem;
    cursor: pointer;
    transition: all var(--transition-base);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.demo-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    opacity: 0;
    transition: opacity var(--transition-base);
}

.demo-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-medium);
    background: var(--bg-card-hover);
    box-shadow: var(--shadow-md);
}

.demo-card:hover::before {
    opacity: 1;
}

.card-status {
    position: absolute;
    top: 1.75rem;
    right: 1.75rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    transition: all var(--transition-base);
}

.status-stable { 
    background: var(--status-stable); 
    box-shadow: 0 0 0 3px var(--status-stable-bg);
}

.status-experimental { 
    background: var(--status-experimental); 
    box-shadow: 0 0 0 3px var(--status-experimental-bg);
}

.demo-card:hover .card-status {
    transform: scale(1.2);
}

.card-domain {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 0.75rem;
    font-family: 'Space Mono', monospace;
}

.card-title {
    font-size: 1.375rem;
    font-weight: 700;
    margin: 0 0 0.75rem 0;
    color: var(--text-primary);
    line-height: 1.3;
}

.card-desc {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
    flex-grow: 1;
    margin-bottom: 1.25rem;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.875rem;
}

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

.tag {
    background: var(--bg-elevated);
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-family: 'Space Mono', monospace;
    border: 1px solid var(--border-subtle);
}

.card-footer > span {
    color: var(--text-muted);
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
}

/* ===== STATES ===== */
.loading-state,
.empty-state,
.error-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.loader {
    width: 40px;
    height: 40px;
    border: 3px solid var(--bg-elevated);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-state p,
.empty-state,
.error-state {
    font-size: 1rem;
    margin-top: 1rem;
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity var(--transition-base);
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 14, 23, 0.8);
    backdrop-filter: blur(8px);
}

.modal-window {
    position: relative;
    background: var(--bg-card);
    width: 90%;
    height: 90%;
    max-width: 1400px;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-medium);
    transform: scale(0.95);
    transition: transform var(--transition-base);
}

.modal-overlay:not(.hidden) .modal-window {
    transform: scale(1);
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-elevated);
}

.modal-title-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-domain {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary);
    font-weight: 700;
    font-family: 'Space Mono', monospace;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.modal-action-btn {
    background: transparent;
    border: 1px solid var(--border-subtle);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-action-btn:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-medium);
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #EF4444;
    color: #EF4444;
}

.modal-content {
    flex: 1;
    position: relative;
    background: var(--bg-base);
}

.iframe-loader {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-base);
    z-index: 1;
    opacity: 1;
    transition: opacity var(--transition-base);
}

iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    background: white;
}

iframe:not([src=""]) ~ .iframe-loader {
    opacity: 0;
    pointer-events: none;
}

/* ===== FOOTER ===== */
.lab-footer {
    margin-top: 6rem;
    padding: 2rem;
    border-top: 1px solid var(--border-subtle);
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

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

.footer-divider {
    color: var(--text-muted);
    opacity: 0.3;
}

.footer-right {
    display: flex;
    gap: 2rem;
}

.footer-link {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    transition: color var(--transition-base);
}

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

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

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .lab-container {
        padding: 2rem 1rem;
    }
    
    .header-content {
        padding: 0 1rem;
    }
    
    .header-nav {
        gap: 1rem;
    }
    
    .nav-link {
        font-size: 0.85rem;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .stats-bar {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .stat-divider {
        width: 80%;
        height: 1px;
    }
    
    .controls-bar {
        flex-direction: column;
    }
    
    .search-wrapper {
        min-width: 100%;
    }
    
    .filters {
        flex-direction: column;
        width: 100%;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .filters select {
        width: 100%;
    }
    
    .demo-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-window {
        width: 95%;
        height: 95%;
    }
}

@media (max-width: 480px) {
    .logo-text {
        font-size: 1rem;
    }
    
    .view-toggle {
        display: none;
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
    
    .footer-left {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .footer-divider {
        display: none;
    }
}
