body.modal-open {
    overflow: hidden;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(12, 26, 43, 0.68);
}

.modal-overlay[hidden] {
    display: none;
}

.modal {
    width: min(100%, 720px);
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--color-surface);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-large);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
}

.modal-large {
    width: min(100%, 1050px);
}

.modal-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 22px 26px;
    color: #ffffff;
    background: var(--color-navy);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.35rem;
}

.modal-header p {
    margin: 5px 0 0;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.88rem;
}

.modal-close {
    position: relative;
    width: 36px;
    height: 36px;
    min-width: 36px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid transparent;
    border-radius: 50%;
    font-size: 0;
    line-height: 1;
    cursor: pointer;
    transition:
        background-color 180ms ease,
        border-color 180ms ease,
        transform 180ms ease;
}

.modal-close::before,
.modal-close::after {
    content: "";
    position: absolute;
    top: calc(50% + 1px);
    left: calc(50% - 1px);
    width: 14px;
    height: 2px;
    background: #ffffff;
    border-radius: 2px;
    transform-origin: center;
}

.modal-close::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.modal-close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.24);
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.modal-close:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.45);
    outline-offset: 2px;
}

.modal-close:active {
    transform: scale(0.96);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 26px;
}

.modal-footer {
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 18px 26px;
    background: #f8fafc;
    border-top: 1px solid var(--color-border);
}
/* Keep shared confirmation dialogs above any open editor/modal. */
#delete-confirmation-modal,
#unsaved-changes-modal {
    z-index: 2500;
}
