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

:root {
    --bg: #0a0a0a;
    --glass-bg: rgba(255, 255, 255, 0.06);
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-glow: rgba(255, 60, 60, 0.1);
    --text: #e8e8e8;
    --text-muted: #888;
    --accent: rgba(255, 80, 80, 0.8);
    --accent-bright: #ff4444;
    --glow-color: rgba(255, 50, 50, 0.35);
    --glow-soft: rgba(255, 80, 80, 0.15);
    --timeline-line: rgba(255, 255, 255, 0.15);
}

::selection {
    background: rgba(255, 60, 60, 0.4);
    color: #fff;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Geist Variable', -apple-system, BlinkMacSystemFont, sans-serif;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

/* Header */
#site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 16px 20px;
    background: rgba(10, 10, 10, 0.3);
    backdrop-filter: blur(2px) saturate(1.2) url(#liquid-refract);
    -webkit-backdrop-filter: blur(2px) saturate(1.2) url(#liquid-refract);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-inner {
    max-width: 720px;
    margin: 0 auto;
}

.logo {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* Glass pill */
.glass-pill {
    display: inline-block;
    position: relative;
    padding: 10px 32px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    backdrop-filter: blur(2px) saturate(1.2) url(#liquid-refract);
    -webkit-backdrop-filter: blur(2px) saturate(1.2) url(#liquid-refract);
    box-shadow:
        0 2px 12px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.15),
        inset 0 -1px 0 rgba(255, 255, 255, 0.05);
    font-size: 0.9rem;
    color: var(--text);
    text-align: center;
    overflow: visible;
}

/* Timeline header */
.timeline-header {
    text-align: center;
    padding: 24px 20px 8px;
    max-width: 720px;
    margin: 0 auto;
}

/* Timeline */
.timeline {
    position: relative;
    max-width: 720px;
    margin: 0 auto;
    padding: 20px 20px 60px 80px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 60px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(180deg, transparent, rgba(255, 80, 80, 0.3) 10%, rgba(255, 80, 80, 0.3) 90%, transparent);
    box-shadow: 0 0 10px rgba(255, 50, 50, 0.15), 0 0 30px rgba(255, 50, 50, 0.08);
}

/* Moving glow overlay on the line */
.timeline-line-glow {
    position: absolute;
    left: 51px;
    width: 20px;
    height: 80px;
    pointer-events: none;
    z-index: 1;
}

.timeline-line-glow::before {
    content: '';
    position: absolute;
    left: 9px;
    top: 0;
    width: 2px;
    height: 100%;
    background: radial-gradient(ellipse 2px 40px at center 50%, rgba(255, 120, 80, 0.9) 0%, rgba(255, 60, 40, 0.5) 30%, transparent 70%);
}

.timeline-line-glow::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse 20px 60px at center 50%, rgba(255, 50, 50, 0.2) 0%, transparent 70%);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(60px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Timeline item */
.timeline-item {
    position: relative;
    margin-bottom: 32px;
    opacity: 0;
    animation: slideUp 0.6s ease-out forwards;
}

/* Dot */
@keyframes dotPulse {
    0%, 100% { box-shadow: 0 0 8px var(--glow-color), 0 0 20px var(--glow-soft); }
    50% { box-shadow: 0 0 14px var(--glow-color), 0 0 35px var(--glow-soft), 0 0 60px rgba(255, 50, 50, 0.12); }
}

@keyframes dotHit {
    0% { box-shadow: 0 0 8px var(--glow-color), 0 0 20px var(--glow-soft); }
    40% { box-shadow: 0 0 20px rgba(255, 80, 50, 0.8), 0 0 40px rgba(255, 60, 40, 0.5), 0 0 70px rgba(255, 50, 50, 0.25); }
    100% { box-shadow: 0 0 8px var(--glow-color), 0 0 20px var(--glow-soft); }
}

.timeline-dot {
    position: absolute;
    left: -26px;
    top: 4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-bright);
    box-shadow: 0 0 10px var(--glow-color), 0 0 25px var(--glow-soft);
    z-index: 2;
    cursor: pointer;
    transition: transform 0.2s ease;
    animation: dotPulse 2.5s ease-in-out infinite;
}

/* Read state: hollow ring with opaque center to mask line */
.timeline-dot.read {
    background: #0a0a0a;
    border: 2px solid rgba(255, 80, 80, 0.4);
    box-shadow: none;
    animation: none;
}

.timeline-item:hover .timeline-dot,
.timeline-item.active .timeline-dot {
    transform: scale(1.3);
    box-shadow: 0 0 14px var(--glow-color), 0 0 35px var(--glow-soft), 0 0 60px rgba(255, 50, 50, 0.15);
}

.timeline-item:hover .timeline-dot.read,
.timeline-item.active .timeline-dot.read {
    border-color: rgba(255, 80, 80, 0.6);
    box-shadow: 0 0 10px rgba(255, 50, 50, 0.2);
}

/* Date label - always visible */
.timeline-date {
    position: absolute;
    left: -76px;
    top: 0;
    width: 44px;
    text-align: right;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1.2;
    text-transform: uppercase;
}

.timeline-date .month {
    display: block;
}

.timeline-date .day {
    display: block;
    font-size: 1rem;
    color: var(--text);
}

/* Animated glow on cards */
@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 30px rgba(255, 50, 50, 0.08), 0 0 60px rgba(255, 50, 50, 0.04);
    }
    50% {
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 50px rgba(255, 50, 50, 0.18), 0 0 100px rgba(255, 50, 50, 0.08);
    }
}

@keyframes borderGlow {
    0%, 100% { border-color: rgba(255, 80, 80, 0.15); }
    50% { border-color: rgba(255, 80, 80, 0.35); }
}

/* Card - hidden by default, shown on hover */
.timeline-card {
    position: relative;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    backdrop-filter: blur(2px) saturate(1.2) url(#liquid-refract);
    -webkit-backdrop-filter: blur(2px) saturate(1.2) url(#liquid-refract);
    overflow: visible;
    cursor: pointer;
    opacity: 0;
    transform: translateX(10px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease, background 0.3s ease;
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.15),
        inset 0 -1px 0 rgba(255, 255, 255, 0.05);
    margin-top: -8px;
}

.timeline-item:hover .timeline-card,
.timeline-item.active .timeline-card {
    opacity: 1;
    transform: translateX(0) scale(1);
    pointer-events: auto;
    animation: borderGlow 3s ease-in-out infinite;
}

.card-body {
    display: flex;
    gap: 16px;
    padding: 16px;
}

.card-thumb {
    width: 100px;
    min-width: 100px;
    height: 80px;
    border-radius: 10px;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.05);
}

.card-info {
    flex: 1;
    min-width: 0;
}

.card-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 6px;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.card-excerpt {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Article preview in hover tile */
.card-preview {
    position: relative;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.4s ease, opacity 0.4s ease;
}

.timeline-item:hover .card-preview,
.timeline-item.active .card-preview {
    max-height: 120px;
    opacity: 1;
}

.card-preview-inner {
    padding: 0 16px;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.card-preview-inner .markdown-body {
    font-size: 0.8rem;
    line-height: 1.5;
}

.card-preview-inner .markdown-body h1,
.card-preview-inner .markdown-body h2,
.card-preview-inner .markdown-body h3 {
    font-size: 0.85rem;
    margin-top: 0.5em;
}

.card-preview-fade {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(to bottom, transparent, rgba(10, 10, 10, 0.95));
    pointer-events: none;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px 14px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.card-footer .read-more {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Tags */
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.tag {
    display: inline-block;
    padding: 4px 12px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: var(--text);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Featured card (first item) */
.timeline-card.featured {
    padding: 0;
}

.featured-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.featured .card-body {
    display: block;
    padding: 20px;
}

.featured .card-body h3 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}


/* Rotating border light */
@keyframes rotateBorderLight {
    0% { --border-angle: 0deg; }
    100% { --border-angle: 360deg; }
}

@property --border-angle {
    syntax: "<angle>";
    initial-value: 0deg;
    inherits: false;
}

/* Reusable rotating border glow */
.glow-border {
    position: relative;
}

.glow-border::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: conic-gradient(
        from var(--border-angle),
        transparent 40%,
        rgba(255, 60, 40, 0.5) 48%,
        rgba(255, 120, 80, 0.7) 50%,
        rgba(255, 60, 40, 0.5) 52%,
        transparent 60%
    );
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 1;
    pointer-events: none;
    animation: rotateBorderLight 4s linear infinite;
}

/* Cards: show glow on hover/active */
.timeline-item:hover .timeline-card::before,
.timeline-item.active .timeline-card::before {
    opacity: 1;
}

/* Buttons: always show glow when visible */
.back-btn::before {
    opacity: 1;
}


/* Back button — fixed overlay, hidden by default */
.back-btn {
    cursor: pointer;
    border: none;
    font-family: inherit;
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    opacity: 0;
    pointer-events: none;
}

.back-btn {
    overflow: visible;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Card article content area — hidden by default */
.card-article {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
}

.card-article-inner {
    padding: 0 16px 16px;
}

/* Fade timeline line via CSS variable */
.timeline.line-fading::before {
    opacity: var(--line-opacity, 1) !important;
    animation: none !important;
}

/* When card is being expanded by JS */
.timeline-card.expanding {
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: none !important;
    animation: none !important;
    transition: none !important;
    border: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
    margin: 0 !important;
}

.timeline-card.expanding::before {
    display: none !important;
}

.timeline-card.expanding > * {
    width: 100%;
}


/* Article header inside card */
.card-article .article-header {
    margin-bottom: 32px;
}

.article-featured-image {
    display: block;
    width: 100%;
    max-height: 240px;
    object-fit: cover;
    border-radius: 18px;
    margin: 0 0 24px;
}

.card-article .article-header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
    margin-bottom: 12px;
}

.article-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* Markdown content */
.markdown-body {
    line-height: 1.7;
    font-size: 1rem;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
    margin-top: 2em;
    margin-bottom: 0.5em;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.markdown-body h1 { font-size: 1.6rem; }
.markdown-body h2 { font-size: 1.3rem; }
.markdown-body h3 { font-size: 1.1rem; }

.markdown-body p {
    margin-bottom: 1em;
    color: rgba(232, 232, 232, 0.85);
}

.markdown-body a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.markdown-body img {
    max-width: 100%;
    border-radius: 12px;
    margin: 1em 0;
}

.markdown-body blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 16px;
    margin: 1.5em 0;
    color: var(--text-muted);
    font-style: italic;
}

.markdown-body pre {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 16px;
    overflow-x: auto;
    margin: 1.5em 0;
}

.markdown-body code {
    font-family: 'Geist Mono Variable', 'SF Mono', monospace;
    font-size: 0.88em;
}

.markdown-body :not(pre) > code {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
}

.markdown-body ul,
.markdown-body ol {
    padding-left: 1.5em;
    margin-bottom: 1em;
}

.markdown-body li {
    margin-bottom: 0.3em;
    color: rgba(232, 232, 232, 0.85);
}

.markdown-body hr {
    border: none;
    height: 1px;
    background: var(--glass-border);
    margin: 2em 0;
}

/* Section reader — Apple-style section-by-section */
.section-reader {
    height: 100vh;
    overflow: hidden;
    position: relative;
}

.article-section {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    overflow-y: auto;
    max-width: 720px;
    margin: 0 auto;
    opacity: 0;
    pointer-events: none;
    overscroll-behavior: contain;
    scrollbar-width: none;
}

.article-section.visible {
    opacity: 1;
    pointer-events: auto;
}

.article-section::-webkit-scrollbar {
    display: none;
}

.article-section-content {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 60px 20px;
    box-sizing: border-box;
}

.article-section-content.section-magnetized {
    transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
}

.article-section-intro .article-section-content {
    justify-content: center;
}

.article-section-intro .article-header {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}

.article-section-intro.visible .article-header {
    opacity: 1;
    transform: translateY(0);
}

.article-section-story .article-section-content {
    justify-content: center;
    padding-top: 48px;
    padding-bottom: 56px;
}

/* Story section entrance: H3 and paragraph slide up + fade in */
.article-section-story .story-frame .section-context.story-h3,
.article-section-story .story-frame .substory-carousel {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform, opacity;
}

.article-section-story.visible .story-frame .section-context.story-h3 {
    opacity: 1;
    transform: translateY(0);
}

.article-section-story.visible .story-frame .substory-carousel {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.07s;
}

.article-section-chapter-intro .article-section-content {
    display: block;
    min-height: auto;
    padding: 0;
}

.section-context {
    margin-bottom: 16px;
}

.section-context-h2,
.section-context-h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: -0.01em;
    text-transform: uppercase;
    margin: 0 0 4px;
}

.section-context-h3 {
    font-size: clamp(1.2rem, 2vw, 1.7rem);
    font-weight: 600;
    color: var(--text);
    text-transform: none;
    letter-spacing: -0.03em;
    opacity: 1;
}

.story-frame {
    width: min(100%, 760px);
    min-height: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.story-h2 {
    position: fixed;
    top: max(86px, env(safe-area-inset-top, 0px) + 72px);
    left: max(24px, calc(50vw - 340px));
    right: auto;
    margin: 0;
    width: min(280px, calc(100vw - 48px));
    text-align: left;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.5s ease, transform 0.5s ease;
    z-index: 4;
}

.article-section.visible .story-h2 {
    opacity: 1;
    transform: translateY(0);
}

.story-h2 .section-context-h2 {
    font-size: 0.74rem;
    letter-spacing: 0.14em;
    color: rgba(255, 255, 255, 0.68);
}

.story-h3 {
    text-align: center;
    margin-bottom: 18px;
}

.article-section-chapter-intro {
    background: var(--bg);
    overflow: hidden; /* animations are gesture-driven, no internal scroll */
}

.article-section-chapter-intro .story-h2 {
    opacity: 0; /* controlled by JS — starts hidden */
    will-change: transform, opacity;
}

.article-section-chapter-intro .story-h3,
.article-section-chapter-intro .substory-carousel {
    opacity: 0; /* controlled by JS applyChapterIntroProgress */
    will-change: transform, opacity;
}

.chapter-transition-stage {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.chapter-transition-title {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 24px;
    font-size: clamp(2rem, 5vw, 3.6rem);
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1.05;
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
    opacity: 1; /* controlled by JS applyChapterIntroProgress */
    will-change: transform, opacity;
}

.article-toc {
    background: transparent;
}

.chapter-intro-frame {
    position: relative;
    z-index: 1;
    opacity: 1;
}

.chapter-transition-spacer {
    height: 0; /* no longer needed — progress is gesture-driven */
    display: none;
}

.substory-carousel {
    position: relative;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.substory-viewport {
    overflow: hidden;
    touch-action: pan-y;
    cursor: grab;
}

.substory-viewport.carousel-magnetized {
    transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
}

.substory-viewport:active {
    cursor: grabbing;
}

.substory-track {
    display: flex;
    transition: transform 0.45s ease;
    will-change: transform;
}

.substory-slide {
    min-width: 100%;
    flex: 0 0 100%;
    opacity: 0.2;
    transform: translateX(24px);
    transition: opacity 0.35s ease, transform 0.35s ease;
    display: flex;
    justify-content: center;
}

.substory-slide.active {
    opacity: 1;
    transform: translateX(0);
}

.paragraph-carousel .substory-slide > * {
    width: min(100%, 700px);
    margin: 0 auto;
    text-align: justify;
    text-wrap: pretty;
}

.paragraph-carousel .substory-slide p,
.paragraph-carousel .substory-slide li,
.paragraph-carousel .substory-slide blockquote {
    font-size: clamp(1.05rem, 2vw, 1.28rem);
    line-height: 1.42;
}

.substory-slide > *:last-child {
    margin-bottom: 0;
}

.carousel-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 28px;
}

.carousel-nav {
    min-width: 88px;
    padding: 8px 18px;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
}

.carousel-nav:disabled {
    opacity: 0.35;
    cursor: default;
}

.carousel-dots {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.carousel-dot {
    width: 8px;
    height: 8px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
    box-shadow: none;
    cursor: pointer;
    transition: transform 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
}

.carousel-dot.active {
    background: var(--accent-bright);
    transform: scale(1.2);
    box-shadow: 0 0 10px rgba(255, 80, 80, 0.35);
}

.dots-only {
    min-height: 18px;
}

/* Table of contents — right side */
.article-toc {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 250;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-end;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    max-height: 80vh;
    overflow-y: auto;
    scrollbar-width: none;
    padding: 8px 0;
}

.article-toc::-webkit-scrollbar {
    display: none;
}

.article-toc.visible {
    opacity: 1;
    pointer-events: auto;
}

.toc-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    flex-direction: row-reverse;
    padding: 2px 0;
}

.toc-line {
    height: 2px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 1px;
    transition: background 0.3s ease, width 0.3s ease;
}

.toc-level-1 .toc-line { width: 28px; }
.toc-level-2 .toc-line { width: 18px; }
.toc-level-3 .toc-line { width: 10px; }

.toc-item.active .toc-line {
    background: var(--accent-bright);
    box-shadow: 0 0 6px var(--glow-color);
}

.toc-item:hover .toc-line {
    background: rgba(255, 255, 255, 0.5);
}

.toc-label {
    font-size: 0;
    max-width: 0;
    overflow: hidden;
    white-space: nowrap;
    color: var(--text-muted);
    transition: font-size 0.3s ease, max-width 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    text-align: right;
}

.article-toc:hover .toc-label {
    font-size: 0.78rem;
    max-width: 200px;
    opacity: 1;
}

.toc-level-2 .toc-label { padding-right: 10px; }
.toc-level-3 .toc-label { padding-right: 20px; }

.toc-item.active .toc-label {
    color: var(--text);
}

.toc-item:hover .toc-label {
    color: var(--text);
}

/* Bookmark marker in TOC */
.toc-bookmark .toc-line {
    width: 22px;
    height: 3px;
    background: var(--accent-bright);
    box-shadow: 0 0 6px var(--glow-color), 0 0 12px var(--glow-soft);
    border-radius: 2px;
}

.toc-bookmark .toc-label {
    color: var(--accent);
}

.article-toc:hover .toc-bookmark .toc-label {
    color: var(--accent-bright);
}

/* Mobile-only elements: hidden on desktop */
.toc-progress-bar,
.toc-fab,
.toc-mobile-panel {
    display: none;
}

/* Responsive */
@media (max-width: 600px) {
    .timeline {
        padding-left: 60px;
    }

    .timeline::before {
        left: 40px;
    }

    /* Align glow beam with the mobile timeline line (left: 40px, beam core at +9px) */
    .timeline-line-glow {
        left: 31px;
    }

    .timeline-dot {
        left: -26px;
    }

    .timeline-date {
        left: -56px;
        width: 36px;
        font-size: 0.68rem;
    }

    .timeline-date .day {
        font-size: 0.88rem;
    }

    .card-thumb {
        width: 80px;
        min-width: 80px;
        height: 64px;
    }

    .featured-image {
        height: 160px;
    }

    .featured .card-body h3 {
        font-size: 1.15rem;
    }

    .article-content .article-header h1 {
        font-size: 1.5rem;
    }

    /* Hide desktop TOC on mobile — replaced by FAB */
    .article-toc {
        display: none;
    }

    /* Reading progress bar — mobile only */
    .toc-progress-bar {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 3px;
        z-index: 310;
        background: rgba(255, 255, 255, 0.08);
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .toc-progress-bar.visible {
        opacity: 1;
    }

    .toc-progress-fill {
        height: 100%;
        width: 0%;
        background: var(--accent-bright);
        box-shadow: 0 0 8px var(--glow-color);
        transition: width 0.4s ease;
    }

    /* Floating action button — opens mobile TOC */
    .toc-fab {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        bottom: 24px;
        right: 16px;
        width: 48px;
        height: 48px;
        border-radius: 50%;
        border: none;
        background: rgba(30, 30, 42, 0.97);
        color: var(--text);
        cursor: pointer;
        z-index: 305;
        box-shadow: 0 2px 16px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease, background 0.2s ease, transform 0.2s ease;
    }

    .toc-fab.visible {
        opacity: 1;
        pointer-events: auto;
    }

    .toc-fab.active {
        background: var(--accent);
        transform: rotate(90deg);
    }

    /* Mobile TOC panel */
    .toc-mobile-panel {
        display: block;
        position: fixed;
        bottom: 84px;
        right: 16px;
        background: rgba(18, 18, 28, 0.98);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 14px;
        padding: 8px 4px;
        z-index: 304;
        max-height: 60vh;
        overflow-y: auto;
        min-width: 220px;
        max-width: calc(100vw - 32px);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7);
        opacity: 0;
        pointer-events: none;
        transform: scale(0.95) translateY(8px);
        transform-origin: bottom right;
        transition: opacity 0.2s ease, transform 0.2s ease;
        scrollbar-width: thin;
        scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
    }

    .toc-mobile-panel.open {
        opacity: 1;
        pointer-events: auto;
        transform: scale(1) translateY(0);
    }

    .toc-mobile-item {
        display: block;
        padding: 9px 16px;
        cursor: pointer;
        border-radius: 8px;
        color: var(--text-muted);
        font-size: 0.84rem;
        line-height: 1.35;
        transition: background 0.15s ease, color 0.15s ease;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .toc-mobile-item.toc-level-2 {
        padding-left: 24px;
        font-size: 0.8rem;
    }

    .toc-mobile-item.toc-level-3 {
        padding-left: 36px;
        font-size: 0.75rem;
        color: var(--text-dim, rgba(255, 255, 255, 0.35));
    }

    .toc-mobile-item:active {
        background: rgba(255, 255, 255, 0.07);
    }

    .toc-mobile-item.active {
        color: var(--accent-bright);
    }
}

