*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "SF Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    color: #5b5660;
    background: linear-gradient(180deg, #FFCAD6 0%, #E3FFF9 100%);
}

.page-letter-history {
    min-height: 100vh;
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px 24px 56px;
}

.letter-header,
.calendar-panel,
.letter-list-panel {
    width: min(1040px, 100%);
    margin: 0 auto;
}

.letter-header {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 28px;
}

.letter-back {
    display: inline-block;
    width: fit-content;
    color: #ED688D;
    text-decoration: none;
    font-size: 16px;
    font-weight: 700;
}

.letter-title-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    text-align: center;
}

.letter-title-icon {
    width: 56px;
    height: 56px;
    object-fit: contain;
}

.letter-title {
    margin: 0;
    font-size: clamp(32px, 3.6vw, 46px);
    color: #ED688D;
}

.letter-subtitle {
    margin: 8px 0 0;
    color: #757575;
    font-size: 15px;
}

.calendar-panel,
.letter-list-panel {
    padding: 28px;
    border-radius: 32px;
    background: rgba(255, 255, 255, 0.68);
    box-shadow: 0 20px 45px rgba(148, 124, 137, 0.14);
    backdrop-filter: blur(10px);
}

.calendar-panel {
    margin-bottom: 26px;
}

.calendar-head,
.letter-list-head,
.detail-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.calendar-kicker,
.letter-list-kicker {
    margin: 0 0 6px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #4DA39F;
    text-transform: uppercase;
}

.calendar-title,
.letter-list-title,
.detail-modal-title {
    margin: 0;
    font-size: 28px;
    color: #54505b;
}

.calendar-nav {
    display: flex;
    gap: 10px;
}

.calendar-nav-btn,
.detail-modal-close {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    color: #ED688D;
    background: rgba(255, 202, 214, 0.7);
}

.calendar-weekdays,
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 12px;
}

.calendar-weekdays {
    margin-top: 24px;
    margin-bottom: 12px;
    text-align: center;
    color: #908995;
    font-weight: 700;
}

.calendar-day {
    position: relative;
    min-height: 96px;
    padding: 14px 12px;
    border: none;
    border-radius: 22px;
    text-align: left;
    background: rgba(255, 255, 255, 0.78);
    color: #5b5660;
    box-shadow: inset 0 0 0 1px rgba(165, 225, 212, 0.35);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.calendar-day:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(148, 124, 137, 0.12);
}

.calendar-day--empty {
    visibility: hidden;
}

.calendar-day--has-letter {
    background: linear-gradient(180deg, rgba(255, 202, 214, 0.9) 0%, rgba(227, 255, 249, 0.85) 100%);
}

.calendar-day-number {
    display: block;
    font-size: 18px;
    font-weight: 700;
}

.calendar-day-count {
    display: block;
    margin-top: 8px;
    font-size: 13px;
    color: #4DA39F;
}

.calendar-day-recipients {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #7e7582;
    line-height: 1.4;
}

.calendar-day-unread {
    position: absolute;
    top: 10px;
    right: 10px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
    color: #fff;
    background: #ED688D;
    box-shadow: 0 8px 16px rgba(237, 104, 141, 0.25);
}

.letter-list-head {
    margin-bottom: 20px;
}

.letter-add-link {
    padding: 12px 22px;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 700;
    color: #4DA39F;
    background: #A5E1D4;
}

.letter-list {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.letter-item {
    border-radius: 26px;
}

.letter-card {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 18px;
    align-items: start;
    padding: 22px 24px;
    border-radius: 26px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 14px 30px rgba(148, 124, 137, 0.12);
    transition: transform 0.2s ease;
    touch-action: pan-y;
    cursor: pointer;
}

.letter-card-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    padding-left: 8px;
}

.letter-card-delete {
    border: none;
    background: transparent;
    color: #5b5660;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 999px;
}

.letter-card-delete:hover {
    opacity: 0.85;
}

.letter-card.is-unread {
    box-shadow: 0 18px 36px rgba(237, 104, 141, 0.12);
    outline: 2px solid rgba(237, 104, 141, 0.15);
}

.letter-card:hover {
    transform: translateY(-2px);
}

.letter-card-title {
    margin: 0 0 10px;
    font-size: 22px;
    color: #4f4954;
}

.letter-card-meta,
.letter-card-content,
.letter-empty {
    margin: 0;
    color: #757575;
    line-height: 1.7;
}

.letter-card-date {
    font-weight: 700;
    color: #4DA39F;
    white-space: nowrap;
}

.detail-modal {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(90, 79, 91, 0.34);
}

.detail-modal[hidden] {
    display: none;
}

.detail-modal-card {
    width: min(860px, 100%);
    max-height: min(84vh, 900px);
    overflow: auto;
    padding: 24px;
    border-radius: 30px;
    background: rgba(255, 252, 248, 0.98);
    box-shadow: 0 24px 48px rgba(84, 80, 91, 0.22);
}

.detail-modal-kicker {
    margin: 0 0 6px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #ED688D;
    text-transform: uppercase;
}

.detail-modal-list {
    display: flex;
    flex-direction: column;
    gap: 22px;
    margin-top: 22px;
}

.detail-paper {
    position: relative;
    padding: 42px 28px 28px;
    border-radius: 24px;
    background:
        repeating-linear-gradient(
            180deg,
            rgba(255, 255, 255, 0.98) 0,
            rgba(255, 255, 255, 0.98) 32px,
            rgba(165, 225, 212, 0.08) 32px,
            rgba(165, 225, 212, 0.08) 33px
        );
    box-shadow: 0 18px 35px rgba(148, 124, 137, 0.14);
    overflow: hidden;
}

.detail-paper::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 54px;
    background: linear-gradient(135deg, #FFD7E1 0%, #FFE9EF 48%, #F9FFFD 100%);
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    opacity: 0.9;
}

.detail-paper::after {
    content: "";
    position: absolute;
    top: 18px;
    right: 24px;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(237, 104, 141, 0.2) 0%, rgba(237, 104, 141, 0) 70%);
}

.detail-paper-head {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.detail-paper-tag {
    display: inline-block;
    margin-bottom: 10px;
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    color: #4DA39F;
    background: rgba(165, 225, 212, 0.25);
}

.detail-paper-title {
    margin: 0;
    font-size: 24px;
    color: #544e59;
}

.detail-paper-date {
    flex-shrink: 0;
    text-align: right;
    color: #8f8793;
    line-height: 1.6;
}

.detail-paper-date strong {
    display: block;
    color: #ED688D;
    font-size: 18px;
}

.detail-letter-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 18px;
    color: #756d78;
    font-weight: 600;
}

.detail-letter-content {
    margin: 0;
    font-size: 15px;
    line-height: 2;
    color: #5c5660;
    white-space: pre-wrap;
}

.detail-letter-sign {
    margin-top: 22px;
    text-align: right;
    color: #4DA39F;
    font-weight: 700;
}

@media (max-width: 760px) {
    .page-letter-history {
        padding: 20px 14px 40px;
    }

    .calendar-panel,
    .letter-list-panel {
        padding: 18px;
        border-radius: 24px;
    }

    .calendar-weekdays,
    .calendar-grid {
        gap: 8px;
    }

    .calendar-day {
        min-height: 82px;
        padding: 12px 10px;
    }

    .letter-card {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 18px;
    }

    .letter-card-date {
        white-space: normal;
    }

    .detail-modal-card {
        padding: 18px;
        border-radius: 24px;
    }

    .detail-paper {
        padding: 36px 18px 20px;
    }

    .detail-paper-head {
        flex-direction: column;
    }

    .detail-paper-date {
        text-align: left;
    }
}
