:root {
    --dark-carbon: #141418;
    --carbon-surface: #1a1a20;
    --warmer-carbon: #201e24;
    --deepest: #0f0f14;
    --parchment: #d8d0c4;
    --muted-steel: #7a7a88;
    --amber-pulse: #d4a030;
    --copper-dim: #8a6420;
    --whisper-rule: rgba(255, 255, 255, 0.024);
}

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

body {
    background: var(--carbon-surface);
    color: var(--parchment);
    font-family: 'EB Garamond', serif;
    font-size: 16px;
    line-height: 1.75;
    overflow-x: hidden;
}

/* ============================================
   Grain Overlay
   ============================================ */
.grain-filter {
    position: absolute;
    width: 0;
    height: 0;
}

.grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    filter: url(#grain);
    opacity: 0.04;
    pointer-events: none;
    z-index: 200;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 240px;
    height: 100vh;
    background: var(--dark-carbon);
    z-index: 100;
    display: flex;
    flex-direction: column;
    padding: 32px 24px;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
}

.sidebar-identity {
    margin-bottom: 48px;
}

.sidebar-domain {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--parchment);
    letter-spacing: 0.02em;
}

/* Sidebar Navigation */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav-link {
    font-family: 'EB Garamond', serif;
    font-size: 0.85rem;
    color: var(--muted-steel);
    text-decoration: none;
    padding: 6px 0;
    transition: color 0.3s ease;
    letter-spacing: 0.01em;
}

.nav-link:hover,
.nav-link.active {
    color: var(--amber-pulse);
}

/* Sidebar Meta */
.sidebar-meta {
    margin-top: auto;
    padding-top: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.activity-dots {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--amber-pulse);
    opacity: 0.3;
}

.dot:nth-child(1) {
    animation: pulse-dot 4s ease-in-out infinite;
}

.dot:nth-child(2) {
    animation: pulse-dot 4s ease-in-out 0.3s infinite;
}

.dot:nth-child(3) {
    animation: pulse-dot 4s ease-in-out 0.6s infinite;
}

@keyframes pulse-dot {
    0%, 30%, 100% { opacity: 0.3; }
    10% { opacity: 1; }
}

.sidebar-timestamp {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    color: var(--muted-steel);
    letter-spacing: 0.04em;
}

/* Scroll Progress Track */
.scroll-track {
    position: absolute;
    top: 0;
    right: 0;
    width: 2px;
    height: 100%;
    background: rgba(255, 255, 255, 0.03);
}

.scroll-progress {
    width: 100%;
    height: 0%;
    background: var(--amber-pulse);
    transition: height 0.1s linear;
}

/* ============================================
   Content River
   ============================================ */
.content-river {
    margin-left: 240px;
}

/* ============================================
   Sections
   ============================================ */
.section {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    overflow: hidden;
}

.section-dark {
    background: var(--carbon-surface);
}

.section-alt {
    background: var(--warmer-carbon);
}

.section-status {
    background: var(--warmer-carbon);
}

/* Grid-line underlay */
.grid-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 27px,
        rgba(255, 255, 255, 0.024) 27px,
        rgba(255, 255, 255, 0.024) 28px
    );
    opacity: 0;
    transition: opacity 0.8s ease;
    pointer-events: none;
}

.section.in-view .grid-lines {
    opacity: 1;
}

.section:hover .grid-lines {
    background: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 27px,
        rgba(255, 255, 255, 0.05) 27px,
        rgba(255, 255, 255, 0.05) 28px
    );
}

/* Section inner content */
.section-inner {
    position: relative;
    z-index: 1;
    max-width: 65ch;
    padding: 80px 48px;
}

.section-inner-wide {
    max-width: 80ch;
}

/* Sweep line */
.sweep-line {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--amber-pulse);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.6s ease;
}

.section.in-view .sweep-line {
    transform: scaleX(1);
}

/* ============================================
   Section fade-in
   ============================================ */
.section .section-inner {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.section.in-view .section-inner {
    opacity: 1;
}

/* ============================================
   Hero
   ============================================ */
.hero-heading {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(2.5rem, 6vw, 5rem);
    color: var(--parchment);
    letter-spacing: 0.02em;
    line-height: 1.1;
    margin-bottom: 16px;
}

.session-meta {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    color: var(--muted-steel);
    letter-spacing: 0.04em;
}

/* ============================================
   Section Headings
   ============================================ */
.section-heading {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(2rem, 4.5vw, 3.5rem);
    color: var(--parchment);
    letter-spacing: 0.02em;
    margin-bottom: 24px;
    line-height: 1.2;
}

/* ============================================
   Body Text
   ============================================ */
.body-text {
    font-family: 'EB Garamond', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.3vw, 1.1rem);
    line-height: 1.75;
    color: var(--parchment);
    margin-bottom: 16px;
    opacity: 0.88;
}

.body-text-large {
    font-size: clamp(1.1rem, 1.5vw, 1.25rem);
}

/* ============================================
   Code Blocks
   ============================================ */
.code-block {
    background: var(--deepest);
    border-left: 2px solid var(--amber-pulse);
    padding: 16px 20px;
    margin: 24px 0;
    border-radius: 2px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.code-line {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    color: var(--muted-steel);
    letter-spacing: 0.04em;
    line-height: 1.6;
}

.code-key {
    color: var(--amber-pulse);
}

.code-comment {
    color: var(--copper-dim);
    font-style: italic;
}

/* ============================================
   Metrics Row
   ============================================ */
.metrics-row {
    display: flex;
    gap: 48px;
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.metric {
    display: flex;
    flex-direction: column;
}

.metric-val {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: 2rem;
    color: var(--amber-pulse);
    line-height: 1.2;
}

.metric-key {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    color: var(--muted-steel);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-top: 4px;
}

/* ============================================
   Session End
   ============================================ */
.session-end-log {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    color: var(--muted-steel);
    letter-spacing: 0.04em;
    line-height: 2;
}

.end-domain {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--copper-dim);
    margin-top: 48px;
    letter-spacing: 0.02em;
}

/* ============================================
   Mobile Responsive
   ============================================ */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 48px;
        flex-direction: row;
        align-items: center;
        padding: 0 16px;
        border-right: none;
        border-top: 1px solid rgba(255, 255, 255, 0.06);
    }

    .sidebar-identity {
        margin-bottom: 0;
        margin-right: 16px;
    }

    .sidebar-domain {
        font-size: 0.9rem;
    }

    .sidebar-nav {
        flex-direction: row;
        gap: 12px;
        overflow-x: auto;
        flex: 1;
    }

    .nav-link {
        font-size: 0.75rem;
        white-space: nowrap;
    }

    .sidebar-meta {
        margin-top: 0;
        padding-top: 0;
        border-top: none;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .scroll-track {
        display: none;
    }

    .content-river {
        margin-left: 0;
        padding-bottom: 48px;
    }

    .section-inner {
        padding: 60px 24px;
    }

    .metrics-row {
        flex-direction: column;
        gap: 24px;
    }
}
