:root {
    /* Material 3 Dark Colors */
    --md-sys-color-primary: #D0BCFF;
    --md-sys-color-on-primary: #381E72;
    --md-sys-color-surface: #1C1B1F;
    --md-sys-color-surface-variant: #49454F;
    --md-sys-color-on-surface: #E6E1E5;
    --md-sys-color-outline: #938F99;
    --md-sys-color-info: #7FCFFF;
    --md-sys-color-success: #B1F0AD;
    
    /* Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --glass-blur: blur(12px);
    
    /* Spacing & Radius */
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --spacing-main: 1.5rem;
    
    /* Typography */
    --font-sans: 'Inter', sans-serif;
    --font-display: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--md-sys-color-surface);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    color: var(--md-sys-color-on-surface);
    font-family: var(--font-sans);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    transition: background-image 1.5s ease;
}

/* Dark overlay to keep text readable over paintings */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(16, 14, 20, 0.72);
    z-index: 0;
    pointer-events: none;
}

#app-container {
    position: relative;
    z-index: 1;
}

h1, h2, h3, h4, .brand {
    font-family: var(--font-display);
    font-weight: 500;
}

/* (app-container already set via body::before z-index block above) */
#app-container {
    max-width: 100%;
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

.content-wrapper {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    padding-bottom: 80px; /* Space for mobile nav */
}

/* Header & Hero */
.app-header {
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.glass-header {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 2rem 1.5rem;
    box-shadow: var(--glass-shadow);
}

.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.brand {
    font-size: 1rem;
    color: var(--md-sys-color-primary);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-weight: 600;
}

.hero-content h1 {
    font-size: 2.2rem;
    line-height: 1.2;
    margin: 0 0 1rem;
    background: linear-gradient(135deg, #fff 0%, var(--md-sys-color-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-content p {
    font-size: 1rem;
    opacity: 0.8;
    margin: 0;
}

/* Content Layout */
.content {
    padding: var(--spacing-main);
    flex: 1;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--glass-shadow);
}

/* Info Card */
#intro-card h2 {
    font-size: 1.25rem;
    margin-top: 0;
    color: var(--md-sys-color-info);
}

.info-grid {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.info-blue { background-color: var(--md-sys-color-info); }

/* Emotion Grid */
.selection-section {
    margin: 2rem 0;
}

.section-title {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    padding-left: 0.5rem;
}

.emotion-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 16px;
}

.emotion-btn {
    --emotion-color: #7FCFFF;
    --emotion-accent: #6BA8CC;

    aspect-ratio: 1;
    background: var(--glass-bg);
    border: 2px solid var(--emotion-color);
    border-radius: var(--radius-md);
    color: #fff;
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.8;
}

.emotion-btn:hover, .emotion-btn:active {
    background: var(--emotion-color);
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.3) 0%, transparent 100%), var(--emotion-color);
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4), 0 0 20px var(--emotion-color);
    border-color: var(--emotion-accent);
    opacity: 1;
}

.emotion-icon {
    font-size: 1.5rem;
}

/* Detail View */
.detail-section {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.detail-container {
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    padding: 2rem;
    scrollbar-width: thin;
}

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

.detail-header h3 {
    font-size: 1.8rem;
    margin: 0;
    color: var(--md-sys-color-primary);
}

.emotion-description {
    background: rgba(127, 207, 255, 0.08);
    border-left: 4px solid var(--md-sys-color-info);
    padding: 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
    transition: all 0.3s ease;
}

.emotion-description p {
    margin: 0.75rem 0;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--md-sys-color-on-surface);
}

.emotion-description p:first-child {
    margin-top: 0;
    font-weight: 500;
}

.emotion-description p:last-child {
    margin-bottom: 0;
}

.emotion-description p:nth-child(2)::before {
    content: "📍 ";
    margin-right: 0.5rem;
    font-weight: 600;
}

.emotion-description p:nth-child(3)::before {
    content: "🧬 ";
    margin-right: 0.5rem;
    font-weight: 600;
}

.close-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Timeline */
.timeline-visual {
    padding: 2.5rem 0;
    margin-bottom: 2rem;
}

.timeline-track {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 120px;
}

.timeline-line {
    flex: 1;
    height: 2px;
    background: var(--md-sys-color-outline);
    margin-bottom: 30px;
    opacity: 0.3;
}

.timeline-node {
    flex: 2;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: all 0.5s ease;
}

.timeline-node.start { height: 60px; }
.timeline-node.peak { height: 90px; }
.timeline-node.resolution { height: 50px; }

.timeline-node.highlight {
    background: var(--emotion-highlight, rgba(127, 207, 255, 0.15));
    border-color: var(--emotion-color, var(--md-sys-color-info));
    box-shadow: 0 0 20px var(--emotion-color-shadow, rgba(127, 207, 255, 0.3));
}

.node-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
}

.node-sub {
    font-size: 0.6rem;
    opacity: 0.7;
}

/* Body Map */
.map-layout {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 1.5rem;
    align-items: center;
    margin: 1rem 0;
}

.svg-wrapper {
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius-md);
    padding: 10px;
}

.body-base {
    fill: var(--md-sys-color-outline);
    opacity: 0.2;
}

.sensations-details ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sensations-details li {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    padding-left: 1.25rem;
    position: relative;
}

.sensations-details li::before {
    content: "●";
    position: absolute;
    left: 0;
    color: var(--sensation-color, var(--md-sys-color-info));
    transition: color 0.3s ease;
}

/* Steps */
.steps-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 1rem;
}

.step-card {
    background: rgba(255,255,255,0.03);
    border-top: 3px solid var(--emotion-color, var(--md-sys-color-info));
    padding: 1rem;
    border-radius: var(--radius-md);
    position: relative;
    transition: all 0.3s ease;
}

.step-card:hover {
    background: rgba(255,255,255,0.06);
    box-shadow: 0 4px 12px var(--emotion-color-shadow, rgba(0,0,0,0.2));
}

.step-num {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 2rem;
    font-weight: 800;
    opacity: 0.08;
    color: var(--emotion-color, var(--md-sys-color-primary));
}

.step-card h5 {
    margin: 0 0 0.5rem;
    color: var(--emotion-color, var(--md-sys-color-primary));
    font-size: 0.9rem;
    transition: color 0.3s ease;
}

.step-card p {
    margin: 0;
    font-size: 0.75rem;
    opacity: 0.8;
}

/* Footer & Buttons */
.primary-btn {
    display: block;
    width: 100%;
    padding: 1rem;
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    text-align: center;
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    margin-top: 1.5rem;
    transition: transform 0.2s;
}

.primary-btn:active {
    transform: scale(0.98);
}

.success-border {
    border-top: 4px solid var(--md-sys-color-success);
}

.app-footer {
    padding: 2rem;
    text-align: center;
    opacity: 0.6;
}

.app-footer p {
    margin: 4px 0;
    font-size: 0.85rem;
}

.app-footer .small {
    font-size: 0.7rem;
}

/* Painting credit badge */
.painting-credit {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 6px 12px;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    font-size: 0.7rem;
    opacity: 0.7;
    font-style: italic;
}

.hide { display: none !important; }

/* Mobile Nav Buttons */
.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(28, 27, 31, 0.8);
    backdrop-filter: var(--glass-blur);
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-around;
    padding: 12px 0;
    z-index: 150;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--md-sys-color-on-surface);
    text-decoration: none;
    font-size: 0.75rem;
    opacity: 0.6;
    transition: all 0.3s ease;
}

.nav-item svg {
    transition: transform 0.3s ease;
}

.nav-item.active {
    opacity: 1;
    color: var(--md-sys-color-primary);
}

.nav-item:active svg {
    transform: scale(0.85);
}

/* Scroll Behavior */
html {
    scroll-behavior: smooth;
    scroll-padding-top: 100px;
}

/* Mobile Optimizations */
@media (max-width: 600px) {
    .hero-content h1 {
        font-size: 1.8rem;
    }
    
    .glass-header {
        padding: 1.5rem 1rem;
    }
}

@media (min-width: 800px) {
    .content-wrapper {
        padding-top: 2rem;
    }
    
    .mobile-nav {
        display: none; /* Hide on desktop */
    }
    
    .app-header {
        position: relative;
    }

    #app-container {
        align-items: center;
    }
    
    .content {
        max-width: 800px;
        width: 100%;
    }
}
