/**
 * Beautiful Memory Visualization Styles
 * "Inside Out 2" inspired crystal orb visualization
 * Jony Ive design: radical simplicity, meaningful animation, material honesty
 */

/* ============================================
   Emotion Color Variables
   ============================================ */
:root {
    /* Joy - Warm yellow */
    --memory-joy: #EAB308;
    --memory-joy-glow: rgba(234, 179, 8, 0.4);
    --memory-joy-rgb: 234, 179, 8;

    /* Calm - Soft blue */
    --memory-calm: #93C5FD;
    --memory-calm-glow: rgba(147, 197, 253, 0.4);
    --memory-calm-rgb: 147, 197, 253;

    /* Sadness - Deep blue */
    --memory-sadness: #3B82F6;
    --memory-sadness-glow: rgba(59, 130, 246, 0.4);
    --memory-sadness-rgb: 59, 130, 246;

    /* Anger - Vivid red */
    --memory-anger: #EF4444;
    --memory-anger-glow: rgba(239, 68, 68, 0.4);
    --memory-anger-rgb: 239, 68, 68;

    /* Fear - Purple */
    --memory-fear: #A855F7;
    --memory-fear-glow: rgba(168, 85, 247, 0.4);
    --memory-fear-rgb: 168, 85, 247;

    /* Surprise - Pink */
    --memory-surprise: #EC4899;
    --memory-surprise-glow: rgba(236, 72, 153, 0.4);
    --memory-surprise-rgb: 236, 72, 153;

    /* Love/Trust - Green */
    --memory-love: #22C55E;
    --memory-love-glow: rgba(34, 197, 94, 0.4);
    --memory-love-rgb: 34, 197, 94;

    /* Anticipation - Light yellow */
    --memory-anticipation: #FDE047;
    --memory-anticipation-glow: rgba(253, 224, 71, 0.4);
    --memory-anticipation-rgb: 253, 224, 71;

    /* Default/neutral */
    --memory-default: #9CA3AF;
    --memory-default-glow: rgba(156, 163, 175, 0.4);
    --memory-default-rgb: 156, 163, 175;

    /* Default orb variables (used when no emotion class applied) */
    --orb-rgb: 156, 163, 175;
    --orb-glow: rgba(156, 163, 175, 0.4);
}


/* ============================================
   Memory Grid Container
   ============================================ */
.memories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1.5rem;
    padding: 1.5rem;
    max-height: calc(80vh - 200px);
    overflow-y: auto;
}

.memories-grid-compact {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 1rem;
    padding: 1rem;
}


/* ============================================
   Crystal Orb Base Styles
   Inside Out 2 inspired: clean, luminous, inviting
   ============================================ */
.memory-orb {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    cursor: pointer;

    /* Smooth transitions */
    transition: transform 250ms ease, box-shadow 250ms ease;

    /* Gentle float animation */
    animation: orb-float 4s ease-in-out infinite;

    /* Clean gradient - light source from top */
    background: radial-gradient(
        circle at 50% 30%,
        rgba(var(--orb-rgb), 1) 0%,
        rgba(var(--orb-rgb), 0.85) 40%,
        rgba(var(--orb-rgb), 0.6) 100%
    );

    /* Soft glow */
    box-shadow:
        0 0 25px var(--orb-glow),
        0 0 50px rgba(var(--orb-rgb), 0.2),
        inset 0 -8px 20px rgba(0, 0, 0, 0.15);
}

/* Glass shine - single clean highlight */
.memory-orb::before {
    content: '';
    position: absolute;
    top: 10%;
    left: 20%;
    width: 35%;
    height: 35%;
    border-radius: 50%;
    background: radial-gradient(
        circle at 50% 50%,
        rgba(255, 255, 255, 0.7) 0%,
        rgba(255, 255, 255, 0.3) 40%,
        transparent 70%
    );
    pointer-events: none;
}

/* Subtle bottom reflection */
.memory-orb::after {
    content: '';
    position: absolute;
    bottom: 15%;
    right: 20%;
    width: 20%;
    height: 15%;
    border-radius: 50%;
    background: radial-gradient(
        circle at 50% 50%,
        rgba(255, 255, 255, 0.2) 0%,
        transparent 70%
    );
    pointer-events: none;
}

/* Hover state - lift and glow */
.memory-orb:hover {
    transform: scale(1.1) translateY(-4px);
    box-shadow:
        0 0 35px var(--orb-glow),
        0 0 70px rgba(var(--orb-rgb), 0.3),
        0 10px 25px rgba(0, 0, 0, 0.2),
        inset 0 -8px 20px rgba(0, 0, 0, 0.15);
}

/* Active/pressed state */
.memory-orb:active {
    transform: scale(1.05) translateY(-2px);
    transition-duration: 100ms;
}


/* ============================================
   Salience Size Variants
   ============================================ */
.memory-orb.salience-high {
    width: 100px;
    height: 100px;
}

.memory-orb.salience-medium {
    width: 80px;
    height: 80px;
}

.memory-orb.salience-low {
    width: 64px;
    height: 64px;
}

/* Preview (home page) size */
.memory-orb.orb-preview {
    width: 64px;
    height: 64px;
}


/* ============================================
   Emotion Color Classes
   Each emotion has its own color identity while sharing
   the same 3D glass material properties
   ============================================ */
.memory-orb.emotion-joy {
    --orb-rgb: 234, 179, 8;
    --orb-glow: rgba(234, 179, 8, 0.4);
}

.memory-orb.emotion-calm {
    --orb-rgb: 147, 197, 253;
    --orb-glow: rgba(147, 197, 253, 0.4);
}

.memory-orb.emotion-sadness {
    --orb-rgb: 59, 130, 246;
    --orb-glow: rgba(59, 130, 246, 0.4);
}

.memory-orb.emotion-anger {
    --orb-rgb: 239, 68, 68;
    --orb-glow: rgba(239, 68, 68, 0.4);
}

.memory-orb.emotion-fear {
    --orb-rgb: 168, 85, 247;
    --orb-glow: rgba(168, 85, 247, 0.4);
}

.memory-orb.emotion-surprise {
    --orb-rgb: 236, 72, 153;
    --orb-glow: rgba(236, 72, 153, 0.4);
}

.memory-orb.emotion-love,
.memory-orb.emotion-trust,
.memory-orb.emotion-love-trust {
    --orb-rgb: 34, 197, 94;
    --orb-glow: rgba(34, 197, 94, 0.4);
}

.memory-orb.emotion-anticipation {
    --orb-rgb: 253, 224, 71;
    --orb-glow: rgba(253, 224, 71, 0.4);
}

/* Default/no emotion */
.memory-orb.emotion-default {
    --orb-rgb: 156, 163, 175;
    --orb-glow: rgba(156, 163, 175, 0.4);
}


/* ============================================
   Dual Emotion Gradient Styles
   "Inside Out 2" inspired: organic radial blend of two emotions
   ============================================ */
.memory-orb.dual-emotion {
    /* Override the single-color gradient with a dual-color radial blend */
    background: radial-gradient(
        circle at 30% 30%,
        rgba(var(--orb-primary-rgb), 1) 0%,
        rgba(var(--orb-primary-rgb), 0.8) 35%,
        rgba(var(--orb-secondary-rgb), 0.7) 65%,
        rgba(var(--orb-secondary-rgb), 0.9) 100%
    );

    /* Combined glow from both colors */
    box-shadow:
        0 0 25px var(--orb-primary-glow),
        0 0 50px var(--orb-secondary-glow),
        inset 0 -8px 20px rgba(0, 0, 0, 0.15);
}

.memory-orb.dual-emotion:hover {
    box-shadow:
        0 0 35px var(--orb-primary-glow),
        0 0 70px var(--orb-secondary-glow),
        0 10px 25px rgba(0, 0, 0, 0.2),
        inset 0 -8px 20px rgba(0, 0, 0, 0.15);
}


/* ============================================
   Float Animation
   Gentle, organic movement
   ============================================ */
@keyframes orb-float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-4px);
    }
}

/* Staggered animation delays for grid */
.memory-orb:nth-child(1) { animation-delay: 0s; }
.memory-orb:nth-child(2) { animation-delay: 0.2s; }
.memory-orb:nth-child(3) { animation-delay: 0.4s; }
.memory-orb:nth-child(4) { animation-delay: 0.6s; }
.memory-orb:nth-child(5) { animation-delay: 0.8s; }
.memory-orb:nth-child(6) { animation-delay: 1.0s; }
.memory-orb:nth-child(7) { animation-delay: 1.2s; }
.memory-orb:nth-child(8) { animation-delay: 1.4s; }
.memory-orb:nth-child(9) { animation-delay: 1.6s; }
.memory-orb:nth-child(10) { animation-delay: 1.8s; }
.memory-orb:nth-child(11) { animation-delay: 2.0s; }
.memory-orb:nth-child(12) { animation-delay: 2.2s; }


/* ============================================
   Memory Modal Styles
   ============================================ */
.memories-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 300ms ease, visibility 300ms ease;
}

.memories-modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.memories-modal-backdrop.memories-modal-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.memories-modal {
    width: 90%;
    max-width: 1000px;
    max-height: 85vh;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.95);
    opacity: 0;
    transition: transform 300ms ease, opacity 300ms ease;
}

.memories-modal-backdrop.active .memories-modal {
    transform: scale(1);
    opacity: 1;
}


/* ============================================
   Modal Header
   ============================================ */
.memories-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.memories-modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.memories-modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 200ms ease;
}

.memories-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
}


/* ============================================
   Modal Controls (Filters)
   ============================================ */
.memories-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.memories-filter-select {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    font-size: 0.875rem;
    cursor: pointer;
    transition: border-color 200ms ease, background 200ms ease;
}

.memories-filter-select:hover {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
}

.memories-filter-select:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.4);
}


/* ============================================
   Modal Grid Content
   ============================================ */
.memories-modal-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}


/* ============================================
   Memory Detail Modal
   ============================================ */
.memory-detail-modal {
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.memory-detail-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 1.5rem;
    text-align: center;
}

.memory-detail-orb {
    width: 120px;
    height: 120px;
    margin-bottom: 1.5rem;

    /* Slower, more contemplative animation for detail view */
    animation: orb-float 5s ease-in-out infinite;

    /* Enhanced glow for larger orb */
    box-shadow:
        0 0 40px var(--orb-glow),
        0 0 80px rgba(var(--orb-rgb), 0.25),
        inset 0 -10px 25px rgba(0, 0, 0, 0.15);
}

.memory-detail-orb.salience-high {
    width: 160px;
    height: 160px;
}

.memory-type-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    background: rgba(255, 255, 255, 0.1);
}

.memory-type-badge.type-moment {
    background: rgba(236, 72, 153, 0.2);
    color: #EC4899;
}

.memory-type-badge.type-essence {
    background: rgba(168, 85, 247, 0.2);
    color: #A855F7;
}

.memory-detail-summary {
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1.5;
    margin: 0;
    max-width: 90%;
}

.memory-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
    font-size: 0.875rem;
    opacity: 0.7;
}

.memory-meta-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}


/* ============================================
   Evidence Section
   ============================================ */
.memory-evidence-section {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.memory-evidence-title {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.6;
    margin: 0 0 1rem 0;
}

.memory-evidence-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.memory-evidence-card {
    padding: 1rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0;
    animation: evidence-fade-in 300ms ease forwards;
}

.memory-evidence-card:nth-child(1) { animation-delay: 0ms; }
.memory-evidence-card:nth-child(2) { animation-delay: 150ms; }
.memory-evidence-card:nth-child(3) { animation-delay: 300ms; }
.memory-evidence-card:nth-child(4) { animation-delay: 450ms; }
.memory-evidence-card:nth-child(5) { animation-delay: 600ms; }
.memory-evidence-card:nth-child(6) { animation-delay: 750ms; }

@keyframes evidence-fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.memory-evidence-quote {
    font-style: italic;
    line-height: 1.6;
    margin: 0 0 0.5rem 0;
}

.memory-evidence-quote::before {
    content: '"';
    opacity: 0.5;
}

.memory-evidence-quote::after {
    content: '"';
    opacity: 0.5;
}

.memory-evidence-date {
    font-size: 0.75rem;
    opacity: 0.5;
}


/* ============================================
   Linked Entries Section
   ============================================ */
.memory-linked-section {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.memory-linked-title {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.6;
    margin: 0 0 1rem 0;
}

.memory-linked-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.memory-linked-entry {
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 200ms ease, border-color 200ms ease;
}

.memory-linked-entry:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}


/* ============================================
   Navigation Arrows (Detail Modal)
   ============================================ */
.memory-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 200ms ease, transform 200ms ease;
    z-index: 10;
}

.memory-nav-arrow:hover {
    background: rgba(255, 255, 255, 0.2);
}

.memory-nav-arrow:active {
    transform: translateY(-50%) scale(0.95);
}

.memory-nav-arrow.prev {
    left: 1rem;
}

.memory-nav-arrow.next {
    right: 1rem;
}

.memory-nav-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}


/* ============================================
   Empty State
   ============================================ */
.memories-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
}

.memories-empty-orb {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.5;
}

.memories-empty-title {
    font-size: 1.125rem;
    font-weight: 500;
    margin: 0 0 0.5rem 0;
}

.memories-empty-description {
    font-size: 0.875rem;
    opacity: 0.6;
    margin: 0;
    max-width: 300px;
}


/* ============================================
   Home Page Preview Section
   ============================================ */
.memories-preview-section {
    padding: 1.5rem;
}

.memories-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.memories-preview-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.memories-preview-link {
    font-size: 0.875rem;
    opacity: 0.7;
    cursor: pointer;
    transition: opacity 200ms ease;
}

.memories-preview-link:hover {
    opacity: 1;
}

.memories-preview-grid {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}


/* ============================================
   Load More Button
   ============================================ */
.memories-load-more {
    display: flex;
    justify-content: center;
    padding: 1.5rem;
}

.memories-load-more-btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 200ms ease, border-color 200ms ease;
}

.memories-load-more-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.memories-load-more-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}


/* ============================================
   Responsive Adjustments
   ============================================ */
@media (max-width: 768px) {
    .memories-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 1rem;
        padding: 1rem;
    }

    .memory-orb {
        width: 64px;
        height: 64px;
    }

    .memory-orb.salience-high {
        width: 80px;
        height: 80px;
    }

    .memory-orb.salience-medium {
        width: 64px;
        height: 64px;
    }

    .memory-orb.salience-low {
        width: 52px;
        height: 52px;
    }

    .memories-modal {
        width: 95%;
        max-height: 90vh;
    }

    .memory-detail-modal {
        width: 95%;
    }

    .memory-nav-arrow {
        width: 36px;
        height: 36px;
    }
}


/* ============================================
   Reduced Motion - Accessibility
   Respect user preferences while maintaining visual identity
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .memory-orb {
        animation: none;
    }

    .memory-orb::before,
    .memory-orb::after {
        animation: none;
    }

    .memory-orb:hover {
        transform: scale(1.08);
    }

    .memory-evidence-card {
        animation: none;
        opacity: 1;
    }
}


/* ============================================
   Immersive Memory Detail Modal
   Full-screen dark experience with animated blobs,
   floating particles, parallax orb, and staggered evidence.
   ============================================ */

/* --- Backdrop --- */
.memory-detail-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: #06060a;
    opacity: 0;
    visibility: hidden;
    transition: opacity 400ms ease, visibility 400ms ease;
    overflow: hidden;
    --md-primary-rgb: 168, 85, 247;
    --md-secondary-rgb: 168, 85, 247;
}

.memory-detail-backdrop.active {
    opacity: 1;
    visibility: visible;
}


/* --- Organic Blobs --- */
.md-blob {
    position: absolute;
    border-radius: 40% 60% 55% 45% / 55% 40% 60% 45%;
    pointer-events: none;
    will-change: transform, opacity;
}

.md-blob-1 {
    top: -15%;
    left: -25%;
    width: 110%;
    height: 55%;
    background: rgba(var(--md-primary-rgb), 1);
    opacity: 0.07;
    animation: md-blob1 8s ease-in-out infinite;
    border-radius: 20% 80% 60% 30% / 55% 40% 60% 45%;
}

.md-blob-2 {
    bottom: -10%;
    right: -20%;
    width: 85%;
    height: 45%;
    background: rgba(var(--md-secondary-rgb), 1);
    opacity: 0.06;
    animation: md-blob2 11s ease-in-out infinite;
    border-radius: 50% 25% 35% 70% / 55% 40% 60% 45%;
}

.md-blob-3 {
    top: 35%;
    right: -15%;
    width: 60%;
    height: 30%;
    background: rgba(var(--md-primary-rgb), 1);
    opacity: 0.05;
    animation: md-blob3 9s ease-in-out infinite;
    border-radius: 35% 15% 20% 40% / 55% 40% 60% 45%;
}

.md-blob-4 {
    top: 55%;
    left: -10%;
    width: 50%;
    height: 25%;
    background: rgba(var(--md-secondary-rgb), 1);
    opacity: 0.06;
    animation: md-blob4 7s ease-in-out infinite;
    border-radius: 15% 40% 30% 10% / 55% 40% 60% 45%;
}

@keyframes md-blob1 {
    0%, 100% { transform: translate(-30px, 0) scale(1) rotate(-5deg); opacity: 0.06; }
    30% { transform: translate(15px, 40px) scale(1.2) rotate(0deg); opacity: 0.10; }
    70% { transform: translate(-10px, 15px) scale(1.05) rotate(4deg); opacity: 0.07; }
}

@keyframes md-blob2 {
    0%, 100% { transform: translate(20px, -15px) scale(1.15) rotate(10deg); opacity: 0.06; }
    25% { transform: translate(-35px, 10px) scale(0.9) rotate(0deg); opacity: 0.09; }
    60% { transform: translate(10px, 30px) scale(1.1) rotate(-6deg); opacity: 0.07; }
}

@keyframes md-blob3 {
    0%, 100% { transform: translate(40px, 25px) scale(0.9) rotate(0deg); opacity: 0.05; }
    33% { transform: translate(-25px, -10px) scale(1.1) rotate(10deg); opacity: 0.08; }
    66% { transform: translate(35px, -30px) scale(1.25) rotate(20deg); opacity: 0.06; }
}

@keyframes md-blob4 {
    0%, 100% { transform: translate(-20px, 10px) rotate(15deg); opacity: 0.05; }
    50% { transform: translate(40px, -25px) rotate(-10deg); opacity: 0.08; }
}


/* --- Floating Particles --- */
.md-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    pointer-events: none;
    will-change: transform, opacity;
    animation: md-particle-drift var(--p-dur, 12s) ease-in-out infinite;
    animation-delay: var(--p-delay, 0s);
    opacity: var(--p-opacity, 0.15);
    left: var(--p-x, 50%);
    top: var(--p-y, 50%);
}

.md-particle:nth-child(odd) {
    background: rgba(var(--md-primary-rgb), 1);
}

.md-particle:nth-child(even) {
    background: rgba(var(--md-secondary-rgb), 1);
}

@keyframes md-particle-drift {
    0%, 100% {
        transform: translate(
            calc(var(--p-dx1, 20px)),
            calc(var(--p-dy1, -30px))
        );
        opacity: var(--p-opacity, 0.15);
    }
    33% {
        transform: translate(
            calc(var(--p-dx2, -40px)),
            calc(var(--p-dy2, 20px))
        );
        opacity: calc(var(--p-opacity, 0.15) * 1.5);
    }
    66% {
        transform: translate(
            calc(var(--p-dx3, 30px)),
            calc(var(--p-dy3, 10px))
        );
        opacity: calc(var(--p-opacity, 0.15) * 0.7);
    }
}


/* --- Close Button --- */
.md-close-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10002;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    font-size: 28px;
    font-weight: 300;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 200ms ease;
    line-height: 1;
}

.md-close-btn:hover {
    color: rgba(255, 255, 255, 0.9);
}


/* --- Navigation Arrows --- */
.md-nav-arrow {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10001;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.5);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 200ms ease, background 200ms ease;
}

.memory-detail-backdrop:hover .md-nav-arrow {
    opacity: 1;
}

.md-nav-arrow:hover {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.8);
}

.md-nav-arrow.prev { left: 16px; }
.md-nav-arrow.next { right: 16px; }


/* --- Scroll Container --- */
.md-scroll {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1;
    -webkit-overflow-scrolling: touch;
}


/* --- Orb Section (Parallax) --- */
.md-orb-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 100px 0 32px;
    min-height: 260px;
    will-change: transform;
}

.md-orb-container {
    transition: opacity 250ms ease;
}

/* Nav hint */
.md-nav-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
    animation: md-hint-pulse 3s ease-in-out infinite;
}

.md-nav-hint-text {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.5px;
}

.md-nav-hint-chevron {
    font-size: 20px;
    color: rgba(255, 255, 255, 0.3);
    font-weight: 300;
}

@keyframes md-hint-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}


/* --- Info Section --- */
.md-info-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 32px 80px;
    transition: opacity 300ms ease;
}

/* Subtype badge */
.md-subtype-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 1.2px;
    text-transform: uppercase;
    margin-bottom: 20px;
}

/* Summary */
.md-summary {
    font-size: 24px;
    font-weight: 300;
    line-height: 1.5;
    color: #fff;
    text-align: center;
    letter-spacing: -0.5px;
    margin: 0 0 24px;
    max-width: 600px;
}

/* Meta row */
.md-meta-row {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 32px;
    opacity: 0.45;
}

.md-meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.md-emotion-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.md-meta-text {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 0.2px;
}


/* --- Filter Chips --- */
.md-filter-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 40px;
    width: 100%;
    max-width: 600px;
}

.md-filter-chip {
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.5);
    font-size: 13px;
    cursor: pointer;
    transition: all 200ms ease;
    white-space: nowrap;
}

.md-filter-chip:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.md-filter-chip.active {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-weight: 500;
}


/* --- Evidence Section --- */
.md-evidence-section {
    width: 100%;
    max-width: 600px;
    padding-top: 32px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.md-evidence-title {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    text-align: center;
    margin-bottom: 20px;
}

.md-no-evidence {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.25);
    font-style: italic;
    text-align: center;
    padding: 32px 0;
}


/* --- Evidence Card --- */
.md-evidence-card {
    position: relative;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: background 200ms ease, border-color 200ms ease;
    opacity: 0;
    animation: md-evidence-enter 400ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.md-evidence-card:nth-child(1) { animation-delay: 0ms; }
.md-evidence-card:nth-child(2) { animation-delay: 80ms; }
.md-evidence-card:nth-child(3) { animation-delay: 160ms; }
.md-evidence-card:nth-child(4) { animation-delay: 240ms; }
.md-evidence-card:nth-child(5) { animation-delay: 320ms; }
.md-evidence-card:nth-child(6) { animation-delay: 400ms; }
.md-evidence-card:nth-child(7) { animation-delay: 480ms; }
.md-evidence-card:nth-child(8) { animation-delay: 560ms; }
.md-evidence-card:nth-child(9) { animation-delay: 640ms; }
.md-evidence-card:nth-child(10) { animation-delay: 720ms; }

.md-evidence-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

@keyframes md-evidence-enter {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Decorative quote mark */
.md-quote-mark {
    position: absolute;
    top: 12px;
    left: 16px;
    font-size: 48px;
    font-family: Georgia, serif;
    color: rgba(255, 255, 255, 0.08);
    line-height: 1;
    pointer-events: none;
}

.md-evidence-quote {
    font-size: 16px;
    line-height: 1.625;
    color: rgba(255, 255, 255, 0.8);
    font-family: Georgia, serif;
    font-style: italic;
    padding-left: 8px;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.md-evidence-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.md-evidence-date {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 0.3px;
}

.md-evidence-arrow {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.5);
}


/* --- Responsive --- */
@media (max-width: 768px) {
    .md-orb-section {
        padding-top: 72px;
        min-height: 220px;
    }

    .md-summary {
        font-size: 20px;
    }

    .md-info-section {
        padding: 0 20px 60px;
    }

    .md-nav-arrow {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .md-nav-arrow.prev { left: 8px; }
    .md-nav-arrow.next { right: 8px; }

    .md-evidence-card {
        padding: 18px;
        border-radius: 16px;
    }
}


/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    .md-blob,
    .md-particle {
        animation: none !important;
    }

    .md-blob-1 { opacity: 0.06; }
    .md-blob-2 { opacity: 0.05; }
    .md-blob-3 { opacity: 0.04; }
    .md-blob-4 { opacity: 0.05; }

    .md-evidence-card {
        animation: none !important;
        opacity: 1;
    }

    .md-nav-hint {
        animation: none;
        opacity: 0.8;
    }

    .memory-detail-backdrop {
        transition: opacity 200ms ease, visibility 200ms ease;
    }
}
