:root {
    --hpc-toast-success: #39b54a;
    --hpc-toast-success-soft: #eefaf0;
    --hpc-toast-message: #a5167d;
    --hpc-toast-message-soft: #fbf0f8;
    --hpc-toast-info: #1c8fbd;
    --hpc-toast-info-soft: #eef8fc;
    --hpc-toast-warning: #f7941d;
    --hpc-toast-warning-soft: #fff7eb;
    --hpc-toast-danger: #ed1c24;
    --hpc-toast-danger-soft: #fff1f2;
    --hpc-toast-text: #152536;
    --hpc-toast-muted: #5b6b7d;
    --hpc-toast-border: #cfdce8;
    --hpc-toast-surface: #ffffff;
    --hpc-toast-shadow:
        0 18px 44px rgba(21, 37, 54, 0.16),
        0 4px 14px rgba(21, 37, 54, 0.10);
}

.hpc-toast-region {
    position: fixed;
    top: max(16px, env(safe-area-inset-top));
    right: max(16px, env(safe-area-inset-right));
    z-index: 2147483000;
    display: grid;
    width: min(430px, calc(100vw - 32px));
    gap: 12px;
    pointer-events: none;
}

.hpc-toast {
    --hpc-toast-tone: var(--hpc-toast-message);
    --hpc-toast-soft: var(--hpc-toast-message-soft);
    --hpc-toast-duration: 6000ms;

    position: relative;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 34px;
    gap: 12px;
    align-items: start;
    min-height: 86px;
    padding: 15px 14px 17px 16px;
    overflow: hidden;
    color: var(--hpc-toast-text);
    background:
        linear-gradient(90deg, var(--hpc-toast-soft), var(--hpc-toast-surface) 34%);
    border: 1px solid color-mix(in srgb, var(--hpc-toast-tone) 32%, var(--hpc-toast-border));
    border-radius: 14px;
    box-shadow: var(--hpc-toast-shadow);
    pointer-events: auto;
    isolation: isolate;
    animation: hpc-toast-enter 220ms ease-out both;
}

.hpc-toast::after {
    position: absolute;
    inset: 0;
    z-index: -1;
    content: "";
    background: linear-gradient(
        115deg,
        color-mix(in srgb, var(--hpc-toast-tone) 5%, transparent),
        transparent 42%
    );
    pointer-events: none;
}

.hpc-toast--success {
    --hpc-toast-tone: var(--hpc-toast-success);
    --hpc-toast-soft: var(--hpc-toast-success-soft);
}

.hpc-toast--message {
    --hpc-toast-tone: var(--hpc-toast-message);
    --hpc-toast-soft: var(--hpc-toast-message-soft);
}

.hpc-toast--info {
    --hpc-toast-tone: var(--hpc-toast-info);
    --hpc-toast-soft: var(--hpc-toast-info-soft);
}

.hpc-toast--warning {
    --hpc-toast-tone: var(--hpc-toast-warning);
    --hpc-toast-soft: var(--hpc-toast-warning-soft);
}

.hpc-toast--danger {
    --hpc-toast-tone: var(--hpc-toast-danger);
    --hpc-toast-soft: var(--hpc-toast-danger-soft);
}

.hpc-toast__accent {
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    background: var(--hpc-toast-tone);
}

.hpc-toast__icon {
    display: inline-grid;
    width: 42px;
    height: 42px;
    place-items: center;
    color: #ffffff;
    font-size: 22px;
    font-weight: 900;
    line-height: 1;
    background: var(--hpc-toast-tone);
    border-radius: 12px;
    box-shadow: 0 7px 16px color-mix(in srgb, var(--hpc-toast-tone) 24%, transparent);
}

.hpc-toast__content {
    min-width: 0;
    padding-top: 1px;
}

.hpc-toast__heading {
    display: flex;
    gap: 8px;
    align-items: center;
    min-width: 0;
    margin-bottom: 4px;
}

.hpc-toast__title {
    overflow: hidden;
    color: color-mix(in srgb, var(--hpc-toast-tone) 72%, #132333);
    font-size: 15px;
    font-weight: 800;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hpc-toast__counter {
    flex: 0 0 auto;
    min-width: 24px;
    padding: 2px 7px;
    color: #ffffff;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.25;
    text-align: center;
    background: var(--hpc-toast-tone);
    border-radius: 999px;
}

.hpc-toast__message {
    overflow-wrap: anywhere;
    color: var(--hpc-toast-text);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
    white-space: pre-line;
}

.hpc-toast__close {
    display: inline-grid;
    width: 32px;
    height: 32px;
    padding: 0;
    place-items: center;
    color: var(--hpc-toast-muted);
    font: inherit;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    background: transparent;
    border: 0;
    border-radius: 9px;
}

.hpc-toast__close:hover,
.hpc-toast__close:focus-visible {
    color: var(--hpc-toast-text);
    background: color-mix(in srgb, var(--hpc-toast-tone) 12%, transparent);
    outline: none;
}

.hpc-toast__progress {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 5px;
    height: 4px;
    background: var(--hpc-toast-tone);
    transform-origin: left center;
    animation: hpc-toast-progress var(--hpc-toast-duration) linear both;
}

.hpc-toast[data-persistent="true"] .hpc-toast__progress {
    display: none;
}

.hpc-toast:hover .hpc-toast__progress,
.hpc-toast:focus-within .hpc-toast__progress {
    animation-play-state: paused;
}

.hpc-toast--leaving {
    animation: hpc-toast-leave 180ms ease-in both;
}

@keyframes hpc-toast-enter {
    from {
        opacity: 0;
        transform: translate3d(24px, -8px, 0) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
    }
}

@keyframes hpc-toast-leave {
    from {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
    }

    to {
        opacity: 0;
        transform: translate3d(28px, -4px, 0) scale(0.97);
    }
}

@keyframes hpc-toast-progress {
    from {
        transform: scaleX(1);
    }

    to {
        transform: scaleX(0);
    }
}

@media (max-width: 640px) {
    .hpc-toast-region {
        top: max(10px, env(safe-area-inset-top));
        right: max(10px, env(safe-area-inset-right));
        left: max(10px, env(safe-area-inset-left));
        width: auto;
    }

    .hpc-toast {
        grid-template-columns: 38px minmax(0, 1fr) 32px;
        gap: 10px;
        min-height: 78px;
        padding: 13px 11px 15px 13px;
        border-radius: 12px;
    }

    .hpc-toast__icon {
        width: 38px;
        height: 38px;
        border-radius: 10px;
    }

    .hpc-toast__title {
        font-size: 14px;
    }

    .hpc-toast__message {
        font-size: 13px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hpc-toast,
    .hpc-toast--leaving,
    .hpc-toast__progress {
        animation-duration: 1ms !important;
    }
}

html.dark .hpc-toast,
body.dark .hpc-toast,
[data-theme="dark"] .hpc-toast {
    --hpc-toast-text: #edf5fb;
    --hpc-toast-muted: #a9bbca;
    --hpc-toast-border: #3b4d5e;
    --hpc-toast-surface: #172432;
    --hpc-toast-success-soft: #183322;
    --hpc-toast-message-soft: #35172f;
    --hpc-toast-info-soft: #153242;
    --hpc-toast-warning-soft: #3b2a16;
    --hpc-toast-danger-soft: #3d1a1d;

    background:
        linear-gradient(90deg, var(--hpc-toast-soft), var(--hpc-toast-surface) 42%);
}


.hpc-toast--pulse {
    animation:
        hpc-toast-pulse 260ms ease-out,
        hpc-toast-enter 1ms linear both;
}

@keyframes hpc-toast-pulse {
    0%,
    100% {
        transform: scale(1);
    }

    45% {
        transform: scale(1.025);
    }
}
