:root {
    --ksy-toast-primary: var(--ksy-blue, #007aff);
    --ksy-toast-success: var(--ksy-green, #2ecc71);
    --ksy-toast-error: var(--ksy-red, #e74c3c);
    --ksy-toast-warning: var(--ksy-orange, #f39c12);
    --ksy-toast-info: var(--ksy-blue, #3498db);
    --ksy-toast-bg: #ffffff;
    --ksy-toast-text: #ffffff;
    --ksy-toast-text-muted: rgba(255, 255, 255, 0.9);
    --ksy-toast-border: rgba(255, 255, 255, 0.1);
    --ksy-toast-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    --ksy-toast-radius: var(--ksy-radius, 6px);
    --ksy-toast-transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --ksy-toast-gap: 12px;
    --ksy-toast-padding: 16px;
    --ksy-toast-min-width: 280px;
    --ksy-toast-max-width: 380px;
    --ksy-toast-close-size: 20px;
    --ksy-toast-close-color: rgba(255, 255, 255, 0.6);
    --ksy-toast-close-hover: #ffffff;
    --ksy-toast-z-index: 10000;
}

/* Уникальный префикс ksy-toast- */
.ksy-toast-shell {
    position: fixed;
    top: calc(20px + env(safe-area-inset-top));
    right: 20px;
    z-index: var(--ksy-toast-z-index);
    display: flex;
    flex-direction: column;
    gap: var(--ksy-toast-gap);
    pointer-events: none;
}

.ksy-toast-item {
    position: relative;
    min-width: var(--ksy-toast-min-width);
    max-width: var(--ksy-toast-max-width);
    padding: var(--ksy-toast-padding);
    border-radius: var(--ksy-toast-radius);
    box-shadow: var(--ksy-toast-shadow);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    pointer-events: auto;
    transform: translateX(130%);
    transition: var(--ksy-toast-transition);
    color: var(--ksy-toast-text);
    border: 1px solid var(--ksy-toast-border);
    font-family: inherit;
}

.ksy-toast-item.is-visible {
    transform: translateX(0);
}

.ksy-toast-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-left: 30px; /* Место для иконки слева */
    position: relative;
}

.ksy-toast-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 12px;
    flex-shrink: 0;
    position: absolute;
    top: 2px;
    left: 0;
}

.ksy-toast--light .ksy-toast-icon {
    background: rgba(0, 0, 0, 0.1);
}

.ksy-toast-title {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.2;
}

.ksy-toast-msg {
    font-size: 13px;
    opacity: 0.9;
    line-height: 1.4;
    word-break: break-word;
    color: var(--ksy-toast-text-muted);
}

.ksy-toast-close {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--ksy-toast-close-color);
    font-size: var(--ksy-toast-close-size);
    line-height: 1;
    padding: 0 2px;
    margin-top: -2px;
    flex-shrink: 0;
    transition: transform 0.2s ease, color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ksy-toast-close:hover {
    color: var(--ksy-toast-close-hover);
    transform: scale(1.2);
}

/* Модификаторы типов */
.ksy-toast--success { background-color: var(--ksy-toast-success); }
.ksy-toast--error   { background-color: var(--ksy-toast-error); }
.ksy-toast--warning { background-color: var(--ksy-toast-warning); }
.ksy-toast--info    { background-color: var(--ksy-toast-info); }

/* Дополнительные модификаторы */
.ksy-toast-item.ksy-toast--light {
    background-color: var(--ksy-toast-bg);
    color: var(--ksy-text, #1e293b);
    border: 1px solid var(--ksy-border, #e2e8f0);
    box-shadow: var(--ksy-shadow-2, 0 10px 24px rgba(2, 6, 23, 0.14));
}

.ksy-toast--light .ksy-toast-title {
    color: var(--ksy-text, #1e293b);
}

.ksy-toast--light .ksy-toast-msg {
    color: var(--ksy-muted, #64748b);
    opacity: 1;
}

.ksy-toast--light .ksy-toast-close {
    color: var(--ksy-muted, #64748b);
}

.ksy-toast--light .ksy-toast-close:hover {
    color: var(--ksy-text, #1e293b);
}

/* Позиционирование */
.ksy-toast-shell.ksy-toast--top-left {
    top: calc(20px + env(safe-area-inset-top));
    left: 20px;
    right: auto;
}

.ksy-toast-shell.ksy-toast--top-center {
    top: calc(20px + env(safe-area-inset-top));
    left: 50%;
    right: auto;
    transform: translateX(-50%);
}

.ksy-toast-shell.ksy-toast--bottom-right {
    top: auto;
    bottom: 20px;
    right: 20px;
    left: auto;
}

.ksy-toast-shell.ksy-toast--bottom-left {
    top: auto;
    bottom: 20px;
    left: 20px;
    right: auto;
}

.ksy-toast-shell.ksy-toast--bottom-center {
    top: auto;
    bottom: 20px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
}

/* Bottom-позиции: тосты появляются снизу вверх */
.ksy-toast-shell.ksy-toast--bottom-right .ksy-toast-item,
.ksy-toast-shell.ksy-toast--bottom-left .ksy-toast-item,
.ksy-toast-shell.ksy-toast--bottom-center .ksy-toast-item {
    transform: translateY(130%);
}
.ksy-toast-shell.ksy-toast--bottom-right .ksy-toast-item.is-visible,
.ksy-toast-shell.ksy-toast--bottom-left .ksy-toast-item.is-visible,
.ksy-toast-shell.ksy-toast--bottom-center .ksy-toast-item.is-visible {
    transform: translateY(0);
}

/* Top-center и bottom-center: левые позиции тянутся слева */
.ksy-toast-shell.ksy-toast--top-left .ksy-toast-item,
.ksy-toast-shell.ksy-toast--top-center .ksy-toast-item {
    transform: translateX(-130%);
}
.ksy-toast-shell.ksy-toast--top-left .ksy-toast-item.is-visible,
.ksy-toast-shell.ksy-toast--top-center .ksy-toast-item.is-visible {
    transform: translateX(0);
}

/* Темная тема */
[data-theme-dark] {
    --ksy-toast-bg: var(--ksy-card, #0f1a2e);
}

@media (max-width: 480px) {
    .ksy-toast-shell {
        right: 10px;
        left: 10px;
        top: calc(10px + env(safe-area-inset-top));
    }
    .ksy-toast-item {
        max-width: none;
        min-width: 0;
    }
}
