.history-page {
    max-width: 1080px;
    margin: 0 auto;
    padding: 36px 32px 56px;
}

.history-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.history-card {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: calc(50% - 10px);
    aspect-ratio: 3 / 2;
    background-size: cover;
    background-position: center;
    background-color: #222222;
    overflow: hidden;
    border-radius: 8px;
    cursor: pointer;
}

.history-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.45);
    z-index: 1;
}

.history-card:hover .history-card__label,
.history-card:focus-visible .history-card__label,
.history-card:active .history-card__label {
    color: #cccccc;
}

.history-card__label {
    position: relative;
    z-index: 2;
    color: #ffffff;
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.05em;
}

.history-card__session-badge {
    display: block;
    font-size: 13px;
    font-weight: 400;
    opacity: 0.85;
    margin-top: 2px;
}

.history-empty {
    margin: 0;
    padding: 28px 20px;
    text-align: center;
    font-size: 16px;
    color: #666666;
    width: 100%;
}

.history-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}

.history-modal.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.2s ease, visibility 0s linear 0s;
}

.history-modal__overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
}

.history-modal__dialog {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: min(960px, 100%);
    max-height: min(90vh, 960px);
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.18);
}

.history-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 20px 24px 16px;
    background-color: #efefef;
    border-radius: 12px 12px 0 0;
    flex-shrink: 0;
}

.history-modal__title {
    margin: 0;
    color: #ac2e45;
    font-size: 30px;
    line-height: 1.3;
    min-width: 0;
    overflow-wrap: break-word;
}

.history-modal__close {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    background: transparent;
    font-size: 28px;
    line-height: 1;
    color: #666666;
    cursor: pointer;
    flex-shrink: 0;
}

.history-modal__close:hover,
.history-modal__close:focus-visible {
    color: #000000;
    outline: none;
}

.history-modal__body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0;
}

/* ---- Hero ---- */

.history-hero {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background-size: cover;
    background-position: center;
    background-color: #222222;
    flex-shrink: 0;
}

.history-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(transparent 50%, rgba(0, 0, 0, 0.65));
}

.history-hero__overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2;
    padding: 18px 24px 22px;
    color: #ffffff;
}

.history-hero__session {
    font-size: 32px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 2px;
}

.history-hero__year {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 6px;
}

.history-hero__session-badge {
    font-size: 16px;
    font-weight: 400;
    opacity: 0.8;
}

.history-hero__date {
    font-size: 15px;
    line-height: 1.4;
    opacity: 0.9;
}

.history-hero__location {
    font-size: 15px;
    line-height: 1.4;
    opacity: 0.9;
}

.history-hero__operator {
    font-size: 15px;
    line-height: 1.4;
    opacity: 0.9;
}

.history-hero__intro {
    font-size: 14px;
    line-height: 1.4;
    opacity: 0.85;
    margin-top: 4px;
}

/* ---- Note banner ---- */

.history-note {
    margin: 16px 32px 0;
    padding: 0;
}

.history-note__body {
    padding: 14px 24px;
    background-color: #ffffff;
    border: 3px solid #e67e22;
    border-radius: 6px;
    font-size: 15px;
    line-height: 1.6;
    color: #666666;
}

.history-note__title {
    font-size: 16px;
    font-weight: 700;
    color: #e67e22;
    margin-bottom: 6px;
}

.history-note__text-wrap {
    position: relative;
    max-height: 72px;
    overflow: hidden;
    transition: max-height 0.35s ease;
}

.history-note__text-wrap--expanded {
    max-height: 5000px;
}

.history-note__text {
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

.history-note__fade {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1.2em;
    background: linear-gradient(transparent, #ffffff);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.history-note__toggle {
    display: inline-block;
    margin-top: 8px;
    padding: 0;
    border: 0;
    background: transparent;
    font-size: 14px;
    color: #ac2e45;
    cursor: pointer;
    line-height: 1.4;
}

.history-note__toggle[hidden] {
    display: none;
}

.history-note__toggle:hover,
.history-note__toggle:focus-visible {
    text-decoration: underline;
    outline: none;
}

.history-note[hidden] {
    display: none;
}

/* ---- Content sections inside modal body ---- */

.history-content {
    padding: 28px 32px;
}

.history-section {
    margin-bottom: 28px;
}

.history-section:last-child {
    margin-bottom: 0;
}

.history-section__heading {
    margin: 0 0 12px;
    font-size: 20px;
    font-weight: 600;
    color: #333333;
}

/* ---- Fare table ---- */

.fare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
}

.fare-table th,
.fare-table td {
    padding: 10px 14px;
    border: 1px solid #dddddd;
    text-align: left;
}

.fare-table th {
    background-color: #efefef;
    font-weight: 600;
    color: #333333;
}

.fare-table td {
    color: #555555;
}

/* ---- Route + Fares side by side ---- */

.route-fares-row {
    display: flex;
    gap: 32px;
    align-items: flex-start;
}

.route-fares-row__route {
    flex: 1;
    min-width: 0;
}

.route-fares-row__fares {
    flex: 0 0 auto;
    min-width: 160px;
}

.fare-item {
    margin-bottom: 16px;
}

.fare-item:last-child {
    margin-bottom: 0;
}

.fare-item__label {
    font-size: 18px;
    font-weight: 600;
    color: #333333;
}

.fare-item__price {
    font-size: 16px;
    color: #555555;
    margin-top: 2px;
}

.fare-item__desc {
    font-size: 13px;
    color: #888888;
    margin-top: 1px;
}

/* ---- Route diagram ---- */

.route-diagram {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.route-stop {
    display: flex;
    gap: 14px;
    z-index: 1;
}

.route-stop__line-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 28px;
    flex-shrink: 0;
    position: relative;
}

.route-stop__circle {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 3px solid #11254A;
    background-color: #ffffff;
    flex-shrink: 0;
    z-index: 1;
    box-sizing: border-box;
}

.route-stop--NS .route-stop__circle {
    border-color: #A6A6A6;
    background-color: #CCCCCC;
}

.route-stop--expanded {
    display: flex;
    gap: 14px;
}

.route-stop__exp-line-col {
    display: flex;
    justify-content: center;
    width: 28px;
    flex-shrink: 0;
    margin-left: -42px;
}

.route-stop__circle-exp {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 3px solid #11254A;
    background-color: #ffffff;
    flex-shrink: 0;
    margin-top: 3px;
    box-sizing: border-box;
}

.route-stop--expanded.route-stop--NS .route-stop__circle-exp {
    border-color: #A6A6A6;
    background-color: #CCCCCC;
}

.route-stop__line {
    width: 6px;
    flex: 1;
    min-height: 36px;
    background-color: #164A7C;
}

.route-stop:last-child .route-stop__line {
    display: none;
}

.route-stop__info {
    flex: 1;
    padding-bottom: 18px;
    min-width: 0;
}

.route-stop:last-child .route-stop__info {
    padding-bottom: 0;
}

.route-stop--expanded .route-stop__info {
    padding-bottom: 18px;
}

.route-stop__type-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.6;
    margin-bottom: 4px;
}

.route-stop__type-badge--UP {
    background-color: #e8f5e9;
    color: #2e7d32;
}

.route-stop__type-badge--NS {
    background-color: #fce4ec;
    color: #c62828;
}

.route-stop__type-badge--TA {
    background-color: #fff3e0;
    color: #e65100;
}

.route-stop__type-badge--DP {
    background-color: #e3f2fd;
    color: #1565c0;
}

.route-stop__name {
    font-size: 18px;
    font-weight: 600;
    color: #333333;
}

.route-stop--NS .route-stop__name,
.route-stop--NS .route-stop__en,
.route-stop--NS .route-stop__interchange-label,
.route-stop--NS .route-stop__interchange-value {
    text-decoration: line-through;
    color: #999999;
}

.route-stop__en {
    font-size: 13px;
    color: #888888;
    margin-top: 1px;
}

.route-stop__interchange-row {
    display: flex;
    gap: 3px;
    align-items: baseline;
    margin-top: 2px;
}

.route-stop__interchange-label {
    font-size: 12px;
    color: #666666;
    flex-shrink: 0;
}

.route-stop__interchange-value {
    font-size: 13px;
    color: #888888;
}

.route-collapse {
    display: flex;
    gap: 14px;
}

.route-collapse__line-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 28px;
    flex-shrink: 0;
}

.route-collapse__line {
    width: 6px;
    flex: 1;
    min-height: 36px;
    background-color: #164A7C;
}

.route-collapse__content {
    flex: 1;
    min-width: 0;
}

.route-collapse__body {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.35s ease, opacity 0.3s ease;
}

.route-collapse-toggle {
    display: inline-block;
    padding: 0;
    border: 0;
    background: transparent;
    font-size: 14px;
    color: #666666;
    cursor: pointer;
    text-align: left;
    line-height: 1.6;
}

.route-collapse-toggle:hover,
.route-collapse-toggle:focus-visible {
    color: #ac2e45;
    outline: none;
}

/* ---- Photo gallery ---- */

.photo-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.photo-gallery__item {
    display: flex;
    flex-direction: column;
    border: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
}

.photo-gallery__item:focus-visible {
    outline: 2px solid #ac2e45;
    outline-offset: 2px;
}

.photo-gallery__thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
    border-radius: 8px;
}

.photo-gallery__caption {
    padding: 8px 4px 0;
    font-size: 13px;
    line-height: 1.4;
    color: #666666;
    text-align: left;
}

.photo-gallery__caption strong {
    color: #333333;
    font-weight: 600;
}

/* ---- Responsive ---- */

@media (max-width: 768px) {
    .history-page {
        padding: 24px 16px 40px;
    }

    .history-grid {
        gap: 12px;
    }

    .history-card {
        width: calc(50% - 6px);
    }

    .history-card__label {
        font-size: 17px;
    }

    .history-modal {
        padding: 12px;
    }

    .history-modal__header {
        padding: 16px 18px 12px;
    }

    .history-modal__title {
        font-size: 24px;
    }

    .history-content {
        padding: 22px 18px;
    }

    .history-note {
        margin: 12px 16px 0;
    }

    .route-fares-row {
        flex-direction: column;
        gap: 20px;
    }

    .route-fares-row__fares {
        min-width: 0;
    }

    .history-hero__session {
        font-size: 26px;
    }

    .history-hero__year {
        font-size: 22px;
    }

    .photo-gallery {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}
