/* Compact XSSM toast system */

.toast-region {
    position: fixed;
    z-index: 20000;
    right: 0;
    bottom: calc(env(safe-area-inset-bottom, 0px) + clamp(16px, 2.4vh, 24px));
    left: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding-inline: 12px;
    pointer-events: none;
}

.toast-notification {
    --toast-tone: #a89cf6;
    position: relative;
    inset: auto;
    width: fit-content;
    min-width: 176px;
    max-width: min(360px, calc(100vw - 24px));
    min-height: 46px;
    display: grid;
    grid-template-columns: 28px minmax(0, auto) auto 22px;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    margin: 0;
    padding: 8px 8px 8px 9px;
    color: rgba(245, 243, 250, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.085);
    border-radius: 16px;
    background: linear-gradient(145deg, rgba(27, 30, 42, 0.91), rgba(15, 18, 28, 0.9));
    box-shadow:
        0 12px 30px rgba(2, 4, 12, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.055);
    -webkit-backdrop-filter: blur(24px) saturate(125%);
    backdrop-filter: blur(24px) saturate(125%);
    opacity: 0;
    transform: translateY(12px) scale(0.985);
    transform-origin: center bottom;
    transition:
        opacity 180ms ease,
        transform 320ms cubic-bezier(0.16, 1, 0.3, 1),
        border-color 160ms ease,
        background 160ms ease;
    pointer-events: auto;
}

.toast-notification.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    animation: toast-arrive 360ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.toast-notification.is-leaving {
    opacity: 0;
    transform: translateY(7px) scale(0.99);
    transition-duration: 160ms;
}

.toast-notification:hover,
.toast-notification:focus-within {
    border-color: rgba(255, 255, 255, 0.13);
    background: linear-gradient(145deg, rgba(31, 34, 47, 0.94), rgba(17, 20, 31, 0.93));
}

.toast-icon {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    color: var(--toast-tone);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.055);
}

.toast-icon > i {
    color: inherit;
    font-size: 0.68rem;
}

.toast-copy {
    min-width: 0;
    display: block;
}

.toast-repeat {
    min-width: 24px;
    padding: 3px 6px;
    color: var(--toast-tone);
    border: 1px solid color-mix(in srgb, var(--toast-tone) 24%, transparent);
    border-radius: 999px;
    background: color-mix(in srgb, var(--toast-tone) 9%, transparent);
    font-size: 0.58rem;
    font-weight: 780;
    line-height: 1;
    text-align: center;
}

.toast-repeat[hidden] {
    display: none;
}

.toast-notification.is-repeated {
    border-color: color-mix(in srgb, var(--toast-tone) 42%, rgba(255, 255, 255, 0.12));
    animation: toast-attention 560ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.toast-message {
    display: block;
    max-width: 100%;
    color: inherit;
    font-size: 0.76rem;
    font-weight: 540;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.toast-close {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    padding: 0;
    color: rgba(235, 232, 244, 0.3);
    border: 0;
    border-radius: 7px;
    background: transparent;
    cursor: pointer;
    transition:
        color 150ms ease,
        background 150ms ease,
        transform 150ms ease;
}

.toast-close:hover,
.toast-close:focus-visible {
    color: rgba(255, 255, 255, 0.86);
    background: rgba(255, 255, 255, 0.065);
    outline: none;
}

.toast-close:active {
    transform: scale(0.9);
}

.toast-close > i {
    font-size: 0.58rem;
}

.toast-success { --toast-tone: #69cba8; }
.toast-error { --toast-tone: #e9828f; }
.toast-warning { --toast-tone: #dcb66e; }
.toast-info { --toast-tone: #a89cf6; }

[data-theme="light"] .toast-notification {
    color: rgba(39, 36, 48, 0.88);
    border-color: rgba(48, 40, 72, 0.11);
    background: linear-gradient(145deg, rgba(250, 250, 253, 0.94), rgba(234, 236, 242, 0.93));
    box-shadow:
        0 12px 30px rgba(48, 42, 70, 0.14),
        inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

[data-theme="light"] .toast-notification:hover,
[data-theme="light"] .toast-notification:focus-within {
    border-color: rgba(48, 40, 72, 0.16);
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.97), rgba(238, 239, 245, 0.96));
}

[data-theme="light"] .toast-icon {
    background: rgba(48, 40, 72, 0.055);
}

[data-theme="light"] .toast-close {
    color: rgba(54, 49, 66, 0.3);
}

[data-theme="light"] .toast-close:hover,
[data-theme="light"] .toast-close:focus-visible {
    color: rgba(45, 41, 54, 0.82);
    background: rgba(48, 40, 72, 0.06);
}

@keyframes toast-arrive {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toast-attention {
    0%, 100% { transform: translateX(0) scale(1); }
    18% { transform: translateX(-3px) scale(1.012); }
    36% { transform: translateX(3px) scale(1.018); }
    54% { transform: translateX(-2px) scale(1.012); }
    72% { transform: translateX(1px) scale(1.006); }
}

@media (max-width: 560px) {
    .toast-notification {
        min-width: 164px;
        max-width: min(340px, calc(100vw - 24px));
    }
}

@media (prefers-reduced-motion: reduce) {
    .toast-notification,
    .toast-notification.show,
    .toast-notification.is-leaving,
    .toast-notification.is-repeated {
        animation: none;
        transition: opacity 100ms ease;
        transform: none;
    }
}
