/* Canonical popup shell: based on the Duel history dialog. See AGENTS.md. */
html[data-popup-locked], html[data-popup-locked] body { overflow: hidden !important; overscroll-behavior: none; }
.bdx-popup {
    display: none !important;
    position: fixed !important;
    inset: var(--popup-viewport-top, 0px) 0 auto !important;
    width: 100% !important;
    height: var(--popup-viewport-height, 100dvh) !important;
    margin: 0 !important;
    padding: 24px 24px calc(24px + var(--popup-nav-space, 0px)) !important;
    box-sizing: border-box !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
    overscroll-behavior: none;
    background: rgba(14, 22, 34, 0.62) !important;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: var(--popup-layer, 100000) !important;
}
.bdx-popup[data-popup-active] { display: flex !important; }
.bdx-popup[hidden] { display: none !important; }
.bdx-popup .bdx-popup__dialog {
    position: relative !important;
    inset: auto !important;
    display: flex !important;
    flex-direction: column !important;
    flex: 0 1 auto;
    width: min(var(--popup-width, 620px), 100%) !important;
    max-width: 100% !important;
    min-width: 0;
    min-height: 0 !important;
    height: auto !important;
    max-height: min(820px, 100%) !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    border: none !important;
    border-radius: var(--radius-lg, 16px) !important;
    background: var(--surface-muted, #f0f3f6) !important;
    color: var(--text-strong, #1c2530);
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.34) !important;
    text-align: left !important;
    transform: none !important;
    visibility: visible !important;
    animation: none !important;
}
.bdx-popup .bdx-popup__head {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex: 0 0 auto !important;
    gap: 12px;
    margin: 0 !important;
    padding: 16px 18px !important;
    background: #fff !important;
    border: 0 !important;
    border-bottom: 1px solid var(--border-subtle, #e1e7ee) !important;
    color: var(--text-strong, #1c2530) !important;
}
.bdx-popup__head > :first-child { min-width: 0; }
.bdx-popup .bdx-popup__head :is(h2, h3, .bdx-popup__title) {
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    color: var(--text-strong, #1c2530) !important;
    font-size: 1.15rem !important;
    line-height: 1.3;
    text-align: left !important;
    text-shadow: none !important;
    overflow-wrap: anywhere;
}
.bdx-popup .bdx-popup__close {
    position: static !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;
    flex: 0 0 36px !important;
    box-sizing: border-box;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: var(--surface-muted, #f0f3f6) !important;
    color: var(--text-muted, #697482) !important;
    box-shadow: none !important;
    transform: none !important;
    font: 1.35rem/1 'Segoe UI', sans-serif;
    cursor: pointer;
}
.bdx-popup__close svg { width: 20px; height: 20px; }
.bdx-popup .bdx-popup__body {
    flex: 1 1 auto;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    padding: 18px !important;
    margin: 0 !important;
    scrollbar-gutter: stable;
    overflow-wrap: anywhere;
}
.bdx-popup .bdx-popup__foot {
    flex: 0 0 auto;
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 9px;
    margin: 0 !important;
    padding: 14px 18px !important;
    background: #fff;
    border-top: 1px solid var(--border-subtle, #e1e7ee);
}
.bdx-popup__foot:empty { display: none; }
.bdx-popup__body :is(h2, h3, h4) { color: var(--text-strong, #1c2530); text-shadow: none !important; }
.bdx-popup .bdx-popup__button {
    appearance: none;
    width: auto !important;
    min-width: 0;
    box-sizing: border-box;
    margin: 0 !important;
    padding: 10px 14px !important;
    border: 1px solid transparent !important;
    border-radius: var(--radius-md, 12px) !important;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 800;
    line-height: 1.2;
    box-shadow: none !important;
    cursor: pointer;
    background: var(--dex-green, #4caf50) !important;
    color: #fff !important;
}
.bdx-popup .bdx-popup__button--quiet { background: var(--surface-muted, #f0f3f6) !important; color: #566170 !important; }
.bdx-popup .bdx-popup__button--danger { background: var(--dex-red, #dc0a2d) !important; color: #fff !important; }
.bdx-popup .bdx-popup__button--secondary { background: #fff !important; border-color: var(--border-info, #acdafa) !important; color: var(--text-info, #147fbe) !important; }
.bdx-popup__body > .bdx-popup__button { width: 100% !important; }
.bdx-popup button:disabled { cursor: not-allowed; opacity: 0.55; }
.bdx-popup :is(button, a, input, select, textarea):focus-visible {
    outline: 2px solid var(--text-info, #147fbe) !important;
    outline-offset: 3px;
}
.bdx-popup .np-message { margin: 0; white-space: pre-wrap; line-height: 1.5; color: #444; }
.bdx-popup .np-input {
    width: 100%; box-sizing: border-box; margin-top: 14px; padding: 11px 12px;
    border: 1px solid #cfd8e3; border-radius: var(--radius-md, 12px); font: inherit;
    background: #fff; color: var(--text-strong, #1c2530);
}
.np-btn-charging { position: relative; overflow: hidden; }
.np-btn-label { position: relative; z-index: 1; }
.np-countdown-fill { position: absolute; inset: 0 0 0 auto; width: 0; background: rgba(255,255,255,0.2); }

/* Legacy content regions relinquish scrolling to the shell's single body. */
.bdx-popup__body :is(.fr-scroll, .cu-scroll, .cu-list, .blm-body, #nearby-buses-list,
    #gradient-edit-list, #title-edit-list, #badge-edit-list, #network-activity-body) {
    max-height: none !important; overflow: visible !important; min-height: 0;
}
.bdx-popup__body .lb-sheet__grip { display: none; }
.bdx-popup__head .tut-card__icon { display: none; }
.bdx-popup__head .tut-card__title { flex: 1; }
.bdx-popup__body #result-content { color: var(--text-strong, #1c2530); }
.bdx-popup__body :is(.logres-title, .logres-sub, .logcard-foot__label) { color: var(--text-strong, #1c2530); }
.bdx-popup__body .logres-panel { background: var(--surface-success, #e8f5e9); color: var(--text-success, #2e7d32); }
.bdx-popup__body .card-overlay__stage { margin-inline: auto; }
.bdx-popup__body :is(.card-overlay__hint, .card-overlay__pos, .card-overlay__acquired) { color: var(--text-muted, #697482); }
.bdx-popup__body .card-overlay__action { background: #fff; border-color: var(--border-info, #acdafa); color: var(--text-info, #147fbe); border-radius: var(--radius-md, 12px); }
.bdx-popup__body .card-overlay__action.is-showcased { background: #f0b429; color: #302000; }
.bdx-popup__body .card-overlay__nav { color: var(--text-info, #147fbe); }
/* Navigation remains above every popup, including nested confirmations. */
.mobile-nav[data-popup-navigation] {
    z-index: 200000 !important;
    bottom: calc(100% - var(--popup-viewport-top, 0px) - var(--popup-viewport-height, 100dvh) + max(15px, env(safe-area-inset-bottom))) !important;
}
@media (max-width: 768px) {
    .bdx-popup {
        padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
            calc(max(16px, env(safe-area-inset-bottom)) + var(--popup-nav-space, 0px)) max(16px, env(safe-area-inset-left)) !important;
    }
    .bdx-popup .bdx-popup__dialog {
        width: 100% !important;
        max-height: 100% !important;
        border-radius: var(--radius-lg, 16px) !important;
    }
    .bdx-popup .bdx-popup__body { padding: 15px !important; }
    .bdx-popup .bdx-popup__body:last-child { padding-bottom: calc(15px + env(safe-area-inset-bottom)) !important; }
    .bdx-popup .bdx-popup__foot { padding: 12px 15px calc(12px + env(safe-area-inset-bottom)) !important; }
    .bdx-popup__foot > .bdx-popup__button { flex: 1 1 0; }
    .bdx-popup input:not([type=checkbox]):not([type=radio]):not([type=range]),
    .bdx-popup select, .bdx-popup textarea { font-size: max(16px, 1em); }
}
