/* 상세 카드에서 실제 응답을 기다리는 작은 슬롯만 안정화한다.
 * 댓글·통계·계약처럼 크기를 알 수 없는 섹션에는 빈 공간을 예약하지 않는다. */
#detailModal [data-detail-async-slot="attachments"] #detailAttachments {
    min-block-size: 46px;
}

#detailModal .detail-async-status {
    display: flex;
    align-items: center;
    min-block-size: 46px;
    padding: 10px 12px;
    box-sizing: border-box;
    color: #64748b;
    font-size: 0.84rem;
    line-height: 1.45;
}

#detailModal [data-detail-async-slot="attachments"][data-detail-async-state="loading"]
    .detail-async-status::before {
    width: 14px;
    height: 14px;
    margin-right: 8px;
    border: 2px solid #bfdbfe;
    border-top-color: #2563eb;
    border-radius: 50%;
    content: "";
    animation: detail-async-slot-spin 0.8s linear infinite;
}

#detailModal #descriptionSection.private-bid-description-media .body-html figure.inline-media:not(.overlay-player-wrap):not([data-img-shapes]):not([data-vid-shapes]) > img,
#detailModal #descriptionSection.private-bid-description-media .body-html figure.inline-media:not(.overlay-player-wrap):not([data-img-shapes]):not([data-vid-shapes]) > video,
#detailModal .private-bid-dialog-media > img,
#detailModal .private-bid-dialog-media > video {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: contain;
    background: #0f172a;
}

@keyframes detail-async-slot-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    #detailModal [data-detail-async-slot="attachments"][data-detail-async-state="loading"]
        .detail-async-status::before {
        animation: none;
    }
}

/* 공고 상세는 홈과 내일거리에서 같은 크기와 스크롤 소유권을 사용한다.
 * 페이지별 다이얼로그 계약은 그대로 두고 공유 #detailModal만 결속한다. */
body:is(.unified-page, .private-bids-page) #detailModal > .modal-content {
    --app-dialog-preferred-max: calc(
        100dvh - var(--app-dialog-safe-bottom, 0px) - 70px
    );
    min-height: 0 !important;
    max-height: min(
        var(--app-dialog-preferred-max),
        var(--app-dialog-max-height)
    ) !important;
    box-sizing: border-box !important;
}

body:is(.unified-page, .private-bids-page)
    #detailModal > .modal-content > .modal-body {
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
}

/* 모바일 상세은 작은 중앙 카드가 아니라 안전영역 안의 전체 작업면을 사용한다.
 * 헤더와 작업 기록 진입은 고정하고 본문 하나만 스크롤 소유자가 된다. */
@media (max-width: 767px) {
    body:is(.unified-page, .private-bids-page) #detailModal.modal {
        align-items: stretch !important;
        padding: 8px !important;
        /* AppDialogViewport가 게시한 실제 가시 높이에서 현재 보이는 광고만
         * 차감한다. 광고가 숨겨지거나 landscape가 되면 예약값은 0으로
         * 돌아가므로 기존 전체 작업면을 그대로 사용한다. */
        height: calc(
            var(--app-dialog-viewport-height, 100dvh)
            - var(--app-bottom-reserved, 0px)
        ) !important;
    }

    body:is(.unified-page, .private-bids-page) #detailModal > .modal-content {
        display: flex;
        flex-direction: column;
        width: 100% !important;
        height: calc(
            var(--app-dialog-viewport-height, 100dvh)
            - var(--app-bottom-reserved, 0px)
            - 16px
        ) !important;
        min-height: calc(
            var(--app-dialog-viewport-height, 100dvh)
            - var(--app-bottom-reserved, 0px)
            - 16px
        ) !important;
        max-height: calc(
            var(--app-dialog-viewport-height, 100dvh)
            - var(--app-bottom-reserved, 0px)
            - 16px
        ) !important;
        margin: 0 !important;
        overflow: hidden !important;
        border-radius: min(12px, 2.5vw) !important;
    }

    body:is(.unified-page, .private-bids-page)
        #detailModal > .modal-content > .modal-header,
    body:is(.unified-page, .private-bids-page)
        #detailModal > .modal-content > .work-log-detail-entry {
        flex: 0 0 auto;
    }

    body:is(.unified-page, .private-bids-page)
        #detailModal > .modal-content > .modal-body {
        flex: 1 1 auto;
        min-height: 0 !important;
        overflow-y: auto !important;
        overscroll-behavior: contain;
    }
}

/* D2-13: 요약 → 기존 동작 → 한 줄 안내 → V4 정보 상자 순서.
 * 요약과 동작의 고정 트랙은 상세·참가자격 응답 전후 같은 높이를 쓴다. */
#detailModal .detail-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px 12px;
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    color: #0f172a;
}
#detailModal .detail-summary > div {
    min-width: 0;
    height: 44px;
}
#detailModal .detail-summary-label {
    display: block;
    height: 20px;
    font-size: 12px;
    line-height: 20px;
    color: #475569;
    white-space: nowrap;
}
#detailModal .detail-summary-label b {
    margin-left: 4px;
    color: inherit;
}
#detailModal .detail-summary strong {
    display: block;
    overflow: hidden;
    font-size: 14px;
    line-height: 24px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#detailModal .detail-primary-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-flow: row;
    grid-auto-rows: 64px;
    gap: 6px;
    margin: 0 0 12px;
    padding: 0;
    border: 0;
}
#detailModal .detail-primary-actions > .action-btn {
    box-sizing: border-box;
    min-width: 0;
    width: 100%;
    height: 64px;
    margin: 0;
    padding: 4px 8px;
    align-items: center;
    justify-content: center;
    align-content: center;
    font-size: 14px;
    line-height: 20px;
}
#detailModal .detail-primary-actions > .collab { gap: 0; }
#detailModal .detail-primary-actions .collab-btn-title {
    font-size: 14px;
    line-height: 18px;
}
#detailModal .detail-primary-actions .collab-btn-desc {
    font-size: 12px;
    line-height: 16px;
}
#detailModal #detailLink { order: 1; }
#detailModal #privateBidChatBtn { order: 2; }
#detailModal #collabLobbyBtn { order: 3; }
#detailModal #collabListBtn { order: 4; }
#detailModal #shareBtn { order: 5; }
#detailModal #workLogDetailBtn { order: 6; }
#detailModal .detail-primary-actions > .work-log-shared-links {
    order: 8;
    grid-column: 1 / -1;
    min-width: 0;
    max-height: 64px;
    overflow-y: auto;
    overscroll-behavior: contain;
}
#detailModal #fiscalBtn { order: 7; }
#detailModal .detail-primary-actions > .work-log-shared-links:empty { display: none; }
#detailModal .detail-notice-slot {
    min-height: 32px;
    margin-bottom: 4px;
}
#detailModal .detail-notice-slot > div {
    box-sizing: border-box;
    margin: 0 !important;
    padding: 4px 10px !important;
    font-size: 14px !important;
    line-height: 22px !important;
}
#detailModal .detail-notice summary {
    overflow: hidden;
    cursor: pointer;
    white-space: nowrap;
    text-overflow: ellipsis;
}
#detailModal .detail-notice-content {
    padding: 8px 0;
    white-space: normal;
    overflow-wrap: anywhere;
}
#detailModal .detail-org-wrap { min-width: 0; }
#detailModal #orgHistoryBtn {
    flex-shrink: 0;
    white-space: nowrap;
}
html[data-theme="dark"] #detailModal .detail-summary {
    background: #182334;
    border-color: #475569;
    color: #e2e8f0;
}
html[data-theme="dark"] #detailModal .detail-summary-label { color: #cbd5e1; }
@media (max-width: 767px) {
    #detailModal .detail-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    #detailModal .detail-primary-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* 보이는 동작만 순서대로 채우고, 빈 그룹의 아래 여백만 제거한다. */
#detailModal .detail-primary-actions[data-detail-action-rows] {
    align-items: start;
}
#detailModal .detail-primary-actions[data-detail-action-rows="empty"] {
    margin-bottom: 0;
}
#detailModal .detail-primary-actions > [hidden] {
    display: none !important;
}
@media (max-width: 767px) {
    /* 44px 접기/펼치기 영역 + 안내의 상하 패딩·테두리를 응답 전부터 예약한다. */
    #detailModal .detail-notice-slot {
        min-height: 54px;
    }
    #detailModal .detail-notice summary {
        box-sizing: border-box;
        min-height: 44px;
        padding-block: 11px;
    }
}

/* #450-100: adopted detail cards. Action order/targets stay actions-flow-v1. */
html body #detailModal.ui-flow {
    --flow-surface:#fff; --flow-border:#e3e6eb; --flow-text:#12151a; --flow-text-secondary:#4b5361;
}
html[data-theme="dark"] body #detailModal.ui-flow {
    --flow-surface:#14171b; --flow-border:#353b44; --flow-text:#eceef2; --flow-text-secondary:#a7aeba;
}
html body #detailModal.ui-flow > .modal-content { border-radius:8px; }
html body #detailModal.ui-flow > .modal-content > .modal-header { padding-block:8px; gap:8px; }
html body #detailModal.ui-flow #modalTitle { font-size:20px !important; line-height:1.4 !important; overflow-wrap:anywhere; }
html body #detailModal.ui-flow .detail-grid { gap:12px; align-items:start; }
html body #detailModal.ui-flow .detail-section { padding:12px; border-radius:8px; min-width:0; }
html body #detailModal.ui-flow .detail-section > h3 {
    display:flex; flex-wrap:wrap; align-items:center; gap:6px; min-height:var(--section-header-height,28px);
    box-sizing:border-box; margin:0 0 8px; padding:0 0 4px; font-size:14px;
    line-height:20px; border-bottom:1px solid var(--flow-border);
}
html body #detailModal.ui-flow :is(.detail-item,.detail-content,.extra-info-list,.detail-org-wrap) { min-width:0; }
html body #detailModal.ui-flow .detail-item { gap:8px; padding-block:6px; line-height:1.5; }
html body #detailModal.ui-flow .detail-item > :is(span,div) { overflow-wrap:anywhere; min-width:0; }
html body #detailModal.ui-flow .detail-item > label { color:var(--flow-text-secondary); }
html body #detailModal.ui-flow :is(.attachments-list,.detail-source-actions) { gap:8px; }
html body #detailModal.ui-flow .attachment-item { min-width:0; border-color:var(--flow-border); background:var(--flow-surface); }
html body #detailModal.ui-flow .attachment-name { min-width:0; white-space:normal; overflow-wrap:anywhere; }
@media(max-width:767px) {
    html body #detailModal.ui-flow #modalTitle { font-size:18px !important; }
    html body #detailModal.ui-flow .detail-grid { grid-template-columns:minmax(0,1fr); gap:8px; }
    html body #detailModal.ui-flow .detail-section { padding:10px; }
}
