:root {
    --v4-record-gutter: 18px;
    --v4-record-content-width: 1440px;
}

html.v4-record-modal-open,
body.v4-record-modal-open {
    overflow: hidden !important;
    overscroll-behavior: none;
}

body.v4-record-modal-open > :not(.v4-record-modal):not(script):not(style):not(link) {
    pointer-events: none !important;
    user-select: none;
}

.v4-record-modal {
    position: fixed;
    z-index: 2147483000;
    inset: 12px;
    box-sizing: border-box;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 18px;
    color: var(--v4-ink);
    background: var(--v4-paper);
    box-shadow: 0 28px 80px rgba(24, 42, 59, .25);
    overflow: hidden;
    isolation: isolate;
}

.v4-record-modal:not([open]) {
    display: none;
}

.v4-record-modal::backdrop {
    background: rgba(24, 42, 59, .72);
    backdrop-filter: blur(6px);
}

.v4-record-modal.is-fallback-modal {
    inset: 0;
    width: 100vw;
    height: 100dvh;
    padding: 12px;
    border-radius: 0;
    background: rgba(24, 42, 59, .72);
    box-shadow: none;
    backdrop-filter: blur(6px);
}

.v4-record-modal.is-fallback-modal .v4-record-modal-shell {
    border-radius: 18px;
    box-shadow: 0 28px 80px rgba(24, 42, 59, .25);
}

.v4-record-modal-shell {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: inherit;
    background: var(--v4-paper);
    isolation: isolate;
}

.v4-record-modal-header {
    position: relative;
    z-index: 4;
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
    padding-block: 8px;
    padding-inline: max(var(--v4-record-gutter), calc((100% - var(--v4-record-content-width)) / 2));
    border-bottom: 1px solid var(--v4-line);
    background: rgba(255, 255, 255, .96);
}

.v4-record-modal-header-start {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.v4-record-modal-back {
    min-width: 44px;
    min-height: 44px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 12px;
    border: 1px solid var(--v4-line);
    border-radius: 12px;
    color: var(--v4-ink);
    background: #fff;
    font: inherit;
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
}

.v4-record-modal-back svg {
    width: 18px;
    height: 18px;
}

.v4-record-modal-back:hover {
    border-color: var(--v4-control);
    background: var(--v4-surface-soft);
}

.v4-record-modal-back:focus-visible {
    outline: 3px solid var(--v4-brand);
    outline-offset: 2px;
}

.v4-record-modal-heading {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.v4-record-modal-heading-copy {
    min-width: 0;
}

.v4-record-modal-contact:not([hidden]) {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 14px;
    margin-top: 2px;
    color: var(--v4-muted);
    font-size: 12px;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.v4-record-modal.has-attendance-identity .v4-record-modal-heading {
    align-items: flex-start;
}

.v4-record-modal.has-attendance-identity .v4-record-modal-heading > span {
    padding-top: 3px;
}

.v4-record-modal.has-attendance-identity .v4-record-modal-heading h2 {
    font-size: 17px;
}

.v4-record-modal-heading > span {
    flex: 0 0 auto;
    color: var(--v4-muted);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.v4-record-modal-heading h2 {
    min-width: 0;
    margin: 0;
    color: var(--v4-ink);
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bni-v4 .v4-record-modal-heading h2:focus,
.bni-v4 .v4-record-modal-heading h2:focus-visible {
    outline: none;
}

.v4-record-modal-close {
    min-width: 44px;
    min-height: 44px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 12px;
    border: 1px solid var(--v4-line);
    border-radius: 12px;
    color: var(--v4-ink);
    background: #fff;
    font: inherit;
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
}

.v4-record-modal-close svg {
    width: 18px;
    height: 18px;
}

.v4-record-modal-close:hover {
    border-color: var(--v4-control);
    background: var(--v4-surface-soft);
}

.v4-record-modal-close:focus-visible {
    outline: 3px solid var(--v4-brand);
    outline-offset: 2px;
}

.v4-record-modal-body {
    position: relative;
    z-index: 1;
    min-height: 0;
    overflow: hidden;
    background: var(--v4-paper);
}

.v4-record-modal-frame {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: var(--v4-paper);
    opacity: 0;
    transition: opacity 140ms ease;
}

.v4-record-modal-frame:focus,
.v4-record-modal-frame:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

.v4-record-modal.is-ready .v4-record-modal-frame {
    opacity: 1;
}

.v4-record-modal-loading {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: grid;
    place-items: center;
    background: var(--v4-paper);
    transition: opacity 120ms ease;
}

.v4-record-modal.is-ready .v4-record-modal-loading {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.v4-record-modal-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--v4-line);
    border-top-color: var(--v4-brand);
    border-radius: 50%;
    animation: v4-record-modal-spin .8s linear infinite;
}

@keyframes v4-record-modal-spin {
    to { transform: rotate(360deg); }
}

html.v4-record-modal-root,
html.v4-record-modal-root body {
    min-height: 100%;
    background: var(--v4-paper);
}

body.v4-record-modal-document {
    position: relative;
    min-width: 0;
    margin: 0;
    padding: 16px var(--v4-record-gutter) 28px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    isolation: isolate;
}

.v4-record-modal-document .dropdown-menu.show,
.v4-record-modal-document .popover.show {
    z-index: 1200;
}

.v4-record-modal-document [popover]:popover-open,
.v4-record-modal-document dialog[open] {
    z-index: 2147483000;
}

.v4-record-modal-document #v4-main {
    width: min(100%, var(--v4-record-content-width));
    margin: 0 auto;
}

.v4-record-modal-document .v4-editor-back,
.v4-record-modal-document .v4-radar-back {
    display: none !important;
}

.v4-record-modal-document .v4-property-editor,
.v4-record-modal-document .v4-radars {
    margin-top: 0;
}

.v4-record-modal-document .v4-editor-page-heading,
.v4-record-modal-document .v4-radar-operational-header {
    margin-top: 0;
}

.v4-record-modal-document .v4-property-detail-navigation,
.v4-record-modal-document .v4-radar-detail-tabs {
    top: 0;
}

@media (max-width: 640px) {
    :root {
        --v4-record-gutter: 10px;
    }

    .v4-record-modal {
        inset: 0;
        width: auto;
        height: auto;
        border-radius: 0;
    }

    .v4-record-modal.is-fallback-modal {
        padding: 0;
    }

    .v4-record-modal.is-fallback-modal .v4-record-modal-shell {
        border-radius: 0;
    }

    .v4-record-modal-header {
        min-height: 56px;
        padding-block: max(6px, env(safe-area-inset-top)) 6px;
    }

    .v4-record-modal-header-start {
        gap: 6px;
    }

    .v4-record-modal-back {
        padding: 0 9px;
    }

    .v4-record-modal-heading {
        display: block;
    }

    .v4-record-modal-heading > span {
        display: block;
        margin-bottom: 1px;
        font-size: .62rem;
    }

    .v4-record-modal-heading h2 {
        font-size: .9rem;
    }

    .v4-record-modal.has-attendance-identity .v4-record-modal-back {
        width: 44px;
        padding: 0;
    }

    .v4-record-modal.has-attendance-identity .v4-record-modal-back > span {
        display: none;
    }

    .v4-record-modal.has-attendance-identity .v4-record-modal-heading h2 {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        font-size: 14px;
        overflow-wrap: anywhere;
        white-space: normal;
    }

    .v4-record-modal.has-attendance-identity .v4-record-modal-heading > span {
        padding-top: 0;
    }

    .v4-record-modal-contact:not([hidden]) {
        font-size: 11px;
    }

    .v4-record-modal-close {
        flex: 0 0 44px;
        width: 44px;
        padding: 0;
    }

    .v4-record-modal-close span {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    body.v4-record-modal-document {
        padding-block: 10px max(18px, env(safe-area-inset-bottom));
    }
}

@media (prefers-reduced-motion: reduce) {
    .v4-record-modal-frame,
    .v4-record-modal-loading {
        transition: none;
    }

    .v4-record-modal-spinner {
        animation-duration: 1.6s;
    }
}
