.elg-modal[hidden] {
    display: none !important;
}

html.elg-modal-open,
html.elg-modal-open body {
    overflow: hidden;
}

.elg-modal {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.elg-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
}

.elg-modal__dialog {
    position: relative;
    width: min(100%, 620px);
    max-height: calc(100vh - 40px);
    overflow: auto;
    padding: 28px;
    border: 1px solid #4a4c50;
    border-radius: 8px;
    background: #2d2e30;
    color: #e5e5e5;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.elg-modal__dialog:focus {
    outline: 2px solid #1683a5;
    outline-offset: 3px;
}

.elg-modal__title {
    margin: 0 0 14px;
    color: #ffffff;
    font-size: clamp(1.3rem, 3vw, 1.7rem);
    line-height: 1.25;
}

.elg-modal__dialog p {
    margin: 0 0 20px;
    color: #e5e5e5;
    line-height: 1.55;
}

.elg-modal__target {
    display: grid;
    gap: 6px;
    margin: 0 0 24px;
    padding: 14px;
    border: 1px solid #45474a;
    border-radius: 5px;
    background: #242527;
}

.elg-modal__label {
    color: #aeb3b8;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.elg-modal__target strong {
    color: #ffffff;
    overflow-wrap: anywhere;
}

.elg-modal__target code {
    display: block;
    max-height: 90px;
    overflow: auto;
    padding: 0;
    background: transparent;
    color: #b9dce7;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.84rem;
    white-space: normal;
    overflow-wrap: anywhere;
}

.elg-modal__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.elg-button {
    min-height: 42px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 5px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.elg-button:focus-visible {
    outline: 3px solid rgba(22, 131, 165, 0.45);
    outline-offset: 2px;
}

.elg-button--secondary {
    border-color: #686b70;
    background: transparent;
    color: #ffffff;
}

.elg-button--secondary:hover {
    background: #3a3b3e;
}

.elg-button--primary {
    background: #1683a5;
    color: #ffffff;
}

.elg-button--primary:hover {
    background: #126e8b;
}

.elg-external-link--icon::after {
    content: " ↗";
    font-size: 0.82em;
    white-space: nowrap;
}

@media (max-width: 520px) {
    .elg-modal {
        align-items: flex-end;
        padding: 12px;
    }

    .elg-modal__dialog {
        padding: 22px 18px;
    }

    .elg-modal__actions {
        flex-direction: column-reverse;
    }

    .elg-button {
        width: 100%;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .elg-modal__dialog {
        animation: elg-modal-in 140ms ease-out;
    }

    @keyframes elg-modal-in {
        from {
            opacity: 0;
            transform: translateY(8px) scale(0.99);
        }
        to {
            opacity: 1;
            transform: none;
        }
    }
}

.elg-external-image-placeholder,
.elg-external-image-link {
    display: inline-block;
    max-width: 100%;
    padding: 8px 11px;
    border: 1px solid #55585c;
    border-radius: 5px;
    background: #242527;
    color: #b9dce7;
    font-size: 0.92em;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.elg-external-image-link::before {
    content: "🖼 ";
}
