.cart-layout {
  display: grid;
  gap: var(--sp-5);
  align-items: start;
}

.cart-list {
  display: grid;
  gap: var(--sp-3);
  margin: 0;
  padding: 0;
  list-style: none;
  container-type: inline-size;
}

.cart-item {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) auto;
  grid-template-areas:
    "image info total"
    "image qty remove";
  gap: 10px 12px;
  align-items: center;
  padding: var(--sp-3);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t-base), border-color var(--t-base);
}

.cart-item:hover {
  border-color: var(--c-border-strong, var(--c-border));
  box-shadow: var(--shadow-md);
}

.cart-item__image-link {
  grid-area: image;
  align-self: start;
  color: inherit;
  text-decoration: none;
}

.cart-item__img-wrap {
  width: 88px;
  height: 88px;
  overflow: hidden;
  border-radius: var(--r-md);
  background: var(--c-bg-alt);
}

.cart-item__img,
.cart-item__placeholder {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cart-item__info {
  grid-area: info;
  display: grid;
  gap: 4px;
  min-width: 0;
  align-content: center;
}

.cart-item__name {
  min-width: 0;
  color: var(--c-text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
  text-decoration: none;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.cart-item__name:hover,
.cart-item__name:focus-visible {
  color: var(--c-accent-dark);
}

.cart-item__price {
  color: var(--c-text-secondary);
  font-size: var(--fs-sm);
  white-space: nowrap;
}

.cart-item__qty {
  grid-area: qty;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  margin: 0;
  width: max-content;
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface);
}

.cart-item__qty-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 44px;
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--c-bg-alt);
  color: var(--c-text);
  font: inherit;
  font-size: var(--fs-lg);
  line-height: 1;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.cart-item__qty-btn:hover,
.cart-item__qty-btn:focus-visible {
  background: var(--c-accent-bg);
  color: var(--c-accent-dark);
}

.cart-item__qty-btn:disabled,
.cart-item__qty-btn:disabled:hover,
.cart-item__qty-btn:disabled:focus-visible {
  background: var(--c-bg-alt);
  color: var(--c-text-muted);
  cursor: default;
}

.cart-item__qty-value {
  min-width: 2.25rem;
  padding: 0 var(--sp-2);
  border-inline: 1px solid var(--c-border);
  background: var(--c-surface);
  font-size: 16px;
  font-weight: var(--fw-semibold);
  line-height: 44px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.cart-item__total {
  grid-area: total;
  justify-self: end;
  align-self: start;
  padding-top: 2px;
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cart-item__remove-form {
  grid-area: remove;
  justify-self: end;
  margin: 0;
}

.cart-item__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid #e8b4b4;
  border-radius: var(--r-md);
  background: var(--c-danger-light);
  color: var(--c-danger);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}

.cart-item__remove-label {
  display: none;
}

.cart-item__remove:hover,
.cart-item__remove:focus-visible {
  background: var(--c-danger);
  border-color: var(--c-danger);
  color: var(--c-text-inverse);
  outline: none;
}

.cart-summary {
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-5);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}

.cart-summary__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin: 0;
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--c-border);
  font-size: var(--fs-lg);
}

.cart-summary__row strong {
  font-variant-numeric: tabular-nums;
}

.cart-summary__min,
.cart-summary__hint {
  margin: 0;
  color: var(--c-text-secondary);
  font-size: var(--fs-sm);
  line-height: var(--lh-base);
}

.cart-summary__cta {
  width: 100%;
  min-height: 56px;
  margin-top: var(--sp-1);
}

.cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  min-height: min(60vh, calc(100dvh - var(--header-h) - 8rem));
  padding: var(--sp-6) var(--sp-4);
  text-align: center;
}

.cart-empty__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: var(--r-pill);
  background: var(--c-bg-alt);
  color: var(--c-text-muted);
}

.cart-empty__title {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  color: var(--c-text);
}

.cart-empty__text {
  margin: 0;
  max-width: 22rem;
  color: var(--c-text-secondary);
  line-height: var(--lh-base);
}

.cart-empty__cta {
  min-height: 56px;
  border-color: var(--c-text);
  border-radius: var(--r-lg);
  background: var(--c-text);
  color: var(--c-text-inverse);
}

.cart-empty__cta:hover,
.cart-empty__cta:focus-visible {
  background: var(--c-text);
  border-color: var(--c-text);
  color: var(--c-text-inverse);
  box-shadow: var(--shadow-md);
}

@media (min-width: 600px) {
  .cart-item {
    padding: var(--sp-4);
  }

  .cart-item__total {
    align-self: center;
    padding-top: 0;
  }

  .cart-item__remove {
    width: auto;
    min-width: 0;
    height: 44px;
    padding: 0 0.85rem;
  }

  .cart-item__remove-label {
    display: inline;
  }
}

@media (min-width: 768px) {
  .cart-item__img-wrap {
    width: 112px;
    height: 112px;
  }

  .cart-item {
    grid-template-columns: 112px minmax(0, 1fr) auto;
  }

  .cart-item__name {
    font-size: var(--fs-md);
  }
}

@container (min-width: 720px) {
  .cart-item {
    grid-template-columns: 112px minmax(8rem, 1fr) max-content max-content max-content;
    grid-template-areas: "image info qty total remove";
    gap: 12px 20px;
  }

  .cart-item__total {
    justify-self: end;
  }
}

@media (min-width: 900px) {
  .cart-layout {
    grid-template-columns: minmax(0, 1fr) 20rem;
  }

  .cart-summary {
    position: sticky;
    top: calc(var(--header-h) + var(--sp-4));
  }
}

@media (min-width: 1200px) {
  .cart-item {
    grid-template-columns: 112px minmax(8rem, 1fr) max-content max-content max-content;
    grid-template-areas: "image info qty total remove";
    gap: 12px 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cart-item,
  .cart-item__remove,
  .cart-empty__cta {
    transition: none;
  }
}
