

.jex-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
        max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.jex-overlay.active {
    display: flex;
    animation: jex-overlay-in 0.18s ease forwards;
}

@keyframes jex-overlay-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.jex-modal {
    position: relative;
    width: 100%;
    background: linear-gradient(150deg, #1a1e2e 0%, #14172200 100%), #14172280;
    background: linear-gradient(160deg, #1c2033 0%, #151820 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.04),
        0 32px 80px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    overflow: hidden;
    animation: jex-modal-in 0.24s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes jex-modal-in {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.jex-modal-sm  { max-width: 460px; }
.jex-modal-md  { max-width: 560px; }
.jex-modal-lg  { max-width: 660px; }
.jex-modal-xl  { max-width: 780px; }

.jex-modal-scroll {
    max-height: min(90vh, 780px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.jex-modal-scroll::-webkit-scrollbar { width: 3px; }
.jex-modal-scroll::-webkit-scrollbar-track { background: transparent; }
.jex-modal-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 99px;
}

.jex-modal-flex {
    display: flex;
    flex-direction: column;
    max-height: min(90vh, 780px);
    overflow: hidden;
}

.jex-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: rgba(200, 215, 240, 0.45);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
    font-family: inherit;
    z-index: 2;
}

.jex-modal-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(225, 235, 255, 0.85);
}

.jex-modal-head {
    padding: 26px 60px 22px 28px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.jex-modal-kicker {
    font-size: 0.69rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(165, 188, 230, 0.65);
    margin-bottom: 6px;
    font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
}

.jex-modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: rgba(238, 244, 255, 0.95);
    line-height: 1.35;
    letter-spacing: -0.015em;
    margin: 0;
}

.jex-modal-subtitle {
    font-size: 0.875rem;
    color: rgba(175, 195, 230, 0.68);
    margin: 8px 0 0;
    line-height: 1.65;
}

.jex-modal-body {
    padding: 24px 28px;
}

.jex-modal-body.flex-grow {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 120px;
}

.jex-modal-body.flex-grow::-webkit-scrollbar { width: 3px; }
.jex-modal-body.flex-grow::-webkit-scrollbar-track { background: transparent; }
.jex-modal-body.flex-grow::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 99px;
}

.jex-modal-footer {
    padding: 18px 28px 26px;
    display: flex;
    gap: 10px;
}

.jex-modal-footer.bordered {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.1);
    padding: 14px 22px 16px;
}

.jex-btn {
    flex: 1;
    padding: 11px 20px;
    border-radius: 9px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    font-family: inherit;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    letter-spacing: -0.005em;
}

.jex-btn-ghost {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(195, 212, 242, 0.72);
}

.jex-btn-ghost:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(255, 255, 255, 0.18);
    color: rgba(220, 233, 255, 0.9);
}

.jex-btn-primary {
    background: rgba(228, 236, 255, 0.92);
    border: 1px solid transparent;
    color: #151820;
    font-weight: 600;
}

.jex-btn-primary:hover { background: #eaf0ff; }
.jex-btn-primary:active { background: rgba(215, 226, 252, 0.88); }

.jex-btn-danger {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.32);
    color: rgba(252, 165, 165, 0.85);
}

.jex-btn-danger:hover {
    background: rgba(239, 68, 68, 0.09);
    border-color: rgba(239, 68, 68, 0.5);
    color: #fca5a5;
}

.jex-btn-send {
    width: 38px;
    height: 38px;
    flex: none;
    padding: 0;
    border-radius: 9px;
    background: rgba(228, 236, 255, 0.9);
    border: none;
    color: #151820;
    font-size: 14px;
    font-weight: 700;
    transition: background 0.15s ease;
    cursor: pointer;
}

.jex-btn-send:hover { background: #eaf0ff; }

.jex-field {
    margin-bottom: 18px;
}

.jex-field:last-child { margin-bottom: 0; }

.jex-field-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: rgba(165, 188, 225, 0.65);
    margin-bottom: 8px;
    font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
}

.jex-input,
.jex-textarea {
    width: 100%;
    padding: 12px 14px;
    font-size: 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.055);
    color: rgba(228, 238, 255, 0.88);
    font-family: inherit;
    transition: border-color 0.15s ease, background 0.15s ease;
    box-sizing: border-box;
}

.jex-input::placeholder,
.jex-textarea::placeholder {
    color: rgba(160, 180, 215, 0.3);
}

.jex-input:focus,
.jex-textarea:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.08);
}

.jex-textarea {
    resize: vertical;
    min-height: 114px;
    max-height: 260px;
    line-height: 1.62;
}

.jex-textarea-auto {
    resize: none;
    min-height: 40px;
    max-height: 120px;
    overflow-y: hidden;
    line-height: 1.55;
    flex: 1;
}

.jex-info-table {
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 11px;
    overflow: hidden;
    margin-bottom: 20px;
}

.jex-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.jex-info-row:last-child { border-bottom: none; }
.jex-info-row:nth-child(even) { background: rgba(255, 255, 255, 0.025); }

.jex-info-label {
    font-size: 0.825rem;
    color: rgba(170, 192, 230, 0.72);
}

.jex-info-value {
    font-size: 0.84rem;
    color: rgba(220, 234, 255, 0.88);
    text-align: right;
    font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
}

.jex-info-value.accent { color: rgba(235, 244, 255, 0.97); }

.jex-spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid rgba(200, 220, 255, 0.1);
    border-top-color: rgba(200, 220, 255, 0.65);
    animation: jex-spin 0.7s linear infinite;
    margin: 0 auto 22px;
}

@keyframes jex-spin {
    to { transform: rotate(360deg); }
}

.jex-success-icon {
    width: 52px;
    height: 52px;
    background: rgba(200, 220, 255, 0.08);
    border: 1px solid rgba(200, 220, 255, 0.15);
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 22px;
    color: rgba(220, 238, 255, 0.9);
}

.jex-modal-center {
    text-align: center;
    padding: 40px 36px 36px;
}

.jex-modal-center .jex-modal-title {
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.jex-modal-center .jex-modal-subtitle {
    margin: 0 auto 24px;
    max-width: 310px;
}

.jex-msg-thread {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px 24px;
    background: rgba(6, 8, 14, 0.3);
    flex: 1;
    overflow-y: auto;
    min-height: 160px;
    -webkit-overflow-scrolling: touch;
}

.jex-msg-thread::-webkit-scrollbar { width: 3px; }
.jex-msg-thread::-webkit-scrollbar-track { background: transparent; }
.jex-msg-thread::-webkit-scrollbar-thumb {
    background: rgba(200, 218, 255, 0.12);
    border-radius: 99px;
}

.jex-reply-bar {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 20px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(6, 8, 14, 0.2);
    flex-shrink: 0;
}

@media (max-width: 540px) {
    .jex-modal-sm,
    .jex-modal-md,
    .jex-modal-lg,
    .jex-modal-xl {
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        margin-top: auto;
        margin-bottom: 0;
    }

    .jex-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .jex-modal-flex {
        max-height: 88dvh;
        border-radius: 16px 16px 0 0;
    }
}
