.cart-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: #ffffff;
  font-size: 14px;
  box-shadow: none;
  position: relative;
  width: 48px;
  height: 48px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cart-link:hover {
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.cart-link__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: transparent;
  border-radius: inherit;
  border: none;
  box-shadow: none;
  outline: none;
}

.cart-link__img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  transition: transform 0.15s ease;
}


.cart-link__icon .bi {
  font-size: 22px;
  line-height: 1;
  color: var(--text-main, #0b0e14);
  transition: transform 0.15s ease;
}

.cart-link:hover .cart-link__img,
.cart-link:hover .cart-link__icon .bi {
  filter: contrast(1.08);
}

.cart-count {
  position: absolute;
  top: -6px;
  right: -6px;
  transform: translate(0, 0);
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent-color);
  color: #111111;
  border: 1px solid #111111;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.16);
}

.cart-modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--motion-base, 220ms) var(--motion-ease, ease);
}

.cart-modal-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.cart-modal {
  background-color: #ffffff;
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.4);
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  transform: translateY(24px) scale(0.98);
  transition: transform var(--motion-slow, 320ms) var(--motion-ease, ease);
  will-change: transform;
}

.cart-modal-overlay.is-open .cart-modal {
  transform: translateY(0) scale(1);
}

.cart-modal-overlay.is-closing .cart-modal {
  transform: translateY(24px);
}

.cart-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.cart-modal__title {
  font-size: 18px;
  font-weight: 600;
}

.cart-modal__close {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  padding: 4px 6px;
}

.cart-modal__body {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
  margin-bottom: 10px;
}

.cart-modal__footer {
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.cart-modal__total {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 14px;
}

.cart-modal__total span:last-child {
  font-weight: 600;
  font-size: 16px;
}

.cart-modal__footer-cta {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.cart-modal__checkout {
  white-space: nowrap;
}

.cart-modal__min-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cart-modal__min-hint {
  font-size: 13px;
}

.cart-modal__checkout--secondary {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: #111111;
}

.cart-modal__checkout--secondary:hover {
  background: #f6f6f8;
}

.cart-modal__items {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
}

.cart-modal__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.cart-modal__row:last-child {
  border-bottom: none;
}

.cart-modal__row-image {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--border-subtle);
}

.cart-modal__row-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cart-modal__row-info {
  flex: 1;
  min-width: 0;
}

.cart-modal__row-name {
  font-weight: 500;
  margin-bottom: 2px;
}

.cart-modal__row-meta {
  font-size: 13px;
  color: var(--text-muted);
}

.cart-modal__row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}


.cart-modal__qty {
  display: flex;
  align-items: stretch;
  gap: 0;
  flex-shrink: 0;
  border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.12));
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.cart-modal__qty-form {
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
  margin: 0;
}

.cart-modal__qty-btn {
  width: 36px;
  min-width: 36px;
  min-height: 40px;
  border: none;
  border-radius: 0;
  background: #f0f0f3;
  font-size: 18px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--text-main, #101010);
  -webkit-tap-highlight-color: transparent;
}

.cart-modal__qty-btn:hover {
  background: #e4e4e8;
}

.cart-modal__qty-btn:active {
  background: #d8d8de;
}

.cart-modal__qty-btn--step {
  width: 36px;
  font-size: 14px;
}

.cart-modal__qty-input {
  box-sizing: border-box;
  
  flex: 0 0 auto;
  flex-shrink: 0;
  width: 5.5rem;
  min-width: 5.5rem;
  max-width: 8.5rem;
  text-align: center;
  font-weight: 600;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  padding: 9px 14px;
  border: none;
  border-left: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.1));
  border-right: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.1));
  border-radius: 0;
  background: #fafafb;
  color: var(--text-main, #101010);
  direction: ltr;
}

.cart-modal__qty-input:focus {
  outline: none;
  background: #fff;
}

.cart-modal__qty-input:focus-visible {
  outline: 2px solid var(--text-main, #111);
  outline-offset: -2px;
  z-index: 1;
  position: relative;
}

.cart-modal__qty-input::-webkit-outer-spin-button,
.cart-modal__qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.cart-modal__qty-input[type="number"] {
  -webkit-appearance: none;
  -moz-appearance: textfield;
  appearance: textfield;
}

.cart-modal__qty-num {
  min-width: 24px;
  text-align: center;
  font-weight: 500;
  font-size: 14px;
}

.cart-modal__remove-form {
  display: inline;
}

.cart-modal__remove-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px 0;
}

.cart-modal__remove-btn:hover {
  color: #c00;
}

.cart-modal__empty {
  font-size: 14px;
}

body.cart-open {
  overflow: hidden;
}

.cart-toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}

.cart-toast {
  padding: 12px 20px;
  background: #111111;
  color: #f7f7f9;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  max-width: 90vw;
  opacity: 0;
  transform: translateY(100%);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.cart-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.cart-toast.is-leaving {
  opacity: 0;
  transform: translateY(-8px);
}

.cart-toast--success {
  background: #2e7d32;
  color: #fff;
}

.cart-toast--error {
  background: #c62828;
  color: #fff;
}

.cart-toast--stacked {
  position: relative;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.2),
    0 4px 12px rgba(0, 0, 0, 0.15),
    0 2px 6px rgba(0, 0, 0, 0.1);
}

.cart-toast--stacked::after {
  content: "+" attr(data-stack-count);
  position: absolute;
  bottom: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

@media (max-width: 768px) {
  .cart-modal {
    max-width: 100%;
    border-radius: 18px 18px 0 0;
  }
}

@media (max-width: 480px) {
  .cart-link {
    width: 44px;
    height: 44px;
  }

  .cart-link__img {
    width: 24px;
    height: 24px;
  }

  .cart-count {
    min-width: 18px;
    height: 18px;
    font-size: 10px;
    top: -5px;
    right: -5px;
  }
}

.add-to-cart-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--motion-base, 220ms) var(--motion-ease, ease);
}

.add-to-cart-popup-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.add-to-cart-popup-overlay[hidden] {
  display: none !important;
}

.add-to-cart-popup {
  background: #ffffff;
  border-radius: 20px;
  padding: 24px 26px 26px;
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.04);
  max-width: 420px;
  width: 100%;
  position: relative;
  opacity: 0;
  transform: translateY(18px) scale(0.98);
  transition:
    opacity var(--motion-base, 220ms) var(--motion-ease, ease),
    transform var(--motion-slow, 320ms) var(--motion-ease, ease);
  will-change: transform, opacity;
}

.add-to-cart-popup-overlay.is-open .add-to-cart-popup {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.add-to-cart-popup-overlay.is-closing .add-to-cart-popup {
  opacity: 0;
  transform: translateY(18px) scale(0.98);
}

.add-to-cart-popup__title {
  margin-bottom: 18px;
  font-size: 20px;
  font-weight: 600;
  padding-right: 32px;
}

.add-to-cart-popup__product {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--bg-page, #f6f6f8);
  border-radius: 14px;
}

.add-to-cart-popup__product-img {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  object-fit: cover;
  background: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.add-to-cart-popup__product-info {
  min-width: 0;
  flex: 1;
}

.add-to-cart-popup__product-name {
  display: block;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 6px;
}

.add-to-cart-popup__hint {
  font-size: 12px;
  line-height: 1.4;
  margin: 0;
}

.add-to-cart-popup__tiers {
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--bg-page, #f6f6f8);
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.5;
}

.add-to-cart-popup__tiers[hidden] {
  display: none;
}

.add-to-cart-popup__tier-line {
  margin-bottom: 4px;
}

.add-to-cart-popup__tier-line:last-child {
  margin-bottom: 0;
}

.add-to-cart-popup__detail-link {
  display: inline-block;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--accent-color);
  text-decoration: underline;
  cursor: pointer;
}

.add-to-cart-popup__detail-link:hover {
  text-decoration: none;
}

.add-to-cart-popup__form {
  margin-bottom: 0;
}

.add-to-cart-popup__qty {
  margin-bottom: 18px;
}

.add-to-cart-popup__qty label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main, #101010);
}

.add-to-cart-popup__qty-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.add-to-cart-popup__qty-row input {
  width: auto;
  min-width: 4.5rem;
  max-width: 7rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  box-sizing: border-box;
}

.add-to-cart-popup__qty-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: #fff;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.add-to-cart-popup__qty-btn:hover {
  background: var(--bg-page, #f6f6f8);
  border-color: rgba(0, 0, 0, 0.12);
}

.add-to-cart-popup__qty input {
  padding: 10px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: 0;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.add-to-cart-popup__submit {
  width: 100%;
  padding: 12px 20px;
  font-size: 16px;
  border-radius: 12px;
}

.add-to-cart-popup__close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.add-to-cart-popup__close:hover {
  color: var(--text-main);
  background: var(--bg-page, #f6f6f8);
}


.product-qty-input,
.cart-modal__qty-input,
.order-checkout-qty-input,
input[data-add-to-cart-quantity] {
  border-radius: 0 !important;
  -webkit-border-radius: 0 !important;
}

.product-qty-input[type="number"],
.cart-modal__qty-input[type="number"],
.order-checkout-qty-input[type="number"],
input[type="number"][data-add-to-cart-quantity] {
  -webkit-appearance: none;
  -moz-appearance: textfield;
  appearance: textfield;
}
