:root {
    --page-padding: 18px 22px 34px;
    --page-padding-mobile: 10px 8px 24px;
    --event-card-width: 228px;
}

.timeline-wrap {
    margin: 0 auto;
    max-width: 1700px;
    overflow-x: scroll;
    padding-bottom: 6px;
    cursor: grab;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.timeline-wrap.is-dragging {
    cursor: grabbing;
    user-select: none;
}

@supports selector(::-webkit-scrollbar) {
    .timeline-wrap::-webkit-scrollbar {
        display: none;
    }
}

.timeline-scrollbar-shell {
    position: sticky;
    bottom: 14px;
    z-index: 45;
    max-width: 1700px;
    margin: 14px auto 0;
    padding: 12px 14px 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: color-mix(in oklab, var(--surface) 90%, transparent);
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(10px);
}

.timeline-scrollbar-shell.is-disabled {
    opacity: 0.55;
}

.timeline-scrollbar-track {
    position: relative;
    height: 20px;
    border-radius: 999px;
    background: linear-gradient(
        90deg,
        color-mix(in oklab, var(--surface-2) 92%, transparent),
        color-mix(in oklab, var(--axis) 62%, var(--surface-2))
    );
    border: 1px solid color-mix(in oklab, var(--axis) 55%, var(--border));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        inset 0 -1px 0 rgba(0, 0, 0, 0.12);
    cursor: pointer;
}

.timeline-scrollbar-thumb {
    position: absolute;
    top: 1px;
    left: 0;
    height: calc(100% - 2px);
    min-width: 104px;
    border-radius: 999px;
    background: linear-gradient(
        90deg,
        color-mix(in oklab, #7dd3fc 42%, var(--surface)),
        color-mix(in oklab, #38bdf8 68%, var(--surface))
    );
    border: 1px solid color-mix(in oklab, #9bdcff 68%, var(--border));
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.08),
        0 8px 18px rgba(22, 94, 124, 0.3);
    cursor: grab;
    touch-action: none;
    transition:
        transform 0.08s linear,
        box-shadow 0.2s ease,
        filter 0.2s ease;
}

.timeline-scrollbar-thumb:hover {
    filter: brightness(1.08);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.16),
        0 10px 22px rgba(22, 94, 124, 0.38);
}

.timeline-scrollbar-thumb.is-dragging {
    cursor: grabbing;
    filter: brightness(1.12);
}

.timeline {
    min-height: 740px;
    min-width: 1200px;
}

.timeline-axis {
    position: absolute;
    left: 60px;
    right: 60px;
    top: 50%;
    height: 4px;
    border-radius: 999px;
    background: var(--axis);
    transform: translateY(-50%);
    z-index: 0;
}

.timeline-break {
    position: absolute;
    width: 34px;
    height: 32px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 3;
}

.timeline-break::before,
.timeline-break::after {
    content: "";
    position: absolute;
    top: 4px;
    width: 6px;
    height: 24px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    border-radius: 999px;
    transform: rotate(-28deg);
    box-shadow: 0 0 0 1px color-mix(in oklab, var(--surface) 72%, transparent);
}

.timeline-break::before {
    left: 8px;
}

.timeline-break::after {
    left: 18px;
}

.timeline-break-label {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    padding: 4px 9px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: color-mix(in oklab, var(--surface) 92%, transparent);
    color: var(--muted);
    font-size: 0.64rem;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.02em;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(8px);
}

.timeline-break[data-kind="expanded"]::before,
.timeline-break[data-kind="expanded"]::after {
    border-left-color: color-mix(in oklab, #4fc3f7 58%, var(--border));
    border-right-color: color-mix(in oklab, #4fc3f7 58%, var(--border));
}

.timeline-break[data-kind="expanded"] .timeline-break-label {
    color: color-mix(in oklab, var(--text) 82%, #4fc3f7);
    border-color: color-mix(in oklab, #4fc3f7 40%, var(--border));
}

.year-marker {
    position: absolute;
    top: calc(50% - 10px);
    width: 2px;
    height: 20px;
    background: var(--axis);
    transition: opacity 0.3s ease;
}

.year-marker span {
    position: absolute;
    top: 21px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.82rem;
    color: var(--muted);
    font-weight: 700;
    white-space: nowrap;
}

.period-marker {
    position: absolute;
    top: 12px;
    font-size: 0.78rem;
    background: var(--surface-2);
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 7px 10px;
    min-height: 34px;
    text-align: center;
    line-height: 1.25;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.event-card.in-view {
    animation-duration: 0.5s;
    animation-timing-function: ease-out;
    animation-fill-mode: both;
}

.event-card.side-top {
    transform: translate(-50%, 24px);
}

.event-card.side-bottom {
    transform: translate(-50%, -24px);
}

.event-card.side-top.in-view {
    animation-name: reveal-top;
}

.event-card.side-bottom.in-view {
    animation-name: reveal-bottom;
}

.event-card.filtered-out {
    opacity: 0;
    transform: translate(-50%, 0) scale(0.95);
    pointer-events: none;
    visibility: hidden;
}

@keyframes reveal-top {
    from {
        opacity: 0;
        transform: translate(-52%, 30px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

@keyframes reveal-bottom {
    from {
        opacity: 0;
        transform: translate(-48%, -30px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.connector {
    position: absolute;
    width: 2px;
    background: color-mix(in oklab, var(--axis) 85%, transparent);
    z-index: -1;
}

@media (max-width: 980px) {
    :root {
        --event-card-width: 210px;
    }

    .timeline {
        min-width: 980px;
        min-height: 820px;
    }

    .timeline-break-label {
        display: none;
    }

    .timeline-scrollbar-shell {
        bottom: 10px;
        padding: 10px 12px 12px;
    }
}

@media (max-width: 640px) {
    .timeline {
        min-width: 860px;
    }

    .timeline-scrollbar-shell {
        margin-top: 10px;
    }

    .timeline-scrollbar-track {
        height: 18px;
    }
}
