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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: Arial, sans-serif;
    background-color: #f4f4f4;
}

.container {
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
}

header {
    padding: 20px;
    background: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    text-align: center;
    position: relative;
    z-index: 10;
}

h1 {
    color: #333;
    font-size: 1.5em;
}

.file-label {
    display: inline-block;
    padding: 10px 20px;
    background-color: #0078d4;
    color: white;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 10px;
}

input[type="file"] {
    display: none;
}

.filter {
    padding: 10px;
    background: #fff;
    overflow-x: auto;
    white-space: nowrap;
    display: flex;
    gap: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    z-index: 5;
    flex-shrink: 0; /* Prevent shrinking */
}

.tag-button {
    display: inline-block;
}

.tag-button input[type="checkbox"] {
    display: none;
}

.tag-button label {
    padding: 8px 12px;
    background-color: #ddd;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
    font-size: 0.9em;
}

.tag-button input[type="checkbox"]:checked + label {
    background-color: #0078d4;
    color: white;
}

/* Desktop: Multi-row horizontal layout with connecting line */
@media (min-width: 769px) {
    .timeline {
        flex: 1;
        overflow-x: auto;
        overflow-y: auto;
        padding: 20px;
        display: flex;
        flex-wrap: wrap;
        gap: 30px;
        align-content: flex-start;
        scroll-behavior: smooth;
        cursor: grab;
        position: relative;
    }

    .timeline:active {
        cursor: grabbing;
    }

    .timeline-item {
        position: relative;
        width: 300px;
        padding: 20px;
        background: white;
        border-radius: 8px;
        box-shadow: 0 4px 10px rgba(0,0,0,0.1);
        text-align: center;
        z-index: 1; /* Above the line */
    }

    .timeline-item::before {
        content: var(--marker-content, '');
        position: absolute;
        width: 32px;
        height: 32px;
        top: 125px;
        left: 50%;
        transform: translateX(-50%);
        background: var(--dot-color, #0078d4);
        border-radius: 50%;
        font-size: 20px;
        line-height: 32px;
        overflow: hidden;
        z-index: 2; /* Above the line */
    }

    /* Connecting line as SVG (managed via JS) */
    .timeline svg.connecting-line {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        pointer-events: none;
        z-index: 0;
    }
}

/* Mobile: Vertical layout */
@media (max-width: 768px) {
    .timeline {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 20px;
        display: flex;
        flex-direction: column;
        align-items: center;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }

    .timeline::before {
        content: '';
        position: fixed;
        top: 0;
        left: 50%;
        width: 2px;
        height: 100%;
        background: #ccc;
        transform: translateX(-50%);
        z-index: 0;
    }

    .timeline-item {
        position: relative;
        width: 90%;
        max-width: 300px;
        padding: 15px;
        background: white;
        border-radius: 8px;
        box-shadow: 0 4px 10px rgba(0,0,0,0.1);
        margin: 20px 0;
        text-align: center;
        z-index: 1;
    }

    .timeline-item::before {
        content: var(--marker-content, '');
        position: absolute;
        width: 28px;
        height: 28px;
        top: 50%;
        left: -42px;
        transform: translateY(-50%);
        background: var(--dot-color, #0078d4);
        border-radius: 50%;
        font-size: 18px;
        line-height: 28px;
        overflow: hidden;
    }
}

.timeline-item.has-image::before {
    background-image: var(--marker-image);
    background-size: cover;
    background-position: center;
    background-color: transparent;
}

.date {
    font-weight: bold;
    color: #0078d4;
    font-size: 1em;
}

.event {
    margin: 10px 0;
    font-size: 1.2em;
}

.description {
    color: #666;
    font-size: 1em;
}

.tags {
    font-size: 0.9em;
    color: #888;
    margin-top: 5px;
}

.link {
    margin-top: 10px;
    font-size: 0.9em;
}

.link a {
    color: #0078d4;
    text-decoration: none;
    word-break: break-all;
}

.link a:hover {
    text-decoration: underline;
}