.chat-deal-layout {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}
.chat-deal-layout.deal-ui-off {
    display: flex;
    grid-template-columns: none;
    grid-template-areas: none;
}
.chat-deal-layout.deal-ui-off > .deal-column {
    display: none;
}
@media (min-width: 901px) {
    .chat-deal-layout.deal-ui-off {
        display: flex;
        flex-direction: column;
        grid-template-columns: none;
    }
    .chat-deal-layout.deal-ui-off > .main-container {
        grid-area: auto;
        height: auto;
    }
}

.deal-column {
    min-height: 0;
}
.mobile-deal-public-link {
    display: none;
}

#dealPayoutBar {
    min-height: 0;
}
#dealPayoutBar[open] {
    max-height: min(58dvh, 520px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
#dealPayoutBar > summary {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #ecfdf5;
    padding-bottom: 4px;
}
#dealPayoutBar[open] .deal-panel-body {
    padding-bottom: 16px;
}
#dealList button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #a7f3d0;
    background: #fff;
    font-size: 11px;
    line-height: 1.45;
    color: #374151;
}
#dealList button.on {
    border-color: #059669;
    background: #ecfdf5;
}
#dealList .deal-muted { color: #6b7280; }

@media (min-width: 901px) {
    .page-container {
        max-width: 1180px;
    }
    .chat-deal-layout {
        display: grid;
        grid-template-columns: 1.15fr 0.85fr;
        grid-template-areas: "chat deal";
        gap: 14px;
        margin-top: 8px;
    }
    .chat-deal-layout > .main-container {
        grid-area: chat;
        margin-top: 0 !important;
        min-height: 0;
        height: 100%;
    }
    .chat-deal-layout.deal-ui-off {
        display: flex;
        flex-direction: column;
        grid-template-columns: none;
        grid-template-areas: none;
    }
    .chat-deal-layout.deal-ui-off > .main-container {
        grid-area: auto;
        height: auto;
        min-height: 0;
    }
    .deal-column {
        grid-area: deal;
        height: 100%;
        display: flex;
        flex-direction: column;
    }
    .deal-column #dealPayoutBar {
        margin-top: 0;
        border-radius: 18px;
    }
    #dealPayoutBar,
    #dealPayoutBar[open] {
        flex: 1;
        min-height: 0;
        max-height: none;
        margin-top: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    #dealPayoutBar > summary {
        pointer-events: none;
        list-style: none;
    }
    #dealPayoutBar > summary::-webkit-details-marker {
        display: none;
    }
    #dealPayoutBar .deal-panel-body {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    #dealList {
        max-height: min(36vh, 280px);
    }
}

@media (max-width: 900px) {
    .chat-deal-layout {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        grid-template-areas: "deal" "chat";
    }
    .chat-deal-layout:has(.mobile-peer-bar) {
        grid-template-rows: auto auto 1fr;
        grid-template-areas: "deal" "peer" "chat";
        row-gap: 0;
    }
    .deal-column { grid-area: deal; }
    .mobile-peer-bar { grid-area: peer; }
    .chat-deal-layout > .main-container {
        grid-area: chat;
        min-height: 0;
    }
    .chat-deal-layout.deal-ui-off:has(.mobile-peer-bar) {
        grid-template-rows: auto 1fr;
        grid-template-areas: "peer" "chat";
    }
    .mobile-deal-public-link {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-top: 8px;
        padding: 10px 12px;
        border-radius: 8px;
        background: #ecfdf5;
        border: 1px solid #a7f3d0;
        color: #065f46;
        text-decoration: none;
        font-size: 13px;
        font-weight: 600;
    }
    .mobile-deal-public-link::after {
        content: "↗";
        font-weight: 500;
        color: #047857;
    }
    .deal-column:has(.mobile-deal-public-link) > #dealPayoutBar {
        display: none !important;
    }
}

html:not(.deal-ui-schemes-ready) label:has(> input[name="dealScheme"]) {
    display: none !important;
}
html:not(.deal-ui-schemes-ready) #dealSchemeGuard {
    display: none !important;
}
html.deal-ui-schemes-ready #dealSchemeLoading {
    display: none !important;
}
html.deal-wallet-soft-blocked #dealApproveBtn,
html.deal-wallet-soft-blocked #dealLockBtn,
html.deal-wallet-soft-blocked #dealReleaseBtn,
html.deal-wallet-soft-blocked #dealCancelBtn,
html.deal-wallet-soft-blocked #dealRefundBtn {
    pointer-events: none;
    opacity: 0.42;
    filter: grayscale(0.3);
}
#dealWalletSoftWall:not(.hidden) {
    position: sticky;
    top: 8px;
    z-index: 8;
    box-shadow: 0 8px 24px rgba(120, 53, 15, 0.12);
}
