/* Premium global toast + loading UI. Desktop and mobile are intentionally tuned separately. */
#uiLoadingBar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    z-index: 2147483646;
    pointer-events: none;
    opacity: 0;
    transform: scaleX(0);
    transform-origin: left center;
    background: linear-gradient(90deg, #111 0%, #777 48%, #111 100%);
    transition: opacity .2s ease;
}

#uiLoadingBar.is-loading {
    opacity: 1;
    animation: uiLoading 1.15s cubic-bezier(.4,0,.2,1) infinite;
}

#uiLoadingBar.is-done {
    opacity: 1;
    transform: scaleX(1);
    transition: transform .25s ease, opacity .35s ease .12s;
}

@keyframes uiLoading {
    0% { transform: translateX(-55%) scaleX(.28); }
    55% { transform: translateX(35%) scaleX(.68); }
    100% { transform: translateX(100%) scaleX(.32); }
}

#uiToastStack {
    position: fixed;
    top: 82px;
    right: 24px;
    width: min(390px, calc(100vw - 48px));
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 2147483645;
    pointer-events: none;
}

.ui-toast {
    position: relative;
    display: grid;
    grid-template-columns: 38px 1fr 28px;
    align-items: center;
    min-height: 66px;
    padding: 10px 12px 10px 10px;
    overflow: hidden;
    border: 1px solid rgba(17,17,17,.1);
    border-radius: 16px;
    background: rgba(255,255,255,.94);
    box-shadow: 0 18px 50px rgba(0,0,0,.16), 0 4px 12px rgba(0,0,0,.08);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    transform: translate3d(30px,-10px,0) scale(.96);
    opacity: 0;
    transition: transform .34s cubic-bezier(.22,1,.36,1), opacity .25s ease;
    pointer-events: auto;
}

.ui-toast.is-visible { transform: translate3d(0,0,0) scale(1); opacity: 1; }
.ui-toast.is-leaving { transform: translate3d(20px,-8px,0) scale(.97); opacity: 0; }

.ui-toast-icon {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    margin-left: 3px;
    border-radius: 50%;
    background: #111;
    color: #fff;
    font: 700 14px/1 Arial, sans-serif;
}
.ui-toast-success .ui-toast-icon { background: #111; }
.ui-toast-error .ui-toast-icon { background: #8b1e1e; }
.ui-toast-info .ui-toast-icon { background: #4a4a4a; }

.ui-toast-text {
    padding: 0 8px 0 4px;
    color: #171717;
    font: 600 13px/1.45 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: .01em;
}
.ui-toast-close {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #777;
    cursor: pointer;
    font-size: 21px;
    line-height: 1;
}
.ui-toast-close:hover { background: #f2f2f2; color: #111; }

.ui-toast-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    width: 100%;
    background: #111;
    transform-origin: left center;
    animation: uiToastProgress 3.2s linear forwards;
}
.ui-toast-error .ui-toast-progress { background: #8b1e1e; }

@keyframes uiToastProgress { from { transform: scaleX(1); } to { transform: scaleX(0); } }

@media (max-width: 750px) {
    #uiLoadingBar { height: 2px; }
    #uiToastStack {
        top: auto;
        right: 12px;
        bottom: calc(14px + env(safe-area-inset-bottom));
        left: 12px;
        width: auto;
        gap: 9px;
    }
    .ui-toast {
        grid-template-columns: 34px 1fr 28px;
        min-height: 60px;
        padding: 9px 9px 9px 8px;
        border-radius: 14px;
        transform: translate3d(0,20px,0) scale(.97);
    }
    .ui-toast.is-visible { transform: translate3d(0,0,0) scale(1); }
    .ui-toast.is-leaving { transform: translate3d(0,18px,0) scale(.97); }
    .ui-toast-icon { width: 28px; height: 28px; font-size: 13px; }
    .ui-toast-text { font-size: 12.5px; }
}

@media (min-width: 751px) {
    body { padding-top: 0; }
}
