.hm_scrap_modal[hidden] {
    display: none !important;
}

.hm_scrap_modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    font-family: var(--g5-font-sans, "Pretendard Variable", Pretendard, "Noto Sans KR", sans-serif);
}

.hm_scrap_modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .45);
}

.hm_scrap_modal__panel {
    position: relative;
    z-index: 1;
    width: min(440px, 100%);
    max-width: 100%;
    /* 가로 플렉스에서 축소·내부 스크롤이 되도록 */
    min-height: 0;
    flex-shrink: 1;
    max-height: min(520px, calc(100vh - 40px));
    max-height: min(520px, calc(100dvh - 40px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .22);
}

/* 확인·안내형(스크랩 확인, 완료 메시지 등) — 목록 모달보다 좁게 */
.hm_scrap_modal.hm_scrap_modal--compact .hm_scrap_modal__panel {
    width: min(320px, calc(100vw - 48px));
    max-width: min(320px, calc(100vw - 48px));
}

.hm_scrap_modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    min-height: 58px;
    padding: 0 18px 0 22px;
    border-bottom: 1px solid #eee;
}

.hm_scrap_modal__title {
    margin: 0;
    color: #171717;
    font-size: 18px;
    font-weight: 800;
    line-height: 1.3;
}

.hm_scrap_modal__close {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #333;
    font-size: 26px;
    line-height: 36px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.hm_scrap_modal__close:hover,
.hm_scrap_modal__close:focus,
.hm_scrap_modal__close:active {
    background: transparent;
    outline: none;
    box-shadow: none;
}

.hm_scrap_modal__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    /* 시트 배경 잠금(hm_nav_sheet) 중에도 본문 세로 스크롤 허용 (iOS WebKit) */
    touch-action: pan-y;
}

.hm_scrap_modal_open {
    overflow: hidden;
}

.hm_scrap_loading,
.hm_scrap_empty,
.hm_scrap_notice__message {
    margin: 0;
    padding: 24px 6px;
    color: #333;
    font-size: 15px;
    line-height: 1.6;
    text-align: center;
}

.hm_scrap_loading--inline {
    display: inline-block;
    padding: 12px 0;
    color: #777;
    font-size: 13px;
}

.hm_scrap_notice__actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    padding-top: 4px;
}

.hm_scrap_btn,
.hm_scrap_more {
    min-height: 42px;
    padding: 0 18px;
    border: 1px solid #ddd;
    border-radius: 999px;
    background: #fff;
    color: #222;
    font-weight: 700;
    cursor: pointer;
}

.hm_scrap_btn--primary,
.hm_scrap_more {
    border-color: #283593;
    background: #283593;
    color: #fff;
}

.hm_scrap_list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.hm_scrap_item + .hm_scrap_item {
    border-top: 1px solid #f0f0f0;
}

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

.hm_scrap_item.is-deleting {
    opacity: .55;
    pointer-events: none;
}

.hm_scrap_item__link {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    padding: 14px 4px;
    color: inherit;
    text-decoration: none;
}

.hm_scrap_item__subject {
    display: block;
    color: #171717;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.45;
}

.hm_scrap_item__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-top: 6px;
    color: #777;
    font-size: 12px;
    line-height: 1.4;
}

.hm_scrap_item__delete {
    flex: 0 0 auto;
    min-width: 48px;
    height: 32px;
    padding: 0 11px;
    border: 1px solid #e8e8e8;
    border-radius: 999px;
    background: #fafafa;
    color: #777;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.hm_scrap_item__delete:hover,
.hm_scrap_item__delete:focus {
    border-color: #d64545;
    background: #fff5f5;
    color: #c92a2a;
}

.hm_scrap_list_more {
    padding-top: 14px;
    text-align: center;
}

@media (max-width: 640px) {
    .hm_scrap_modal {
        align-items: center;
        justify-content: center;
        padding: max(14px, env(safe-area-inset-top))
            calc(10px + env(safe-area-inset-right, 0px))
            max(14px, env(safe-area-inset-bottom))
            calc(10px + env(safe-area-inset-left, 0px));
    }

    .hm_scrap_modal__panel {
        width: 100%;
        max-width: none;
        /* 좌우 10px 여백: 컨테이너 패딩 10px + 패널 100% = 화면 - 20px */
        align-self: stretch;
        flex-shrink: 1;
        min-height: 0;
        max-height: min(520px, calc(100vh - 56px));
        max-height: min(520px, calc(100dvh - 56px));
        border-radius: 18px;
        box-sizing: border-box;
    }

    .hm_scrap_modal.hm_scrap_modal--compact .hm_scrap_modal__panel {
        align-self: center;
        width: min(320px, calc(100vw - 36px));
        max-width: min(320px, calc(100vw - 36px));
    }

    .hm_scrap_modal__header {
        min-height: 48px;
        padding: 0 14px 0 18px;
    }

    .hm_scrap_modal__title {
        font-size: 16px;
    }

    .hm_scrap_modal__body {
        padding: 14px;
    }

    .hm_scrap_loading,
    .hm_scrap_empty,
    .hm_scrap_notice__message {
        padding: 16px 4px;
    }

    .hm_scrap_notice__actions {
        padding-top: 2px;
    }

    .hm_scrap_item__link {
        padding: 10px 2px;
    }

    .hm_scrap_item__meta {
        margin-top: 4px;
        font-size: 11px;
    }

    .hm_scrap_list_more {
        padding-top: 10px;
    }
}

/* ============================================================
 * 다크 모드 — 모바일 (html[data-hm-theme="dark"] 토글, PC와 동일 방식)
 * ============================================================ */
html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_modal {
    color-scheme: dark;
}

html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_modal__backdrop {
    background: rgba(0, 0, 0, 0.68);
}

html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_modal__panel {
    background: var(--hm-bg-surface, #1e1e20);
    border: 1px solid var(--hm-card-border, rgba(255, 255, 255, 0.1));
    box-shadow:
        0 22px 60px rgba(0, 0, 0, 0.55),
        0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_modal__header {
    border-bottom-color: var(--hm-border, #2c2c2e);
}

html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_modal__title {
    color: var(--hm-text-main, #e1e1e1);
}

html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_modal__close {
    background: transparent;
    color: var(--hm-text-body, #e1e1e1);
}

html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_modal__close:hover,
html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_modal__close:focus,
html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_modal__close:active {
    background: transparent;
    color: var(--hm-text-main, #fff);
    outline: none;
}

html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_loading,
html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_empty,
html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_notice__message {
    color: var(--hm-text-body, #e1e1e1);
}

html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_loading--inline {
    color: var(--hm-text-muted, #787878);
}

html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_btn {
    border-color: var(--hm-card-border, rgba(255, 255, 255, 0.14));
    background: var(--hm-bg-card, #252525);
    color: var(--hm-text-main, #e1e1e1);
}

html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_btn:hover,
html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_btn:focus {
    border-color: rgba(255, 255, 255, 0.22);
    background: var(--hm-tap, rgba(255, 255, 255, 0.07));
    outline: none;
}

html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_btn--primary,
html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_more {
    border-color: #7c93f0;
    background: #5c6bc0;
    color: #fafafa;
}

html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_btn--primary:hover,
html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_btn--primary:focus,
html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_more:hover,
html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_more:focus {
    border-color: #9aabf5;
    background: #6d7fd4;
    color: #fff;
    outline: none;
}

html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_item + .hm_scrap_item {
    border-top-color: var(--hm-border, #2c2c2e);
}

html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_item__subject {
    color: var(--hm-text-main, #e1e1e1);
}

html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_item__meta {
    color: var(--hm-text-sub, #a1a1a1);
}

html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_item__delete {
    border-color: var(--hm-card-border, rgba(255, 255, 255, 0.12));
    background: rgba(255, 255, 255, 0.04);
    color: var(--hm-text-muted, #9ca3af);
}

html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_item__delete:hover,
html[data-hm-theme="dark"] body.hm-mobile .hm_scrap_item__delete:focus {
    border-color: rgba(239, 68, 68, 0.45);
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5;
    outline: none;
}

/* ============================================================
 * 다크 모드 — PC 토글(상단 라이트/다크 버튼) 대응
 * html[data-hm-theme="dark"] body:not(.hm-mobile) 일 때만 적용
 * ============================================================ */
html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_modal {
    color-scheme: dark;
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_modal__backdrop {
    background: rgba(0, 0, 0, 0.6);
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_modal__panel {
    background: #111827;
    border: 1px solid #334155;
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.55);
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_modal__header {
    border-bottom-color: #293241;
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_modal__title {
    color: #e5e7eb;
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_modal__close {
    background: transparent;
    color: #cbd5e1;
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_modal__close:hover,
html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_modal__close:focus,
html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_modal__close:active {
    background: transparent;
    color: #fff;
    outline: none;
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_loading,
html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_empty,
html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_notice__message {
    color: #cbd5e1;
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_loading--inline {
    color: #94a3b8;
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_btn {
    border-color: #374151;
    background: #1f2937;
    color: #e5e7eb;
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_btn:hover,
html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_btn:focus {
    border-color: #4b5563;
    background: #374151;
    outline: none;
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_btn--primary,
html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_more {
    border-color: #5c6bc0;
    background: #5c6bc0;
    color: #fff;
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_btn--primary:hover,
html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_btn--primary:focus,
html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_more:hover,
html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_more:focus {
    border-color: #7c8cdf;
    background: #6d7fd4;
    color: #fff;
    outline: none;
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_item + .hm_scrap_item {
    border-top-color: #293241;
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_item__subject {
    color: #e5e7eb;
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_item__meta {
    color: #94a3b8;
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_item__delete {
    border-color: #374151;
    background: rgba(255, 255, 255, 0.04);
    color: #9ca3af;
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_item__delete:hover,
html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_scrap_item__delete:focus {
    border-color: rgba(239, 68, 68, 0.45);
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5;
    outline: none;
}
