/* Global save loading overlay & feedback toasts */

body.rl-save-active {
    overflow: hidden;
}

.rl-save-overlay {
    position: fixed;
    inset: 0;
    z-index: 2005;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.28s ease, visibility 0.28s ease;
}

.rl-save-overlay.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.rl-save-overlay__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.rl-save-overlay__panel {
    position: relative;
    z-index: 1;
    width: min(100%, 380px);
    padding: 2rem 1.75rem 1.65rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid rgba(37, 99, 235, 0.18);
    box-shadow:
        0 24px 64px rgba(15, 23, 42, 0.22),
        0 0 0 1px rgba(255, 255, 255, 0.6) inset;
    text-align: center;
    transform: translateY(12px) scale(0.97);
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.rl-save-overlay.is-visible .rl-save-overlay__panel {
    transform: translateY(0) scale(1);
}

.rl-save-overlay__spinner {
    position: relative;
    width: 72px;
    height: 72px;
    margin: 0 auto 1.25rem;
}

.rl-save-overlay__ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid rgba(37, 99, 235, 0.12);
}

.rl-save-overlay__ring--spin {
    border-top-color: #2563eb;
    border-right-color: #1d4ed8;
    animation: rlSaveSpin 0.85s linear infinite;
}

.rl-save-overlay__ring--pulse {
    inset: 10px;
    border-color: rgba(37, 99, 235, 0.28);
    animation: rlSavePulse 1.6s ease-in-out infinite;
}

.rl-save-overlay__core {
    position: absolute;
    inset: 22px;
    border-radius: 50%;
    background: linear-gradient(135deg, #60a5fa 0%, #2563eb 55%, #1d4ed8 100%);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
    animation: rlSaveCore 1.2s ease-in-out infinite;
}

.rl-save-overlay__title {
    font-size: 1.05rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.01em;
    margin-bottom: 0.35rem;
}

.rl-save-overlay__hint {
    font-size: 0.875rem;
    color: #64748b;
    line-height: 1.45;
    margin-bottom: 1.1rem;
}

.rl-save-overlay__bar {
    height: 4px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.1);
    overflow: hidden;
}

.rl-save-overlay__bar-fill {
    display: block;
    height: 100%;
    width: 38%;
    border-radius: inherit;
    background: linear-gradient(90deg, #60a5fa, #2563eb, #1d4ed8, #60a5fa);
    background-size: 200% 100%;
    animation: rlSaveBar 1.15s ease-in-out infinite;
}

@keyframes rlSaveSpin {
    to { transform: rotate(360deg); }
}

@keyframes rlSavePulse {
    0%, 100% { transform: scale(1); opacity: 0.55; }
    50% { transform: scale(1.06); opacity: 1; }
}

@keyframes rlSaveCore {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(0.92); }
}

@keyframes rlSaveBar {
    0% { transform: translateX(-120%); background-position: 0% 50%; }
    100% { transform: translateX(280%); background-position: 100% 50%; }
}

/* ── Toasts ── */
.rl-toast-stack {
    position: fixed;
    top: calc(4.5rem + env(safe-area-inset-top, 0px));
    right: max(1rem, env(safe-area-inset-right, 0px));
    z-index: 2010;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    width: min(420px, calc(100vw - 2rem));
    pointer-events: none;
}

.rl-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 0.95rem 1rem 0.95rem 0.95rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow:
        0 16px 40px rgba(15, 23, 42, 0.14),
        0 0 0 1px rgba(255, 255, 255, 0.7) inset;
    animation: rlToastIn 0.38s cubic-bezier(0.22, 1, 0.36, 1);
    transform-origin: top right;
}

.rl-toast.is-leaving {
    animation: rlToastOut 0.28s ease forwards;
}

.rl-toast__icon {
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 800;
    line-height: 1;
}

.rl-toast__body {
    flex: 1;
    min-width: 0;
    padding-top: 0.1rem;
}

.rl-toast__title {
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    margin-bottom: 0.2rem;
}

.rl-toast__message {
    font-size: 0.9rem;
    line-height: 1.45;
    color: #334155;
    margin: 0;
}

.rl-toast__close {
    flex-shrink: 0;
    width: 1.75rem;
    height: 1.75rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #94a3b8;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.rl-toast__close:hover {
    background: rgba(15, 23, 42, 0.06);
    color: #475569;
}

.rl-toast--success {
    border-left: 4px solid #16a34a;
}

.rl-toast--success .rl-toast__icon {
    background: rgba(22, 163, 74, 0.12);
    color: #15803d;
}

.rl-toast--success .rl-toast__title {
    color: #15803d;
}

.rl-toast--error {
    border-left: 4px solid #dc2626;
}

.rl-toast--error .rl-toast__icon {
    background: rgba(220, 38, 38, 0.1);
    color: #b91c1c;
}

.rl-toast--error .rl-toast__title {
    color: #b91c1c;
}

.rl-toast--warning {
    border-left: 4px solid #d97706;
}

.rl-toast--warning .rl-toast__icon {
    background: rgba(217, 119, 6, 0.12);
    color: #b45309;
}

.rl-toast--warning .rl-toast__title {
    color: #b45309;
}

@keyframes rlToastIn {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes rlToastOut {
    to {
        opacity: 0;
        transform: translateY(-8px) scale(0.96);
    }
}

@media (max-width: 575.98px) {
    .rl-toast-stack {
        left: max(1rem, env(safe-area-inset-left, 0px));
        right: max(1rem, env(safe-area-inset-right, 0px));
        width: auto;
    }

    .rl-save-overlay__panel {
        padding: 1.65rem 1.25rem 1.35rem;
    }
}

/* ── Dark theme ── */
html[data-theme="dark"] .rl-save-overlay__panel,
[data-theme="dark"] .rl-save-overlay__panel {
    background: rgba(30, 41, 59, 0.97);
    border-color: rgba(96, 165, 250, 0.28);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] .rl-save-overlay__title,
[data-theme="dark"] .rl-save-overlay__title {
    color: #f1f5f9;
}

html[data-theme="dark"] .rl-save-overlay__hint,
[data-theme="dark"] .rl-save-overlay__hint {
    color: #94a3b8;
}

html[data-theme="dark"] .rl-toast,
[data-theme="dark"] .rl-toast {
    background: rgba(30, 41, 59, 0.98);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .rl-toast__message,
[data-theme="dark"] .rl-toast__message {
    color: #cbd5e1;
}

html[data-theme="dark"] .rl-toast__close:hover,
[data-theme="dark"] .rl-toast__close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
}
