.profile-share-dialog,
.profile-share-dialog * {
    box-sizing: border-box;
}

.profile-share-dialog {
    inset: auto 0 0;
    width: min(24rem, 100%);
    max-width: min(24rem, 100%);
    height: fit-content;
    max-height: 52vh;
    max-height: min(52dvh, calc(100dvh - env(safe-area-inset-top, 0px) - 8dvh));
    margin: 0 auto;
    border: 0;
    padding: 0;
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    background: transparent;
    overflow: hidden;
    color: inherit;
}

.profile-share-dialog:has([data-share-stage="qr"]:not([hidden])) {
    max-height: 80vh;
    max-height: min(80dvh, calc(100dvh - env(safe-area-inset-top, 0px) - 8dvh));
}

.profile-share-dialog--pix {
    height: 92vh;
    height: min(92dvh, calc(100dvh - env(safe-area-inset-top, 0px) - 8dvh));
    max-height: 92vh;
    max-height: min(92dvh, calc(100dvh - env(safe-area-inset-top, 0px) - 8dvh));
}

.profile-share-dialog::backdrop {
    background: rgba(15, 23, 42, 0.48);
}

.profile-share-dialog__sheet {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    max-height: inherit;
    padding: 0.35rem 1.25rem calc(1.15rem + env(safe-area-inset-bottom, 0px));
    border-radius: 16px 16px 0 0;
    background: var(--card-bg, #fff);
    color: var(--color-text-primary, #0f172a);
    box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.22);
    overflow: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.profile-share-dialog--pix .profile-share-dialog__sheet {
    height: 100%;
    overflow: hidden;
    overflow-x: hidden;
}

.profile-share-dialog[open] .profile-share-dialog__sheet {
    animation: profile-sheet-in 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes profile-sheet-in {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .profile-share-dialog[open] .profile-share-dialog__sheet {
        animation: none;
    }
}

.profile-share-dialog__handle {
    flex-shrink: 0;
    width: 2.5rem;
    height: 0.25rem;
    margin: 0.35rem auto 0.65rem;
    border-radius: 999px;
    background: color-mix(in srgb, currentColor 22%, transparent);
}

.profile-share-dialog__header {
    display: flex;
    flex-shrink: 0;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.profile-share-dialog__header--pix {
    justify-content: flex-end;
    margin-bottom: 0.25rem;
}

.profile-share-dialog__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--color-text-primary, #0f172a);
}

.profile-share-dialog__body {
    display: flex;
    flex-direction: column;
    flex: 0 1 auto;
    min-width: 0;
    min-height: 0;
    overflow: visible;
}

.profile-share-dialog--pix .profile-share-dialog__body {
    flex: 1 1 auto;
    overflow: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.profile-share-dialog__close,
.profile-share-dialog__back {
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font: inherit;
    touch-action: manipulation;
}

.profile-share-dialog__close {
    flex-shrink: 0;
    width: 2.75rem;
    height: 2.75rem;
    min-width: 44px;
    min-height: 44px;
    border-radius: 999px;
}

.profile-share-dialog__close:focus-visible,
.profile-share-dialog__back:focus-visible,
.profile-share-dialog__btn:focus-visible {
    outline: 2px solid var(--color-primary-500, #7c5cdb);
    outline-offset: 2px;
}

.profile-share-dialog [hidden],
.profile-share-dialog [data-share-stage][hidden] {
    display: none !important;
}

.profile-share-dialog__actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.profile-share-dialog__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    min-height: 44px;
    padding: 0.7rem 1rem;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, var(--button-bg, var(--color-primary-600, #7c5cdb)) 28%, transparent);
    background: var(--button-bg, var(--color-primary-600, #7c5cdb));
    color: var(--button-text, #fff);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
}

.profile-share-dialog__btn--secondary {
    background: transparent;
    color: inherit;
}

.profile-share-dialog__btn:active {
    transform: scale(0.98);
}

@media (hover: hover) and (pointer: fine) {
    .profile-share-dialog__btn:hover {
        filter: brightness(0.96);
    }

    .profile-share-dialog__btn--secondary:hover {
        background: color-mix(in srgb, currentColor 8%, transparent);
        filter: none;
    }

    .profile-share-dialog__close:hover {
        background: color-mix(in srgb, currentColor 8%, transparent);
    }
}

.profile-share-dialog__back {
    min-height: 44px;
    margin-bottom: 0.5rem;
    padding: 0;
    font-size: 0.875rem;
    font-weight: 600;
    text-align: left;
}

.profile-qr {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.85rem;
}

.profile-qr__canvas {
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    max-width: 100%;
    height: auto;
    min-width: min(200px, 100%);
    min-height: min(200px, 100%);
    padding: 12px;
    background: #fff;
    color-scheme: light;
    border-radius: 12px;
}

.profile-qr__canvas svg,
.profile-qr__canvas svg * {
    box-sizing: content-box !important;
    margin: 0 !important;
    padding: 0 !important;
}

.profile-qr__canvas svg {
    display: block;
    width: min(200px, 100%);
    height: auto;
    aspect-ratio: 1;
    min-width: 200px;
    max-width: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.profile-qr__caption {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.profile-share-dialog__notice {
    margin: 0 0 0.75rem;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--color-text-secondary, #475569);
}

.profile-share-dialog .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 359px) {
    .profile-share-dialog__sheet {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .profile-qr__canvas svg {
        min-width: 0;
        width: min(200px, 100%);
    }
}

@media (min-width: 768px) {
    .profile-share-dialog {
        width: 24rem;
        max-width: 24rem;
    }
}
