:root {
    --bg: #11161f;
    --surface: #1a2230;
    --surface-2: #202b3d;
    --text: #e9edf5;
    --muted: #a8b3c6;
    --axis: #3b4658;
    --border: #2f3b50;
    --shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
    --page-padding: 18px 22px 34px;
    --page-padding-mobile: 10px 8px 24px;
    --event-card-width: 228px;
    --event-card-min-height: 0;
}

:root.light {
    --bg: #f7f8fb;
    --surface: #ffffff;
    --surface-2: #f0f4fa;
    --text: #2f3641;
    --muted: #6e7787;
    --axis: #d6dde8;
    --border: #dbe2ec;
    --shadow: 0 8px 22px rgba(18, 28, 45, 0.12);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background:
        radial-gradient(circle at 20% -20%, #243147 0%, transparent 45%),
        radial-gradient(circle at 95% 0%, #1f3644 0%, transparent 40%),
        var(--bg);
    color: var(--text);
    min-height: 100vh;
}

:root.light body {
    background:
        radial-gradient(circle at 0% -30%, #d9e9ff 0%, transparent 45%),
        radial-gradient(circle at 100% 0%, #ffe8d8 0%, transparent 36%),
        var(--bg);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    backdrop-filter: blur(12px);
    background: color-mix(in oklab, var(--surface) 83%, transparent);
    border-bottom: 1px solid var(--border);
    padding: 14px 20px 12px;
}

.topbar-main {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.topbar-title {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.view-tag {
    margin: 0;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: clamp(1.1rem, 2.2vw, 1.6rem);
}

.view-link,
.theme-toggle {
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    border-radius: 999px;
    padding: 8px 12px;
    text-decoration: none;
}

.theme-toggle {
    cursor: pointer;
}

.view-link:hover,
.theme-toggle:hover {
    filter: brightness(1.05);
}

.filters,
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.legend {
    display: none;
}

.filter-btn,
.badge {
    border-radius: 999px;
    border: 1px solid transparent;
    padding: 6px 11px;
    font-size: 0.72rem;
    line-height: 1;
}

.filter-btn {
    cursor: pointer;
    color: #fff;
    opacity: 0.65;
    transform: translateY(0);
    transition:
        opacity 0.2s ease,
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

.filter-btn:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}

.filter-btn.active {
    opacity: 1;
    box-shadow: 0 0 0 2px color-mix(in oklab, white 40%, transparent);
}

.badge {
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.page {
    padding: var(--page-padding);
}

.timeline {
    position: relative;
}

.year-markers,
.period-markers,
.events-layer {
    position: absolute;
    inset: 0;
}

.year-markers,
.period-markers {
    z-index: 1;
}

.events-layer {
    z-index: 2;
}

.event-card {
    position: absolute;
    width: var(--event-card-width);
    min-height: var(--event-card-min-height);
    border-radius: 10px;
    border: 1px solid var(--border);
    border-left-width: 4px;
    background: var(--surface);
    padding: 14px 14px 12px;
    box-shadow: var(--shadow);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    outline: none;
    transition:
        opacity 0.3s ease,
        transform 0.3s ease,
        visibility 0.3s ease;
}

.event-card.is-visible {
    opacity: 1;
    visibility: visible;
}

.event-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
}

.event-date {
    font-size: 0.78rem;
    color: var(--muted);
    margin: 0;
}

.event-title {
    margin: 0;
    font-size: 0.99rem;
    line-height: 1.25;
}

.event-desc {
    margin-top: 8px;
    color: color-mix(in oklab, var(--text) 90%, var(--muted));
    font-size: 0.7rem;
    line-height: 1.35;
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 90;
}

.modal.open {
    display: block;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.modal-card {
    position: relative;
    z-index: 1;
    width: min(760px, calc(100vw - 30px));
    margin: 9vh auto;
    background: var(--surface);
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 22px;
    max-height: 80vh;
    overflow: auto;
}

.modal-close {
    position: sticky;
    top: 0;
    float: right;
    border: 0;
    background: var(--surface-2);
    color: var(--text);
    border-radius: 8px;
    width: 32px;
    height: 32px;
    cursor: pointer;
}

.modal-date {
    color: var(--muted);
    margin: 0;
}

.modal-full-title {
    margin: 6px 0 12px;
    font-style: italic;
    color: var(--muted);
}

.modal-description {
    line-height: 1.6;
}

a {
    color: #62a8ff;
}

:root.light a {
    color: #245ecf;
}

@media (max-width: 720px) {
    .page {
        padding: var(--page-padding-mobile);
    }

    .topbar {
        padding: 10px;
    }

    .topbar-main {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar-actions {
        justify-content: space-between;
    }
}
