.history-explorer-section {
    padding-top: 68px;
}

.history-explorer {
    display: grid;
    grid-template-columns: 350px minmax(0, 1fr);
    gap: 20px;
    margin-top: 32px;
    align-items: start;
}

.history-timeline-wrap {
    --history-axis-x: 74px;
    --history-event-left: 102px;
    --history-offset-x: 18px;
    --history-pointer-x: 74px;
    min-height: 0;
    overflow: hidden;
    border: 1px solid #dce3e6;
    border-radius: 12px;
    background: #fff;
}

.history-timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    height: 50px;
    box-sizing: border-box;
    padding: 0 18px;
    border-bottom: 1px solid #e2e7e9;
    background: #f7f9fa;
}

.history-timeline-header strong {
    color: #364149;
    font-size: 0.84rem;
}

.history-timeline-header span {
    color: #586b75;
    font-size: 0.76rem;
    font-weight: 700;
}

.history-timeline-body {
    position: relative;
    height: calc(100% - 50px);
    overflow: hidden;
}

.history-timeline-scroll {
    position: absolute;
    inset: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #cbd4d8 transparent;
    cursor: grab;
    user-select: none;
    touch-action: pan-y;
}

.history-timeline-scroll.is-dragging {
    cursor: grabbing;
}

.history-timeline-scroll::-webkit-scrollbar {
    width: 6px;
}

.history-timeline-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.history-timeline-scroll::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background: #cbd4d8;
}

.history-timeline-track {
    position: relative;
    width: 100%;
}

.history-timeline-axis {
    position: absolute;
    z-index: 0;
    top: 0;
    bottom: 0;
    left: var(--history-axis-x);
    width: 1px;
    background: #cad5da;
}

.history-timeline-year {
    position: absolute;
    z-index: 1;
    left: 0;
    width: 100%;
    height: 1px;
    pointer-events: none;
}

.history-timeline-year::after {
    content: "";
    position: absolute;
    top: 0;
    left: calc(var(--history-axis-x) - 3px);
    width: 7px;
    height: 1px;
    background: #d3dce0;
}

.history-timeline-year.is-medium::after {
    left: calc(var(--history-axis-x) - 5px);
    width: 11px;
    background: #bec9ce;
}

.history-timeline-year.is-major::after {
    left: calc(var(--history-axis-x) - 8px);
    width: 17px;
    background: #9eacb3;
}

.history-timeline-year-label {
    position: absolute;
    top: 50%;
    left: 8px;
    width: calc(var(--history-axis-x) - 22px);
    color: #89969c;
    font-size: 0.64rem;
    line-height: 1;
    text-align: right;
    transform: translateY(-50%);
}

.history-timeline-year.is-major .history-timeline-year-label {
    color: #65747b;
    font-weight: 700;
}

/* 실제 연도 위치. 표시 위치가 이동한 경우에만 보임 */
.history-timeline-origin {
    position: absolute;
    z-index: 4;
    left: var(--history-axis-x);
    width: 7px;
    height: 7px;
    box-sizing: border-box;
    border: 1px solid #8c9ba2;
    border-radius: 50%;
    background: #fff;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

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

/* 실제 연도 위치와 이동된 지진점을 연결하는 선 */
.history-timeline-event-connector {
    position: absolute;
    z-index: 3;
    height: 1px;
    background: #b9c6cc;
    transform-origin: 0 50%;
    pointer-events: none;
}

.history-timeline-event-connector[hidden] {
    display: none;
}

.history-timeline-event {
    position: absolute;
    z-index: 6;
    left: var(--history-event-left);
    right: 13px;
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 32px;
    box-sizing: border-box;
    padding: 6px 8px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transform: translateY(-50%);
    transition: background 0.15s ease;
}

.history-timeline-event:hover {
    background: #f3f6f7;
}

.history-timeline-event.is-selected {
    z-index: 10;
    background: #eaf1f4;
}

/*
 * JS에서 --history-point-x를 설정한다.
 * 일반 지진: 축 위
 * 위치 보정된 지진: 축에서 오른쪽으로 이동
 */
.history-timeline-event::before {
    content: "";
    position: absolute;
    z-index: 5;
    top: 50%;
    left: calc(var(--history-point-x) - var(--history-event-left));
    width: 9px;
    height: 9px;
    box-sizing: border-box;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #83949d;
    box-shadow: 0 0 0 1px #a4b1b7;
    transform: translate(-50%, -50%);
}

.history-timeline-event.is-selected::before {
    width: 11px;
    height: 11px;
    background: #405e6d;
    box-shadow: 0 0 0 2px rgba(64, 94, 109, 0.17);
}

/* 점과 카드 사이의 별도 가로선은 만들지 않음 */

.history-timeline-event-name {
    display: block;
    min-width: 0;
    overflow: hidden;
    color: #344048;
    font-size: 0.76rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-timeline-event-mag {
    flex: 0 0 auto;
    margin-left: auto;
    color: #89949a;
    font-size: 0.65rem;
}

/*
 * 고정 선택 화살표.
 * JS에서 --history-pointer-x를 선택 지진점의 x좌표로 변경한다.
 */
.history-timeline-pointer {
    position: absolute;
    z-index: 30;
    top: 50%;
    left: 0;
    width: var(--history-pointer-x);
    height: 28px;
    pointer-events: none;
    transform: translateY(-50%);
}

.history-timeline-pointer::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    width: calc(var(--history-pointer-x) - 9px);
    height: 1px;
    background: #405e6d;
}

.history-timeline-pointer span {
    position: absolute;
    top: 50%;
    left: calc(var(--history-pointer-x) - 9px);
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 9px solid #405e6d;
    transform: translateY(-50%);
}

.history-earthquake-view {
    min-width: 0;
}

.history-earthquake-detail {
    padding: 26px 28px;
    border: 1px solid #dce3e6;
    border-radius: 12px;
    background: #fff;
}

.history-detail-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 30px;
    padding-bottom: 22px;
    border-bottom: 1px solid #e2e7e9;
}

.history-detail-year {
    display: block;
    margin-bottom: 7px;
    color: #829098;
    font-size: 0.75rem;
    font-weight: 700;
}

.history-detail-heading h2 {
    margin: 0;
    color: #27333a;
    font-size: 1.45rem;
    line-height: 1.4;
}

.history-detail-mag {
    flex: 0 0 auto;
    min-width: 100px;
    text-align: right;
}

.history-detail-mag span {
    display: block;
    color: #8a959b;
    font-size: 0.7rem;
}

.history-detail-mag strong {
    display: block;
    margin-top: 5px;
    color: #344149;
    font-size: 1.2rem;
}

.history-detail-content {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 30px;
    margin-top: 22px;
}

.history-detail-content > div > span {
    display: block;
    margin-bottom: 8px;
    color: #78858c;
    font-size: 0.72rem;
    font-weight: 700;
}

.history-detail-content p {
    margin: 0;
    color: #667279;
    font-size: 0.81rem;
    line-height: 1.8;
}

.history-map-wrap {
    position: relative;
    overflow: hidden;
    margin-top: 14px;
    border: 1px solid #dce3e6;
    border-radius: 12px;
    background: #eef2f4;
}

.history-map {
    width: 100%;
    height: 520px;
}

.history-map .leaflet-control-attribution {
    font-size: 0.62rem;
}

.history-map-legend {
    position: absolute;
    z-index: 500;
    right: 14px;
    bottom: 14px;
    display: grid;
    grid-template-columns: 14px auto;
    gap: 7px 8px;
    padding: 12px 14px;
    border: 1px solid rgba(211, 219, 223, 0.95);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 3px 12px rgba(36, 49, 57, 0.08);
}

.history-map-legend > strong {
    grid-column: 1 / -1;
    margin-bottom: 2px;
    color: #56646c;
    font-size: 0.7rem;
}

.history-map-legend > div {
    display: contents;
}

.history-map-legend > div > span:last-child {
    color: #68757c;
    font-size: 0.68rem;
}

.history-legend-swatch {
    align-self: center;
    width: 12px;
    height: 12px;
    box-sizing: border-box;
    border-radius: 3px;
}

.certainty-certain {
    border: 2px solid #6d28d9;
    background: rgba(126, 34, 206, 0.34);
}

.certainty-probable {
    border: 2px solid #2563eb;
    background: rgba(37, 99, 235, 0.26);
}

.certainty-possible {
    border: 2px solid #d97706;
    background: rgba(217, 119, 6, 0.22);
}

.certainty-theory {
    border: 2px dashed #64748b;
    background: rgba(100, 116, 139, 0.10);
}

.history-map-note {
    margin-top: 12px;
    padding: 16px 18px;
    border-left: 3px solid #8b9da6;
    background: #f6f8f9;
}

.history-map-note strong {
    display: block;
    color: #39464d;
    font-size: 0.79rem;
}

.history-map-note p {
    margin: 6px 0 0;
    color: #68757c;
    font-size: 0.75rem;
    line-height: 1.75;
}

.history-load-error {
    margin: 0;
    padding: 24px 18px;
    color: #7b878d;
    font-size: 0.8rem;
}

@media (max-width: 900px) {
    .history-explorer {
        grid-template-columns: 300px minmax(0, 1fr);
    }

    .history-timeline-wrap {
        --history-axis-x: 64px;
        --history-event-left: 92px;
        --history-offset-x: 16px;
    }

    .history-detail-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .history-map {
        height: 460px;
    }
}

@media (max-width: 760px) {
    .history-explorer {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .history-timeline-wrap {
        width: 100%;
        height: 340px !important;
    }

    .history-timeline-header {
        height: 46px;
        padding: 0 14px;
    }

    .history-timeline-body {
        height: calc(100% - 46px);
    }

    .history-earthquake-detail {
        padding: 21px 18px;
    }

    .history-detail-heading {
        gap: 16px;
    }

    .history-detail-heading h2 {
        font-size: 1.2rem;
    }

    .history-detail-mag {
        min-width: 70px;
    }

    .history-detail-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .history-map {
        height: 410px;
    }

    .history-map-legend {
        right: 10px;
        bottom: 10px;
    }
}