@keyframes cart-badge-pop {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.35); }
}

.cart-badge.badge-pop { animation: cart-badge-pop .4s ease; }
/* Координаты привязки к нижнему меню выставляет cart.js. */
.cart-toast {
    position: fixed;
    left: 50%;
    bottom: calc(20px + env(safe-area-inset-bottom));
    z-index: 10002;
    display: flex;
    align-items: center;
    width: max-content;
    max-width: min(250px, calc(100vw - 20px));
    box-sizing: border-box;
    padding: 10px 13px;
    border: 1px solid #d6e6f3;
    border-radius: 14px;
    background: #fff;
    color: #153850;
    font: 500 13px/1.3 system-ui, sans-serif;
    box-shadow: 0 8px 25px rgb(20 55 82 / 20%);
    pointer-events: none;
    opacity: 0;
    --toast-shift: -50%;
    transform: translate(var(--toast-shift), 8px);
    transition: opacity .18s ease, transform .18s ease;
}
.cart-toast--anchored {
    left: var(--toast-left);
    bottom: var(--toast-bottom);
    --toast-shift: 0px;
}
.cart-toast--anchored::after {
    position: absolute;
    bottom: -6px;
    left: clamp(12px, var(--toast-arrow), calc(100% - 12px));
    width: 10px;
    height: 10px;
    border-right: 1px solid #d6e6f3;
    border-bottom: 1px solid #d6e6f3;
    background: #fff;
    content: '';
    transform: translateX(-50%) rotate(45deg);
}
.cart-toast.show { opacity: 1; transform: translate(var(--toast-shift), 0); }
.cart-toast strong { font-size: 15px; }
@media (prefers-reduced-motion: reduce) {
    .cart-toast { transition: none; }
    .cart-badge.badge-pop { animation: none; }
}

.cart-slot { display: block; margin-top: 10px; }
.cart-slot-add {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: 0;
    border-radius: 8px;
    background: #247fbd;
    color: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.cart-slot-add:hover { background: #1d72ad; }
.cart-slot-add:active { transform: scale(.98); }
.cart-slot-qty {
    display: flex;
    align-items: stretch;
    overflow: hidden;
    border: 2px solid #247fbd;
    border-radius: 8px;
    background: #fff;
}
.cart-slot-qty button {
    flex: 0 0 36px;
    padding: 0;
    border: 0;
    background: #f1f7fc;
    color: #145b95;
    font-family: inherit;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: background .15s;
}
.cart-slot-qty button:hover { background: #d3e4f2; }
.cart-slot-qty button:active { background: #cce1f2; }
.cart-slot-value {
    display: flex;
    flex: 1;
    min-width: 40px;
    align-items: center;
    justify-content: center;
    padding: 6px 4px;
    color: #145b95;
    font-size: 14px;
    font-weight: 700;
}

/* Компактное управление корзиной прямо поверх фото товара. */
.cart-slot--image {
    position: absolute;
    z-index: 1;
    right: 9px;
    bottom: 9px;
    width: auto;
    margin: 0;
}
.cart-slot--image.cart-slot--filled { right: 9px; left: 9px; width: auto; }
.cart-slot--image .cart-slot-add {
    display: grid;
    width: 40px;
    height: 40px;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: 15px;
    background: rgba(255, 255, 255, .97);
    color: #182b35;
    font-size: 23px;
    font-weight: 300;
    line-height: 1;
    box-shadow: 0 2px 10px rgba(30, 45, 55, .07);
}
.cart-slot--image .cart-slot-add:hover,
.cart-slot--image .cart-slot-add:active { background: #fff; color: #1769aa; }
.cart-slot--image .cart-slot-qty {
    display: flex;
    width: 100%;
    min-height: 40px;
    align-items: center;
    border: 0;
    border-radius: 15px;
    background: rgba(255, 255, 255, .97);
    box-shadow: 0 2px 10px rgba(30, 45, 55, .07);
}
.cart-slot--image .cart-slot-qty button {
    flex: 1 1 0;
    min-width: 34px;
    height: 40px;
    border-radius: 14px;
    background: transparent;
    color: #182b35;
    font-size: 21px;
    font-weight: 400;
}
.cart-slot--image .cart-slot-qty button:hover,
.cart-slot--image .cart-slot-qty button:active { background: #f1f4f5; }
.cart-slot--image .cart-slot-value {
    flex: 0 1 auto;
    min-width: 30px;
    padding: 4px 3px;
    color: #182b35;
    font-size: 16px;
    font-weight: 600;
}

.cart-overlay {
    position: fixed;
    z-index: 10000;
    inset: 0;
    background: rgb(0 0 0 / 40%);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}
.cart-overlay.open { opacity: 1; pointer-events: auto; }
.cart-panel {
    position: fixed;
    z-index: 10001;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    width: 700px;
    max-width: 100vw;
    flex-direction: column;
    background: #fff;
    box-shadow: -4px 0 24px rgb(0 0 0 / 15%);
    transform: translateX(100%);
    transition: transform .25s;
}
.cart-panel.open { transform: translateX(0); }
.cart-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #eee;
}
.cart-panel-head h2 { margin: 0; font-size: 25px; font-weight: 700; }
.cart-panel-head-actions { display: flex; align-items: center; gap: 15px; }
.cart-clear-top { padding: 5px 0; border: 0; background: transparent; color: #9aa0a6; font: inherit; font-size: 16px; cursor: pointer; }
.cart-clear-top:hover { color: #56616b; }
.cart-close { padding: 0 5px; border: 0; background: none; color: #666; font-size: 25px; line-height: 1; cursor: pointer; }
.cart-items { flex: 1; overflow-y: auto; padding: 8px 18px; }
.cart-empty { padding: 40px 10px; color: #888; font-size: 14px; text-align: center; }
.cart-item {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    padding: 12px 4px;
}
.cart-item-thumb { display: grid; width: 82px; height: 82px; place-items: center; overflow: hidden; border-radius: 15px; background: #f5f6f8; color: #91a0aa; }
.cart-item-image { display: block; width: 100%; height: 100%; object-fit: contain; }
.cart-item-no-image { display: none; font-size: 20px; }
.cart-item-thumb.is-missing .cart-item-no-image { display: grid; place-items: center; }
.cart-item-main { min-width: 0; }
.cart-item-heading { display: flex; min-height: 27px; align-items: flex-start; justify-content: space-between; gap: 8px; }
.cart-item-name { display: -webkit-box; overflow: hidden; font-size: 17px; font-weight: 500; line-height: 1.3; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.cart-item-price { margin-top: 6px; color: #78818a; font-size: 14px; }
.cart-item-sum { margin-top: 3px; color: #1769aa; font-size: 18px; font-weight: 700; }
.cart-item-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cart-item-prices { min-width: 0; }
.cart-item-qty { display: flex; flex: 0 0 auto; height: 48px; align-items: center; gap: 8px; }
.cart-item-qty button {
    width: 48px;
    height: 48px;
    border: 1px solid #dce2e8;
    border-radius: 10px;
    background: #fff;
    color: #142833;
    font-size: 25px;
    line-height: 1;
    cursor: pointer;
}
.cart-item-qty button:hover { background: #f5f7f9; }
.cart-item-qty input { width: 80px; height: 48px; padding: 0; border: 1px solid #dce2e8; border-radius: 10px; outline: 0; background: #fff; color: #142833; font-size: 21px; font-weight: 500; text-align: center; appearance: textfield; }
.cart-item-qty input::-webkit-inner-spin-button,.cart-item-qty input::-webkit-outer-spin-button { margin: 0; appearance: none; }
.cart-item-remove { flex: 0 0 auto; width: 24px; height: 24px; margin: -2px 0 0; padding: 0; border: 0; background: transparent; color: #d43131; font-size: 25px; font-weight: 300; line-height: 1; cursor: pointer; }
.cart-item-remove:hover { color: #a81818; }
.cart-panel-foot { padding: 15px 18px 20px; border-top: 1px solid #f0f1f3; background: #fff; }
.cart-delivery { margin-bottom: 10px; padding: 16px 18px 13px; border-radius: 26px 26px 0 0; background: #e7f7f7; color: #273a40; }
.cart-delivery[hidden] { display: none; }
.cart-delivery-copy { display: flex; align-items: center; gap: 7px; min-height: 30px; font-size: 15px; }
.cart-delivery-copy>span:first-child { font-size: 17px; }
.cart-delivery-copy>b { padding: 4px 9px; border-radius: 18px; background: #26383d; color: #fff; font-size: 14px; white-space: nowrap; }
.cart-delivery-copy>span:nth-of-type(2) { font-size: 14px; }
.cart-delivery-info { margin-left: auto; padding: 0 4px; border: 0; background: none; color: #96a6aa; font-size: 19px; cursor: help; }
.cart-delivery-progress { height: 8px; margin-top: 11px; overflow: hidden; border-radius: 10px; background: #c7dedf; }
.cart-delivery-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: #ffc52f; transition: width .2s ease; }
.checkout { display: flex; width: 100%; min-height: 68px; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 20px; border: 0; border-radius: 24px; background: #5b9fd4; color: #fff; font: inherit; font-size: 20px; font-weight: 600; cursor: pointer; }
.checkout strong { font-size: 19px; white-space: nowrap; }
.checkout strong b { font-weight: 600; }
.checkout:hover { filter: brightness(.97); }
.checkout:disabled { cursor: not-allowed; opacity: .55; }

@media (max-width: 520px) {
    .cart-panel-head { padding: 17px 17px; }
    .cart-panel-head h2 { font-size: 22px; }
    .cart-items { padding: 8px 12px; }
    .cart-item { grid-template-columns: 64px minmax(0, 1fr); gap: 8px; padding: 10px 2px; }
    .cart-item-thumb { width: 64px; height: 64px; border-radius: 13px; }
    .cart-item-name { font-size: 14px; }
    .cart-item-price { margin-top: 3px; font-size: 12px; }
    .cart-item-sum { font-size: 16px; }
    .cart-item-bottom { align-items: flex-end; gap: 7px; }
    .cart-item-qty { height: 38px; gap: 4px; }
    .cart-item-qty button { width: 32px; height: 38px; border-radius: 8px; font-size: 20px; }
    .cart-item-qty input { width: 42px; height: 38px; border-radius: 8px; font-size: 16px; }
    .cart-item-remove { font-size: 22px; }
    .cart-panel-foot { padding: 10px 12px calc(14px + env(safe-area-inset-bottom)); }
    .cart-delivery { padding: 12px 13px 10px; border-radius: 20px 20px 0 0; }
    .cart-delivery-copy { flex-wrap: wrap; gap: 5px; font-size: 13px; }
    .cart-delivery-copy>span:first-child { font-size: 14px; }
    .cart-delivery-copy>b { padding: 3px 7px; font-size: 12px; }
    .cart-delivery-copy>span:nth-of-type(2) { font-size: 12px; }
    .checkout { min-height: 58px; padding: 12px 15px; border-radius: 19px; font-size: 17px; }
    .checkout strong { font-size: 15px; }
}
