:root {
    --x3-epf-z-index: 2147483000;
    --x3-epf-overlay: rgba(3, 7, 18, 0.78);
    --x3-epf-surface: #ffffff;
    --x3-epf-text: #111827;
    --x3-epf-muted: #6b7280;
    --x3-epf-border: rgba(17, 24, 39, 0.12);
    --x3-epf-radius: 24px;
    --x3-epf-shadow: 0 28px 90px rgba(0, 0, 0, 0.38);
    --x3-epf-speed: 240ms;
}

body.x3-epf-body-locked {
    position: fixed;
    width: 100%;
    overflow: hidden;
}

.x3-epf-root {
    display: contents;
}

.x3-epf-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 14px 24px;
    border: 0;
    border-radius: 999px;
    background: #111827;
    color: #ffffff;
    font: inherit;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 12px 28px rgba(17, 24, 39, 0.22);
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
    -webkit-appearance: none;
    appearance: none;
}

.x3-epf-button:hover,
.x3-epf-button:focus-visible {
    background: #000000;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 16px 34px rgba(17, 24, 39, 0.3);
}

.x3-epf-button:focus-visible,
.x3-epf-close:focus-visible,
.x3-epf-dialog:focus-visible {
    outline: 3px solid rgba(59, 130, 246, 0.5);
    outline-offset: 3px;
}

.x3-epf-modal {
    position: fixed;
    inset: 0;
    z-index: var(--x3-epf-z-index);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 100vw;
    min-height: 100vh;
    padding: clamp(16px, 4vw, 44px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--x3-epf-speed) ease, visibility 0s linear var(--x3-epf-speed);
}

.x3-epf-modal.x3-epf-is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
}

.x3-epf-overlay {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: var(--x3-epf-overlay);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.x3-epf-dialog {
    position: relative;
    z-index: 1;
    width: min(720px, 100%);
    max-height: min(88vh, 920px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    background: var(--x3-epf-surface);
    color: var(--x3-epf-text);
    border: 1px solid var(--x3-epf-border);
    border-radius: var(--x3-epf-radius);
    box-shadow: var(--x3-epf-shadow);
    transform: translateY(12px) scale(0.96);
    transition: transform var(--x3-epf-speed) ease;
}

.x3-epf-modal.x3-epf-is-open .x3-epf-dialog {
    transform: translateY(0) scale(1);
}

.x3-epf-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 24px 14px;
    background: linear-gradient(180deg, #ffffff 78%, rgba(255, 255, 255, 0));
}

.x3-epf-title {
    margin: 0;
    color: var(--x3-epf-text);
    font-size: clamp(22px, 3vw, 30px);
    font-weight: 800;
    line-height: 1.15;
}

.x3-epf-close {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--x3-epf-border);
    border-radius: 999px;
    background: #f9fafb;
    color: #111827;
    font: inherit;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
    transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
    -webkit-appearance: none;
    appearance: none;
}

.x3-epf-close:hover,
.x3-epf-close:focus-visible {
    background: #f3f4f6;
    border-color: rgba(17, 24, 39, 0.24);
    color: #111827;
    transform: rotate(90deg);
}

.x3-epf-close span {
    display: block;
    margin-top: -4px;
}

.x3-epf-close-floating {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 3;
}

.x3-epf-body {
    padding: 0 24px 24px;
}

.x3-epf-close-floating + .x3-epf-body {
    padding-top: 66px;
}

.x3-epf-body iframe,
.x3-epf-body form,
.x3-epf-body input,
.x3-epf-body textarea,
.x3-epf-body select,
.x3-epf-body button {
    max-width: 100%;
}

.x3-epf-body iframe {
    width: 100%;
}

.x3-epf-admin-warning {
    padding: 16px;
    border: 1px solid rgba(245, 158, 11, 0.55);
    border-radius: 14px;
    background: rgba(255, 251, 235, 0.95);
    color: #78350f;
    font-size: 15px;
    line-height: 1.55;
}

.x3-epf-admin-warning code {
    padding: 2px 5px;
    border-radius: 5px;
    background: rgba(120, 53, 15, 0.09);
    color: #78350f;
}

@media (max-width: 640px) {
    .x3-epf-modal {
        align-items: flex-start;
        justify-content: center;
        padding: 10px;
        overflow-y: auto;
        min-height: 100dvh;
    }

    .x3-epf-dialog {
        width: 100%;
        max-height: calc(100dvh - 20px);
        margin: auto 0;
        border-radius: 18px;
    }

    .x3-epf-header {
        padding: 18px 18px 12px;
    }

    .x3-epf-body {
        padding: 0 18px 18px;
    }

    .x3-epf-close-floating + .x3-epf-body {
        padding-top: 62px;
    }

    .x3-epf-close {
        width: 40px;
        height: 40px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .x3-epf-modal,
    .x3-epf-dialog,
    .x3-epf-button,
    .x3-epf-close {
        transition: none;
    }
}
