:root {
    color-scheme: dark;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, system-ui, sans-serif;
    background: radial-gradient(circle at top left, rgba(59, 130, 246, 0.14), transparent 28%),
        linear-gradient(180deg, #f8fbff 0%, #eef3fb 100%);
    color: #0f172a;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 28px 18px 36px;
}

.hero {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 22px;
}

.hero-copy {
    flex: 1 1 420px;
    min-width: 0;
}

.hero-copy h1 {
    margin: 0;
    font-size: clamp(2rem, 3vw, 3.1rem);
    line-height: 1.02;
    letter-spacing: -0.04em;
}

.page {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(320px, 0.95fr);
    gap: 24px;
    align-items: start;
}

#calendar {
    min-height: 820px;
    background: #ffffff;
    border-radius: 28px;
    box-shadow: 0 24px 90px rgba(15, 23, 42, 0.12);
    padding: 24px;
    overflow: hidden;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel {
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 0 20px 52px rgba(15, 23, 42, 0.08);
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel h2 {
    margin: 0;
    font-size: 1.14rem;
    letter-spacing: -0.02em;
    color: #0f172a;
}

#event-list {
    display: grid;
    gap: 14px;
    overflow-y: auto;
    max-height: calc(100vh - 260px);
    min-height: 200px;
    padding-right: 4px;
}

.event-card {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 16px;
    align-items: stretch;
    padding: 18px;
    border-radius: 20px;
    background: linear-gradient(180deg, #ffffff 0%, #f7f9fc 100%);
    text-decoration: none;
    color: inherit;
    border: 1px solid rgba(148, 163, 184, 0.18);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.event-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.12);
    border-color: rgba(37, 99, 235, 0.2);
}

.event-card img {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: 18px;
    background: #e2e8f0;
}

.event-card-body {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
}

.event-card-title,
.fc .fc-event-title {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    font-weight: 700;
    line-height: 1.3;
    font-size: 1rem;
    color: #111827;
}

.event-card-meta,
.event-card-dates {
    color: #475569;
    font-size: 0.95rem;
}

.event-card-dates {
    font-size: 0.92rem;
    color: #64748b;
}

.fc-toolbar {
    margin-bottom: 22px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
}

.fc .fc-button {
    border: none;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 700;
    box-shadow: none;
}

.fc .fc-button:hover,
.fc .fc-button:focus {
    background: #dbeafe;
}

.fc .fc-button-active {
    background: #1d4ed8;
    color: #ffffff;
}

.fc .fc-daygrid-day-top {
    color: #475569;
    font-weight: 700;
}

.fc .fc-col-header-cell {
    background: #f8fafc;
    color: #334155;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.fc .fc-scrollgrid-section > td,
.fc .fc-scrollgrid-section > th {
    border-color: rgba(148, 163, 184, 0.16);
}

.fc .fc-daygrid-event {
    border: none;
    min-height: auto;
}

.fc .fc-daygrid-day-top,
.fc .fc-daygrid-day-number {
    color: #334155;
}

.fc .fc-daygrid-day-frame {
    border-radius: 22px;
    overflow: visible;
}

@media (max-width: 980px) {
    .page {
        grid-template-columns: 1fr;
        padding: 0;
    }

    .hero {
        align-items: stretch;
    }

    #calendar {
        min-height: 720px;
    }
}

/* Mobile-specific tweaks for small phones */
@media (max-width: 640px) {
    .container {
        max-width: 100%;
        padding: 18px 12px 28px;
    }

    .hero-copy h1 {
        font-size: clamp(1.4rem, 6vw, 2.2rem);
        line-height: 1.05;
    }

    .page {
        gap: 12px;
    }

    #calendar {
        min-height: 420px;
        padding: 12px;
        border-radius: 16px;
        box-shadow: 0 12px 36px rgba(15, 23, 42, 0.10);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .panel {
        padding: 14px;
        border-radius: 14px;
    }

    #event-list {
        max-height: 360px;
        min-height: auto;
        padding-right: 0;
    }

    .event-card {
        grid-template-columns: 72px 1fr;
        gap: 12px;
        padding: 12px;
        border-radius: 14px;
    }

    .event-card img {
        width: 72px;
        height: 72px;
        border-radius: 12px;
    }

    .fc-toolbar {
        gap: 8px;
    }

    /* Keep toolbar chunks on a single line to prevent arrow reordering */
    .fc-toolbar {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .fc-toolbar > * {
        flex: 0 0 auto;
    }

    .fc .fc-button-group, .fc .fc-toolbar-chunk {
        white-space: nowrap;
    }

    .fc .fc-button {
        padding: 9px 12px;
        font-size: 0.95rem;
        min-width: 44px;
        touch-action: manipulation;
    }

    .fc .fc-col-header-cell {
        font-size: 0.85rem;
    }

    /* Improve scroll performance for calendar grids on mobile */
    .fc .fc-scrollgrid, .fc .fc-daygrid-body {
        -webkit-overflow-scrolling: touch;
    }

    /* Make interactive elements easier to tap */
    button, a.fc-button, .event-card {
        -webkit-tap-highlight-color: rgba(0,0,0,0.06);
    }
}
